Changeset 365e156 in network-game for client/Client/main.cpp
- Timestamp:
- Jul 21, 2013, 6:25:00 PM (11 years ago)
- Branches:
- master
- Children:
- 49da01a
- Parents:
- 09ddba7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r09ddba7 r365e156 38 38 #include "Button.h" 39 39 #include "RadioButtonList.h" 40 #include "TextLabel.h" 40 41 #include "chat.h" 41 42 … … 87 88 Textbox* txtUsername; 88 89 Textbox* txtPassword; 90 TextLabel* lblLoginStatus; 89 91 90 92 // wndRegister … … 92 94 Textbox* txtPasswordRegister; 93 95 RadioButtonList* rblClasses; 96 TextLabel* lblRegisterStatus; 94 97 95 98 // wndMain … … 180 183 WorldMap* gameMap = WorldMap::loadMapFromFile("../../data/map.txt"); 181 184 185 cout << "Loaded map" << endl; 186 182 187 wndLogin = new Window(0, 0, SCREEN_W, SCREEN_H); 183 188 wndLogin->addComponent(new Textbox(516, 40, 100, 20, font)); 184 189 wndLogin->addComponent(new Textbox(516, 70, 100, 20, font)); 185 wndLogin->addComponent(new Button(330, 100, 194, 20, font, "Create an Account", goToRegisterScreen)); 186 wndLogin->addComponent(new Button(534, 100, 60, 20, font, "Login", login)); 190 wndLogin->addComponent(new TextLabel(410, 40, 100, 20, font, "Username:", ALLEGRO_ALIGN_RIGHT)); 191 wndLogin->addComponent(new TextLabel(410, 70, 100, 20, font, "Password:", ALLEGRO_ALIGN_RIGHT)); 192 wndLogin->addComponent(new TextLabel((SCREEN_W-600)/2, 100, 600, 20, font, "", ALLEGRO_ALIGN_CENTRE)); 193 wndLogin->addComponent(new Button(SCREEN_W/2-100, 130, 90, 20, font, "Register", goToRegisterScreen)); 194 wndLogin->addComponent(new Button(SCREEN_W/2+10, 130, 90, 20, font, "Login", login)); 187 195 wndLogin->addComponent(new Button(920, 10, 80, 20, font, "Quit", quit)); 188 196 189 197 txtUsername = (Textbox*)wndLogin->getComponent(0); 190 198 txtPassword = (Textbox*)wndLogin->getComponent(1); 199 lblLoginStatus = (TextLabel*)wndLogin->getComponent(4); 200 201 cout << "Created login screen" << endl; 191 202 192 203 wndRegister = new Window(0, 0, SCREEN_W, SCREEN_H); 193 204 wndRegister->addComponent(new Textbox(516, 40, 100, 20, font)); 194 205 wndRegister->addComponent(new Textbox(516, 70, 100, 20, font)); 195 wndRegister->addComponent(new Button(468, 100, 56, 20, font, "Back", goToLoginScreen)); 196 wndRegister->addComponent(new Button(534, 100, 70, 20, font, "Submit", registerAccount)); 206 wndRegister->addComponent(new TextLabel(410, 40, 100, 20, font, "Username:", ALLEGRO_ALIGN_RIGHT)); 207 wndRegister->addComponent(new TextLabel(410, 70, 100, 20, font, "Password:", ALLEGRO_ALIGN_RIGHT)); 208 wndRegister->addComponent(new RadioButtonList(432, 100, "Pick a class", font)); 209 wndRegister->addComponent(new TextLabel((SCREEN_W-600)/2, 190, 600, 20, font, "", ALLEGRO_ALIGN_CENTRE)); 210 wndRegister->addComponent(new Button(SCREEN_W/2-100, 220, 90, 20, font, "Back", goToLoginScreen)); 211 wndRegister->addComponent(new Button(SCREEN_W/2+10, 220, 90, 20, font, "Submit", registerAccount)); 197 212 wndRegister->addComponent(new Button(920, 10, 80, 20, font, "Quit", quit)); 198 wndRegister->addComponent(new RadioButtonList(432, 130, "Pick a class", font));199 213 200 214 txtUsernameRegister = (Textbox*)wndRegister->getComponent(0); 201 215 txtPasswordRegister = (Textbox*)wndRegister->getComponent(1); 202 216 203 rblClasses = (RadioButtonList*)wndRegister->getComponent( 5);217 rblClasses = (RadioButtonList*)wndRegister->getComponent(4); 204 218 rblClasses->addRadioButton("Warrior"); 205 219 rblClasses->addRadioButton("Ranger"); 220 221 lblRegisterStatus = (TextLabel*)wndRegister->getComponent(5); 222 223 cout << "Created register screen" << endl; 206 224 207 225 wndMain = new Window(0, 0, SCREEN_W, SCREEN_H); … … 211 229 212 230 txtChat = (Textbox*)wndMain->getComponent(0); 231 232 cout << "Created main screen" << endl; 213 233 214 234 wndCurrent = wndLogin; … … 380 400 // There should be label gui components that show these or each textbox should have a label 381 401 if(wndCurrent == wndLogin || wndCurrent == wndRegister) { 382 al_draw_text(font, al_map_rgb(0, 255, 0), 416, 43, ALLEGRO_ALIGN_LEFT, "Username:");383 al_draw_text(font, al_map_rgb(0, 255, 0), 413, 73, ALLEGRO_ALIGN_LEFT, "Password:");402 //al_draw_text(font, al_map_rgb(0, 255, 0), 416, 43, ALLEGRO_ALIGN_LEFT, "Username:"); 403 //al_draw_text(font, al_map_rgb(0, 255, 0), 413, 73, ALLEGRO_ALIGN_LEFT, "Password:"); 384 404 } 385 405 else if(wndCurrent == wndMain) { … … 541 561 case MSG_TYPE_REGISTER: 542 562 { 563 lblRegisterStatus->setText(response); 543 564 break; 544 565 } … … 549 570 username.clear(); 550 571 cout << "User login failed" << endl; 572 lblLoginStatus->setText(response); 551 573 } 552 574 else if (response.compare("Incorrect username or password") == 0) … … 554 576 username.clear(); 555 577 cout << "User login failed" << endl; 578 lblLoginStatus->setText(response); 556 579 } 557 580 else … … 573 596 break; 574 597 } 575 case MSG_TYPE_PLAYER: // kind of hacky to put this here598 case MSG_TYPE_PLAYER: 576 599 { 577 600 Player p("", ""); … … 592 615 break; 593 616 } 617 default: 618 { 619 cout << "(STATE_REGISTER) Received invlaid message of type " << msg.type << endl; 620 break; 621 } 594 622 } 595 623 … … 600 628 switch(msg.type) 601 629 { 602 case MSG_TYPE_REGISTER:603 {604 break;605 }606 630 case MSG_TYPE_LOGIN: 607 631 { … … 760 784 default: 761 785 { 762 cout << "Received an unexpected message type: " << msg.type << endl; 786 cout << "(STATE_LOGIN) Received invlaid message of type " << msg.type << endl; 787 break; 763 788 } 764 789 }
Note:
See TracChangeset
for help on using the changeset viewer.