Added config validator and changed behavior of hidden state storage config flag

This commit is contained in:
Wofsauge committed 2021-06-25 21:31:14 +02:00
1 parent 4b248762bc
commit b2b869d9a9
3 files changed
+15 -13

No files matched your search

+4 -4
View File
@@ -54,7 +54,7 @@ EID.UserConfig = {
["HideKey"] = Keyboard.KEY_F2,
-- Initial displaystate. Can be used to change the toggle behavior of the "Hide Key" event
-- Default = false
["Hidden"] = false,
["InitiallyHidden"] = false,
-- Hide the descriptions when in battle
-- Default = false
["HideInBattle"] = false,
@@ -167,11 +167,11 @@ EID.UserConfig = {
---------Mouse Controls-----------
-- Toggles HUD descriptions based on the mouse position
-- Default = "false"
-- Default = false
["EnableMouseControls"] = false,
-- Toggles the custom mouse cursor
-- Default = "false"
-- Default = false
["ShowCursor"] = false,
-------------MISC---------------
@@ -225,7 +225,7 @@ EID.DefaultConfig = {
["MaxDistance"] = 5,
["Indicator"] = "none",
["HideKey"] = Keyboard.KEY_F2,
["Hidden"] = false,
["InitiallyHidden"] = false,
["HideInBattle"] = false,
["DisableObstructionOnFlight"] = true,
["DisableOnCurse"] = true,
+7 -4
View File
@@ -10,7 +10,7 @@ require("eid_config")
EID.Config = EID.UserConfig
EID.Config.Version = "3.2"
EID.DefaultConfig.Version = EID.Config.Version
EID.isHidden = EID.Config["Hidden"]
EID.isHidden = false
EID.player = nil
-- general variables
@@ -728,19 +728,22 @@ if EID.MCMLoaded or REPENTANCE then
if savedEIDConfig.Version == EID.Config.Version then
local isDefaultConfig = true
for key, value in pairs(EID.Config) do
if type(value) ~= type(EID.DefaultConfig[key]) and key ~= "BagContent" then
print("EID Warning! : Config value '"..key.."' has wrong data-type. Resetting it to default...")
EID.Config[key] = EID.DefaultConfig[key]
end
if EID.DefaultConfig[key] ~= value then
isDefaultConfig = false
break
end
end
if isDefaultConfig or EID.MCMLoaded then
for key, value in pairs(EID.Config) do
if savedEIDConfig[key] ~= nil then
if savedEIDConfig[key] ~= nil and type(value) == type(savedEIDConfig[key]) then
EID.Config[key] = savedEIDConfig[key]
end
end
end
EID.isHidden = EID.Config["Hidden"]
EID.isHidden = EID.Config["InitiallyHidden"]
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
EID:addTextPosModifier("HudOffset", Vector((EID.Config["HUDOffset"] * 2) - 20, EID.Config["HUDOffset"] - 10))
+4 -5
View File
@@ -187,18 +187,17 @@ if MCMLoaded then
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.isHidden
return EID.Config["InitiallyHidden"]
end,
Display = function()
local onOff = "False"
if EID.isHidden then
if EID.Config["InitiallyHidden"] then
onOff = "True"
end
return 'Is Hidden: ' .. onOff
return 'Is initially Hidden: ' .. onOff
end,
OnChange = function(currentBool)
EID.Config["Hidden"] = currentBool
EID.isHidden = currentBool
EID.Config["InitiallyHidden"] = currentBool
end
}
)