forked from jk3064/new_widgethandler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.lua
More file actions
110 lines (88 loc) · 3.14 KB
/
Copy pathconfig.lua
File metadata and controls
110 lines (88 loc) · 3.14 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: config.lua
-- brief: configfile for handler.lua
-- author: jK
--
-- Copyright (C) 2011.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--// Config & Widget Locations
ORDER_FILENAME = LUAUI_DIRNAME .. 'Config/' .. Game.modShortName .. '_order.lua'
CONFIG_FILENAME = LUAUI_DIRNAME .. 'Config/' .. Game.modShortName .. '_data.lua'
KNOWN_FILENAME = LUAUI_DIRNAME .. 'Config/' .. Game.modShortName .. '_known.lua'
WIDGET_DIRS = {
LUAUI_DIRNAME .. 'Widgets/';
LUAUI_DIRNAME .. 'SystemWidgets/';
}
--// cache the results of time intensive funcs
include("Utilities/cache.lua", handler.EG)
--// how to handle local widgets
local localWidgetsFirst = true
local localWidgets = true
do
handler:LoadConfigData()
if handler.configData["Local Widgets Config"] then
localWidgetsFirst = handler.configData["Local Widgets Config"].localWidgetsFirst
localWidgets = handler.configData["Local Widgets Config"].localWidgets
end
end
handler.autoUserWidgets = (Spring.GetConfigInt('LuaAutoEnableUserWidgets', 1) ~= 0)
--// reset widget state & data on version changes
do
local ORDER_VERSION = 3
local DATA_VERSION = 2
--FIXME do this on a per widget level!!!
handler:LoadOrderList()
if (handler.orderList.version or ORDER_VERSION) < ORDER_VERSION then
handler.orderList = {}
handler.orderList.version = ORDER_VERSION
table.save(handler.orderList, ORDER_FILENAME, '-- Widget Order List (0 disables a widget)')
end
handler:LoadConfigData()
if (handler.configData.version or DATA_VERSION) < DATA_VERSION then
handler.configData = {}
handler.configData.version = DATA_VERSION
table.save(handler.configData, CONFIG_FILENAME, '-- Widget Custom Data')
end
end
--// VFS Mode
VFSMODE = nil
VFSMODE = localWidgetsFirst and VFS.RAW_FIRST
VFSMODE = VFSMODE or localWidgets and VFS.ZIP_FIRST
VFSMODE = VFSMODE or VFS.ZIP
--// 0: disabled
--// 1: enabled, but can be overriden by widget.GetInfo().unsafe
--// 2: always enabled
SAFEWRAP = 1
SAFEDRAW = false --// requires SAFEWRAP to work
handler.verbose = false
--// ZK related
handler.isStable = Game.modVersion:find("stable",1,true)
function handler:IsStable()
return self.isStable
end
local orig_NewWidget = handler.NewWidget
function handler:NewWidget()
local env = orig_NewWidget(self)
local h = env.widgetHandler
h.isStable = self.IsStable
h.IsStable = self.IsStable
return env
end
local orig_LoadWidgetInfo = handler.LoadWidgetInfo
function handler:LoadWidgetInfo(...)
local wi = orig_LoadWidgetInfo(self, ...)
if (wi) then
--// exprimental widget
--// change name for separate settings and disable by default
if wi.experimental and self.isStable then
wi.name = wi.name .. " (experimental)"
wi.enabled = false
end
end
return wi
end