Quantcast

* Display archaeology skill level next to title

Jesse Adams [02-23-11 - 15:09]
* Display archaeology skill level next to title
* Add slash commands to show/hide
* Add slash commands to set alpha (0.0 - 1.0) and scale (0.0 - 2.0)
* Make sure configuration settings persist
* Handle characters that do not have archaeology a bit better
Filename
README
Solvent.lua
Solvent.toc
sounds/shooting_star.mp3
diff --git a/README b/README
index fff3daf..bfcacd8 100644
--- a/README
+++ b/README
@@ -6,11 +6,11 @@ Ludus of Naz'jatar-US
 The trollers of #wowuidev on irc.freenode.net

 Upcoming Changes:
-* Display archaeology skill level next to title, unless skill is maxed
 * Double right-click surveying
 * Click on artifact bar to solve (when yellow)
-* Add slash commands to show/hide
 * Add slash command to automatically solve everything that is possible to solve, no matter what it takes
+* Make a configuration dialog
+* Make the window position persist

 Things to Test:
 * All races in queue
@@ -18,6 +18,13 @@ Things to Test:

 Changelog:

+2011-02-23:
+* Display archaeology skill level next to title
+* Add slash commands to show/hide
+* Add slash commands to set alpha (0.0 - 1.0) and scale (0.0 - 2.0)
+* Make sure configuration settings persist
+* Handle characters that do not have archaeology a bit better
+
 2011-02-20:
 * Rare artifacts should have blue statusbar color
 * Statusbar color should change to yellow when artifact is solvable
diff --git a/Solvent.lua b/Solvent.lua
index c5aeed8..5319a7f 100644
--- a/Solvent.lua
+++ b/Solvent.lua
@@ -1,5 +1,9 @@
 SOLVENT_DEBUG = false

