Skip to content

Commit

Permalink
Add font size slider to game menu
Browse files Browse the repository at this point in the history
  • Loading branch information
seblindfors committed Jun 25, 2024
1 parent 2986bad commit 8b89190
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ConsolePort/ConsolePort.toc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Title: Console Port
## Notes: Game controller addon
## AddonCompartmentFunc: ConsolePort
## Version: 2.9.7
## Version: 2.9.8

## Author: Sebastian Lindfors
## X-Website: https://github.com/seblindfors/ConsolePort
Expand Down
6 changes: 6 additions & 0 deletions ConsolePort/Model/Data/Shared.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local _, db = ...;
local Shared = db:Register('Shared', CPAPI.CreateEventHandler({'Frame', '$parentSharedDataHandler', ConsolePort}, {
'PLAYER_LOGOUT';
'PLAYER_ENTERING_WORLD';
}, {
Data = {};
}))
Expand Down Expand Up @@ -71,6 +72,7 @@ function Shared:RemoveData(idx, set)
end

function Shared:SaveBindings(bindings)
if not self.metaDataAvailable then return end;
self:SavePlayerData('Bindings', bindings, true)
end

Expand Down Expand Up @@ -109,6 +111,10 @@ function Shared:CollectGarbageRecursive(tbl)
end
end

function Shared:PLAYER_ENTERING_WORLD()
self.metaDataAvailable = true;
end

function Shared:OnDataLoaded()
db:Load('Shared/Data', 'ConsolePortShared')
db:RegisterCallback('OnNewBindings', self.SaveBindings, self)
Expand Down
14 changes: 14 additions & 0 deletions ConsolePort/Widget/PieMenu/PieMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function CPPieMenuMixin:UpdatePieSlices(isShown, numSlices)
slice:Show()
if newObj then
slice:SynchronizeAnimation(self.ActiveSlice)
slice:SetTextSize(self.sliceTextSize)
end
end
end
Expand Down Expand Up @@ -144,6 +145,13 @@ function CPPieMenuMixin:SetSliceText(index, text)
end
end

function CPPieMenuMixin:SetSliceTextSize(size)
self.sliceTextSize = size;
for slice in self.SlicePool:EnumerateActive() do
slice:SetTextSize(size)
end
end

function CPPieMenuMixin:SetActiveSliceText(text)
self.ActiveSlice:SetText(text)
end
Expand Down Expand Up @@ -320,6 +328,12 @@ function CPPieSliceMixin:SetText(text)
end
end

function CPPieSliceMixin:SetTextSize(size)
if not size then return end;
local font, _, flags = self.Text:GetFont()
self.Text:SetFont(font, size, flags)
end

function CPPieSliceMixin:GetText()
return self.Text:GetText()
end
5 changes: 4 additions & 1 deletion ConsolePort_Menu/Database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ ConsolePort:AddVariables({
gameMenuScale = _{Data.Range(1, 0.05, 0.5, 2);
name = 'Scale';
desc = 'Scale of the game menu and radial companion.';
advd = true;
};
gameMenuFontSize = _{Data.Range(12, 1, 8, 20);
name = 'Font Size';
desc = 'Font size of the ring slice buttons.';
};
gameMenuCustomSet = _{Data.Bool(false);
name = 'Use Custom Button Set';
Expand Down
4 changes: 3 additions & 1 deletion ConsolePort_Menu/View/Ring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ end

function Selector:OnSizingChanged()
self:SetScale(db('gameMenuScale'))
self:SetSliceTextSize(db('gameMenuFontSize'))
end

function Selector:OnControlsChanged()
Expand Down Expand Up @@ -409,5 +410,6 @@ db:RegisterSafeCallbacks(Selector.OnControlsChanged, Selector,
'Settings/gameMenuSwitch'
);
db:RegisterSafeCallbacks(Selector.OnSizingChanged, Selector,
'Settings/gameMenuScale'
'Settings/gameMenuScale',
'Settings/gameMenuFontSize'
);

0 comments on commit 8b89190

Please sign in to comment.