V-Gears 0
Free Final Fantasy VII engine.
VGearsApplication.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreRoot.h>
19#include <OgreOverlaySystem.h>
20#include <memory>
21#include "TypeDefine.h"
22
23namespace VGears{
24
28 class Application : public Ogre::Singleton<Application>{
29
30 public:
31
40 Ogre::String pluginsFileName, Ogre::String resourcesFile, Ogre::String logFileName
41 ): plugins_filename_(pluginsFileName),
42 resources_filename_(resourcesFile), log_filename_(logFileName)
43 {}
44
51 Application(int argc, char *argv[]);
52
56 virtual ~Application();
57
66 bool initOgre(bool hideWindow = false);
67
73 Ogre::Root* getRoot(void);
74
80 Ogre::RenderWindow* getRenderWindow(void);
81
87 const String& getResourcesFilename(void);
88
94 Ogre::ResourceGroupManager* ResMgr() {return res_mgr_;}
95
96 protected:
97
103 String getWindowTitle(void) const;
104
113 bool processCommandLine(int argc, char *argv[]);
114
119 void registerArchiveFactories(void);
120
124 void loadResourcesConfig(void);
125
131 void initComponents(void);
132
138 void destroyComponents(void);
139
143 void createResourceManagers(void);
144
148 void destroyResourceManagers(void);
149
150 private:
151
155 typedef std::vector<std::shared_ptr<Ogre::ResourceManager>>
157
161 static const char* CLI_SECTION_GENERIC;
162
166 static const char* CLI_HELP;
167
171 static const char* CLI_HELP_DESCRIPTION;
172
176 static const char* CLI_CONFIG_FILE;
177
181 static const char* CLI_CONFIG_FILE_DESCRIPTION;
182
186 static const char* CLI_LOG_FILE;
187
191 static const char* CLI_LOG_FILE_DESCRIPTION;
192
196 static const char* CLI_PLUGINS_FILE;
197
202
206 static const char* CLI_RESOURCES_FILE;
207
212
216 int _argc = 0;
217
221 char **_argv = nullptr;
222
227
232
237
242
246 bool _initialized = false;
247
251 std::unique_ptr<Ogre::Root> _root;
252
256 std::unique_ptr<Ogre::OverlaySystem> _overlay_system;
257
261 Ogre::RenderWindow* _render_window = nullptr; // Not owned
262
267
271 Ogre::ResourceGroupManager* res_mgr_ = nullptr; // Not owned
272 };
273}
The V-Gears main applicacion.
Definition: VGearsApplication.h:28
static const char * CLI_CONFIG_FILE
String for the command line arguments.
Definition: VGearsApplication.h:176
void destroyResourceManagers(void)
Unloads the resource manager.
Definition: VGearsApplication.cpp:268
bool _initialized
Flag for initialization status.
Definition: VGearsApplication.h:246
Ogre::ResourceGroupManager * ResMgr()
Retrieves the Ogre resource manager.
Definition: VGearsApplication.h:94
const String & getResourcesFilename(void)
Retrieves the Ogre resources file name.
Definition: VGearsApplication.cpp:151
static const char * CLI_PLUGINS_FILE
String for the command line arguments.
Definition: VGearsApplication.h:196
int _argc
Number of arguments assed by command line.
Definition: VGearsApplication.h:216
Application(Ogre::String pluginsFileName, Ogre::String resourcesFile, Ogre::String logFileName)
Constructor.
Definition: VGearsApplication.h:39
String getWindowTitle(void) const
Retrieves the main window title.
Definition: VGearsApplication.cpp:155
std::unique_ptr< Ogre::Root > _root
Ogre main component.
Definition: VGearsApplication.h:251
static const char * CLI_LOG_FILE_DESCRIPTION
String for the command line help text.
Definition: VGearsApplication.h:191
void registerArchiveFactories(void)
Registers an {.
Definition: VGearsApplication.cpp:207
String resources_filename_
Path to the resource configuration file.
Definition: VGearsApplication.h:241
std::unique_ptr< Ogre::OverlaySystem > _overlay_system
The ogre overlay system.
Definition: VGearsApplication.h:256
static const char * CLI_PLUGINS_FILE_DESCRIPTION
String for the command line help text.
Definition: VGearsApplication.h:201
static const char * CLI_HELP_DESCRIPTION
String for the command line help text.
Definition: VGearsApplication.h:171
char ** _argv
List of arguments passed by command line.
Definition: VGearsApplication.h:221
bool initOgre(bool hideWindow=false)
Initializes the Ogre rendering system.
Definition: VGearsApplication.cpp:75
Ogre::Root * getRoot(void)
Retrieves the Ogre system main component.
Definition: VGearsApplication.cpp:147
Ogre::RenderWindow * getRenderWindow(void)
Retrieves the Ogre main window.
Definition: VGearsApplication.cpp:149
static const char * CLI_CONFIG_FILE_DESCRIPTION
String for the command line help text.
Definition: VGearsApplication.h:181
static const char * CLI_HELP
String for the command line arguments.
Definition: VGearsApplication.h:166
String log_filename_
Path to the log file.
Definition: VGearsApplication.h:231
void destroyComponents(void)
Unloads components.
Definition: VGearsApplication.cpp:219
void createResourceManagers(void)
Initializes the resource manager.
Definition: VGearsApplication.cpp:225
String config_filename_
Path to the configuration file.
Definition: VGearsApplication.h:226
static const char * CLI_RESOURCES_FILE_DESCRIPTION
String for the command line help text.
Definition: VGearsApplication.h:211
Ogre::ResourceGroupManager * res_mgr_
Ogre resource group manager.
Definition: VGearsApplication.h:271
static const char * CLI_LOG_FILE
String for the command line arguments.
Definition: VGearsApplication.h:186
virtual ~Application()
Destructor.
Definition: VGearsApplication.cpp:73
void initComponents(void)
Initializes components.
Definition: VGearsApplication.cpp:213
static const char * CLI_SECTION_GENERIC
String for the command line help text.
Definition: VGearsApplication.h:161
ResourceManagerVector _resource_managers
List of Ogre resource managers.
Definition: VGearsApplication.h:266
String plugins_filename_
Path to the plugin configuration file.
Definition: VGearsApplication.h:236
std::vector< std::shared_ptr< Ogre::ResourceManager > > ResourceManagerVector
List of resource managers.
Definition: VGearsApplication.h:156
Ogre::RenderWindow * _render_window
The Ogre main window.
Definition: VGearsApplication.h:261
void loadResourcesConfig(void)
Loads the resource configuration from the file.
Definition: VGearsApplication.cpp:122
static const char * CLI_RESOURCES_FILE
String for the command line arguments.
Definition: VGearsApplication.h:206
bool processCommandLine(int argc, char *argv[])
Processes command line arguments.
Definition: VGearsApplication.cpp:157
Definition: FF7NameLookup.h:24
Ogre::String String
Definition: TypeDefine.h:37