diff --git a/Delete-Account.lua b/Delete-Account.lua
index 2d31fae..63352fb 100644
--- a/Delete-Account.lua
+++ b/Delete-Account.lua
@@ -65,9 +65,7 @@ end
accounts_list = {} -- String list for selection dialog
naccounts = 0
for i,j in pairs(History_SV["Default"]) do
- print(i)
- lang = j["$AccountWide"].lang
- print(lang)
+ naccounts = naccounts +1
table.insert(accounts_list, i)
end
@@ -83,7 +81,7 @@ dofile (path)
function select_account()
local selected
- if naccounts > 0 then
+ if naccounts >1 then
selected = iup.ListDialog (1, L.ChooseAccounttoDelete,
naccounts, --Size
accounts_list,
@@ -101,14 +99,14 @@ function select_account()
end
end
---[[ -- Need two or more accounts
+ -- Need two or more accounts
if naccounts < 2 then
iup.Message("",L.NoAccount)
iup.Close()
os.exit()
end
---]]
+
-- Create dialog to choose account
@@ -129,42 +127,29 @@ confirm= iup.messagedlg{
}
confirm:popup()
--- Button "1" is OK.
+-- Button "1" is "OK"
if iup.GetAttribute(confirm, "BUTTONRESPONSE") ~= "1" then
-print ("Cancelled")
--- iup.Close()
--- os.exit()
+ iup.Close()
+ os.exit()
end
backfile=os.date("History-"..dateformat_log .. ".lua")
--- os.execute( "md ..\\..\\SavedVariables\\History_Bak" ) -- fails silently if already exists.
--- os.execute("copy ..\\..\\SavedVariables\\History.lua ..\\..\\SavedVariables\\History_Bak\\" .. backfile)
-
-print ("Deleted")
+os.execute( "md ..\\..\\SavedVariables\\History_Bak" ) -- fails silently if already exists.
+os.execute("copy ..\\..\\SavedVariables\\History.lua ..\\..\\SavedVariables\\History_Bak\\" .. backfile)
newf = assert(io.open("../../SavedVariables/History.new", "w"))
-- ==============
+-- Erase Account
+
+History_SV["Default"][account] = nil
--Dump it back out
newf:write("History_SV=" .. write_saved(History_SV))
newf:close()
---[[
--- ============== Setup storage for old characters.
-archivef = io.open("../../SavedVariables/History.Archive", "r")
-if archivef ==nil then --create empty file
- archivef = io.open("../../SavedVariables/History.Archive", "w")
- archivef:write("Archive = {} \n")
-end
+os.execute("del ..\\..\\SavedVariables\\History.lua")
+os.execute("rename ..\\..\\SavedVariables\\History.new history.lua")
-archivef:close()
-dofile "../../SavedVariables/History.Archive"
--- newf = assert(io.open("../../SavedVariables/History.new", "w"))
--- ==============
---]]
---Dump it back out
--- newf:write("History_SV=" .. write_saved(History_SV))
--- newf:close()
diff --git a/Delete-Character.lua b/Delete-Character.lua
index bbbc0fc..b07e9c5 100644
--- a/Delete-Character.lua
+++ b/Delete-Character.lua
@@ -10,11 +10,6 @@ Utility to delete old chars
-- Configuration ==========
local dateformat = "%Y-%m-%d, %H:%M"
local dateformat_log = "%Y-%m-%d-%H-%M-%S"
-local FG_Colour_Not_Complete = "#FFB67D"
-local FG_Colour_Complete = "#000000"
-local BG_Colour_Not_Complete = "#FFB67D"
-local BG_Colour_Complete = "#A4FF5A"
-local Colour_Heading_Complete = "#58FA58"
--iup.SetGlobal("UTF8MODE","YES")
-- ========================
@@ -39,7 +34,10 @@ end
-- Minimally effective quoting
function quote(astring)
- return '"' .. string.gsub(astring,"%'", "\\'") .. '"'
+ local quoted1 = string.gsub(astring,'\"', '\\"')
+ local quoted2 = '"' .. string.gsub(quoted1,"%'", "\\'") .. '"'
+ local linefeed = string.gsub(quoted2,"\n", "\\n")
+ return linefeed
end
@@ -63,32 +61,123 @@ function write_saved(o)
end
+
+accounts_list = {} -- String list for selection dialog
+naccounts = 0
+for i,j in pairs(History_SV["Default"]) do
+ naccounts = naccounts +1
+ table.insert(accounts_list, i)
+end
+
+if lang == nil then
+lang = "en"
+end
+
+local path = "./data/" .. lang .. ".lua"
+dofile (path)
+
+
+
+
+function select_account()
+ local selected
+ if naccounts >1 then
+ selected = iup.ListDialog (1, L.ChooseAccounttoDelete,
+ naccounts, --Size
+ accounts_list,
+ 1, --Initial
+ 1,naccounts --MaxCol MaxLine
+ )
+
+ if selected <0 then
+ return nil -- Cancelled
+ else
+ return accounts_list[selected+1]
+ end
+ else
+ return accounts_list[1] -- only 1 account, no need for Dialog
+ end
+end
+
+
+-- Create dialog to choose account
+account=select_account()
+
+-- Not selected, quit. should happen, but to be sure
+if account == nil then
+ iup.Close()
+ os.exit()
+end
+
+playerNames = {}
+playerName2ID={}
+
+ for playerID, j in pairs(History_SV["Default"][account]["$AccountWide"]["data"]) do
+ if j.name == nil then
+ table.insert(playerNames, playerID) -- old Style
+ playerName2ID[playerID] = playerID
+ else
+ table.insert(playerNames, j.name)
+ playerName2ID[j.name] = playerID
+ end
+ end
+
+
+-- No players.
+if #playerNames == 0 then
+ iup.Close()
+ os.exit()
+end
+
+selected = iup.ListDialog (1, L.SelectA,
+ #playerNames, --Size
+ playerNames,
+ 1, --Initial
+ 1,#playerNames--MaxCol MaxLine
+ )
+
+if selected <0 then
+ iup.Close() -- Cancelled
+ os.exit()
+end
+
+
+playerName = playerNames[selected +1]
+playerID = playerName2ID[playerName]
+
+
+confirm= iup.messagedlg{
+ dialogtype = "QUESTION",
+ buttons = "OKCANCEL",
+ buttondefault = 2,
+ title = L.Delete .. " " .. L.Char,
+ value = L.Delete .. " " .. playerNames[selected +1]
+ }
+
+confirm:popup()
+-- Button "1" is "OK"
+
+if iup.GetAttribute(confirm, "BUTTONRESPONSE") ~= "1" then
+ iup.Close()
+ os.exit()
+end
+
backfile=os.date("History-"..dateformat_log .. ".lua")
os.execute( "md ..\\..\\SavedVariables\\History_Bak" ) -- fails silently if already exists.
os.execute("copy ..\\..\\SavedVariables\\History.lua ..\\..\\SavedVariables\\History_Bak\\" .. backfile)
-
newf = assert(io.open("../../SavedVariables/History.new", "w"))
-- ==============
+-- Erase Account
+
+History_SV["Default"][account]["$AccountWide"]["data"][playerID] = nil
--Dump it back out
--- newf:write("History_SV=" .. write_saved(History_SV))
--- newf:close()
---[[
--- ============== Setup storage for old characters.
-archivef = io.open("../../SavedVariables/History.Archive", "r")
-if archivef ==nil then --create empty file
- archivef = io.open("../../SavedVariables/History.Archive", "w")
- archivef:write("Archive = {} \n")
-end
+newf:write("History_SV=" .. write_saved(History_SV))
+newf:close()
+
+os.execute("del ..\\..\\SavedVariables\\History.lua")
+os.execute("rename ..\\..\\SavedVariables\\History.new history.lua")
-archivef:close()
-dofile "../../SavedVariables/History.Archive"
--- newf = assert(io.open("../../SavedVariables/History.new", "w"))
--- ==============
---]]
---Dump it back out
--- newf:write("History_SV=" .. write_saved(History_SV))
--- newf:close()
diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt
index 8993ca1..4d0d803 100644
--- a/Doc/Changelog.txt
+++ b/Doc/Changelog.txt
@@ -1,3 +1,24 @@
+2016-08-07 version 21
+ Internal changes in the save file to allow correct operation when the character is
+ Renamed
+ Race changed
+ Gender Changed
+
+ After installing this update, you should log in to all your characters so it will update.
+
+ Included are
+ Delete-Account.lua
+ Delete-Character.lua
+
+ Which you can run from the iuplua53 console.
+ They will perform one operation and then quit. This is so you can use histoffline to confirm its doing what you think.
+ You should BACKUP YOUR savedvariables/History.lua file.
+ The apps copy the datafile into a sub folder called History_bak, with a timestamp in the name, before writing any data.
+ This is new code..... you do have a backup, don't you?
+
+ This addon could use some love from DE and FR speakers.
+
+
2016-08-01 version 20
API for Update 11
diff --git a/Doc/Description.txt b/Doc/Description.txt
index be0f691..1378170 100644
--- a/Doc/Description.txt
+++ b/Doc/Description.txt
@@ -1,3 +1,5 @@
+[COLOR="RED"]====READ THE CHANGELOG===[/COLOR]
+
If you've ever had a conversation like this..
[COLOR="DarkOrange"]"Do you want to join us in dungeon X?"
@@ -73,7 +75,6 @@ Read "installation.pdf" in the Doc folder for details on installing the IUP tool
[SIZE=4]To Do[/SIZE]
[LIST]
-[*]Ability to make character data inactive, for deleted chars. It needs to be moved to another file for storage.
[*]Capture group data for deaths and Dungeons.
[/LIST]
diff --git a/HistOffline.lua b/HistOffline.lua
index 2c7da23..f25fffc 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -109,12 +109,6 @@ for i,_ in pairs(History_SV["Default"]) do
table.insert(accounts_list, i)
end
-function write_data()
- local newf = assert(io.open("../../SavedVariables/History.new", "w"))
- newf:write("History_SV=" .. write_saved(History_SV))
- newf:close()
-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
@@ -333,7 +327,7 @@ end
end
-- Create Grp Dungeon Achievements Box=========================
me.Grp_box = {}
- me.Grp_box = iup.matrix {numcol=4, numcol_visible=4, numlin=5, widthdef=90}
+ me.Grp_box = iup.matrix {numcol=4, numcol_visible=4, numlin=5, widthdef=100}
--Set Column titles
for i=1, 4 do
me.Grp_box:setcell(0,i, Area_names[i].long)
@@ -391,7 +385,7 @@ end
-- me.Grp_box.Redraw= "ALL"
-- Create Pub Dungeon Achievements Box==========================
- me.Pub_box = iup.matrix {numcol=4, numcol_visible=4, numlin=5, widthdef=90}
+ me.Pub_box = iup.matrix {numcol=4, numcol_visible=4, numlin=5, widthdef=100}
for i=1, 4 do -- Load text
me.Pub_box:setcell(0,i, Area_names[i].long)
end
@@ -844,7 +838,7 @@ end
end
--========== DLC
- me.DLC_box= iup.matrix {numcol=1, numcol_visible=1, numlin=4, widthdef=90}
+ me.DLC_box= iup.matrix {numcol=1, numcol_visible=1, numlin=4, widthdef=100}
--Set Column titles
for i=1,1 do
me.DLC_box:setcell(0,i, DLC_names[i].long)
@@ -989,7 +983,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
-- Create Pub Dungeon Character Box=========================
dung.Pub_box = {}
- dung.Pub_box = iup.matrix {numcol=#accounts[acc].playerIDs, numlin=#grp2key, widthdef=90}
+ dung.Pub_box = iup.matrix {numcol=#accounts[acc].playerIDs, numlin=#grp2key, widthdef=100}
--Set Line titles
for i,key in ipairs(grp2key) do
dung.Pub_box:setcell(i, 0, pub_names[key])
@@ -1031,7 +1025,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
-- Create Grp Dungeon Character Box=========================
dung.Grp_box = {}
- dung.Grp_box = iup.matrix {numcol=#accounts[acc].playerIDs, numlin=#grp2key, widthdef=90}
+ dung.Grp_box = iup.matrix {numcol=#accounts[acc].playerIDs, numlin=#grp2key, widthdef=100}
--Set Line titles
for i, key in ipairs(grp2key) do
dung.Grp_box:setcell(i, 0, grp_names[key])
@@ -1113,7 +1107,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
if #accounts[acc].playerIDs_vet > 0 then -- skip vet and trials if no eligible chars
-- Create Vet Grp Dungeon Character Box=======================
dung.Vet_box = {}
- dung.Vet_box = iup.matrix {numcol=#accounts[acc].playerIDs_vet, numlin=#vet2key, widthdef=90}
+ dung.Vet_box = iup.matrix {numcol=#accounts[acc].playerIDs_vet, numlin=#vet2key, widthdef=100}
--Set Line titles
for i,key in ipairs(vet2key) do
dung.Vet_box:setcell(i, 0, grp_names[key])
@@ -1162,7 +1156,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
-- Create Trials Character Box=======================
dung.Trials_box = {}
- dung.Trials_box = iup.matrix {numcol=0, numlin=#trial2key, widthdef=90}
+ dung.Trials_box = iup.matrix {numcol=0, numlin=#trial2key, widthdef=100}
--Set Line titles
for line,key in ipairs(trial2key) do
dung.Trials_box:setcell(line, 0, trial_names[key])
@@ -1207,13 +1201,7 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)
end -- Accounts
---Setup menu
--- Creates main menu with submenu
-
-menuitem_About= iup.item {title = L.About}
-
-menu = iup.menu {menuitem_About}
function select_account()
@@ -1254,7 +1242,6 @@ if myaccount ~=nil then
},
title=L.title .. myaccount,
size=accounts[myaccount].panelsize,
- menu=menu
}
-- Shows dialog in the centre of the screen
dlg:showxy(iup.CENTER, iup.CENTER)
diff --git a/data/de.lua b/data/de.lua
index b7fcb52..9d53bc3 100644
--- a/data/de.lua
+++ b/data/de.lua
@@ -83,7 +83,10 @@ DLC_names = {
Account = "Account",
Char = "Char",
About = "About",
- Delete = "Delete"
+ Delete = "Delete",
+ NoAccount ="Only 1 account, can't delete that.",
+ ChooseAccounttoDelete = "Choose Account to Delete",
+ ChooseChartoDelete = "Choose Character to Delete",
}
pub_names = {
diff --git a/data/en.lua b/data/en.lua
index b936669..6d4b779 100644
--- a/data/en.lua
+++ b/data/en.lua
@@ -84,6 +84,7 @@ DLC_names = {
Delete = "Delete",
NoAccount ="Only 1 account, can't delete that.",
ChooseAccounttoDelete = "Choose Account to Delete",
+ ChooseChartoDelete = "Choose Character to Delete",
}
pub_names = {
diff --git a/data/fr.lua b/data/fr.lua
index f6977a0..2b07443 100644
--- a/data/fr.lua
+++ b/data/fr.lua
@@ -79,7 +79,10 @@ DLC_names = {
Account = "Account",
Char = "Char",
About = "About",
- Delete = "Delete"
+ Delete = "Delete",
+ NoAccount ="Only 1 account, can't delete that.",
+ ChooseAccounttoDelete = "Choose Account to Delete",
+ ChooseChartoDelete = "Choose Character to Delete",
}
pub_names = {
diff --git a/history.lua b/history.lua
index 33c7210..e571378 100644
--- a/history.lua
+++ b/history.lua
@@ -8,7 +8,7 @@ hist = {
playerName = "", -- might change
playerID = "", -- Unique through renames
tz_offset =0,
- debug = false
+ debug = true
}
local function log_truncate(max)
@@ -287,14 +287,14 @@ function hist.Initialise(_, addOnName)
hist.playerName = GetUnitName("player")
hist.playerID = GetCurrentCharacterId()
+
local level = GetUnitLevel("player") + GetUnitVeteranRank("player")
-- Load the saved variables
hist.SV = ZO_SavedVars:NewAccountWide("History_SV", 1, nil, nil)
- if hist.SV.log == nil
- then hist.SV.log = {}
- elseif hist.SV.log[1]["TimeStamp"] == nil -- Remove Old Log Formats
- then log_clear()
+ if hist.SV.log == nil then
+ hist.SV.log = {}
+ log("hist.SV.log created")
end
if (hist.SV.data == nil ) then
@@ -311,10 +311,10 @@ function hist.Initialise(_, addOnName)
hist.SV.this_version = hist.version
- hist.SV.version = nil -- Old Variable not used
+ --- hist.SV.version -- Used by ZOS System
if hist.SV.data[hist.playerID] == nil then
- log("No data found")
+ log("No data found for PlayerID")
-- Ok playerID may be nil, but we might still have data under player name
-- In which case we rename it, otherwise it is a new char.
diff --git a/history.txt b/history.txt
index d938fc3..e446d87 100644
--- a/history.txt
+++ b/history.txt
@@ -1,6 +1,6 @@
## Title: Dad's History
## APIVersion: 100016
-## Version: 20
+## Version: 21
## Author: HisDad
## Description: Record progress of all characters for offline viewing.
## SavedVariables: History_SV