Fixed mouse bug, allow locales list
This commit is contained in:
parent
b1bab32618
commit
8f9055f48b
|
@ -17,14 +17,22 @@ end
|
||||||
function createWindow()
|
function createWindow()
|
||||||
localesWindow = g_ui.displayUI('locales')
|
localesWindow = g_ui.displayUI('locales')
|
||||||
local localesPanel = localesWindow:getChildById('localesPanel')
|
local localesPanel = localesWindow:getChildById('localesPanel')
|
||||||
|
local layout = localesPanel:getLayout()
|
||||||
|
local spacing = layout:getCellSpacing()
|
||||||
|
local size = layout:getCellSize()
|
||||||
|
|
||||||
|
local count = 0
|
||||||
for name,locale in pairs(installedLocales) do
|
for name,locale in pairs(installedLocales) do
|
||||||
local widget = g_ui.createWidget('LocalesButton', localesPanel)
|
local widget = g_ui.createWidget('LocalesButton', localesPanel)
|
||||||
widget:setImageSource('/images/flags/' .. name .. '')
|
widget:setImageSource('/images/flags/' .. name .. '')
|
||||||
widget:setText(locale.languageName)
|
widget:setText(locale.languageName)
|
||||||
widget.onClick = function() selectFirstLocale(name) end
|
widget.onClick = function() selectFirstLocale(name) end
|
||||||
|
count = count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
count = math.max(1, math.min(count, 3))
|
||||||
|
localesPanel:setWidth(size.width*count + spacing*(count-1))
|
||||||
|
|
||||||
addEvent(function() addEvent(function() localesWindow:raise() localesWindow:focus() end) end)
|
addEvent(function() addEvent(function() localesWindow:raise() localesWindow:focus() end) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,7 +69,7 @@ function init()
|
||||||
pdebug('Using configured locale: ' .. userLocaleName)
|
pdebug('Using configured locale: ' .. userLocaleName)
|
||||||
else
|
else
|
||||||
setLocale(defaultLocaleName)
|
setLocale(defaultLocaleName)
|
||||||
connect(g_app, {onRun = createWindow})
|
connect(g_app, { onRun = createWindow })
|
||||||
end
|
end
|
||||||
|
|
||||||
ProtocolGame.registerExtendedOpcode(ExtendedIds.Locale, onExtendedLocales)
|
ProtocolGame.registerExtendedOpcode(ExtendedIds.Locale, onExtendedLocales)
|
||||||
|
@ -73,6 +81,7 @@ function terminate()
|
||||||
currentLocale = nil
|
currentLocale = nil
|
||||||
|
|
||||||
ProtocolGame.unregisterExtendedOpcode(ExtendedIds.Locale)
|
ProtocolGame.unregisterExtendedOpcode(ExtendedIds.Locale)
|
||||||
|
disconnect(g_app, { onRun = createWindow })
|
||||||
disconnect(g_game, { onGameStart = onGameStart })
|
disconnect(g_game, { onGameStart = onGameStart })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -101,6 +110,8 @@ function installLocale(locale)
|
||||||
error('Unable to install locale.')
|
error('Unable to install locale.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if _G.allowedLocales and not _G.allowedLocales[locale.name] then return end
|
||||||
|
|
||||||
if locale.name ~= defaultLocaleName then
|
if locale.name ~= defaultLocaleName then
|
||||||
local updatesNeeded = 0
|
local updatesNeeded = 0
|
||||||
for _i,k in pairs(neededTranslations) do
|
for _i,k in pairs(neededTranslations) do
|
||||||
|
|
|
@ -24,8 +24,6 @@ UIWindow
|
||||||
|
|
||||||
Panel
|
Panel
|
||||||
id: localesPanel
|
id: localesPanel
|
||||||
!width: 96*3 + 32*3
|
|
||||||
margin-left: 16
|
|
||||||
margin-top: 50
|
margin-top: 50
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
|
|
|
@ -20,8 +20,8 @@ function g_mouse.bindPressMove(widget, callback)
|
||||||
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
|
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
|
||||||
if widget:isPressed() then
|
if widget:isPressed() then
|
||||||
callback(mousePos, mouseMoved)
|
callback(mousePos, mouseMoved)
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
end })
|
end })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue