~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to CorsixTH/Lua/dialogs/fullscreen/annual_report.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:
61
61
  -- stand alone dialog since it has (2) sprites in another sprite file?
62
62
  self.state = 2
63
63
  self.default_button_sound = "selectx.wav"
64
 
  
 
64
 
65
65
  -- Close button, in the future different behaviours for different screens though
66
66
  --self.first_close = self:addPanel(0, 609, 449):makeButton(0, 0, 26, 26, 1, self.changePage)
67
67
  self.second_close = self:addPanel(0, 608, 449):makeButton(0, 0, 26, 26, 1, self.close)
68
68
  self:setActive(self.second_close, true)
69
 
  
 
69
 
70
70
  -- Change page buttons for the second and third pages
71
71
  local --[[persistable:annual_report_change_page]] function change() self:changePage(3) end
72
72
  self.second_change = self:addPanel(0, 274, 435):makeButton(0, 0, 91, 42, 3, change)
73
73
  self:setActive(self.second_change, true)
74
 
  
 
74
 
75
75
  self.third_change = self:addPanel(0, 272, 367):makeButton(0, 0, 91, 42, 3, self.changePage)
76
76
  self:setActive(self.third_change, false)
77
 
  
 
77
 
78
78
  -- The plaque showed after the player has clicked on a trophy
79
79
  local plaque = {}
80
80
  plaque[1] = self:addPanel(19, 206, 87)
115
115
  self:checkTrophiesAndAwards(world)
116
116
 
117
117
  -- Get and sort values used on the statistics screen.
118
 
  -- The six categories. The extra tables are used to be able to sort the values. 
 
118
  -- The six categories. The extra tables are used to be able to sort the values.
119
119
    self.money = {}
120
120
    self.money_sort = {}
121
121
    self.visitors = {}
128
128
    self.cures_sort = {}
129
129
    self.value = {}
130
130
    self.value_sort = {}
131
 
    
 
131
 
132
132
    -- TODO: Right now there are no real competitors, they all have initial values.
133
133
    for i, hospital in ipairs(world.hospitals) do
134
134
      self.money[hospital.name] = hospital.balance - hospital.loan
144
144
      self.salary[hospital.name] = hospital.player_salary
145
145
      self.salary_sort[i] = hospital.player_salary
146
146
    end
147
 
    
 
147
 
148
148
    local sort_order = function(a,b) return a>b end
149
149
    table.sort(self.money_sort, sort_order)
150
150
    table.sort(self.visitors_sort, sort_order)
152
152
    table.sort(self.cures_sort, sort_order)
153
153
    table.sort(self.value_sort, sort_order)
154
154
    table.sort(self.salary_sort, sort_order)
155
 
    
 
155
 
156
156
  -- Pause the game to allow the player plenty of time to check all statistics and trophies won
157
157
  if world and world:isCurrentSpeed("Speed Up") then
158
158
    world:setSpeed("Pause")
226
226
      self.rep_amount = self.rep_amount + win_value
227
227
    elseif hosp.value < prices.HospValuePoor then
228
228
      -- added some here so you get odd amounts as in TH!
229
 
      local lose_value = prices.HospValuePenalty * math.random(1, 15)  
 
229
      local lose_value = prices.HospValuePenalty * math.random(1, 15)
230
230
      self:addAward(_S.trophy_room.hosp_value.penalty[1], "reputation", lose_value)
231
231
      self.rep_amount = self.rep_amount + lose_value
232
232
    end
279
279
  if self.rep_amount ~= 0 then
280
280
    hosp:changeReputation("year_end", nil, math.floor(self.rep_amount))
281
281
  end
282
 
end  
283
 
    
 
282
end
 
283
 
