diff --git a/examples/menus/options/init.lua b/examples/menus/options/init.lua index 4e092b4..f602d68 100644 --- a/examples/menus/options/init.lua +++ b/examples/menus/options/init.lua @@ -37,6 +37,7 @@ function OptionsMenu:new() self:addSubMenu("lang", "lang") self:addSubMenu("input", "input") + Widgets.Resolution(self, "video") Widgets.Switch(self, "video", "fullscreen") Widgets.Switch(self, "video", "borders") Widgets.Switch(self, "video", "vsync") diff --git a/examples/menus/options/widgets.lua b/examples/menus/options/widgets.lua index f7aa2d5..eacbfea 100644 --- a/examples/menus/options/widgets.lua +++ b/examples/menus/options/widgets.lua @@ -30,6 +30,7 @@ widgets.SubMenu = DoubleTextWidget:extend() widgets.Dummy = Widget.Text:extend() widgets.Exit = Widget.Text:extend() widgets.Switch = DoubleTextWidget:extend() +widgets.Resolution = DoubleTextWidget:extend() -- BASIC WIDGETS -- Simple and reusables widgets @@ -144,5 +145,32 @@ function widgets.Switch:action() self:invalidateCanvas() end +-- Resolution Widget + +function widgets.Resolution:new(scene, menu) + self.scene = scene + local widgetmenu = self.scene.menusystem.menus[menu] + local font = self.scene.assets.fonts["medium"] + local keyname = "resolution" + local label2 = self:getLabel() + widgets.Resolution.super.new(self, widgetmenu, font, keyname, label2) +end + +function widgets.Resolution:getLabel() + return "x" .. core.options.data.video.resolution +end + +function widgets.Resolution:action() + if core.options.data.video.resolution == 3 then + core.options.data.video.resolution = 1 + else + core.options.data.video.resolution = core.options.data.video.resolution + 1 + end + self.label2 = self:getLabel() + core.screen:applySettings() + self:invalidateCanvas() + core.options:write() +end + return widgets