Fixed mouse bug, allow locales list

This commit is contained in:
Henrique Santiago 2013-02-10 03:24:51 -02:00
parent b1bab32618
commit 8f9055f48b
3 changed files with 13 additions and 4 deletions

View File

@ -17,14 +17,22 @@ end
function createWindow()
localesWindow = g_ui.displayUI('locales')
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
local widget = g_ui.createWidget('LocalesButton', localesPanel)
widget:setImageSource('/images/flags/' .. name .. '')
widget:setText(locale.languageName)
widget.onClick = function() selectFirstLocale(name) end
count = count + 1
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)
end
@ -61,7 +69,7 @@ function init()
pdebug('Using configured locale: ' .. userLocaleName)
else
setLocale(defaultLocaleName)
connect(g_app, {onRun = createWindow})
connect(g_app, { onRun = createWindow })
end
ProtocolGame.registerExtendedOpcode(ExtendedIds.Locale, onExtendedLocales)
@ -73,6 +81,7 @@ function terminate()
currentLocale = nil
ProtocolGame.unregisterExtendedOpcode(ExtendedIds.Locale)
disconnect(g_app, { onRun = createWindow })
disconnect(g_game, { onGameStart = onGameStart })
end
@ -101,6 +110,8 @@ function installLocale(locale)
error('Unable to install locale.')
end
if _G.allowedLocales and not _G.allowedLocales[locale.name] then return end
if locale.name ~= defaultLocaleName then
local updatesNeeded = 0
for _i,k in pairs(neededTranslations) do

View File

@ -24,8 +24,6 @@ UIWindow
Panel
id: localesPanel
!width: 96*3 + 32*3
margin-left: 16
margin-top: 50
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: prev.bottom

View File

@ -20,8 +20,8 @@ function g_mouse.bindPressMove(widget, callback)
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
if widget:isPressed() then
callback(mousePos, mouseMoved)
end
return true
end
end })
end