Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
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
36
DEF_MAP_CLIENT
(
NetServerDlg
, OnApply);
37
DEF_MAP_CLIENT
(
NetServerDlg
, OnCancel);
38
39
// +--------------------------------------------------------------------+
40
41
NetServerDlg::NetServerDlg
(
Screen
* s,
FormDef
& def,
MenuScreen
* mgr)
42
:
FormWindow
(s, 0, 0, s->Width(), s->Height()), manager(mgr)
43
{
44
config
=
NetServerConfig::GetInstance
();
45
Init
(def);
46
}
47
48
NetServerDlg::~NetServerDlg
()
49
{
50
}
51
52
// +--------------------------------------------------------------------+
53
54
void
55
NetServerDlg::RegisterControls
()
56
{
57
edt_name
= (
EditBox
*)
FindControl
(200);
58
cmb_type
= (
ComboBox
*)
FindControl
(201);
59
edt_game_port
= (
EditBox
*)
FindControl
(202);
60
edt_admin_port
= (
EditBox
*)
FindControl
(203);
61
edt_game_pass
= (
EditBox
*)
FindControl
(204);
62
edt_admin_name
= (
EditBox
*)
FindControl
(205);
63
edt_admin_pass
= (
EditBox
*)
FindControl
(206);
64
65
btn_apply
= (
Button
*)
FindControl
(1);
66
btn_cancel
= (
Button
*)
FindControl
(2);
67
68
REGISTER_CLIENT
(
EID_CLICK
,
btn_apply
,
NetServerDlg
,
OnApply
);
69
REGISTER_CLIENT
(
EID_CLICK
,
btn_cancel
,
NetServerDlg
,
OnCancel
);
70
}
71
72
// +--------------------------------------------------------------------+
73
74
void
75
NetServerDlg::Show
()
76
{
77
if
(!
IsShown
())
78
FormWindow::Show
();
79
80
NetServerConfig::Initialize
();
81
config
=
NetServerConfig::GetInstance
();
82
83
if
(
config
) {
84
config
->
Load
();
85
86
char
buff[32];
87
88
if
(
edt_name
) {
89
edt_name
->
SetText
(
config
->
Name
());
90
edt_name
->
SetFocus
();
91
}
92
93
if
(
cmb_type
)
94
cmb_type
->
SetSelection
(
config
->
GetGameType
());
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
)
107
edt_game_pass
->
SetText
(
config
->
GetGamePass
());
108
109
if
(
edt_admin_name
)
110
edt_admin_name
->
SetText
(
config
->
GetAdminName
());
111
112
if
(
edt_admin_pass
)
113
edt_admin_pass
->
SetText
(
config
->
GetAdminPass
());
114
}
115
}
116
117
// +--------------------------------------------------------------------+
118
119
void
120
NetServerDlg::ExecFrame
()
121
{
122
}
123
124
// +--------------------------------------------------------------------+
125
126
void
127
NetServerDlg::OnApply
(
AWEvent
* event)
128
{
129
if
(
config
) {
130
if
(
edt_name
)
131
config
->
SetName
(
edt_name
->
GetText
());
132
133
if
(
cmb_type
)
134
config
->
SetGameType
(
cmb_type
->
GetSelectedIndex
());
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
)
150
config
->
SetGamePass
(
edt_game_pass
->
GetText
());
151
152
if
(
edt_admin_name
)
153
config
->
SetAdminName
(
edt_admin_name
->
GetText
());
154
155
if
(
edt_admin_pass
)
156
config
->
SetAdminPass
(
edt_admin_pass
->
GetText
());
157
158
159
config
->
Save
();
160
}
161
162
Starshatter
* stars =
Starshatter::GetInstance
();
163
164
if
(stars) {
165
::Print
(
"\nSTART LOCAL SERVER\n\n"
);
166
stars->
SetLobbyMode
(
Starshatter::NET_LOBBY_SERVER
);
167
manager
->
ShowNetLobbyDlg
();
168
}
169
else
{
170
manager
->
ShowMenuDlg
();
171
}
172
}
173
174
void
175
NetServerDlg::OnCancel
(
AWEvent
* event)
176
{
177
NetServerConfig::Close
();
178
manager
->
ShowNetClientDlg
();
179
}
Stars45
NetServerDlg.cpp
Generated on Tue Jun 5 2012 20:47:05 for Starshatter_Open by
1.8.1