~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to CorsixTH/Lua/dialogs/bottom_panel.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:
23
23
 
24
24
function UIBottomPanel:UIBottomPanel(ui)
25
25
  self:Window()
26
 
  
 
26
 
27
27
  local app = ui.app
28
28
 
29
29
  self.ui = ui
37
37
  self.date_font = app.gfx:loadFont("QData", "Font16V")
38
38
  self.white_font = app.gfx:loadFont("QData", "Font01V", 0, -2)
39
39
  self.pause_font = app.gfx:loadFont("QData", "Font124V")
40
 
  
 
40
 
41
41
  -- State relating to fax notification messages
42
42
  self.show_animation = true
43
43
  self.factory_counter = 22
44
44
  self.factory_direction = 0
45
45
  self.message_windows = {}
46
46
  self.message_queue = {}
47
 
  
 
47
 
48
48
  self.default_button_sound = "selectx.wav"
49
49
  self.countdown = 0
50
 
  
 
50
 
51
51
  self.bank_button = self:addPanel( 1,   0, 0):makeToggleButton(6, 6, 35, 36, 2, self.dialogBankManager, nil, self.dialogBankStats):setTooltip(_S.tooltip.toolbar.bank_button)
52
52
  self:addPanel( 3,  40, 0) -- Background for balance, rep and date
53
53
  self:addPanel( 4, 206, 0):makeButton(6, 6, 35, 36, 5, self.dialogBuildRoom):setTooltip(_S.tooltip.toolbar.rooms)
61
61
    self:addPanel(13, x, 0)
62
62
  end
63
63
  self:addPanel(14, 627, 0)
64
 
  
 
64
 
65
65
  -- Buttons that are shown instead of the dynamic info bar when hovering over it.
66
66
  local panels = {}
67
67
  local buttons = {}
68
 
  
 
68
 
69
69
  panels[1]  = self:addPanel(15, 364, 0) -- Staff management button
70
70
  buttons[1] = panels[1]:makeToggleButton(6, 6, 35, 36, 16, self.dialogStaffManagement):setTooltip(_S.tooltip.toolbar.staff_list)
71
71
  panels[2]  = self:addPanel(17, 407, 0) -- Town map button
86
86
    end
87
87
  self.additional_panels = panels
88
88
  self.additional_buttons = buttons
89
 
  
 
89
 
90
90
  self:makeTooltip(_S.tooltip.toolbar.balance, 41, 5, 137, 28)
91
91
  self:makeTooltip(_S.tooltip.toolbar.date, 140, 5, 200, 42)
