💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
6.2 KiB

7 years ago
  1. /*
  2. * Copyright (C) 2017 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper Source Code.
  5. *
  6. * Antkeeper Source Code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper Source Code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper Source Code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef APPLICATION_HPP
  20. #define APPLICATION_HPP
  21. #include <emergent/emergent.hpp>
  22. using namespace Emergent;
  23. #include "mesh.hpp"
  24. #include "terrain.hpp"
  25. #include "input.hpp"
  26. #include "controls.hpp"
  27. #include "settings.hpp"
  28. #include "render-passes.hpp"
  29. #include "ui/ui.hpp"
  30. #include "ui/tween.hpp"
  31. class Menu;
  32. class ApplicationState;
  33. class Colony;
  34. class SplashState;
  35. class TitleState;
  36. class ExperimentState;
  37. class CameraController;
  38. class SurfaceCameraController;
  39. class TunnelCameraController;
  40. class LineBatcher;
  41. class ModelLoader;
  42. class MaterialLoader;
  43. class Application
  44. {
  45. public:
  46. Application(int argc, char* argv[]);
  47. ~Application();
  48. // Executes the application and returns a status code
  49. int execute();
  50. // Changes the application state
  51. void changeState(ApplicationState* state);
  52. // Sets the termination code to be returned when the application finishes
  53. void setTerminationCode(int code);
  54. // Closes the application
  55. void close(int terminationCode);
  56. void changeFullscreen();
  57. void changeVerticalSync();
  58. void saveUserSettings();
  59. void resizeUI();
  60. void enterMenu(std::size_t index);
  61. void exitMenu(std::size_t index);
  62. void selectMenuItem(std::size_t index);
  63. void activateMenuItem(std::size_t index);
  64. private:
  65. ApplicationState* state;
  66. ApplicationState* nextState;
  67. int terminationCode;
  68. public:
  69. SDL_Window* window;
  70. SDL_GLContext context;
  71. ModelInstance lensToolObject;
  72. ModelInstance forcepsToolObject;
  73. ModelInstance navigatorObject;
  74. DirectionalLight sunlight;
  75. DirectionalLight fillLight;
  76. DirectionalLight backLight;
  77. Spotlight lensHotspot;
  78. Spotlight lensFalloff;
  79. RenderTarget shadowMapRenderTarget;
  80. GLuint shadowFramebuffer;
  81. GLuint shadowDepthTexture;
  82. ShadowMapRenderPass shadowMapPass;
  83. Compositor shadowCompositor;
  84. Camera sunlightCamera;
  85. RenderTarget defaultRenderTarget;
  86. LightingRenderPass lightingPass;
  87. DebugRenderPass debugPass;
  88. Compositor defaultCompositor;
  89. Camera camera;
  90. Scene scene;
  91. BillboardBatch particleBatch;
  92. MaterialLoader* materialLoader;
  93. ModelLoader* modelLoader;
  94. Renderer renderer;
  95. int toolIndex;
  96. std::string appDataPath;
  97. std::string userDataPath;
  98. ParameterDict settings;
  99. std::string defaultSettingsFilename;
  100. std::string userSettingsFilename;
  101. bool fullscreen;
  102. int fullscreenWidth;
  103. int fullscreenHeight;
  104. int windowedWidth;
  105. int windowedHeight;
  106. int swapInterval;
  107. int width;
  108. int height;
  109. InputManager* inputManager;
  110. Keyboard* keyboard;
  111. Mouse* mouse;
  112. SplashState* splashState;
  113. TitleState* titleState;
  114. ExperimentState* experimentState;
  115. ControlProfile* menuControlProfile;
  116. Control menuLeft;
  117. Control menuRight;
  118. Control menuUp;
  119. Control menuDown;
  120. Control menuSelect;
  121. Control menuCancel;
  122. Control toggleFullscreen;
  123. Control escape;
  124. ControlProfile* gameControlProfile;
  125. Control cameraMoveForward;
  126. Control cameraMoveBack;
  127. Control cameraMoveLeft;
  128. Control cameraMoveRight;
  129. Control cameraRotateCW;
  130. Control cameraRotateCCW;
  131. Control cameraZoomIn;
  132. Control cameraZoomOut;
  133. Control cameraToggleOverheadView;
  134. Control cameraToggleNestView;
  135. bool cameraOverheadView;
  136. bool cameraNestView;
  137. // Misc
  138. Timer frameTimer;
  139. // UI
  140. ParameterDict strings;
  141. float dpi;
  142. float fontSizePT;
  143. float fontSizePX;
  144. Font* menuFont;
  145. Texture splashTexture;
  146. Texture titleTexture;
  147. Vector4 selectedColor;
  148. Vector4 deselectedColor;
  149. UIContainer* uiRootElement;
  150. UIImage* blackoutImage;
  151. UIImage* splashImage;
  152. UIImage* titleImage;
  153. UIImage* copyrightImage;
  154. UILabel* anyKeyLabel;
  155. UILabel* menuSelectorLabel;
  156. UIContainer* mainMenuContainer;
  157. UIContainer* challengeMenuContainer;
  158. UIContainer* experimentMenuContainer;
  159. UIContainer* settingsMenuContainer;
  160. UILabel* challengeLabel;
  161. UILabel* experimentLabel;
  162. UILabel* settingsLabel;
  163. UILabel* quitLabel;
  164. UILabel* loadLabel;
  165. UILabel* newLabel;
  166. UILabel* experimentBackLabel;
  167. UILabel* videoLabel;
  168. UILabel* audioLabel;
  169. UILabel* controlsLabel;
  170. UILabel* gameLabel;
  171. UILabel* settingsBackLabel;
  172. UIContainer* pauseMenuContainer;
  173. UILabel* pausedResumeLabel;
  174. UILabel* pausedSaveLabel;
  175. UILabel* pausedNewLabel;
  176. UILabel* pausedSettingsLabel;
  177. UILabel* returnToMainMenuLabel;
  178. UILabel* quitToDesktopLabel;
  179. BillboardBatch* uiBatch;
  180. UIBatcher* uiBatcher;
  181. UIRenderPass uiPass;
  182. Compositor uiCompositor;
  183. Camera uiCamera;
  184. Scene uiScene;
  185. Camera bgCamera;
  186. BillboardBatch bgBatch;
  187. Compositor bgCompositor;
  188. VignetteRenderPass vignettePass;
  189. Scene bgScene;
  190. // Animation
  191. Tweener* tweener;
  192. Tween<Vector4>* fadeInTween;
  193. Tween<Vector4>* fadeOutTween;
  194. Tween<Vector4>* splashFadeInTween;
  195. Tween<Vector4>* splashFadeOutTween;
  196. Tween<Vector4>* titleFadeInTween;
  197. Tween<Vector4>* titleFadeOutTween;
  198. Tween<Vector4>* copyrightFadeInTween;
  199. Tween<Vector4>* copyrightFadeOutTween;
  200. Tween<Vector4>* anyKeyFadeInTween;
  201. Tween<Vector4>* anyKeyFadeOutTween;
  202. Tween<Vector4>* menuFadeInTween;
  203. Tween<Vector4>* menuFadeOutTween;
  204. Tween<Vector2>* menuSlideInTween;
  205. // Menus
  206. std::size_t menuCount;
  207. Menu** menus;
  208. int currentMenuIndex;
  209. int selectedMenuItemIndex;
  210. UIContainer** menuContainers;
  211. Menu* currentMenu;
  212. Menu* mainMenu;
  213. Menu* challengeMenu;
  214. Menu* experimentMenu;
  215. Menu* settingsMenu;
  216. // Models
  217. Model* displayModel;
  218. Model* antModel;
  219. ModelInstance* displayModelInstance;
  220. ModelInstance* antModelInstance;
  221. // Game variables
  222. Colony* colony;
  223. SurfaceCameraController* surfaceCam;
  224. TunnelCameraController* tunnelCam;
  225. Plane clippingPlanes[5];
  226. Vector3 clippingPlaneNormals[5];
  227. Vector3 clippingPlaneOffsets[5];
  228. AABB clippingPlaneAABBS[5];
  229. // Debug
  230. LineBatcher* lineBatcher;
  231. };
  232. #endif // APPLICATION_HPP