~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to CorsixTH/Lua/dialogs/fullscreen/bank_manager.lua

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    palette:setEntry(255, 0xFF, 0x00, 0xFF) -- Make index 255 transparent
33
33
    self.panel_sprites = gfx:loadSpriteTable("QData", "Bank02V", true, palette)
34
34
    self.font = gfx:loadFont("QData", "Font36V", false, palette)
35
 
  
36
 
    -- The statistics font 
 
35
 
 
36
    -- The statistics font
37
37
    palette = gfx:loadPalette("QData", "Stat01V.pal")
38
38
    palette:setEntry(255, 0xFF, 0x00, 0xFF) -- Make index 255 transparent
39
39
    self.stat_font = gfx:loadFont("QData", "Font37V", false, palette)
47
47
  self.browsclk = 0
48
48
  self.smilesclk = 0
49
49
  self.eyesclk = 0
50
 
  
 
50
 
51
51
   -- sprites for the animation
52
52
  self.smiles = self:addPanel(12, 303, 199)
53
53
  self.eyesblink = self:addPanel(7, 298, 173)
54
54
  self.browslift = self:addPanel(9, 296, 165)
55
 
  
 
55
 
56
56
  -- Button so that the user can click in the middle and get the statistics page and
57
57
  -- vice versa
58
58
  self.stat_button = self:addPanel(0, 230, 100)
60
60
  self.return_from_stat_button = self:addPanel(0, 0, 0)
61
61
    :makeButton(0, 0, 640, 440, 0, self.hideStatistics)
62
62
  self.return_from_stat_button.enabled = false
63
 
  
 
63
 
64
64
  -- Buttons
65
65
  -- The close button needs to be movable
66
66
  self.close_panel = self:addPanel(0, 607, 448)
67
67
  self.close_button = self.close_panel:makeButton(0, 0, 26, 26, 4, self.close):setTooltip(_S.tooltip.bank_manager.close)
68
 
  
 
68
 
69
69
  self:addPanel(0, 250, 390):makeButton(0, 0, 200, 50, 0, self.openTownMap):setTooltip(_S.tooltip.toolbar.town_map)
70
70
  self:addPanel(0, 192, 265):makeButton(0, 0, 21, 21, 6, self.increaseLoan):setTooltip(_S.tooltip.bank_manager.borrow_5000)
71
71
  self:addPanel(0, 50, 265):makeButton(0, 0, 21, 21, 5, self.decreaseLoan):setTooltip(_S.tooltip.bank_manager.repay_5000)
72
 
  
 
72
 
73
73
  self.graph_buttons = {
74
74
    self:addPanel(0, 547, 157):makeButton(0, 0, 42, 23, 3, self.showGraph1):setTooltip(_S.tooltip.bank_manager.show_graph:format(self.ui.hospital.insurance[1])),
75
75
    self:addPanel(0, 547, 217):makeButton(0, 0, 42, 23, 3, self.showGraph2):setTooltip(_S.tooltip.bank_manager.show_graph:format(self.ui.hospital.insurance[2])),
76
76
    self:addPanel(0, 547, 277):makeButton(0, 0, 42, 23, 3, self.showGraph3):setTooltip(_S.tooltip.bank_manager.show_graph:format(self.ui.hospital.insurance[3]))
77
77
  }
78
 
  
 
78
 
79
79
  self.graph = self:addPanel(1, 417, 150)
80
 
  
 
80
 
81
81
  self.graph.visible = false
82
82
  self.graph.enabled = false
83
83
  self.return_from_graph_button = self:addPanel(0, 547, 277)
84
84
  self.return_from_graph_button:makeButton(0, 0, 42, 23, 2, self.returnFromGraph):setTooltip(_S.tooltip.bank_manager.graph_return)
85
85
  self.return_from_graph_button.visible = false
86
86
  self.return_from_graph_button.enabled = false
87
 
  
 
87
 
88
88
  self:makeTooltip(_S.tooltip.bank_manager.hospital_value,   60, 105, 203, 157)
89
89
  self:makeTooltip(_S.tooltip.bank_manager.balance,          60, 170, 203, 222)
90
90
  self:makeTooltip(_S.tooltip.bank_manager.current_loan,     60, 235, 203, 287)
91
91
  self:makeTooltip(_S.tooltip.bank_manager.interest_payment, 60, 300, 203, 352)
92
 
  
 
92
 
93
93
  local --[[persistable:insurance_tooltip_template]] function insurance_tooltip(i)
94
94
    return --[[persistable:insurance_tooltip]] function()
95
95
      if not self.graph.visible then
97
97
      end
98
98
    end
99
99
  end
100
 
  
 
100
 
101
101
  self:makeDynamicTooltip(insurance_tooltip(1), 430, 128, 589, 180)
102
102
  self:makeDynamicTooltip(insurance_tooltip(2), 430, 188, 589, 240)
103
103
  self:makeDynamicTooltip(insurance_tooltip(3), 430, 248, 589, 300)
123
123
 
124
124
local function sum(t)
125
125
  local sum = 0
126
 
  for _, entry in ipairs(t) do 
 
126
  for _, entry in ipairs(t) do
127
127
    sum = sum + entry
128
128
  end
129
129
  return sum
138
138
    if self.eyesclk > 2 then
