Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

testclientframework.h

00001 /***************************************************************************
00002  * The contents of this file are subject to the Mozilla Public             *
00003  * License Version 1.1 (the "License"); you may not use this file          *
00004  * except in compliance with the License. You may obtain a copy of         *
00005  * the License at http://www.mozilla.org/MPL/                              *
00006  *                                                                         *
00007  * Software distributed under the License is distributed on an "AS         *
00008  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or              *
00009  * implied. See the License for the specific language governing            *
00010  * rights and limitations under the License.                               *
00011  *                                                                         *
00012  * The Original Code is Game Network Framework (GaNeF).                    *
00013  *                                                                         *
00014  * The Initial Developers of the Original Code are                         *
00015  * Lars Langer and Emanuel Greisen                                         *
00016  * Copyright (C) 2005. Lars Langer & Emanuel Greisen                       *
00017  * All Rights Reserved.                                                    *
00018  *                                                                         *
00019  * Contributor(s):                                                         *
00020  *   none yet....                                                          *
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  * @cond EXCLUDEDTESTSOURCES
00040  * This is just a test-client-framework.
00041  * @author Lars Langer and Emanuel Greisen
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: // These must be implemented in a derived class
00073       virtual void writeHandshakeInitMessage(ClientPacket * fp); //give first message
00074       virtual void onHandshakingDiscontinue(ClientPacket * fp); //recieve
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 /// @endcond

Generated on Mon Feb 6 12:24:50 2006 for Ganef by  doxygen 1.4.4