2011-12-14 07:40:48 +00:00
// ==============================================================
// This file is part of MegaGlest (www.glest.org)
//
// Copyright (C) 2011 - by Mark Vejvoda <mark_vejvoda@hotmail.com>
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
2010-03-13 10:39:22 +00:00
# include "main.h"
# include <stdexcept>
2010-03-13 22:00:01 +00:00
# include "model_gl.h"
2010-03-13 10:39:22 +00:00
# include "graphics_interface.h"
# include "util.h"
# include "conversion.h"
2010-05-25 18:06:42 +00:00
# include "platform_common.h"
# include "xml_parser.h"
2010-05-25 18:51:35 +00:00
# include <iostream>
2010-06-24 14:00:20 +00:00
# include <wx/event.h>
2011-03-10 17:59:40 +00:00
# include "config.h"
2010-08-25 18:26:17 +00:00
# include "game_constants.h"
2011-03-12 02:28:00 +00:00
# include <wx/stdpaths.h>
2011-05-18 21:49:11 +00:00
# include <platform_util.h>
2016-01-18 13:20:49 -08:00
# include "common_scoped_ptr.h"
2012-07-22 00:04:44 +00:00
2011-05-23 19:50:17 +00:00
# ifndef WIN32
# include <errno.h>
# endif
2011-01-28 01:41:30 +00:00
# ifndef WIN32
# define stricmp strcasecmp
# define strnicmp strncasecmp
# define _strnicmp strncasecmp
# endif
2010-03-13 10:39:22 +00:00
using namespace Shared : : Platform ;
2010-05-25 18:06:42 +00:00
using namespace Shared : : PlatformCommon ;
2010-03-13 10:39:22 +00:00
using namespace Shared : : Graphics ;
using namespace Shared : : Graphics : : Gl ;
using namespace Shared : : Util ;
2010-05-25 18:06:42 +00:00
using namespace Shared : : Xml ;
2010-03-13 10:39:22 +00:00
using namespace std ;
2010-08-25 18:26:17 +00:00
using namespace Glest : : Game ;
2010-03-13 10:39:22 +00:00
2010-06-24 13:18:11 +00:00
# ifdef _WIN32
const char * folderDelimiter = " \\ " ;
# else
const char * folderDelimiter = " / " ;
# endif
2011-03-10 17:59:40 +00:00
//int GameConstants::updateFps= 40;
//int GameConstants::cameraFps= 100;
2010-08-25 18:26:17 +00:00
2017-03-08 21:44:28 +01:00
const string g3dviewerVersionString = " v3.13-dev " ;
2011-01-28 01:41:30 +00:00
2011-07-05 19:08:28 +00:00
// Because g3d should always support alpha transparency
string fileFormat = " png " ;
2011-03-10 17:59:40 +00:00
namespace Glest { namespace Game {
2012-07-22 00:04:44 +00:00
2011-03-10 17:59:40 +00:00
string getGameReadWritePath ( string lookupKey ) {
string path = " " ;
if ( path = = " " & & getenv ( " GLESTHOME " ) ! = NULL ) {
2013-12-25 11:42:00 -08:00
path = safeCharPtrCopy ( getenv ( " GLESTHOME " ) , 8096 ) ;
2011-03-10 17:59:40 +00:00
if ( path ! = " " & & EndsWith ( path , " / " ) = = false & & EndsWith ( path , " \\ " ) = = false ) {
path + = " / " ;
}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for read/write files [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
}
return path ;
}
} }
2010-03-13 10:39:22 +00:00
namespace Shared { namespace G3dViewer {
// ===============================================
// class Global functions
// ===============================================
wxString ToUnicode ( const char * str ) {
return wxString ( str , wxConvUTF8 ) ;
}
wxString ToUnicode ( const string & str ) {
return wxString ( str . c_str ( ) , wxConvUTF8 ) ;
}
2011-01-28 01:41:30 +00:00
const wxChar * GAME_ARGS [ ] = {
wxT ( " --help " ) ,
2011-01-28 05:49:52 +00:00
wxT ( " --auto-screenshot " ) ,
2011-01-29 03:53:05 +00:00
wxT ( " --load-unit " ) ,
2011-01-28 05:49:52 +00:00
wxT ( " --load-model " ) ,
wxT ( " --load-model-animation-value " ) ,
wxT ( " --load-particle " ) ,
wxT ( " --load-projectile-particle " ) ,
wxT ( " --load-splash-particle " ) ,
wxT ( " --load-particle-loop-value " ) ,
wxT ( " --zoom-value " ) ,
wxT ( " --rotate-x-value " ) ,
wxT ( " --rotate-y-value " ) ,
2011-07-05 19:08:28 +00:00
wxT ( " --screenshot-format " ) ,
2012-01-06 18:04:01 +00:00
wxT ( " --verbose " ) ,
2011-01-28 01:41:30 +00:00
} ;
enum GAME_ARG_TYPE {
GAME_ARG_HELP = 0 ,
GAME_ARG_AUTO_SCREENSHOT ,
2011-01-29 03:53:05 +00:00
GAME_ARG_LOAD_UNIT ,
2011-01-28 05:49:52 +00:00
GAME_ARG_LOAD_MODEL ,
GAME_ARG_LOAD_MODEL_ANIMATION_VALUE ,
GAME_ARG_LOAD_PARTICLE ,
GAME_ARG_LOAD_PARTICLE_PROJECTILE ,
GAME_ARG_LOAD_PARTICLE_SPLASH ,
GAME_ARG_LOAD_PARTICLE_LOOP_VALUE ,
GAME_ARG_ZOOM_VALUE ,
GAME_ARG_ROTATE_X_VALUE ,
GAME_ARG_ROTATE_Y_VALUE ,
2011-07-05 19:08:28 +00:00
GAME_ARG_SCREENSHOT_FORMAT ,
2012-01-06 18:04:01 +00:00
GAME_ARG_VERBOSE ,
2011-01-28 01:41:30 +00:00
} ;
2013-05-26 06:03:32 +00:00
bool hasCommandArgument ( int argc , wxChar * * argv , const string & argName ,
2011-01-28 01:41:30 +00:00
int * foundIndex = NULL , int startLookupIndex = 1 ,
bool useArgParamLen = false ) {
bool result = false ;
if ( foundIndex ! = NULL ) {
* foundIndex = - 1 ;
}
2011-03-12 02:28:00 +00:00
size_t compareLen = strlen ( argName . c_str ( ) ) ;
2011-01-28 01:41:30 +00:00
for ( int idx = startLookupIndex ; idx < argc ; idx + + ) {
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( argv [ idx ] ) ;
//printf("tmp_buf [%s]\n",(const char *)tmp_buf);
if ( useArgParamLen = = true ) {
compareLen = strlen ( tmp_buf ) ;
}
if ( _strnicmp ( argName . c_str ( ) , tmp_buf , compareLen ) = = 0 ) {
result = true ;
if ( foundIndex ! = NULL ) {
* foundIndex = idx ;
}
break ;
}
}
return result ;
}
void printParameterHelp ( const char * argv0 , bool foundInvalidArgs ) {
if ( foundInvalidArgs = = true ) {
printf ( " \n " ) ;
}
2017-04-01 14:53:34 +02:00
// "================================================================================"
printf ( " \n %s %s, [Using %s] \n " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , g3dviewerVersionString . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( wxVERSION_STRING ) ) ;
printf ( " \n Displays glest 3D-models and unit/projectile/splash particle systems. \n " ) ;
printf ( " \n Rotate with left mouse button. Zoom with right mouse button or mousewheel. " ) ;
printf ( " \n Use ctrl to load more than one particle system. " ) ;
printf ( " \n Press R to restart particles, this also reloads all files if they are changed. " ) ;
//printf("\n\noptionally you may use any of the following:\n");
printf ( " \n \n %s [G3D FILE], usage " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) ) ;
printf ( " \n \n Commandline Parameter: Description: " ) ;
printf ( " \n \n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " ) ;
printf ( " \n \n %s \t \t Displays this help text. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_HELP ] ) ) ;
// "================================================================================"
printf ( " \n \n %s=x \t \t Auto load the unit / skill information specified " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_UNIT ] ) ) ;
printf ( " \n \n \t in path/filename x. " ) ;
printf ( " \n \n \t Where x is a g3d filename to load separated with a " ) ;
printf ( " \n \n \t comma and one or more skill names to try loading. " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=techs/megapack/factions/ " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_UNIT ] ) ) ;
printf ( " \n \n \t tech/units/battle_machine,attack_skill,stop_skill " ) ;
printf ( " \n \n %s=x \t Auto load the model specified in path/filename x. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL ] ) ) ;
printf ( " \n \n \t Where x is a g3d filename to load. " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=techs/megapack/factions/ " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL ] ) ) ;
printf ( " \n \n \t tech/units/battle_machine/models/battle_machine_dying.g3d " ) ;
printf ( " \n \n %s=x " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL_ANIMATION_VALUE ] ) ) ;
printf ( " \n \n \t Animation value when loading a model. " ) ;
printf ( " \n \n \t Where x is a decimal value from -1.0 to 1.0 " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=0.5 " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL_ANIMATION_VALUE ] ) ) ;
// "================================================================================"
printf ( " \n \n %s=x \t Automatically takes a screenshot of the items you " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_AUTO_SCREENSHOT ] ) ) ;
printf ( " \n \n \t are loading. " ) ;
printf ( " \n \n \t Where x is a comma-delimited list of one or more " ) ;
printf ( " \n \n \t of the optional settings: " ) ;
printf ( " \n \n \t transparent, enable_grid, enable_wireframe, " ) ;
printf ( " \n \n \t enable_normals, disable_grid, disable_wireframe, " ) ;
printf ( " \n \n \t disable_normals, saveas-<filename>, resize-wxh " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=transparent, " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_AUTO_SCREENSHOT ] ) ) ;
printf ( " \n \n \t disable_grid,saveas-test.png,resize-800x600 " ) ;
printf ( " \n \n \t %s=techs/megapack/factions/tech/units/ " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL ] ) ) ;
printf ( " \n \n \t battle_machine/models/battle_machine_dying.g3d " ) ;
// "================================================================================"
printf ( " \n \n %s=x \t Auto load the particle specified in path/filename x. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE ] ) ) ;
printf ( " \n \n \t Where x is a Particle XML filename to load. " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=techs/megapack/factions/ " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE ] ) ) ;
printf ( " \n \n \t persian/units/genie/glow_particles.xml " ) ;
printf ( " \n \n %s=x " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_PROJECTILE ] ) ) ;
printf ( " \n \n \t Auto load the projectile particle specified in " ) ;
printf ( " \n \n \t path/filename x. " ) ;
printf ( " \n \n \t Where x is a Projectile Particle Definition XML " ) ;
printf ( " \n \n \t filename to load. " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=techs/megapack/ " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_PROJECTILE ] ) ) ;
printf ( " \n \n \t factions/persian/units/genie/particle_proj.xml " ) ;
printf ( " \n \n %s=x " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_SPLASH ] ) ) ;
printf ( " \n \n \t Auto load the splash particle specified in " ) ;
printf ( " \n \n \t path/filename x. " ) ;
printf ( " \n \n \t Where x is a Splash Particle Definition XML " ) ;
printf ( " \n \n \t filename to load. " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=techs/megapack/ " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_SPLASH ] ) ) ;
printf ( " \n \n \t factions/persian/units/genie/particle_splash.xml " ) ;
printf ( " \n \n %s=x " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_LOOP_VALUE ] ) ) ;
printf ( " \n \n \t Particle loop value when loading one or more " ) ;
printf ( " \n \n \t particles. " ) ;
printf ( " \n \n \t Where x is an integer value from 1 to particle count. " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=25 " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_LOOP_VALUE ] ) ) ;
printf ( " \n \n %s=x \t Zoom value when loading a model. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ZOOM_VALUE ] ) ) ;
printf ( " \n \n \t Where x is a decimal value from 0.1 to 10.0 " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=4.2 " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ZOOM_VALUE ] ) ) ;
printf ( " \n \n %s=x \t X Coordinate Rotation value when loading a model. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_X_VALUE ] ) ) ;
printf ( " \n \n \t Where x is a decimal value from -10.0 to 10.0 " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=2.2 " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_X_VALUE ] ) ) ;
printf ( " \n \n %s=x \t Y Coordinate Rotation value when loading a model. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_Y_VALUE ] ) ) ;
printf ( " \n \n \t Where x is a decimal value from -10.0 to 10.0 " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=2.2 " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_Y_VALUE ] ) ) ;
printf ( " \n \n %s=x \t Specify which image format to use for screenshots. " , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_SCREENSHOT_FORMAT ] ) ) ;
printf ( " \n \n \t Where x is one of the following supported formats: " ) ;
printf ( " \n \n \t png,jpg,tga,bmp " ) ;
printf ( " \n \n \t *NOTE: png is the default (and supports transparency) " ) ;
printf ( " \n \n \t example: " ) ;
printf ( " \n \n \t %s %s=jpg " , extractFileFromDirectoryPath ( argv0 ) . c_str ( ) , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_SCREENSHOT_FORMAT ] ) ) ;
2011-07-05 19:08:28 +00:00
2011-01-28 01:41:30 +00:00
printf ( " \n \n " ) ;
}
bool autoScreenShotAndExit = false ;
vector < string > autoScreenShotParams ;
2012-01-06 19:34:47 +00:00
std : : pair < int , int > overrideSize ( 0 , 0 ) ;
2011-01-28 01:41:30 +00:00
2010-03-13 10:39:22 +00:00
// ===============================================
// class MainWindow
// ===============================================
2010-12-03 05:07:42 +00:00
const string MainWindow : : winHeader = " G3D viewer " + g3dviewerVersionString ;
2010-03-13 10:39:22 +00:00
2011-10-07 07:53:06 +00:00
const float defaultspeed = 0.025f ;
2011-01-29 04:35:55 +00:00
MainWindow : : MainWindow ( std : : pair < string , vector < string > > unitToLoad ,
2011-01-29 03:53:05 +00:00
const string modelPath ,
2011-01-28 05:49:52 +00:00
const string particlePath ,
const string projectileParticlePath ,
const string splashParticlePath ,
float defaultAnimation ,
int defaultParticleLoopStart ,
2011-03-05 23:15:07 +00:00
float defaultZoom , float defaultXRot , float defaultYRot ,
string appPath )
2011-01-29 08:46:28 +00:00
: wxFrame ( NULL , - 1 , ToUnicode ( winHeader ) ,
wxPoint ( Renderer : : windowX , Renderer : : windowY ) ,
2011-03-20 06:05:09 +00:00
wxSize ( Renderer : : windowW , Renderer : : windowH ) ) ,
2013-11-19 06:14:06 +00:00
glCanvas ( NULL ) ,
renderer ( NULL ) ,
timer ( NULL ) ,
menu ( NULL ) ,
fileDialog ( NULL ) ,
colorPicker ( NULL ) ,
model ( NULL ) ,
initTextureManager ( true ) ,
startupSettingsInited ( false )
2010-03-13 10:39:22 +00:00
{
2011-03-05 23:15:07 +00:00
this - > appPath = appPath ;
2011-05-03 11:15:15 +00:00
Properties : : setApplicationPath ( executable_path ( appPath ) ) ;
2011-03-10 17:59:40 +00:00
2014-12-23 20:39:03 -08:00
lastanim = 0 ;
model = NULL ;
2011-03-10 17:59:40 +00:00
Config & config = Config : : getInstance ( ) ;
2011-03-20 06:05:09 +00:00
2012-09-22 20:13:57 +00:00
isControlKeyPressed = false ;
2011-03-20 00:59:17 +00:00
2016-01-23 11:42:44 +01:00
initGlCanvas ( ) ;
2011-03-20 00:59:17 +00:00
# if wxCHECK_VERSION(2, 9, 1)
2013-11-17 07:37:13 +00:00
2011-03-20 00:59:17 +00:00
# else
2016-01-23 11:42:44 +01:00
glCanvas - > SetCurrent ( ) ;
2011-03-20 00:59:17 +00:00
# endif
2011-01-29 22:06:05 +00:00
2011-01-29 04:35:55 +00:00
unitPath = unitToLoad ;
2011-01-29 03:53:05 +00:00
2010-05-25 18:06:42 +00:00
if ( modelPath ! = " " ) {
this - > modelPathList . push_back ( modelPath ) ;
2012-11-10 06:37:23 +00:00
printf ( " Startup Adding model [%s] list size " MG_SIZE_T_SPECIFIER " \n " , modelPath . c_str ( ) , this - > modelPathList . size ( ) ) ;
2010-05-25 18:06:42 +00:00
}
2011-01-28 05:49:52 +00:00
if ( particlePath ! = " " ) {
this - > particlePathList . push_back ( particlePath ) ;
}
if ( projectileParticlePath ! = " " ) {
this - > particleProjectilePathList . push_back ( projectileParticlePath ) ;
}
if ( splashParticlePath ! = " " ) {
this - > particleSplashPathList . push_back ( splashParticlePath ) ;
}
2011-01-29 03:53:05 +00:00
resetAnimation = false ;
2011-01-28 05:49:52 +00:00
anim = defaultAnimation ;
particleLoopStart = defaultParticleLoopStart ;
2011-01-29 03:53:05 +00:00
resetAnim = anim ;
resetParticleLoopStart = particleLoopStart ;
2011-01-28 05:49:52 +00:00
rotX = defaultXRot ;
rotY = defaultYRot ;
zoom = defaultZoom ;
2010-03-13 10:39:22 +00:00
playerColor = Renderer : : pcRed ;
2011-10-07 07:53:06 +00:00
speed = defaultspeed ;
2010-03-13 10:39:22 +00:00
//getGlPlatformExtensions();
menu = new wxMenuBar ( ) ;
//menu
menuFile = new wxMenu ( ) ;
2011-01-28 05:49:52 +00:00
menuFile - > Append ( miFileLoad , wxT ( " &Load G3d model \t Ctrl+L " ) , wxT ( " Load 3D model " ) ) ;
menuFile - > Append ( miFileLoadParticleXML , wxT ( " Load &Particle XML \t Ctrl+P " ) , wxT ( " Press ctrl before menu for keeping current particles " ) ) ;
menuFile - > Append ( miFileLoadProjectileParticleXML , wxT ( " Load Pro&jectile Particle XML \t Ctrl+J " ) , wxT ( " Press ctrl before menu for keeping current projectile particles " ) ) ;
menuFile - > Append ( miFileLoadSplashParticleXML , wxT ( " Load &Splash Particle XML \t Ctrl+S " ) , wxT ( " Press ctrl before menu for keeping current splash particles " ) ) ;
menuFile - > Append ( miFileClearAll , wxT ( " &Clear All \t Ctrl+C " ) ) ;
menuFile - > AppendCheckItem ( miFileToggleScreenshotTransparent , wxT ( " &Transparent Screenshots \t Ctrl+T " ) ) ;
menuFile - > Append ( miFileSaveScreenshot , wxT ( " Sa&ve a Screenshot \t Ctrl+V " ) ) ;
2010-11-03 19:03:25 +00:00
menuFile - > AppendSeparator ( ) ;
menuFile - > Append ( wxID_EXIT ) ;
menu - > Append ( menuFile , wxT ( " &File " ) ) ;
2010-03-13 10:39:22 +00:00
//mode
menuMode = new wxMenu ( ) ;
2010-11-03 19:03:25 +00:00
menuMode - > AppendCheckItem ( miModeNormals , wxT ( " &Normals " ) ) ;
menuMode - > AppendCheckItem ( miModeWireframe , wxT ( " &Wireframe " ) ) ;
menuMode - > AppendCheckItem ( miModeGrid , wxT ( " &Grid " ) ) ;
menu - > Append ( menuMode , wxT ( " &Mode " ) ) ;
2010-03-13 10:39:22 +00:00
//mode
menuSpeed = new wxMenu ( ) ;
2010-11-03 19:03:25 +00:00
menuSpeed - > Append ( miSpeedSlower , wxT ( " &Slower \t - " ) ) ;
menuSpeed - > Append ( miSpeedFaster , wxT ( " &Faster \t + " ) ) ;
menuSpeed - > AppendSeparator ( ) ;
2010-12-05 01:33:28 +00:00
menuSpeed - > Append ( miRestart , wxT ( " &Restart particles \t R " ) , wxT ( " Restart particle animations, this also reloads model and particle files if they are changed " ) ) ;
2010-11-03 19:03:25 +00:00
menu - > Append ( menuSpeed , wxT ( " &Speed " ) ) ;
2010-03-13 10:39:22 +00:00
//custom color
menuCustomColor = new wxMenu ( ) ;
2011-01-21 16:34:33 +00:00
menuCustomColor - > Append ( miChangeBackgroundColor , wxT ( " Change Background Color " ) ) ;
2010-11-03 19:03:25 +00:00
menuCustomColor - > AppendCheckItem ( miColorRed , wxT ( " &Red \t 0 " ) ) ;
menuCustomColor - > AppendCheckItem ( miColorBlue , wxT ( " &Blue \t 1 " ) ) ;
menuCustomColor - > AppendCheckItem ( miColorGreen , wxT ( " &Green \t 2 " ) ) ;
menuCustomColor - > AppendCheckItem ( miColorYellow , wxT ( " &Yellow \t 3 " ) ) ;
menuCustomColor - > AppendCheckItem ( miColorWhite , wxT ( " &White \t 4 " ) ) ;
menuCustomColor - > AppendCheckItem ( miColorCyan , wxT ( " &Cyan \t 5 " ) ) ;
menuCustomColor - > AppendCheckItem ( miColorOrange , wxT ( " &Orange \t 6 " ) ) ;
2010-12-03 05:07:42 +00:00
menuCustomColor - > AppendCheckItem ( miColorMagenta , wxT ( " &Pink \t 7 " ) ) ; // it is called Pink everywhere else so...
2010-11-03 19:03:25 +00:00
menu - > Append ( menuCustomColor , wxT ( " &Custom Color " ) ) ;
2010-03-13 10:39:22 +00:00
menuMode - > Check ( miModeGrid , true ) ;
menuCustomColor - > Check ( miColorRed , true ) ;
SetMenuBar ( menu ) ;
//misc
2010-12-03 05:07:42 +00:00
backBrightness = 0.3f ;
gridBrightness = 1.0f ;
lightBrightness = 0.3f ;
2010-03-13 10:39:22 +00:00
lastX = 0 ;
lastY = 0 ;
2011-01-28 05:49:52 +00:00
2011-01-13 19:27:26 +00:00
statusbarText = " " ;
2010-03-13 10:39:22 +00:00
CreateStatusBar ( ) ;
2011-01-29 23:12:20 +00:00
this - > Layout ( ) ;
2010-06-25 22:54:00 +00:00
wxInitAllImageHandlers ( ) ;
2010-06-25 22:04:40 +00:00
# ifdef WIN32
2010-12-08 20:03:15 +00:00
# if defined(__MINGW32__)
wxIcon icon ( ToUnicode ( " IDI_ICON1 " ) ) ;
# else
2011-05-23 19:23:00 +00:00
wxIcon icon ( L " IDI_ICON1 " ) ;
2010-12-08 20:03:15 +00:00
# endif
2010-06-25 22:54:00 +00:00
# else
wxIcon icon ;
2013-05-26 06:03:32 +00:00
string iniFilePath = extractDirectoryPathFromFile ( config . getFileName ( false ) ) ;
2011-05-03 23:34:25 +00:00
string icon_file = iniFilePath + " g3dviewer.ico " ;
std : : ifstream testFile ( icon_file . c_str ( ) ) ;
2010-10-07 18:13:17 +00:00
if ( testFile . good ( ) ) {
testFile . close ( ) ;
2011-05-03 23:34:25 +00:00
icon . LoadFile ( ToUnicode ( icon_file . c_str ( ) ) , wxBITMAP_TYPE_ICO ) ;
2010-10-07 18:13:17 +00:00
}
2010-06-25 22:04:40 +00:00
# endif
2010-06-25 22:54:00 +00:00
SetIcon ( icon ) ;
2010-06-25 22:04:40 +00:00
2011-01-18 21:17:48 +00:00
fileDialog = new wxFileDialog ( this ) ;
if ( modelPath ! = " " ) {
fileDialog - > SetPath ( ToUnicode ( modelPath ) ) ;
}
2013-06-15 01:43:44 +00:00
string userData = config . getString ( " UserData_Root " , " " ) ;
2011-04-05 04:49:48 +00:00
if ( userData ! = " " ) {
endPathWithSlash ( userData ) ;
}
string defaultPath = userData + " techs/ " ;
2011-04-05 07:10:12 +00:00
fileDialog - > SetDirectory ( ToUnicode ( defaultPath . c_str ( ) ) ) ;
2011-04-05 04:49:48 +00:00
2011-01-29 22:59:33 +00:00
2015-10-26 19:49:25 -07:00
if ( glCanvas ! = NULL ) {
glCanvas - > SetFocus ( ) ;
}
2011-03-12 02:28:00 +00:00
// For windows register g3d file extension to launch this app
2011-04-05 07:32:36 +00:00
# if defined(WIN32) && !defined(__MINGW32__)
2011-03-12 02:28:00 +00:00
// example from: http://stackoverflow.com/questions/1387769/create-registry-entry-to-associate-file-extension-with-application-in-c
2011-05-18 21:49:11 +00:00
//[HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command]
//@="c:\path\to\app.exe \"%1\""
//[HKEY_CURRENT_USER\Software\Classes\.blerg]
2011-03-12 02:28:00 +00:00
//@="blergcorp.blergapp.v1"
2011-04-05 07:32:36 +00:00
//Open the registry key.
2011-05-23 19:23:00 +00:00
wstring subKey = L " Software \\ Classes \\ megaglest.g3d \\ shell \\ open \\ command " ;
2011-03-12 02:28:00 +00:00
HKEY keyHandle ;
2011-05-18 21:49:11 +00:00
DWORD dwDisposition ;
RegCreateKeyEx ( HKEY_CURRENT_USER , subKey . c_str ( ) , 0 , NULL , 0 , KEY_ALL_ACCESS , NULL , & keyHandle , & dwDisposition ) ;
//Set the value.
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( appPath . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
wstring launchApp = wstring ( wstr . get ( ) ) + L " \" %1 \" " ;
2017-02-10 17:11:48 -08:00
DWORD len = ( launchApp . size ( ) + 1 ) * sizeof ( wchar_t ) ;
2011-05-18 21:49:11 +00:00
RegSetValueEx ( keyHandle , NULL , 0 , REG_SZ , ( PBYTE ) launchApp . c_str ( ) , len ) ;
RegCloseKey ( keyHandle ) ;
2011-05-23 19:23:00 +00:00
subKey = L " Software \\ Classes \\ .g3d " ;
2011-05-18 21:49:11 +00:00
RegCreateKeyEx ( HKEY_CURRENT_USER , subKey . c_str ( ) , 0 , NULL , 0 , KEY_ALL_ACCESS , NULL , & keyHandle , & dwDisposition ) ;
//Set the value.
2011-05-23 19:23:00 +00:00
launchApp = L " megaglest.g3d " ;
2017-02-10 17:11:48 -08:00
len = ( launchApp . size ( ) + 1 ) * sizeof ( wchar_t ) ;
2011-05-18 21:49:11 +00:00
RegSetValueEx ( keyHandle , NULL , 0 , REG_SZ , ( PBYTE ) launchApp . c_str ( ) , len ) ;
RegCloseKey ( keyHandle ) ;
2011-03-12 02:28:00 +00:00
# endif
2010-03-13 10:39:22 +00:00
}
2011-03-20 06:05:09 +00:00
void MainWindow : : setupTimer ( ) {
timer = new wxTimer ( this ) ;
timer - > Start ( 100 ) ;
}
void MainWindow : : setupStartupSettings ( ) {
2014-11-28 23:35:35 -08:00
2015-10-26 19:49:25 -07:00
//printf("In setupStartupSettings #1\n");
if ( glCanvas = = NULL ) {
2016-01-23 11:42:44 +01:00
initGlCanvas ( ) ;
2016-01-22 18:05:46 -08:00
# if wxCHECK_VERSION(2, 9, 1)
# else
glCanvas - > SetCurrent ( ) ;
# endif
2015-10-26 19:49:25 -07:00
}
2014-11-28 23:35:35 -08:00
glCanvas - > setCurrentGLContext ( ) ;
2015-10-26 19:49:25 -07:00
//printf("In setupStartupSettings #2\n");
2014-11-28 23:35:35 -08:00
GLuint err = glewInit ( ) ;
if ( GLEW_OK ! = err ) {
2013-06-03 06:10:16 +00:00
fprintf ( stderr , " Error [main]: glewInit failed: %s \n " , glewGetErrorString ( err ) ) ;
//return 1;
throw std : : runtime_error ( ( char * ) glewGetErrorString ( err ) ) ;
2014-11-28 23:35:35 -08:00
}
2013-06-03 06:10:16 +00:00
2011-03-20 06:05:09 +00:00
renderer = Renderer : : getInstance ( ) ;
for ( unsigned int i = 0 ; i < autoScreenShotParams . size ( ) ; + + i ) {
if ( autoScreenShotParams [ i ] = = " transparent " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuFile - > Check ( miFileToggleScreenshotTransparent , true ) ;
float alpha = 0.0f ;
renderer - > setAlphaColor ( alpha ) ;
}
if ( autoScreenShotParams [ i ] = = " enable_grid " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuMode - > Check ( miModeGrid , true ) ;
if ( renderer - > getGrid ( ) = = false ) {
renderer - > toggleGrid ( ) ;
}
}
if ( autoScreenShotParams [ i ] = = " enable_wireframe " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuMode - > Check ( miModeWireframe , true ) ;
if ( renderer - > getWireframe ( ) = = false ) {
renderer - > toggleWireframe ( ) ;
}
}
if ( autoScreenShotParams [ i ] = = " enable_normals " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuMode - > Check ( miModeNormals , true ) ;
if ( renderer - > getNormals ( ) = = false ) {
renderer - > toggleNormals ( ) ;
}
}
if ( autoScreenShotParams [ i ] = = " disable_grid " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuMode - > Check ( miModeGrid , false ) ;
if ( renderer - > getGrid ( ) = = true ) {
renderer - > toggleGrid ( ) ;
}
}
if ( autoScreenShotParams [ i ] = = " enable_wireframe " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuMode - > Check ( miModeWireframe , false ) ;
if ( renderer - > getWireframe ( ) = = true ) {
renderer - > toggleWireframe ( ) ;
}
}
if ( autoScreenShotParams [ i ] = = " enable_normals " ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
menuMode - > Check ( miModeNormals , false ) ;
if ( renderer - > getNormals ( ) = = true ) {
renderer - > toggleNormals ( ) ;
}
}
}
renderer - > init ( ) ;
wxCommandEvent event ;
onMenuRestart ( event ) ;
}
2010-03-13 10:39:22 +00:00
MainWindow : : ~ MainWindow ( ) {
delete timer ;
2011-01-29 08:46:28 +00:00
timer = NULL ;
2012-04-20 01:04:05 +00:00
2012-07-21 20:21:27 +00:00
delete fileDialog ;
fileDialog = NULL ;
2014-12-23 20:39:03 -08:00
//delete model;
//model = NULL;
if ( renderer ) renderer - > end ( ) ;
2012-04-20 01:04:05 +00:00
delete renderer ;
renderer = NULL ;
2015-10-26 19:49:25 -07:00
if ( glCanvas ) {
glCanvas - > Destroy ( ) ;
}
2011-01-29 08:46:28 +00:00
glCanvas = NULL ;
2010-06-25 22:04:40 +00:00
2010-03-13 10:39:22 +00:00
}
2016-01-23 11:42:44 +01:00
void MainWindow : : initGlCanvas ( ) {
if ( glCanvas = = NULL ) {
int args [ ] = { WX_GL_RGBA , WX_GL_DOUBLEBUFFER , WX_GL_MIN_ALPHA , 8 } ; // to prevent flicker
glCanvas = new GlCanvas ( this , args ) ;
}
}
2011-01-28 01:41:30 +00:00
void MainWindow : : init ( ) {
2012-04-20 01:04:05 +00:00
# if wxCHECK_VERSION(2, 9, 3)
2015-10-26 19:49:25 -07:00
2012-04-20 01:04:05 +00:00
# elif wxCHECK_VERSION(2, 9, 1)
2011-03-20 06:05:09 +00:00
2011-03-20 00:59:17 +00:00
# else
2016-01-23 11:42:44 +01:00
glCanvas - > SetCurrent ( ) ;
2013-06-03 06:10:16 +00:00
//printf("setcurrent #2\n");
2011-03-20 00:59:17 +00:00
# endif
2010-03-13 10:39:22 +00:00
}
2011-03-20 06:05:09 +00:00
void MainWindow : : onPaint ( wxPaintEvent & event ) {
2015-10-26 19:49:25 -07:00
if ( ! IsShown ( ) ) {
event . Skip ( ) ;
return ;
}
2011-05-25 07:21:22 +00:00
2015-10-26 19:49:25 -07:00
bool isFirstWindowShownEvent = ! startupSettingsInited ;
2011-03-20 06:05:09 +00:00
if ( startupSettingsInited = = false ) {
startupSettingsInited = true ;
setupStartupSettings ( ) ;
}
2015-10-26 19:49:25 -07:00
glCanvas - > setCurrentGLContext ( ) ;
2012-01-06 21:02:23 +00:00
2013-11-19 06:14:06 +00:00
static float autoScreenshotRender = - 1 ;
if ( autoScreenShotAndExit = = true & & autoScreenshotRender > = 0 ) {
anim = autoScreenshotRender ;
}
2011-05-25 06:19:07 +00:00
// notice that we use GetSize() here and not GetClientSize() because
// the latter doesn't return correct results for the minimized windows
// (at least not under Windows)
2012-01-06 19:34:47 +00:00
int viewportW = GetClientSize ( ) . x ;
int viewportH = GetClientSize ( ) . y ;
2013-11-17 08:01:45 +00:00
2013-11-17 08:06:06 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " %d x %d \n " , viewportW , viewportH ) ;
2011-05-25 07:21:22 +00:00
2013-11-17 08:19:17 +00:00
if ( viewportW = = 0 & & viewportH = = 0 ) {
printf ( " #1 %d x %d \n " , viewportW , viewportH ) ;
viewportW = GetSize ( ) . x ;
viewportH = GetSize ( ) . y ;
2013-11-19 06:14:06 +00:00
if ( viewportH > 0 ) {
//viewportH -= menu->GetSize().y;
viewportH - = 22 ;
}
2013-11-17 08:19:17 +00:00
printf ( " #2 %d x %d \n " , viewportW , viewportH ) ;
}
2012-01-06 19:34:47 +00:00
# if defined(WIN32)
renderer - > reset ( viewportW , viewportH , playerColor ) ;
2011-05-25 06:19:07 +00:00
# else
2012-01-06 19:34:47 +00:00
renderer - > reset ( viewportW , viewportH , playerColor ) ;
2011-05-25 06:19:07 +00:00
# endif
2010-03-13 10:39:22 +00:00
renderer - > transform ( rotX , rotY , zoom ) ;
renderer - > renderGrid ( ) ;
2011-01-28 05:49:52 +00:00
//printf("anim [%f] particleLoopStart [%d]\n",anim,particleLoopStart);
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2010-03-13 10:39:22 +00:00
renderer - > renderTheModel ( model , anim ) ;
2011-01-28 05:49:52 +00:00
int updateLoops = particleLoopStart ;
particleLoopStart = 1 ;
2011-10-07 07:53:06 +00:00
if ( resetAnimation = = true | | ( ( anim - lastanim ) > = defaultspeed * 2 ) ) {
2011-10-07 14:38:20 +00:00
//printf("anim [%f] [%f] [%f]\n",anim,lastanim,speed);
2011-10-07 07:53:06 +00:00
for ( int i = 0 ; i < updateLoops ; + + i ) {
renderer - > updateParticleManager ( ) ;
}
2010-05-25 18:06:42 +00:00
}
renderer - > renderParticleManager ( ) ;
2012-01-04 21:43:34 +00:00
2015-10-26 19:49:25 -07:00
if ( isFirstWindowShownEvent ) {
this - > Refresh ( ) ;
glCanvas - > Refresh ( ) ;
glCanvas - > SetFocus ( ) ;
}
2011-08-31 23:10:43 +00:00
bool haveLoadedParticles = ( particleProjectilePathList . empty ( ) = = false | | particleSplashPathList . empty ( ) = = false ) ;
2011-01-29 08:46:28 +00:00
2013-11-17 08:01:45 +00:00
if ( autoScreenShotAndExit = = true & & viewportW > 0 & & viewportH > 0 ) {
2011-01-29 08:46:28 +00:00
printf ( " Auto exiting app... \n " ) ;
fflush ( stdout ) ;
2011-01-28 01:41:30 +00:00
autoScreenShotAndExit = false ;
2013-11-19 06:14:06 +00:00
2011-01-28 01:41:30 +00:00
saveScreenshot ( ) ;
Close ( ) ;
2011-01-29 08:46:28 +00:00
return ;
2011-01-28 01:41:30 +00:00
}
2012-01-04 21:43:34 +00:00
glCanvas - > SwapBuffers ( ) ;
2013-11-17 08:01:45 +00:00
if ( autoScreenShotAndExit = = true & & viewportW = = 0 & & viewportH = = 0 ) {
2013-11-19 06:14:06 +00:00
autoScreenshotRender = anim ;
2013-11-17 08:19:17 +00:00
printf ( " Auto exiting desired but waiting for w x h > 0... \n " ) ;
2013-11-17 08:01:45 +00:00
return ;
}
2012-01-04 21:43:34 +00:00
if ( ( modelPathList . empty ( ) = = false ) & & resetAnimation & & haveLoadedParticles ) {
2011-01-29 08:46:28 +00:00
if ( anim > = resetAnim & & resetAnim > 0 ) {
printf ( " RESETTING EVERYTHING [%f][%f]... \n " , anim , resetAnim ) ;
fflush ( stdout ) ;
resetAnimation = false ;
particleLoopStart = resetParticleLoopStart ;
2011-01-29 03:53:05 +00:00
2011-01-29 08:46:28 +00:00
wxCommandEvent event ;
if ( unitPath . first ! = " " ) {
//onMenuFileClearAll(event);
2011-01-29 03:53:05 +00:00
2011-01-29 08:46:28 +00:00
modelPathList . clear ( ) ;
particlePathList . clear ( ) ;
particleProjectilePathList . clear ( ) ;
particleSplashPathList . clear ( ) ; // as above
onMenuRestart ( event ) ;
}
else {
2011-01-29 03:53:05 +00:00
onMenuRestart ( event ) ;
}
}
}
2011-09-01 18:08:56 +00:00
else if ( modelPathList . empty ( ) = = true & & haveLoadedParticles ) {
2011-01-29 08:46:28 +00:00
if ( renderer - > hasActiveParticleSystem ( ParticleSystem : : pst_ProjectileParticleSystem ) = = false & &
renderer - > hasActiveParticleSystem ( ParticleSystem : : pst_SplashParticleSystem ) = = false ) {
printf ( " RESETTING PARTICLES... \n " ) ;
fflush ( stdout ) ;
resetAnimation = false ;
anim = 0.f ;
particleLoopStart = resetParticleLoopStart ;
wxCommandEvent event ;
onMenuRestart ( event ) ;
}
}
2011-10-07 07:53:06 +00:00
lastanim = anim ;
2010-03-13 10:39:22 +00:00
}
void MainWindow : : onClose ( wxCloseEvent & event ) {
2010-11-03 19:03:25 +00:00
// release memory first (from onMenuFileClearAll)
2011-12-03 08:54:18 +00:00
//printf("OnClose START\n");
//fflush(stdout);
2011-01-29 08:46:28 +00:00
2010-11-03 19:03:25 +00:00
modelPathList . clear ( ) ;
particlePathList . clear ( ) ;
particleProjectilePathList . clear ( ) ;
particleSplashPathList . clear ( ) ; // as above
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
2010-11-03 19:03:25 +00:00
unitParticleSystems . clear ( ) ;
unitParticleSystemTypes . clear ( ) ;
2010-12-03 05:07:42 +00:00
2010-11-03 19:03:25 +00:00
projectileParticleSystems . clear ( ) ;
projectileParticleSystemTypes . clear ( ) ;
splashParticleSystems . clear ( ) ; // as above
splashParticleSystemTypes . clear ( ) ;
2014-12-23 20:39:03 -08:00
//delete model;
//model = NULL;
if ( renderer ) renderer - > end ( ) ;
2010-11-03 19:03:25 +00:00
2011-12-03 08:54:18 +00:00
//printf("OnClose about to END\n");
//fflush(stdout);
2011-01-29 08:46:28 +00:00
2012-04-20 01:04:05 +00:00
delete timer ;
timer = NULL ;
2014-11-28 23:35:35 -08:00
//delete model;
//model = NULL;
2012-04-20 01:04:05 +00:00
delete renderer ;
renderer = NULL ;
//delete glCanvas;
2015-10-26 19:49:25 -07:00
if ( glCanvas ) {
glCanvas - > Destroy ( ) ;
}
2012-04-20 01:04:05 +00:00
glCanvas = NULL ;
this - > Destroy ( ) ;
2010-03-13 10:39:22 +00:00
}
2010-12-03 05:07:42 +00:00
// for the mousewheel
2010-11-03 19:03:25 +00:00
void MainWindow : : onMouseWheelDown ( wxMouseEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
wxPaintEvent paintEvent ;
zoom * = 1.1f ;
zoom = clamp ( zoom , 0.1f , 10.0f ) ;
2011-01-28 05:49:52 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-28 05:49:52 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2011-01-20 19:47:33 +00:00
onPaint ( paintEvent ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-11-03 19:03:25 +00:00
}
void MainWindow : : onMouseWheelUp ( wxMouseEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
wxPaintEvent paintEvent ;
zoom * = 0.90909f ;
zoom = clamp ( zoom , 0.1f , 10.0f ) ;
2011-01-28 05:49:52 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-28 05:49:52 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2011-01-20 19:47:33 +00:00
onPaint ( paintEvent ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-11-03 19:03:25 +00:00
}
2010-03-13 10:39:22 +00:00
void MainWindow : : onMouseMove ( wxMouseEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
int x = event . GetX ( ) ;
int y = event . GetY ( ) ;
wxPaintEvent paintEvent ;
if ( event . LeftIsDown ( ) ) {
rotX + = clamp ( lastX - x , - 10 , 10 ) ;
rotY + = clamp ( lastY - y , - 10 , 10 ) ;
2011-01-28 05:49:52 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-28 05:49:52 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2011-01-20 19:47:33 +00:00
onPaint ( paintEvent ) ;
}
else if ( event . RightIsDown ( ) ) {
zoom * = 1.0f + ( lastX - x + lastY - y ) / 100.0f ;
zoom = clamp ( zoom , 0.1f , 10.0f ) ;
2011-01-28 05:49:52 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-28 05:49:52 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2011-01-20 19:47:33 +00:00
onPaint ( paintEvent ) ;
}
2010-03-13 10:39:22 +00:00
2011-01-20 19:47:33 +00:00
lastX = x ;
lastY = y ;
2010-03-13 10:39:22 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-03-13 10:39:22 +00:00
}
}
void MainWindow : : onMenuFileLoad ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
2012-10-06 07:06:40 +00:00
//string fileName;
2011-01-21 01:53:58 +00:00
fileDialog - > SetWildcard ( wxT ( " G3D files (*.g3d)|*.g3d;*.G3D " ) ) ;
2011-01-20 19:47:33 +00:00
fileDialog - > SetMessage ( wxT ( " Selecting Glest Model for current view. " ) ) ;
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
if ( fileDialog - > ShowModal ( ) = = wxID_OK ) {
modelPathList . clear ( ) ;
2012-11-05 05:40:47 +00:00
string file ;
2011-05-23 19:50:17 +00:00
# ifdef WIN32
2011-05-23 19:23:00 +00:00
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( fileDialog - > GetPath ( ) ) ;
2011-05-23 19:50:17 +00:00
file = tmp_buf ;
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( file . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
file = utf8_encode ( wstr . get ( ) ) ;
2011-05-23 19:50:17 +00:00
# else
file = ( const char * ) wxFNCONV ( fileDialog - > GetPath ( ) . c_str ( ) ) ;
# endif
2011-05-23 19:23:00 +00:00
//loadModel((const char*)wxFNCONV(fileDialog->GetPath().c_str()));
loadModel ( file ) ;
2011-01-20 19:47:33 +00:00
}
isControlKeyPressed = false ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-05-25 18:06:42 +00:00
}
}
void MainWindow : : onMenuFileLoadParticleXML ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
2012-10-06 07:06:40 +00:00
//string fileName;
2011-01-20 19:47:33 +00:00
fileDialog - > SetWildcard ( wxT ( " XML files (*.xml)|*.xml " ) ) ;
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
if ( isControlKeyPressed = = true ) {
fileDialog - > SetMessage ( wxT ( " Adding Mega-Glest particle to current view. " ) ) ;
}
else {
fileDialog - > SetMessage ( wxT ( " Selecting Mega-Glest particle for current view. " ) ) ;
}
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
if ( fileDialog - > ShowModal ( ) = = wxID_OK ) {
2011-05-23 19:23:00 +00:00
//string path = (const char*)wxFNCONV(fileDialog->GetPath().c_str());
2012-11-05 05:40:47 +00:00
string file ;
2011-05-23 19:50:17 +00:00
# ifdef WIN32
2011-05-23 19:23:00 +00:00
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( fileDialog - > GetPath ( ) ) ;
2011-05-23 19:50:17 +00:00
file = tmp_buf ;
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( file . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
file = utf8_encode ( wstr . get ( ) ) ;
2011-05-23 19:50:17 +00:00
# else
file = ( const char * ) wxFNCONV ( fileDialog - > GetPath ( ) . c_str ( ) ) ;
# endif
2011-05-23 19:23:00 +00:00
loadParticle ( file ) ;
2011-01-20 19:47:33 +00:00
}
isControlKeyPressed = false ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-05-25 18:06:42 +00:00
}
}
2010-06-24 10:52:58 +00:00
void MainWindow : : onMenuFileLoadProjectileParticleXML ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
2012-10-06 07:06:40 +00:00
//string fileName;
2011-01-20 19:47:33 +00:00
fileDialog - > SetWildcard ( wxT ( " XML files (*.xml)|*.xml " ) ) ;
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
if ( isControlKeyPressed = = true ) {
fileDialog - > SetMessage ( wxT ( " Adding Mega-Glest projectile particle to current view. " ) ) ;
}
else {
fileDialog - > SetMessage ( wxT ( " Selecting Mega-Glest projectile particle for current view. " ) ) ;
}
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
if ( fileDialog - > ShowModal ( ) = = wxID_OK ) {
2011-05-23 19:23:00 +00:00
//string path = (const char*)wxFNCONV(fileDialog->GetPath().c_str());
2012-11-05 05:40:47 +00:00
string file ;
2011-05-23 19:50:17 +00:00
# ifdef WIN32
2011-05-23 19:23:00 +00:00
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( fileDialog - > GetPath ( ) ) ;
2011-05-23 19:50:17 +00:00
file = tmp_buf ;
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( file . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
file = utf8_encode ( wstr . get ( ) ) ;
2011-05-23 19:50:17 +00:00
# else
file = ( const char * ) wxFNCONV ( fileDialog - > GetPath ( ) . c_str ( ) ) ;
# endif
2011-05-23 19:23:00 +00:00
loadProjectileParticle ( file ) ;
2011-01-20 19:47:33 +00:00
}
isControlKeyPressed = false ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-06-24 10:52:58 +00:00
}
}
2010-11-03 19:03:25 +00:00
void MainWindow : : onMenuFileLoadSplashParticleXML ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
2012-10-06 07:06:40 +00:00
//string fileName;
2011-01-20 19:47:33 +00:00
fileDialog - > SetWildcard ( wxT ( " XML files (*.xml)|*.xml " ) ) ;
2010-11-03 19:03:25 +00:00
2011-01-20 19:47:33 +00:00
if ( isControlKeyPressed = = true ) {
fileDialog - > SetMessage ( wxT ( " Adding Mega-Glest splash particle to current view. " ) ) ;
}
else {
fileDialog - > SetMessage ( wxT ( " Selecting Mega-Glest splash particle for current view. " ) ) ;
}
2010-11-03 19:03:25 +00:00
2011-01-20 19:47:33 +00:00
if ( fileDialog - > ShowModal ( ) = = wxID_OK ) {
2011-05-23 19:23:00 +00:00
//string path = (const char*)wxFNCONV(fileDialog->GetPath().c_str());
2012-11-05 05:40:47 +00:00
string file ;
2011-05-23 19:50:17 +00:00
# ifdef WIN32
2011-05-23 19:23:00 +00:00
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( fileDialog - > GetPath ( ) ) ;
2011-05-23 19:50:17 +00:00
file = tmp_buf ;
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( file . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
file = utf8_encode ( wstr . get ( ) ) ;
2011-05-23 19:50:17 +00:00
# else
file = ( const char * ) wxFNCONV ( fileDialog - > GetPath ( ) . c_str ( ) ) ;
# endif
2011-05-23 19:23:00 +00:00
loadSplashParticle ( file ) ;
2011-01-20 19:47:33 +00:00
}
isControlKeyPressed = false ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-11-03 19:03:25 +00:00
}
2010-12-03 05:07:42 +00:00
} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method?
2010-11-03 19:03:25 +00:00
2011-01-21 16:34:33 +00:00
void MainWindow : : OnChangeColor ( wxCommandEvent & event ) {
try {
//wxColour color = colorPicker->GetColour();
wxColourData data ;
data . SetChooseFull ( true ) ;
for ( int i = 0 ; i < 16 ; i + + )
{
wxColour colour ( i * 16 , i * 16 , i * 16 ) ;
data . SetCustomColour ( i , colour ) ;
}
wxColourDialog dialog ( this , & data ) ;
if ( dialog . ShowModal ( ) = = wxID_OK )
{
wxColourData retData = dialog . GetColourData ( ) ;
wxColour col = retData . GetColour ( ) ;
renderer - > setBackgroundColor ( col . Red ( ) / 255.0f , col . Green ( ) / 255.0f , col . Blue ( ) / 255.0f ) ;
}
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-21 16:34:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenumFileToggleScreenshotTransparent ( wxCommandEvent & event ) {
try {
float alpha = ( event . IsChecked ( ) = = true ? 0.0f : 1.0f ) ;
renderer - > setAlphaColor ( alpha ) ;
2011-07-05 19:08:28 +00:00
//printf("alpha = %f\n",alpha);
2011-01-21 16:34:33 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-21 16:34:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
2011-01-28 01:41:30 +00:00
void MainWindow : : saveScreenshot ( ) {
2011-01-20 19:47:33 +00:00
try {
2011-01-28 01:41:30 +00:00
int autoSaveScreenshotIndex = - 1 ;
2011-01-29 17:42:34 +00:00
for ( unsigned int i = 0 ; i < autoScreenShotParams . size ( ) ; + + i ) {
2011-01-28 01:41:30 +00:00
if ( _strnicmp ( autoScreenShotParams [ i ] . c_str ( ) , " saveas- " , 7 ) = = 0 ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
autoSaveScreenshotIndex = i ;
break ;
}
}
if ( autoSaveScreenshotIndex > = 0 ) {
string saveAsFilename = autoScreenShotParams [ autoSaveScreenshotIndex ] ;
saveAsFilename . erase ( 0 , 7 ) ;
2011-05-18 21:49:11 +00:00
# ifdef WIN32
FILE * f = _wfopen ( utf8_decode ( saveAsFilename ) . c_str ( ) , L " rb " ) ;
# else
2011-01-28 01:41:30 +00:00
FILE * f = fopen ( saveAsFilename . c_str ( ) , " rb " ) ;
2011-05-18 21:49:11 +00:00
# endif
2011-01-28 01:41:30 +00:00
if ( f = = NULL ) {
2012-01-06 18:49:33 +00:00
renderer - > saveScreen ( saveAsFilename . c_str ( ) , & overrideSize ) ;
2011-01-28 01:41:30 +00:00
}
else {
2011-05-23 19:23:00 +00:00
if ( f ) {
fclose ( f ) ;
}
2011-01-28 01:41:30 +00:00
}
}
else {
2011-03-10 17:59:40 +00:00
//string screenShotsPath = extractDirectoryPathFromFile(appPath) + string("screens/");
string userData = Config : : getInstance ( ) . getString ( " UserData_Root " , " " ) ;
if ( userData ! = " " ) {
2011-03-13 08:23:43 +00:00
endPathWithSlash ( userData ) ;
2011-03-10 17:59:40 +00:00
}
string screenShotsPath = userData + string ( " screens/ " ) ;
2011-03-05 23:15:07 +00:00
printf ( " screenShotsPath [%s] \n " , screenShotsPath . c_str ( ) ) ;
if ( isdir ( screenShotsPath . c_str ( ) ) = = false ) {
createDirectoryPaths ( screenShotsPath ) ;
}
string path = screenShotsPath ;
2011-01-28 01:41:30 +00:00
if ( isdir ( path . c_str ( ) ) = = true ) {
2011-07-05 19:08:28 +00:00
//Config &config= Config::getInstance();
//string fileFormat = config.getString("ScreenShotFileType","jpg");
2011-01-28 01:41:30 +00:00
2011-03-10 17:31:55 +00:00
for ( int i = 0 ; i < 5000 ; + + i ) {
2011-03-05 23:15:07 +00:00
path = screenShotsPath ;
2011-01-28 01:41:30 +00:00
path + = string ( " screen " ) + intToStr ( i ) + string ( " . " ) + fileFormat ;
2011-05-18 21:49:11 +00:00
# ifdef WIN32
FILE * f = _wfopen ( utf8_decode ( path ) . c_str ( ) , L " rb " ) ;
# else
2011-01-28 01:41:30 +00:00
FILE * f = fopen ( path . c_str ( ) , " rb " ) ;
2011-05-18 21:49:11 +00:00
# endif
2011-01-28 01:41:30 +00:00
if ( f = = NULL ) {
2012-01-06 18:49:33 +00:00
renderer - > saveScreen ( path , & overrideSize ) ;
2011-01-28 01:41:30 +00:00
break ;
}
else {
2011-05-23 19:23:00 +00:00
if ( f ) {
fclose ( f ) ;
}
2011-01-28 01:41:30 +00:00
}
2011-01-20 19:47:33 +00:00
}
2011-01-20 18:05:07 +00:00
}
}
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2011-01-20 18:05:07 +00:00
}
2011-01-28 01:41:30 +00:00
void MainWindow : : onMenuFileSaveScreenshot ( wxCommandEvent & event ) {
saveScreenshot ( ) ;
}
2011-01-20 18:05:07 +00:00
void MainWindow : : onMenuFileClearAll ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
2011-12-03 08:54:18 +00:00
//printf("Start onMenuFileClearAll\n");
//fflush(stdout);
2011-01-29 08:46:28 +00:00
2011-01-20 19:47:33 +00:00
modelPathList . clear ( ) ;
particlePathList . clear ( ) ;
particleProjectilePathList . clear ( ) ;
particleSplashPathList . clear ( ) ; // as above
2010-11-03 19:03:25 +00:00
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
if ( renderer ) renderer - > end ( ) ;
2010-06-24 14:00:20 +00:00
2011-01-20 19:47:33 +00:00
unitParticleSystems . clear ( ) ;
unitParticleSystemTypes . clear ( ) ;
2010-12-03 05:07:42 +00:00
2011-01-20 19:47:33 +00:00
projectileParticleSystems . clear ( ) ;
projectileParticleSystemTypes . clear ( ) ;
splashParticleSystems . clear ( ) ; // as above
splashParticleSystemTypes . clear ( ) ;
2010-06-24 14:00:20 +00:00
2014-12-23 20:39:03 -08:00
//delete model;
//model = NULL;
if ( model ! = NULL & & renderer ! = NULL ) renderer - > endModel ( rsGlobal , model ) ;
2011-01-20 19:47:33 +00:00
model = NULL ;
2010-06-24 14:00:20 +00:00
2011-01-29 08:46:28 +00:00
loadUnit ( " " , " " ) ;
2011-01-20 19:47:33 +00:00
loadModel ( " " ) ;
loadParticle ( " " ) ;
loadProjectileParticle ( " " ) ;
loadSplashParticle ( " " ) ; // as above
2010-06-24 14:00:20 +00:00
2011-01-20 19:47:33 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusbarText . c_str ( ) ) ) ;
isControlKeyPressed = false ;
2011-01-29 08:46:28 +00:00
2011-12-03 08:54:18 +00:00
//printf("END onMenuFileClearAll\n");
//fflush(stdout);
2011-01-29 08:46:28 +00:00
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Start ( 100 ) ;
2011-01-20 19:47:33 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-06-24 14:00:20 +00:00
}
2010-11-03 19:03:25 +00:00
void MainWindow : : onMenuFileExit ( wxCommandEvent & event ) {
Close ( ) ;
}
2011-01-29 03:53:05 +00:00
void MainWindow : : loadUnit ( string path , string skillName ) {
if ( path ! = " " & & fileExists ( path ) = = true ) {
// std::cout << "Clearing list..." << std::endl;
2011-01-29 04:35:55 +00:00
this - > unitPath . first = path ;
this - > unitPath . second . push_back ( skillName ) ;
2011-01-29 03:53:05 +00:00
}
try {
2011-01-29 04:35:55 +00:00
if ( this - > unitPath . first ! = " " ) {
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
if ( renderer ) renderer - > end ( ) ;
2011-01-29 08:46:28 +00:00
string titlestring = winHeader ;
2011-01-29 03:53:05 +00:00
2011-01-29 04:35:55 +00:00
string unitPath = this - > unitPath . first ;
2011-01-29 03:53:05 +00:00
string dir = unitPath ;
string name = lastDir ( dir ) ;
string path = dir + " / " + name + " .xml " ;
titlestring = unitPath + " - " + titlestring ;
std : : string unitXML = path ;
string skillModelFile = " " ;
string skillParticleFile = " " ;
string skillParticleProjectileFile = " " ;
string skillParticleSplashFile = " " ;
2012-01-04 19:59:12 +00:00
bool fileFound = fileExists ( unitXML ) ;
2011-01-29 03:53:05 +00:00
2012-01-04 19:59:12 +00:00
printf ( " Loading unit from file [%s] fileFound = %d \n " , unitXML . c_str ( ) , fileFound ) ;
2011-01-29 03:53:05 +00:00
2012-01-04 19:59:12 +00:00
if ( fileFound = = true ) {
2011-01-29 03:53:05 +00:00
XmlTree xmlTree ;
2011-05-06 22:12:16 +00:00
xmlTree . load ( unitXML , Properties : : getTagReplacementValues ( ) ) ;
2011-01-29 03:53:05 +00:00
const XmlNode * unitNode = xmlTree . getRootNode ( ) ;
2011-01-29 04:35:55 +00:00
bool foundSkillName = false ;
2011-01-29 17:42:34 +00:00
for ( unsigned int skillIdx = 0 ; foundSkillName = = false & & skillIdx < this - > unitPath . second . size ( ) ; + + skillIdx ) {
2011-01-29 04:35:55 +00:00
string lookipForSkillName = this - > unitPath . second [ skillIdx ] ;
const XmlNode * skillsNode = unitNode - > getChild ( " skills " ) ;
2011-01-29 17:42:34 +00:00
for ( unsigned int i = 0 ; foundSkillName = = false & & i < skillsNode - > getChildCount ( ) ; + + i ) {
2011-01-29 04:35:55 +00:00
const XmlNode * sn = skillsNode - > getChild ( " skill " , i ) ;
2013-11-19 06:14:06 +00:00
//const XmlNode *typeNode= sn->getChild("type");
2011-01-29 04:35:55 +00:00
const XmlNode * nameNode = sn - > getChild ( " name " ) ;
string skillXmlName = nameNode - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
if ( skillXmlName = = lookipForSkillName ) {
2011-01-29 08:46:28 +00:00
printf ( " Found skill [%s] \n " , lookipForSkillName . c_str ( ) ) ;
2011-01-29 04:35:55 +00:00
foundSkillName = true ;
2011-01-29 08:46:28 +00:00
2011-01-29 04:35:55 +00:00
if ( sn - > getChild ( " animation " ) ! = NULL ) {
2011-05-05 07:15:12 +00:00
skillModelFile = sn - > getChild ( " animation " ) - > getAttribute ( " path " ) - > getRestrictedValue ( unitPath + ' / ' ) ;
2011-01-29 08:46:28 +00:00
printf ( " Found skill model [%s] \n " , skillModelFile . c_str ( ) ) ;
2011-01-29 03:53:05 +00:00
}
2011-01-29 04:35:55 +00:00
if ( sn - > hasChild ( " particles " ) = = true ) {
const XmlNode * particlesNode = sn - > getChild ( " particles " ) ;
//for(int j = 0; particlesNode != NULL && particlesNode->getAttribute("value")->getRestrictedValue() == "true" &&
// j < particlesNode->getChildCount(); ++j) {
if ( particlesNode ! = NULL & & particlesNode - > getAttribute ( " value " ) - > getRestrictedValue ( ) = = " true " & &
particlesNode - > hasChild ( " particle-file " ) = = true ) {
const XmlNode * pf = particlesNode - > getChild ( " particle-file " ) ;
if ( pf ! = NULL ) {
skillParticleFile = unitPath + ' / ' + pf - > getAttribute ( " path " ) - > getRestrictedValue ( ) ;
2011-05-05 07:15:12 +00:00
printf ( " Found skill particle [%s] \n " , skillParticleFile . c_str ( ) ) ;
2011-01-29 04:35:55 +00:00
}
}
2011-01-29 03:53:05 +00:00
}
2011-01-29 04:35:55 +00:00
if ( sn - > hasChild ( " projectile " ) = = true ) {
const XmlNode * particlesProjectileNode = sn - > getChild ( " projectile " ) ;
//for(int j = 0; particlesProjectileNode != NULL && particlesProjectileNode->getAttribute("value")->getRestrictedValue() == "true" &&
// j < particlesProjectileNode->getChildCount(); ++j) {
if ( particlesProjectileNode ! = NULL & & particlesProjectileNode - > getAttribute ( " value " ) - > getRestrictedValue ( ) = = " true " & &
particlesProjectileNode - > hasChild ( " particle " ) = = true ) {
const XmlNode * pf = particlesProjectileNode - > getChild ( " particle " ) ;
if ( pf ! = NULL & & pf - > getAttribute ( " value " ) - > getRestrictedValue ( ) = = " true " ) {
skillParticleProjectileFile = unitPath + ' / ' + pf - > getAttribute ( " path " ) - > getRestrictedValue ( ) ;
2011-01-29 08:46:28 +00:00
printf ( " Found skill skill projectile particle [%s] \n " , skillParticleProjectileFile . c_str ( ) ) ;
2011-01-29 04:35:55 +00:00
}
}
}
if ( sn - > hasChild ( " splash " ) = = true ) {
const XmlNode * particlesSplashNode = sn - > getChild ( " splash " ) ;
//for(int j = 0; particlesSplashNode != NULL && particlesSplashNode->getAttribute("value")->getRestrictedValue() == "true" &&
// j < particlesSplashNode->getChildCount(); ++j) {
if ( particlesSplashNode ! = NULL & & particlesSplashNode - > getAttribute ( " value " ) - > getRestrictedValue ( ) = = " true " & &
particlesSplashNode - > hasChild ( " particle " ) = = true ) {
const XmlNode * pf = particlesSplashNode - > getChild ( " particle " ) ;
if ( pf ! = NULL & & pf - > getAttribute ( " value " ) - > getRestrictedValue ( ) = = " true " ) {
skillParticleSplashFile = unitPath + ' / ' + pf - > getAttribute ( " path " ) - > getRestrictedValue ( ) ;
2011-01-29 08:46:28 +00:00
printf ( " Found skill skill splash particle [%s] \n " , skillParticleSplashFile . c_str ( ) ) ;
2011-01-29 04:35:55 +00:00
}
}
2011-01-29 03:53:05 +00:00
}
}
}
}
if ( skillModelFile ! = " " ) {
this - > modelPathList . push_back ( skillModelFile ) ;
2011-01-29 08:46:28 +00:00
printf ( " Added skill model [%s] \n " , skillModelFile . c_str ( ) ) ;
2011-01-29 03:53:05 +00:00
}
if ( skillParticleFile ! = " " ) {
this - > particlePathList . push_back ( skillParticleFile ) ;
2011-01-29 08:46:28 +00:00
printf ( " Added skill particle [%s] \n " , skillParticleFile . c_str ( ) ) ;
2011-01-29 03:53:05 +00:00
}
if ( skillParticleProjectileFile ! = " " ) {
this - > particleProjectilePathList . push_back ( skillParticleProjectileFile ) ;
2011-01-29 08:46:28 +00:00
printf ( " Added skill projectile particle [%s] \n " , skillParticleProjectileFile . c_str ( ) ) ;
2011-01-29 03:53:05 +00:00
}
if ( skillParticleSplashFile ! = " " ) {
this - > particleSplashPathList . push_back ( skillParticleSplashFile ) ;
2011-01-29 08:46:28 +00:00
printf ( " Added skill splash particle [%s] \n " , skillParticleSplashFile . c_str ( ) ) ;
2011-01-29 03:53:05 +00:00
}
}
SetTitle ( ToUnicode ( titlestring ) ) ;
}
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-29 03:53:05 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Not a Mega-Glest particle XML file, or broken " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
2010-05-25 18:06:42 +00:00
void MainWindow : : loadModel ( string path ) {
2011-01-21 01:53:58 +00:00
try {
if ( path ! = " " & & fileExists ( path ) = = true ) {
this - > modelPathList . push_back ( path ) ;
2012-11-10 06:37:23 +00:00
printf ( " Adding model [%s] list size " MG_SIZE_T_SPECIFIER " \n " , path . c_str ( ) , this - > modelPathList . size ( ) ) ;
2011-01-21 01:53:58 +00:00
}
2011-01-13 19:27:26 +00:00
2011-01-21 01:53:58 +00:00
string titlestring = winHeader ;
for ( unsigned int idx = 0 ; idx < this - > modelPathList . size ( ) ; idx + + ) {
string modelPath = this - > modelPathList [ idx ] ;
2012-11-10 06:37:23 +00:00
//printf("Loading model [%s] %u of " MG_SIZE_T_SPECIFIER "\n",modelPath.c_str(),idx, this->modelPathList.size());
2011-01-29 08:46:28 +00:00
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
2014-12-23 20:39:03 -08:00
//delete model;
if ( model ! = NULL & & renderer ! = NULL ) renderer - > endModel ( rsGlobal , model ) ;
model = NULL ;
2013-12-05 16:17:41 +01:00
model = renderer ? renderer - > newModel ( rsGlobal , modelPath ) : NULL ;
2011-01-21 01:53:58 +00:00
statusbarText = getModelInfo ( ) ;
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-21 01:53:58 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Start ( 100 ) ;
2011-01-21 01:53:58 +00:00
titlestring = extractFileFromDirectoryPath ( modelPath ) + " - " + titlestring ;
}
SetTitle ( ToUnicode ( titlestring ) ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-21 01:53:58 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-03-13 10:39:22 +00:00
}
}
2010-05-25 18:06:42 +00:00
void MainWindow : : loadParticle ( string path ) {
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
2012-05-11 16:05:26 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] about to load [%s] \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , path . c_str ( ) ) ;
2010-05-25 18:06:42 +00:00
if ( path ! = " " & & fileExists ( path ) = = true ) {
2010-06-24 17:47:28 +00:00
renderer - > end ( ) ;
unitParticleSystems . clear ( ) ;
unitParticleSystemTypes . clear ( ) ;
2010-06-24 10:52:58 +00:00
2010-06-24 14:00:20 +00:00
if ( isControlKeyPressed = = true ) {
2010-12-03 05:07:42 +00:00
// std::cout << "Adding to list..." << std::endl;
2010-06-24 14:00:20 +00:00
this - > particlePathList . push_back ( path ) ;
}
else {
2010-12-03 05:07:42 +00:00
// std::cout << "Clearing list..." << std::endl;
2010-06-24 14:00:20 +00:00
this - > particlePathList . clear ( ) ;
this - > particlePathList . push_back ( path ) ;
}
2012-05-11 16:05:26 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] added file [%s] \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , path . c_str ( ) ) ;
2010-06-24 17:47:28 +00:00
}
2010-05-25 18:06:42 +00:00
2012-05-11 16:05:26 +00:00
try {
2011-08-31 23:10:43 +00:00
if ( this - > particlePathList . empty ( ) = = false ) {
2010-12-03 05:07:42 +00:00
string titlestring = winHeader ;
2010-10-21 07:20:17 +00:00
for ( unsigned int idx = 0 ; idx < this - > particlePathList . size ( ) ; idx + + ) {
2010-06-24 17:47:28 +00:00
string particlePath = this - > particlePathList [ idx ] ;
string dir = extractDirectoryPathFromFile ( particlePath ) ;
2010-05-25 18:06:42 +00:00
2010-06-24 17:47:28 +00:00
size_t pos = dir . find_last_of ( folderDelimiter ) ;
2011-01-29 08:46:28 +00:00
if ( pos = = dir . length ( ) - 1 & & dir . length ( ) > 0 ) {
2010-06-24 17:47:28 +00:00
dir . erase ( dir . length ( ) - 1 ) ;
}
2010-05-25 18:06:42 +00:00
2010-06-24 17:47:28 +00:00
particlePath = extractFileFromDirectoryPath ( particlePath ) ;
2010-12-03 05:07:42 +00:00
titlestring = particlePath + " - " + titlestring ;
2010-05-25 18:06:42 +00:00
2010-06-24 17:47:28 +00:00
std : : string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath ( dir ) + " .xml " ;
2010-05-25 18:06:42 +00:00
2012-05-11 16:05:26 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] looking for unit XML [%s] \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , unitXML . c_str ( ) ) ;
2011-08-31 23:10:43 +00:00
//int size = -1;
//int height = -1;
2012-05-11 16:05:26 +00:00
int size = 0 ;
int height = 0 ;
2010-05-25 18:06:42 +00:00
2010-06-24 17:47:28 +00:00
if ( fileExists ( unitXML ) = = true ) {
2012-01-06 18:04:01 +00:00
{
2010-06-24 17:47:28 +00:00
XmlTree xmlTree ;
2011-05-06 22:12:16 +00:00
xmlTree . load ( unitXML , Properties : : getTagReplacementValues ( ) ) ;
2010-06-24 17:47:28 +00:00
const XmlNode * unitNode = xmlTree . getRootNode ( ) ;
const XmlNode * parametersNode = unitNode - > getChild ( " parameters " ) ;
//size
2012-01-06 18:04:01 +00:00
size = parametersNode - > getChild ( " size " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
2010-06-24 17:47:28 +00:00
//height
2012-01-06 18:04:01 +00:00
height = parametersNode - > getChild ( " height " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
}
2010-05-25 18:06:42 +00:00
2011-01-29 08:46:28 +00:00
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
2012-05-11 16:05:26 +00:00
}
else {
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] unit XML NOT FOUND [%s] using default position values \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , unitXML . c_str ( ) ) ;
2011-01-29 08:46:28 +00:00
2012-09-22 20:37:42 +00:00
size = 1 ;
height = 1 ;
2012-05-11 16:05:26 +00:00
}
std : : map < string , vector < pair < string , string > > > loadedFileList ;
UnitParticleSystemType * unitParticleSystemType = new UnitParticleSystemType ( ) ;
unitParticleSystemType - > load ( NULL , dir , dir + folderDelimiter + particlePath , //### if we knew which particle it was, we could be more accurate
renderer , loadedFileList , " g3dviewer " , " " ) ;
unitParticleSystemTypes . push_back ( unitParticleSystemType ) ;
for ( std : : vector < UnitParticleSystemType * > : : const_iterator it = unitParticleSystemTypes . begin ( ) ; it ! = unitParticleSystemTypes . end ( ) ; + + it ) {
UnitParticleSystem * ups = new UnitParticleSystem ( 200 ) ;
2014-11-18 21:38:46 -08:00
ups - > setParticleType ( ( * it ) ) ;
2012-05-11 16:05:26 +00:00
( * it ) - > setValues ( ups ) ;
if ( size > 0 ) {
//getCurrVectorFlat() + Vec3f(0.f, type->getHeight()/2.f, 0.f);
2013-10-02 20:22:10 +00:00
Vec3f vec = Vec3f ( 0.f , height / 2.f , 0.f ) ;
2012-05-11 16:05:26 +00:00
ups - > setPos ( vec ) ;
2011-01-29 08:46:28 +00:00
}
2012-05-11 16:05:26 +00:00
//ups->setFactionColor(getFaction()->getTexture()->getPixmap()->getPixel3f(0,0));
2013-09-26 16:37:32 +00:00
ups - > setFactionColor ( renderer - > getPlayerColorTexture ( playerColor ) - > getPixmap ( ) - > getPixel3f ( 0 , 0 ) ) ;
2012-05-11 16:05:26 +00:00
unitParticleSystems . push_back ( ups ) ;
renderer - > manageParticleSystem ( ups ) ;
ups - > setVisible ( true ) ;
}
2011-01-29 08:46:28 +00:00
2012-05-11 16:05:26 +00:00
if ( path ! = " " & & fileExists ( path ) = = true ) {
renderer - > initModelManager ( ) ;
if ( initTextureManager ) {
renderer - > initTextureManager ( ) ;
2011-01-29 08:46:28 +00:00
}
2012-05-11 16:05:26 +00:00
}
2010-05-25 18:06:42 +00:00
}
2010-12-03 05:07:42 +00:00
SetTitle ( ToUnicode ( titlestring ) ) ;
2010-05-25 18:06:42 +00:00
}
2010-11-03 19:03:25 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2010-11-03 19:03:25 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
2011-01-20 19:47:33 +00:00
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Not a Mega-Glest particle XML file, or broken " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-11-03 19:03:25 +00:00
}
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Start ( 100 ) ;
2010-05-25 18:06:42 +00:00
}
2010-06-24 10:52:58 +00:00
void MainWindow : : loadProjectileParticle ( string path ) {
2012-11-10 06:37:23 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] about to load [%s] particleProjectilePathList.size() = " MG_SIZE_T_SPECIFIER " \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , path . c_str ( ) , this - > particleProjectilePathList . size ( ) ) ;
2012-01-06 18:04:01 +00:00
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
2010-06-24 10:52:58 +00:00
if ( path ! = " " & & fileExists ( path ) = = true ) {
2010-06-24 17:47:28 +00:00
renderer - > end ( ) ;
projectileParticleSystems . clear ( ) ;
projectileParticleSystemTypes . clear ( ) ;
2010-06-24 10:52:58 +00:00
2010-06-24 14:00:20 +00:00
if ( isControlKeyPressed = = true ) {
2010-12-03 05:07:42 +00:00
// std::cout << "Adding to list..." << std::endl;
2010-06-24 14:00:20 +00:00
this - > particleProjectilePathList . push_back ( path ) ;
}
else {
2010-12-03 05:07:42 +00:00
// std::cout << "Clearing list..." << std::endl;
2010-06-24 14:00:20 +00:00
this - > particleProjectilePathList . clear ( ) ;
this - > particleProjectilePathList . push_back ( path ) ;
}
2010-06-24 17:47:28 +00:00
}
2010-06-24 10:52:58 +00:00
2010-11-03 19:03:25 +00:00
try {
2011-08-31 23:10:43 +00:00
if ( this - > particleProjectilePathList . empty ( ) = = false ) {
2012-11-10 06:37:23 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " this->particleProjectilePathList.size() = " MG_SIZE_T_SPECIFIER " \n " , this - > particleProjectilePathList . size ( ) ) ;
2011-10-07 07:53:06 +00:00
2010-12-03 05:07:42 +00:00
string titlestring = winHeader ;
2010-10-21 07:20:17 +00:00
for ( unsigned int idx = 0 ; idx < this - > particleProjectilePathList . size ( ) ; idx + + ) {
2010-06-24 17:47:28 +00:00
string particlePath = this - > particleProjectilePathList [ idx ] ;
string dir = extractDirectoryPathFromFile ( particlePath ) ;
2010-06-24 10:52:58 +00:00
2010-06-24 17:47:28 +00:00
size_t pos = dir . find_last_of ( folderDelimiter ) ;
if ( pos = = dir . length ( ) - 1 ) {
dir . erase ( dir . length ( ) - 1 ) ;
}
2010-06-24 10:52:58 +00:00
2010-06-24 17:47:28 +00:00
particlePath = extractFileFromDirectoryPath ( particlePath ) ;
2010-12-03 05:07:42 +00:00
titlestring = particlePath + " - " + titlestring ;
2010-06-24 10:52:58 +00:00
2010-06-24 17:47:28 +00:00
std : : string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath ( dir ) + " .xml " ;
2010-06-24 10:52:58 +00:00
2012-05-11 16:05:26 +00:00
int size = 1 ;
int height = 1 ;
2010-06-24 10:52:58 +00:00
2010-06-24 17:47:28 +00:00
if ( fileExists ( unitXML ) = = true ) {
2012-10-06 07:06:40 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] loading [%s] idx = %u \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , unitXML . c_str ( ) , idx ) ;
2012-01-06 18:04:01 +00:00
2010-06-24 14:00:20 +00:00
XmlTree xmlTree ;
2011-05-06 22:12:16 +00:00
xmlTree . load ( unitXML , Properties : : getTagReplacementValues ( ) ) ;
2010-06-24 17:47:28 +00:00
const XmlNode * unitNode = xmlTree . getRootNode ( ) ;
const XmlNode * parametersNode = unitNode - > getChild ( " parameters " ) ;
//size
size = parametersNode - > getChild ( " size " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
//height
height = parametersNode - > getChild ( " height " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
}
2010-06-24 10:52:58 +00:00
2010-12-03 05:07:42 +00:00
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
2010-06-24 10:52:58 +00:00
2012-01-06 18:04:01 +00:00
string particleFile = dir + folderDelimiter + particlePath ;
2011-10-07 07:53:06 +00:00
{
2012-10-06 07:06:40 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] loading [%s] idx = %u \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , particleFile . c_str ( ) , idx ) ;
2012-01-06 18:04:01 +00:00
XmlTree xmlTree ;
xmlTree . load ( particleFile , Properties : : getTagReplacementValues ( ) ) ;
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
2010-06-24 10:52:58 +00:00
2012-01-06 18:04:01 +00:00
// std::cout << "Loaded successfully, loading values..." << std::endl;
2011-10-07 07:53:06 +00:00
}
2010-06-24 10:52:58 +00:00
2012-10-06 07:06:40 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] loading [%s] idx = %u \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , particleFile . c_str ( ) , idx ) ;
2011-05-06 07:47:31 +00:00
std : : map < string , vector < pair < string , string > > > loadedFileList ;
2010-06-24 17:47:28 +00:00
ParticleSystemTypeProjectile * projectileParticleSystemType = new ParticleSystemTypeProjectile ( ) ;
2011-07-06 22:23:51 +00:00
projectileParticleSystemType - > load ( NULL , dir , //### we don't know if there are overrides in the unit XML
2012-01-06 18:04:01 +00:00
particleFile , renderer , loadedFileList ,
2011-05-06 22:12:16 +00:00
" g3dviewer " , " " ) ;
2010-06-24 10:52:58 +00:00
2010-12-03 05:07:42 +00:00
// std::cout << "Values loaded, about to read..." << std::endl;
2010-06-24 10:52:58 +00:00
2010-06-24 17:47:28 +00:00
projectileParticleSystemTypes . push_back ( projectileParticleSystemType ) ;
2010-06-24 14:00:20 +00:00
2011-10-07 07:53:06 +00:00
for ( std : : vector < ParticleSystemTypeProjectile * > : : const_iterator it = projectileParticleSystemTypes . begin ( ) ;
it ! = projectileParticleSystemTypes . end ( ) ; + + it ) {
2010-06-24 14:00:20 +00:00
2013-09-23 17:16:34 +00:00
ProjectileParticleSystem * ps = ( * it ) - > create ( NULL ) ;
2010-06-24 10:52:58 +00:00
2010-06-24 17:47:28 +00:00
if ( size > 0 ) {
2013-10-02 20:22:10 +00:00
Vec3f vec = Vec3f ( 0.f , height / 2.f , 0.f ) ;
2010-06-24 17:47:28 +00:00
//ps->setPos(vec);
2010-06-24 14:00:20 +00:00
2013-10-02 20:22:10 +00:00
Vec3f vec2 = Vec3f ( size * 2.f , height * 2.f , height * 2.f ) ;
2013-09-26 16:37:32 +00:00
ps - > setPath ( vec , vec2 ) ;
2010-06-24 14:00:20 +00:00
}
2013-09-26 16:37:32 +00:00
ps - > setFactionColor ( renderer - > getPlayerColorTexture ( playerColor ) - > getPixmap ( ) - > getPixel3f ( 0 , 0 ) ) ;
2010-06-24 14:00:20 +00:00
2010-06-24 17:47:28 +00:00
projectileParticleSystems . push_back ( ps ) ;
ps - > setVisible ( true ) ;
renderer - > manageParticleSystem ( ps ) ;
2010-06-24 14:00:20 +00:00
}
2012-01-06 18:04:01 +00:00
2012-10-06 07:06:40 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] loaded [%s] idx = %u \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , particleFile . c_str ( ) , idx ) ;
2010-06-24 10:52:58 +00:00
}
2010-12-03 05:07:42 +00:00
SetTitle ( ToUnicode ( titlestring ) ) ;
2010-06-24 17:47:28 +00:00
if ( path ! = " " & & fileExists ( path ) = = true ) {
renderer - > initModelManager ( ) ;
2011-01-29 22:17:37 +00:00
if ( initTextureManager ) {
renderer - > initTextureManager ( ) ;
}
2010-06-24 17:47:28 +00:00
}
2010-06-24 10:52:58 +00:00
}
2010-11-03 19:03:25 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2010-11-03 19:03:25 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
2011-01-20 19:47:33 +00:00
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Not a Mega-Glest projectile particle XML file, or broken " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-11-03 19:03:25 +00:00
}
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Start ( 100 ) ;
2012-01-06 18:04:01 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] after load [%s] \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , path . c_str ( ) ) ;
2010-11-03 19:03:25 +00:00
}
void MainWindow : : loadSplashParticle ( string path ) { // uses ParticleSystemTypeSplash::load (and own list...)
2012-11-10 06:37:23 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] about to load [%s] particleSplashPathList.size() = " MG_SIZE_T_SPECIFIER " \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , path . c_str ( ) , this - > particleSplashPathList . size ( ) ) ;
2012-01-06 18:04:01 +00:00
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
2010-11-03 19:03:25 +00:00
if ( path ! = " " & & fileExists ( path ) = = true ) {
renderer - > end ( ) ;
splashParticleSystems . clear ( ) ;
2010-12-03 05:07:42 +00:00
splashParticleSystemTypes . clear ( ) ;
2010-11-03 19:03:25 +00:00
if ( isControlKeyPressed = = true ) {
2010-12-03 05:07:42 +00:00
// std::cout << "Adding to list..." << std::endl;
2010-11-03 19:03:25 +00:00
this - > particleSplashPathList . push_back ( path ) ;
}
else {
2010-12-03 05:07:42 +00:00
// std::cout << "Clearing list..." << std::endl;
2010-11-03 19:03:25 +00:00
this - > particleSplashPathList . clear ( ) ;
this - > particleSplashPathList . push_back ( path ) ;
}
}
try {
2011-08-31 23:10:43 +00:00
if ( this - > particleSplashPathList . empty ( ) = = false ) {
2010-12-03 05:07:42 +00:00
string titlestring = winHeader ;
2010-11-03 19:03:25 +00:00
for ( unsigned int idx = 0 ; idx < this - > particleSplashPathList . size ( ) ; idx + + ) {
string particlePath = this - > particleSplashPathList [ idx ] ;
string dir = extractDirectoryPathFromFile ( particlePath ) ;
size_t pos = dir . find_last_of ( folderDelimiter ) ;
if ( pos = = dir . length ( ) - 1 ) {
dir . erase ( dir . length ( ) - 1 ) ;
}
particlePath = extractFileFromDirectoryPath ( particlePath ) ;
2010-12-03 05:07:42 +00:00
titlestring = particlePath + " - " + titlestring ;
2010-11-03 19:03:25 +00:00
std : : string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath ( dir ) + " .xml " ;
2012-05-11 16:05:26 +00:00
int size = 1 ;
2013-11-19 06:14:06 +00:00
//int height = 1;
2010-11-03 19:03:25 +00:00
if ( fileExists ( unitXML ) = = true ) {
XmlTree xmlTree ;
2011-05-06 22:12:16 +00:00
xmlTree . load ( unitXML , Properties : : getTagReplacementValues ( ) ) ;
2010-11-03 19:03:25 +00:00
const XmlNode * unitNode = xmlTree . getRootNode ( ) ;
const XmlNode * parametersNode = unitNode - > getChild ( " parameters " ) ;
//size
size = parametersNode - > getChild ( " size " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
//height
2013-11-19 06:14:06 +00:00
//height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
2010-11-03 19:03:25 +00:00
}
2010-12-03 05:07:42 +00:00
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
2010-11-03 19:03:25 +00:00
2012-01-06 18:04:01 +00:00
{
XmlTree xmlTree ;
xmlTree . load ( dir + folderDelimiter + particlePath , Properties : : getTagReplacementValues ( ) ) ;
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl;
}
2010-11-03 19:03:25 +00:00
2011-05-06 07:47:31 +00:00
std : : map < string , vector < pair < string , string > > > loadedFileList ;
2010-12-03 05:07:42 +00:00
ParticleSystemTypeSplash * splashParticleSystemType = new ParticleSystemTypeSplash ( ) ;
2011-07-06 22:23:51 +00:00
splashParticleSystemType - > load ( NULL , dir , dir + folderDelimiter + particlePath , renderer , //### we don't know if there are overrides in the unit XML
2011-05-06 22:12:16 +00:00
loadedFileList , " g3dviewer " , " " ) ; // <---- only that must be splash...
2010-11-03 19:03:25 +00:00
2010-12-03 05:07:42 +00:00
// std::cout << "Values loaded, about to read..." << std::endl;
2010-11-03 19:03:25 +00:00
splashParticleSystemTypes . push_back ( splashParticleSystemType ) ;
//ParticleSystemTypeSplash
for ( std : : vector < ParticleSystemTypeSplash * > : : const_iterator it = splashParticleSystemTypes . begin ( ) ; it ! = splashParticleSystemTypes . end ( ) ; + + it ) {
2013-09-23 17:16:34 +00:00
SplashParticleSystem * ps = ( * it ) - > create ( NULL ) ;
2010-11-03 19:03:25 +00:00
if ( size > 0 ) {
2013-11-19 06:14:06 +00:00
//Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
2010-11-03 19:03:25 +00:00
//ps->setPos(vec);
//Vec3f vec2 = Vec3f(size * 2.f, height * 2.f, height * 2.f); // <------- removed relative projectile
//ps->setPath(vec, vec2); // <------- removed relative projectile
}
2013-09-26 16:37:32 +00:00
ps - > setFactionColor ( renderer - > getPlayerColorTexture ( playerColor ) - > getPixmap ( ) - > getPixel3f ( 0 , 0 ) ) ;
2010-11-03 19:03:25 +00:00
splashParticleSystems . push_back ( ps ) ;
ps - > setVisible ( true ) ;
renderer - > manageParticleSystem ( ps ) ;
}
}
2010-12-03 05:07:42 +00:00
SetTitle ( ToUnicode ( titlestring ) ) ;
2010-11-03 19:03:25 +00:00
if ( path ! = " " & & fileExists ( path ) = = true ) {
renderer - > initModelManager ( ) ;
2011-01-29 22:17:37 +00:00
if ( initTextureManager ) {
renderer - > initTextureManager ( ) ;
}
2010-11-03 19:03:25 +00:00
}
}
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2010-11-03 19:03:25 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
2011-01-20 19:47:33 +00:00
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Not a Mega-Glest projectile particle XML file, or broken " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-11-03 19:03:25 +00:00
}
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Start ( 100 ) ;
2012-11-10 06:37:23 +00:00
if ( SystemFlags : : VERBOSE_MODE_ENABLED ) printf ( " In [%s::%s Line: %d] after load [%s] particleSplashPathList.size() = " MG_SIZE_T_SPECIFIER " \n " , extractFileFromDirectoryPath ( __FILE__ ) . c_str ( ) , __FUNCTION__ , __LINE__ , path . c_str ( ) , this - > particleSplashPathList . size ( ) ) ;
2010-06-24 10:52:58 +00:00
}
2010-03-13 10:39:22 +00:00
void MainWindow : : onMenuModeNormals ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
renderer - > toggleNormals ( ) ;
menuMode - > Check ( miModeNormals , renderer - > getNormals ( ) ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-03-13 10:39:22 +00:00
}
void MainWindow : : onMenuModeWireframe ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
renderer - > toggleWireframe ( ) ;
menuMode - > Check ( miModeWireframe , renderer - > getWireframe ( ) ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-03-13 10:39:22 +00:00
}
void MainWindow : : onMenuModeGrid ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
renderer - > toggleGrid ( ) ;
menuMode - > Check ( miModeGrid , renderer - > getGrid ( ) ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-03-13 10:39:22 +00:00
}
void MainWindow : : onMenuSpeedSlower ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
speed / = 1.5f ;
if ( speed < 0 ) {
speed = 0 ;
}
2011-01-13 19:27:26 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-20 19:47:33 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-03-13 10:39:22 +00:00
}
void MainWindow : : onMenuSpeedFaster ( wxCommandEvent & event ) {
2011-01-20 19:47:33 +00:00
try {
speed * = 1.5f ;
if ( speed > 1 ) {
speed = 1 ;
}
2011-01-13 19:27:26 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-20 19:47:33 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-03-13 10:39:22 +00:00
}
2010-11-03 19:03:25 +00:00
// set menu checkboxes to what player color is used
2011-01-20 19:47:33 +00:00
void MainWindow : : onMenuColorRed ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcRed ;
menuCustomColor - > Check ( miColorRed , true ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorBlue ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcBlue ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , true ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorGreen ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcGreen ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , true ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorYellow ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcYellow ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , true ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorWhite ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcWhite ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , true ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorCyan ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcCyan ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , true ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorOrange ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcOrange ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , true ) ;
menuCustomColor - > Check ( miColorMagenta , false ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onMenuColorMagenta ( wxCommandEvent & event ) {
try {
playerColor = Renderer : : pcMagenta ;
menuCustomColor - > Check ( miColorRed , false ) ;
menuCustomColor - > Check ( miColorBlue , false ) ;
menuCustomColor - > Check ( miColorGreen , false ) ;
menuCustomColor - > Check ( miColorYellow , false ) ;
menuCustomColor - > Check ( miColorWhite , false ) ;
menuCustomColor - > Check ( miColorCyan , false ) ;
menuCustomColor - > Check ( miColorOrange , false ) ;
menuCustomColor - > Check ( miColorMagenta , true ) ;
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
}
void MainWindow : : onTimer ( wxTimerEvent & event ) {
2011-01-13 19:27:26 +00:00
anim = anim + speed ;
if ( anim > 1.0f ) {
anim - = 1.f ;
2011-01-29 03:53:05 +00:00
resetAnimation = true ;
2010-03-13 10:39:22 +00:00
}
2011-01-28 05:49:52 +00:00
wxPaintEvent paintEvent ;
2010-03-13 10:39:22 +00:00
onPaint ( paintEvent ) ;
}
2011-01-20 19:47:33 +00:00
string MainWindow : : getModelInfo ( ) {
2010-03-13 10:39:22 +00:00
string str ;
2014-12-23 20:39:03 -08:00
if ( model ! = NULL ) {
2010-03-13 10:39:22 +00:00
str + = " Meshes: " + intToStr ( model - > getMeshCount ( ) ) ;
str + = " , Vertices: " + intToStr ( model - > getVertexCount ( ) ) ;
str + = " , Triangles: " + intToStr ( model - > getTriangleCount ( ) ) ;
str + = " , Version: " + intToStr ( model - > getFileVersion ( ) ) ;
}
return str ;
}
2010-05-25 18:06:42 +00:00
void MainWindow : : onKeyDown ( wxKeyEvent & e ) {
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
try {
// std::cout << "e.ControlDown() = " << e.ControlDown() << " e.GetKeyCode() = " << e.GetKeyCode() << " isCtrl = " << (e.GetKeyCode() == WXK_CONTROL) << std::endl;
2010-06-24 17:47:28 +00:00
2011-01-29 08:46:28 +00:00
// Note: This ctrl-key handling is buggy since it never resets when ctrl is released later, so I reset it at end of loadcommands for now.
2011-01-20 19:47:33 +00:00
if ( e . ControlDown ( ) = = true | | e . GetKeyCode ( ) = = WXK_CONTROL ) {
isControlKeyPressed = true ;
}
else {
isControlKeyPressed = false ;
}
2010-06-24 14:00:20 +00:00
2011-01-20 19:47:33 +00:00
// std::cout << "isControlKeyPressed = " << isControlKeyPressed << std::endl;
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
// here also because + and - hotkeys don't work for numpad automaticly
if ( e . GetKeyCode ( ) = = 388 ) {
speed * = 1.5f ; //numpad+
if ( speed > 1.0 ) {
speed = 1.0 ;
}
2011-01-13 19:27:26 +00:00
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-20 19:47:33 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
2011-01-13 19:27:26 +00:00
}
2011-01-20 19:47:33 +00:00
else if ( e . GetKeyCode ( ) = = 390 ) {
speed / = 1.5f ; //numpad-
if ( speed < 0 ) {
speed = 0 ;
}
2011-07-02 21:44:29 +00:00
string statusTextValue = statusbarText + " animation speed: " + floatToStr ( speed * 1000.0 ) + " anim value: " + floatToStr ( anim ) + " zoom: " + floatToStr ( zoom ) + " rotX: " + floatToStr ( rotX ) + " rotY: " + floatToStr ( rotY ) ;
2011-01-20 19:47:33 +00:00
GetStatusBar ( ) - > SetStatusText ( ToUnicode ( statusTextValue . c_str ( ) ) ) ;
}
2011-01-29 08:46:28 +00:00
else if ( e . GetKeyCode ( ) = = ' W ' ) {
2011-01-20 19:47:33 +00:00
glClearColor ( 0.6f , 0.6f , 0.6f , 1.0f ) ; //w key //backgroundcolor constant 0.3 -> 0.6
2010-12-03 05:07:42 +00:00
2011-01-20 19:47:33 +00:00
}
2010-12-03 05:07:42 +00:00
2011-01-20 19:47:33 +00:00
// some posibility to adjust brightness:
/*
else if ( e . GetKeyCode ( ) = = 322 ) { // Ins - Grid
gridBrightness + = 0.1f ; if ( gridBrightness > 1.0 ) gridBrightness = 1.0 ;
}
else if ( e . GetKeyCode ( ) = = 127 ) { // Del
gridBrightness - = 0.1f ; if ( gridBrightness < 0 ) gridBrightness = 0 ;
}
*/
else if ( e . GetKeyCode ( ) = = 313 ) { // Home - Background
backBrightness + = 0.1f ; if ( backBrightness > 1.0 ) backBrightness = 1.0 ;
glClearColor ( backBrightness , backBrightness , backBrightness , 1.0f ) ;
}
else if ( e . GetKeyCode ( ) = = 312 ) { // End
backBrightness - = 0.1f ; if ( backBrightness < 0 ) backBrightness = 0 ;
glClearColor ( backBrightness , backBrightness , backBrightness , 1.0f ) ;
}
else if ( e . GetKeyCode ( ) = = 366 ) { // PgUp - Lightning of model
lightBrightness + = 0.1f ; if ( lightBrightness > 1.0 ) lightBrightness = 1.0 ;
Vec4f ambientNEW = Vec4f ( lightBrightness , lightBrightness , lightBrightness , 1.0f ) ;
glLightfv ( GL_LIGHT0 , GL_AMBIENT , ambientNEW . ptr ( ) ) ;
}
else if ( e . GetKeyCode ( ) = = 367 ) { // pgDn
lightBrightness - = 0.1f ; if ( lightBrightness < 0 ) lightBrightness = 0 ;
Vec4f ambientNEW = Vec4f ( lightBrightness , lightBrightness , lightBrightness , 1.0f ) ;
glLightfv ( GL_LIGHT0 , GL_AMBIENT , ambientNEW . ptr ( ) ) ;
}
2011-01-29 08:46:28 +00:00
std : : cout < < " pressed " < < e . GetKeyCode ( ) < < std : : endl ;
2010-12-03 05:07:42 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2010-12-03 05:07:42 +00:00
}
2010-11-03 19:03:25 +00:00
}
2010-05-25 18:06:42 +00:00
2011-01-20 19:47:33 +00:00
void MainWindow : : onMenuRestart ( wxCommandEvent & event ) {
try {
// std::cout << "pressed R (restart particle animation)" << std::endl;
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Stop ( ) ;
if ( renderer ) renderer - > end ( ) ;
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
unitParticleSystems . clear ( ) ;
unitParticleSystemTypes . clear ( ) ;
projectileParticleSystems . clear ( ) ;
projectileParticleSystemTypes . clear ( ) ;
splashParticleSystems . clear ( ) ; // as above
splashParticleSystemTypes . clear ( ) ;
2010-05-25 18:06:42 +00:00
2011-01-29 03:53:05 +00:00
loadUnit ( " " , " " ) ;
2011-01-20 19:47:33 +00:00
loadModel ( " " ) ;
loadParticle ( " " ) ;
loadProjectileParticle ( " " ) ;
loadSplashParticle ( " " ) ; // as above
2010-06-24 17:47:28 +00:00
2011-01-20 19:47:33 +00:00
renderer - > initModelManager ( ) ;
2011-01-29 22:17:37 +00:00
if ( initTextureManager ) {
renderer - > initTextureManager ( ) ;
}
2011-01-29 22:59:33 +00:00
if ( timer ) timer - > Start ( 100 ) ;
2011-01-20 19:47:33 +00:00
}
2011-08-31 23:10:43 +00:00
catch ( std : : runtime_error & e ) {
2011-01-20 19:47:33 +00:00
std : : cout < < e . what ( ) < < std : : endl ;
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Error " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
}
2010-05-25 18:06:42 +00:00
}
2010-03-13 10:39:22 +00:00
BEGIN_EVENT_TABLE ( MainWindow , wxFrame )
EVT_TIMER ( - 1 , MainWindow : : onTimer )
EVT_CLOSE ( MainWindow : : onClose )
EVT_MENU ( miFileLoad , MainWindow : : onMenuFileLoad )
2010-05-25 18:06:42 +00:00
EVT_MENU ( miFileLoadParticleXML , MainWindow : : onMenuFileLoadParticleXML )
2010-06-24 10:52:58 +00:00
EVT_MENU ( miFileLoadProjectileParticleXML , MainWindow : : onMenuFileLoadProjectileParticleXML )
2010-11-03 19:03:25 +00:00
EVT_MENU ( miFileLoadSplashParticleXML , MainWindow : : onMenuFileLoadSplashParticleXML )
2010-06-24 14:00:20 +00:00
EVT_MENU ( miFileClearAll , MainWindow : : onMenuFileClearAll )
2011-01-21 16:34:33 +00:00
EVT_MENU ( miFileToggleScreenshotTransparent , MainWindow : : onMenumFileToggleScreenshotTransparent )
2011-01-20 18:05:07 +00:00
EVT_MENU ( miFileSaveScreenshot , MainWindow : : onMenuFileSaveScreenshot )
2010-11-03 19:03:25 +00:00
EVT_MENU ( wxID_EXIT , MainWindow : : onMenuFileExit )
2010-03-13 10:39:22 +00:00
EVT_MENU ( miModeWireframe , MainWindow : : onMenuModeWireframe )
EVT_MENU ( miModeNormals , MainWindow : : onMenuModeNormals )
EVT_MENU ( miModeGrid , MainWindow : : onMenuModeGrid )
EVT_MENU ( miSpeedFaster , MainWindow : : onMenuSpeedFaster )
EVT_MENU ( miSpeedSlower , MainWindow : : onMenuSpeedSlower )
2010-11-03 19:03:25 +00:00
EVT_MENU ( miRestart , MainWindow : : onMenuRestart )
2010-03-13 10:39:22 +00:00
EVT_MENU ( miColorRed , MainWindow : : onMenuColorRed )
EVT_MENU ( miColorBlue , MainWindow : : onMenuColorBlue )
EVT_MENU ( miColorGreen , MainWindow : : onMenuColorGreen )
2010-11-03 19:03:25 +00:00
EVT_MENU ( miColorYellow , MainWindow : : onMenuColorYellow )
EVT_MENU ( miColorWhite , MainWindow : : onMenuColorWhite )
EVT_MENU ( miColorCyan , MainWindow : : onMenuColorCyan )
EVT_MENU ( miColorOrange , MainWindow : : onMenuColorOrange )
EVT_MENU ( miColorMagenta , MainWindow : : onMenuColorMagenta )
2011-01-20 18:05:07 +00:00
EVT_MENU ( miChangeBackgroundColor , MainWindow : : OnChangeColor )
2010-03-13 10:39:22 +00:00
END_EVENT_TABLE ( )
// =====================================================
// class GlCanvas
// =====================================================
2010-05-25 18:06:42 +00:00
void translateCoords ( wxWindow * wnd , int & x , int & y ) {
# ifdef WIN32
int cx , cy ;
wnd - > GetPosition ( & cx , & cy ) ;
x + = cx ;
y + = cy ;
# endif
}
2010-12-03 05:07:42 +00:00
// to prevent flicker
GlCanvas : : GlCanvas ( MainWindow * mainWindow , int * args )
2011-03-20 06:05:09 +00:00
# if wxCHECK_VERSION(2, 9, 1)
2015-10-26 19:49:25 -07:00
: wxGLCanvas ( mainWindow , wxID_ANY , args , wxDefaultPosition , mainWindow - > GetClientSize ( ) , wxFULL_REPAINT_ON_RESIZE , wxT ( " GLCanvas " ) ) {
this - > context = new wxGLContext ( this ) ;
2011-03-20 06:05:09 +00:00
# else
2010-12-03 05:07:42 +00:00
: wxGLCanvas ( mainWindow , - 1 , wxDefaultPosition , wxDefaultSize , 0 , wxT ( " GLCanvas " ) , args ) {
2011-03-20 06:05:09 +00:00
this - > context = NULL ;
# endif
2010-12-03 05:07:42 +00:00
this - > mainWindow = mainWindow ;
2011-03-20 06:05:09 +00:00
}
GlCanvas : : ~ GlCanvas ( ) {
2015-10-26 19:49:25 -07:00
if ( this - > context ) {
delete this - > context ;
}
2011-03-20 06:05:09 +00:00
this - > context = NULL ;
}
void GlCanvas : : setCurrentGLContext ( ) {
2011-10-18 01:13:38 +00:00
# ifndef __APPLE__
2013-11-17 07:37:13 +00:00
2015-10-26 19:49:25 -07:00
# if wxCHECK_VERSION(3, 0, 0)
//printf("Setting glcontext 3x!\n");
//if(!IsShown()) {}
if ( this - > context = = NULL ) {
//printf("Make new ctx!\n");
this - > context = new wxGLContext ( this ) ;
//printf("Set ctx [%p]\n",this->context);
}
# elif wxCHECK_VERSION(2, 9, 1)
//printf("Setting glcontext 29x!\n");
//if(!IsShown()) {}
2013-11-17 07:37:13 +00:00
if ( this - > context = = NULL ) {
this - > context = new wxGLContext ( this ) ;
2014-11-28 23:35:35 -08:00
//printf("Set ctx [%p]\n",this->context);
2013-11-17 07:37:13 +00:00
}
# endif
2013-06-03 06:10:16 +00:00
//printf("Set ctx [%p]\n",this->context);
2011-03-20 06:05:09 +00:00
if ( this - > context ) {
2013-06-03 06:10:16 +00:00
wxGLCanvas : : SetCurrent ( * this - > context ) ;
2014-11-28 23:35:35 -08:00
//printf("Set ctx2 [%p]\n",this->context);
2011-03-20 06:05:09 +00:00
}
2011-10-18 01:13:38 +00:00
# else
this - > SetCurrent ( ) ;
# endif
2010-12-03 05:07:42 +00:00
}
2010-11-03 19:03:25 +00:00
// for the mousewheel
void GlCanvas : : onMouseWheel ( wxMouseEvent & event ) {
if ( event . GetWheelRotation ( ) > 0 ) mainWindow - > onMouseWheelDown ( event ) ;
else mainWindow - > onMouseWheelUp ( event ) ;
}
2010-03-13 10:39:22 +00:00
void GlCanvas : : onMouseMove ( wxMouseEvent & event ) {
mainWindow - > onMouseMove ( event ) ;
}
2010-05-25 18:06:42 +00:00
void GlCanvas : : onKeyDown ( wxKeyEvent & event ) {
int x , y ;
event . GetPosition ( & x , & y ) ;
translateCoords ( this , x , y ) ;
mainWindow - > onKeyDown ( event ) ;
}
2015-10-26 19:49:25 -07:00
void GlCanvas : : OnSize ( wxSizeEvent & event ) {
//printf("OnSize %dx%d\n",event.m_size.GetWidth(),event.m_size.GetHeight());
Update ( ) ;
}
2010-11-03 19:03:25 +00:00
// EVT_SPIN_DOWN(GlCanvas::onMouseDown)
// EVT_SPIN_UP(GlCanvas::onMouseDown)
// EVT_MIDDLE_DOWN(GlCanvas::onMouseWheel)
// EVT_MIDDLE_UP(GlCanvas::onMouseWheel)
2010-03-13 10:39:22 +00:00
BEGIN_EVENT_TABLE ( GlCanvas , wxGLCanvas )
2010-11-03 19:03:25 +00:00
EVT_MOUSEWHEEL ( GlCanvas : : onMouseWheel )
2010-03-13 10:39:22 +00:00
EVT_MOTION ( GlCanvas : : onMouseMove )
2010-05-25 18:06:42 +00:00
EVT_KEY_DOWN ( GlCanvas : : onKeyDown )
2015-10-26 19:49:25 -07:00
EVT_SIZE ( GlCanvas : : OnSize )
2010-03-13 10:39:22 +00:00
END_EVENT_TABLE ( )
// ===============================================
// class App
// ===============================================
2011-05-03 23:34:25 +00:00
bool App : : OnInit ( ) {
2011-12-03 08:54:18 +00:00
SystemFlags : : VERBOSE_MODE_ENABLED = false ;
2013-11-17 07:37:13 +00:00
# if defined(wxMAJOR_VERSION) && defined(wxMINOR_VERSION) && defined(wxRELEASE_NUMBER) && defined(wxSUBRELEASE_NUMBER)
printf ( " Using wxWidgets version [%d.%d.%d.%d] \n " , wxMAJOR_VERSION , wxMINOR_VERSION , wxRELEASE_NUMBER , wxSUBRELEASE_NUMBER ) ;
# endif
2011-05-03 23:34:25 +00:00
2011-01-28 05:49:52 +00:00
string modelPath = " " ;
string particlePath = " " ;
string projectileParticlePath = " " ;
string splashParticlePath = " " ;
2011-01-28 01:41:30 +00:00
bool foundInvalidArgs = false ;
const int knownArgCount = sizeof ( GAME_ARGS ) / sizeof ( GAME_ARGS [ 0 ] ) ;
for ( int idx = 1 ; idx < argc ; + + idx ) {
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( argv [ idx ] ) ;
if ( hasCommandArgument ( knownArgCount , ( wxChar * * ) & GAME_ARGS [ 0 ] , ( const char * ) tmp_buf , NULL , 0 , true ) = = false & &
argv [ idx ] [ 0 ] = = ' - ' ) {
foundInvalidArgs = true ;
printf ( " \n Invalid argument: %s " , ( const char * ) tmp_buf ) ;
2010-11-03 19:03:25 +00:00
}
2011-01-28 01:41:30 +00:00
}
if ( foundInvalidArgs = = true | |
hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_HELP ] ) ) = = true ) {
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , foundInvalidArgs ) ;
return false ;
}
2012-01-06 18:04:01 +00:00
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_VERBOSE ] ) ) = = true ) {
SystemFlags : : VERBOSE_MODE_ENABLED = true ;
}
2011-01-28 01:41:30 +00:00
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_AUTO_SCREENSHOT ] ) ) = = true ) {
autoScreenShotAndExit = true ;
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_AUTO_SCREENSHOT ] ) ;
//printf("param = [%s]\n",(const char*)param);
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string options = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( options , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
string optionsValue = paramPartTokens [ 1 ] ;
autoScreenShotParams . clear ( ) ;
Tokenize ( optionsValue , autoScreenShotParams , " , " ) ;
2011-05-23 19:23:00 +00:00
for ( unsigned int i = 0 ; i < autoScreenShotParams . size ( ) ; + + i ) {
2012-01-06 19:34:47 +00:00
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( autoScreenShotParams [ i ] . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
autoScreenShotParams [ i ] = utf8_encode ( wstr . get ( ) ) ;
2012-01-06 19:34:47 +00:00
# endif
2011-05-23 19:23:00 +00:00
2012-01-06 19:34:47 +00:00
if ( _strnicmp ( autoScreenShotParams [ i ] . c_str ( ) , " resize- " , 7 ) = = 0 ) {
printf ( " Screenshot option [%s] \n " , autoScreenShotParams [ i ] . c_str ( ) ) ;
string resize = autoScreenShotParams [ i ] ;
resize = resize . erase ( 0 , 7 ) ;
vector < string > values ;
Tokenize ( resize , values , " x " ) ;
overrideSize . first = strToInt ( values [ 0 ] ) ;
overrideSize . second = strToInt ( values [ 1 ] ) ;
2012-01-06 21:02:23 +00:00
Renderer : : windowX = 0 ;
Renderer : : windowY = 0 ;
2012-01-06 19:34:47 +00:00
Renderer : : windowW = overrideSize . first ;
Renderer : : windowH = overrideSize . second + 25 ;
}
}
2011-01-28 01:41:30 +00:00
}
}
2011-01-29 04:35:55 +00:00
std : : pair < string , vector < string > > unitToLoad ;
2011-01-29 03:53:05 +00:00
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_UNIT ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_UNIT ] ) ;
//printf("param = [%s]\n",(const char*)param);
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string customPath = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( customPath , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
string customPathValue = paramPartTokens [ 1 ] ;
std : : vector < string > delimitedList ;
Tokenize ( customPathValue , delimitedList , " , " ) ;
if ( delimitedList . size ( ) > = 2 ) {
unitToLoad . first = delimitedList [ 0 ] ;
2011-05-23 19:23:00 +00:00
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( unitToLoad . first . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
unitToLoad . first = utf8_encode ( wstr . get ( ) ) ;
# endif
2011-01-29 17:42:34 +00:00
for ( unsigned int i = 1 ; i < delimitedList . size ( ) ; + + i ) {
2011-05-23 19:23:00 +00:00
string value = delimitedList [ i ] ;
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( value . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
value = utf8_encode ( wstr . get ( ) ) ;
# endif
unitToLoad . second . push_back ( value ) ;
2011-01-29 04:35:55 +00:00
}
2011-01-29 03:53:05 +00:00
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
2011-01-29 08:46:28 +00:00
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL ] ) ) = = true & &
hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL_ANIMATION_VALUE ] ) ) = = false ) {
2011-01-28 01:41:30 +00:00
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL ] ) ;
//printf("param = [%s]\n",(const char*)param);
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string customPath = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( customPath , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
string customPathValue = paramPartTokens [ 1 ] ;
modelPath = customPathValue ;
2011-05-23 19:23:00 +00:00
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( modelPath . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
modelPath = utf8_encode ( wstr . get ( ) ) ;
# endif
2011-01-28 01:41:30 +00:00
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
2011-01-29 08:46:28 +00:00
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE ] ) ) = = true & &
hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_LOOP_VALUE ] ) ) = = false ) {
2011-01-28 05:49:52 +00:00
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE ] ) ;
//printf("param = [%s]\n",(const char*)param);
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string customPath = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( customPath , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
string customPathValue = paramPartTokens [ 1 ] ;
particlePath = customPathValue ;
2011-05-23 19:23:00 +00:00
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( particlePath . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
particlePath = utf8_encode ( wstr . get ( ) ) ;
# endif
2011-01-28 05:49:52 +00:00
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_PROJECTILE ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_PROJECTILE ] ) ;
//printf("param = [%s]\n",(const char*)param);
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string customPath = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( customPath , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
string customPathValue = paramPartTokens [ 1 ] ;
projectileParticlePath = customPathValue ;
2011-05-23 19:23:00 +00:00
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( projectileParticlePath . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
projectileParticlePath = utf8_encode ( wstr . get ( ) ) ;
# endif
2011-01-28 05:49:52 +00:00
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_SPLASH ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_SPLASH ] ) ;
//printf("param = [%s]\n",(const char*)param);
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string customPath = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( customPath , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
string customPathValue = paramPartTokens [ 1 ] ;
splashParticlePath = customPathValue ;
2011-05-23 19:23:00 +00:00
# ifdef WIN32
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( splashParticlePath . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
splashParticlePath = utf8_encode ( wstr . get ( ) ) ;
# endif
2011-01-28 05:49:52 +00:00
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
float newAnimValue = 0.0f ;
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL_ANIMATION_VALUE ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_MODEL_ANIMATION_VALUE ] ) ;
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string value = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( value , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
newAnimValue = strToFloat ( paramPartTokens [ 1 ] ) ;
2011-01-29 08:46:28 +00:00
printf ( " newAnimValue = %f \n " , newAnimValue ) ;
2011-01-28 05:49:52 +00:00
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
int newParticleLoopValue = 1 ;
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_LOOP_VALUE ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_LOAD_PARTICLE_LOOP_VALUE ] ) ;
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string value = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( value , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
newParticleLoopValue = strToInt ( paramPartTokens [ 1 ] ) ;
//printf("newParticleLoopValue = %d\n",newParticleLoopValue);
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
float newZoomValue = 1.0f ;
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ZOOM_VALUE ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ZOOM_VALUE ] ) ;
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string value = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( value , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
newZoomValue = strToFloat ( paramPartTokens [ 1 ] ) ;
//printf("newAnimValue = %f\n",newAnimValue);
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
float newXRotValue = 0.0f ;
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_X_VALUE ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_X_VALUE ] ) ;
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string value = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( value , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
newXRotValue = strToFloat ( paramPartTokens [ 1 ] ) ;
//printf("newAnimValue = %f\n",newAnimValue);
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
float newYRotValue = 0.0f ;
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_Y_VALUE ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_ROTATE_Y_VALUE ] ) ;
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string value = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( value , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
newYRotValue = strToFloat ( paramPartTokens [ 1 ] ) ;
//printf("newAnimValue = %f\n",newAnimValue);
}
else {
printf ( " \n Invalid path specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
2011-07-05 19:08:28 +00:00
if ( hasCommandArgument ( argc , argv , ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_SCREENSHOT_FORMAT ] ) ) = = true ) {
const wxWX2MBbuf param = ( const char * ) wxConvCurrent - > cWX2MB ( GAME_ARGS [ GAME_ARG_SCREENSHOT_FORMAT ] ) ;
int foundParamIndIndex = - 1 ;
hasCommandArgument ( argc , argv , string ( ( const char * ) param ) + string ( " = " ) , & foundParamIndIndex ) ;
if ( foundParamIndIndex < 0 ) {
hasCommandArgument ( argc , argv , ( const char * ) param , & foundParamIndIndex ) ;
}
//printf("foundParamIndIndex = %d\n",foundParamIndIndex);
string value = ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) ;
vector < string > paramPartTokens ;
Tokenize ( value , paramPartTokens , " = " ) ;
if ( paramPartTokens . size ( ) > = 2 & & paramPartTokens [ 1 ] . length ( ) > 0 ) {
fileFormat = paramPartTokens [ 1 ] ;
}
else {
printf ( " \n Invalid value specified on commandline [%s] value [%s] \n \n " , ( const char * ) wxConvCurrent - > cWX2MB ( argv [ foundParamIndIndex ] ) , ( paramPartTokens . size ( ) > = 2 ? paramPartTokens [ 1 ] . c_str ( ) : NULL ) ) ;
printParameterHelp ( wxConvCurrent - > cWX2MB ( argv [ 0 ] ) , false ) ;
return false ;
}
}
2011-01-28 01:41:30 +00:00
if ( argc = = 2 & & argv [ 1 ] [ 0 ] ! = ' - ' ) {
2010-12-08 20:03:15 +00:00
2011-05-23 19:23:00 +00:00
//#if defined(__MINGW32__)
2011-05-23 19:50:17 +00:00
# ifdef WIN32
2010-12-08 20:03:15 +00:00
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( wxFNCONV ( argv [ 1 ] ) ) ;
modelPath = tmp_buf ;
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( modelPath . c_str ( ) ) ) ;
2011-05-23 19:23:00 +00:00
modelPath = utf8_encode ( wstr . get ( ) ) ;
2011-05-23 19:50:17 +00:00
# else
modelPath = wxFNCONV ( argv [ 1 ] ) ;
# endif
2011-05-23 19:23:00 +00:00
//#else
// modelPath = wxFNCONV(argv[1]);
//#endif
2010-12-08 20:03:15 +00:00
2010-03-13 10:39:22 +00:00
}
2011-03-12 02:28:00 +00:00
//#if defined(__MINGW32__)
// const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(argv[0]));
// appPath = tmp_buf;
//#else
// appPath = wxFNCONV(argv[0]);
//#endif
// printf("appPath [%s]\n",argv[0]);
2011-05-18 21:49:11 +00:00
wxString exe_path = wxStandardPaths : : Get ( ) . GetExecutablePath ( ) ;
//wxString path_separator = wxFileName::GetPathSeparator();
//exe_path = exe_path.BeforeLast(path_separator[0]);
2011-03-12 02:28:00 +00:00
//exe_path += path_separator;
2011-05-23 19:23:00 +00:00
//#if defined(__MINGW32__)
2011-05-23 19:50:17 +00:00
# ifdef WIN32
const wxWX2MBbuf tmp_buf = wxConvCurrent - > cWX2MB ( wxFNCONV ( exe_path ) ) ;
2013-05-26 06:03:32 +00:00
string appPath = tmp_buf ;
2011-05-23 19:50:17 +00:00
2016-01-18 15:29:16 -08:00
auto_ptr < wchar_t > wstr ( Ansi2WideString ( appPath . c_str ( ) ) ) ;
2011-05-23 19:50:17 +00:00
appPath = utf8_encode ( wstr . get ( ) ) ;
# else
2013-05-26 06:03:32 +00:00
string appPath ( wxFNCONV ( exe_path ) ) ;
2011-05-23 19:50:17 +00:00
# endif
2011-05-23 19:23:00 +00:00
//#else
// appPath = wxFNCONV(exe_path);
//#endif
2011-03-05 23:15:07 +00:00
2011-03-12 02:28:00 +00:00
// printf("#2 appPath [%s]\n",appPath.c_str());
2011-01-29 03:53:05 +00:00
mainWindow = new MainWindow ( unitToLoad ,
modelPath ,
2011-01-28 05:49:52 +00:00
particlePath ,
projectileParticlePath ,
splashParticlePath ,
newAnimValue ,
newParticleLoopValue ,
newZoomValue ,
newXRotValue ,
2011-03-05 23:15:07 +00:00
newYRotValue ,
appPath ) ;
2011-05-25 05:52:07 +00:00
if ( autoScreenShotAndExit = = true ) {
2011-05-25 07:21:22 +00:00
# if !defined(WIN32)
2011-05-25 05:52:07 +00:00
mainWindow - > Iconize ( true ) ;
2011-05-25 07:21:22 +00:00
# endif
2011-05-25 05:52:07 +00:00
}
2010-03-13 10:39:22 +00:00
mainWindow - > Show ( ) ;
mainWindow - > init ( ) ;
2011-01-29 23:03:56 +00:00
mainWindow - > Update ( ) ;
2011-03-20 06:05:09 +00:00
mainWindow - > setupTimer ( ) ;
2010-03-13 10:39:22 +00:00
return true ;
}
int App : : MainLoop ( ) {
try {
return wxApp : : MainLoop ( ) ;
}
catch ( const exception & e ) {
wxMessageDialog ( NULL , ToUnicode ( e . what ( ) ) , ToUnicode ( " Exception " ) , wxOK | wxICON_ERROR ) . ShowModal ( ) ;
2012-09-22 20:13:57 +00:00
return 1 ;
2010-03-13 10:39:22 +00:00
}
2012-09-22 20:13:57 +00:00
return 0 ;
2010-03-13 10:39:22 +00:00
}
int App : : OnExit ( ) {
2011-03-11 23:48:16 +00:00
SystemFlags : : Close ( ) ;
SystemFlags : : SHUTDOWN_PROGRAM_MODE = true ;
2010-03-13 10:39:22 +00:00
return 0 ;
}
} } //end namespace
2011-03-12 02:28:00 +00:00
IMPLEMENT_APP_CONSOLE ( Shared : : G3dViewer : : App )