139
139
      self.eyesclk = 0
140
140
      self.eyesblink.sprite_index = self.eyesblink.sprite_index + 1
141
 
      if self.eyesblink.sprite_index > 8 then 
 
141
      if self.eyesblink.sprite_index > 8 then
142
142
        self.eyesblink.sprite_index = 7
143
143
      end
144
144
    end
160
160
    if self.smilesclk > 3 then
161
161
      self.smilesclk = 0
162
162
      self.smiles.sprite_index = self.smiles.sprite_index + 1
163
 
      if self.smiles.sprite_index > 15 then 
 
163
      if self.smiles.sprite_index > 15 then
164
164
        self.smiles.sprite_index = 12
165
165
      end
166
166
    end
178
178
  -- up and down once
179
179
  elseif self.counter  >= 88 and self.counter < 100 then
180
180
    animateBrows()
181
 
  -- smile 
 
181
  -- smile
182
182
  elseif self.counter  >= 132 and  self.counter < 140 then
183
183
    animateSmile()
184
184
  -- two blinks
200
200
  elseif self.counter  >= 298 and self.counter < 322 then
201
201
    animateBrows()
202
202
  -- two blinks
203
 
  elseif self.counter  >= 340 and self.counter < 352 then 
 
203
  elseif self.counter  >= 340 and self.counter < 352 then
204
204
    animateEyes()
205
205
  end
206
206
  -- reset the animation counter
211
211
 
212
212
function UIBankManager:draw(canvas, x, y)
213
213
  local hospital = self.ui.hospital
214
 
  
 
214
 
215
215
  -- Either draw the statistics page or the normal bank page
216
216
  if self.showingStatistics then
217
217
    local font = self.stat_font
218
218
    self.stat_background:draw(canvas, self.x + x, self.y + y)
219
219
    UIFullscreen.draw(self, canvas, x, y)
220
220
    x, y = self.x + x, self.y + y
221
 
    
 
221
 
222
222
    -- Titles
223
223
    font:draw(canvas, _S.bank_manager.statistics_page.date, x + 44, y + 37, 65, 0)
224
224
    font:draw(canvas, _S.bank_manager.statistics_page.details, x + 125, y + 40, 230, 0)
225
225
    font:draw(canvas, _S.bank_manager.statistics_page.money_out, x + 373, y + 42, 70, 0)
226
226
    font:draw(canvas, _S.bank_manager.statistics_page.money_in, x + 449, y + 41, 70, 0)
227
227
    font:draw(canvas, _S.bank_manager.statistics_page.balance, x + 525, y + 40, 70, 0)
228
 
    
 
228
 
229
229
    -- Each transaction
230
230
    -- A for loop going backwards
231
231
    for no = 1, #hospital.transactions do
240
240
      end
241
241
      font:draw(canvas, "$ " .. values.balance, x + 529, current_y)
242
242
    end
243
 
    
 
243
 
244
244
    -- Summary
245
245
    font:draw(canvas, _S.bank_manager.statistics_page.current_balance, x + 373, y + 420, 140, 0)
246
246
    font:draw(canvas, "$ " .. hospital.balance, x + 526, y + 421, 70, 0)
249
249
    self.background:draw(canvas, self.x + x, self.y + y)
250
250
    UIFullscreen.draw(self, canvas, x, y)
251
251
    x, y = self.x + x, self.y + y
252
 
    
 
252
 
253
253
    -- The left side
254
254
    font:draw(canvas, _S.bank_manager.hospital_value, x + 60, y + 109, 143, 0)
255
255
    font:draw(canvas, "$ " .. hospital.value, x + 60, y + 139, 143, 0)
260
260
    font:draw(canvas, _S.bank_manager.interest_payment, x + 60, y + 305, 143, 0)
261
261
    local interest = math.floor(hospital.loan * hospital.interest_rate / 12)
262
262
    font:draw(canvas, "$ " .. interest, x + 60, y + 334, 143, 0)
263
 
    
 
263
 
264
264
    -- The right side
265
265
    font:draw(canvas, _S.bank_manager.insurance_owed, x + 430, y + 102, 158, 0)
266
266
    if self.graph.visible then
312
312
  self.showingStatistics = true
313
313
  self.return_from_stat_button.enabled = true
314
314
  self.stat_button.enabled = false
315
 
  -- hides the animated parts of the bank manager when viewing the statement  
 
315
  -- hides the animated parts of the bank manager when viewing the statement
316
316
  self.smiles.visible = false
317
317
  self.eyesblink.visible = false
318
 
  self.browslift.visible = false  
 
318
  self.browslift.visible = false
319
319
  -- The close button has been slightly moved.
320
320
  local panel = self.close_panel
321
321
  panel.x = panel.x - 6
339
339
  -- shows the animated parts of the bank manager when viewing the main screen
340
340
  self.smiles.visible = true
341
341
  self.eyesblink.visible = true
342
 
  self.browslift.visible = true  
343
 
  -- resets the animation counter if the screen is switched to the statement and back 
344
 
  self.counter = -1  
 
342
  self.browslift.visible = true
 
343
  -- resets the animation counter if the screen is switched to the statement and back
 
344
  self.counter = -1
345
345
  -- return the close button again
346
346
  local panel = self.close_panel
347
347
  panel.x = panel.x + 6