From bc04732263fb964d0b3ca09225e65b039e620cb6 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sun, 20 Jun 2021 17:24:33 +0200 Subject: [PATCH] Added Hud Offset config option and fixed config changes made by MCM not being saved correctly --- eid_api.lua | 17 +++++------------ eid_config.lua | 11 ++++++++--- main.lua | 1 + mod_config_menu.lua | 10 +++++----- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 6c5451df..0f158a98 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -806,25 +806,18 @@ function EID:handleHUDElement(hudElement) alteredHudElement[k] = v end local screenSize = EID:GetScreenSize() + local hudOffset = EID.Config["HUDOffset"] for _,v in ipairs(hudElement.anchors) do if v == "TOP" then - if EID.MCMLoaded then - alteredHudElement.y = hudElement.y + EID.MCMHudOffset * 2 - end + alteredHudElement.y = hudElement.y + hudOffset * 2 elseif v == "LEFT" then - if EID.MCMLoaded then - alteredHudElement.x = hudElement.x + EID.MCMHudOffset * 2 - end + alteredHudElement.x = hudElement.x + hudOffset * 2 elseif v == "BOTTOM" then alteredHudElement.y = screenSize.Y*2 - alteredHudElement.y - alteredHudElement.height - if EID.MCMLoaded then - alteredHudElement.y = alteredHudElement.y - EID.MCMHudOffset * 2 - end + alteredHudElement.y = alteredHudElement.y - hudOffset * 2 elseif v == "RIGHT" then alteredHudElement.x = screenSize.X*2 - alteredHudElement.x - alteredHudElement.width - if EID.MCMLoaded then - alteredHudElement.x = alteredHudElement.x - EID.MCMHudOffset * 2 - end + alteredHudElement.x = alteredHudElement.x - hudOffset * 2 end end return alteredHudElement diff --git a/eid_config.lua b/eid_config.lua index 576bcba1..6c884183 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -30,11 +30,15 @@ EID.UserConfig = { -- Set transparency of the background. Range: [0,...,1] -- Default = 0.75 ["Transparency"] = 0.75, + -- Set the HUD offset of the description. + -- This should be set to the same number of "strokes" set in the ingame options for the "hud offset" value. (Range is 0 to 10) + -- Default = 10 + ["HUDOffset"] = 10, -- Set X Position (Width) of the descriptiontext - -- Default = 60 (with default rep Hud offset, otherwise 50 is recommended) + -- Default = 60 ["XPosition"] = 60, -- Set Y Position (Height) of the descriptiontext - -- Default = 45 (with default rep Hud offset, otherwise 35 is recommended) + -- Default = 45 ["YPosition"] = 45, -- Set the distance to an item in which informations will be displayed (in Tiles) -- Default = 5 @@ -215,6 +219,7 @@ EID.DefaultConfig = { ["TextboxWidth"] = 100, ["Scale"] = 1, ["Transparency"] = 0.75, + ["HUDOffset"] = 10, ["XPosition"] = 60, ["YPosition"] = 45, ["MaxDistance"] = 5, @@ -249,7 +254,7 @@ EID.DefaultConfig = { ["DisplayBagOfCrafting"] = "always", ["BagOfCraftingResults"] = 7, ["SpindownDiceResults"] = 3, - ["UseMouseControls"] = false, + ["EnableMouseControls"] = false, ["ShowCursor"] = false, ["ErrorMessage"] = "[Effect not defined]", ["TextColor"] = "ColorEIDText", diff --git a/main.lua b/main.lua index 6cc856fd..a4493b02 100644 --- a/main.lua +++ b/main.lua @@ -740,6 +740,7 @@ if EID.MCMLoaded or REPENTANCE then EID.isHidden = EID.Config["Hidden"] 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)) end end end diff --git a/mod_config_menu.lua b/mod_config_menu.lua index eefec0f4..0a871a63 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -6,7 +6,6 @@ local MCMCompat_isDisplayingDummyMCMObj = false local MCMCompat_oldPermanentObj = false EID.MCMLoaded = MCMLoaded local colorNameArray = {} -EID.MCMHudOffset = 10 local function renderDummyDesc() MCMCompat_oldPermanentObj = EID.permanentDisplayTextObj @@ -29,11 +28,12 @@ end function EID:renderMCMDummyDescription() if MCMLoaded then - EID.MCMHudOffset = ModConfigMenu.Config["General"].HudOffset - if EID.MCMHudOffset == nil and ScreenHelper then - EID.MCMHudOffset = ScreenHelper.GetOffset() + local hudOffset = ModConfigMenu.Config["General"].HudOffset + if hudOffset == nil and ScreenHelper then + hudOffset = ScreenHelper.GetOffset() end - EID:addTextPosModifier("MCM_HudOffset", Vector((EID.MCMHudOffset * 2) - 20, EID.MCMHudOffset - 10)) + EID.Config["HUDOffset"] = hudOffset + EID:addTextPosModifier("HudOffset", Vector((hudOffset * 2) - 20, hudOffset - 10)) if MCM.IsVisible and EID.MCMCompat_isDisplayingEIDTab ~= "" then if EID.MCMCompat_isDisplayingEIDTab == "Mouse" and EID.Config["EnableMouseControls"] then clearRenderDummyDesc()