@@ -52,6 +52,8 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program,
52
52
mainMessageBox(" Options_Network" , " mainMessageBox" ),
53
53
54
54
labelExternalPort(" Options_Network" , " labelExternalPort" ),
55
+ labelServerBindIpLabel(" Options_Network" , " labelServerBindIpLabel" ),
56
+ labelServerBindIp(" Options_Network" , " labelServerBindIp" ),
55
57
labelServerPortLabel(" Options_Network" , " labelServerPortLabel" ),
56
58
57
59
labelPublishServerExternalPort(" Options_Network" ,
@@ -91,6 +93,7 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program,
91
93
Config &config = Config::getInstance ();
92
94
this ->parentUI = parentUI;
93
95
this ->console .setOnlyChatMessagesInStoredLines (false );
96
+ this ->activeInputLabel = NULL ;
94
97
95
98
int leftLabelStart = 100 ;
96
99
int leftColumnStart = leftLabelStart + 300 ;
@@ -152,8 +155,21 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program,
152
155
extPort = " !!! " + extPort + " !!!" ;
153
156
}
154
157
labelExternalPort.setText (extPort);
158
+ currentLine -= lineOffset;
155
159
160
+ // Server bind IP
161
+ labelServerBindIpLabel.init (currentLabelStart, currentLine);
162
+ labelServerBindIpLabel.setText (lang.getString (" ServerBindIP" ));
163
+
164
+ labelServerBindIp.init (currentColumnStart, currentLine);
165
+ labelServerBindIp.setText (config.getString (" ServerBindAddress" , " " ));
166
+ labelServerBindIp.setFont (CoreData::getInstance ().getMenuFontBig ());
167
+ labelServerBindIp.setFont3D (CoreData::getInstance ().getMenuFontBig3D ());
168
+ labelServerBindIp.setEditable (true );
169
+ labelServerBindIp.setMaxEditWidth (16 );
170
+ labelServerBindIp.setMaxEditRenderWidth (200 );
156
171
currentLine -= lineOffset;
172
+
157
173
// server port
158
174
labelServerPortLabel.init (currentLabelStart, currentLine);
159
175
labelServerPortLabel.setText (lang.getString (" ServerPort" ));
@@ -292,6 +308,7 @@ void MenuStateOptionsNetwork::reloadUI() {
292
308
}
293
309
294
310
labelServerPortLabel.setText (lang.getString (" ServerPort" ));
311
+ labelServerBindIpLabel.setText (lang.getString (" ServerBindAddress" ));
295
312
labelPublishServerExternalPort.setText (
296
313
lang.getString (" PublishServerExternalPort" ));
297
314
labelEnableFTP.setText (lang.getString (" EnableFTP" ));
@@ -347,6 +364,9 @@ void MenuStateOptionsNetwork::mouseClick(int x, int y,
347
364
}
348
365
mainMenu->setState (new MenuStateRoot (program, mainMenu));
349
366
return ;
367
+ } else if (labelServerBindIp.mouseClick (x, y) &&
368
+ (activeInputLabel != &labelServerBindIp)) {
369
+ this ->setActiveInputLabel (&labelServerBindIp);
350
370
} else if (buttonAudioSection.mouseClick (x, y)) {
351
371
soundRenderer.playFx (coreData.getClickSoundA ());
352
372
mainMenu->setState (new MenuStateOptionsSound (
@@ -422,35 +442,29 @@ void MenuStateOptionsNetwork::mouseMove(int x, int y, const MouseState *ms) {
422
442
}
423
443
424
444
// bool MenuStateOptionsNetwork::isInSpecialKeyCaptureEvent() {
425
- // return (activeInputLabel != NULL);
426
- // }
427
- //
428
- // void MenuStateOptionsNetwork::keyDown(SDL_KeyboardEvent key) {
429
- // if (activeInputLabel != NULL) {
430
- // keyDownEditLabel(key, &activeInputLabel);
431
- // }
432
- // }
445
+ // return (activeInputLabel != NULL);
446
+ // }
447
+
448
+ void MenuStateOptionsNetwork::keyDown (SDL_KeyboardEvent key) {
449
+ if (activeInputLabel != NULL ) {
450
+ keyDownEditLabel (key, &activeInputLabel);
451
+ }
452
+ }
433
453
434
454
void MenuStateOptionsNetwork::keyPress (SDL_KeyboardEvent c) {
435
- // if(activeInputLabel != NULL) {
436
- // //printf("[%d]\n",c); fflush(stdout);
437
- // if( &labelPlayerName == activeInputLabel ||
438
- // &labelTransifexUser == activeInputLabel ||
439
- // &labelTransifexPwd == activeInputLabel ||
440
- // &labelTransifexI18N == activeInputLabel) {
441
- // textInputEditLabel(c, &activeInputLabel);
442
- // }
443
- // }
444
- // else {
445
- Config &configKeys = Config::getInstance (
446
- std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
447
- if (isKeyPressed (configKeys.getSDLKey (" SaveGUILayout" ), c) == true ) {
448
- GraphicComponent::saveAllCustomProperties (containerName);
449
- // Lang &lang= Lang::getInstance();
450
- // console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ?
451
- // lang.getString("Yes") : lang.getString("No"))+ "]");
455
+ if (activeInputLabel != NULL ) {
456
+ keyPressEditLabel (c, &activeInputLabel);
457
+ } else {
458
+ Config &configKeys = Config::getInstance (
459
+ std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
460
+ if (isKeyPressed (configKeys.getSDLKey (" SaveGUILayout" ), c) == true ) {
461
+ GraphicComponent::saveAllCustomProperties (containerName);
462
+ // Lang &lang= Lang::getInstance();
463
+ // console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ?
464
+ // lang.getString("Yes") : lang.getString("No"))+ "]");
465
+ }
466
+ // }
452
467
}
453
- // }
454
468
}
455
469
456
470
void MenuStateOptionsNetwork::render () {
@@ -467,6 +481,8 @@ void MenuStateOptionsNetwork::render() {
467
481
renderer.renderButton (&buttonMiscSection);
468
482
renderer.renderButton (&buttonNetworkSettings);
469
483
renderer.renderLabel (&labelServerPortLabel);
484
+ renderer.renderLabel (&labelServerBindIpLabel);
485
+ renderer.renderLabel (&labelServerBindIp);
470
486
renderer.renderLabel (&labelExternalPort);
471
487
renderer.renderLabel (&labelPublishServerExternalPort);
472
488
renderer.renderListBox (&listBoxServerPort);
@@ -498,10 +514,14 @@ void MenuStateOptionsNetwork::render() {
498
514
void MenuStateOptionsNetwork::saveConfig () {
499
515
Config &config = Config::getInstance ();
500
516
Lang &lang = Lang::getInstance ();
501
- setActiveInputLable (NULL );
517
+ this -> setActiveInputLabel (NULL );
502
518
503
519
lang.loadGameStrings (config.getString (" Lang" ));
504
520
521
+ if (labelServerBindIp.getText ().length () >= 0 ) {
522
+ config.setString (" ServerBindAddress" , labelServerBindIp.getText ());
523
+ }
524
+
505
525
config.setString (" PortServer" , listBoxServerPort.getSelectedItem ());
506
526
config.setInt (" FTPServerPort" , config.getInt (" PortServer" ) + 1 );
507
527
config.setBool (" EnableFTPXfer" , checkBoxEnableFTP.getValue ());
@@ -520,7 +540,18 @@ void MenuStateOptionsNetwork::saveConfig() {
520
540
console.addLine (lang.getString (" SettingsSaved" ));
521
541
}
522
542
523
- void MenuStateOptionsNetwork::setActiveInputLable (GraphicLabel *newLable) {}
543
+ bool MenuStateOptionsNetwork::textInput (std::string text) {
544
+ if (activeInputLabel != NULL ) {
545
+ if (&labelServerBindIp == activeInputLabel) {
546
+ return textInputEditLabel (text, &activeInputLabel);
547
+ }
548
+ }
549
+ return false ;
550
+ }
551
+
552
+ void MenuStateOptionsNetwork::setActiveInputLabel (GraphicLabel *newLabel) {
553
+ MenuState::setActiveInputLabel (newLabel, &activeInputLabel);
554
+ }
524
555
525
556
} // namespace Game
526
557
} // namespace Glest
0 commit comments