jolievivienne

New Header

May 28th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.79 KB | None | 0 0
  1. #ifndef EXISTENCECLIENT_H
  2. #define EXISTENCECLIENT_H
  3.  
  4. //
  5. // Copyright (c) 2008-2014 the Urho3D project.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25.  
  26.  
  27. #define DISPLAYMESH_MUILTIPLECHARACTER 1
  28. #define DISPLAYMESH_SINGLECHARACTER 2
  29.  
  30. #define UIBLANK 0
  31. #define UIMAIN  1
  32.  
  33. #define CHARACTERMAINSCENE          0
  34. #define CHARACTERUISCENE            1
  35.  
  36. #define CAMERAORIENTATIONROTATEYAW 1
  37. #define CAMERAORIENTATIONROTATEPITCH 1
  38.  
  39. #include "../../../Urho3D/Procedural/Rules.h"
  40.  
  41. #include <time.h>
  42.  
  43. #include "../ExistenceApps.h"
  44. #include "../Account.h"
  45. #include "../factions.h"
  46. #include "../Player.h"
  47. #include "../PlayerLevels.h"
  48.  
  49.  
  50. #include "GameStateHandler.h"
  51.  
  52. string ConvertUIntToString(unsigned int val);
  53.  
  54. /// This first example, maintaining tradition, prints a "Hello World" message.
  55. /// Furthermore it shows:
  56. ///     - Using the Sample / Application classes, which initialize the Urho3D engine and run the main loop
  57. ///     - Adding a Text element to the graphical user interface
  58. ///     - Subscribing to and handling of update events
  59. class ExistenceClient : public ExistenceApp
  60. {
  61.     OBJECT(ExistenceClient);
  62.  
  63.  
  64. public:
  65.     /// Construct.
  66.     ExistenceClient(Context* context);
  67.  
  68.     /// Setup after engine initialization and before running the main loop.
  69.     virtual void Start();
  70.  
  71. protected:
  72.     /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.https://github.com/urho3d/Urho3D/tree/master/Source/Samples
  73.     virtual String GetScreenJoystickPatchString() const
  74.     {
  75.         return
  76.             "<patch>"
  77.             "    <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  78.             "        <attribute name=\"Is Visible\" value=\"false\" />"
  79.             "    </add>"
  80.             "</patch>";
  81.     }
  82.  
  83. private:
  84.  
  85.     /// Diaplay login screen
  86.     void SetupScreenViewport(void);
  87.     void SetupScreenUI(void);
  88.  
  89.     /// Subscribe to application-wide logic update events.
  90.     void SubscribeToEvents();
  91.     /// Handle the logic update event.
  92.     void HandleUpdate(StringHash eventType, VariantMap& eventData);
  93.     /// Events Keyboard
  94.     void HandleKeyDown(StringHash eventType, VariantMap& eventData);
  95.  
  96.     void HandleInput(const String& input);
  97.     void eraseScene(void);
  98.  
  99.     void AddLogoViewport(void);
  100.  
  101.     int CreateCursor(void);
  102.  
  103.     void MoveCamera(float timeStep);
  104.     void Print(const String& output);
  105.  
  106.     void HandlePostUpdates(StringHash eventType, VariantMap& eventData);
  107.  
  108.     /// Render related functions
  109.     int LoadCharacterMesh(int mode, String nodename, unsigned int alienrace, unsigned int gender);
  110.     int loadplayerMesh(Node * playermeshNode, int alienrace, int gender,int mode);
  111.  
  112.     /// File related functions
  113.     void LoadAccount(void);
  114.     void SaveAccount(accountinformation account);
  115.     void SavePlayer(bool activeplayer);
  116.     int LoadAccountPlayers(void);
  117.     int LoadPlayer(int player);
  118.     int LoadTemporaryPlayer(int player);
  119.     int GenerateSceneLoadDifferential(const char *filename=NULL);
  120.     int LoadEnvironmentSettings(const char *environment);
  121.  
  122.     /// Console related functions
  123.     void InitializeConsole(void);
  124.     void HandleConsoleCommand(StringHash eventType, VariantMap& eventData);
  125.  
  126.     int ConsoleActionEnvironment(const char * lineinput);
  127.     int ConsoleActionCamera(const char * lineinput);
  128.     int ConsoleActionDebug(const char * lineinput);
  129.     int ConsoleActionCharacter(const char * lineinput);
  130.     int ConsoleActionRenderer(const char * lineinput);
  131.     int ConsoleActionBuild(const char * lineinput);
  132.  
  133.     /// UI Related Functions
  134.     void loadSceneUI(void);
  135.     bool loadHUDFile(const char * filename, const int positionx, const int positiony);
  136.     void loadUIXMLClosePressed(StringHash eventType, VariantMap& eventData);
  137.     bool loadUIXML(int windowtype, const int positionx, const int positiony, int selected);
  138.     void QuickMenuPressed(StringHash eventType, VariantMap& eventData);
  139.     void UpdateUI(float timestep);
  140.     void PlayerWindowUpdateUI(int selected);
  141.     void PlayerWindowHandleDisplaySelection(StringHash eventType, VariantMap& eventData);
  142.     int UpdateUISceneLoader(void);
  143.     void UpdatePlayerInfoBar(void);
  144.     void SceneLoaderHanderPress(StringHash eventType, VariantMap& eventData);
  145.  
  146.     /// Window shared pointers
  147.     SharedPtr<Window> window_;
  148.     SharedPtr<Window> window2_;
  149.  
  150.     /// The UI's root UIElement.
  151.     SharedPtr<UIElement> uiRoot_;
  152.     SharedPtr<Viewport> viewport;
  153.     SharedPtr<RenderPath> effectRenderPath;
  154.  
  155.     /// Remembered drag begin position.
  156.     IntVector2 dragBeginPosition_;
  157.  
  158.     /// Shared pointer for input
  159.     SharedPtr<Input> input_;
  160.  
  161.     /// This is temoporarily the necessary code
  162.     bool accountexist;
  163.  
  164.     /// Shared pointer for a single character
  165.     WeakPtr<Character> character_;
  166.  
  167.     /// Class and variable declation for character/player related information
  168.     Player  TemporaryPlayer;
  169.     Player  * TemporaryAccountPlayerList;
  170.     unsigned int TemporaryAccountPlayerSelected;
  171.     unsigned int TemporaryAccountPlayerListLimit;
  172.  
  173.     /// Class and variable declaration for alien race alliance information
  174.     vector<string> aliensarray;
  175.     vector<string> tempaliensarray;
  176. };
  177.  
  178. /// Login State
  179. class ExistenceClientStateLogin : public ExistenceClient
  180. {
  181.     OBJECT(ExistenceClientStateLogin);
  182. public:
  183.     ExistenceClientStateLogin(Urho3D::Context * context);
  184.     virtual ~ExistenceClientStateLogin();
  185.     virtual void Enter();
  186.     virtual void Exit();
  187.     virtual void OnUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData );
  188. private:
  189.     void LoginUI(bool exist);
  190.     void LoginScreenUINewAccountHandleClosePressed(StringHash eventType, VariantMap& eventData);
  191.     void LoginScreenUILoginHandleClosePressed(StringHash eventType, VariantMap& eventData);
  192. protected:
  193.  
  194. };
  195.  
  196. /// Account State
  197. class ExistenceClientStateAccount: public ExistenceClient
  198. {
  199.     OBJECT(ExistenceClientStateAccount);
  200. public:
  201.     ExistenceClientStateAccount(Urho3D::Context * context);
  202.     virtual ~ ExistenceClientStateAccount();
  203.     virtual void Enter();
  204.     virtual void Exit();
  205.     virtual void OnUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData );
  206. private:
  207.     void CreateAccountScreenUI(void);
  208.     void CreateAccountUIHandleClosePressed(StringHash eventType, VariantMap& eventData);
  209. protected:
  210.  
  211. };
  212.  
  213. /// Main Screen State
  214. class ExistenceClientStateMainScreen: public ExistenceClient
  215. {
  216.     OBJECT(ExistenceClientStateMainScreen);
  217. public:
  218.     ExistenceClientStateMainScreen(Urho3D::Context * context);
  219.     virtual ~ExistenceClientStateMainScreen();
  220.     virtual void Enter();
  221.     virtual void Exit();
  222.     virtual void OnUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData );
  223. private:
  224.     void mainScreenUI(void);
  225.     void MainScreenUIHandleClosePressed(StringHash eventType, VariantMap& eventData);
  226.     void HandleCharacterStartButtonReleased(StringHash eventType, VariantMap& eventData);
  227.     void HandleCharacterSelectedReleased(StringHash eventType, VariantMap& eventData);
  228.     void HandleCharacterSelectedInfoButtonReleased(StringHash eventType, VariantMap& eventData);
  229. protected:
  230.  
  231. };
  232.  
  233. /// Player Create Login State
  234. class ExistenceClientStatePlayer: public ExistenceClient
  235. {
  236.     OBJECT(ExistenceClientStatePlayer);
  237. public:
  238.     ExistenceClientStatePlayer(Urho3D::Context * context);
  239.     virtual ~ExistenceClientStatePlayer();
  240.     virtual void Enter();
  241.     virtual void Exit();
  242.     virtual void OnUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData );
  243. private:
  244.     void CreatePlayerScreenUI(void);
  245.     void HandlerCameraOrientation(StringHash eventType, VariantMap& eventData);
  246.     void CameraOrientationRotateMove (float degrees, int movement);
  247.     void HandleMouseReleased(StringHash eventType, VariantMap& eventData);
  248.     void CreatePlayerUIHandleClosePressed(StringHash eventType, VariantMap& eventData);
  249.     void HandlePersonalitySelectionItemClick(StringHash eventType, VariantMap& eventData);
  250. protected:
  251.  
  252. };
  253.  
  254. /// Main Screen State
  255. class ExistenceClientStateProgress :public ExistenceClient
  256. {
  257.     OBJECT(ExistenceClientStateProgress);
  258. public:
  259.     ExistenceClientStateProgress(Urho3D::Context * context);
  260.     virtual ~ExistenceClientStateProgress();
  261.     virtual void Enter();
  262.     virtual void Exit();
  263.     virtual void OnUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData );
  264. private:
  265.     void ProgressScreenUI(void);
  266.     void ProgressScreenUIHandleClosePressed(StringHash eventType, VariantMap& eventData);
  267.     void CreateCharacter(void);
  268.     void GenerateScene(terrain_rule terrainrule,const char *differentialfilename);
  269.     void loadSceneCreationCreation(const char * lineinput);
  270.     int GenerateSceneBuildWorld(terrain_rule terrainrule);
  271.     void loadDummyScene(void);
  272.     void LoadScene(const int mode, const char * lineinput);
  273. protected:
  274.  
  275. };
  276.  
  277. /// Player Create Login State
  278. class ExistenceClientStateGameMode: public ExistenceClient
  279. {
  280.     OBJECT(ExistenceClientStateGameMode);
  281. public:
  282.     ExistenceClientStateGameMode(Urho3D::Context * context);
  283.     virtual ~ExistenceClientStateGameMode();
  284.     virtual void Enter();
  285.     virtual void Exit();
  286. private:
  287.     void GameMode(void);
  288. protected:
  289.  
  290. };
  291.  
  292.  
  293. /// Miscellanous functions
  294. vector<string> split(const string& s, const string& delim, const bool keep_empty=true);
  295. time_t ConvertStringToTime(const char * buff, time_t timeseed);
  296. string GenerateName(char group, char subgroup);
  297.  
  298. string ConvertUIntToString(unsigned int val);
  299. float cutoff(float inputvalue, float pointmid, float range,bool debug);
  300. float StringToFloat(string buffer);
  301. Vector3 NormalizedToWorld(Image *height, Terrain *terrain, Vector2 normalized);
  302. typedef std::pair<float,float> range ;
  303. bool intersects( range a, range b );
  304. range make_range( float a, float b );
  305.  
  306. #endif
Advertisement
Add Comment
Please, Sign In to add comment