earthtable.lua
字号:
if ( not frame ) then frame = this; end frame:SetWidth(width); getglobal(frame:GetName().."Middle"):SetWidth(width - 9);endfunction EarthTable_Header_Clear(header) if ( header ) then header:SetText(""); header:Hide(); endendfunction EarthTable_Cell_Clear(cell) if ( cell ) then cell:SetText(""); cell:Hide(); endendfunction EarthTable_OnHorizontalScroll( call ) local scrollbar = getglobal(this:GetName().."ScrollBar"); scrollbar:SetValue(arg1); local min, max = scrollbar:GetMinMaxValues(); this.offset = floor(scrollbar:GetValue() + 0.5); call();end--[[ Converts a type into a string ]]--function EarthTable_GetInfo(data) if ( type(data) == "string" ) then return data; elseif ( type(data) == "boolean" ) then if ( data ) then return EARTHTABLE_KEYWORD_BOOL_TRUE; else return EARTHTABLE_KEYWORD_BOOL_FALSE; end elseif ( type(data) == "table" ) then return EARTHTABLE_KEYWORD_TABLE; elseif ( type(data) == "function" ) then return EARTHTABLE_KEYWORD_FUNCTION; elseif ( type(data) == "nil" ) then return EARTHTABLE_KEYWORD_NIL; else return EARTHTABLE_KEYWORD_UNKNOWN; endend--[[ Creates a Database Comparator function ]]--function EarthTable_CreateComparator(order) return function(a,b) if ( order.reverse == true ) then if ( a[order.key] > b[order.key] ) then return true; end else if ( a[order.key] < b[order.key] ) then return true; end end return false; end end-- Gets an item by IDfunction EarthTable_GetDatabaseItemByID(frame,id) local vOffset = FauxScrollFrame_GetOffset(getglobal(frame:GetName().."ListScrollFrameV")); local nth = id + vOffset; if ( frame.database[nth] ) then return frame.database[nth]; else return nil; endendfunction EarthTable_GetHeaderByID(frame,id) local realid = frame.activeHeaders[id]; if( realid ) then return frame.headerList[realid]; else return nil; endend---- Sets the location of the Tooltip--function EarthTable_SetTooltip(frame, tooltipText) if ( frame.tooltip ) then local tooltip = getglobal(frame.tooltip); if ( tooltipText ) then -- Set the location of the tooltip if ( frame.tooltipPlacement == "cursor" ) then tooltip:SetOwner(UIParent,"ANCHOR_CURSOR"); elseif ( frame.tooltipPlacement == "button" ) then tooltip:SetOwner(this,frame.tooltipAnchor); else tooltip:SetOwner(frame,frame.tooltipAnchor); end Sea.wow.tooltip.protectTooltipMoney(); tooltip:SetText(tooltipText, 0.8, 0.8, 1.0); tooltip:Show(); Sea.wow.tooltip.unprotectTooltipMoney(); end endend---- Hides the location of the Tooltip--function EarthTable_HideTooltip(frame) if ( frame.tooltip ) then getglobal(frame.tooltip):Hide(); getglobal(frame.tooltip):SetOwner(UIParent, "ANCHOR_RIGHT"); endend--[[---- Event Handlers----]]--[[ Row Actions ]]--function EarthTable_RowButton_OnLoad() --this:RegisterForClicks("LeftButtonDown", "LeftButtonUp", "RightButtonDown", "RightButtonUp"); this:RegisterForClicks("LeftButtonDown", "RightButtonDown"); this.onClick = EarthTable_RowButton_OnClick; this.onDoubleClick = EarthTable_RowButton_OnDoubleClick; this.onEnter = EarthTable_RowButton_OnEnter; this.onLeave = EarthTable_RowButton_OnLeave;endfunction EarthTable_RowButton_OnClick() PlaySound("igMainMenuOptionCheckBoxOn"); EarthTable_HandleEvent(this:GetParent(),this:GetID(),"CLICK_ROW");endfunction EarthTable_RowButton_OnDoubleClick() PlaySound("igMainMenuOptionCheckBoxOn"); EarthTable_HandleEvent(this:GetParent(),this:GetID(),"DOUBLECLICK_ROW");endfunction EarthTable_RowButton_OnEnter() EarthTable_HandleEvent(this:GetParent(),this:GetID(),"ENTER_ROW");endfunction EarthTable_RowButton_OnLeave() EarthTable_HandleEvent(this:GetParent(),this:GetID(),"LEAVE_ROW");end--[[ Header Actions ]]--function EarthTable_HeaderButton_OnLoad() --this:RegisterForClicks("LeftButtonDown", "LeftButtonUp", "RightButtonDown", "RightButtonUp"); this:RegisterForClicks("LeftButtonDown", "RightButtonDown"); EarthTable_Header_SetWidth(52); this.onClick = EarthTable_HeaderButton_OnClick; this.onEnter = EarthTable_HeaderButton_OnEnter; this.onLeave = EarthTable_HeaderButton_OnLeave;end function EarthTable_HeaderButton_OnClick() PlaySound("igMainMenuOptionCheckBoxOn"); EarthTable_HandleEvent(this:GetParent(),this:GetID(),"CLICK_HEADER");endfunction EarthTable_HeaderButton_OnEnter() EarthTable_HandleEvent(this:GetParent(),this:GetID(),"ENTER_HEADER");endfunction EarthTable_HeaderButton_OnLeave() EarthTable_HandleEvent(this:GetParent(),this:GetID(),"LEAVE_HEADER");end--[[ Frame Actions ]]--function EarthTable_Frame_OnLoad() -- Initalizes the frame this.rowCount = 20; -- this.database = {}; this.headerList = {}; this.activeHeaders = {}; this.sortingOrder = {}; this.headerIndex = 0; this.headerSpace = 300; this.headerMax = 4; -- Use any tooltip you'd like. I use my own this.tooltip = "EarthTooltip"; -- -- Can be "button", "frame", "cursor" -- this.tooltipPlacement = "cursor"; this.tooltipAnchor = "ANCHOR_RIGHT"; -- Can be any valid tooltip anchor this.activeTable = {}; getglobal(this:GetName().."ListScrollFrameVScrollBar"):SetMinMaxValues(0,1); getglobal(this:GetName().."ListScrollFrameHScrollBar"):SetMinMaxValues(0,1);end--[[-- Demo function----function dt() local database = { {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; {name="Roger";class="Rabbit";level="1";group="yes";onClick=function() Sea.io.print("Hiya!")end;tooltip="R!"}; {name="Sam"; class="Spy";level="32";group="no";onClick=function() Sea.io.print("Yo.")end;tooltip="S!"}; {name="Alex";class="Host";level="500";group="yes";onClick=function() Sea.io.print("The question is...")end;tooltip="A!!"}; } local headers = { { title = "Name"; key = "name"; width = 100; titleColor = {r=1.0;g=1.0;b=0.0}; sortable = true; stick="true"; }; { title = "Class"; key = "class"; width = 120; titleColor = {r=1.0;g=1.0;b=1.0}; sortable = true; }; { title = "Level"; key = "level"; width = 150; titleColor = {r=1.0;g=1.0;b=1.0}; sortable = true; }; { title = "Grouped?"; key = "group"; width = 150; titleColor = {r=1.0;g=1.0;b=1.0}; sortable = true; }; { title = "Grouped? 2"; key = "group"; width = 300; titleColor = {r=1.0;g=1.0;b=1.0}; sortable = true; }; } EarthTable_LoadDatabase( getglobal("EarthTable"), database ); EarthTable_LoadHeaders( getglobal("EarthTable"), headers ); EarthTable_UpdateFrame( getglobal("EarthTable") );end]]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -