Fixed a bug with Scenes from the new patch.

Jayden Platell [08-04-14 - 22:50]
Fixed a bug with Scenes from the new patch.
Added an "import from before patch" button in settings to migrate data from the broken GetDisplayName era.
Filename
Librarian.lua
Librarian.txt
Librarian.xml
LibrarianSettings.lua
diff --git a/Librarian.lua b/Librarian.lua
index 8d2fec3..82addc1 100644
--- a/Librarian.lua
+++ b/Librarian.lua
@@ -20,6 +20,10 @@ ZO_CreateStringId("SI_LIBRARIAN_FULLTEXT_SEARCH", "Full-text Search:")
 ZO_CreateStringId("SI_LIBRARIAN_SEARCH_HINT", "Enter text to search for.")
 ZO_CreateStringId("SI_LIBRARIAN_RELOAD_REMINDER", "ReloadUI suggested to update Librarian database.")
 ZO_CreateStringId("SI_LIBRARIAN_BACKUP_REMINDER", "Remember to backup your Librarian SavedVariables regularly.  Look up Librarian on ESOUI for instructions.")
+ZO_CreateStringId("SI_LIBRARIAN_EMPTY_LIBRARY_IMPORT_PROMPT", [[It appears your Library is empty.
+Patch 1.3 fixed a bug in the storage of addon data which now needs to be moved back to the correct place.
+Please click the "Import from before patch" button in the Librarian setting menu to perform this migration.
+It is recommended that you backup your Librarian SavedVariables before performing this step as a precaution.]])

 local SORT_ARROW_UP = "EsoUI/Art/Miscellaneous/list_sortUp.dds"
 local SORT_ARROW_DOWN = "EsoUI/Art/Miscellaneous/list_sortDown.dds"
@@ -221,7 +225,7 @@ function Librarian:InitializeScene()
 	if not LIBRARIAN_SCENE then
 		LIBRARIAN_TITLE_FRAGMENT = ZO_SetTitleFragment:New(SI_WINDOW_TITLE_LIBRARIAN)
 		LIBRARIAN_SCENE = ZO_Scene:New("librarian", SCENE_MANAGER)
-		LIBRARIAN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.UI_WINDOW)
+		LIBRARIAN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.MOUSE_DRIVEN_UI_WINDOW)
 		LIBRARIAN_SCENE:AddFragmentGroup(FRAGMENT_GROUP.FRAME_TARGET_STANDARD_RIGHT_PANEL)
 		LIBRARIAN_SCENE:AddFragment(ZO_FadeSceneFragment:New(LibrarianFrame))
 		LIBRARIAN_SCENE:AddFragment(RIGHT_BG_FRAGMENT)
@@ -270,7 +274,17 @@ function Librarian:ImportFromLoreLibrary()
 	self.settings.alertEnabled = alertEnabled
 end

+function Librarian:ImportFromEmptyAccount()
+	if Librarian_SavedVariables["Default"][""] ~= nil then
+		Librarian_SavedVariables["Default"][GetDisplayName()] = Librarian_SavedVariables["Default"][""]
+	end
+	Librarian_SavedVariables["Default"][""] = nil
+	SLASH_COMMANDS["/reloadui"]()
+end
+
 function Librarian:BuildMasterList()
+	if #self.books > 0 then LibrarianFrameMessage:SetHidden(true) end
+
     for i, book in ipairs(self.books) do
 		local data = {}
 		for k,v in pairs(book) do
diff --git a/Librarian.txt b/Librarian.txt
index d6d30b6..51ff9f3 100644
--- a/Librarian.txt
+++ b/Librarian.txt
@@ -1,6 +1,6 @@
 ## Title: Librarian
 ## Author: Flamage
-## APIVersion: 100004
+## APIVersion: 100008
 ## SavedVariables: Librarian_SavedVariables
 ## OptionalDependsOn: LibAddonMenu-2.0

diff --git a/Librarian.xml b/Librarian.xml
index 824b809..73c5cbe 100644
--- a/Librarian.xml
+++ b/Librarian.xml
@@ -28,7 +28,7 @@
                 </Label>
             </Controls>
         </Button>
-        <TopLevelControl name="LibrarianFrame" inherits="ZO_RightPanelFootPrint"  hidden="true">
+        <TopLevelControl name="LibrarianFrame" inherits="ZO_RightPanelFootPrint" hidden="true">
             <Controls>
                 <Label name="$(parent)BookCount" font="ZoFontHeader3" color="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_NORMAL">
                     <Anchor point="TOPLEFT" offsetY="10" />
@@ -87,6 +87,13 @@
                     <Anchor point="TOPLEFT" relativeTo="$(parent)Headers" relativePoint="BOTTOMLEFT" />
                     <Anchor point="BOTTOMRIGHT" offsetX="-12" offsetY="-29" />
                 </Control>
+                <Label name="$(parent)Message" font="ZoFontGame" horizontalAlignment="center" verticalAlignment="center">
+                    <Anchor point="TOPLEFT" relativeTo="$(parent)Headers" relativePoint="BOTTOMLEFT" />
+                    <Anchor point="BOTTOMRIGHT" offsetX="-12" offsetY="-29" />
+                    <OnInitialized>
+                        self:SetText(GetString(SI_LIBRARIAN_EMPTY_LIBRARY_IMPORT_PROMPT))
+                    </OnInitialized>
+                </Label>
                 <Label name="$(parent)BackupPSA" font="ZoFontGame" color="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_DISABLED">
                     <Anchor point="BOTTOMLEFT" offsetX="29" />
                     <OnInitialized>
diff --git a/LibrarianSettings.lua b/LibrarianSettings.lua
index 6fb6be5..2458919 100644
--- a/LibrarianSettings.lua
+++ b/LibrarianSettings.lua
@@ -127,6 +127,12 @@ function LibrarianSettings:Initialise(settings)
       name = "Import from Lore Library",
       tooltip = "Import any missing books from the Lore Library.  Works with all books once Eidetic Memory is unlocked.",
       func = function() LIBRARIAN:ImportFromLoreLibrary() end
+    },
+    [6] = {
+      type = "button",
+      name = "Import from before patch",
+      tooltip = "Migrate data from before Patch 1.3, where account name was broken.",
+      func = function() LIBRARIAN:ImportFromEmptyAccount() end
     }
   }