Update 49, Option to hide chars in Dungeon mode

His Dad [08-03-18 - 06:03]
Update 49, Option to hide chars in Dungeon mode

Signed-off-by: His Dad <John@hisdad.org>
Filename
Doc/Changelog.txt
HistOffline.lua
data/de/de.lua
data/en/en.lua
data/fr/fr.lua
history.txt
diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt
index bfe9899..fdf11e6 100644
--- a/Doc/Changelog.txt
+++ b/Doc/Changelog.txt
@@ -1,3 +1,6 @@
+2018-08-03 version 49
+	Add Toggle to hide characters that have completed all dungeons (Dungeon Mode)
+
 2018-05-18  version 48
 	Made TG/DB/Clockwork Groups Bosses available.

diff --git a/HistOffline.lua b/HistOffline.lua
index d544817..ef97607 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -16,7 +16,7 @@ local dname, key, count, ccount, colour, bgcolour
 --force_lang = "fr"  --	or "de" or "en"  for debugging

 -- ========================
-version= "48"
+version= "49"
 require( "iuplua" )
 require( "iupluacontrols" )
 iup.SetGlobal("UTF8MODE","YES")
@@ -42,10 +42,10 @@ dofile "./data/Group1.lua"		-- Grp Mode 1 data, N, V, VH
 dofile "./data/Group2.lua"		-- Grp Mode 2 data, N, V, VH
 dofile "./data/Public.lua"
 dofile "./data/Quest.lua"
-dofile "./data/Veteran.lua"		-- Auxillary Achievements for Vet Dungeons
+dofile "./data/Veteran.lua"		-- Auxiliary Achievements for Vet Dungeons
 dofile "./data/WB.lua"
 dofile "./data/Trials.lua"
-dofile "./data/Special.lua"		-- Record of non standard Achievment ID's we need to keep.
+dofile "./data/Special.lua"		-- Record of non standard Achievement ID's we need to keep.
 dofile "./data/utility.lua"		-- utility functions

 --generate_id ()			-- Generate the file the addon uses to filter Achievement ID's
@@ -288,6 +288,7 @@ end
   function tog:action(x)
 	if x == 1 then
 	accounts[acc].mode_zbox.value =accounts[acc].char_tabs
+	iup.SetAttribute(view_tog, "VISIBLE", "NO")
 	end
   end

@@ -297,19 +298,29 @@ end
   function tog:action(x)
 	if x == 1 then
 	accounts[acc].mode_zbox.value = accounts[acc].dung_tabs
+	iup.SetAttribute(view_tog, "VISIBLE", "YES")
 	end
   end
+
+  view_tog = iup.toggle{ title = L.View_Toggle, VISIBLE = "NO"}
+
+
   accounts[acc].mode = iup.frame {
-								iup.radio {
 								iup.hbox{
-										accounts[acc].char_tog,
-										accounts[acc].dung_tog,
+									iup.radio {
+										iup.hbox{
+												accounts[acc].char_tog,
+												accounts[acc].dung_tog,
+												},
 										},
+									view_tog,
 									}
 								}
+
   accounts[acc].mode.title =  L.Mode
   accounts[acc].mode.margin = "15x5"

+  alldungeons = {}
   -- Prepare for Dungeon data recording as we iterate through characters.
   accounts[acc].dung = {}		-- put all dungeon mode stuff here. Populate it with character data.
   -- N Normal,   V Vet,    VH   Vet hard mode
@@ -317,18 +328,43 @@ end
   dung.pub = {}
   dung.pub.box = {}
   dung.pub.key = {}
+  dung.pub.name = "pub"
+  table.insert(alldungeons,dung.pub)
+
   dung.DLC = {}
   dung.DLC.box = {}
   dung.DLC.key = {}
-  dung.nPlayers = #accounts[acc].playerIDs
+  dung.DLC.name = "DLC"
+  table.insert(alldungeons,dung.DLC)
   dung.Grp = {}		-- these ones are indexed.
   dung.Trials = {}

+    function view_tog:action(x)
+		if x == 1 then   --hide completed columns
+			for _, ADung in pairs (alldungeons) do	-- for each dungeon
+				for col,show in pairs(ADung.ShowColumn) do
+					if show  then
+						iup.SetAttribute(ADung.box, "WIDTH"..tostring(col) ,"100")
+					else
+						iup.SetAttribute(ADung.box, "WIDTH"..tostring(col) ,"0")
+					end
+				end  --]]
+			end
+		else   -- show all
+			for _, ADung in pairs (alldungeons) do	-- for each dungeon
+				for col,show in pairs(ADung.ShowColumn) do
+						iup.SetAttribute(ADung.box, "WIDTH"..tostring(col) ,"100")
+				end
+			end
+		end
+	end
+
   -- Set up dungeon mode Group Dungeons
   for _,i in ipairs(Grp_Order) do
 	dung.Grp[i]= {}
