-
Notifications
You must be signed in to change notification settings - Fork 0
/
overrides.lua
93 lines (71 loc) · 1.86 KB
/
overrides.lua
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
local function overrideable(name)
assert(name, "name is nil")
local old = _G[name]
assert(old, "old is nil")
local new = {}
_G[name] = new
core.__pristine_G[name] = new -- Apply to modules, too
setmetatable(new, {
__index = function(t, k)
if not old[k] then
return nil
--return function()
-- error("Missing member " .. k .. " in c-class " .. name)
--end
end
return function(badself, ...)
return old[k](old, ...)
end
end
})
new.old = old
end
-- SoundDevice
overrideable("SoundDevice")
function SoundDevice:events(sb, ...)
return self.old:events(sb, ...) or {}
end
-- PackageManager
overrideable("PackageManager")
function PackageManager:load(name, ...)
--error("aabadsfjlk")
--if name == "packages/game_base_init" then error("hi!") end
log("Loading package " .. name)
if name == "packages/production/editor" then
log("Got it!!")
return
end
--local id = Idstring(name)
--if id:key() == "38d76ada6dbed4fa" or id:key() == "fad4be6dda6ad738" then
-- error(id:key())
--end
return self.old:load(name, ...)
end
-- TODO
PackageManager.editor_load_script_data = PackageManager.script_data
PackageManager:set_streaming_enabled(true)
-- Application
log(tostring(Application))
overrideable("Application")
log(tostring(Application))
function Application:editor()
local dbg = debug.getinfo(2, "fSl")
local res = {
["lib/entry.lua"] = true,
["lib/managers/achievmentmanager.lua"] = true,
["core/lib/units/data/corescriptunitdata.lua"] = true,
["@mods/editor/hooks/coresetup_hook.lua"] = true,
}
if res[dbg.source] then
return res[dbg.source] and znix_editor.editor_enabled
end
--log(json.encode(dbg))
return znix_editor.editor_enabled --false
end
function Application:ews_enabled()
return znix_editor.ews_enabled
end
-- TODO implement this in C
function Application:set_ews_window(win)
-- error("set_ews_window")
end