2012-01-05 02:28:29 +01:00
|
|
|
Client = {}
|
2011-12-03 22:41:37 +01:00
|
|
|
|
2012-03-18 14:34:39 +01:00
|
|
|
function Client.reloadScripts()
|
2012-06-26 00:13:30 +02:00
|
|
|
g_modules.reloadModules()
|
2012-06-20 02:15:56 +02:00
|
|
|
dofile '/otclientrc'
|
2012-04-26 21:54:16 +02:00
|
|
|
local message = tr('All modules and scripts were reloaded.')
|
|
|
|
TextMessage.displayEventAdvance(message)
|
|
|
|
print(message)
|
2012-03-18 14:34:39 +01:00
|
|
|
end
|
|
|
|
|
2012-01-17 06:36:25 +01:00
|
|
|
function Client.init()
|
2012-01-06 10:35:48 +01:00
|
|
|
g_window.setMinimumSize({ width = 600, height = 480 })
|
2011-12-30 07:36:10 +01:00
|
|
|
|
2011-12-30 05:50:19 +01:00
|
|
|
-- initialize in fullscreen mode on mobile devices
|
|
|
|
if g_window.getPlatformType() == "X11-EGL" then
|
2011-12-30 07:05:32 +01:00
|
|
|
g_window.setFullscreen(true)
|
2011-12-30 05:50:19 +01:00
|
|
|
else
|
2012-01-06 09:48:59 +01:00
|
|
|
-- window size
|
|
|
|
local size = { width = 800, height = 600 }
|
2012-06-26 00:13:30 +02:00
|
|
|
size = g_settings.getSize('window-size', size)
|
2012-01-03 02:32:34 +01:00
|
|
|
g_window.resize(size)
|
|
|
|
|
2012-01-06 09:48:59 +01:00
|
|
|
-- window position, default is the screen center
|
2012-01-03 02:32:34 +01:00
|
|
|
local displaySize = g_window.getDisplaySize()
|
2012-02-05 23:42:35 +01:00
|
|
|
local defaultPos = { x = (displaySize.width - size.width)/2,
|
|
|
|
y = (displaySize.height - size.height)/2 }
|
2012-06-26 00:13:30 +02:00
|
|
|
local pos = g_settings.getPoint('window-pos', defaultPos)
|
2012-01-03 02:32:34 +01:00
|
|
|
g_window.move(pos)
|
2012-01-06 09:48:59 +01:00
|
|
|
|
|
|
|
-- window maximized?
|
2012-06-26 00:13:30 +02:00
|
|
|
local maximized = g_settings.getBoolean('window-maximized', false)
|
2012-01-06 09:48:59 +01:00
|
|
|
if maximized then g_window.maximize() end
|
2011-12-30 05:50:19 +01:00
|
|
|
end
|
2011-12-30 07:36:10 +01:00
|
|
|
|
2011-12-03 22:41:37 +01:00
|
|
|
g_window.setTitle('OTClient')
|
2012-01-05 02:28:29 +01:00
|
|
|
g_window.setIcon(resolvepath('clienticon.png'))
|
2012-07-05 22:03:41 +02:00
|
|
|
g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts)
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-06-20 02:15:56 +02:00
|
|
|
addEvent(function()
|
2012-03-27 23:33:58 +02:00
|
|
|
scheduleEvent(function()
|
2012-06-19 01:58:56 +02:00
|
|
|
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
2012-06-22 05:14:13 +02:00
|
|
|
--g_sounds.playMusic("startup.ogg", 3)
|
2012-06-19 01:58:56 +02:00
|
|
|
connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
|
|
|
|
connect(g_game, { onGameEnd= function() g_sounds.playMusic("startup.ogg", 3) end })
|
2012-06-20 02:15:56 +02:00
|
|
|
end, 100)
|
2012-03-27 23:33:58 +02:00
|
|
|
end, 0)
|
2012-01-06 10:35:48 +01:00
|
|
|
end
|
|
|
|
|
2011-12-05 19:27:07 +01:00
|
|
|
function Client.terminate()
|
2012-01-17 06:36:25 +01:00
|
|
|
-- save window configs
|
2012-06-26 00:13:30 +02:00
|
|
|
g_settings.set('window-size', g_window.getUnmaximizedSize())
|
|
|
|
g_settings.set('window-pos', g_window.getUnmaximizedPos())
|
|
|
|
g_settings.set('window-maximized', g_window.isMaximized())
|
2012-02-07 01:41:53 +01:00
|
|
|
Client = nil
|
2011-12-03 22:41:37 +01:00
|
|
|
end
|