+solventDefaultEnabled = true
+solventDefaultScale = 1.0
+solventDefaultAlpha = 1.0
+
 function TotalKeystonesFromBags()
   keystones = {
     { -- Dwarf
@@ -92,7 +96,7 @@ function SolventGetCurrentArtifacts()

   prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions();
   if not archaeology then
-    SolventSolveFrame:Hide()
+    DEFAULT_CHAT_FRAME:AddMessage("Solvent: You need to train Archaeology before I can function!")
     return
   end
   name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(archaeology)
@@ -137,7 +141,7 @@ function SolventGetCurrentArtifacts()
           DEFAULT_CHAT_FRAME:AddMessage("No Frame for " .. raceName .. ", creating...")
         end

-        statusBars[i] = CreateFrame("Frame", "SolventSolveFrameRow" .. raceName, UIParent, "SolventRowTemplate")
+        statusBars[i] = CreateFrame("Frame", "SolventSolveFrameRow" .. raceName, SolventSolveFrame, "SolventRowTemplate")
         statusBars[i]:SetWidth(200)
         statusBars[i]:SetHeight(12)

@@ -184,18 +188,28 @@ function SolventGetCurrentArtifacts()

       lastRaceName = raceName
     end
+
+    if skillLevel == maxSkillLevel then
+      SolventSolveFrameAddonTitleText:SetText("Solvent - Archaeology " .. skillLevel)
+    else
+      SolventSolveFrameAddonTitleText:SetText("Solvent - Archaeology " .. skillLevel .. ' / ' .. maxSkillLevel)
+    end
   end
 end

 function SolventStartup()
-  DEFAULT_CHAT_FRAME:AddMessage("Solvent Archaeology Addon Loaded!")
-  RequestArtifactCompletionHistory()
-  --SolventGetCurrentArtifacts()
+ DEFAULT_CHAT_FRAME:AddMessage("Solvent Archaeology Addon Loaded!")
+ RequestArtifactCompletionHistory()
 end

 surveyDetected = false
 initiallyLoaded = false
 function SolventHandleEvent(frame, eventName, ...)
+  if eventName == 'VARIABLES_LOADED' then
+    SolventProcessVariables()
+    return
+  end
+
   --print(eventName)
   if eventName == "ARTIFACT_HISTORY_READY" then
     initiallyLoaded = true
@@ -214,12 +228,86 @@ function SolventHandleEvent(frame, eventName, ...)
   end
 end

+solventRealm = GetCVar("realmName")
+solventCharacter = UnitName("player")
+function SolventProcessVariables()
+	if not solventConfig then
+	 	solventConfig = {};
+	end
+
+	if not solventConfig[solventRealm] then
+	 	solventConfig[solventRealm] = {};
+	end
+
+	if not solventConfig[solventRealm][solventCharacter] then
+	 	solventConfig[solventRealm][solventCharacter] = {};
+	end
+
+  if not solventConfig[solventRealm][solventCharacter].enabled then
+		solventConfig[solventRealm][solventCharacter].enabled = solventDefaultEnabled;
+	end
+
+	if not solventConfig[solventRealm][solventCharacter].scale then
+		solventConfig[solventRealm][solventCharacter].scale = solventDefaultScale;
+	end
+
+	if not solventConfig[solventRealm][solventCharacter].alpha then
+		solventConfig[solventRealm][solventCharacter].alpha = solventDefaultAlpha;
+	end
+
+  variablesLoaded = true;
+	processConfigChange();
+end
+
+function processConfigChange()
+  if not variablesLoaded then return end
+
+  if solventConfig[solventRealm][solventCharacter].enabled then
+    SolventSolveFrame:Show()
+  else
+    SolventSolveFrame:Hide()
+  end
+  solventConfig[solventRealm][solventCharacter].alpha = 1
+  SolventSolveFrame:SetBackdropColor(1, 1, 1, solventConfig[solventRealm][solventCharacter].alpha)
+  SolventSolveFrame:SetBackdropBorderColor(1, 1, 1, solventConfig[solventRealm][solventCharacter].alpha)
+  SolventSolveFrame:SetScale(solventConfig[solventRealm][solventCharacter].scale)
+end
+
 dframe = CreateFrame("Frame", nil, UIParent)
 dframe:RegisterEvent("CURRENCY_DISPLAY_UPDATE");
 dframe:RegisterEvent("ARTIFACT_HISTORY_READY")
 dframe:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
 dframe:RegisterEvent("ARTIFACT_COMPLETE")
+dframe:RegisterEvent("VARIABLES_LOADED")
 --dframe:RegisterEvent("ARTIFACT_UPDATE");       ONLY AFTER SOLVING!
 dframe:RegisterEvent("BAG_UPDATE");
 dframe:SetScript("OnEvent", SolventHandleEvent);

+SLASH_SOLVENT1 = '/solvent';
+local function modify_display(msg, editbox)
+  local command, rest = msg:match("^(%S*)%s*(.-)$");
+
+  if command == 'hide' then
+    solventConfig[solventRealm][solventCharacter].enabled = false
+    processConfigChange()
+  elseif command == 'show' then
+    solventConfig[solventRealm][solventCharacter].enabled = true
+    processConfigChange()
+  elseif command == 'alpha' then
+    alpha = tonumber(rest)
+    if alpha >= 0 and alpha <= 1 then
+      solventConfig[solventRealm][solventCharacter].alpha = alpha
+      processConfigChange()
+    end
+  elseif command == 'scale' then
+    scale = tonumber(rest)
+    if scale >= 0 and scale <= 2 then
+      solventConfig[solventRealm][solventCharacter].scale = scale
+      processConfigChange()
+    end
+  else
+    print("Usage: /solvent [show hide]")
+  end
+end
+SlashCmdList["SOLVENT"] = modify_display;
+
diff --git a/Solvent.toc b/Solvent.toc
index cbb3fe4..5edf0df 100644
--- a/Solvent.toc
+++ b/Solvent.toc
@@ -2,5 +2,6 @@
 ## Name: Solvent
 ## Notes: Arch surveying and solving tool
 ## Author: techno-geek
+## SavedVariables: solventConfig
 Solvent.lua
 Solvent.xml
diff --git a/sounds/shooting_star.mp3 b/sounds/shooting_star.mp3
index c2c7f7d..db64bd6 100644
Binary files a/sounds/shooting_star.mp3 and b/sounds/shooting_star.mp3 differ