Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AwardDlg.cpp
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: AwardDlg.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Main Menu Dialog Active Window class
13 */
14 
15 #include "MemDebug.h"
16 #include "AwardDlg.h"
17 #include "PlanScreen.h"
18 #include "Starshatter.h"
19 #include "Ship.h"
20 #include "Player.h"
21 #include "Campaign.h"
22 
23 #include "Game.h"
24 #include "DataLoader.h"
25 #include "Button.h"
26 #include "ListBox.h"
27 #include "EditBox.h"
28 #include "ImageBox.h"
29 #include "FormatUtil.h"
30 #include "Video.h"
31 #include "Keyboard.h"
32 #include "Mouse.h"
33 #include "Sound.h"
34 
35 // +--------------------------------------------------------------------+
36 // DECLARE MAPPING FUNCTIONS:
37 
38 DEF_MAP_CLIENT(AwardDlg, OnClose);
39 
40 // +--------------------------------------------------------------------+
41 
43 : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
44 lbl_name(0), lbl_info(0), img_rank(0), btn_close(0), exit_latch(true)
45 {
46  Init(def);
47 }
48 
50 {
51 }
52 
53 // +--------------------------------------------------------------------+
54 
55 void
57 {
58  lbl_name = FindControl(203);
59  lbl_info = FindControl(201);
60  img_rank = (ImageBox*) FindControl(202);
61 
64 }
65 
66 // +--------------------------------------------------------------------+
67 
68 void
70 {
72  ShowPlayer();
73 
74  exit_latch = true;
75 }
76 
77 // +--------------------------------------------------------------------+
78 
79 void
81 {
82  if (Keyboard::KeyDown(VK_RETURN)) {
83  if (!exit_latch)
84  OnClose(0);
85  }
86 
87  else if (Keyboard::KeyDown(VK_ESCAPE)) {
88  if (!exit_latch)
89  OnClose(0);
90  }
91 
92  else {
93  exit_latch = false;
94  }
95 }
96 
97 // +--------------------------------------------------------------------+
98 
99 void
101 {
103 
104  if (p) {
105  if (lbl_name) {
106  lbl_name->SetText(p->AwardName());
107  }
108 
109  if (lbl_info) {
110  lbl_info->SetText(p->AwardDesc());
111  }
112 
113  if (img_rank) {
115  img_rank->Show();
116  }
117 
118  Sound* congrats = p->AwardSound();
119  if (congrats) {
120  congrats->Play();
121  }
122  }
123  else {
124  if (lbl_info) lbl_info->SetText("");
125  if (img_rank) img_rank->Hide();
126  }
127 }
128 
129 // +--------------------------------------------------------------------+
130 
131 void
133 {
134  Player* player = Player::GetCurrentPlayer();
135  if (player)
136  player->ClearShowAward();
137 
139 
140  if (stars) {
141  Mouse::Show(false);
142 
143  Campaign* campaign = Campaign::GetCampaign();
144  if (campaign && campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS)
146  else
148  }
149 
150  else
151  Game::Panic("AwardDlg::OnClose() - Game instance not found");
152 }