00001 #ifndef _MM_LOBBY_GS_H_
00002 #define _MM_LOBBY_GS_H_
00003
00004 #include <vector>
00005 #include <string>
00006 #include <iostream>
00007
00008 #include "gamestate.h"
00009 #include "config/Config.h"
00010
00011 #include "net/NetClient.h"
00012 #include "net/NetCallback.h"
00013 #include "net/Player.h"
00014 #include "net/Game.h"
00015 #include "resources/texturemanager.h"
00016 #include "textures.h"
00017
00018 #include "menu/widgets.h"
00019
00020 #include "opengl.h"
00021
00022 using namespace MMNet;
00023
00024 #define LOBBY_GUI_MARGIN 10
00025 #define SLOT_X_PADDING 50
00026 #define BORDER_MARGIN 4
00027 #define TEXTHEIGHT 20
00028
00029 #define SLOT_WIDTH 160
00030 #define SLOT_HEIGHT 200
00031 #define SLOT_MARGIN 10
00032
00033 class PlayerSlot;
00034 class LobbyCallback;
00035
00036 class LobbyGS : public GameState {
00037 public:
00038 LobbyGS(NetClient *client);
00039
00040 void init();
00041 void update();
00042 void exit();
00043 void display();
00044
00045 void setupGame(TNL::U32 seed);
00046
00047 bool allReady();
00048
00049 void displaySlots();
00050 void updateSlots();
00051 void initSlots();
00052
00053 void disableModelButtons();
00054 void enableModelButtons();
00055
00056 private:
00057 void updateModelButtons();
00058
00059 MMGUI::Frame* initModelButtons();
00060
00061 LobbyCallback *callback;
00062
00063 MMGUI::Textfield *charName;
00064
00065 MMGUI::Button *robinButton;
00066 MMGUI::Button *littleJohnButton;
00067 MMGUI::Button *noneButton;
00068 MMGUI::Button *guardButton;
00069 MMGUI::Button *sheriffButton;
00070
00071 MMGUI::Button *lastOver;
00072
00073 MMGUI::Button *exitButton;
00074 MMGUI::Button *readyButton;
00075
00076 PlayerSlot *slots[MAX_PLAYERS];
00077
00078 TNL::U32 seed;
00079
00080 };
00081
00082 class LobbyCallback : public GameCallback {
00083 private:
00084 LobbyGS *parent;
00085
00086 public:
00087 LobbyCallback(LobbyGS *parent) { this->parent = parent; };
00088
00089 void SetupGame(TNL::U32 seed) {
00090 parent->setupGame(seed);
00091 };
00092
00093 void StartGame() { };
00094
00095 void EndGame() { };
00096 };
00097
00098 struct PlayerSlotInfo {
00099 bool valid;
00100 bool ready;
00101 enum Team team;
00102 enum PlayerModel model;
00103 };
00104
00105 class PlayerSlot : public MMGUI::Frame {
00106 private:
00107 Game *game;
00108 int slot;
00109
00110 LobbyGS *parent;
00111
00112 Player *player;
00113
00114 MMGUI::Image *image;
00115 MMGUI::Textfield *nameField;
00116 MMGUI::Textfield *teamField;
00117
00118
00119 PlayerSlotInfo last;
00120
00121 public:
00122
00123 PlayerSlot(Game *game, LobbyGS *parent, int slot, int x, int y);
00124
00125 void clearImage();
00126 void setImage(GLuint texture);
00127
00128 bool isValid();
00129
00130 bool isReady();
00131
00132 bool isLocalPlayer();
00133
00134 bool isPlayer(MMNet::Player *player);
00135
00136 void update();
00137
00138 void clear();
00139
00140 enum PlayerModel getModel() { return last.model; };
00141
00142 private:
00143 void updateColors();
00144 };
00145
00146 #endif
00147