duncan
Mom and Dad were wrong!
|
00001 #ifndef CLIENT_GAMESTATE_H_ 00002 #define CLIENT_GAMESTATE_H_ 00003 00004 #include <ncurses.h> 00005 #include <string> 00006 #include <list> 00007 #include <cstring> 00008 #include <sstream> 00009 #include "inputline.h" 00010 #include "state.h" 00011 #include "input.h" 00012 #include "world.h" 00013 #include "ncwindow.h" 00014 #include "pathfinder.h" 00015 #include "../network/connection.h" 00016 #include "../network/packetlistener.h" 00017 #include "../dl/downloader.h" 00018 #include "../dl/downloadlistener.h" 00019 00020 namespace client { 00021 00031 class GameState : public State, public net::PacketListener, public dl::DownloadListener { 00032 private: 00033 static const size_t kMaxMessages=10; 00034 unsigned int rows_,cols_; 00035 InputLine chat_; 00036 State::Action state_; 00037 std::string ip_, name_; 00038 std::list<std::string> messages_; 00039 bool changed_,chatting_; 00040 NCWindow worldwin_,chatwin_,dlwin_; 00041 00042 dl::Downloader dl_; 00043 00044 std::string next_world_; 00045 net::maphash_t next_hash_; 00046 00047 net::dir_t move_direction_; 00048 00049 World world_; 00050 00051 PathFinder pathfinder_; 00052 00053 net::Connection* con_; 00054 00055 void new_message(const std::string&); 00056 void send_chat(); 00057 void draw_chat(); 00058 void draw_dl(); 00059 00060 bool check_hash(); 00061 00062 void request_change_world(); 00063 00064 void move(net::dir_t, bool); 00065 public: 00066 GameState(); 00067 00068 void resize(unsigned int, unsigned int); 00069 void set_ip(const std::string&); 00070 void set_name(const std::string&); 00071 void set_dim(unsigned int, unsigned int); 00072 void on_packet(net::data_t*, size_t, net::index_t); 00073 void on_connect(net::index_t); 00074 void on_disconnect(net::index_t); 00075 void on_press(unsigned int,bool); 00076 void on_release(unsigned int,bool); 00077 void on_progress(double,double); 00078 void on_push(); 00079 void on_pop(); 00080 void on_active(); 00081 State::Action update(); 00082 void draw(); 00083 }; 00084 00085 } // namespace 00086 00087 #endif