+	dung.Grp[i].name = i
 	dung.Grp[i].key ={}   -- key lookup
-	dung.Grp[i].box = iup.matrix {numcol=dung.nPlayers,     numlin=_size(Grp_Dat[i].id), widthdef=100}
+	dung.Grp[i].box = iup.matrix {numcol=#accounts[acc].playerIDs,     numlin=_size(Grp_Dat[i].id), widthdef=100}
 	iup.SetAttribute(dung.Grp[i].box, "READONLY", "YES")

 	dung.Grp[i].tab = iup.vbox {
@@ -342,7 +378,7 @@ end
 	dung.Grp[i].box.mousemove_cb = box_mousemove_cb
 	dung.Grp[i].box.leavewindow_cb = box_leavewindow_cb

-		--set lines Heading
+	--set lines Heading
 	dung.Grp[i].box:setcell(0,0, L.Location)
 	--Set Line titles
 	for line,key in ipairs(Grp_Dat[i].key) do
@@ -354,7 +390,7 @@ end
 		dung.Grp[i].box:setcell(0, col, playerNames[playerID])
 	end

-
+	table.insert(alldungeons,dung.Grp[i])
   end

   -- a table for each dungeon to which we add characters
@@ -379,8 +415,9 @@ end
   -- Set up dungeon mode  Trials
   for _,i in ipairs(Trials_Order) do
 		dung.Trials[i]= {}
+		dung.Trials[i].name = i
 		dung.Trials[i].key ={}   -- key lookup
-		dung.Trials[i].box = iup.matrix {numcol=dung.nPlayers,  numlin=_size(Trials_Dat[i].id), widthdef=100}
+		dung.Trials[i].box = iup.matrix {numcol=#accounts[acc].playerIDs,  numlin=_size(Trials_Dat[i].id), widthdef=100}
 		iup.SetAttribute(dung.Trials[i].box, "READONLY", "YES")

 		dung.Trials[i].tab = iup.vbox {
@@ -389,33 +426,33 @@ end
 							iup.fill{},
 						}

-	dung.Trials[i].box.dat = Trials_Dat[i]
-	dung.Trials[i].box.mousemove_cb = box_mousemove_cb
-	dung.Trials[i].box.leavewindow_cb = box_leavewindow_cb
+		dung.Trials[i].box.dat = Trials_Dat[i]
+		dung.Trials[i].box.mousemove_cb = box_mousemove_cb
+		dung.Trials[i].box.leavewindow_cb = box_leavewindow_cb


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

+		--Create Columns for Chars
+		for col ,playerID in ipairs(accounts[acc].playerIDs) do
+			dung.Trials[i].box:setcell(0, col, playerNames[playerID])
+		end


-    -- a table for each dungeon to which we add characters
-	for _,key in ipairs(Trials2key[i]) do
-	  dung.Trials[i].key[key] = {}
-	  for _,playerID in ipairs(accounts[acc].playerIDs) do
-		dung.Trials[i].key[key][playerID] = false
-	  end
-	end

+		-- a table for each dungeon to which we add characters
+		for _,key in ipairs(Trials2key[i]) do
+		  dung.Trials[i].key[key] = {}
+		  for _,playerID in ipairs(accounts[acc].playerIDs) do
+			dung.Trials[i].key[key][playerID] = false
+		  end
+		end
+		table.insert(alldungeons,dung.Trials[i])
   end


@@ -1046,7 +1083,7 @@ end

 		iup.Append(accounts[acc].char_tabs,me.tab)

-		local wide =((dung.nPlayers+1) * 110)
+		local wide =((#accounts[acc].playerIDs+1) * 110)
 		if wide < 690  then
 			wide = 690
 		elseif wide >960 then
@@ -1067,11 +1104,20 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 		if ADung.key == nil  then
 			print ("ADung.key  is nil (fatal)")
 		end
+
+		ADung.ShowColumn = {}		-- Save Column Completion Information
+		-- Set Column Show Information to false
+		for col,playerID in ipairs(accounts[acc].playerIDs) do
+			ADung.ShowColumn[col] = false
+		end
+
+
 		for line, key in ipairs(Grp_key) do  -- for lines going down, get the key
-		-- does that char exist in the table. Check by PlayerID
+
+			-- does that char exist in the table. Check by PlayerID
 			for col,playerID in ipairs(accounts[acc].playerIDs) do	-- over each char in order
 				if ADung.key[key] == nil  then
-				ADung.key[key] = {}
+					ADung.key[key] = {}
 				end

 				if ADung.key[key][playerID]  then
@@ -1080,14 +1126,26 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 				else
 					ADung.box:setcell(line,col, L.NoLabel)
 					iup.SetAttribute(ADung.box,"BGCOLOR" .. tostring(line) .. ":" .. tostring(col), BG_Colour_Not_Complete)
+					ADung.ShowColumn[col] = true		-- flag entire column as not complete, thus to show it.
 				end
 			end
 		end
+
+		--Ok, Set the Column Width flag Hide sometimes
+		--And column Heading background Always
+		for col,state in pairs(ADung.ShowColumn) do
+			if state then
+				iup.SetAttribute(ADung.box,"BGCOLOR" .. "0:" .. tostring(col), BG_Colour_Not_Complete)
+			else
+				iup.SetAttribute(ADung.box,"BGCOLOR" .. "0:" .. tostring(col), BG_Colour_Complete)
+			end
+		end
+
 	end

 	-- Create Pub Dungeon Character Box=========================

-	dung.pub.box = iup.matrix {numcol=dung.nPlayers,  numlin=#Pub_Dat.key, widthdef=100}
+	dung.pub.box = iup.matrix {numcol=#accounts[acc].playerIDs,  numlin=#Pub_Dat.key, widthdef=100}
 	dung.pub.box.dat = Pub_Dat
 	dung.pub.box.mousemove_cb = box_mousemove_cb
 	dung.pub.box.leavewindow_cb = box_leavewindow_cb
@@ -1131,7 +1189,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)

 	-- Create DLC Dungeon Character Box=========================

-	dung.DLC.box = iup.matrix {numcol=dung.nPlayers ,  numlin=#DLC2key, widthdef=100}
+	dung.DLC.box = iup.matrix {numcol=#accounts[acc].playerIDs ,  numlin=#DLC2key, widthdef=100}

 	dung.DLC.box.dat = DLC_Dat
 	dung.DLC.box.mousemove_cb = box_mousemove_cb
@@ -1150,6 +1208,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)

 	iup.SetAttribute(dung.DLC.box, "READONLY", "YES")

+	--[[
 	-- Populate with character data ============================
 	for line,key in ipairs(DLC2key) do		-- over each dungeon
 	    -- does that char exist in the table.
@@ -1163,6 +1222,8 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
 			end
 		end
 	end
+	--]]
+	populate(dung.DLC,DLC_Dat.key)


 	-- Create DLC Dungeon Tab ==================================
@@ -1201,7 +1262,7 @@ function select_account()
 					)

 			if selected <0 then
-				return nil		-- Cancelled
+				return nil		-- Canceled				iup.SetAttribute(ADung.box,"BGCOLOR" .. "0:" .. tostring(col), BG_Colour_Not_Complete)
 			else
 				return accounts_list[selected+1]
 			end
diff --git a/data/de/de.lua b/data/de/de.lua
index 51b10dc..3497fdf 100644
--- a/data/de/de.lua
+++ b/data/de/de.lua
@@ -108,6 +108,7 @@ L = {
 		YesLabel = "J",
 		NoLabel = "N",
 		Version = "Version",
+		View_Toggle = "Hide Complete",
 }
 L.Grp_TabName["1N"] = "Mode 1N"
 L.Grp_TabName["1V"] = "Mode 1V"
diff --git a/data/en/en.lua b/data/en/en.lua
index 72bef26..0c42393 100644
--- a/data/en/en.lua
+++ b/data/en/en.lua
@@ -106,6 +106,7 @@ Area_names = {
 		YesLabel = "Y",
 		NoLabel = "N",
 		Version = "Version",
+		View_Toggle = "Hide Complete",
 	}
 L.Grp_TabName["1N"] = "Mode 1N"
 L.Grp_TabName["1V"] = "Mode 1V"
diff --git a/data/fr/fr.lua b/data/fr/fr.lua
index eb9532f..42e92f2 100644
--- a/data/fr/fr.lua
+++ b/data/fr/fr.lua
@@ -108,6 +108,7 @@ Area_names = {
 		YesLabel = "O",
 		NoLabel = "N",
 		Version = "Version",
+		View_Toggle = "Hide Complete",
 	}
 L.Grp_TabName["1N"] = "Mode 1N"
 L.Grp_TabName["1V"] = "Mode 1V"
diff --git a/history.txt b/history.txt
index 6370d00..bdcba75 100644
--- a/history.txt
+++ b/history.txt
@@ -1,6 +1,6 @@
 ## Title: Dad's History
-## APIVersion: 100022 100023
-## Version: 48
+## APIVersion: 100023
+## Version: 49
 ## Author: HisDad
 ## Description: Record progress of all characters for offline viewing.
 ## SavedVariables: History_SV