Signed-off-by: His Dad <John@hisdad.org>

His Dad [09-25-16 - 18:03]
Signed-off-by: His Dad <John@hisdad.org>
Filename
HistOffline.lua
data/Group1.lua
data/Group2.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index 164ff5f..afa9435 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -25,7 +25,7 @@ Grp2_Order={"2N","2V","2VH"}
 for _,i in ipairs(Grp_Order) do
 	Grp_Dat[i]={}
 end
-
+dofile "./data/Keys.lua"		--Linking tables, must do first
 dofile "./data/DLC.lua"	--Achievement to Grid lookup, language independent
 dofile "./data/Group1.lua"		-- Grp Mode 1 data, N, V, VH
 dofile "./data/Group2.lua"		-- Grp Mode 2 data, N, V, VH
@@ -36,7 +36,7 @@ dofile "./data/WB.lua"
 dofile "./data/Trial.lua"


-dofile "./data/Keys.lua"		--Linking tables
+
 dump = function (o)
    if type(o) == 'table' then
       local s = '{ '
@@ -128,31 +128,13 @@ accounts = {}
 accounts_list = {}		-- String list for selection dialog
 playerNames = {}		-- Get name from ID.

-for i,_ in pairs(History_SV["Default"]) do
-	accounts[i] = {}
-	accounts[i].playerIDs = {}	-- intermediate table for sorting. WIP. Array formatted.
-	accounts[i].playerIDs_vet= {}	--subset of names which are >L50
-	table.insert(accounts_list, i)
-end
-
--- Load up playerIDs, as a first run through. It's a sortable array.
--- This is used as an indirection to control presentation order
- for acc,_ in pairs (accounts) do
-  for playerID, _ in pairs(History_SV["Default"][acc]["$AccountWide"]["data"]) do
-      table.insert (accounts[acc].playerIDs, playerID)
-	  accounts[acc].playerIDs[playerID] = {}		-- stub table to hold char data
-  end
- end
-
+for acc,_ in pairs(History_SV["Default"]) do
+	accounts[acc] = {}
+	accounts[acc].player = {}
+	accounts[acc].playerIDs = {}	-- intermediate table for sorting. WIP. Controls presentation order
+	accounts[acc].playerIDs_vet= {}	--subset of names which are >L50
+	table.insert(accounts_list, acc)

-
--- set up some static data
-
-
---[[ ==========================================
-	Iterate over all accounts and PlayerIDs creating display items
---]]
- for acc,_ in pairs (accounts) do
   -- ===	Load Language Tables
     accounts[acc].lang = (History_SV["Default"][acc]["$AccountWide"].lang)
 	if accounts[acc].lang == nil then
@@ -169,6 +151,54 @@ end
 	DLC_Location_names = lingua[accounts[acc].lang].DLC_Location_names
 	Ach_Detail = lingua[accounts[acc].lang].Ach_Detail

+
+-- Load Character Data
+	for playerID, _ in pairs(History_SV["Default"][acc]["$AccountWide"]["data"]) do
+		table.insert (accounts[acc].playerIDs, playerID)
+		accounts[acc].player[playerID] = {}		-- stub table to hold char data, later becomes "me"
+--
+		local me = accounts[acc].player[playerID]											-- shorter reference: our code
+		local thischar = History_SV["Default"][acc]["$AccountWide"]["data"][playerID]	-- shorter reference: History DB
+		-- Pull in some char data for processing
+		if thischar.name == nil  then --	Old Format
+	--	    print("Old Format  " .. playerID)
+			me.name = playerID
+		else
+			me.name = thischar.name
+		end
+		playerNames[playerID]=me.name
+
+		-- == Gender
+		if thischar.Gender =="M" then
+			me.gender = L.Male
+		elseif thischar.Gender == "F" then
+			me.gender = L.Female
+		end
+		-- ==Level
+		local level = thischar.level
+
+		me.level = level
+		if (level <=50) then
+			me.levelstr = tostring(level)
+			me.isvet = false
+		else
+			me.levelstr = "V" .. tostring(level -50)
+			me.isvet = true
+			table.insert(accounts[acc].playerIDs_vet,playerID)
+		end
+		-- == Cumulative TimePlayed
+		me.timeplayed = math.floor(thischar.levels[level].time/60)
+	end
+end
+
+
+
+
+--[[ ==========================================
+	Iterate over all accounts and PlayerIDs creating display items
+--]]
+ for acc,_ in pairs (accounts) do
+
   -- ====  Accountwide Data
   -- Setup Log data
 	accounts[acc].logtabs  =iup.tabs{}
