ManaPlus
Functions
maingui.h File Reference

(986a3bf)

#include "localconsts.h"

Go to the source code of this file.

Functions

int mainGui (int argc, char *argv[])
 

Function Documentation

◆ mainGui()

int mainGui ( int  argc,
char *  argv[] 
)

Definition at line 142 of file maingui.cpp.

144 {
145 #ifdef __SWITCH__
146  nxInit();
147 #endif
148 #if defined(__MINGW32__)
149  // load mingw crash handler. Won't fail if dll is not present.
150  // may load libray from current dir, it may not same as program dir
151  LoadLibrary("exchndl.dll");
152 #endif // defined(__MINGW32__)
153 
154  selfName = argv[0];
155 
156  parseOptions(argc, argv);
157 
158  std::ios::sync_with_stdio(false);
159 
160 #ifdef ANDROID
161  mkdir_r(getSdStoragePath().c_str());
162 #endif // ANDROID
163 
164  VirtFs::init(argv[0]);
165  XML::initXML();
166 #if SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
167  IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG);
168 #endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
169 #if SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
170  Mix_Init(MIX_INIT_OGG);
171 #endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
172 
173 #ifdef WIN32
174  SetCurrentDirectory(VirtFs::getBaseDir());
175 #endif // WIN32
176 
177  setPriority(true);
178  client = new Client;
179  int ret = 0;
181  {
182  client->gameInit();
183  ret = client->gameExec();
184  }
185  else
186  {
187  client->testsInit();
188  ret = Client::testsExec();
189  }
190  delete2(client)
191  VirtFs::deinit();
192 
193 #if SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
194  Mix_Quit();
195 #endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
196 #if SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
197  IMG_Quit();
198 #endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
199 
200 #ifdef __SWITCH__
201  SDL_Quit();
202 #endif
203 
204 #ifdef __SWITCH__
205  NxDeinit();
206 #endif
207 
208  return ret;
209 }
Definition: client.h:50
void gameInit()
Definition: client.cpp:170
static int testsExec()
Definition: client.cpp:833
void testsInit()
Definition: client.cpp:161
int gameExec()
Definition: client.cpp:577
Options options
Definition: settings.h:130
void parseOptions(const int argc, char *const argv[])
#define delete2(var)
Definition: delete2.h:25
Client * client
Definition: client.cpp:118
char * selfName
Definition: maingui.cpp:135
int mkdir_r(const char *const pathname)
Create a directory, making leading components first if necessary.
Definition: mkdir.cpp:109
bool deinit()
Definition: fs.cpp:785
void init(const std::string &name)
Definition: fs.cpp:58
const char * getBaseDir()
Definition: fs.cpp:79
void initXML()
Definition: libxml.cpp:305
void setPriority(const bool big)
Definition: process.cpp:328
Settings settings
Definition: settings.cpp:32
bool testMode
Definition: options.h:99

References client, VirtFs::deinit(), delete2, Client::gameExec(), Client::gameInit(), VirtFs::getBaseDir(), VirtFs::init(), XML::initXML(), mkdir_r(), Settings::options, parseOptions(), selfName, setPriority(), settings, Options::testMode, Client::testsExec(), and Client::testsInit().

Referenced by main().