Skip to content

Commit

Permalink
Tooltip updates for dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Jan 13, 2024
1 parent ae501fa commit 5a63f12
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 24 deletions.
9 changes: 7 additions & 2 deletions class_configs/shd_class_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1203,8 +1203,13 @@ local _ClassConfig = {
},
['DefaultConfig'] = {
['Mode'] = { DisplayName = "Mode", Category = "Combat", Tooltip = "Select the Combat Mode for this Toon", Type = "Custom", RequiresLoadoutChange = true, Default = 1, Min = 1, Max = 3, },
['DoTorrent'] = { DisplayName = "Cast Torrents", Category = "Spells and Abilities", Tooltip = function(self) return mq.TLO.Spell(self.ResolvedActionMap['Torrent'])
.Description() end, RequiresLoadoutChange = true, Default = true, },
['DoTorrent'] = {
DisplayName = "Cast Torrents",
Category = "Spells and Abilities",
Tooltip = function() return RGMercUtils.GetDynamicTooltipForSpell("Torrent") end,
RequiresLoadoutChange = true,
Default = true,
},
['DoDireTap'] = { DisplayName = "Cast Dire Taps", Category = "Spells and Abilities", Tooltip = "Enable casting Dire Tap spells.", RequiresLoadoutChange = true, Default = true, },
['DoBandolier'] = { DisplayName = "Use Bandolier", Category = "Equipment", Tooltip = "Enable Swapping of items using the bandolier.", Default = false, },
['DoSnare'] = { DisplayName = "Cast Snares", Category = "Spells and Abilities", Tooltip = "Enable casting Snare spells.", Default = true, },
Expand Down
2 changes: 1 addition & 1 deletion extras/version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return { commitId = 'f6d15a1 2024-01-13' }
return { commitId = 'ae501fa 2024-01-13' }
4 changes: 2 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ local function RGMercsGUI()
ImGui.Text("Stuck To: " .. (mq.TLO.Stick.Active() and (mq.TLO.Stick.StickTargetName() or "None") or "None"))
if ImGui.CollapsingHeader("Config Options") then
local settingsRef = RGMercConfig:GetSettings()
settingsRef, pressed, _ = RGMercUtils.RenderSettings(nil, settingsRef, RGMercConfig.DefaultConfig, RGMercConfig.DefaultCategories)
settingsRef, pressed, _ = RGMercUtils.RenderSettings(settingsRef, RGMercConfig.DefaultConfig, RGMercConfig.DefaultCategories)
if pressed then
RGMercConfig:SaveSettings(false)
end
Expand All @@ -223,7 +223,7 @@ local function RGMercsGUI()
ImGui.PushID(n .. "_config_hdr")
if s and s.settings and s.defaults and s.categories then
if ImGui.CollapsingHeader(string.format("%s: Config Options", n)) then
s.settings, pressed, _ = RGMercUtils.RenderSettings(s.self, s.settings, s.defaults, s.categories)
s.settings, pressed, _ = RGMercUtils.RenderSettings(s.settings, s.defaults, s.categories)
if pressed then
RGMercModules:ExecModule(n, "SaveSettings", true)
end
Expand Down
4 changes: 2 additions & 2 deletions modules/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ function Module:Render()
if self.ClassConfig and self.ModuleLoaded then
ImGui.Text("Mode: ")
ImGui.SameLine()
RGMercUtils.Tooltip(self, self.ClassConfig.DefaultConfig.Mode.Tooltip)
RGMercUtils.Tooltip(self.ClassConfig.DefaultConfig.Mode.Tooltip)
self.settings.Mode, pressed = ImGui.Combo("##_select_ai_mode", self.settings.Mode, self.ClassConfig.Modes, #self.ClassConfig.Modes)
if pressed then
self:SaveSettings(false)
self.TempSettings.NewCombatMode = true
end

if ImGui.CollapsingHeader("Config Options") then
self.settings, pressed, loadoutChange = RGMercUtils.RenderSettings(self, self.settings, self.ClassConfig.DefaultConfig, self.DefaultCategories)
self.settings, pressed, loadoutChange = RGMercUtils.RenderSettings(self.settings, self.ClassConfig.DefaultConfig, self.DefaultCategories)
if pressed then
self:SaveSettings(false)
self.TempSettings.NewCombatMode = self.TempSettings.NewCombatMode or loadoutChange
Expand Down
2 changes: 1 addition & 1 deletion modules/mez.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function Module:Render()

if self.ModuleLoaded then
if ImGui.CollapsingHeader("Config Options") then
self.settings, pressed, _ = RGMercUtils.RenderSettings(self, self.settings, self.DefaultConfig, self.DefaultCategories)
self.settings, pressed, _ = RGMercUtils.RenderSettings(self.settings, self.DefaultConfig, self.DefaultCategories)
if pressed then
self:SaveSettings(false)
end
Expand Down
2 changes: 1 addition & 1 deletion modules/movement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function Module:Render()
local chaseSpawn = mq.TLO.Spawn("pc =" .. (self.settings.ChaseTarget or "NoOne"))

if ImGui.CollapsingHeader("Config Options") then
self.settings, pressed, _ = RGMercUtils.RenderSettings(self, self.settings, self.DefaultConfig, self.DefaultCategories)
self.settings, pressed, _ = RGMercUtils.RenderSettings(self.settings, self.DefaultConfig, self.DefaultCategories)
if pressed then
self:SaveSettings(false)
end
Expand Down
2 changes: 1 addition & 1 deletion modules/performance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function Module:Render()
self:SaveSettings(false)
end

self.settings, pressed, _ = RGMercUtils.RenderSettings(self, self.settings, self.DefaultConfig, self.DefaultCategories)
self.settings, pressed, _ = RGMercUtils.RenderSettings(self.settings, self.DefaultConfig, self.DefaultCategories)
if pressed then
self:SaveSettings(false)
end
Expand Down
2 changes: 1 addition & 1 deletion modules/pull.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function Module:Render()
end

if ImGui.CollapsingHeader("Config Options") then
self.settings, pressed, _ = RGMercUtils.RenderSettings(self, self.settings, self.DefaultConfig, self.DefaultCategories)
self.settings, pressed, _ = RGMercUtils.RenderSettings(self.settings, self.DefaultConfig, self.DefaultCategories)
if pressed then
self:SaveSettings(false)
end
Expand Down
31 changes: 18 additions & 13 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,12 @@ function Utils.SetLoadOut(caller, spellGemList, itemSets, abilitySets)
return resolvedActionMap, spellLoadOut
end

function Utils.GetDynamicTooltipForSpell(action)
local resolvedItem = RGMercModules:ExecModule("Class", "GetResolvedActionMapItem", action)

return string.format("Use %s Spell : %s\n\nThis Spell:\n%s", action, resolvedItem() or "None", resolvedItem.Description() or "None")
end

---@param loc string
function Utils.NavEnabledLoc(loc)
ImGui.PushStyleColor(ImGuiCol.Text, 0.690, 0.553, 0.259, 1)
Expand All @@ -2271,18 +2277,18 @@ function Utils.NavEnabledLoc(loc)
printf('\ayNavigating to \ag%s', loc)
end

Utils.Tooltip(nil, "Double click to Nav")
Utils.Tooltip("Double click to Nav")
end
end

---@param desc string
function Utils.Tooltip(caller, desc)
function Utils.Tooltip(desc)
ImGui.SameLine()
if ImGui.IsItemHovered() then
ImGui.BeginTooltip()
ImGui.PushTextWrapPos(ImGui.GetFontSize() * 25.0)
if type(desc) == "function" then
ImGui.Text(desc(caller))
ImGui.Text(desc())
else
ImGui.Text(desc)
end
Expand Down Expand Up @@ -2586,7 +2592,7 @@ function Utils.RenderRotationTable(caller, name, rotationTable, resolvedActionMa
if entry.cond then
local condArg = Utils.GetEntryConditionArg(resolvedActionMap, entry)
local condTarg = mq.TLO.Target
local pass = entry.cond(caller, condArg, condTarg, true)
local pass = entry.cond(condArg, condTarg, true)
local active = entry.active_cond and entry.active_cond(caller, condArg) or false

if active == true then
Expand All @@ -2605,7 +2611,7 @@ function Utils.RenderRotationTable(caller, name, rotationTable, resolvedActionMa
end
ImGui.PopStyleColor()
if entry.tooltip then
Utils.Tooltip(caller, entry.tooltip)
Utils.Tooltip(entry.tooltip)
end
ImGui.TableNextColumn()
local mappedAction = resolvedActionMap[entry.name]
Expand Down Expand Up @@ -2717,15 +2723,14 @@ function Utils.RenderOptionNumber(id, text, cur, min, max, step)
return input, changed
end

---@param caller self
---@param settings table
---@param settingNames table
---@param defaults table
---@param category string
---@return table # settings
---@return boolean # any_pressed
---@return boolean # requires_new_loadout
function Utils.RenderSettingsTable(caller, settings, settingNames, defaults, category)
function Utils.RenderSettingsTable(settings, settingNames, defaults, category)
local any_pressed = false
local new_loadout = false
---@type boolean|nil
Expand All @@ -2750,7 +2755,7 @@ function Utils.RenderSettingsTable(caller, settings, settingNames, defaults, cat
-- build a combo box.
ImGui.TableNextColumn()
ImGui.Text((defaults[k].DisplayName or "None"))
Utils.Tooltip(caller, defaults[k].Tooltip)
Utils.Tooltip(defaults[k].Tooltip)
ImGui.TableNextColumn()
ImGui.PushID("##combo_setting_" .. k)
settings[k], pressed = ImGui.Combo("", settings[k], defaults[k].ComboOptions)
Expand All @@ -2776,14 +2781,14 @@ function Utils.RenderSettingsTable(caller, settings, settingNames, defaults, cat
pressed = true
end
end
Utils.Tooltip(caller, string.format("Drop a new item here to replace\n%s", settings[k]))
Utils.Tooltip(string.format("Drop a new item here to replace\n%s", settings[k]))
new_loadout = new_loadout or ((pressed or false) and (defaults[k].RequiresLoadoutChange or false))
any_pressed = any_pressed or (pressed or false)
ImGui.PopID()
elseif defaults[k].Type ~= "Custom" then
ImGui.TableNextColumn()
ImGui.Text((defaults[k].DisplayName or "None"))
Utils.Tooltip(caller, defaults[k].Tooltip)
Utils.Tooltip(defaults[k].Tooltip)
ImGui.TableNextColumn()
if type(settings[k]) == 'boolean' then
settings[k], pressed = Utils.RenderOptionToggle(k, "", settings[k])
Expand All @@ -2796,7 +2801,7 @@ function Utils.RenderSettingsTable(caller, settings, settingNames, defaults, cat
any_pressed = any_pressed or pressed
elseif type(settings[k]) == 'string' then -- display only
ImGui.Text(settings[k])
Utils.Tooltip(caller, settings[k])
Utils.Tooltip(settings[k])
end
end
end
Expand All @@ -2814,7 +2819,7 @@ end
---@return table: settings
---@return boolean: any_pressed
---@return boolean: requires_new_loadout
function Utils.RenderSettings(caller, settings, defaults, categories)
function Utils.RenderSettings(settings, defaults, categories)
local any_pressed = false
local new_loadout = false

Expand Down Expand Up @@ -2854,7 +2859,7 @@ function Utils.RenderSettings(caller, settings, defaults, categories)
if ImGui.BeginTabItem(c) then
local cat_pressed = false

settings, cat_pressed, new_loadout = Utils.RenderSettingsTable(caller, settings, settingNames, defaults, c)
settings, cat_pressed, new_loadout = Utils.RenderSettingsTable(settings, settingNames, defaults, c)
any_pressed = any_pressed or cat_pressed
ImGui.EndTabItem()
end
Expand Down

0 comments on commit 5a63f12

Please sign in to comment.