📄 myinventory.lua
字号:
local columns, rows = MyInventoryColumns, ceil(frameSize / MyInventoryColumns);
local height, width = MyInventoryFrame_GetAppropriateHeight(rows), MyInventoryFrame_GetAppropriateWidth(columns);
MyInventoryFrame:SetHeight(height);
MyInventoryFrame:SetWidth(width);
MyInventory_SetGraphics(); -- Turn on or Off Blizzard Graphics
-- Border
local First_Y = -6 ;
-- Title
local show = false
if MyInventoryGraphics == 1 then -- -LITE{
show = true;
end -- }-LITE
if MyInventoryShowTitle==1 or MyInventoryButtons == 1 or show then
First_Y = First_Y - MYINVENTORY_TOP_HEIGHT;
end
-- BagButtons
MyInventoryBagButtonsBar:ClearAllPoints();
-- -LITE{
if MyInventoryGraphics == 1 then
if MyInventoryColumns == 5 then
First_Y = First_Y + MYINVENTORY_ITEM_OFFSET_Y;
MyInventoryBagButtonsBar:SetPoint("TOP", "MyInventoryFrame", "TOP", 0, First_Y);
else
MyInventoryBagButtonsBar:SetPoint("TOP", "MyInventoryFrame", "TOP", 20, First_Y);
First_Y = First_Y + MYINVENTORY_ITEM_OFFSET_Y;
end
else
-- }-LITE
MyInventoryBagButtonsBar:SetPoint("TOP", "MyInventoryFrame", "TOP", 0, First_Y);
end -- -LITE
if MyInventoryBagView == 1 then
if MyInventoryGraphics == 0 or MyInventoryColumns == 5 then -- -LITE
First_Y = First_Y + MYINVENTORY_ITEM_OFFSET_Y;
end -- -LITE
MyInventoryBagButtonsBar:Show();
else
MyInventoryBagButtonsBar:Hide();
end
local curCol;
if MyInventoryAIOIStyle==1 then
curCol=columns-(mod(frameSize, columns)-1);
if curCol>columns then
curCol=curCol-columns;
end
else
curCol=1;
end
local curRow=1;
for j=1, frameSize, 1 do
local itemButton = getglobal(name.."Item"..j);
itemButton:SetID(j);
-- Set first button
itemButton:ClearAllPoints();
local dx, dy, baseframe;
if ( j == 1 ) then
baseframe = name;
if MyInventoryAIOIStyle == 1 then
dx = (curCol-1)*MYINVENTORY_ITEM_OFFSET_X + MYINVENTORY_FIRST_ITEM_OFFSET_X;
dy = First_Y;
else
dx = MYINVENTORY_FIRST_ITEM_OFFSET_X;
dy = First_Y;
end
else
if ( mod((curCol+j-2), columns) == 0 ) then
baseframe = "MyInventoryFrame";
dx = MYINVENTORY_FIRST_ITEM_OFFSET_X;
dy = First_Y + MYINVENTORY_ITEM_OFFSET_Y*curRow;
curRow=curRow+1;
else
baseframe = name.."Item"..(j - 1);
dy = 0;
dx = MYINVENTORY_ITEM_OFFSET_X;
end
end
itemButton:SetPoint("TOPLEFT", baseframe, "TOPLEFT", dx, dy);
itemButton:Show();
end
local button = nil;
for i = frameSize+1, MYINVENTORY_MAX_ID do
button = getglobal("MyInventoryFrameItem"..i);
if ( button ) then
button:Hide();
end
end
end -- }}}
-- }}}
-- Get Height and Width {{{
function MyInventoryFrame_GetAppropriateHeight(rows) -- {{{
-- Border 6 on top, 6 on bottom
-- First row is 28 pixels down.
-- BASE_HEIGHT = 44
if MyInventoryGraphics == 1 then -- -LITE{
rows = rows+1;
end -- }-LITE
if MyInventoryBagView == 1 then
if MyInventoryGraphics == 0 or MyInventoryColumns == 5 then -- -LITE
rows = rows+1;
end -- -LITE
end
local height = 12;
if MyInventoryButtons==1 or MyInventoryShowTitle==1 or MyInventoryGraphics == 1 then
height = height + MYINVENTORY_TOP_HEIGHT;
end
if (MyInventoryCash==1) or (MyInventoryCount > -1) then
height = height + MYINVENTORY_BOTTOM_HEIGHT;
end
height = height + (-MYINVENTORY_ITEM_OFFSET_Y) * rows;
return height;
end -- }}}
function MyInventoryFrame_GetAppropriateWidth(cols) -- {{{
return 12 + ( MYINVENTORY_ITEM_OFFSET_X * cols );
end -- }}}
-- }}}
-- Get Bag Slots {{{
function MyInventory_GetBagsTotalSlots() -- {{{
local slots = 0;
for bag = 0, 4 do
slots = slots + GetContainerNumSlots(bag);
end
return slots;
end -- }}}
function MyInventory_GetBagsReplacingSlots() -- {{{
local slots = 0;
for bag = 0, 4 do
if MyInventory_ShouldOverrideBag(bag) then
slots = slots + GetContainerNumSlots(bag);
end
end
return slots;
end -- }}}
function MyInventory_GetIdAsBagSlot(id) -- {{{
-- depreciated
local button = getglobal("MyInventoryFrameItem"..id);
if button.bagIndex then
return button.bagIndex, button.itemIndex;
end
return -1,-1;
end -- }}}
-- }}}
function MyInventoryTitle_Update() -- {{{
if MyInventoryCash == 1 then
MyInventoryFrameMoneyFrame:Show();
else
MyInventoryFrameMoneyFrame:Hide();
end
MyInventorySlots_Update();
if MyInventoryShowTitle == 0 then
if MyInventoryGraphics == 0 then -- -LITE
MyInventoryFrameName:Hide();
return;
end -- -LITE
end
MyInventoryFrameName:Show();
if ( UnitName('player') ) then
local player, realm = UnitName('player'),MyInventory_Trim(GetCVar("realmName"));
if (MyInventoryColumns < 5 ) then
MyInventoryFrameName:SetText(MYINVENTORY_TITLE);
elseif (MyInventoryColumns < 7 ) then
if MyInventoryGraphics == 1 then -- -LITE
MyInventoryFrameName:SetText(MYINVENTORY_TITLE); -- -LITE
else -- -LITE
MyInventoryFrameName:SetText(format(MYINVENTORY_TITLE_S, player));
end -- -LITE
else
if MyInventoryGraphics == 1 and MyInventoryColumns < 9 then -- -LITE
MyInventoryFrameName:SetText(format(MYINVENTORY_TITLE_S, player)); -- -LITE
else -- -LITE
MyInventoryFrameName:SetText(format(MYINVENTORY_TITLE_SS,player, realm));
end -- -LITE
end
MyInventoryFrameName:SetTextColor(1.0, 1.0, 1.0);
end
end -- }}}
function MyInventorySlots_Update() -- {{{
local i, j, totalSlots= 0, 0, 0;
local takenSlots = 0;
for i = 0, 4 do
local slots = GetContainerNumSlots(i)
if MyInventory_ShouldOverrideBag(i) then
totalSlots = totalSlots + slots;
for j = 1, slots do
if GetContainerItemInfo(i,j) then
takenSlots=takenSlots + 1;
end
end
end
end
if MyInventoryCount == 0 then
MyInventoryFrameSlots:Show();
MyInventoryFrameSlots:SetText(format(MYINVENTORY_SLOTS_DD, (totalSlots-takenSlots),totalSlots));
elseif MyInventoryCount == 1 then
MyInventoryFrameSlots:Show();
MyInventoryFrameSlots:SetText(format(MYINVENTORY_SLOTS_DD, (takenSlots),totalSlots));
else
MyInventoryFrameSlots:Hide();
end
end -- }}}
function MyInventory_SetLock() -- {{{
if MyInventoryLock == 1 then
MILockNormalTexture:SetTexture("Interface\\AddOns\\AllInOneInventory\\Skin\\LockButton-Locked-Up");
else
MILockNormalTexture:SetTexture("Interface\\AddOns\\AllInOneInventory\\Skin\\LockButton-Unlocked-Up");
end
MyInventoryFrame:EnableMouse(1-MyInventoryLock);
end -- }}}
function MyInventory_ShowButtons() -- {{{
local show = false;
if MyInventoryGraphics == 1 then -- -LITE{
show = true
end -- }-LITE
if MyInventoryButtons == 1 or show then
MyInventoryFrameCloseButton:Show();
MyInventoryFrameLockButton:Show();
MyInventoryFrameHideBagsButton:Show();
else
MyInventoryFrameCloseButton:Hide();
MyInventoryFrameLockButton:Hide();
MyInventoryFrameHideBagsButton:Hide();
end
end -- }}}
function MyInventory_SetGraphics() -- {{{
-- -LITE{
if MyInventoryGraphics == 1 then
MyInventoryFrame:SetBackdropColor(0,0,0,0);
MyInventoryFrame:SetBackdropBorderColor(0,0,0,0);
MyInventoryFramePortrait:Show();
MyInventoryFrameTextureTopLeft:Show();
MyInventoryFrameTextureTopCenter:Show();
MyInventoryFrameTextureTopRight:Show();
MyInventoryFrameTextureLeft:Show();
MyInventoryFrameTextureCenter:Show();
MyInventoryFrameTextureRight:Show();
MyInventoryFrameTextureBottomLeft:Show();
MyInventoryFrameTextureBottomCenter:Show();
MyInventoryFrameTextureBottomRight:Show();
MyInventoryFrameName:ClearAllPoints();
MyInventoryFrameName:SetPoint("TOPLEFT", "MyInventoryFrame", "TOPLEFT", 70, -8);
MyInventoryFrameCloseButton:ClearAllPoints();
MyInventoryFrameCloseButton:SetPoint("TOPRIGHT", "MyInventoryFrame", "TOPRIGHT", 10, 0);
else -- }-LITE
if MyInventoryBackground==1 then
MyInventoryFrame:SetBackdropColor(0,0,0,1.0);
MyInventoryFrame:SetBackdropBorderColor(1,1,1,1.0);
else
MyInventoryFrame:SetBackdropColor(0,0,0,0);
MyInventoryFrame:SetBackdropBorderColor(1,1,1,0);
end
MyInventoryFramePortrait:Hide();
MyInventoryFrameTextureTopLeft:Hide();
MyInventoryFrameTextureTopCenter:Hide();
MyInventoryFrameTextureTopRight:Hide();
MyInventoryFrameTextureLeft:Hide();
MyInventoryFrameTextureCenter:Hide();
MyInventoryFrameTextureRight:Hide();
MyInventoryFrameTextureBottomLeft:Hide();
MyInventoryFrameTextureBottomCenter:Hide();
MyInventoryFrameTextureBottomRight:Hide();
MyInventoryFrameName:ClearAllPoints();
MyInventoryFrameName:SetPoint("TOPLEFT", "MyInventoryFrame", "TOPLEFT", 5, -6);
MyInventoryFrameCloseButton:ClearAllPoints();
MyInventoryFrameCloseButton:SetPoint("TOPRIGHT", "MyInventoryFrame", "TOPRIGHT", 2, 2);
end -- -LITE
end -- }}}
-- }}}
function MyInventoryFrame_Update(frame) --- {{{
local frame = getglobal("MyInventoryFrame");
MyInventoryFrame_UpdateLookIfNeeded();
local name = frame:GetName();
local index = 0;
MyInventorySlots_Update();
local altbag=0; -- Even or odd bag
for bag=0, 4 do
if MyInventory_ShouldOverrideBag(bag) and GetContainerNumSlots(bag)>0 then
altbag=math.abs(altbag-1); -- Even or odd (couting the replaced ones only)
for slot=1, GetContainerNumSlots(bag) do
index = index + 1;
local itemButton = getglobal(name.."Item"..index);
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(bag, slot);
itemButton.bagIndex = bag; itemButton.itemIndex = slot; -- Save the slot and bag, MUCH easier then looking it up every time.
if not texture and MyInventoryGraphics==1 then -- -LITE{
SetItemButtonTexture(itemButton, "Interface\\AddOns\\AllInOneInventory\\Skin\\blank");
else -- }-LITE
SetItemButtonTexture(itemButton, texture);
end -- -LITE
SetItemButtonCount(itemButton, itemCount);
SetItemButtonDesaturated(itemButton, locked, 0.5, 0.5, 0.5);
local color = { ["r"]=0.5, ["g"]=0.5, ["b"]=0.5 };
if (MyInventoryItemBorder == 1) and ( quality and quality >= 2 ) then
if quality == 3 then
color = { ["r"]=0.0,["g"]=0.0,["b"]=1.0}
elseif quality == 2 then
color = { ["r"]=0.0,["g"]=1.0,["b"]=0.0}
elseif quality == 4 then
color = { ["r"]=1.0,["g"]=0.0,["b"]=1.0}
else
color = { ["r"]=1.0,["g"]=0.7,["b"]=0.0}
end
elseif MyInventoryItemBorder == 2 then
if altbag == 0 then
color = { ["r"]=0.0,["g"]=0.0,["b"]=1.0}
else
color = { ["r"]=0.0,["g"]=1.0,["b"]=0.0}
end
end
SetItemButtonNormalTextureVertexColor(itemButton, color.r, color.g, color.b);
-- If it is a Quiver/AmmoBag
if ( string.find(GetBagName(bag), "Quiver") or string.find(GetBagName(bag), "Ammo") ) then
SetItemButtonNormalTextureVertexColor(itemButton, 1.0, 1.0, 0.0);
end
if ( texture ) then
local cooldown = getglobal(itemButton:GetName().."Cooldown");
local start, duration, enable = GetContainerItemCooldown(bag, slot);
CooldownFrame_SetTimer(cooldown, start, duration, enable);
if ( duration > 0 and enable == 0 ) then
SetItemButtonTextureVertexColor(button, 0.4, 0.4, 0.4);
end
else
getglobal(name.."Item"..index.."Cooldown"):Hide();
end
itemButton.readable = readable;
local showSell = nil;
if ( GameTooltip:IsOwned(itemButton) ) then
if ( texture ) then
local hasCooldown, repairCost = GameTooltip:SetBagItem(bag, slot);
if ( hasCooldown ) then
itemButton.updateTooltip = TOOLTIP_UPDATE_TIME;
else
itemButton.updateTooltip = nil;
end
if ( InRepairMode() and (repairCost > 0) ) then
GameTooltip:AddLine(TEXT(REPAIR_COST), "", 1, 1, 1);
SetTooltipMoney(GameTooltip, repairCost);
GameTooltip:Show();
elseif ( MerchantFrame:IsVisible() and not locked) then
showSell = 1;
end
else
GameTooltip:Hide();
end
if ( showSell ) then
ShowContainerSellCursor(bag, slot);
elseif ( readable ) then
ShowInspectCursor();
else
ResetCursor();
end
end
end
end
end
end -- }}}
--[[glim reg]]
function AllInOne_Register()
gLim_RegisterButton (
"All in one",
"整合包裹",
"Interface\\AddOns\\AllInOneInventory\\Icon",
function()
gLimModSecBookShowConfig("gLimAllInOne");
end,
3,
8
);
gLim_RegisterConfigClass("gLimAllInOne","All in one","CraZy aPpLe");
gLim_RegisterConfigSection("gLimAllInOneSection","整合包裹","整合包裹 Modified CraZy aPpLe(gLim)","CraZy aPpLe","gLimAllInOne");
gLim_RegisterConfigCheckBox(
"gLim_AllInOne_IsReplace",
"替换系统包裹",
"用整合包裹代替系统默认的包裹",
MyInventoryProfile[PlayerName]["replace"],
AllInOne_IsReplace,
"gLimAllInOne"
);
gLim_RegisterConfigCheckBox(
"gLim_AllInOne_IsInclude",
"优质物品提示",
"物品边框颜色根据稀有度改变",
MyInventoryProfile[PlayerName]["ItemBorder"],
AllInOne_IsGood,
"gLimAllInOne"
);
gLim_RegisterConfigSlider(
"gLim_AllInOne_Cols",
"设置大包裹样式",
"设置大包裹每行显示的格数",
"格数(5-18)",
"",
1,
5,
18,
MyInventoryColumns,
AllInOne_Cols,
"gLimAllInOne"
);
gLim_RegisterConfigSlider(
"gLim_AllInOne_Alpha",
"设置大包裹尺寸",
"尺寸设置",
"缩放(0.5-1.5)",
"",
0.01,
0.5,
1.5,
MyInventoryScale,
AllInOne_Scale,
"gLimAllInOne"
);
gLim_RegisterConfigButton(
"gLim_AllInOne_Options",
"整合包裹细节设置",
"整合包裹的各种细节设置",
"详细设置",
function()
ShowUIPanel(MyInventoryOptionsFrame);
gLimConfigSubFrame:Hide();
end,
"gLimAllInOne"
);
end
function AllInOne_IsReplace(toggle)
MyInventoryProfile[PlayerName]["replace"] = toggle;
MyInventory_Toggle_Option("ReplaceBags", toggle, 1);
MyInventoryFrame_UpdateLook(MyInventory_GetBagsTotalSlots());
end
function AllInOne_IsGood(toggle)
MyInventoryProfile[PlayerName]["ItemBorder"] = toggle;
MyInventory_Toggle_Option("ItemBorder", toggle, 1);
MyInventoryFrame_UpdateLook(MyInventory_GetBagsTotalSlots());
end
function AllInOne_Cols(toggle)
MyInventoryFrame_SetColumns(toggle);
MyInventoryColumns = toggle;
end
function AllInOne_Scale(toggle)
MyInventory_SetScale(toggle);
MyInventoryScale = toggle;
end
--[[注册结束]]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -