Skip to content

Commit

Permalink
Text Size Slider
Browse files Browse the repository at this point in the history
Added a text size slider to the config popup.
will adjust text on all of Alert Master's Windows
  • Loading branch information
grimmier378 committed Mar 28, 2024
1 parent 4c1bd36 commit 7d85cef
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions init.lua
Expand Up @@ -59,8 +59,7 @@ local useThemeName = 'Default'
local ColorCount = 0
local openConfigGUI = false
local themeFile = mq.configDir .. '/MyThemeZ.lua'

-- local a = mq.moduleDir
local ZoomLvl = 1.0

---@class
local DistColorRanges = {
Expand Down Expand Up @@ -205,6 +204,8 @@ local load_settings = function()
if settings['SafeZones'] == nil then settings['SafeZones'] = {} end
useThemeName = settings[CharConfig]['theme'] or 'Default'
settings[CharConfig]['theme'] = useThemeName
ZoomLvl = settings[CharConfig]['ZoomLvl'] or 1.0
settings[CharConfig]['ZoomLvl'] = ZoomLvl
delay = settings[CharConfig]['delay']
remind = settings[CharConfig]['remind']
pcs = settings[CharConfig]['pcs']
Expand Down Expand Up @@ -256,7 +257,7 @@ local function ColorDistance(distance)
return COLOR.color('red')
end
end
function isSpawnInAlerts(spawnName, spawnAlerts)
local function isSpawnInAlerts(spawnName, spawnAlerts)
for _, spawnData in pairs(spawnAlerts) do
if spawnData.DisplayName() == spawnName or spawnData.Name() == spawnName then
return true
Expand Down Expand Up @@ -496,6 +497,7 @@ local function DrawToggles()
local gIcon = Icons.MD_SETTINGS
if ImGui.Button(gIcon) then
openConfigGUI = not openConfigGUI
save_settings()
--mq.pickle(themeFile, theme)
end
if ImGui.IsItemHovered() and showTooltips then
Expand Down Expand Up @@ -719,8 +721,7 @@ local function DrawSearchWindow()
end

SearchWindowOpen = ImGui.Begin("Alert Master", SearchWindowOpen, GUI_Main.Flags)

ImGui.SameLine()
ImGui.SetWindowFontScale(ZoomLvl)
DrawToggles()
--ImGui.SameLine()
ImGui.Separator()
Expand Down Expand Up @@ -903,6 +904,7 @@ local function DrawSearchWindow()
end
ImGui.PopStyleVar(1)
if ColorCount > 0 then ImGui.PopStyleColor(ColorCount) end
ImGui.SetWindowFontScale(1)
ImGui.End()

end
Expand All @@ -923,10 +925,12 @@ function Config_GUI(open)
end

open, openConfigGUI = ImGui.Begin("config", open, bit32.bor(ImGuiWindowFlags.None, ImGuiWindowFlags.NoCollapse))
ImGui.SetWindowFontScale(ZoomLvl)
if not openConfigGUI then
openConfigGUI = false
open = false
if ColorCountConf > 0 then ImGui.PopStyleColor(ColorCountConf) end
ImGui.SetWindowFontScale(1)
ImGui.End()
return open
end
Expand All @@ -935,6 +939,7 @@ function Config_GUI(open)
ImGui.Text("Cur Theme: %s", themeName)
-- Combo Box Load Theme
if ImGui.BeginCombo("Load Theme", themeName) then
ImGui.SetWindowFontScale(ZoomLvl)
for k, data in pairs(theme.Theme) do
local isSelected = data.Name == themeName
if ImGui.Selectable(data.Name, isSelected) then
Expand All @@ -948,9 +953,20 @@ function Config_GUI(open)
ImGui.EndCombo()
end

if ColorCountConf > 0 then ImGui.PopStyleColor(ColorCountConf) end
-- Slider for adjusting zoom level
local tmpZoom = ZoomLvl
if ZoomLvl then
tmpZoom = ImGui.SliderFloat("Zoom Level", tmpZoom, 0.5, 2.0)
end
if ZoomLvl ~= tmpZoom then
ZoomLvl = tmpZoom
settings[CharConfig]['ZoomLvl'] = ZoomLvl
end

if ColorCountConf > 0 then ImGui.PopStyleColor(ColorCountConf) end
ImGui.SetWindowFontScale(1)
ImGui.End()

end
local ColorCountAlert = 0
local function BuildAlertRows() -- Build the Button Rows for the GUI Window
Expand Down Expand Up @@ -1025,10 +1041,12 @@ function DrawAlertGUI() -- Draw GUI Window
spawnAlerts = {}
end
else
ImGui.SetWindowFontScale(ZoomLvl)
BuildAlertRows()
end
ImGui.PopStyleVar(1)
ImGui.PopStyleColor(ColorCountAlert)
ImGui.SetWindowFontScale(1)
ImGui.End()
end
end
Expand Down

0 comments on commit 7d85cef

Please sign in to comment.