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

testclient/testclientframework.h

/***************************************************************************
 * The contents of this file are subject to the Mozilla Public             *
 * License Version 1.1 (the "License"); you may not use this file          *
 * except in compliance with the License. You may obtain a copy of         *
 * the License at http://www.mozilla.org/MPL/                              *
 *                                                                         *
 * Software distributed under the License is distributed on an "AS         *
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or              *
 * implied. See the License for the specific language governing            *
 * rights and limitations under the License.                               *
 *                                                                         *
 * The Original Code is Game Network Framework (GaNeF).                    *
 *                                                                         *
 * The Initial Developers of the Original Code are                         *
 * Lars Langer and Emanuel Greisen                                         *
 * Copyright (C) 2005. Lars Langer & Emanuel Greisen                       *
 * All Rights Reserved.                                                    *
 *                                                                         *
 * Contributor(s):                                                         *
 *   none yet....                                                          *
 *                                                                         *
 ***************************************************************************/
#ifndef TESTCLIENTFRAMEWORK_H
#define TESTCLIENTFRAMEWORK_H

#include "../Ganef/client/clientframework.h"

#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>


#include "testclientsnakebite.h"
#include <vector>

/**
 * @cond EXCLUDEDTESTSOURCES
 * This is just a test-client-framework.
 * @author Lars Langer and Emanuel Greisen
 */
class TestClientFramework : public ClientFramework
{
   private:
      SDL_Surface *screen;
      SDL_Surface *snakebite;
      SDL_Surface *snakehead;
      TTF_Font * font;
      bool is_running;
      std::vector<TestClientSnakeBite *> snakebites;
      static TestClientFramework * theclient;
      TestClientSnakeBite * my_own_bite;
      std::string server_hostname;

   private:
      void handleUserEvents();
      void draw();
      void writeToScreen(const std::string & str, int number, int x, int y);
      void writeToScreen(const std::string & str, int x, int y);
      void paintTestClientSnakeBite(TestClientSnakeBite * bite);

   public:
      TestClientFramework();
      ~TestClientFramework();

   public:
      void addTestClientSnakeBite(TestClientSnakeBite * bite);
      void setServerHost(const char * str) { server_hostname = str; };
      void removeSnakeBite(TestClientSnakeBite * bite);

   protected: // These must be implemented in a derived class
      virtual void writeHandshakeInitMessage(ClientPacket * fp); //give first message
      virtual void onHandshakingDiscontinue(ClientPacket * fp); //recieve
      virtual bool onHandshakeDescription(ClientPacket * fp, ClientPacket * reply);
      virtual void onDisconnect();
      virtual void onConnect();

   public:
      bool initSDL();
      void mainLoop();
      static ClientData * constructTestClientSnakeBite(ClientFramework * f, ClientPacket * packet);
};

#endif
/// @endcond

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