00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TESTCLIENTFRAMEWORK_H
00024 #define TESTCLIENTFRAMEWORK_H
00025
00026 #include "../Ganef/client/clientframework.h"
00027
00028 #include <iostream>
00029 #include <cstdlib>
00030 #include <stdlib.h>
00031 #include <SDL/SDL.h>
00032 #include <SDL/SDL_ttf.h>
00033
00034
00035 #include "testclientsnakebite.h"
00036 #include <vector>
00037
00038
00039
00040
00041
00042
00043 class TestClientFramework : public ClientFramework
00044 {
00045 private:
00046 SDL_Surface *screen;
00047 SDL_Surface *snakebite;
00048 SDL_Surface *snakehead;
00049 TTF_Font * font;
00050 bool is_running;
00051 std::vector<TestClientSnakeBite *> snakebites;
00052 static TestClientFramework * theclient;
00053 TestClientSnakeBite * my_own_bite;
00054 std::string server_hostname;
00055
00056 private:
00057 void handleUserEvents();
00058 void draw();
00059 void writeToScreen(const std::string & str, int number, int x, int y);
00060 void writeToScreen(const std::string & str, int x, int y);
00061 void paintTestClientSnakeBite(TestClientSnakeBite * bite);
00062
00063 public:
00064 TestClientFramework();
00065 ~TestClientFramework();
00066
00067 public:
00068 void addTestClientSnakeBite(TestClientSnakeBite * bite);
00069 void setServerHost(const char * str) { server_hostname = str; };
00070 void removeSnakeBite(TestClientSnakeBite * bite);
00071
00072 protected:
00073 virtual void writeHandshakeInitMessage(ClientPacket * fp);
00074 virtual void onHandshakingDiscontinue(ClientPacket * fp);
00075 virtual bool onHandshakeDescription(ClientPacket * fp, ClientPacket * reply);
00076 virtual void onDisconnect();
00077 virtual void onConnect();
00078
00079 public:
00080 bool initSDL();
00081 void mainLoop();
00082 static ClientData * constructTestClientSnakeBite(ClientFramework * f, ClientPacket * packet);
00083 };
00084
00085 #endif
00086