@@ -268,13 +298,19 @@ end
 						iup.fill{},
 					}

+	--set lines Heading
+	dung.Grp[i].box:setcell(0,0, L.Location)
 	--Set Line titles
-	for i,key in ipairs(grp2tokey) do
---		dung.Grp[i].box:setcell(i, 0, grp_names[key])
+	for line,key in ipairs(Grp_Dat[i].key) do
+		dung.Grp[i].box:setcell(line, 0, grp_names[key])
+	end
+
+	--Create Columns for Chars
+	for col ,playerID in ipairs(accounts[acc].playerIDs) do
+		dung.Grp[i].box:setcell(0, col, playerNames[playerID])
 	end
-	--set lines
---	dung.Grp[i].box:setcell(0,0, L.Location)

+	iup.SetAttribute(dung.Grp[i].box, "READONLY", "YES")
   end

   dung.trials = {}
@@ -284,17 +320,13 @@ end
   -- a table for each dungeon to which we add characters
   for _,i in ipairs(Grp1_Order) do
     for _,j in ipairs(grp1tokey) do
-	  dung.Grp[i][j] = {}
-	  dung.Grp[i][j] = {}
-	  dung.Grp[i][j] = {}
+	  dung.Grp[i].key[j] = {}
 	end
   end

   for _,i in ipairs(Grp2_Order) do
     for _,j in ipairs(grp2tokey) do
-	  dung.Grp[i][j] = {}
-	  dung.Grp[i][j] = {}
-	  dung.Grp[i][j] = {}
+	  dung.Grp[i].key[j] = {}
 	end
   end

@@ -317,37 +349,9 @@ end

 -- Creates boxes, stage from names to allow optional sorting in future.
 	for _,playerID in ipairs(accounts[acc].playerIDs) do
-		local me = accounts[acc].playerIDs[playerID]											-- shorter reference: our code
+		local me = accounts[acc].player[playerID]											-- shorter reference: our code
 		local thischar = History_SV["Default"][acc]["$AccountWide"]["data"][playerID]	-- shorter reference: History DB
-		-- Pull in some char data for processing
-		if thischar.name == nil  then --	Old Format
-	--	    print("Old Format  " .. playerID)
-			me.name = playerID
-		else
-			me.name = thischar.name
-		end
-		playerNames[playerID]=me.name

-		-- == Gender
-		if thischar.Gender =="M" then
-			me.gender = L.Male
-		elseif thischar.Gender == "F" then
-			me.gender = L.Female
-		end
-		-- ==Level
-		local level = thischar.level
-
-		me.level = level
-		if (level <=50) then
-			me.levelstr = tostring(level)
-			me.isvet = false
-		else
-			me.levelstr = "V" .. tostring(level -50)
-			me.isvet = true
-			table.insert(accounts[acc].playerIDs_vet,playerID)
-		end
-		-- == Cumulative TimePlayed
-		me.timeplayed = math.floor(thischar.levels[level].time/60)

 		-- Generate the leveling box.  ============================

@@ -385,10 +389,9 @@ end
 		end
 		-- Create Grp Dungeon Boxes ====================================
 		me.Grp ={}		-- Put them all together
-		me.Grp_Display_Order ={}	-- Store also in here for display by ipairs
+
 		for _, i in ipairs(Grp_Order) do		-- For Each Grp Dungeon
 			me.Grp[i] = {}						--  Dungeon data storage
-			me.Grp[i].name= L.Grp_TabName[i]
 			me.Grp[i].vet = Grp_Dat[i].vet
 			me.Grp[i].box = iup.matrix {numcol=4, numcol_visible=4,  numlin=5, widthdef=100}

@@ -404,8 +407,6 @@ end
 			iup.SetAttribute(me.Grp[i].box,  "FGCOLOR*:3", FG_Colour_Not_Complete)
 			iup.SetAttribute(me.Grp[i].box,  "FGCOLOR*:4", FG_Colour_Not_Complete)

-			table.insert(me.Grp_Display_Order, me.Grp[i])
-
 			-- set text to black if achievement found.

 			for id,_ in pairs (Grp_Dat[i]) do
