Cleanup init. Push UI to just 1 row for zone.
Sasky [06-23-14 - 00:38]
Cleanup init. Push UI to just 1 row for zone.
diff --git a/XPCount.lua b/XPCount.lua
index ab3a076..6acb4f6 100644
--- a/XPCount.lua
+++ b/XPCount.lua
@@ -1,39 +1,36 @@
-if XPCount == nil then
- d("Initializing LRT")
- XPCount = {}
- XPCount.curZone = ""
- XPCount.zoneStart = 0
- XPCount.zoneXpStart = 0
- XPCount.zoneVpStart = 0
- XPCount.clockStart = 0
- XPCount.clockXpStart = 0
- XPCount.clockVpStart = 0
- XPCount.init = function(_, _)
- EVENT_MANAGER:UnregisterForEvent("XPCount", EVENT_PLAYER_ACTIVATED)
- XPCount.set()
- XPCount.zoneSet()
- EVENT_MANAGER:RegisterForEvent("XPCountPlayerActivate", EVENT_PLAYER_ACTIVATED, XPCount.zoneChange)
- EVENT_MANAGER:RegisterForEvent("XPCountZoneChange", EVENT_ZONE_CHANGED, XPCount.zoneChange)
+XPCount = {}
+
+XPCount.init = function(_, _)
+ EVENT_MANAGER:UnregisterForEvent("XPCount", EVENT_PLAYER_ACTIVATED)
+
+ if XPCount.curZone ~= nil then
+ d("Already init XPCount")
end
- EVENT_MANAGER:RegisterForEvent("XPCount", EVENT_PLAYER_ACTIVATED, XPCount.init)
-else
- d("Should show info here...")
-end
-XPCount.zoneSet = function(_, _, _, _)
- XPCount.curZone = GetUnitZone("player")
- XPCount.clockStart = GetTimeStamp()
- XPCount.clockXpStart = GetUnitXP("player")
- XPCount.clockVpStart = GetUnitVeteranPoints("player")
+ XPCount.resetCounter("zone")
+ XPCount.zoneSet("zone")
+ EVENT_MANAGER:RegisterForEvent("XPCountPlayerActivate", EVENT_PLAYER_ACTIVATED, XPCount.zoneChange)
+ EVENT_MANAGER:RegisterForEvent("XPCountZoneChange", EVENT_ZONE_CHANGED, XPCount.zoneChange)
+ EVENT_MANAGER:RegisterForUpdate("XPCountUIUpdate", 15000, XPCount.updateUI)
+
end
-XPCount.set = function(_, _, _, _)
+XPCount.zoneSet = function()
XPCount.curZone = GetUnitZone("player")
XPCount.zoneStart = GetTimeStamp()
XPCount.zoneXpStart = GetUnitXP("player")
XPCount.zoneVpStart = GetUnitVeteranPoints("player")
end
+XPCount.resetCounter = function()
+ XPCount.curZone = GetUnitZone("player")
+ XPCount.clockStart = GetTimeStamp()
+ XPCount.clockXpStart = GetUnitXP("player")
+ XPCount.clockVpStart = GetUnitVeteranPoints("player")
+end
+
+
+
XPCount.zoneChange = function()
local playerZone = GetUnitZone("player")
if playerZone ~= XPCount.curZone then
@@ -46,6 +43,32 @@ XPCount.zoneChange = function()
end
end
+local function nn(val) if val == nil then return 0 end return val end
+
+XPCount.updateUI = function()
+ local time = GetTimeStamp()
+ local elapsedZone = GetDiffBetweenTimeStamps(time, XPCount.zoneStart)
+ local curXP = GetUnitXP("player")
+ local curVP = GetUnitVeteranPoints("player")
+ local xp = curXP - nn(XPCount.zoneXpStart)
+ local vp = curVP - nn(XPCount.zoneVpStart)
+ XPCountUIZoneTime:SetText(XPCount.formatTime(elapsedZone))
+ if vp > 0 then
+ xp = vp
+ XPCountUIZoneXP:SetText(vp .. "vp")
+ else
+ XPCountUIZoneXP:SetText(xp .. "xp")
+ end
+
+ local rate = 0
+ if elapsedZone > 0 then
+ rate = math.floor((xp/elapsedZone)*3600)
+ end
+ XPCountUIZoneRate:SetText(rate .. "/h")
+end
+
+SLASH_COMMANDS["/zzz"] = XPCount.updateUI
+
XPCount.formatTime = function(delta)
local sec = delta % 60
delta = (delta - sec) / 60
@@ -56,7 +79,7 @@ XPCount.formatTime = function(delta)
if hrs > 0 then
out = out .. hrs .. "h "
end
- out = out .. min .. "m " .. sec .. "s"
+ out = out .. min .. "m "
return out
end
@@ -89,4 +112,12 @@ SLASH_COMMANDS["/xpcount"] = function(arg)
else
XPCount.showStats()
end
-end
\ No newline at end of file
+end
+
+SLASH_COMMANDS["/xpinit"] = function()
+ d("Init")
+ XPCount.init()
+ d("End init")
+end
+
+EVENT_MANAGER:RegisterForEvent("XPCount", EVENT_PLAYER_ACTIVATED, XPCount.init)
diff --git a/XPCount.xml b/XPCount.xml
index be14d54..c78618f 100644
--- a/XPCount.xml
+++ b/XPCount.xml
@@ -1,53 +1,51 @@
<GuiXml>
<Controls>
- <TopLevelControl name="XPCount" mouseEnabled="true" movable="true" clampedToScreen="true" hidden="false" >
- <Dimensions x="200" y="60" />
- <Anchor point="TOP" offsetX="0" offsetY="50" />
+ <TopLevelControl name="XPCountUI" mouseEnabled="true" movable="true" clampedToScreen="true" hidden="false" >
+ <Dimensions x="220" y="20" />
+ <Anchor point="TOPRIGHT" offsetX="0" offsetY="0" />
<!--<OnMoveStop>
craftingXP.OnMoveStop( self )
</OnMoveStop>-->
<Controls>
- <Backdrop name="$(parent)BG" inherits="ZO_DefaultBackdrop" opacity="0.6" />
-
- <Label name="$(parent)Zone" font="ZoFontTooltipTitle" color="EEEEEE"
+ <!--<Label name="$(parent)Zone" font="ZoFontAnnounceSmall" color="C5C29E"
wrapMode="ELLIPSIS" text="Zone:" horizontalAlignment="CENTER">
- <Anchor point="TOPLEFT" offsetY="0" />
- </Label>
+ <Anchor point="TOPLEFT" offsetY="-2" />
+ </Label>-->
- <Label name="$(parent)ZoneTime" font="ZoFontAnnounceSmall" color="C5C29E"
- wrapMode="ELLIPSIS" text="10h33m" horizontalAlignment="CENTER">
- <Anchor point="TOPLEFT" offsetX="50" />
+ <Label name="$(parent)ZoneTime" font="ZoFontGameSmall" color="CCCCCC"
+ wrapMode="ELLIPSIS" text="" horizontalAlignment="CENTER">
+ <Anchor point="TOPLEFT" offsetX="45" />
</Label>
- <Label name="$(parent)ZoneXP" font="ZoFontAnnounceSmall" color="C5C29E"
- wrapMode="ELLIPSIS" text="1000000 vp" horizontalAlignment="LEFT" opacity="0.85">
+ <Label name="$(parent)ZoneXP" font="ZoFontGameSmall" color="CCCCCC"
+ wrapMode="ELLIPSIS" text="" horizontalAlignment="LEFT" opacity="0.85">
<Anchor point="TOPLEFT" offsetX="90" />
</Label>
- <Label name="$(parent)ZoneRate" font="ZoFontAnnounceSmall" color="C5C29E"
- wrapMode="ELLIPSIS" text="1000000 vp/h" horizontalAlignment="RIGHT">
+ <Label name="$(parent)ZoneRate" font="ZoFontGameSmall" color="CCCCCC"
+ wrapMode="ELLIPSIS" text="" horizontalAlignment="RIGHT">
<Anchor point="TOPLEFT" offsetX="150" />
</Label>
-
- <Label name="$(parent)Reset" font="ZoFontTooltipTitle" color="EEEEEE"
+ <!--
+ <Label name="$(parent)Reset" font="ZoFontAnnounceSmall" color="C5C29E"
wrapMode="ELLIPSIS" text="Reset" horizontalAlignment="CENTER">
- <Anchor point="TOPLEFT" offsetY="30" />
+ <Anchor point="TOPLEFT" offsetY="18" />
</Label>
- <Label name="$(parent)CounterTime" font="ZoFontAnnounceSmall" color="C5C29E"
+ <Label name="$(parent)CounterTime" font="ZoFontGameSmall" color="BBBBBB"
wrapMode="ELLIPSIS" text="10h33m" horizontalAlignment="CENTER">
- <Anchor point="TOPLEFT" offsetY="30" offsetX="50" />
+ <Anchor point="TOPLEFT" offsetY="20" offsetX="45" />
</Label>
- <Label name="$(parent)CounterXP" font="ZoFontAnnounceSmall" color="C5C29E"
+ <Label name="$(parent)CounterXP" font="ZoFontGameSmall" color="BBBBBB"
wrapMode="ELLIPSIS" text="1000000 vp" horizontalAlignment="LEFT" opacity="0.85">
- <Anchor point="TOPLEFT" offsetY="30" offsetX="90" />
+ <Anchor point="TOPLEFT" offsetY="20" offsetX="90" />
</Label>
- <Label name="$(parent)CounterRate" font="ZoFontAnnounceSmall" color="C5C29E"
+ <Label name="$(parent)CounterRate" font="ZoFontGameSmall" color="BBBBBB"
wrapMode="ELLIPSIS" text="1000000 vp/h" horizontalAlignment="RIGHT">
- <Anchor point="TOPLEFT" offsetY="30" offsetX="150" />
- </Label>
+ <Anchor point="TOPLEFT" offsetY="20" offsetX="150" />
+ </Label> -->
</Controls>