-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinit.lua
More file actions
160 lines (131 loc) · 5.23 KB
/
init.lua
File metadata and controls
160 lines (131 loc) · 5.23 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
-- _ __ ___
-- | | \ \ / / |
-- | | _____ __ _ _ __ _ \ \ /\ / /| |__ ___ ___ _______
-- | |/ / _ \/ _` | '_ \| | | \ \/ \/ / | '_ \ / _ \/ _ \_ / _ \
-- | < __/ (_| | | | | |_| |\ /\ / | | | | __/ __// / __/
-- |_|\_\___|\__,_|_| |_|\__,_| \/ \/ |_| |_|\___|\___/___\___|
-------------------------------------------------------------------------------------------------------------------------------
-- This mod was created by keanuWheeze from CP2077 Modding Tools Discord.
--
-- You are free to use this mod as long as you follow the following license guidelines:
-- * It may not be uploaded to any other site without my express permission.
-- * Using any code contained herein in another mod requires full credits / asking me.
-- * You may not fork this code and make your own competing version of this mod available for download without my permission.
--
-------------------------------------------------------------------------------------------------------------------------------
local settings = require("modules/utils/settings")
local builder = require("modules/utils/entityBuilder")
local Cron = require("modules/utils/Cron")
local cache = require("modules/utils/cache")
local style = require("modules/ui/style")
local history = require("modules/utils/history")
local input = require("modules/utils/input")
local registry = require("modules/utils/nodeRefRegistry")
local rht = require("modules/utils/rhtPlugin")
local preview = require("modules/utils/previewUtils")
---@class spawner
---@field runtimeData {cetOpen: boolean, inGame: boolean, inMenu: boolean}
---@field baseUI baseUI
---@field player any
spawner = {
player = nil,
runtimeData = {
cetOpen = false,
inGame = false,
inMenu = false
},
e = function(data)
local red = require("modules/utils/redConverter")
config.saveFile("wkit.json", red.redDataToJSON(data))
end,
i = function(data)
local red = require("modules/utils/redConverter")
red.JSONToRedData(config.loadFile("wkit.json"), data)
end,
baseUI = require("modules/ui/baseUI"),
editor = require("modules/utils/editor/editor"),
GameUI = require("modules/utils/GameUI")
}
-- local x = collectgarbage("count")
function spawner:new()
registerForEvent("onInit", function()
self.player = Game.GetPlayer()
settings.load()
cache.load()
cache.generateRecordsList()
self.baseUI.init()
self.baseUI.savedUI.spawner = self
self.baseUI.savedUI.backwardComp()
self.baseUI.savedUI.filter = settings.savedUIFilter
self.baseUI.spawnUI.filter = settings.spawnUIFilter
self.baseUI.spawnUI.loadSpawnData(self)
self.baseUI.spawnUI.favoritesUI.init(self)
self.baseUI.spawnedUI.spawner = self
self.baseUI.spawnedUI.cachePaths()
self.baseUI.spawnedUI.registerHotkeys()
self.baseUI.savedUI.reload()
self.baseUI.exportUI.init(self)
history.spawnedUI = self.baseUI.spawnedUI
registry.init(self)
self.editor.init(self)
rht.init(self)
Game.GetScriptableServiceContainer():GetService("EntityBuilder"):Initialize()
builder.init()
Observe('RadialWheelController', 'OnIsInMenuChanged', function(_, isInMenu)
self.runtimeData.inMenu = isInMenu
end)
self.GameUI.OnSessionStart(function()
self.runtimeData.inGame = true
self.baseUI.spawnedUI.root:setVisible(true, false)
preview.addHUD()
end)
self.GameUI.OnSessionEnd(function()
self.runtimeData.inGame = false
self.baseUI.spawnedUI.root:setVisible(false, false)
preview.elements = {}
end)
self.runtimeData.inGame = not self.GameUI.IsDetached()
if self.runtimeData.inGame then
preview.addHUD()
end
end)
registerForEvent("onUpdate", function (dt)
if not self.editor then return end
if self.runtimeData.inGame and not self.runtimeData.inMenu then
Cron.Update(dt)
end
if self.editor.camera then
self.editor.camera.deltaTime = dt
end
end)
registerForEvent("onShutdown", function ()
if settings.despawnOnReload then
self.baseUI.spawnedUI.root:remove()
end
end)
registerForEvent("onDraw", function()
if not self.editor then return end
style.initialize(true)
self.editor.suspend(self.runtimeData.cetOpen)
if self.runtimeData.cetOpen then
self.editor.onDraw()
self.baseUI.draw(self)
input.update()
else
self.baseUI.spawnUI.hidden()
end
-- if ImGui.Begin("Collect", ImGuiWindowFlags.AlwaysAutoResize) then
-- ImGui.Text("Memory delta: " .. string.format("%.2f", collectgarbage("count") - x) .. " KB")
-- x = collectgarbage("count")
-- ImGui.End()
-- end
end)
registerForEvent("onOverlayOpen", function()
self.runtimeData.cetOpen = true
end)
registerForEvent("onOverlayClose", function()
self.runtimeData.cetOpen = false
end)
return self
end
return spawner:new()