Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bmButtonHandlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ function BMButtonHandlers.RenderButtonIcon(Button, cursorScreenPos, size)

local draw_list = ImGui.GetWindowDrawList()

local iconId = Button.Icon
local iconType = Button.IconType
local iconId = Button.Icon or -1
local iconType = Button.IconType or ''
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change existing behavior (nil iconType means something) so please make sure this doesn't break existing stuff.


if Button.IconLua and Button.IconLua:len() > 0 then
local success
Expand All @@ -164,10 +164,11 @@ function BMButtonHandlers.RenderButtonIcon(Button, cursorScreenPos, size)
end

local renderIconAnim = animItems
if iconType == nil or iconType == "Spell" then

if iconType == "Spell" then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely broken as nil is a valid case. which will now be either nil or '' with your changes...

animSpellIcons:SetTextureCell(tonumber(iconId) or 0)
renderIconAnim = animSpellIcons
else
elseif iconType == "Item" then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could do if iconType == "Item" else ... assume spell

animItems:SetTextureCell(tonumber(iconId) or 0)
end

Expand Down
35 changes: 24 additions & 11 deletions bmEditButtonPopup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ BMButtonEditor.tmpButton = nil

BMButtonEditor.selectedTimerType = 1
BMButtonEditor.selectedUpdateRate = 1

-- ---@diagnostic disable-next-line:undefined-field
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not add comments back into the branch.

-- BMButtonEditor.textEditor = ImGui.TextEditor.new("##TextEditor")
-- BMButtonEditor.textEditor:SetSyntax('lua')
-- ---@diagnostic disable-next-line:undefined-global
-- BMButtonEditor.textEditor.windowFlags = bit32.bor(TextEditorWindowFlags.ShowLineNumbers, TextEditorWindowFlags.WrapText, TextEditorWindowFlags.ShowIndicators)
function BMButtonEditor:RenderEditButtonPopup()
if not self.editButtonPopupOpen then
picker:SetClosed()
Expand Down Expand Up @@ -71,7 +75,7 @@ function BMButtonEditor:RenderEditButtonPopup()
elseif attachmentType == "social" then
self.tmpButton.Label = buttonText
if cursorIndex + 1 > 120 then
self.tmpButton.Cmd = string.format("/alt act %d", cursorIndex - 120)
self.tmpButton.Cmd = string.format("/alt act %d", cursorIndex)
self.tmpButton.Icon = nil
self.tmpButton.Cooldown = buttonText
self.tmpButton.TimerType = "AA"
Expand All @@ -81,8 +85,7 @@ function BMButtonEditor:RenderEditButtonPopup()
for i = 0, 4 do
local cmd = mq.TLO.Social(cursorIndex + 1).Cmd(i)() or ""
if cmd:len() > 0 then
self.tmpButton.Cmd = string.format("%s%s%s", self.tmpButton.Cmd,
self.tmpButton.Cmd:len() > 0 and "\n" or "", cmd)
self.tmpButton.Cmd = string.format("%s%s%s", self.tmpButton.Cmd, self.tmpButton.Cmd:len() > 0 and "\n" or "", cmd)
end
end
end
Expand All @@ -108,8 +111,9 @@ function BMButtonEditor:RenderEditButtonPopup()
ButtonKey -- add the button key for this button set index
BMSettings:GetSettings().Buttons[ButtonKey] = btnUtils.shallowcopy(self.tmpButton) -- store the tmp button into the settings table
BMSettings:GetSettings().Buttons[ButtonKey].Unassigned = nil -- clear the unassigned flag

BMSettings:SaveSettings(true)
BMSettings:updateButtonDB(btnUtils.shallowcopy(self.tmpButton), ButtonKey)
BMSettings:updateSetDB(self.editButtonSet, self.editButtonIndex, ButtonKey)
self.editButtonUIChanged = false
else
btnUtils.Output("\arSave failed. Button Label cannot be empty.")
Expand Down Expand Up @@ -140,6 +144,8 @@ function BMButtonEditor:RenderEditButtonPopup()
BMSettings:GetSettings().Buttons[ButtonKey].Unassigned = nil -- clear the unassigned flag

