add module versioning to prevent old versions from loading.

Sammy James [03-22-14 - 16:06]
add module versioning to prevent old versions from loading.
Filename
core/PSBT.lua
core/PSBT_Options.lua
core/PSBT_Settings.lua
modules/PSBT_Auras.lua
modules/PSBT_Combat.lua
modules/PSBT_Cooldowns.lua
modules/PSBT_Experience.lua
modules/PSBT_LowSomething.lua
modules/PSBT_Ultimate.lua
diff --git a/core/PSBT.lua b/core/PSBT.lua
index fd945fa..5e4319b 100644
--- a/core/PSBT.lua
+++ b/core/PSBT.lua
@@ -113,13 +113,19 @@ function PSBT:SetConfigurationMode( mode )
     end
 end

-function PSBT:RegisterModule( identity, class )
-    if ( self._modules[ identity ] ) then
+function PSBT:RegisterModule( identity, class, version )
+    if ( not version ) then
+        version = -1
+    end
+
+    if ( self._modules[ identity ] and ( version < self._modules[ identity ].__version or 0 ) ) then
         return
     end

-    print ( 'PSBT:RegisterModule %s', identity )
+    print( 'PSBT module registered: ' .. identity .. ' @ ' .. version )
+
     self._modules[ identity ] = class
+    self._modules[ identity ].__version = version
 end

 function PSBT:GetModule( identity )
diff --git a/core/PSBT_Options.lua b/core/PSBT_Options.lua
index f06fc75..abd287c 100644
--- a/core/PSBT_Options.lua
+++ b/core/PSBT_Options.lua
@@ -13,6 +13,8 @@ local PSBT_EVENTS       = PSBT_EVENTS
 local PSBT_SETTINGS     = PSBT_SETTINGS
 local PSBT_ICON_SIDE    = PSBT_ICON_SIDE

+local kVersion          = 1.0
+
 local decorations = { 'none', 'soft-shadow-thin', 'soft-shadow-thick', 'shadow' }
 local iconside = { PSBT_ICON_SIDE.NONE, PSBT_ICON_SIDE.LEFT, PSBT_ICON_SIDE.RIGHT }
 local direction = { PSBT_SCROLL_DIRECTIONS.UP, PSBT_SCROLL_DIRECTIONS.DOWN }
@@ -189,5 +191,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.OPTIONS, PSBT_Options:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.OPTIONS, PSBT_Options:New( psbt ), kVersion )
     end)
\ No newline at end of file
diff --git a/core/PSBT_Settings.lua b/core/PSBT_Settings.lua
index 111cc17..9e372eb 100644
--- a/core/PSBT_Settings.lua
+++ b/core/PSBT_Settings.lua
@@ -14,6 +14,8 @@ local RIGHT                  = RIGHT
 local LEFT                   = LEFT
 local CENTER                 = CENTER

+local kVersion               = 2.5
+
 local defaults =
 {
     normal_font =
@@ -74,7 +76,7 @@ local defaults =
 function PSBT_Settings:Initialize( ... )
     PSBT_Module.Initialize( self, ... )

-    self.db      = ZO_SavedVars:New( 'PSBT_DB', 2.5, nil, defaults )
+    self.db      = ZO_SavedVars:New( 'PSBT_DB', kVersion, nil, defaults )
     self.profile = self.db:GetInterfaceForCharacter( GetDisplayName(), GetUnitName( 'player' ) )
 end

@@ -92,5 +94,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.SETTINGS, PSBT_Settings:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.SETTINGS, PSBT_Settings:New( psbt ), kVersion )
     end)
\ No newline at end of file
diff --git a/modules/PSBT_Auras.lua b/modules/PSBT_Auras.lua
index 3590541..dbe28e6 100644
--- a/modules/PSBT_Auras.lua
+++ b/modules/PSBT_Auras.lua
@@ -1,6 +1,7 @@
 local PSBT_Module           = PSBT_Module
 local PSBT_Auras            = PSBT_Module:Subclass()
 local CBM                   = CALLBACK_MANAGER
+local kVerison = 1.0

 local EFFECT_RESULT_FADED   = EFFECT_RESULT_FADED
 local EFFECT_RESULT_GAINED  = EFFECT_RESULT_GAINED
@@ -41,5 +42,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.AURAS, PSBT_Auras:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.AURAS, PSBT_Auras:New( psbt ), kVerison )
     end)
