FrameworkZ 10.8.3
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
xOverrides.lua
Go to the documentation of this file.
2FrameworkZ.Overrides = FrameworkZ.Foundation:GetModule("Overrides")
3
4function FrameworkZ.Overrides.onChatWindowInit()
5 ISChat.instance:setVisible(false)
6end
7Events.OnChatWindowInit.Add(FrameworkZ.Overrides.onChatWindowInit)
9ConnectToServer.OnConnected = function(self)
10 if not SystemDisabler.getAllowDebugConnections() and getDebug() and not isAdmin() and not isCoopHost() and not SystemDisabler.getOverrideServerConnectDebugCheck() then
11 forceDisconnect()
12 return
13 end
14 connectionManagerLog("connect-state-finish", "lua-connected");
16 self:setVisible(false)
17 if not checkSavePlayerExists() then
18 if not getWorld():getMap() then
19 getWorld():setMap("Muldraugh, KY")
20 end
22 if MainScreen.instance.createWorld then
23 createWorld(getWorld():getWorld())
24 end
26 GameWindow.doRenderEvent(false)
27 forceChangeState(LoadingQueueState.new())
28 else
29 GameWindow.doRenderEvent(false)
30 forceChangeState(LoadingQueueState.new())
31 end
32end
33
34FrameworkZ.Overrides.MainScreen_onMenuItemMouseDownMainMenu = MainScreen.onMenuItemMouseDownMainMenu
35
36function FrameworkZ.Overrides.onMenuItemMouseDownMainMenu(item, x, y)
37 local isoPlayer = getPlayer()
38
39 if item.internal == "EXIT" or item.internal == "QUIT_TO_DESKTOP" then
40 FrameworkZ.Foundation:SendFire(isoPlayer, "FrameworkZ.Foundation.OnTeleportToLimbo", function(data, success)
41 FrameworkZ.Players:Destroy(isoPlayer:getUsername())
42
43 if success then
44 FrameworkZ.Foundation:TeleportToLimbo(isoPlayer)
45 print("[FZ] Player teleported to limbo. Disconnecting now...")
46 else
47 print("[FZ] Failed to teleport player to limbo. Disconnecting anyways...")
48 end
49
51 end)
52 else
54 end
55end
56
57function FrameworkZ.Overrides:OnGameStart()
58 MainScreen.onMenuItemMouseDownMainMenu = FrameworkZ.Overrides.onMenuItemMouseDownMainMenu
59
60 LoadMainScreenPanelInt(true)
61end
62Events.OnGameStart.Remove(LoadMainScreenPanelIngame)
63--Events.OnGameStart.Add(FrameworkZ.Overrides.OnGameStart)
64
66
67function FrameworkZ.Overrides.WordWrapText(text)
68 local maxLineLength = 28
69 local lines = {}
70 local line = ""
71 local lineLength = 0
72 local words = {}
73
74 for word in string.gmatch(text, "%S+") do
75 table.insert(words, word)
76 end
77
78 for i = 1, #words do
79 local word = words[i]
80 local wordLength = string.len(word)
81
82 if lineLength + wordLength <= maxLineLength then
83 line = line .. " " .. word
84 lineLength = lineLength + wordLength
85 else
86 table.insert(lines, line)
87 line = word
88 lineLength = wordLength
89 end
90 end
91
92 table.insert(lines, line)
93
94 return lines
95end
96
97function FrameworkZ.Overrides.DoTooltip(objTooltip, item, panel)
98 local itemData = item:getModData()["FZ_ITM"]
99
100 objTooltip:render()
101
102 local textureWidth, textureHeight = 64, 64
103 local font = objTooltip:getFont()
104 local lineSpace = objTooltip:getLineSpacing()
105 local yOffset = 5
106
107 if itemData then
108 local itemName = itemData.name
109 local itemDescription = itemData.description
110
111 objTooltip:DrawText(font, itemName, 5.0, yOffset, 1.0, 1.0, 0.8, 1.0)
112 objTooltip:adjustWidth(5, itemName)
113 yOffset = yOffset + lineSpace + 5
114
115 local yTextureOffset = textureHeight + 10
116 objTooltip:DrawTextureScaled(item:getTexture(), panel:getWidth() - textureWidth - 15, 5, textureWidth, textureHeight, 0.75)
117
118 local description = FrameworkZ.Overrides.WordWrapText(itemDescription)
119
120 for k, v in pairs(description) do
121 objTooltip:DrawText(font, v, 5, yOffset, 1, 1, 0.8, 1)
122 objTooltip:adjustWidth(5, v)
123 yOffset = yOffset + lineSpace + 2.5
124 end
125
126 if yTextureOffset > yOffset then
127 yOffset = yTextureOffset
128 end
129
130 panel:drawRect(0, yOffset, panel:getWidth(), 1, panel.borderColor.a, panel.borderColor.r, panel.borderColor.g, panel.borderColor.b)
131
132 yOffset = yOffset + 2.5
133 else
134 objTooltip:DrawText(font, item:getDisplayName(), 5.0, yOffset, 1.0, 1.0, 0.8, 1.0)
135 objTooltip:adjustWidth(5, item:getDisplayName())
136 yOffset = yOffset + lineSpace + 5
137
138 local yTextureOffset = textureHeight + 10
139 objTooltip:DrawTextureScaled(item:getTexture(), panel:getWidth() - textureWidth - 15, 5, textureWidth, textureHeight, 0.75)
140
141 --[[
142 local description = FrameworkZ.Overrides.WordWrapText(item:getDescription())
143
144 for k, v in pairs(description) do
145 objTooltip:DrawText(font, v, 5, yOffset, 1, 1, 0.8, 1)
146 objTooltip:adjustWidth(5, v)
147 yOffset = yOffset + lineSpace + 2.5
148 end
149 --]]
150
151 if yTextureOffset > yOffset then
152 yOffset = yTextureOffset
153 end
154
155 panel:drawRect(0, yOffset, panel:getWidth(), 1, panel.borderColor.a, panel.borderColor.r, panel.borderColor.g, panel.borderColor.b)
156
157 yOffset = yOffset + 2.5
158 end
159
160 local layoutTooltip = objTooltip:beginLayout()
161 layoutTooltip:setMinLabelWidth(128)
162 local layout = nil
163
164 if itemData then
165 local itemInstance = FrameworkZ.Items:GetInstance(itemData.instanceID)
166 local itemCustomFields = itemData.customFields
167
168 for k, v in pairs(itemCustomFields) do
169 layout = layoutTooltip:addItem()
170 layout:setLabel(k .. ":", 1, 1, 0.8, 1)
171
172 if type(v) == "boolean" then
173 if v then
174 layout:setValue("Yes", 1, 1, 1, 1)
175 else
176 layout:setValue("No", 1, 1, 1, 1)
177 end
178 else
179 if v.get then
180 local values = v.get(itemInstance)
181
182 if type(values) == "table" then
183 local displayString = ""
184
185 for _, v2 in pairs(values) do
186 displayString = displayString .. tostring(v2) .. "\n"
187 end
188
189 layout:setValue(displayString, 1, 1, 1, 1)
190 else
191 layout:setValue(tostring(v.get(itemInstance)), 1, 1, 1, 1)
192 end
193 else
194 layout:setValue(v, 1, 1, 1, 1)
195 end
196 end
197 end
198 end
199
200 local weightEquipped = item:getCleanString(item:getEquippedWeight())
201 local weightUnequipped = item:getUnequippedWeight()
202 layout = layoutTooltip:addItem()
203 layout:setLabel("Weight (Unequipped):", 1, 1, 0.8, 1)
204
205 if weightUnequipped > 0 and weightUnequipped < 0.01 then
206 weightUnequipped = "<0.01"
207 else
208 weightUnequipped = item:getCleanString(weightUnequipped)
209 end
210
211 if not item:isEquipped() then
212 layout:setValue("*" .. tostring(weightUnequipped) .. "*", 1, 1, 1, 1)
213 else
214 layout:setValue(tostring(weightUnequipped), 1, 1, 1, 1)
215 end
216
217 layout = layoutTooltip:addItem()
218 layout:setLabel("Weight (Equipped):", 1, 1, 0.8, 1)
219
220 if item:isEquipped() then
221 layout:setValue("*" .. tostring(weightEquipped) .. "*", 1, 1, 1, 1)
222 else
223 layout:setValue(tostring(weightEquipped), 1, 1, 1, 1)
224 end
225
226 --[[
227 if not item:IsWeapon() and not item:IsClothing() and not item:IsDrainable() and not string.match(item:getFullType(), "Walkie") then
228 local unequippedWeight = item:getUnequippedWeight()
229
230 if unequippedWeight > 0 and unequippedWeight < 0.01 then
231 unequippedWeight = 0.01
232 end
233
234 layout:setValueRightNoPlus(unequippedWeight)
235 elseif item:isEquipped() then
236 local equippedWeight = item:getCleanString(item:getEquippedWeight())
237
238 layout:setValue(equippedWeight .. " (" .. item:getCleanString(item:getUnequippedWeight()) .. " " .. getText("Tooltip_item_Unequipped") .. ")", 1.0, 1.0, 1.0, 1.0)
239 elseif item:getAttachedSlot() > -1 then
240 local hotbarEquippedWeight = item:getCleanString(item:getHotbarEquippedWeight())
241
242 layout:setValue(hotbarEquippedWeight .. " (" .. item:getCleanString(item:getUnequippedWeight()) .. " " .. getText("Tooltip_item_Unequipped") .. ")", 1.0, 1.0, 1.0, 1.0)
243 else
244 local unequippedWeight = item:getCleanString(item:getUnequippedWeight())
245
246 layout:setValue(unequippedWeight .. " (" .. item:getCleanString(item:getEquippedWeight()) .. " " .. getText("Tooltip_item_Equipped") .. ")", 1.0, 1.0, 1.0, 1.0)
247 end
248 --]]
249
250 if item:getTooltip() ~= nil then
251 layout = layoutTooltip:addItem()
252 layout:setLabel(getText(item:getTooltip()), 1, 1, 0.8, 1)
253 end
254
255 yOffset = layoutTooltip:render(5, yOffset, objTooltip)
256 objTooltip:endLayout(layoutTooltip)
257 yOffset = yOffset + 5
258 objTooltip:setHeight(yOffset)
259
260 if objTooltip:getWidth() < 256 then
261 objTooltip:setWidth(256)
262 end
263end
264
265ISToolTipInv.render = function(self)
266 local mx = getMouseX() + 24
267 local my = getMouseY() + 24
268
269 if not self.followMouse then
270 mx = self:getX()
271 my = self:getY()
272 if self.anchorBottomLeft then
273 mx = self.anchorBottomLeft.x
274 my = self.anchorBottomLeft.y
275 end
276 end
277
278 self.tooltip:setX(mx + 11);
279 self.tooltip:setY(my);
280
281 self.tooltip:setWidth(50)
282 self.tooltip:setMeasureOnly(true)
283
284 if self.item ~= nil and self.tooltip ~= nil then
285 FrameworkZ.Overrides.DoTooltip(self.tooltip, self.item, self);
286 else
287 self.item:DoTooltip(self.tooltip);
288 end
289
290 self.tooltip:setMeasureOnly(false)
291
292 -- clampy x, y
293
294 local myCore = getCore();
295 local maxX = myCore:getScreenWidth();
296 local maxY = myCore:getScreenHeight();
297
298 local tw = self.tooltip:getWidth();
299 local th = self.tooltip:getHeight();
300
301 self.tooltip:setX(math.max(0, math.min(mx + 11, maxX - tw - 1)));
302
303 if not self.followMouse and self.anchorBottomLeft then
304 self.tooltip:setY(math.max(0, math.min(my - th, maxY - th - 1)));
305 else
306 self.tooltip:setY(math.max(0, math.min(my, maxY - th - 1)));
307 end
308
309 self:setX(self.tooltip:getX() - 11);
310 self:setY(self.tooltip:getY());
311 self:setWidth(tw + 11);
312 self:setHeight(th);
313
314 if self.followMouse then
315 self:adjustPositionToAvoidOverlap({
316 x = mx - 24 * 2,
317 y = my - 24 * 2,
318 width = 24 * 2,
319 height = 24 * 2
320 })
321 end
322
324 self:drawRectBorder(0, 0, self.width, self.height, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b);
325
326 if self.item ~= nil and self.tooltip ~= nil then
327 FrameworkZ.Overrides.DoTooltip(self.tooltip, self.item, self);
328 else
329 self.item:DoTooltip(self.tooltip);
330 end
331end
332
void local y()
void local x()
void local yOffset()
void local height()
void local width
void local success
void customFields()
void local instanceID
void description()
void item()
void type()
void local itemInstance()
void local instance()
void local itemData()
void self createCharacterButton font()
void self FrameworkZ UI self nil
Definition MainMenu.lua:95
void self self
Definition MainMenu.lua:89
void local player()
void processingNotification backgroundColor a()
void self textCloseButton internal()
void self playerListPanel render()
void local getMouseY()
void local getMouseX()
void local getTexture()
void button borderColor()
void button backgroundColor()
void local name()
void if type v()
void local Events()
void local data()
void local getPlayer()
void FrameworkZ Foundation()
void isoPlayer()
Foundation for FrameworkZ.
void onMenuItemMouseDownMainMenu(item, x, y)
void DoTooltip(objTooltip, item, panel)
void FrameworkZ Overrides ISToolTipInv_render()
void ConnectToServer OnConnected()
void local word()
void for i()
void self connecting()
void FrameworkZ()
void local wordLength()
void FrameworkZ Overrides()
void FrameworkZ Overrides MainScreen_onMenuItemMouseDownMainMenu()