diff options
author | Aki <please@ignore.pl> | 2022-04-01 21:23:39 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-01 21:23:39 +0200 |
commit | 3c487c5cd69c53d6fea948643c0a76df03516605 (patch) | |
tree | 72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /Stars45/NetServerDlg.cpp | |
parent | 8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff) | |
download | starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2 |
Moved Stars45 to StarsEx
Diffstat (limited to 'Stars45/NetServerDlg.cpp')
-rw-r--r-- | Stars45/NetServerDlg.cpp | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/Stars45/NetServerDlg.cpp b/Stars45/NetServerDlg.cpp deleted file mode 100644 index 1729123..0000000 --- a/Stars45/NetServerDlg.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* Starshatter: The Open Source Project - Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors - Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors - Copyright (c) 1997-2006, Destroyer Studios LLC. - - AUTHOR: John DiCamillo - - - OVERVIEW - ======== - Main Menu Dialog Active Window class -*/ - -#include "NetServerDlg.h" -#include "NetServerConfig.h" -#include "MenuScreen.h" -#include "Starshatter.h" - -#include "NetAddr.h" -#include "HttpClient.h" -#include "HttpServer.h" - -#include "DataLoader.h" -#include "Button.h" -#include "EditBox.h" -#include "ComboBox.h" -#include "Video.h" -#include "Keyboard.h" -#include "MachineInfo.h" - -// +--------------------------------------------------------------------+ -// DECLARE MAPPING FUNCTIONS: - -DEF_MAP_CLIENT(NetServerDlg, OnApply); -DEF_MAP_CLIENT(NetServerDlg, OnCancel); - -// +--------------------------------------------------------------------+ - -NetServerDlg::NetServerDlg(Screen* s, FormDef& def, MenuScreen* mgr) -: FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr) -{ - config = NetServerConfig::GetInstance(); - Init(def); -} - -NetServerDlg::~NetServerDlg() -{ -} - -// +--------------------------------------------------------------------+ - -void -NetServerDlg::RegisterControls() -{ - edt_name = (EditBox*) FindControl(200); - cmb_type = (ComboBox*) FindControl(201); - edt_game_port = (EditBox*) FindControl(202); - edt_admin_port = (EditBox*) FindControl(203); - edt_game_pass = (EditBox*) FindControl(204); - edt_admin_name = (EditBox*) FindControl(205); - edt_admin_pass = (EditBox*) FindControl(206); - - btn_apply = (Button*) FindControl(1); - btn_cancel = (Button*) FindControl(2); - - REGISTER_CLIENT(EID_CLICK, btn_apply, NetServerDlg, OnApply); - REGISTER_CLIENT(EID_CLICK, btn_cancel, NetServerDlg, OnCancel); -} - -// +--------------------------------------------------------------------+ - -void -NetServerDlg::Show() -{ - if (!IsShown()) - FormWindow::Show(); - - NetServerConfig::Initialize(); - config = NetServerConfig::GetInstance(); - - if (config) { - config->Load(); - - char buff[32]; - - if (edt_name) { - edt_name->SetText(config->Name()); - edt_name->SetFocus(); - } - - if (cmb_type) - cmb_type->SetSelection(config->GetGameType()); - - if (edt_game_port) { - sprintf_s(buff, "%d", config->GetLobbyPort()); - edt_game_port->SetText(buff); - } - - if (edt_admin_port) { - sprintf_s(buff, "%d", config->GetAdminPort()); - edt_admin_port->SetText(buff); - } - - if (edt_game_pass) - edt_game_pass->SetText(config->GetGamePass()); - - if (edt_admin_name) - edt_admin_name->SetText(config->GetAdminName()); - - if (edt_admin_pass) - edt_admin_pass->SetText(config->GetAdminPass()); - } -} - -// +--------------------------------------------------------------------+ - -void -NetServerDlg::ExecFrame() -{ -} - -// +--------------------------------------------------------------------+ - -void -NetServerDlg::OnApply(AWEvent* event) -{ - if (config) { - if (edt_name) - config->SetName(edt_name->GetText()); - - if (cmb_type) - config->SetGameType(cmb_type->GetSelectedIndex()); - - if (edt_game_port) { - int port = 0; - sscanf_s(edt_game_port->GetText(), "%d", &port); - config->SetLobbyPort((WORD) port); - config->SetGamePort((WORD) port+1); - } - - if (edt_admin_port) { - int port = 0; - sscanf_s(edt_admin_port->GetText(), "%d", &port); - config->SetAdminPort((WORD) port); - } - - if (edt_game_pass) - config->SetGamePass(edt_game_pass->GetText()); - - if (edt_admin_name) - config->SetAdminName(edt_admin_name->GetText()); - - if (edt_admin_pass) - config->SetAdminPass(edt_admin_pass->GetText()); - - - config->Save(); - } - - Starshatter* stars = Starshatter::GetInstance(); - - if (stars) { - ::Print("\nSTART LOCAL SERVER\n\n"); - stars->SetLobbyMode(Starshatter::NET_LOBBY_SERVER); - manager->ShowNetLobbyDlg(); - } - else { - manager->ShowMenuDlg(); - } -} - -void -NetServerDlg::OnCancel(AWEvent* event) -{ - NetServerConfig::Close(); - manager->ShowNetClientDlg(); -} |