@@ -421,7 +422,7 @@ end

 			-- Create display tab
 			me.Grp[i].tab = iup.vbox {
-						["tabtitle"] =me.Grp[i].name,
+						["tabtitle"] =L.Grp_TabName[i],
 						me.Grp[i].box,
 						iup.fill{},
 				}
@@ -913,10 +914,10 @@ end

 		me.data_tabs = iup.tabs{} --Data tabs for Char
 		-- All Grp Dungeons
-		for _,i in ipairs (me.Grp_Display_Order) do
-			if me.isvet or i.vet == false then
+		for _,i in ipairs (Grp_Order) do
+			if me.isvet or me.Grp[i].vet == false then
 				-- non vet chars only see non-vet dungeons
-				iup.Append(me.data_tabs, i.tab)
+				iup.Append(me.data_tabs, me.Grp[i].tab)
 			end
 		end

@@ -1039,6 +1040,20 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 	-- Grp Dungeons  ===========================================
 	for _,i in ipairs (Grp_Order) do
 		iup.Append(accounts[acc].dung_tabs, dung.Grp[i].tab)
+
+		-- Populate with character data ============================
+		for line,key in ipairs(dung.Grp[i].key) do		-- over each dungeon
+			-- does that char exist in the table.
+			for col,playerID in ipairs(accounts[acc].playerIDs) do	-- over each char in order
+				if dung.Grp[i].key[key][playerID] == nil then
+					dung.Grp[i].box:setcell(line,col, "N")
+					iup.SetAttribute(dung.Grp[i].box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Not_Complete)
+				else
+					dung.Grp[i].box:setcell(line,col, "Y")
+					iup.SetAttribute(dung.Grp[i].box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Complete)
+				end
+			end
+	end
 	end

 	-- Create DLC Dungeon Character Box=========================
diff --git a/data/Group1.lua b/data/Group1.lua
index d0b614c..6e32a33 100644
--- a/data/Group1.lua
+++ b/data/Group1.lua
@@ -23,6 +23,7 @@ Grp_Dat["1N"].dat = {
 [570]= {L=5, C=4},		-- "Vaults of Madness Vanquisher"
 }
 Grp_Dat["1N"].vet = false
+Grp_Dat["1N"].key=grp1tokey	-- from keys.lua file


 Grp_Dat["1V"].dat = {
@@ -47,6 +48,7 @@ Grp_Dat["1V"].dat = {
 [1653]= {L=5, C=4},		-- "Vaults of Madness Conqueror"
 }
 Grp_Dat["1V"].vet = true
+Grp_Dat["1V"].key=grp1tokey	-- from keys.lua file

 --Hard Mode
 Grp_Dat["1VH"].dat = {
@@ -71,4 +73,5 @@ Grp_Dat["1VH"].dat = {
 [1658]= {L=5, C=4},		-- "New Mayor of Crazy Town"
 }

-Grp_Dat["1VH"].vet = true
\ No newline at end of file
+Grp_Dat["1VH"].vet = true
+Grp_Dat["1VH"].key=grp1tokey	-- from keys.lua file
diff --git a/data/Group2.lua b/data/Group2.lua
index f65f08a..3b45e1c 100644
--- a/data/Group2.lua
+++ b/data/Group2.lua
@@ -25,6 +25,7 @@ Grp_Dat["2N"].dat = {
 -- [570]= {L=5, C=4},		-- "Vaults of Madness Vanquisher"
 }
 Grp_Dat["2N"].vet = false
+Grp_Dat["2N"].key=grp2tokey	-- from keys.lua file

 Grp_Dat["2V"].dat = {
 [343]= {L=1, C=1},		-- "Fungal Grotto II Conqueror"
@@ -48,6 +49,7 @@ Grp_Dat["2V"].dat = {
 -- [570]= {L=5, C=4},		-- "Vaults of Madness Vanquisher"
 }
 Grp_Dat["2V"].vet = true
+Grp_Dat["2V"].key=grp2tokey	-- from keys.lua file

 -- Hard Mode Activated
 Grp_Dat["2VH"].dat = {
@@ -72,3 +74,4 @@ Grp_Dat["2VH"].dat = {
 -- [570]= {L=5, C=4},		-- "Vaults of Madness Vanquisher"
 }
 Grp_Dat["2VH"].vet = true
+Grp_Dat["2VH"].key=grp2tokey	-- from keys.lua file