Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FirstTimeDlg.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: FirstTimeDlg.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 "FirstTimeDlg.h"
17 #include "Player.h"
18 #include "MenuScreen.h"
19 #include "Ship.h"
20 #include "Starshatter.h"
21 #include "KeyMap.h"
22 #include "Random.h"
23 
24 #include "DataLoader.h"
25 #include "Button.h"
26 #include "EditBox.h"
27 #include "ComboBox.h"
28 #include "Video.h"
29 #include "Keyboard.h"
30 #include "MachineInfo.h"
31 
32 // +--------------------------------------------------------------------+
33 // DECLARE MAPPING FUNCTIONS:
34 
36 
37 // +--------------------------------------------------------------------+
38 
40 : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr)
41 {
42  Init(def);
43 }
44 
46 {
47 }
48 
49 // +--------------------------------------------------------------------+
50 
51 void
53 {
54  edt_name = (EditBox*) FindControl(200);
57 
60 }
61 
62 // +--------------------------------------------------------------------+
63 
64 void
66 {
67  if (!IsShown())
69 
70  if (edt_name)
71  edt_name->SetText("Noobie");
72 }
73 
74 // +--------------------------------------------------------------------+
75 
76 void
78 {
79 }
80 
81 // +--------------------------------------------------------------------+
82 
83 void
85 {
87  Player* player = Player::GetCurrentPlayer();
88 
89  if (player) {
90  if (edt_name) {
91  char password[16];
92  sprintf_s(password, "%08x", (DWORD) Random(0, 2e9));
93 
94  player->SetName(edt_name->GetText());
95  player->SetPassword(password);
96  }
97 
98  if (cmb_playstyle) {
99  // ARCADE:
100  if (cmb_playstyle->GetSelectedIndex() == 0) {
101  player->SetFlightModel(2);
102  player->SetLandingModel(1);
103  player->SetHUDMode(0);
104  player->SetGunsight(1);
105 
106  if (stars) {
107  KeyMap& keymap = stars->GetKeyMap();
108 
109  keymap.Bind(KEY_CONTROL_MODEL, 1, 0);
110  keymap.SaveKeyMap("key.cfg", 256);
111 
112  stars->MapKeys();
113  }
114 
116  }
117 
118  // HARDCORE:
119  else {
120  player->SetFlightModel(0);
121  player->SetLandingModel(0);
122  player->SetHUDMode(0);
123  player->SetGunsight(0);
124 
125  if (stars) {
126  KeyMap& keymap = stars->GetKeyMap();
127 
128  keymap.Bind(KEY_CONTROL_MODEL, 0, 0);
129  keymap.SaveKeyMap("key.cfg", 256);
130 
131  stars->MapKeys();
132  }
133 
135  }
136  }
137 
139  player->SetRank(2); // Lieutenant
140  player->SetTrained(255); // Fully Trained
141  }
142 
143  Player::Save();
144  }
145 
146  manager->ShowMenuDlg();
147 }