functionRSystemServer:OnInitialize() self.db = LibStub("AceDB-3.0"):New("RSystemServerDB") -- Called when the addon is enabled self:RegisterEvent("CHAT_MSG_ADDON") self:RegisterEvent("PLAYER_ENTERING_WORLD") if (self.db.profile.receiveRequestList) then receiveRequestList = self.db.profile.receiveRequestList end end
functionRSystemServer:PLAYER_ENTERING_WORLD() RegisterAddonMessagePrefix("RSystemServer") end
functionRSystem:OnInitialize() -- Called when the addon is enabled self:RegisterEvent("MAIL_SHOW") self:RegisterEvent("MAIL_CLOSED") self:RegisterEvent("MAIL_FAILED") self:RegisterEvent("MAIL_SEND_SUCCESS") self:RegisterEvent("CHAT_MSG_ADDON") self:RegisterEvent("PLAYER_ENTERING_WORLD") self:RegisterComm("RSystemClient", function()end) end
可以看到,我们的插件会和邮件系统的事件有很多交互。
创建一个tooltip,后面我们就可以直接调“MyTooltip:Show()”用了
1 2 3 4 5 6 7 8 9 10
functionRSystem:OnEnable() -- create tool tip ifnot MyTooltip then CreateFrame("GameTooltip", "MyTooltip", nil, "GameTooltipTemplate") MyTooltip:SetOwner( WorldFrame, "ANCHOR_NONE" ); MyTooltip:AddFontStrings( MyTooltip:CreateFontString( "$parentTextLeft1", nil, "GameTooltipText" ), MyTooltip:CreateFontString( "$parentTextRight1", nil, "GameTooltipText" ) ); end end
创建界面元素
1 2 3 4 5 6 7 8 9 10 11
functionRSystem:createFrameWidgets(f) local HeaderFrame = AceGUI:Create("InlineGroup") HeaderFrame:SetFullWidth(true) HeaderFrame:SetLayout("Flow") RSystem:createEditBox(HeaderFrame,"物品ID",200,false,handleRequireNameChange) RSystem:createMoneyInput(HeaderFrame) RSystem:createButton(HeaderFrame, "发布需求", 100, handlePushRequest) RSystem:createTabGroup(f,{{text="找物品", value="item"}, {text="找打手", value="help"}},"item",SelectGroup) f:AddChild(HeaderFrame) end