forked from jk3064/new_widgethandler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
69 lines (54 loc) · 2.03 KB
/
Copy pathmain.lua
File metadata and controls
69 lines (54 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: main.lua
-- brief: the entry point from LuaUI
-- author: jK
--
-- Copyright (C) 2011.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
LUA_NAME = Script.GetName()
LUAUI_DIRNAME = Script.GetName() .. "/"
LUAUI_VERSION = Script.GetName() .. " v1.0"
VFS.DEF_MODE = VFS.RAW_FIRST
if (VFS.FileExists("gamedata/lockluaui.txt")) then
VFS.DEF_MODE = VFS.ZIP_FIRST
end
Spring.SendCommands("ctrlpanel " .. LUAUI_DIRNAME .. "ctrlpanel.txt")
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--
-- Load
--
VFS.Include(LUAUI_DIRNAME .. 'utils.lua', nil, VFS.DEF_MODE)
--// contains a simple LayoutButtons()
require "layout.lua" --FIXME make it a widget?
--// Lua-based fonthandler (deprecated)
require "fonts.lua"
--// the widget handler
include "handler.lua"
--// print Lua & LuaUI version
Spring.Echo(LUAUI_VERSION .. " (" .. _VERSION .. ")")
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--
-- Update()
--
activePage = 0
forceLayout = true
--FIXME move to handler or a widget?
function Update()
local currentPage = Spring.GetActivePage()
if (forceLayout or (currentPage ~= activePage)) then
Spring.ForceLayoutUpdate() --for the page number indicator
forceLayout = false
end
activePage = currentPage
fontHandler.Update()
handler:Update()
end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------