Restructure SQ

His Dad [05-10-15 - 00:53]
Restructure SQ
Filename
HistOffline.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index 9cb4960..c29b0db 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -95,6 +95,32 @@ load_lang("de")
 print(dump(lingua["de"].Ach_Detail))
 --]]

+--[[ Load Skill Giving Quest boxes. These are the same for all users, we just change the highlighting
+	This is not account dependent.
+
+--]]
+--SQ_Dat loaded  from data.lua
+
+SQ_Info= {} -- keyed by "LC" string as the  ZONE Identifier
+for id,_ in pairs (SQ_dat) do  -- Load all Quest Data by Achievement ID
+		local L = SQ_dat[id].L
+		local C = SQ_dat[id].C
+		key = tostring(L) .. tostring(C)	-- make name key
+
+		if SQ_Info[key] == nil then
+			SQ_Info[key] = {}
+			SQ_Info[key].quest = {}
+			SQ_Info[key].quests = {}
+			SQ_Info[key].L = L	-- Save separating it out from key later
+			SQ_Info[key].C = C
+		end
+
+		table.insert(SQ_Info[key].quests,id)
+end
+
+
+
+
 accounts = {}
 accounts_list = {}		-- String list for selection dialog
 naccounts = 0
@@ -573,34 +599,39 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 		iup.SetAttribute(accounts[acc].name[char].SQ_box,  "FGCOLOR*:5", Colour_Not_Complete)

 		-- Need to keep track of multiple achievements for SQ in Zones. Index them by zone LineColumn.
-		SQ_Info = accounts[acc].name[char].SQ_Info
-		SQ_Area={}
-		SQ_count = {}
-		for id,_ in pairs (SQ_dat) do  -- Load all Quest Data. Info LC is the ZONE Identifier
-				local L = SQ_dat[id].L
-				local C = SQ_dat[id].C
+		thisSQ_Info = accounts[acc].name[char].SQ_Info
+		SQ_Faction={}
+		local count = 0
+
+		-- Set up box with default data
+		for C=1, 4 do
+			for L = 1, 5 do
 				key = tostring(L) .. tostring(C)	-- make name key
 				dname = Locations[key]				-- Zone Locations
-					if dname == nil then
-				dname = "key " .. key .." not found"
+				if dname == nil then
+					break	-- only 1 in Coldharbour
 				end

-				if SQ_Info[key] == nil then
-					SQ_Info[key] = {}
-					SQ_Info[key].quest = {}
-					SQ_Info[key].allquest = {}
-					SQ_Info[key].L = L	-- Save separating it out from key later
-					SQ_Info[key].C = C
-					SQ_count[key] = {count= 0}
-					SQ_Area[C] =0
-				end
-				--print("Added  " .. id)
-				table.insert(SQ_Info[key].allquest,id)
+		--			SQ_count[key] = {count= 0}
+			--		SQ_Faction[C] =0

-				accounts[acc].name[char].SQ_box:setcell(L,C,dname .. " (0)")
-		end
+				for _, id in ipairs (SQ_Info[key].quests) do	-- get the quests of the zone
+				--	print (dump(id))

+					if  thischar.ach[id] ~= nil then	-- Have we got it?
+						count =count +1
+					end
+				end
+				accounts[acc].name[char].SQ_box:setcell(L,C,dname .. " (" .. tostring(count) .. ")")

+				if count == #SQ_Info[key].quests then		-- Got them all??
+					local colour_cell = "FGCOLOR" .. L .. ":" .. C
+					iup.SetAttribute(accounts[acc].name[char].SQ_box, colour_cell , Colour_Complete)
+				end
+			end   -- L
+		end		--
+--[[
+		-- Customise it with our achievements
 		for id,_ in pairs (SQ_dat) do  -- For Achievements we have..
 			if thischar.ach[id] ~= nil then
 				local L = SQ_dat[id].L
@@ -624,16 +655,13 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 				SQ_Area[C] = SQ_Area[C] +1


-			-- This is where we store detail for each cell for popup
-			-- For each LC, lookup the quest ID's that we have.
-
-			table.insert(SQ_Info[key].quest, id)
 			end
 		end
+		--]]
 -- Create SkillQuest Achievements Detail Boxes=======================
 		accounts[acc].name[char].SQ_Detail_box= {}
 		accounts[acc].name[char].SQ_Frame = iup.frame{title = "Quest Details"} -- Panel for details
-
+--[[
 		local info, name, link
 		for key, info in pairs(SQ_Info) do	-- for each zone
 			--print (key, dump(info))
@@ -648,9 +676,9 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 			iup.SetAttribute(thisbox, "ALIGNMENT1", "ALEFT")
 			iup.SetAttribute(thisbox, "ALIGNMENT2", "ALEFT")
 			iup.SetAttribute(thisbox,"WIDTH0", "30")
-			iup.SetAttribute(thisbox,"WIDTH1", "120")
-			iup.SetAttribute(thisbox,"WIDTH2", "220")
-			for _, id in ipairs (info.allquest) do	-- get the quests of the zone
+			iup.SetAttribute(thisbox,"WIDTH1", "150")
+			iup.SetAttribute(thisbox,"WIDTH2", "250")
+			for _, id in ipairs (info.quests) do	-- get the quests of the zone
 			--	print (dump(id))
 				thisbox.numlin = Line
 				thisbox:setcell(Line,0, tostring(id))
@@ -661,14 +689,16 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 				name = Ach_Detail[id].name
 				end
 				link = SQ_dat[id].link1
-				thisbox:setcell(Line,3, link)
+				thisbox:setcell(Line,1, name)
+				thisbox:setcell(Line,2, link)
 				--print(name, link)
 				Line= Line+1
 			end
 		end

-		iup.Append(accounts[acc].name[char].SQ_Frame, accounts[acc].name[char].SQ_Detail_box["11"])

+		iup.Append(accounts[acc].name[char].SQ_Frame, accounts[acc].name[char].SQ_Detail_box["11"])
+--]]
 	 -- ====================================
 	--  == Prepare for the user display tabs
 		accounts[acc].name[char].tab = iup.vbox{
@@ -721,7 +751,7 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 									iup.vbox {	["tabtitle"] =L.SkillQuests,
 												iup.label{title=L.SkillLab,expand="HORIZONTAL"},
 												accounts[acc].name[char].SQ_box,
-												accounts[acc].name[char].SQ_Frame,
+									--			accounts[acc].name[char].SQ_Frame,
 												iup.fill{}
 											},
 								},	-- end of tabs for dungeons
@@ -735,7 +765,7 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 		elseif panel >950 then
 			panel = 950
 		end
-		accounts[acc].panelsize =  tostring(panel) ..  "x250"
+		accounts[acc].panelsize =  tostring(panel) ..  "x300"
 	end  -- Chars

 -- Add to end of Characters