examples/options: support language changing
This commit is contained in:
parent
a470f53f8f
commit
853a55cda4
2 changed files with 25 additions and 0 deletions
|
@ -42,6 +42,8 @@ function OptionsMenu:new()
|
||||||
Widgets.Switch(self, "video", "borders")
|
Widgets.Switch(self, "video", "borders")
|
||||||
Widgets.Switch(self, "video", "vsync")
|
Widgets.Switch(self, "video", "vsync")
|
||||||
|
|
||||||
|
self:setLanguageMenu()
|
||||||
|
|
||||||
Widgets.Exit(self, "main")
|
Widgets.Exit(self, "main")
|
||||||
self.menusystem:switchMenu("main")
|
self.menusystem:switchMenu("main")
|
||||||
end
|
end
|
||||||
|
@ -66,6 +68,12 @@ function OptionsMenu:addScene(submenu, scene, fullname)
|
||||||
Widgets.Dummy(self, submenu, fullname)
|
Widgets.Dummy(self, submenu, fullname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function OptionsMenu:setLanguageMenu()
|
||||||
|
for i,v in ipairs(core.lang.data.available) do
|
||||||
|
Widgets.Lang(self, "langs", v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function OptionsMenu:draw()
|
function OptionsMenu:draw()
|
||||||
love.graphics.setColor(.3, .1, .4, 1)
|
love.graphics.setColor(.3, .1, .4, 1)
|
||||||
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
||||||
|
|
|
@ -31,6 +31,7 @@ widgets.Dummy = Widget.Text:extend()
|
||||||
widgets.Exit = Widget.Text:extend()
|
widgets.Exit = Widget.Text:extend()
|
||||||
widgets.Switch = DoubleTextWidget:extend()
|
widgets.Switch = DoubleTextWidget:extend()
|
||||||
widgets.Resolution = DoubleTextWidget:extend()
|
widgets.Resolution = DoubleTextWidget:extend()
|
||||||
|
widgets.Lang = Widget.Text:extend()
|
||||||
|
|
||||||
-- BASIC WIDGETS
|
-- BASIC WIDGETS
|
||||||
-- Simple and reusables widgets
|
-- Simple and reusables widgets
|
||||||
|
@ -178,5 +179,21 @@ function widgets.Resolution:action()
|
||||||
core.options:write()
|
core.options:write()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- LANGS WIDGET
|
||||||
|
-- Allow you to change the lang of the game
|
||||||
|
|
||||||
|
function widgets.Lang:new(scene, menu, lang)
|
||||||
|
self.scene = scene
|
||||||
|
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||||
|
local font = self.scene.assets.fonts["medium"]
|
||||||
|
local label = core.lang:getLangName(lang)
|
||||||
|
self.lang = lang
|
||||||
|
widgets.Lang.super.new(self, widgetmenu, font, label)
|
||||||
|
end
|
||||||
|
|
||||||
|
function widgets.Lang:action()
|
||||||
|
core.options:setLanguage(self.lang)
|
||||||
|
--self.scene.menusystem:invalidateAllWidgets()
|
||||||
|
end
|
||||||
|
|
||||||
return widgets
|
return widgets
|
||||||
|
|
Loading…
Reference in a new issue