Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
NetPassDlg.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: NetPassDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Network Server Password Dialog Active Window class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
NetPassDlg.h
"
17
#include "
MenuScreen.h
"
18
#include "
NetClientConfig.h
"
19
#include "
NetLobby.h
"
20
21
#include "
Game.h
"
22
#include "
DataLoader.h
"
23
#include "
Button.h
"
24
#include "
EditBox.h
"
25
#include "
ListBox.h
"
26
#include "
Slider.h
"
27
#include "
Video.h
"
28
#include "
Keyboard.h
"
29
#include "
Mouse.h
"
30
#include "
ParseUtil.h
"
31
#include "
FormatUtil.h
"
32
33
// +--------------------------------------------------------------------+
34
// DECLARE MAPPING FUNCTIONS:
35
36
DEF_MAP_CLIENT
(
NetPassDlg
, OnApply);
37
DEF_MAP_CLIENT
(
NetPassDlg
, OnCancel);
38
39
// +--------------------------------------------------------------------+
40
41
NetPassDlg::NetPassDlg
(
Screen
* s,
FormDef
& def,
MenuScreen
* mgr)
42
:
FormWindow
(s, 0, 0, s->Width(), s->Height()), manager(mgr),
43
btn_apply(0), btn_cancel(0), edt_pass(0), lbl_name(0)
44
{
45
Init
(def);
46
}
47
48
NetPassDlg::~NetPassDlg
()
49
{
50
}
51
52
// +--------------------------------------------------------------------+
53
54
void
55
NetPassDlg::RegisterControls
()
56
{
57
btn_apply
= (
Button
*)
FindControl
(1);
58
btn_cancel
= (
Button
*)
FindControl
(2);
59
60
REGISTER_CLIENT
(
EID_CLICK
,
btn_apply
,
NetPassDlg
,
OnApply
);
61
REGISTER_CLIENT
(
EID_CLICK
,
btn_cancel
,
NetPassDlg
,
OnCancel
);
62
63
lbl_name
=
FindControl
(110);
64
edt_pass
= (
EditBox
*)
FindControl
(200);
65
66
if
(
edt_pass
)
67
edt_pass
->
SetText
(
""
);
68
}
69
70
// +--------------------------------------------------------------------+
71
72
void
73
NetPassDlg::Show
()
74
{
75
if
(!
IsShown
()) {
76
FormWindow::Show
();
77
78
NetClientConfig
* config =
NetClientConfig::GetInstance
();
79
80
if
(config &&
lbl_name
) {
81
NetServerInfo
* info = config->
GetSelectedServer
();
82
83
if
(info)
84
lbl_name
->
SetText
(info->
name
);
85
}
86
87
if
(
edt_pass
) {
88
edt_pass
->
SetText
(
""
);
89
edt_pass
->
SetFocus
();
90
}
91
}
92
}
93
94
// +--------------------------------------------------------------------+
95
96
static
bool
tab_latch =
false
;
97
98
void
99
NetPassDlg::ExecFrame
()
100
{
101
if
(
Keyboard::KeyDown
(VK_RETURN)) {
102
OnApply
(0);
103
}
104
}
105
106
// +--------------------------------------------------------------------+
107
108
void
109
NetPassDlg::OnApply
(
AWEvent
* event)
110
{
111
NetClientConfig
* config =
NetClientConfig::GetInstance
();
112
113
if
(config &&
edt_pass
) {
114
NetServerInfo
* info = config->
GetSelectedServer
();
115
116
if
(info &&
edt_pass
->
GetText
().
length
() < 250) {
117
char
buffer[256];
118
strcpy_s(buffer,
edt_pass
->
GetText
().
data
());
119
120
// trim from first occurrence of invalid character
121
char
* p = strpbrk(buffer,
"\n\r\t"
);
122
if
(p) *p = 0;
123
124
info->
password
=
SafeQuotes
(buffer);
125
126
if
(
manager
) {
127
manager
->
ShowNetLobbyDlg
();
128
return
;
129
}
130
}
131
}
132
133
if
(
manager
) {
134
manager
->
ShowNetClientDlg
();
135
}
136
}
137
138
void
139
NetPassDlg::OnCancel
(
AWEvent
* event)
140
{
141
if
(
manager
)
142
manager
->
ShowNetClientDlg
();
143
}
Stars45
NetPassDlg.cpp
Generated on Tue Jun 5 2012 20:47:05 for Starshatter_Open by
1.8.1