Starshatter_Open
Open source Starshatter engine
 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 
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 
49 {
50 }
51 
52 // +--------------------------------------------------------------------+
53 
54 void
56 {
59 
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
74 {
75  if (!IsShown()) {
77 
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
100 {
101  if (Keyboard::KeyDown(VK_RETURN)) {
102  OnApply(0);
103  }
104 }
105 
106 // +--------------------------------------------------------------------+
107 
108 void
110 {
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) {
128  return;
129  }
130  }
131  }
132 
133  if (manager) {
135  }
136 }
137 
138 void
140 {
141  if (manager)
143 }