Skip to content

Commit

Permalink
Implemented LibRealmInfo, Added Class coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike authored and Mike committed Feb 10, 2017
1 parent f4b9e39 commit 73c11ef
Show file tree
Hide file tree
Showing 13 changed files with 1,508 additions and 58 deletions.
2 changes: 2 additions & 0 deletions Keyed/Keyed/Keyed.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
<None Include="$(MSBuildThisFileDirectory)Keyed\Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Libs\LibRealmInfo\LibRealmInfo.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Libs\LibStub\LibStub.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Locales\enUS.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Locales\esES.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Locales\rurRU.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Locales\zhTW.lua" />
<None Include="$(MSBuildThisFileDirectory)Keyed\Textures\Keyed-Portrait.blp" />
</ItemGroup>
Expand Down
Binary file modified Keyed/Keyed/Keyed.zip
Binary file not shown.
15 changes: 10 additions & 5 deletions Keyed/Keyed/Keyed/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local defaults = {
["*"] = {
name = "",
guid = nil,
class = "PALADIN",
time = 0,
keystones = {}
}
Expand All @@ -38,7 +39,7 @@ KeyedMinimapButton = LibStub("LibDBIcon-1.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")

local KeystoneId = 138019
local prefix = "KEYED_13"
local prefix = "KEYED_16"
local KeyedName = "|cffd6266cKeyed|r"
local keystoneRequest = "keystones"
local playerKeystoneRequest = "playerkeystone"
Expand All @@ -50,7 +51,7 @@ function Keyed:OnInitialize()
KeystoneListFrame:RegisterForDrag("LeftButton")

-- Load Database
self.db = LibStub("AceDB-3.0"):New("Keyedv2DB", defaults)
self.db = LibStub("AceDB-3.0"):New("Keyedv3DB", defaults)

-- Register Minimap Button
KeyedMinimapButton:Register("Keyed", keyedLDB, self.db.profile.minimap)
Expand Down Expand Up @@ -130,6 +131,7 @@ function Keyed:OnCommReceived (prefix, message, channel, sender)
local time = 0
local player = ""
local uid = ""
local classFileName = ""

-- Handle...
if arguments[1] == "request" then
Expand All @@ -140,7 +142,8 @@ function Keyed:OnCommReceived (prefix, message, channel, sender)
elseif arguments[1] == keystoneRequest then
player = arguments[2]
uid = arguments[3]
time = tonumber(arguments[4])
classFileName = arguments[4]
time = tonumber(arguments[5])
for i = 5, #arguments do
if not self:isempty(arguments[i]) then
name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(arguments[i])
Expand All @@ -153,6 +156,7 @@ function Keyed:OnCommReceived (prefix, message, channel, sender)
self.db.factionrealm[uid].time = time
self.db.factionrealm[uid].name = player
self.db.factionrealm[uid].uid = uid
self.db.factionrealm[uid].class = classFileName
table.wipe(self.db.factionrealm[uid].keystones)
for i = 1, #keystones do
table.insert(self.db.factionrealm[uid].keystones, keystones[i])
Expand All @@ -170,7 +174,7 @@ function Keyed:SendEntries(target)
local message = ""
for playerName, entry in pairs(self.db.factionrealm) do
if playerName ~= name then
message = keystoneRequest .. ";" .. entry.name .. ";" .. entry.uid .. ";" .. tostring(entry.time) .. ";"
message = keystoneRequest .. ";" .. entry.name .. ";" .. entry.uid .. ";" .. entry.class .. ";" .. tostring(entry.time) .. ";"
for i = 1, #entry.keystones do message = message .. entry.keystones[i] .. ";" end
self:SendResponse(target, message)
end
Expand All @@ -179,9 +183,10 @@ end

function Keyed:SendKeystones(target)
-- Prepare
local localizedClass, classFileName = UnitClass("player")
local uid = UnitGUID("player")
local name = UnitName("player")
local message = keystoneRequest .. ";" .. name .. ";" .. uid .. ";" .. tostring(GetServerTime()) .. ";"
local message = keystoneRequest .. ";" .. name .. ";" .. uid .. ";" .. classFileName .. ";" .. tostring(GetServerTime()) .. ";"
local keystones = self:FindKeystones()
for i = 1, #keystones do
message = message .. keystones[i] .. ";"
Expand Down
4 changes: 2 additions & 2 deletions Keyed/Keyed/Keyed/Keyed.toc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Interface: 70100
## Author: Michael Mattera
## Version: 1.5.0
## Version: 1.6.0
## Title: |cffd6266cKeyed|r
## Notes: Browse guild's Mythic+ Keystones
## SavedVariables: Keyedv2DB
## SavedVariables: Keyedv3DB

References.xml
Core.lua
Expand Down
37 changes: 30 additions & 7 deletions Keyed/Keyed/Keyed/KeyedFrame.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
KEYED_WEEK = 604800 -- 7 Days
KEYED_RESET_NA = 1467712800 -- Tue, 05 Jul 2016 00:00:00 GMT
KEYED_RESET_OC = 1467752400 -- Tue, 05 Jul 2016 11:00:00 GMT !!!UNTESTED (Also unused)!!!
KEYED_RESET_EU = 1467799200 -- Mon, 06 Jul 2016 10:00:00 GMT !!!UNTESTED (Also unused)!!!
KEYED_RESET_US = 1467712800 -- Tue, 05 Jul 2016 00:00:00 GMT -- apparently US, Latin America, and Oceanic use the same reset... why must you be different EU!!
KEYED_RESET_EU = 1467788400 -- Mon, 06 Jul 2016 07:00:00 GMT
KEYED_RESET_CN = 0 --Leave blank for now...
KEYED_RESET_TW = 0
KEYED_OOD = false
KEYED_DEPLETED_MASK = 4194304
KEYED_FRAME_PLAYER_HEIGHT = 16
Expand All @@ -12,6 +13,17 @@ KEYED_SORT_TYPE = "level"

-- Load Locale...
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")
local keyedRealmInfo = LibStub("LibRealmInfo");

-- Resets by region
KEYED_REGION_RESETS = {
["US"] = KEYED_RESET_US,
["EU"] = KEYED_RESET_EU,
["TW"] = KEYED_RESET_TW,
["CN"] = KEYED_RESET_CN,
};

-- Instance Names by ID
INSTANCE_NAMES = {
-- Raids
["1520"] = L["The Emerald Nightmare"],
Expand Down Expand Up @@ -79,6 +91,9 @@ function KeystoneList_Update ()
local SetHighlighted = function(fontString)
fontString:SetTextColor(GameFontHighlightSmall:GetTextColor())
end
local SetClass = function(fontString, classTable)
fontString:SetTextColor(classTable.r, classTable.g, classTable.b, classTable.a)
end
local SetNormal = function(fontString)
fontString:SetTextColor(GameFontNormalSmall:GetTextColor())
end
Expand All @@ -90,14 +105,15 @@ function KeystoneList_Update ()
button.link = nil
if keystoneIndex <= #keystoneData then
button.playerName = keystoneData[keystoneIndex].name
button.classColor = RAID_CLASS_COLORS[keystoneData[keystoneIndex].class]
button.dungeon = keystoneData[keystoneIndex].dungeon
button.level = tostring(keystoneData[keystoneIndex].level)
button.link = keystoneData[keystoneIndex].link
button.depleted = keystoneData[keystoneIndex].depleted
button.ood = keystoneData[keystoneIndex].ood
buttonText = _G["KeystoneListFrameButton" .. i .. "Name"];
buttonText:SetText (button.playerName);
if button.depleted or button.ood then SetDepleted(buttonText) else SetNormal(buttonText) end
buttonText:SetText(button.playerName)
if button.classColor then SetClass(buttonText, button.classColor) else SetNormal(buttonText) end
buttonText = _G["KeystoneListFrameButton" .. i .. "Dungeon"];
buttonText:SetText (button.dungeon);
if button.depleted or button.ood then SetDepleted(buttonText) else SetHighlighted(buttonText) end
Expand Down Expand Up @@ -131,7 +147,7 @@ end

function GetKeystoneData ()
-- Prepare
local keyedReset = KEYED_RESET_NA
local keyedReset = KEYED_REGION_RESETS[keyedRealmInfo.GetCurrentRegion()]
local keyedWeek = KEYED_WEEK

local tuesdays = math.floor((GetServerTime() - keyedReset) / keyedWeek)
Expand All @@ -150,6 +166,7 @@ function GetKeystoneData ()
number = number + 1
table.insert (data, {
name = entry.name,
class = entry.class,
dungeon = dungeon,
dungeonId = tonumber(id),
level = tonumber(level),
Expand Down Expand Up @@ -235,7 +252,9 @@ function Keyed_SortByDungeon (a, b)
end

function Keyed_SortByLevel (a, b)
local result = a.level < b.level -- Compare by level first...
local lv1 = tonumber(a.level);
local lv2 = tonumber(b.level);
local result = lv1 < lv2; -- Compare by level first...
if a.level == b.level then
result = a.name > b.name -- ... if level is same, compare by name...
if a.name == b.name then
Expand Down Expand Up @@ -263,4 +282,8 @@ function KeyedFrame_ToggleMinimap(self, checked)
Keyed.db.profile.minimap.hide = true
KeyedMinimapButton:Hide("Keyed")
end
end

function KeyedRegionDropdown_OnLoad(self)

end
59 changes: 29 additions & 30 deletions Keyed/Keyed/Keyed/KeyedFrame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
</OnLoad>
<OnClick>
if self.link then
ChatFrame1EditBox:Show()
ChatFrame1EditBox:SetFocus()
ChatFrame1EditBox:Insert(self.link)
ChatFrame1EditBox:Show()
ChatFrame1EditBox:SetFocus()
ChatFrame1EditBox:Insert(self.link)
end
PlaySound("igMainMenuOptionCheckBoxOn");
</OnClick>
Expand Down Expand Up @@ -91,9 +91,7 @@
</Layers>
<Scripts>
<OnClick>
if ( self.sortType ) then
Keyed_SortKeyed(self.sortType);
end
if (self.sortType) then Keyed_SortKeyed(self.sortType); end
PlaySound("igMainMenuOptionCheckBoxOn");
</OnClick>
</Scripts>
Expand Down Expand Up @@ -173,10 +171,10 @@
<Scripts>
<OnLoad>
-- Load Locale...
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")
self:SetText(L["Name"])
KeyedFrameColumn_SetWidth(self, 94)
self.sortType = "name"
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed");
self:SetText(L["Name"]);
KeyedFrameColumn_SetWidth(self, 94);
self.sortType = "name";
</OnLoad>
</Scripts>
</Button>
Expand All @@ -187,10 +185,10 @@
<Scripts>
<OnLoad>
-- Load Locale...
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")
self:SetText(L["Dungeon"])
KeyedFrameColumn_SetWidth(self, 175)
self.sortType = "dungeon"
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed");
self:SetText(L["Dungeon"]);
KeyedFrameColumn_SetWidth(self, 175);
self.sortType = "dungeon";
</OnLoad>
</Scripts>
</Button>
Expand All @@ -201,10 +199,10 @@
<Scripts>
<OnLoad>
-- Load Locale...
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")
self:SetText(L["Lvl"])
KeyedFrameColumn_SetWidth(self, 32)
self.sortType = "level"
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed");
self:SetText(L["Lvl"]);
KeyedFrameColumn_SetWidth(self, 32);
self.sortType = "level";
</OnLoad>
</Scripts>
</Button>
Expand All @@ -216,19 +214,19 @@
<Scripts>
<OnLoad>
-- Load Locale...
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")
self:SetText(L["Get Keystones"])
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed");
self:SetText(L["Get Keystones"]);
</OnLoad>
<OnClick function="KeyedFrameGetKeystonesButton_OnClick"/>
<OnUpdate>
if KEYED_BROADCAST then
if (GetServerTime() - KEYED_BROADCAST) > 4 then
self:Enable()
else
self:Disable()
end
if (GetServerTime() - KEYED_BROADCAST) > 4 then
self:Enable();
else
self:Disable();
end
else
self:Enable()
self:Enable();
end
</OnUpdate>
</Scripts>
Expand All @@ -243,7 +241,7 @@
</HitRectInsets>
<Layers>
<Layer level="BORDER">
<FontString name="KeyedFrameShowMinimapButtonText" inherits="GameFontNormalSmall" justifyH="LEFT">
<FontString name="KeyedFrameShowMinimapButtonText" inherits="GameFontNormal" justifyH="LEFT">
<Size x="0" y="14"/>
<Anchors>
<Anchor point="LEFT" x="26" y="0"/>
Expand All @@ -254,11 +252,11 @@
<Scripts>
<OnLoad>
-- Load Locale...
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed")
KeyedFrameShowMinimapButtonText:SetText(L["Enable Minimap Button"])
local L = LibStub("AceLocale-3.0"):GetLocale("Keyed");
KeyedFrameShowMinimapButtonText:SetText(L["Enable Minimap Button"]);
</OnLoad>
<OnClick>
KeyedFrame_ToggleMinimap(self, self:GetChecked())
KeyedFrame_ToggleMinimap(self, self:GetChecked());
</OnClick>
</Scripts>
<NormalTexture file="Interface\Buttons\UI-CheckBox-Up"/>
Expand All @@ -267,6 +265,7 @@
<CheckedTexture name="$parentCheckedTexture" file="Interface\Buttons\UI-CheckBox-Check"/>
<DisabledCheckedTexture file="Interface\Buttons\UI-CheckBox-Check-Disabled"/>
</CheckButton>

<CheckButton name="KeyedFrameShowOutOfDateButton" checked="false">
<Size x="24" y="24" />
<Anchors>
Expand Down
Loading

0 comments on commit 73c11ef

Please sign in to comment.