Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NetServerDlg.cpp
Go to the documentation of this file.
1 /* Project Starshatter 5.0
2  Destroyer Studios LLC
3  Copyright © 1997-2007. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: NetServerDlg.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 "NetServerDlg.h"
17 #include "NetServerConfig.h"
18 #include "MenuScreen.h"
19 #include "Starshatter.h"
20 
21 #include "NetAddr.h"
22 #include "HttpClient.h"
23 #include "HttpServer.h"
24 
25 #include "DataLoader.h"
26 #include "Button.h"
27 #include "EditBox.h"
28 #include "ComboBox.h"
29 #include "Video.h"
30 #include "Keyboard.h"
31 #include "MachineInfo.h"
32 
33 // +--------------------------------------------------------------------+
34 // DECLARE MAPPING FUNCTIONS:
35 
37 DEF_MAP_CLIENT(NetServerDlg, OnCancel);
38 
39 // +--------------------------------------------------------------------+
40 
42 : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr)
43 {
45  Init(def);
46 }
47 
49 {
50 }
51 
52 // +--------------------------------------------------------------------+
53 
54 void
56 {
57  edt_name = (EditBox*) FindControl(200);
58  cmb_type = (ComboBox*) FindControl(201);
64 
67 
70 }
71 
72 // +--------------------------------------------------------------------+
73 
74 void
76 {
77  if (!IsShown())
79 
82 
83  if (config) {
84  config->Load();
85 
86  char buff[32];
87 
88  if (edt_name) {
90  edt_name->SetFocus();
91  }
92 
93  if (cmb_type)
95 
96  if (edt_game_port) {
97  sprintf_s(buff, "%d", config->GetLobbyPort());
98  edt_game_port->SetText(buff);
99  }
100 
101  if (edt_admin_port) {
102  sprintf_s(buff, "%d", config->GetAdminPort());
103  edt_admin_port->SetText(buff);
104  }
105 
106  if (edt_game_pass)
108 
109  if (edt_admin_name)
111 
112  if (edt_admin_pass)
114  }
115 }
116 
117 // +--------------------------------------------------------------------+
118 
119 void
121 {
122 }
123 
124 // +--------------------------------------------------------------------+
125 
126 void
128 {
129  if (config) {
130  if (edt_name)
132 
133  if (cmb_type)
135 
136  if (edt_game_port) {
137  int port = 0;
138  sscanf_s(edt_game_port->GetText(), "%d", &port);
139  config->SetLobbyPort((WORD) port);
140  config->SetGamePort((WORD) port+1);
141  }
142 
143  if (edt_admin_port) {
144  int port = 0;
145  sscanf_s(edt_admin_port->GetText(), "%d", &port);
146  config->SetAdminPort((WORD) port);
147  }
148 
149  if (edt_game_pass)
151 
152  if (edt_admin_name)
154 
155  if (edt_admin_pass)
157 
158 
159  config->Save();
160  }
161 
163 
164  if (stars) {
165  ::Print("\nSTART LOCAL SERVER\n\n");
168  }
169  else {
170  manager->ShowMenuDlg();
171  }
172 }
173 
174 void
176 {
179 }