92
92
  self:makeDynamicTooltip(--[[persistable:reputation_tooltip]] function()
103
103
  ui:addKeyHandler("F7", buttons[5], buttons[5].handleClick, "left")    -- status
104
104
  ui:addKeyHandler("F8", buttons[6], buttons[6].handleClick, "left")    -- charts
105
105
  ui:addKeyHandler("F9", buttons[7], buttons[7].handleClick, "left")    -- policy
106
 
  
 
106
 
107
107
  -- "old" keyboard shortcuts for some of the fullscreen windows
108
108
  ui:addKeyHandler("T", buttons[2], buttons[2].handleClick, "left") -- T for town map
109
109
  ui:addKeyHandler("R", buttons[4], buttons[4].handleClick, "left") -- R for research
112
112
    ui:addKeyHandler("C", buttons[3], buttons[3].handleClick, "left") -- C for casebook
113
113
  else
114
114
    ui:addKeyHandler({"shift", "C"}, buttons[3], buttons[3].handleClick, "left") -- Shift + C for casebook
115
 
  end    
 
115
  end
116
116
  ui:addKeyHandler({"shift", "L"}, self, self.openLoad)  -- Shift + L for Load saved game menu
117
117
  ui:addKeyHandler({"shift", "S"}, self, self.openSave)  -- Shift + S for Load create save menu
118
118
  ui:addKeyHandler({"shift", "R"}, self, self.restart)  -- Shift + R for restart the level
119
119
  ui:addKeyHandler({"shift", "Q"}, self, self.quit)  -- Shift + Q quit the game and return to main menu
120
120
  ui:addKeyHandler({"shift", "alt", "S"}, self, self.quickSave)  -- Shift+Alt+S quick save
121
 
  ui:addKeyHandler({"shift", "alt", "L"}, self, self.quickLoad)  -- Shift+Alt+L load last quick save 
122
 
  
 
121
  ui:addKeyHandler({"shift", "alt", "L"}, self, self.quickLoad)  -- Shift+Alt+L load last quick save
 
122
 
123
123
  -- misc. keyhandlers
124
124
  ui:addKeyHandler("M", self, self.openFirstMessage)    -- M for message
125
125
  ui:addKeyHandler("I", self, self.toggleInformation)   -- I for Information when you first build
132
132
 
133
133
function UIBottomPanel:openSave()
134
134
  self.ui:addWindow(UISaveGame(self.ui))
135
 
end  
 
135
end
136
136
 
137
137
function UIBottomPanel:openLoad()
138
138
  self.ui:addWindow(UILoadGame(self.ui, "game"))
139
 
end 
 
139
end
140
140
 
141
141
function UIBottomPanel:quickSave()
142
142
  self.ui.app:quickSave()
144
144
 
145
145
function UIBottomPanel:quickLoad()
146
146
  self.ui.app:quickLoad()
147
 
end 
 
147
end
148
148
 
149
149
function UIBottomPanel:restart()
150
150
  self.ui.app:restart()
151
 
end 
 
151
end
152
152
 
153
153
function UIBottomPanel:quit()
154
 
  self.ui:quit() 
 
154
  self.ui:quit()
155
155
end
156
156
 
157
157
function UIBottomPanel:draw(canvas, x, y)
161
161
  self.money_font:draw(canvas, ("%7i"):format(self.ui.hospital.balance), x + 44, y + 9)
162
162
  local month, day = self.world:getDate()
163
163
  self.date_font:draw(canvas, _S.date_format.daymonth:format(day, month), x + 140, y + 20, 60, 0)
164
 
  
 
164
 
165
165
  -- Draw possible information in the dynamic info bar
166
166
  if not self.additional_panels[1].visible then
167
167
    self:drawDynamicInfo(canvas, x + 364, y)
168
168
  end
169
 
  
 
169
 
170
170
  if self.show_animation then
171
171
    if self.factory_counter >= 1 then
172
172
        self.panel_sprites:draw(canvas, 40, x + 177, y + 1)
173
173
    end
174
 
  
 
174
 
175
175
    if self.factory_counter > 1 and self.factory_counter <= 22 then
176
176
      for dx = 0, self.factory_counter do
177
177
        self.panel_sprites:draw(canvas, 41, x + 179 + dx, y + 1)
178
178
      end
179
179
    end
180
 
  
 
180
 
181
181
    if self.factory_counter == 22 then
182
182
      self.panel_sprites:draw(canvas, 42, x + 201, y + 1)
183
183
    end
184
184
  end
185
 
  
 
185
 
186
186
  self:drawReputationMeter(canvas, x + 55, y + 35)
187
187
end
188
188
 
314
314
-- first performing the necessary animation.
315
315
function UIBottomPanel:showMessage()
316
316
  if self.factory_direction ~= -1 then
317
 
    self.factory_direction = -1 
 
317
    self.factory_direction = -1
318
318
    if self.factory_counter < 0 then
319
319
      -- Factory is already opened so don't wait to show the message
320
320
      self.show_animation = false
372
372
    end
373
373
    table.remove(self.message_windows, index_to_remove)
374
374
  end
375
 
  
 
375
 
376
376
  if not index then
377
377
    index = 1
378
378
  end
413
413
      self.factory_counter = self.factory_counter - 1
414
414
    end
415
415
  end
416
 
  
 
416
 
417
417
  -- The dynamic info bar is there a while longer when hovering an entity has stopped
418
418
  if self.countdown then
419
419
    if self.countdown < 1 then
432
432
      self.countdown = self.countdown - 1
433
433
    end
434
434
  end
435
 
  
 
435
 
436
436
  -- Move an item out of the message queue if there is room
437
437
  if #self.message_windows < 5 and #self.message_queue > 0 then
438
438
    self:showMessage()
439
439
  end
440
 
  
 
440
 
441
441
  Window.onTick(self)
442
442
end
443
443
 
454
454
    self:updateButtonStates()
455
455
    return
456
456
  end
457
 
    
 
457
 
458
458
  if enable then
459
459
    self:addDialog("UIBankManager", stats and "showStatistics")
460
460
  else
723
723
      self.additional_buttons[i] = self.buttons[5 + i]:makeToggle() -- made them toggle buttons
724
724
    end
725
725
    self.bank_button = self.buttons[1]:makeToggle()
726
 
    
 
726
 
727
727
    -- keyboard shortcuts have been added/changed
728
728
    self.ui:addKeyHandler("F1", self.bank_button, self.bank_button.handleClick, "left")  -- bank manager
729
729
    self.ui:addKeyHandler("F2", self.bank_button, self.bank_button.handleClick, "right")  -- bank manager
757
757
    self.ui:addKeyHandler("J", self, self.openJukebox)   -- open the jukebox
758
758
    self.ui:addKeyHandler({"shift", "L"}, self, self.openLoad)  -- Shift + L for Load saved game menu
759
759
    self.ui:addKeyHandler({"shift", "S"}, self, self.openSave)  -- Shift + S for Load create save menu
760
 
    self.ui:addKeyHandler({"shift", "R"}, self, self.restart)  -- Shift + R for restart the level 
761
 
    self.ui:addKeyHandler({"shift", "Q"}, self, self.quit)  -- Shift + Q quit the game and return to main menu    
762
 
  end  
 
760
    self.ui:addKeyHandler({"shift", "R"}, self, self.restart)  -- Shift + R for restart the level
 
761
    self.ui:addKeyHandler({"shift", "Q"}, self, self.quit)  -- Shift + Q quit the game and return to main menu
 
762
  end
763
763
  if old < 82 then
764
764
    self.ui:addKeyHandler({"shift","alt", "S"}, self, self.quickSave)  -- Shift+Alt+S quick save
765
765
    self.ui:addKeyHandler({"shift","alt", "L"}, self, self.quickLoad)  -- Shift+Alt+L load last quick save
766
 
  end    
 
766
  end
767
767
  Window.afterLoad(self, old, new)
768
768
end
769
769