-
Notifications
You must be signed in to change notification settings - Fork 354
/
staff_management.lua
598 lines (538 loc) · 22.3 KB
/
staff_management.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
--[[ Copyright (c) 2009 Edvin "Lego3" Linge
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. --]]
local math_floor = math.floor
--! Staff management screen
class "UIStaffManagement" (UIFullscreen)
---@type UIStaffManagement
local UIStaffManagement = _G["UIStaffManagement"]
function UIStaffManagement:UIStaffManagement(ui)
self:UIFullscreen(ui)
local gfx = ui.app.gfx
if not pcall(function()
self.background = gfx:loadRaw("Staff01V", 640, 480, "QData", "QData", "Staff01V.pal", true)
local palette = gfx:loadPalette("QData", "Staff01V.pal", true)
self.panel_sprites = gfx:loadSpriteTable("QData", "Staff02V", true, palette)
self.title_font = gfx:loadFont("QData", "Font01V", false, palette)
self.face_parts = ui.app.gfx:loadRaw("Face01V", 65, 1350, nil, "Data", "MPalette.dat")
end) then
ui:addWindow(UIInformation(ui, {_S.errors.dialog_missing_graphics}))
self:close()
return
end
local hosp = ui.hospital
self.ui = ui
self.hospital = hosp
-- Order the staff
self:updateStaffList()
self.default_button_sound = "selectx.wav"
-- Close button
self:addPanel(0, 603, 443):makeButton(0, 0, 26, 26, 10, self.close):setTooltip(_S.tooltip.staff_list.close)
-- Top categories
local --[[persistable:staff_management_category]] function category(name)
self:setCategory(name)
end
self.categories = {
self:addPanel(0, 53, 15):makeToggleButton(0, 0, 58, 58, 1, category, "Doctor"):setTooltip(_S.tooltip.staff_list.doctors),
self:addPanel(0, 119, 15):makeToggleButton(0, 0, 58, 58, 1, category, "Nurse"):setTooltip(_S.tooltip.staff_list.nurses),
self:addPanel(0, 185, 15):makeToggleButton(0, 0, 58, 58, 1, category, "Handyman"):setTooltip(_S.tooltip.staff_list.handymen),
self:addPanel(0, 251, 15):makeToggleButton(0, 0, 58, 58, 1, category, "Receptionist"):setTooltip(_S.tooltip.staff_list.receptionists),
}
-- Other buttons
self:addPanel(0, 12, 86):makeButton(0, 0, 31, 74, 2, self.scrollUp):setTooltip(_S.tooltip.staff_list.prev_person)
self:addPanel(0, 12, 274):makeButton(0, 0, 31, 74, 3, self.scrollDown):setTooltip(_S.tooltip.staff_list.next_person)
-- Disable the default sounds on the the following three buttons as their sounds are implemented in the callback.
self:addPanel(0, 319, 372):makeButton(0, 0, 112, 39, 7, self.payBonus):setTooltip(_S.tooltip.staff_list.bonus):setSound()
self:addPanel(0, 319, 418):makeButton(0, 0, 112, 39, 8, self.increaseSalary):setTooltip(_S.tooltip.staff_list.pay_rise):setSound()
self:addPanel(0, 438, 372):makeButton(0, 0, 45, 85, 9, self.fire):setTooltip(_S.tooltip.staff_list.sack):setSound()
-- "Arrow" to show title of doctors
self.arrow = self:addPanel(12, 259, 397)
self.arrow_position = 259
self.arrow.visible = false
-- Scroll bar dot
self.scroll_dot = self:addPanel(11, 21, 168)
self.scroll_dot.visible = false
-- Doctors' skills or progress towards them
self.progress_surgeon = self:addPanel(17, 188, 408)
self.progress_surgeon.visible = false
self.qualified_surgeon = self:addPanel(20, 188, 408):setTooltip(_S.tooltip.staff_list.surgeon)
self.qualified_surgeon.visible = false
self.progress_psychiatrist = self:addPanel(18, 228, 408)
self.progress_psychiatrist.visible = false
self.qualified_psychiatrist = self:addPanel(21, 228, 408):setTooltip(_S.tooltip.staff_list.psychiatrist)
self.qualified_psychiatrist.visible = false
self.progress_researcher = self:addPanel(19, 268, 408)
self.progress_researcher.visible = false
self.qualified_researcher = self:addPanel(22, 268, 408):setTooltip(_S.tooltip.staff_list.researcher)
self.qualified_researcher.visible = false
-- Blankers for each row
local row_blankers = {}
for i = 1, 10 do
row_blankers[i] = self:addColourPanel(50, 55 + i*27, 580, 27, 60, 174, 203)
end
self.row_blankers = row_blankers
-- Extra background for the portrait
self.portrait_back = self:addColourPanel(65, 374, 71, 81, 210, 255, 255)
self.portrait_back.visible = false
-- Doctor skill blankers
self.title_blanker = self:addColourPanel(225, 365, 90, 39, 57, 166, 198)
self.skill_blanker = self:addColourPanel(142, 406, 168, 54, 57, 166, 198)
-- Tooltip regions
self:makeTooltip(_S.tooltip.staff_list.happiness, 321, 51, 421, 75)
self:makeTooltip(_S.tooltip.staff_list.tiredness, 426, 51, 526, 75)
self:makeTooltip(_S.tooltip.staff_list.ability, 530, 51, 629, 75)
self:makeTooltip(_S.tooltip.staff_list.detail, 146, 367, 226, 407)
self:makeTooltip(_S.tooltip.staff_list.view_staff, 495, 371, 583, 458)
self.row_tooltips = {}
for line_num = 1, 10 do
self.row_tooltips[line_num] = {
self:makeTooltip(_S.tooltip.staff_list.salary, 193, 84 + 27 * (line_num - 1), 313, 108 + 27 * (line_num - 1)),
self:makeTooltip(_S.tooltip.staff_list.happiness_2, 321, 84 + 27 * (line_num - 1), 421, 108 + 27 * (line_num - 1)),
self:makeTooltip(_S.tooltip.staff_list.tiredness_2, 425, 84 + 27 * (line_num - 1), 525, 108 + 27 * (line_num - 1)),
self:makeTooltip(_S.tooltip.staff_list.ability_2, 529, 84 + 27 * (line_num - 1), 628, 108 + 27 * (line_num - 1)),
}
end
self.seniority_tooltip =
self:makeTooltip(_S.tooltip.staff_list.doctor_seniority, 230, 367, 310, 407)
self.skills_tooltip =
self:makeTooltip(_S.tooltip.staff_list.skills, 146, 406, 186, 460)
self:setCategory("Doctor")
self:registerKeyHandlers()
end
function UIStaffManagement:registerKeyHandlers()
-- Hotkeys.
self:addKeyHandler("ingame_scroll_left", self.previousCategory)
self:addKeyHandler("ingame_scroll_right", self.nextCategory)
self:addKeyHandler("ingame_scroll_up", self.previousStaff)
self:addKeyHandler("ingame_scroll_down", self.nextStaff)
end
function UIStaffManagement:updateTooltips()
self.seniority_tooltip.enabled = self.category == "Doctor"
self.skills_tooltip.enabled = self.category == "Doctor"
for i, tooltips in ipairs(self.row_tooltips) do
local state = 10 * (self.page - 1) + i <= #self.staff_members[self.category]
for _, tooltip in ipairs(tooltips) do
tooltip.enabled = state
end
end
end
function UIStaffManagement:updateStaffList(staff_member_removed)
local selected_staff
if staff_member_removed then
-- The update was issued because someone was removed from the list, we need to handle this.
selected_staff = self.staff_members[self.category][self.selected_staff]
if self.staff_members[self.category][self.selected_staff] == staff_member_removed then
self.selected_staff = nil
selected_staff = nil
end
end
local hosp = self.hospital
local staff_members = {
Doctor = {},
Nurse = {},
Handyman = {},
Receptionist = {},
}
for _, staff in ipairs(hosp.staff) do
local list = staff_members[staff.profile.humanoid_class]
list[#list + 1] = staff
-- The selected staff might have been moved because someone else was removed from the list.
if selected_staff == staff then
self.selected_staff = #list
end
end
self.staff_members = staff_members
if staff_member_removed then
self:updateTooltips()
-- If we're viewing a page that no longer exists, go back a page
if self.page > math.ceil(#self.staff_members[self.category] / 10) then
self:scrollUp()
end
self:updateScrollDotVisibility()
end
end
function UIStaffManagement:setCategory(name)
self.skill_blanker.visible = name ~= "Doctor"
self.title_blanker.visible = name ~= "Doctor"
self.category = name
for _, btn in ipairs(self.categories) do
local should_be_toggled = btn.on_click_self == name
if btn.toggled ~= should_be_toggled then
btn:toggle()
end
end
self.selected_staff = nil
self.page = 1
self:updateScrollDotVisibility()
self:updateTooltips()
end
-- Function to select given list index in the current category.
-- Includes jumping to correct page.
function UIStaffManagement:selectIndex(idx)
if idx > #self.staff_members[self.category] or idx <= 0 then
return
end
self.page = math.floor((idx - 1) / 10) + 1
self.selected_staff = idx
end
-- Function to select a given staff member.
-- Includes switching to correct category and page.
function UIStaffManagement:selectStaff(staff)
self:setCategory(staff.profile.humanoid_class)
for i, s in ipairs(self.staff_members[self.category]) do
if s == staff then
self:selectIndex(i)
break
end
end
end
function UIStaffManagement:draw(canvas, x, y)
self.background:draw(canvas, self.x + x, self.y + y)
UIFullscreen.draw(self, canvas, x, y)
x, y = self.x + x, self.y + y
local titles = self.title_font
-- Titles
titles:draw(canvas, _S.staff_list.morale, x + 323, y + 31, 95, 0)
titles:draw(canvas, _S.staff_list.tiredness, x + 427, y + 31, 95, 0)
titles:draw(canvas, _S.staff_list.skill, x + 530, y + 31, 95, 0)
-- Number of employees
titles:draw(canvas, #self.staff_members["Doctor"], x + 79, y + 57)
titles:draw(canvas, #self.staff_members["Nurse"], x + 145, y + 57)
titles:draw(canvas, #self.staff_members["Handyman"], x + 211, y + 57)
titles:draw(canvas, #self.staff_members["Receptionist"], x + 277, y + 57)
local total_happiness = 0
local total_fatigue = 0
local total_skill = 0
-- Draw each listing
local staff_list = self.staff_members[self.category]
for i, staff in ipairs(staff_list) do
if not staff then
break
end
-- Morale, tiredness and skill, used to draw the average at the end too.
local happiness_bar_width = 0
if staff:getAttribute("happiness") then
happiness_bar_width = math_floor(staff:getAttribute("happiness") * 40 + 0.5)
total_happiness = total_happiness + staff:getAttribute("happiness")
end
local fatigue_bar_width = 40.5
if staff:getAttribute("fatigue") then
total_fatigue = total_fatigue + staff:getAttribute("fatigue")
fatigue_bar_width = math_floor((1 - staff:getAttribute("fatigue")) * 40 + 0.5)
end
local skill_bar_width = math_floor(staff.profile.skill * 40 + 0.5)
total_skill = total_skill + staff.profile.skill
-- Is this staff member on the visible page? Then draw him/her
if i > (self.page-1)*10 and i <= self.page*10 then
local row_no = i - (self.page-1)*10
self.row_blankers[row_no].visible = false
titles:draw(canvas, row_no + 10*(self.page-1), x + 58, y + 63 + row_no*27)
titles:draw(canvas, staff.profile:getFullName(),
x + 88, y + 63 + row_no*27)
titles:draw(canvas, "$" .. staff.profile.wage, x + 230, y + 63 + row_no*27, 80, 0)
-- Draw the morale, tiredness and skill for this staff member
if happiness_bar_width ~= 0 then
for dx = 0, happiness_bar_width - 1 do
self.panel_sprites:draw(canvas, 16, x + 351 + dx, y + 65 + row_no*27)
end
end
if fatigue_bar_width ~= 0 then
for dx = 0, fatigue_bar_width - 1 do
self.panel_sprites:draw(canvas, 15, x + 456 + dx, y + 65 + row_no*27)
end
end
if skill_bar_width ~= 0 then
for dx = 0, skill_bar_width - 1 do
self.panel_sprites:draw(canvas, 14, x + 559 + dx, y + 65 + row_no*27)
end
end
end
end
-- Make sure the other ones are not visible
for i = #staff_list + 1 - (self.page-1)*10, 10 do
self.row_blankers[i].visible = true
end
-- Draw the average morale, tiredness and skill
if #staff_list ~= 0 then
local happiness_bar_width = math_floor((total_happiness/#staff_list) * 40 + 0.5)
if happiness_bar_width ~= 0 then
for dx = 0, happiness_bar_width - 1 do
self.panel_sprites:draw(canvas, 16, x + 351 + dx, y + 59)
end
end
local fatigue_bar_width = math_floor((1 - (total_fatigue/#staff_list)) * 40 + 0.5)
if fatigue_bar_width ~= 0 then
for dx = 0, fatigue_bar_width - 1 do
self.panel_sprites:draw(canvas, 15, x + 456 + dx, y + 59)
end
end
local skill_bar_width = math_floor((total_skill/#staff_list) * 40 + 0.5)
if skill_bar_width ~= 0 then
for dx = 0, skill_bar_width - 1 do
self.panel_sprites:draw(canvas, 14, x + 559 + dx, y + 59)
end
end
end
-- Reset
self.progress_surgeon.visible = false
self.qualified_surgeon.visible = false
self.progress_psychiatrist.visible = false
self.qualified_psychiatrist.visible = false
self.progress_researcher.visible = false
self.qualified_researcher.visible = false
self.arrow.visible = false
self.portrait_back.visible = false
-- If a staff member is selected, draw picture, skill etc
if self.selected_staff then
local staff = self.staff_members[self.category][self.selected_staff]
local profile = staff.profile
-- Draw the red rectangle TODO: Make a neater function in C?
local red = canvas:mapRGB(221, 83, 0)
local y_pos = self.selected_staff - (self.page - 1)*10
canvas:drawRect(red, x + 49, y + y_pos*27 + 54, 581, 1)
canvas:drawRect(red, x + 49, y + y_pos*27 + 81, 581, 1)
canvas:drawRect(red, x + 49, y + y_pos*27 + 54, 1, 28)
canvas:drawRect(red, x + 630, y + y_pos*27 + 54, 1, 28)
-- Current position in the game world
local px, py = self:getStaffPosition(37, 61)
self.ui.app.map:draw(canvas, px, py, 83, 82, x + 497, y + 373)
-- Portrait
self.portrait_back.visible = true
profile:drawFace(canvas, x + 68, y + 377, self.face_parts)
-- 10 % increase in salary or a bonus:
local max_salary = self.hospital.world.map.level_config.payroll.MaxSalary
local new_salary = math.min(math.floor(profile.wage * 1.1), max_salary)
titles:draw(canvas, "$" .. math_floor(profile.wage*0.1), x + 377, y + 387, 45, 0)
titles:draw(canvas, "$" .. new_salary, x + 377, y + 432, 45, 0)
-- Attention to detail
local attention_bar_width = math_floor(profile.attention_to_detail * 40 + 0.5)
if attention_bar_width ~= 0 then
for dx = 0, attention_bar_width - 1 do
self.panel_sprites:draw(canvas, 13, x + 178 + dx, y + 387)
end
end
-- If it is a doctor, draw skills etc.
if self.category == "Doctor" then
if profile.is_surgeon > 0 then
if profile.is_surgeon >= 1.0 then
self.qualified_surgeon.visible = true
elseif not profile.is_consultant then
self.progress_surgeon.visible = true
self.progress_surgeon:setTooltip(_S.tooltip.staff_list.surgeon_train:format(math_floor(profile.is_surgeon * 100)))
local progress = math_floor(profile.is_surgeon * 23 + 0.5)
for dx = 0, progress - 1 do
self.panel_sprites:draw(canvas, 13, x + 196 + dx, y + 447)
end
end
end
if profile.is_psychiatrist > 0 then
if profile.is_psychiatrist >= 1.0 then
self.qualified_psychiatrist.visible = true
elseif not profile.is_consultant then
self.progress_psychiatrist.visible = true
self.progress_psychiatrist:setTooltip(_S.tooltip.staff_list.psychiatrist_train:format(math_floor(profile.is_psychiatrist * 100)))
local progress = math_floor(profile.is_psychiatrist * 23 + 0.5)
for dx = 0, progress - 1 do
self.panel_sprites:draw(canvas, 13, x + 236 + dx, y + 447)
end
end
end
if profile.is_researcher > 0 then
if profile.is_researcher >= 1.0 then
self.qualified_researcher.visible = true
elseif not profile.is_consultant then
self.progress_researcher.visible = true
self.progress_researcher:setTooltip(_S.tooltip.staff_list.researcher_train:format(math_floor(profile.is_researcher * 100)))
local progress = math_floor(profile.is_researcher * 23 + 0.5)
for dx = 0, progress - 1 do
self.panel_sprites:draw(canvas, 13, x + 276 + dx, y + 447)
end
end
end
-- Draw type of doctor
self.arrow.visible = true
if profile.is_consultant then
self.arrow.x = self.arrow_position + 29
elseif profile.is_junior then
self.arrow.x = self.arrow_position - 23
else
self.arrow.x = self.arrow_position
end
end
end
end
function UIStaffManagement:onMouseDown(code, x, y)
if code == "left" then
if x > 50 and x < 490 then
if y > 82 and y < 351 then
if #self.staff_members[self.category] - (self.page - 1)*10 > math_floor((y - 81)/27) then
self.selected_staff = math_floor((y - 81)/27) + 1 + (self.page - 1)*10
end
end
elseif x > 497 and x < 580 and y > 373 and y < 455 and self.selected_staff then
-- Hit in the view of the staff
local ui = self.ui
ui:scrollMapTo(self:getStaffPosition())
ui:addWindow(UIStaff(ui, self.staff_members[self.category][self.selected_staff]))
self:close()
return false
end
end
return UIFullscreen.onMouseDown(self, code, x, y)
end
function UIStaffManagement:onMouseWheel(x, y)
if not UIFullscreen.onMouseWheel(self, x, y) then
if self:hitTest(self.cursor_x, self.cursor_y) then
if y > 0 then
self:scrollUp()
return true
else
self:scrollDown()
return true
end
end
return false
else
return true
end
end
function UIFullscreen:getStaffPosition(dx, dy)
local staff = self.staff_members[self.category][self.selected_staff]
local x, y = self.ui.app.map:WorldToScreen(staff.tile_x, staff.tile_y)
local px, py = staff.th:getMarker()
return x + px - (dx or 0), y + py - (dy or 0)
end
function UIStaffManagement:previousCategory()
if self.category == "Nurse" then
self:setCategory("Doctor")
elseif self.category == "Handyman" then
self:setCategory("Nurse")
elseif self.category == "Receptionist" then
self:setCategory("Handyman")
end
end
function UIStaffManagement:nextCategory()
if self.category == "Doctor" then
self:setCategory("Nurse")
elseif self.category == "Nurse" then
self:setCategory("Handyman")
elseif self.category == "Handyman" then
self:setCategory("Receptionist")
end
end
function UIStaffManagement:previousStaff()
-- If nothing currently selected, select the last one, otherwise the previous.
if self.selected_staff == nil then
self:selectIndex(#self.staff_members[self.category])
else
self:selectIndex(self.selected_staff - 1)
end
end
function UIStaffManagement:nextStaff()
-- If nothing currently selected, select the first one, otherwise the next.
if self.selected_staff == nil then
self:selectIndex(1)
else
self:selectIndex(self.selected_staff + 1)
end
end
function UIStaffManagement:scrollUp()
if self.scroll_dot.visible and self.page > 1 then
self.selected_staff = nil
self.page = self.page - 1
self:updateScrollDot()
end
self:updateTooltips()
end
function UIStaffManagement:scrollDown()
if self.scroll_dot.visible and self.page*10 < #self.staff_members[self.category] then
self.selected_staff = nil
self.page = self.page + 1
self:updateScrollDot()
end
self:updateTooltips()
end
--! Updates the position of the paging scroll indicator
function UIStaffManagement:updateScrollDot()
local numPages = math.ceil(#self.staff_members[self.category] / 10)
local yOffset = math_floor(83 * ((self.page - 1) / (numPages - 1)))
self.scroll_dot.y = 168 + yOffset
end
--! Updates whether the paging scroll indicator is visible and its position if visible
function UIStaffManagement:updateScrollDotVisibility()
if #self.staff_members[self.category] > 10 then
self.scroll_dot.visible = true
self:updateScrollDot()
else
self.scroll_dot.visible = false
end
end
function UIStaffManagement:payBonus()
local staff = self.staff_members[self.category][self.selected_staff]
if self.selected_staff and self.hospital.balance > math_floor(staff.profile.wage*0.1) then
staff:changeAttribute("happiness", 0.5)
self.hospital:spendMoney(math_floor(staff.profile.wage*0.1), _S.transactions.personal_bonus)
self.ui:playSound("cashreg.wav")
return
end
self.ui:playSound("wrong2.wav")
end
function UIStaffManagement:increaseSalary()
if self.selected_staff then
local staff = self.staff_members[self.category][self.selected_staff]
if staff:increaseWage(math_floor(staff.profile.wage * 0.1)) then
self.ui:playSound("bonusal2.wav")
return
end
end
self.ui:playSound("wrong2.wav")
end
function UIStaffManagement:fire()
if self.selected_staff then
self.ui:playSound(self.default_button_sound)
self.ui:addWindow(UIConfirmDialog(self.ui, false, _S.confirmation.sack_staff, --[[persistable:staff_management_confirm_sack]] function()
local current_category = self.staff_members[self.category]
current_category[self.selected_staff]:fire()
-- Close the staff window if open
local staff_window = self.ui:getWindow(UIStaff)
if staff_window and staff_window.staff == current_category[self.selected_staff] then
staff_window:close()
end
-- Update the staff list
self:updateStaffList(current_category[self.selected_staff])
end)) -- End of confirmation dialog
else
self.ui:playSound("wrong2.wav")
end
end
function UIStaffManagement:close()
UIFullscreen.close(self)
self.ui:getWindow(UIBottomPanel):updateButtonStates()
end
function UIStaffManagement:afterLoad(old, new)
self:registerKeyHandlers()
if old < 175 then
self:close()
end
if old < 179 then
local gfx = TheApp.gfx
self.background = gfx:loadRaw("Staff01V", 640, 480, "QData", "QData", "Staff01V.pal", true)
local palette = gfx:loadPalette("QData", "Staff01V.pal", true)
self.panel_sprites = gfx:loadSpriteTable("QData", "Staff02V", true, palette)
self.title_font = gfx:loadFont("QData", "Font01V", false, palette)
end
UIFullscreen.afterLoad(self, old, new)
end