Compare with Previous | Blame | View Log
EERaidAdmin = LibStub("AceAddon-3.0"):NewAddon("EERaidAdmin", "AceConsole-3.0", "AceBucket-3.0", "AceEvent-3.0", "AceComm-3.0") ------ VARIABLES local __EERACaption = "EERaidAdmin" local __EERA = "EERA" local __NoItem = "ÐÐµÑ ÐÑедмеÑа" local __UpdateRate = 0.1 local __IsDebugging = 0 local __serverOffset = nil local __raidActiveGroups = 5 local __raidActivePlayers = __raidActiveGroups * 5 local db EERaidAdmin.__IsDebugging = __IsDebugging EERaidAdmin.__serverOffset = __serverOffset EERaidAdmin.__raidActiveGroups = __raidActiveGroups EERaidAdmin.__raidActivePlayers = __raidActivePlayers ------ HELPER METHODS local function _hex(r, g, b) if type(r) == "table" then if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end end return string.format("|cff%02x%02x%02x", r*255, g*255, b*255) end local function _color(r, g, b, msg) if type(r) == "table" then if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end end t_color = string.format("|cff%02x%02x%02x", r*255, g*255, b*255) if msg ~= '' then return t_color..msg..'|r' else return t_color end end local function _message(msg, label) local output = "" output = _color(0,1,1, 'EERaidAdmin: ') if label then output = output.._color(0,0.7,0.7, label..': ') end output = output..msg print(output) end local function _debug(msg, fatal) --if __IsDebugging == 1 or fatal then -- EELoot:Print("|cffdd0000debug: "..msg.."|r") --end end function EERaidAdmin:ServerDateTime() if __serverOffset == nil then local serverHour, serverMinute = GetGameTime() local utcHour = tonumber(date("%H")) local utcMinute = tonumber(date("%M")) local ser = serverHour + serverMinute / 60 local utc = utcHour + utcMinute / 60 __serverOffset = floor((ser - utc) * 2 + 0.5) / 2 if __serverOffset >= 12 then __serverOffset = __serverOffset - 24 elseif __serverOffset < -12 then __serverOffset = __serverOffset + 24 end end local t_time = time()+__serverOffset*60*60 local t_date = date("%Y-%m-%d %H:%M:%S", t_time) return t_date end function EERaidAdmin:OnCommReceived(prefix, message, distribution, sender) _debug("OnCommReceived") local tokens = { strsplit(";", message) } if prefix == "LSRC" then if tokens[1] == "C_VER" then -- pechataem versii klientov _message(sender..", "..tokens[2], "ÐеÑÑÐ¸Ñ ÐºÐ»Ð¸ÐµÐ½Ñа") end elseif prefix == "LSRA" then if tokens[1] == "A_VER_POLL" then -- otzyvaemjsa na zapros o versii adminki self:SendCommMessage("LSRA", "A_VER;"..GetAddOnMetadata("EERaidAdmin", "X-Curse-Packaged-Version"), "WHISPER", sender) elseif tokens[1] == "A_VER" then _message(sender..", "..tokens[2], "ÐеÑÑÐ¸Ñ Ð°Ð´Ð¼Ð¸Ð½Ð°") end end end function EERaidAdmin:ValidateTabs() _debug("ValidateTabs") local rank --local role local isML for i = 1, GetNumRaidMembers() do -- rank: Returns 2 if the raid member is the leader of the raid, 1 if the raid member is promoted to assistant, and 0 otherwise. -- role: The player's role within the raid ("maintank" or "mainassist"). local t_name, t_rank, _, _, _, _, _, _, _, t_role, t_isML = GetRaidRosterInfo(i) if UnitName("player") == t_name then rank = t_rank --role = t_role isML = t_isML break end end if UnitInRaid("player") then self.tab1:Enable() else self.tab1:Disable(); end self.tab2:Enable() self.tab3:Enable() end function EERaidAdmin:RAID_ROSTER_UPDATE() _debug("RAID_ROSTER_UPDATE") self:ValidateTabs() end function EERaidAdmin:OnInitialize() _debug("OnInitialize") self.db = LibStub("AceDB-3.0"):New("EERaidAdminDB") db = self.db.global if db.__AutoGreen == nil then db.__AutoGreen = true; end if db.__AutoAnnounceLoot == nil then db.__AutoAnnounceLoot = true; end -- register chat command self:RegisterChatCommand(__EERA, "ParseChatCommand") self:RegisterBucketEvent("RAID_ROSTER_UPDATE", 0.5, "RAID_ROSTER_UPDATE") self:RegisterComm("LSRC") self:RegisterComm("LSRA") self:CreateFrames() self.Anchor:Hide() PanelTemplates_SetNumTabs(self.Anchor, 3) PanelTemplates_TabResize(self.tab1,20) PanelTemplates_TabResize(self.tab2,20) PanelTemplates_TabResize(self.tab3,20) PanelTemplates_SetTab(self.Anchor, 0) self:ValidateTabs() end function EERaidAdmin:OnEnable() _debug("OnEnable") end function EERaidAdmin:OnDisable() _debug("OnDisable") end -- Main event handler function EERaidAdmin:OnEvent() if (event == "VARIABLES_LOADED") then end if (event == "CHAT_MSG_ADDON") then end end function EERaidAdmin:OnShow() PlaySound("UChatScrollButton") self:ValidateTabs() --PanelTemplates_SetTab(diskpContainerFrame, 1) --DisKP_SetTab(DisKP_SelectedTab) --DisKP_CheckNewBoss:SetChecked( DisKP_config["NEW_BOSS"] ) end function EERaidAdmin:CreateFrames() -- Anchor self.Anchor = CreateFrame("Frame", "EERAAnchor", UIParent) self.Anchor:SetFrameStrata("MEDIUM") self.Anchor:SetToplevel(true) self.Anchor:SetMovable(true) self.Anchor:EnableMouse(true) self.Anchor:SetWidth(600) self.Anchor:SetHeight(680) -- self.Anchor:SetScript("OnLoad", function() EERaidAdmin:OnLoad() end ) self.Anchor:SetScript("OnEvent", function() EERaidAdmin:OnEvent() end ) self.Anchor:SetScript("OnShow", function() EERaidAdmin:OnShow() end ) self.Anchor:SetScript("OnHide", function() PlaySound("UChatScrollButton") end ) self.Anchor:SetScript("OnMouseDown", self.Anchor.StartMoving) self.Anchor:SetScript("OnMouseUp", self.Anchor.StopMovingOrSizing) self.Anchor:SetBackdrop({ bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", tile=true, tileSize=32, edgeSize=32, insets={left=10, right=10, top=10, bottom=10} }) -- Caption and cancel button local t = self.Anchor:CreateTexture("FrameHeader") t:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") t:SetWidth(350) t:SetHeight(64) t:SetPoint("TOP",0,12) self.Anchor.texture = t local fs = self.Anchor:CreateFontString("$parentTitle","ARTWORK","GameFontNormal") fs:SetText(__EERACaption) fs:SetPoint("TOP","FrameHeader",0,-14) local cb = CreateFrame("Button", nil, self.Anchor, "UIPanelCloseButton") cb:SetPoint("TOPRIGHT",self.Anchor,-2,-3) -- Bottom tabs self.tab1 = CreateFrame("Button", "$parentTab1", self.Anchor, "CharacterFrameTabButtonTemplate" ) self.tab1:SetText("Рейд") self.tab1:SetScript("OnClick", function() EERaidAdmin:SetTab(1) -- TODO: end ) self.tab1:SetPoint("LEFT",self.Anchor,"BOTTOMLEFT",10,-10) self.tab2 = CreateFrame("Button", "$parentTab2", self.Anchor, "CharacterFrameTabButtonTemplate" ) self.tab2:SetText("ÐаÑма") self.tab2:SetScript("OnClick", function() EERaidAdmin:SetTab(2) end) self.tab2:SetPoint("LEFT",self.tab1,"RIGHT",-16,0) self.tab3 = CreateFrame("Button", "$parentTab3", self.Anchor, "CharacterFrameTabButtonTemplate" ) self.tab3:SetText("Ролл") self.tab3:SetScript("OnClick", function() EERaidAdmin:SetTab(3) end ) self.tab3:SetPoint("LEFT",self.tab2,"RIGHT",-16,0) -- Panels ---- Raid panel ---- ---- Raid panel -- self.RaidTab = CreateFrame("Frame",nil,self.Anchor) -- -- self.StartRaid = CreateFrame("Button","CollectLootButton",self.RaidTab,"OptionsButtonTemplate") -- self.StartRaid:SetHeight(28) -- self.StartRaid:SetText("ÐолÑÑиÑÑ") -- self.StartRaid:SetScript("OnClick", function() -- EERaidAdmin:CollectLoot_OnClick() -- end ) -- self.StartRaid:SetPoint("LEFT",self.RaidTab,"TOPLEFT",20,-60) -- self.Anchor:SetClampedToScreen( true ) self.Anchor:SetPoint("CENTER",0,0) end function EERaidAdmin:ParseChatCommand(input) _debug("ParseChatCommand") local input = strtrim(input) if input ~= '' then -- squeeze spaces input = string.gsub(input, "(%s+)", " ") -- tokenize local tokens = { strsplit(" ", input) } -- switch if string.lower(tokens[1]) == "dbcreate" then EEKarma:DBCreate(tokens[2]) elseif string.lower(tokens[1]) == "dbuse" then EEKarma:DBUse(tokens[2]) elseif string.lower(tokens[1]) == "dblist" then EEKarma:DBList() elseif string.lower(tokens[1]) == "raidstart" then -- start raid EERaid:StartRaid() elseif string.lower(tokens[1]) == "raidstop" then -- end raid EERaid:EndRaid() elseif string.lower(tokens[1]) == "raidshow" then -- ??? EERaid:ContinueRaid() elseif string.lower(tokens[1]) == "loot" then -- manual loot local mloot = string.gsub(input, "^loot%s*", '') _debug("> Loot added manually " .. mloot); EELoot:ManualCollectLoot(mloot) EERaidAdmin.Anchor:Show() EERaidAdmin:SetTab(3) elseif string.lower(tokens[1]) == "dbactive" then if EEKarma:DBActive() then _message(db.ActiveDB, "ÐкÑÐ¸Ð²Ð½Ð°Ñ ÐÐ") else _debug("ÐРне опÑеделена" , 1) end elseif string.lower(tokens[1]) == "dbcompact" then _message("ÐÑÑаÑÑÑ ÑжаÑÑ ÐÐ") EEKarma:DBCompact() elseif string.lower(tokens[1]) == "dbprune" then _message("ÐÑÑаÑÑÑ ÑдалиÑÑ Ð¸Ð³Ñока из ÐÐ") if tokens[2] then EEKarma:DBPrune(tokens[2]) end elseif string.lower(tokens[1]) == "dbpruneall" then _message("ÐÑÑаÑÑÑ Ð¿Ð¾ÑиÑÑиÑÑ ÐÐ Ð¾Ñ Ð¿Ð»Ð¾Ñ Ð¸Ñ Ð¸Ð³Ñоков") EEKarma:DBPrune() elseif string.lower(tokens[1]) == "raidbeer" then self:SendCommMessage("LSRA", "BEER", "RAID") elseif string.lower(tokens[1]) == "guildbeer" then self:SendCommMessage("LSRA", "BEER", "GUILD") -- elseif string.lower(tokens[1]) == "autogreen" then if db.__AutoGreen == true then db.__AutoGreen = false _message( _color(0.85,0,0,"ÐÑклÑÑено"), "ÐвÑомаÑиÑеÑки подбиÑаÑÑ Ð·ÐµÐ»ÐµÐ½ÐºÑ") else db.__AutoGreen = true _message( _color(0,0.85,0,"ÐклÑÑено"), "ÐвÑомаÑиÑеÑки подбиÑаÑÑ Ð·ÐµÐ»ÐµÐ½ÐºÑ") end elseif string.lower(tokens[1]) == "autoannounceloot" then if db.__AutoAnnounceLoot == true then db.__AutoAnnounceLoot = false _message( _color(0.85,0,0,"ÐÑклÑÑено"), "ÐвÑомаÑиÑеÑкое анонÑиÑование лÑÑа") else db.__AutoAnnounceLoot = true _message( _color(0,0.85,0,"ÐклÑÑено"), "ÐвÑомаÑиÑеÑкое анонÑиÑование лÑÑа") end elseif string.lower(tokens[1]) == "verpoll" then -- stub if not tokens[2] then _message( _color(0,0.85,0,"/eera verpoll client|admin"), "Please type"); elseif string.lower(tokens[2]) == "client" then self:SendCommMessage("LSRA", "C_VER_POLL", "GUILD") elseif string.lower(tokens[2]) == "admin" then self:SendCommMessage("LSRA", "A_VER_POLL", "GUILD") end elseif string.lower(tokens[1]) == "notify" then if tokens[2] and (string.lower(tokens[2]) == "raid" or string.lower(tokens[2]) == "guild") then EEKarma:SendMassNotify(string.lower(tokens[2])) end elseif string.lower(tokens[1]) == "freeraid" then db._FreeRaid = not db._FreeRaid; _message( _color(0,0.85,0,"ÐклÑÑено"), "FreeRaid:") end else --_message("---- ÐейÑÑÐ²Ð¸Ñ Ñ ÐÐ --------------") --_message("СоздаÑÑ Ð½Ð¾Ð²ÑÑ ÐÐ", "/eera dbcreate [name]") --_message("ÐадейÑÑвоваÑÑ ÐÐ", "/eera dbuse [name]") --_message("ÐоказаÑÑ Ð°ÐºÑивнÑÑ ÐÐ", "/eera dbactive") --_message("ÐоказаÑÑ ÑпиÑок вÑÐµÑ ÐÐ", "/eera dblist") --_message("СжаÑÑ ÐÐ", "/eera dbcompact") --_message("УдалиÑÑ Ð¿Ð»Ð¾Ñ Ð¾Ð³Ð¾ игÑока из ÐÐ", "/eera dbprune [name]") --_message("УдалиÑÑ Ð¿Ð»Ð¾Ñ Ð¸Ñ Ð¸Ð³Ñоков из ÐÐ", "/eera dbpruneall") _message("---- ÐбÑие наÑÑÑойки ------------") _message("ÐвÑомаÑиÑеÑки подбиÑаÑÑ Ð·ÐµÐ»ÐµÐ½ÐºÑ", "/eera autogreen") _message("ÐвÑомаÑиÑеÑкое анонÑиÑование лÑÑа", "/eera autoannounceloot") _message("ÐомеÑÑиÑÑ Ð¸Ñем в ÑпиÑок лÑÑа", "/eera loot [itemLink]") --_message("---- УпÑавление Ñейдом ----------"); --_message("ÐаÑаÑÑ Ñейд", "/eera raidstart") --_message("ÐаконÑиÑÑ Ñейд", "/eera raidstop") --_message("ÐоказаÑÑ Ð¸Ð½Ñо о ÑекÑÑем Ñейде", "/eera raidshow") _message("ÐÑпÑавиÑÑ Ð¾Ð¿Ð¾Ð²ÐµÑение о колиÑеÑÑве каÑÐ¼Ñ Ð³Ð¸Ð»Ñдии/ÑейдÑ", "/eera notify [guild/raid]") EERaidAdmin.Anchor:Show() end end function EERaidAdmin:SetTab(tab) PanelTemplates_SetTab(self.Anchor, tab) if tab == 1 then EEKarma.Anchor:Hide() EELoot.Anchor:Hide() -- EERaid.Anchor:SetParent(self.Anchor) EERaid.Anchor:SetPoint("TOPLEFT", self.Anchor, "TOPLEFT") EERaid.Anchor:SetPoint("BOTTOMRIGHT", self.Anchor, "BOTTOMRIGHT") EERaid.Anchor:Show() elseif tab == 2 then EERaid.Anchor:Hide() EELoot.Anchor:Hide() -- EEKarma.Anchor:SetParent(self.Anchor) EEKarma.Anchor:SetPoint("TOPLEFT", self.Anchor, "TOPLEFT") EEKarma.Anchor:SetPoint("BOTTOMRIGHT", self.Anchor, "BOTTOMRIGHT") EEKarma.Anchor:Show() elseif tab == 3 then EERaid.Anchor:Hide() EEKarma.Anchor:Hide() -- EELoot.Anchor:SetParent(self.Anchor) EELoot.Anchor:SetPoint("TOPLEFT", self.Anchor, "TOPLEFT") EELoot.Anchor:SetPoint("BOTTOMRIGHT", self.Anchor, "BOTTOMRIGHT") EELoot.Anchor:Show() end self:ValidateTabs() end