284
284
-- A table defining which type of shadow each award should have.
285
285
local award_shadows = {
286
286
  { shadow = 4 },
502
502
function UIAnnualReport:draw(canvas, x, y)
503
503
  self.background:draw(canvas, self.x + x, self.y + y)
504
504
  UIFullscreen.draw(self, canvas, x, y)
505
 
  
 
505
 
506
506
  x, y = self.x + x, self.y + y
507
507
  local font = self.stat_font
508
508
  local world = self.ui.app.world
509
 
    
 
509
 
510
510
  if self.state == 1 then -- Fame screen
511
511
    -- Title and column names
512
512
    font:draw(canvas, _S.high_score.best_scores, x + 220, y + 104, 200, 0)
513
513
    font:draw(canvas, _S.high_score.pos, x + 218, y + 132)
514
514
    font:draw(canvas, _S.high_score.player, x + 260, y + 132)
515
515
    font:draw(canvas, _S.high_score.score, x + 360, y + 132)
516
 
    
 
516
 
517
517
    -- Players and their score
518
518
    local i = 1
519
519
    local dy = 0
562
562
 
563
563
  local font = self.stat_font
564
564
  local world = self.ui.app.world
565
 
  
 
565
 
566
566
  -- Draw titles
567
 
  font:draw(canvas, _S.menu.charts .. " " 
 
567
  font:draw(canvas, _S.menu.charts .. " "
568
568
  .. (world.year + 1999), x + 210, y + 30, 200, 0)
569
569
  font:draw(canvas, _S.high_score.categories.money, x + 140, y + 98, 170, 0)
570
570
  font:draw(canvas, _S.high_score.categories.salary, x + 328, y + 98, 170, 0)
572
572
  font:draw(canvas, _S.high_score.categories.deaths, x + 328, y + 205, 170, 0)
573
573
  font:draw(canvas, _S.high_score.categories.visitors, x + 140, y + 310, 170, 0)
574
574
  font:draw(canvas, _S.high_score.categories.total_value, x + 328, y + 310, 170, 0)
575
 
  
 
575
 
576
576
  -- TODO: Add possibility to right align text.
577
577
 
578
578
  -- Helper function to find where the person is in the array.
603
603
  local dup_value = 0
604
604
  for _, player in ipairs(world.hospitals) do
605
605
    local name = player.name
606
 
    
 
606
 
607
607
    -- Most Money
608
608
    local index, dup_m = getindex(self.money_sort, self.money[name])
609
609
    -- index is the returned value of the sorted place for this player.
610
610
    -- However there might be many players with the same value, so each iteration a
611
611
    -- duplicate has been found, one additional row lower is the right place to be.
612
 
    font:draw(canvas, name:upper(), x + 140, 
 
612
    font:draw(canvas, name:upper(), x + 140,
613
613
      y + row_y + row_dy*(index-1) + row_dy*(dup_money))
614
 
    font:draw(canvas, self.money[name], x + 240, 
 
614
    font:draw(canvas, self.money[name], x + 240,
615
615
      y + row_y + row_dy*(index-1) + row_dy*(dup_money), 70, 0, "right")
616
 
    
 
616
 
617
617
    -- Highest Salary
618
618
    local index, dup_s = getindex(self.salary_sort, self.salary[name])
619
 
    font:draw(canvas, name:upper(), x + 140 + col_x, 
 
619
    font:draw(canvas, name:upper(), x + 140 + col_x,
620
620
      y + row_y + row_dy*(index-1) + row_dy*(dup_salary))
621
 
    font:draw(canvas, self.salary[name], x + 240 + col_x, 
 
621
    font:draw(canvas, self.salary[name], x + 240 + col_x,
622
622
      y + row_y + row_dy*(index-1) + row_dy*(dup_salary), 70, 0, "right")
623
 
    
 
623
 
624
624
    -- Most Cures
625
625
    local index, dup_c = getindex(self.cures_sort, self.cures[name])
626
 
    font:draw(canvas, name:upper(), x + 140, 
 
626
    font:draw(canvas, name:upper(), x + 140,
627
627
      y + row_y + row_no_y + row_dy*(index-1) + row_dy*(dup_cures))
628
 
    font:draw(canvas, self.cures[name], x + 240, 
 
628
    font:draw(canvas, self.cures[name], x + 240,
629
629
      y + row_y + row_no_y + row_dy*(index-1) + row_dy*(dup_cures), 70, 0, "right")
630
 
    
 
630
 
631
631
    -- Most Deaths
632
632
    local index, dup_d = getindex(self.deaths_sort, self.deaths[name])
633
 
    font:draw(canvas, name:upper(), x + 140 + col_x, 
 
633
    font:draw(canvas, name:upper(), x + 140 + col_x,
634
634
      y + row_y + row_no_y + row_dy*(index-1) + row_dy*(dup_deaths))
635
 
    font:draw(canvas, self.deaths[name], x + 240 + col_x, 
 
635
    font:draw(canvas, self.deaths[name], x + 240 + col_x,
636
636
      y + row_y + row_no_y + row_dy*(index-1) + row_dy*(dup_deaths), 70, 0, "right")
637
 
    
 
637
 
638
638
    -- Most Visitors
639
639
    local index, dup_v = getindex(self.visitors_sort, self.visitors[name])
640
 
    font:draw(canvas, name:upper(), x + 140, 
 
640
    font:draw(canvas, name:upper(), x + 140,
641
641
      y + row_y + row_no_y*2 + row_dy*(index-1) + row_dy*(dup_visitors))
642
 
    font:draw(canvas, self.visitors[name], x + 240, 
 
642
    font:draw(canvas, self.visitors[name], x + 240,
643
643
      y + row_y + row_no_y*2 + row_dy*(index-1) + row_dy*(dup_visitors), 70, 0, "right")
644
 
    
 
644
 
645
645
    -- Highest Value
646
646
    local index, dup_v2 = getindex(self.value_sort, self.value[name])
647
 
    font:draw(canvas, name:upper(), x + 140 + col_x, 
 
647
    font:draw(canvas, name:upper(), x + 140 + col_x,
648
648
      y + row_y + row_no_y*2 + row_dy*(index-1) + row_dy*(dup_value))
649
 
    font:draw(canvas, self.value[name], x + 240 + col_x, 
 
649
    font:draw(canvas, self.value[name], x + 240 + col_x,
650
650
      y + row_y + row_no_y*2 + row_dy*(index-1) + row_dy*(dup_value), 70, 0, "right")
651
 
    
 
651
 
652
652
    if dup_m > 1 then dup_money = dup_money + 1 else dup_money = 0 end
653
653
    if dup_s > 1 then dup_salary = dup_salary + 1 else dup_salary = 0 end
654
654
    if dup_c > 1 then dup_cures = dup_cures + 1 else dup_cures = 0 end