changeset 27:c3aa94bc6be2

collating module-specific function into their own files and dropping the UI and Style scripts
author Nenue
date Wed, 13 Apr 2016 20:18:50 -0400
parents d5563cae5bf1
children c33c17dd97e7
files ObjectiveTracker/BonusObjectives.lua ObjectiveTracker/ObjectiveSecure.xml ObjectiveTracker/ObjectiveTracker.xml ObjectiveTracker/ObjectiveUI.lua ObjectiveTracker/Scenarios.lua ObjectiveTracker/SecureButton.xml
diffstat 6 files changed, 150 insertions(+), 208 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveTracker/BonusObjectives.lua	Wed Apr 13 20:18:50 2016 -0400
@@ -0,0 +1,66 @@
+--- ${PACKAGE_NAME}
+-- @file-author@
+-- @project-revision@ @project-hash@
+-- @file-revision@ @file-hash@
+-- Created: 4/13/2016 7:48 PM
+local B = select(2,...).frame
+local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
+local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
+local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
+local Default, Quest = T.DefaultHandler, T.Quest
+local format = format
+local print = B.print('Tracker')
+local lprint = B.print('Line')
+local iprint = B.print('Info')
+local Bonus = mod.Bonus
+
+
+--- Module-specific data wrangling that has to happen during UpdateBlock()
+-- Most of this is sculpting objectives data into a parsible list.
+-- Some of it is additional block manipulation that doesn't quite fit with the other modules..
+Bonus.UpdateObjectives = function(handler, block)
+  Default.UpdateObjectives(handler, block)
+end
+
+
+
+Bonus.UpdateLine = function(handler, block, line, data)
+  local info = block.info
+  local print = lprint
+
+
+  line.displayColor = 'FFFFFF'
+  line.displayText = data.text
+  line.progress = 0
+  print('  ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text)
+  if data.objectiveType == 'progressbar' then
+    line.widgetType = 'ProgressBar'
+    print('    |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID)))
+    data.value = GetQuestProgressBarPercent(info.questID) or 0
+    data.maxValue = 100
+    if  data.value >= data.maxValue then
+      line.progress = 1
+    elseif data.value > 0 then
+      line.progress = 2
+    end
+    line.format = PERCENTAGE_STRING
+    local widget = T.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex)
+    print('    |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue)
+    widget:SetPoint('TOP', line, 'TOP', 0, 0)
+
+    line.widget = widget
+    line.height = widget.height
+  else
+    line.displayText = data.text
+    line.widget = nil
+  end
+  return line
+end
+
+Bonus.Select = function(self)
+
+  Bonus:OnTurnIn(self.info.questID)
+end
+Bonus.Remove = function(self)
+
+end
\ No newline at end of file
--- a/ObjectiveTracker/ObjectiveSecure.xml	Wed Apr 13 11:21:38 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-<Ui>
-  <!--
-   The following was lifted from QuestKing, mainly to spare the horrors of writing a global space frame script
-  -->
-  <Button name="VeneerItemButtonTemplate" inherits="SecureActionButtonTemplate" virtual="true">
-    <Attributes>
-      <Attribute name="type" value="item" />
-    </Attributes>
-    <Layers>
-      <Layer level="ARTWORK">
-        <FontString parentKey="HotKey" inherits="NumberFontNormalSmallGray" justifyH="LEFT" text="RANGE_INDICATOR">
-          <Size x="29" y="10"/>
-          <Anchors>
-            <Anchor point="TOPRIGHT" x="16" y="-2"/>
-          </Anchors>
-        </FontString>
-      </Layer>
-      <Layer level="BORDER">
-        <Texture parentKey="icon"/>
-        <FontString parentKey="Count" inherits="NumberFontNormal" justifyH="RIGHT" hidden="true">
-          <Anchors>
-            <Anchor point="BOTTOMRIGHT" x="-3" y="2"/>
-          </Anchors>
-        </FontString>
-      </Layer>
-    </Layers>
-    <Frames>
-      <Cooldown parentKey="Cooldown" inherits="CooldownFrameTemplate"/>
-    </Frames>
-    <Scripts>
-      <OnLoad>
-        self:RegisterForClicks("AnyUp");
-      </OnLoad>
-      <OnEvent>
-        if (event == "PLAYER_TARGET_CHANGED") then
-          self.rangeTimer = -1;
-        elseif (event == "BAG_UPDATE_COOLDOWN") then
-          Veneer_QuestObjectiveItem_UpdateCooldown(self)
-        end
-      </OnEvent>
-      <OnUpdate function="Veneer_QuestObjectiveItem_OnUpdate" />
-      <OnShow>
-        self:RegisterEvent("PLAYER_TARGET_CHANGED");
-        self:RegisterEvent("BAG_UPDATE_COOLDOWN");
-      </OnShow>
-      <OnHide>
-        self:UnregisterEvent("PLAYER_TARGET_CHANGED");
-        self:UnregisterEvent("BAG_UPDATE_COOLDOWN");
-      </OnHide>
-      <OnEnter>
-        GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
-        GameTooltip:SetQuestLogSpecialItem(self.questLogIndex);
-      </OnEnter>
-      <OnLeave>
-        GameTooltip:Hide();
-      </OnLeave>
-    </Scripts>
-    <NormalTexture parentKey="NormalTexture" file="Interface\Buttons\UI-Quickslot2">
-      <Anchors>
-        <Anchor point="CENTER"/>
-      </Anchors>
-    </NormalTexture>
-    <PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/>
-    <HighlightTexture file="Interface\Buttons\ButtonHilight-Square" alphaMode="ADD"/>
-  </Button>
-</Ui>
\ No newline at end of file
--- a/ObjectiveTracker/ObjectiveTracker.xml	Wed Apr 13 11:21:38 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.xml	Wed Apr 13 20:18:50 2016 -0400
@@ -483,20 +483,19 @@
     </Layers>
   </Frame>
 
-  <Include file="ObjectiveSecure.xml" />
-  <Include file="ObjectiveWidgets.xml" />
+  <Include file="SecureButton.xml" />
+  <Include file="Widgets.xml" />
 
-  <Script file="ObjectiveCore.lua" />
-  <Script file="ObjectiveFrame.lua" />
-  <Script file="QuestTracker.lua" />
-  <Script file="AchievementsTracker.lua" />
-  <Script file="AutoQuestPopUpTracker.lua" />
-  <Script file="BonusObjectiveTracker.lua" />
-  <Script file="ScenarioTracker.lua" />
-  <Script file="XPTracker.lua" />
+  <Script file="ObjectiveTracker.lua" />
+  <Script file="Frame.lua" />
+  <Script file="Quests.lua" />
+  <Script file="Achievements.lua" />
+  <Script file="AutoQuestPopups.lua" />
+  <Script file="BonusObjectives.lua" />
+  <Script file="ScenarioObjectives.lua" />
+  <Script file="ExerienceBar.lua" />
   <Script file="ObjectiveInfo.lua" />
-  <Script file="ObjectiveUI.lua" />
   <Script file="ObjectiveStyle.lua" />
-  <Script file="ObjectiveEvents.lua" />
-  <Script file="ObjectiveWidgets.lua" />
+  <Script file="Events.lua" />
+  <Script file="Widgets.lua" />
 </Ui>
\ No newline at end of file
--- a/ObjectiveTracker/ObjectiveUI.lua	Wed Apr 13 11:21:38 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
---- ${PACKAGE_NAME}
--- @file-author@
--- @project-revision@ @project-hash@
--- @file-revision@ @file-hash@
--- Created: 3/29/2016 7:07 PM
-local B = select(2,...).frame
-local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
-local print = B.print('Objectives')
-local Default, AutoQuest, Quest, Cheevs = mod.DefaultHandler, mod.AutoQuest, mod.Quest, mod.Cheevs
-local itemButtonSize, itemButtonSpacing =  36, 1
-local tremove, tremovebyval = table.remove, table.removebyval
-
---------------------------------------------------------------------
---- Functions responsible for:
---- - UI interactions that propagate to the BlizzardUI (sending RemoveQuestWatch() on remove quest action)
---- -
---------------------------------------------------------------------
-
-Default.Select = function(self) end
-Default.Open = function(self) end
-Default.Remove = function(self) end
-Default.Report = function(self)
-  print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.')
-end
-
-Default.OnMouseUp = function(self, button)
-
-  print(self.handler.name, self.mainStyle, self.subStyle)
-  if button == 'LeftButton' then
-    if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then
-      self:Link()
-    elseif IsModifiedClick("QUESTWATCHTOGGLE") then
-      self:Remove()
-    else
-      self:Select()
-    end
-  elseif button == 'RightButton' then
-    self:Open()
-  end
-  self.initialButton = nil
-  self.modChatLink = nil
-  self.modQuestWatch = nil
-  mod:Update(self.handler.updateReasonModule)
-  print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r')
-end
-
-Default.OnMouseDown = function(self, button)
-
-  print(IsModifiedClick("CHATLINK"), IsModifiedClick("QUESTWATCHTOGGLE"))
-  print(self.info.title)
-end
-
-AutoQuest.Select = function(self)
-
-  if self.info.popupType == 'OFFER'  then
-    ShowQuestOffer(self.info.questIndex)
-  else
-    ShowQuestComplete(self.info.questIndex)
-  end
-  RemoveAutoQuestPopUp(self.info.questID)
-end
-
-Quest.Select = function(self)
-
-  if self.info.isAutoComplete and self.info.isComplete then
-    ShowQuestComplete(self.info.questLogIndex)
-  else
-    SetSuperTrackedQuestID(self.info.questID)
-  end
-end
-
-Quest.Link = function(self)
-
-  local questLink = GetQuestLink(self.info.questLogIndex);
-  if ( questLink ) then
-    ChatEdit_InsertLink(questLink);
-  end
-end
-
-AutoQuest.Link = Quest.Link
-
-Quest.Open = function(self)
-
-  QuestMapFrame_OpenToQuestDetails(self.info.questID)
-end
-
-Quest.Remove = function(self)
-
-  print('removing', self.info.questLogIndex, 'from watcher')
-  RemoveQuestWatch(self.info.questLogIndex)
-end
-
-
------------------------------
---- CHEEVS
-Cheevs.Select = function(self)
-  --mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT)
-end
-Cheevs.Remove = function(self)
-
-  RemoveTrackedAchievement(self.info.cheevID)
-end
-Cheevs.OnMouseUp = function(self, button)
-
-  Default.OnMouseUp(self, button)
-end
-Cheevs.Link = function(self)
-
-  local achievementLink = GetAchievementLink(self.info.cheevID);
-  if ( achievementLink ) then
-    ChatEdit_InsertLink(achievementLink);
-  end
-end
-
-Cheevs.Open = function(self)
-
-  if ( not AchievementFrame ) then
-    AchievementFrame_LoadUI();
-  end
-  if ( not AchievementFrame:IsShown() ) then
-    AchievementFrame_ToggleAchievementFrame();
-  end
-  AchievementFrame_SelectAchievement(self.info.cheevID);
-end
-
-local Bonus = mod.Bonus
-Bonus.Select = function(self)
-
-  Bonus:OnTurnIn(self.info.questID)
-end
-Bonus.Remove = function(self)
-
-end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveTracker/Scenarios.lua	Wed Apr 13 20:18:50 2016 -0400
@@ -0,0 +1,6 @@
+--- ${PACKAGE_NAME}
+-- @file-author@
+-- @project-revision@ @project-hash@
+-- @file-revision@ @file-hash@
+-- Created: 4/13/2016 8:17 PM
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveTracker/SecureButton.xml	Wed Apr 13 20:18:50 2016 -0400
@@ -0,0 +1,66 @@
+<Ui>
+  <!--
+   The following was lifted from QuestKing, mainly to spare the horrors of writing a global space frame script
+  -->
+  <Button name="VeneerItemButtonTemplate" inherits="SecureActionButtonTemplate" virtual="true">
+    <Attributes>
+      <Attribute name="type" value="item" />
+    </Attributes>
+    <Layers>
+      <Layer level="ARTWORK">
+        <FontString parentKey="HotKey" inherits="NumberFontNormalSmallGray" justifyH="LEFT" text="RANGE_INDICATOR">
+          <Size x="29" y="10"/>
+          <Anchors>
+            <Anchor point="TOPRIGHT" x="16" y="-2"/>
+          </Anchors>
+        </FontString>
+      </Layer>
+      <Layer level="BORDER">
+        <Texture parentKey="icon"/>
+        <FontString parentKey="Count" inherits="NumberFontNormal" justifyH="RIGHT" hidden="true">
+          <Anchors>
+            <Anchor point="BOTTOMRIGHT" x="-3" y="2"/>
+          </Anchors>
+        </FontString>
+      </Layer>
+    </Layers>
+    <Frames>
+      <Cooldown parentKey="Cooldown" inherits="CooldownFrameTemplate"/>
+    </Frames>
+    <Scripts>
+      <OnLoad>
+        self:RegisterForClicks("AnyUp");
+      </OnLoad>
+      <OnEvent>
+        if (event == "PLAYER_TARGET_CHANGED") then
+          self.rangeTimer = -1;
+        elseif (event == "BAG_UPDATE_COOLDOWN") then
+          Veneer_QuestObjectiveItem_UpdateCooldown(self)
+        end
+      </OnEvent>
+      <OnUpdate function="Veneer_QuestObjectiveItem_OnUpdate" />
+      <OnShow>
+        self:RegisterEvent("PLAYER_TARGET_CHANGED");
+        self:RegisterEvent("BAG_UPDATE_COOLDOWN");
+      </OnShow>
+      <OnHide>
+        self:UnregisterEvent("PLAYER_TARGET_CHANGED");
+        self:UnregisterEvent("BAG_UPDATE_COOLDOWN");
+      </OnHide>
+      <OnEnter>
+        GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
+        GameTooltip:SetQuestLogSpecialItem(self.questLogIndex);
+      </OnEnter>
+      <OnLeave>
+        GameTooltip:Hide();
+      </OnLeave>
+    </Scripts>
+    <NormalTexture parentKey="NormalTexture" file="Interface\Buttons\UI-Quickslot2">
+      <Anchors>
+        <Anchor point="CENTER"/>
+      </Anchors>
+    </NormalTexture>
+    <PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/>
+    <HighlightTexture file="Interface\Buttons\ButtonHilight-Square" alphaMode="ADD"/>
+  </Button>
+</Ui>
\ No newline at end of file