BMSettings:SaveSettings(true)
BMSettings:updateButtonDB(btnUtils.shallowcopy(self.tmpButton), ButtonKey)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant all the DB updates be handle from SaveSettings? How do you know when to call updatebutton/updateset/etc? That should ideally be abstracted away as much as possible.

BMSettings:updateSetDB(self.editButtonSet, self.editButtonIndex, ButtonKey)
self.editButtonUIChanged = false
else
btnUtils.Output("\arSave failed. Button Label cannot be empty.")
Expand All @@ -152,6 +158,7 @@ end

function BMButtonEditor:CloseEditPopup()
picker:SetClosed()
-- self.textEditor:Clear()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not add comments back into the branch.

self.editButtonPopupOpen = false
self.editButtonIndex = 0
self.editButtonSet = ""
Expand All @@ -163,6 +170,7 @@ function BMButtonEditor:OpenEditPopup(Set, Index)
self.editButtonSet = Set
self.selectedTimerType = 1
self.selectedUpdateRate = 1

local button = BMSettings:GetButtonBySetIndex(Set, Index)
self.tmpButton = btnUtils.shallowcopy(button)

Expand All @@ -180,6 +188,7 @@ function BMButtonEditor:OpenEditPopup(Set, Index)
end
end
end
-- self.textEditor:Clear()
end