\ No newline at end of file
diff --git a/modules/PSBT_Combat.lua b/modules/PSBT_Combat.lua
index f35fed2..e52308b 100644
--- a/modules/PSBT_Combat.lua
+++ b/modules/PSBT_Combat.lua
@@ -16,6 +16,7 @@ local PSBT_EVENTS           = PSBT_EVENTS
 local zo_strformat          = zo_strformat
 local GetString             = GetString
 local select                = select
+local kVerison              = 1.0

 local function IsPlayerType( targetType )
     return targetType == COMBAT_UNIT_TYPE_PLAYER or
@@ -375,5 +376,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.COMBAT, PSBT_Combat:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.COMBAT, PSBT_Combat:New( psbt ), kVerison )
     end)
\ No newline at end of file
diff --git a/modules/PSBT_Cooldowns.lua b/modules/PSBT_Cooldowns.lua
index 6645b4b..04587eb 100644
--- a/modules/PSBT_Cooldowns.lua
+++ b/modules/PSBT_Cooldowns.lua
@@ -5,6 +5,8 @@ local CBM                   = CALLBACK_MANAGER
 local PSBT_EVENTS           = PSBT_EVENTS
 local PSBT_MODULES          = PSBT_MODULES

+local kVerison              = 1.0
+
 function PSBT_Cooldowns:Initialize( ... )
     PSBT_Module.Initialize( self, ... )

@@ -20,5 +22,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.COOLDOWNS, PSBT_Cooldowns:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.COOLDOWNS, PSBT_Cooldowns:New( psbt ), kVerison )
     end )
\ No newline at end of file
diff --git a/modules/PSBT_Experience.lua b/modules/PSBT_Experience.lua
index 649066a..10de48f 100644
--- a/modules/PSBT_Experience.lua
+++ b/modules/PSBT_Experience.lua
@@ -9,6 +9,8 @@ local PSBT_AREAS        = PSBT_AREAS
 local PSBT_EVENTS       = PSBT_EVENTS
 local PSBT_MODULES      = PSBT_MODULES

+local kVersion          = 1.0
+
 function PSBT_Experience:Initialize( ... )
     PSBT_Module.Initialize( self, ... )

@@ -40,5 +42,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.XP, PSBT_Experience:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.XP, PSBT_Experience:New( psbt ), kVersion )
     end)
\ No newline at end of file
diff --git a/modules/PSBT_LowSomething.lua b/modules/PSBT_LowSomething.lua
index ea1b190..2d24ce3 100644
--- a/modules/PSBT_LowSomething.lua
+++ b/modules/PSBT_LowSomething.lua
@@ -14,6 +14,8 @@ local POWERTYPE_MAGICKA     = POWERTYPE_MAGICKA
 local POWERTYPE_STAMINA     = POWERTYPE_STAMINA
 local POWERTYPE_MOUNT_STAMINA = POWERTYPE_MOUNT_STAMINA

+local kVersion              = 1.0
+
 function PSBT_LowSomething:Initialize( ... )
     PSBT_Module.Initialize( self, ... )

@@ -67,5 +69,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.LOW, PSBT_LowSomething:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.LOW, PSBT_LowSomething:New( psbt ), kVersion )
     end)
\ No newline at end of file
diff --git a/modules/PSBT_Ultimate.lua b/modules/PSBT_Ultimate.lua
index 3100f2a..be39295 100644
--- a/modules/PSBT_Ultimate.lua
+++ b/modules/PSBT_Ultimate.lua
@@ -1,11 +1,13 @@
 local PSBT_Module = PSBT_Module
 local PSBT_Ultimate = PSBT_Module:Subclass()
 local CBM = CALLBACK_MANAGER
+local kVerison = 1.0

 local PSBT_MODULES = PSBT_MODULES
 local PSBT_AREAS   = PSBT_AREAS
 local PSBT_EVENTS  = PSBT_EVENTS

+local kVersion     = 1.0

 local POWERTYPE_ULTIMATE                = POWERTYPE_ULTIMATE
 local ACTION_BAR_ULTIMATE_SLOT_INDEX    = ACTION_BAR_ULTIMATE_SLOT_INDEX
@@ -56,5 +58,5 @@ end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,
     function( psbt )
-        psbt:RegisterModule( PSBT_MODULES.ULTIMATE, PSBT_Ultimate:New( psbt ) )
+        psbt:RegisterModule( PSBT_MODULES.ULTIMATE, PSBT_Ultimate:New( psbt ), kVerison )
     end )
\ No newline at end of file