Added Locations tab

His Dad [04-25-15 - 20:59]
Added Locations tab
Filename
HistOffline.lua
en.lua
history.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index 99c9276..1eedea1 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -371,6 +371,65 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}

 		accounts[acc].name[char].Vet_box.Redraw= "ALL"

+		-- Create Maps Box==============================================
+		accounts[acc].name[char].Map_box= iup.matrix {numcol=6, numcol_visible=6,  numlin=0, widthdefault=30}
+
+		accounts[acc].name[char].Map_box:setcell(0,0, L.Location)
+		accounts[acc].name[char].Map_box:setcell(0,1, L.Visits)
+		accounts[acc].name[char].Map_box:setcell(0,2, L.FirstVisited)
+		accounts[acc].name[char].Map_box:setcell(0,3, L.FirstLevel)
+		accounts[acc].name[char].Map_box:setcell(0,4, L.TimesLeveled)
+		accounts[acc].name[char].Map_box:setcell(0,5, L.FirstDeath)
+		accounts[acc].name[char].Map_box:setcell(0,6, L.Deaths)
+
+
+		iup.SetAttribute(accounts[acc].name[char].Map_box, "READONLY", "YES")
+		iup.SetAttribute(accounts[acc].name[char].Map_box, "ALIGNMENT0", "ALEFT")
+		iup.SetAttribute(accounts[acc].name[char].Map_box, "WIDTH0", "100")
+
+
+		local map_names = {}
+		for map,_ in pairs(History_SV["Default"][acc]["$AccountWide"]["data"][char].maps) do
+			table.insert(map_names,map)
+		end
+	--	print(dump(map_names))
+		table.sort(map_names)
+		local Line =1
+		for _, map in ipairs(map_names) do
+			accounts[acc].name[char].Map_box.numlin = Line
+
+			accounts[acc].name[char].Map_box:setcell( Line,0, map)
+
+			if History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].visit ~= nil then
+				accounts[acc].name[char].Map_box:setcell( Line,1, History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].visit)
+			end
+
+			if History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].firstvisited ~= nil then
+				local firstvisit = os.date(dateformat,History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].firstvisited)
+				accounts[acc].name[char].Map_box:setcell( Line,2, firstvisit)
+			end
+
+			if History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].firstlevel ~= nil then
+				accounts[acc].name[char].Map_box:setcell( Line,3, History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].firstlevel)
+			end
+
+			if History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].timesleveled ~= nil then
+				accounts[acc].name[char].Map_box:setcell( Line,4, History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].timesleveled)
+			end
+
+			if History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].firstdeathlevel ~= nil then
+				accounts[acc].name[char].Map_box:setcell( Line,5, History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].firstdeathlevel)
+			end
+
+			if History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].deaths ~= nil then
+				accounts[acc].name[char].Map_box:setcell( Line,6, History_SV["Default"][acc]["$AccountWide"]["data"][char].maps[map].deaths )
+			end
+		Line= Line +1
+		end
+
+
+
+
 	 -- ====================================
 	--  == Prepare for the user display tabs
 		accounts[acc].name[char].tab = iup.vbox{
@@ -410,6 +469,11 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 												accounts[acc].name[char].leveling_box,
 												iup.fill{}
 											},
+									iup.vbox {	["tabtitle"] =L.Locations,
+											--	iup.label{title="LevLabel",expand="HORIZONTAL"},
+												accounts[acc].name[char].Map_box,
+												iup.fill{}
+											},
 								},	-- end of tabs for dungeons
 							},
 					}  -- end of tabs for characters vbox
diff --git a/en.lua b/en.lua
index 2d716c5..eb9c68d 100644
--- a/en.lua
+++ b/en.lua
@@ -26,6 +26,10 @@ Area_names = {
 		TPlayed = "Time Played: ",
 		Hrs = "Hours.",
 		Level = "Level",
+		TimesLeveled = "Times Leveled",
+		FirstLevel = "First Level",
+		Visits = "Visits",
+		FirstVisited = "First Visited",
 		Created = "Created: ",
 		PTime = "Play Time (Hr)",
 		Start = "Start Date",
@@ -42,7 +46,9 @@ Area_names = {
 		Welcome = "Welcome to HisDad\'s offline history viewer.",
 		Erased = "The Log has been erased.",
 		FirstDeath = "First Death",
-		SelectA = "Select Account"
+		SelectA = "Select Account",
+		Locations = "Locations",
+		Location = "Location"
 	}


diff --git a/history.lua b/history.lua
index 3f1080f..b6fbd61 100644
--- a/history.lua
+++ b/history.lua
@@ -32,6 +32,7 @@ end
 local function get_start ()	-- get better start date from Achievements
 		-- Check Achievements
 		local earliest_time = 0
+		local earliest_Achievement
 		for id, ach in pairs(hist.me.ach) do
 			if earliest_time == 0 then
 				earliest_time = ach.time
@@ -132,10 +133,11 @@ end

 local function Activated()
 	hist.me.levels[hist.me.level].time = math.floor(GetSecondsPlayed() /60)
-	map = GetMapName()
+	local map = GetMapName()
 	if hist.me.maps[map] == nil then
 		hist.me.maps[map] = {}
 		hist.me.maps[map].visit = 1
+		hist.me.maps[map].firstvisitdate = GetTimeStamp()
 	else

 		if hist.me.maps[map].visit == nil then
@@ -148,7 +150,7 @@ local function Activated()
 end


-local function levelup(eventCode, unitTag,_)
+local function levelup(_, unitTag,_)
 	if unitTag == "player" then
 	local oldlevel = hist.me.level
 	hist.me.level =  GetUnitLevel("player") + GetUnitVeteranRank("player")
@@ -237,6 +239,7 @@ local function Dead()
 	local map = GetMapName()
 	if hist.me.maps[map] == nil then
 		hist.me.maps[map] = {}
+
 	end
 	--Update map data with Deaths
 	if hist.me.maps[map].deaths == nil then
@@ -249,6 +252,10 @@ local function Dead()
 		end
 	end
 	hist.me.maps[map].deaths = hist.me.maps[map].deaths +1
+
+	if hist.me.maps[map].firstdeathdate == nil then
+		hist.me.maps[map].firstdeathdate  = GetTimeStamp()
+	end
 end


@@ -341,7 +348,7 @@ function hist.Initialise(_, addOnName)
 	EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_LEVEL_UPDATE, levelup)
 	EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_VETERAN_RANK_UPDATE, levelup)
 	EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_ACTIVATED, Activated)
-	EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_DEACTIVATED, Activated)
+--	EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_DEACTIVATED, Activated)
 	EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_DEAD, Dead)
 	hist.initialised = true
 end