function BMButtonEditor:CreateButtonFromCursor(Set, Index)
Expand All @@ -201,14 +210,12 @@ function BMButtonEditor:RenderButtonEditUI(renderButton, enableShare, enableEdit

local colorChanged = false
-- color pickers
colorChanged = btnUtils.RenderColorPicker(string.format("##ButtonColorPicker1_%s", renderButton.Label), 'Button',
renderButton,
colorChanged = btnUtils.RenderColorPicker(string.format("##ButtonColorPicker1_%s", renderButton.Label), 'Button', renderButton,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem like non-changes polluting the PR. Can you get rid of them please?

'ButtonColorRGB')
self.editButtonUIChanged = self.editButtonUIChanged or colorChanged

ImGui.SameLine()
colorChanged = btnUtils.RenderColorPicker(string.format("##TextColorPicker1_%s", renderButton.Label), 'Text',
renderButton, 'TextColorRGB')
colorChanged = btnUtils.RenderColorPicker(string.format("##TextColorPicker1_%s", renderButton.Label), 'Text', renderButton, 'TextColorRGB')
self.editButtonUIChanged = self.editButtonUIChanged or colorChanged

ImGui.SameLine()
Expand Down Expand Up @@ -265,8 +272,7 @@ function BMButtonEditor:RenderButtonEditUI(renderButton, enableShare, enableEdit
btnUtils.Tooltip(
"Dynamically override the IconID with this Lua function. \nNote: This MUST return number, string : IconId, IconType")

self.selectedUpdateRate, _ = ImGui.Combo("Update Rate", self.selectedUpdateRate,
function(idx) return BMSettings.Constants.UpdateRates[idx].Display end,
self.selectedUpdateRate, _ = ImGui.Combo("Update Rate", self.selectedUpdateRate, function(idx) return BMSettings.Constants.UpdateRates[idx].Display end,
#BMSettings.Constants.UpdateRates)
renderButton.UpdateRate = BMSettings.Constants.UpdateRates[self.selectedUpdateRate].Value
self.editButtonUIChanged = self.editButtonUIChanged or textChanged
Expand All @@ -284,6 +290,13 @@ function BMButtonEditor:RenderButtonEditUI(renderButton, enableShare, enableEdit
ImGui.PushFont(ImGui.ConsoleFont)
renderButton.Cmd, textChanged = ImGui.InputTextMultiline("##_Cmd_Edit", renderButton.Cmd or "",
ImVec2(ImGui.GetWindowWidth() * 0.98, editHeight), ImGuiInputTextFlags.AllowTabInput)
-- self.textEditor:Render(ImVec2(ImGui.GetWindowWidth() * 0.98, editHeight))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not add comments back into the branch.

-- local textContents = self.textEditor.text ~= '' and self.textEditor.text or (renderButton.Cmd and renderButton.Cmd or "")
-- self.textEditor:LoadContents(textContents)
-- if self.textEditor.text ~= renderButton.Cmd then
-- textChanged = true
-- renderButton.Cmd = self.textEditor.text
-- end
ImGui.PopFont()
self.editButtonUIChanged = self.editButtonUIChanged or textChanged
end
Expand Down
33 changes: 32 additions & 1 deletion bmHotbarClass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function BMHotbarClass.new(id, createFresh)
newBMHotbar.newY = 500

BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end

BMSettings:GetCharConfig().Windows[id].Sets = BMSettings:GetCharConfig().Windows[id].Sets or {}
Expand All @@ -79,6 +80,7 @@ function BMHotbarClass:ToggleVisible()
BMSettings:GetCharacterWindow(self.id).Visible = not BMSettings:GetCharacterWindow(self.id).Visible
self.openGUI = BMSettings:GetCharacterWindow(self.id).Visible
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end

function BMHotbarClass:IsVisible()
Expand Down Expand Up @@ -247,6 +249,7 @@ function BMHotbarClass:RenderTabs()
--ImGuiWindowFlags.NoMove
BMSettings:GetCharacterWindow(self.id).Locked = not BMSettings:GetCharacterWindow(self.id).Locked
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end

ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (iconPadding))
Expand Down Expand Up @@ -277,6 +280,7 @@ function BMHotbarClass:RenderTabs()
--ImGuiWindowFlags.NoMove
BMSettings:GetCharacterWindow(self.id).Locked = not BMSettings:GetCharacterWindow(self.id).Locked
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end

ImGui.SameLine()
Expand Down Expand Up @@ -380,6 +384,7 @@ function BMHotbarClass:RenderTabContextMenu()
if ImGui.MenuItem(k) then
table.insert(BMSettings:GetCharacterWindowSets(self.id), k)
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
break
end
end
Expand All @@ -392,6 +397,7 @@ function BMHotbarClass:RenderTabContextMenu()
if ImGui.MenuItem(v) then
table.remove(BMSettings:GetCharConfig().Windows[self.id].Sets, i)
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
break
end
end
Expand All @@ -413,6 +419,8 @@ function BMHotbarClass:RenderTabContextMenu()
end
BMSettings:GetSettings().Sets[k] = nil
BMSettings:SaveSettings(true)
BMSettings:deleteSetFromDB(k)
BMSettings:deleteSetFromCharacterDB(BMSettings.CharConfig, k)
break
end
end
Expand All @@ -439,6 +447,7 @@ function BMHotbarClass:RenderTabContextMenu()
end
BMSettings:GetSettings().Buttons[buttonData.id] = nil
BMSettings:SaveSettings(true)
BMSettings:deleteButtonFromDB(buttonData.id)
break
end
end
Expand All @@ -458,6 +467,7 @@ function BMHotbarClass:RenderTabContextMenu()
BMSettings:GetCharacterWindow(self.id).ButtonSize = i
self.buttonSizeDirty = true
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
break
end
end
Expand Down Expand Up @@ -489,6 +499,7 @@ function BMHotbarClass:RenderTabContextMenu()
if ImGui.MenuItem(v.label, nil, checked) then
BMSettings:GetCharacterWindow(self.id).Font = v.size
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
break
end
end
Expand All @@ -500,12 +511,15 @@ function BMHotbarClass:RenderTabContextMenu()
if ImGui.MenuItem("Default", nil, checked) then
BMSettings:GetCharacterWindow(self.id).Theme = nil
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end
for n, _ in pairs(themes) do
checked = (BMSettings:GetCharacterWindow(self.id).Theme or "") == n
if ImGui.MenuItem(n, nil, checked) then
BMSettings:GetCharacterWindow(self.id).Theme = n
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())

break
end
end
Expand All @@ -514,6 +528,8 @@ function BMHotbarClass:RenderTabContextMenu()
if ImGui.MenuItem(n, nil, checked) then
BMSettings:GetCharacterWindow(self.id).Theme = n
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())

break
end
end
Expand Down Expand Up @@ -548,7 +564,9 @@ function BMHotbarClass:RenderTabContextMenu()
table.sort(charList, function(a, b) return a.key < b.key end)
for _, value in ipairs(charList) do
if ImGui.MenuItem(value.displayName) then
CopyLocalSet(value.key)
-- CopyLocalSet(value.key)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not add comments back into the branch.

Also is there a reason this was moved to the other coroutine? I am not against it but just curious why this was done.

BMCopy = true
BMCopyKey = value.key
end
end
ImGui.EndMenu()
Expand All @@ -561,26 +579,31 @@ function BMHotbarClass:RenderTabContextMenu()
BMSettings:GetCharacterWindow(self.id).HideTitleBar = not BMSettings:GetCharacterWindow(self.id)
.HideTitleBar
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doesnt SaveSettings do updateCharacterDB?

end
if ImGui.MenuItem((BMSettings:GetCharacterWindow(self.id).CompactMode and "Normal" or "Compact") .. " Mode") then
BMSettings:GetCharacterWindow(self.id).CompactMode = not BMSettings:GetCharacterWindow(self.id)
.CompactMode
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end
if ImGui.MenuItem((BMSettings:GetCharacterWindow(self.id).AdvTooltips and "Disable" or "Enable") .. " Advanced Tooltips") then
BMSettings:GetCharacterWindow(self.id).AdvTooltips = not BMSettings:GetCharacterWindow(self.id)
.AdvTooltips
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end
if ImGui.MenuItem((BMSettings:GetCharacterWindow(self.id).HideScrollbar and "Show" or "Hide") .. " Scrollbar") then
BMSettings:GetCharacterWindow(self.id).HideScrollbar = not BMSettings:GetCharacterWindow(self.id)
.HideScrollbar
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end
if ImGui.MenuItem((BMSettings:GetCharacterWindow(self.id).ShowSearch and "Disable" or "Enable") .. " Search") then
BMSettings:GetCharacterWindow(self.id).ShowSearch = not BMSettings:GetCharacterWindow(self.id)
.ShowSearch
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end
local fps_scale = {
{
Expand All @@ -607,6 +630,8 @@ function BMHotbarClass:RenderTabContextMenu()
if ImGui.MenuItem(v.label, nil, checked) then
BMSettings:GetCharacterWindow(self.id).FPS = v.fps
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())

break
end
end
Expand Down Expand Up @@ -751,6 +776,7 @@ function BMHotbarClass:RenderContextMenu(Set, Index, buttonID)
if ImGui.MenuItem(BMButtonHandlers.ResolveButtonLabel(value, true)) then
BMSettings:GetSettings().Sets[Set][Index] = key
BMSettings:SaveSettings(true)
BMSettings:deleteButtonFromSetDB(Set, Index)
break
end
end
Expand All @@ -771,6 +797,7 @@ function BMHotbarClass:RenderContextMenu(Set, Index, buttonID)
if ImGui.MenuItem("Unassign") then
BMSettings:GetSettings().Sets[Set][Index] = nil
BMSettings:SaveSettings(true)
BMSettings:deleteButtonFromSetDB(Set, Index)
end
if ImGui.MenuItem(Icons.MD_SHARE) then
BMButtonHandlers.ExportButtonToClipBoard(button)
Expand Down Expand Up @@ -842,6 +869,7 @@ function BMHotbarClass:RenderButtons(Set, searchText)
BMSettings:GetSettings().Sets[Set][ButtonIndex],
BMSettings:GetSettings().Sets[Set][num]
BMSettings:SaveSettings(true)
BMSettings:convertConfigToDB('sets')
end
ImGui.EndDragDropTarget()
end
Expand Down Expand Up @@ -955,6 +983,8 @@ function BMHotbarClass:RenderCreateTab()
table.insert(BMSettings:GetCharConfig().Windows[self.id].Sets, self.newSetName)
BMSettings:GetSettings().Sets[self.newSetName] = {}
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
BMSettings:updateSetDB(self.newSetName, 1, '')
else
btnUtils.Output("\arError Saving Set: A set with this name already exists!\ax")
end
Expand Down Expand Up @@ -990,6 +1020,7 @@ function BMHotbarClass:GiveTime()
if not BMSettings:GetCharacterWindow(self.id).FPS then
BMSettings:GetCharacterWindow(self.id).FPS = 0
BMSettings:SaveSettings(true)
BMSettings:updateCharacterDB(BMSettings.CharConfig, BMSettings:GetCharConfig())
end

local fps = BMSettings:GetCharacterWindow(self.id).FPS / 10
Expand Down
Loading