diff --git a/MHRUIpp/BuffIndicatorPP.lua b/MHRUIpp/BuffIndicator++.lua similarity index 100% rename from MHRUIpp/BuffIndicatorPP.lua rename to MHRUIpp/BuffIndicator++.lua diff --git a/MHRUIpp/DebuffIndicatorPP.lua b/MHRUIpp/DebuffIndicator++.lua similarity index 100% rename from MHRUIpp/DebuffIndicatorPP.lua rename to MHRUIpp/DebuffIndicator++.lua diff --git a/MHRUIpp/HealthBarPP.lua b/MHRUIpp/HealthBar++.lua similarity index 100% rename from MHRUIpp/HealthBarPP.lua rename to MHRUIpp/HealthBar++.lua diff --git a/MHRUIpp/QuestTimerPP.lua b/MHRUIpp/QuestTimer++.lua similarity index 100% rename from MHRUIpp/QuestTimerPP.lua rename to MHRUIpp/QuestTimer++.lua diff --git a/MHRUIpp/SharpnessGaugePP.lua b/MHRUIpp/SharpnessGauge++.lua similarity index 100% rename from MHRUIpp/SharpnessGaugePP.lua rename to MHRUIpp/SharpnessGauge++.lua diff --git a/MHRUIpp/StaminaBarPP.lua b/MHRUIpp/StaminaBar++.lua similarity index 100% rename from MHRUIpp/StaminaBarPP.lua rename to MHRUIpp/StaminaBar++.lua diff --git a/MHRUIpp/StockUIHandler.lua b/MHRUIpp/StockUIHandler.lua index 51a8ca7..0a84f04 100644 --- a/MHRUIpp/StockUIHandler.lua +++ b/MHRUIpp/StockUIHandler.lua @@ -11,9 +11,10 @@ return { -- Set defaults and filepath o.cfgFilepath = o.cfgFilepath .. "StockUIHandler.json" o.defaults = mergeTables({o.defaults, { - showHUD = false, - showBuddyHUD = false, + showHUD = false, + showBuddyHUD = false, showSharpnessHUD = false, + showWeaponUI = false }}) -- Load config and font o:loadCfg() @@ -26,6 +27,7 @@ return { if self.cfg.showHUD then GUIManager:call("openHud") else GUIManager:call("closeHud") end if self.cfg.showBuddyHUD then GUIManager:call("openPartHud") else GUIManager:call("closePartHud") end if self.cfg.showSharpnessHUD then GUIManager:call("openHudSharpness") else GUIManager:call("closeHudSharpness") end + if self.cfg.showWeaponUI then GUIManager:call("openWeaponUI") else GUIManager:call("closeWeaponUI") end end, drawConfigWindow = function(self) @@ -45,6 +47,8 @@ return { changed, self.cfg.showSharpnessHUD = imgui.checkbox("Show Sharpness Gauge?", self.cfg.showSharpnessHUD) self.cfgChanged = self.cfgChanged or changed + changed, self.cfg.showWeaponUI = imgui.checkbox("Show Weapon UI?", self.cfg.showWeaponUI) + self.cfgChanged = self.cfgChanged or changed imgui.new_line() if imgui.button("Reset Defaults") then diff --git a/MHRUIpp/WeaponWidgets++/ChargeBladeUI++.lua b/MHRUIpp/WeaponWidgets++/ChargeBladeUI++.lua new file mode 100644 index 0000000..23fe677 --- /dev/null +++ b/MHRUIpp/WeaponWidgets++/ChargeBladeUI++.lua @@ -0,0 +1,97 @@ +require("MHRUIpp/interfaces") + +return { + new = function(self) + o = {} + setmetatable(self, {__index = IPersistantConfigurableViewableWidget}) + self.__index = self + setmetatable(o, self) + o.cfgFilepath = o.cfgFilepath .. "ChargeBladeUI++.json" + o.defaults = mergeTables({o.defaults, { + vialX = 5, + vialY = 105, + shieldX = 41, + shieldY = 105, + borderWidth = 2, + borderColor = "0xAA000000", + textColor = "0xFFFFFFFF" + }}) + o:loadCfg() + o:loadFont() + return o + end, + + draw = function(self) + local CBData, CBName = getCurrentWeaponInstanceAndName(); + if CBName ~= "ChargeAxe" or not CBData then return end + -- Gather all required CB stats. + local numVials = CBData:call("getBottleNumMax") + local numFilledVials = CBData:call("get_ChargedBottleNum") + local gaugeState = CBData:call("get_ChargeGaugeState") -- 0 = empty, 1 = half, 2 = full, 3 = overheat + local shieldBuffTimer = math.floor(CBData:get_field("_ShieldBuffTimer") * staminaUnitsToSeconds) + local swordBuffTimer = math.floor(CBData:get_field("_SwordBuffTimer") * staminaUnitsToSeconds) + local isSwordBuffed = CBData:call("isSwordBuff") + local isShieldBuffed = CBData:call("isShieldBuff") + + -- Draw vials and sword state gauge. + local text = string.format("%d/%d", numFilledVials, numVials) + local w = (string.len(text) * self.cfg.fontSize * fontAspectRatio) + (textHorizOffset << 1) + local h = self.cfg.fontSize + (textVertOffset << 1) + local borderOffset = self.cfg.borderWidth << 1 + + imgui.push_font(self.font) + draw.filled_rect(self.cfg.vialX - self.cfg.borderWidth, self.cfg.vialY - self.cfg.borderWidth, w + borderOffset, h + borderOffset, self.gaugeStateBorderColors[gaugeState]) + draw.filled_rect(self.cfg.vialX, self.cfg.vialY, w, h, (gaugeState == 3 and "0xAA6060FF" or "0xAA000000")) + draw.text(text, self.cfg.vialX + textHorizOffset, self.cfg.vialY + textVertOffset, self.cfg.textColor) + imgui.pop_font() + + -- Draw shield buff indicator + text = (isShieldBuffed and string.format("Shield: %02d:%02d", shieldBuffTimer // 60, shieldBuffTimer % 60) or "Shield: Empty") + w = (string.len(text) * self.cfg.fontSize * fontAspectRatio) + (textHorizOffset << 1) + + imgui.push_font(self.font) + draw.filled_rect(self.cfg.shieldX - self.cfg.borderWidth, self.cfg.shieldY - self.cfg.borderWidth, w + borderOffset, h + borderOffset, self.cfg.borderColor) + draw.filled_rect(self.cfg.shieldX, self.cfg.shieldY, w, h, (isShieldBuffed and "0XAA796AFF" or "0xAAAB7E4A")) + draw.text(text, self.cfg.shieldX + textHorizOffset, self.cfg.shieldY + textVertOffset, self.cfg.textColor) + imgui.pop_font() + end, + + drawConfigWindow = function(self) + -- self.cfgWinVisible = imgui.begin_window("Configure Buff Indicator++", true, 0x10120) + -- if not self.cfgWinVisible then return false end + + -- local changed = false; + -- changed, self.cfg.visible = imgui.checkbox("Show?", self.cfg.visible) + -- self.cfgChanged = self.cfgChanged or changed + -- changed, self.cfg.visibleNotDebuffed = imgui.checkbox("Show when not debuffed?", self.cfg.visibleNotDebuffed) + -- self.cfgChanged = self.cfgChanged or changed + -- imgui.new_line() + + -- changed, self.cfg.fontSize = imgui.drag_int("Font Size", self.cfg.fontSize, 1, 2, 50) + -- self.cfgChanged = self.cfgChanged or changed + -- changed, self.cfg.x = imgui.drag_int("X position", self.cfg.x, 2, 0, 10000) + -- self.cfgChanged = self.cfgChanged or changed + -- changed, self.cfg.y = imgui.drag_int("Y position", self.cfg.y, 2, 0, 10000) + -- self.cfgChanged = self.cfgChanged or changed + -- changed, self.cfg.borderWidth = imgui.drag_int("Border", self.cfg.borderWidth, 1, 0, 50) + -- self.cfgChanged = self.cfgChanged or changed + -- imgui.text("Color pickers coming soon!") + -- imgui.new_line() + + -- if imgui.button("Reset Defaults") then + -- self:restoreDefaults() + -- self.cfgChanged = true + -- end + + -- imgui.end_window() + + return true + end, + + gaugeStateBorderColors = { + [0] = "0xAA000000", + [1] = "0xAA04B3D0", + [2] = "0xAA4545D0", + [3] = "0xAA4545D0" + } +} \ No newline at end of file diff --git a/MHRUIpp_main.lua b/MHRUIpp_main.lua index a2845cd..ca54659 100644 --- a/MHRUIpp_main.lua +++ b/MHRUIpp_main.lua @@ -2,19 +2,20 @@ require("MHRUIpp/helpers") -- Put all elements in array and set them up. StockUIHandler = require("MHRUIpp/StockUIHandler"):new() -StaminaBarPP = require("MHRUIpp/StaminaBarPP"):new() -HealthBarPP = require("MHRUIpp/HealthBarPP"):new() -QuestTimerPP = require("MHRUIpp/QuestTimerPP"):new() -DebuffIndicatorPP = require("MHRUIpp/DebuffIndicatorPP"):new() -BuffIndicatorPP = require("MHRUIpp/BuffIndicatorPP"):new() -SharpnessGaugePP = require("MHRUIpp/SharpnessGaugePP"):new() +StaminaBarPP = require("MHRUIpp/StaminaBar++"):new() +HealthBarPP = require("MHRUIpp/HealthBar++"):new() +QuestTimerPP = require("MHRUIpp/QuestTimer++"):new() +DebuffIndicatorPP = require("MHRUIpp/DebuffIndicator++"):new() +BuffIndicatorPP = require("MHRUIpp/BuffIndicator++"):new() +SharpnessGaugePP = require("MHRUIpp/SharpnessGauge++"):new() MonsterHPBar = require("MHRUIpp/MonsterHPBar"):new() +ChargeBladeUIPP = require("MHRUIpp/WeaponWidgets++/ChargeBladeUI++"):new() -- Group widgets based on what interfaces they implement. -- Those with a Show button -local viewableWidgets = { StaminaBarPP, HealthBarPP, QuestTimerPP, DebuffIndicatorPP, BuffIndicatorPP, SharpnessGaugePP, MonsterHPBar } +local viewableWidgets = { StaminaBarPP, HealthBarPP, QuestTimerPP, DebuffIndicatorPP, BuffIndicatorPP, SharpnessGaugePP, MonsterHPBar, ChargeBladeUIPP } -- Those with profiles that need to be saved -local persistantConfigurableWidgets = { StaminaBarPP, HealthBarPP, QuestTimerPP, DebuffIndicatorPP, BuffIndicatorPP, SharpnessGaugePP, StockUIHandler, MonsterHPBar } +local persistantConfigurableWidgets = { StaminaBarPP, HealthBarPP, QuestTimerPP, DebuffIndicatorPP, BuffIndicatorPP, SharpnessGaugePP, StockUIHandler, MonsterHPBar, ChargeBladeUIPP } -- Those without a Show button local nonViewableWidgets = { StockUIHandler }