00001 /* 00002 * application.h 00003 * 00004 * Copyright (C) 2008,2009 Thomas A. Vaughan 00005 * All rights reserved. 00006 * 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the <organization> nor the 00016 * names of its contributors may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY 00020 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY 00023 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00026 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #ifndef AESOP_APPLICATION_H__ 00032 #define AESOP_APPLICATION_H__ 00033 00034 // includes -------------------------------------------------------------------- 00035 #include "client-game-logic.h" 00036 00037 #include "aesop-clib/aesop-client.h" 00038 #include "gamepad/gamepad.h" 00039 #include "glut/glut.h" 00040 #include "story/story.h" 00041 00042 00043 // forward declarations 00044 class Datahash; 00045 00046 00047 namespace aesop { 00048 00049 /// \ingroup aesop_client_lib 00050 /// \defgroup glut_app AESOP Glut Application 00051 /// 00052 /// \n 00053 /// This is a reference application, using glut for rendering. 00054 /*@{*/ 00055 00056 00057 /// handy for constructing player dialogs 00058 struct player_stats_t { 00059 // constructor, manipulators 00060 player_stats_t(void) throw() { this->clear(); } 00061 void clear(void) throw() { 00062 haveKeyboard = false; 00063 clientState = eClientState_Invalid; 00064 gamepad = NULL; 00065 server = serverInfo = ""; 00066 } 00067 00068 // data fields 00069 bool haveKeyboard; // does player own keyboard? 00070 eClientState clientState; 00071 smart_ptr<gamepad::Gamepad> gamepad; 00072 std::string server; // raw server data 00073 std::string serverInfo; // server info 00074 }; 00075 00076 00077 00078 /// The Application object manages all local terminals (user input/output 00079 /// sessions) as well as communications with the server, and state management 00080 /// for the local host and users. 00081 class Application : public glut::Host { 00082 public: 00083 // virtual destructor -------------------------------------------------- 00084 virtual ~Application(void) throw(); 00085 00086 // aesop::Application class interface methods ------------------------- 00087 virtual story::Story * getStory(void) = 0; 00088 virtual bool getPlayerStats(IN int playerId, 00089 OUT player_stats_t& stats) = 0; 00090 virtual void takeKeyboard(IN int playerId) = 0; 00091 virtual void newGame(IN int playerId) = 0; 00092 virtual void addPlayer(void) = 0; 00093 virtual bool dropPlayer(IN int playerId) = 0; 00094 virtual void configureControls(IN int playerId) = 0; 00095 virtual const server_map_t& getServers(void) = 0; 00096 virtual bool requestConnect(IN const char * serverKey) = 0; 00097 00098 // static factory methods ---------------------------------------------- 00099 static smart_ptr<Application> create(IN const char * config_dir, 00100 IN smart_ptr<Datahash>& params, 00101 IN smart_ptr<ClientGameLogic>& gameLogic, 00102 IN smart_ptr<story::Story>& story); 00103 }; 00104 00105 00106 }; 00107 00108 #endif // AESOP_APPLICATION_H__ 00109