/* ==================== uiscreen_networksetup.cpp ==================== */ #include "uiscreen_networksetup.h" static const int SLIDER_W = 16; // pixel width of slider bars static const int MARGIN = 14; // margin space between elements static int ID = 200; UIScreen_Network::UIScreen_Network(PG_Widget* parent, const PG_Rect &r) :PG_ThemeWidget(parent, r, "ThemeWidget") { // GENERAL STUPH=====================\/============================ // the bg this->SetBackground("graphics/UI/screen_bm/screen_blotchmaker_bg.png", BKMODE_TILE); // status status_lab = new PG_Label(this, PG_Rect(40, 715, 550, 15), "> Not Connected"); status_lab->LoadThemeStyle("Label", "StatusLabel"); // screen label screen_lab = new PG_Label(this, PG_Rect(212,10,600, 35), "Network Setup"); screen_lab->LoadThemeStyle("Label", "BigLabel"); screen_lab->SetAlignment(1); go_back = new PG_Button(this, ID++, PG_Rect(10,10,150, 25), "<< BACK"); done = new PG_Button(this, ID++, PG_Rect(864,10,150, 25), "DONE >>"); make_server = new PG_Button(this, ID++, PG_Rect(40,115,468, 25), "START NEW SERVER"); join_server = new PG_Button(this, ID++, PG_Rect(517,115,468, 25), "CONNECT TO SERVER"); // callsign callsign_lab = new PG_Label(this, PG_Rect(40, 80, 80, 25), "Call Sign: "); callsign_lab->LoadThemeStyle("Label", "MedLabel"); callsign = new PG_LineEdit(this, PG_Rect(120,80,100,25), "LineEdit", 20); callsign->SetValidKeys("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_+!@#$%^&*-=.(){}[],./<>?'\\\";: "); // machine stats machine_stats_lab = new PG_Label(this, PG_Rect(240, 80, 744, 25), "Your computer is [SOME IP ADDRESS], known as [somepc.somedomain.com]"); machine_stats_lab->SetAlignment(2); // server pane ----------------------\/----------------------- serverpane = new PG_ThemeWidget(this, PG_Rect(40,160,944,250)); //serverpane->SetBorderSize(1); serverpane->SetTransparency(255); server_setup_lab = new PG_Label(serverpane, PG_Rect(0,0,944,25), "Server Setup"); server_setup_lab->LoadThemeStyle("Label", "BigLabel"); server_setup_lab->SetAlignment(1); accepted_lab = new PG_Label(serverpane, PG_Rect(0,30,467,25), "Accepted Players:"); accepted_lab->LoadThemeStyle("Label", "MedLabel"); accepted_list = new PG_WidgetList(serverpane, PG_Rect(0,55,467,150)); accepted_list->SetBorderSize(3); accepted_list->SetTransparency(255); accepted_remove = new PG_Button(serverpane, ID++, PG_Rect(0,215,150,25), "Remove Checked"); pending_lab = new PG_Label(serverpane, PG_Rect(477,30,467,25), "Pending Players:"); pending_lab->LoadThemeStyle("Label", "MedLabel"); pending_list = new PG_WidgetList(serverpane, PG_Rect(477,55,467,150)); pending_list->SetTransparency(255); pending_list->SetBorderSize(3); pending_decline = new PG_Button(serverpane, ID++, PG_Rect(634,215,150,25), "Decline Checked"); pending_accept = new PG_Button(serverpane, ID++, PG_Rect(794,215,150,25), "Accept Checked"); serverpane->Hide(); // server pane ----------------------/\----------------------- // client pane ----------------------\/----------------------- clientpane = new PG_ThemeWidget(this, PG_Rect(40,160,944,250)); //clientpane->SetBorderSize(1); clientpane->SetTransparency(255); clientpane->Hide(); client_setup_lab = new PG_Label(clientpane, PG_Rect(0,0,944,25), "Client Setup"); client_setup_lab->LoadThemeStyle("Label", "BigLabel"); client_setup_lab->SetAlignment(1); // client pane ----------------------/\----------------------- // chat pane ----------------------\/----------------------- chatpane = new PG_ThemeWidget(this, PG_Rect(40,420,944,275)); //chatpane->SetBorderSize(1); chatpane->SetTransparency(255); chat_lab = new PG_Label(chatpane, PG_Rect(0,0,944,25), "Pre-Game Chat"); chat_lab->LoadThemeStyle("Label", "BigLabel"); chat_lab->SetAlignment(1); chat_box = new PG_WidgetList(chatpane, PG_Rect(0,30,944,200)); chat_box->SetBorderSize(3); chat_box->SetTransparency(255); chat_text = new PG_LineEdit(chatpane, PG_Rect(0,250,824,25), "LineEdit", 1024); chat_text->SetValidKeys("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_+!@#$%^&*-=.(){}[],./<>?'\\\";: "); chat_send = new PG_Button(chatpane, ID++, PG_Rect(844,250,100,25), "SEND"); // chat pane ----------------------/\----------------------- // GENERAL STUPH =====================/\============================ /* PG_MaskEdit edit(NULL, PG_Rect(260,0,200,25)); edit.SetMask("###.###.###.###"); edit.SetValidKeys("1234567890"); */ // add some junk to the lists: accepted_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 1\" - 128.23.231.97 - pc.domain.com")); accepted_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 2\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 3\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 4\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 5\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 6\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 7\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 8\" - 128.23.231.97 - pc.domain.com")); pending_list->AddWidget(new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), "\"LEIAVOIA 9\" - 128.23.231.97 - pc.domain.com")); // EVENT WIRING ---------------------\/------------------------------ make_server->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Network::handle_show_serverpane, (void*)make_server); join_server->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Network::handle_show_clientpane, (void*)join_server); accepted_remove->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Network::handle_remove_accepted, (void*)accepted_remove); pending_accept->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Network::handle_accept_pending, (void*)pending_accept); pending_decline->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Network::handle_decline_pending, (void*)pending_decline); // EVENT WIRING ---------------------/\------------------------------ } UIScreen_Network::~UIScreen_Network() { } // EVENTS PARAGUI_CALLBACK(UIScreen_Network::handle_show_serverpane) { clientpane->Hide(); serverpane->Show(); return true; } PARAGUI_CALLBACK(UIScreen_Network::handle_show_clientpane) { serverpane->Hide(); clientpane->Show(); return true; } PARAGUI_CALLBACK(UIScreen_Network::handle_remove_accepted) { // loop through the widget list backwards (to prevent index collapsing) and delete all checked buttons. for (int i = accepted_list->GetWidgetCount()-1; i >= 0; i-- ) { PG_CheckButton* cb; cb = dynamic_cast( accepted_list->FindWidget(i) ); if (cb->GetPressed() == 1) { // TODO: SEND A DECLINED NOTICE TO CLIENT accepted_list->DeleteWidget(cb, 1, 1); } } return true; } PARAGUI_CALLBACK(UIScreen_Network::handle_decline_pending) { // loop through the widget list backwards (to prevent index collapsing) and delete all checked buttons. for (int i = pending_list->GetWidgetCount()-1; i >= 0; i-- ) { PG_CheckButton* cb; cb = dynamic_cast( pending_list->FindWidget(i) ); if (cb->GetPressed() == 1) { // TODO: SEND A DECLINED NOTICE TO CLIENT pending_list->DeleteWidget(cb, 1, 1); } } return true; } PARAGUI_CALLBACK(UIScreen_Network::handle_accept_pending) { // loop through the widget list backwards (to prevent index collapsing) and delete all checked buttons. for (int i = pending_list->GetWidgetCount()-1; i >= 0; i-- ) { PG_CheckButton* cb; cb = dynamic_cast( pending_list->FindWidget(i) ); if (cb->GetPressed() == 1) { // TODO: SEND AN ACCEPTED NOTICE TO CLIENT cb->SetUnpressed(); accepted_list->AddWidget( new PG_CheckButton(NULL, ID++, PG_Rect(0,0,400,25), cb->GetText()) ); pending_list->DeleteWidget(cb, 1, 1); //pending_list->RemoveWidget(cb, 1, 1); accepted_list->Show(); //status_lab->SetText( rm->IntToChar( accepted_list->GetWidgetCount() ).c_str() ); //cb->Show(); } } return true; }