00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "config.h"
00026 #include "Teddy/SpaceGame/Root.h"
00027 #include "Teddy/SysSupport/Messages.h"
00028 #include "Teddy/SysSupport/Teddy.h"
00029 #include <cstdlib>
00030 #include <cstring>
00031 using namespace Teddy::SysSupport;
00032
00033
00034 namespace Teddy {
00035 namespace SpaceGame {
00036
00037
00039 Root::Root( int argc, char **argv ){
00040 # if !defined( USE_TINY_GL )
00041 screen_width = 800;
00042 screen_height = 600;
00043 # else
00044 screen_width = 400;
00045 screen_height = 300;
00046 # endif
00047
00048 teddy_init ();
00049 parseOptions( argc, argv );
00050
00051 action_manager = new ActionManager ( this );
00052 audio_manager = new AudioManager ( this );
00053 user_interface = new UserInterface ( this );
00054 object_manager = new ObjectManager ( this );
00055 simulation_timer = new SimulationTimer( this );
00056 event_manager = new EventManager ( this );
00057
00058 object_manager ->addObjects ();
00059 user_interface ->addComponents();
00060 simulation_timer->start ();
00061 audio_manager ->playHyper ();
00062 user_interface ->enterRunLoop ();
00063
00064
00065
00066
00067
00068
00069 }
00070
00071
00073 void Root::parseOptions( int argc, char **argv ){
00074 int i;
00075
00076 # if !defined( USE_TINY_GL )
00077 setOptions( RO_AUDIO | RO_MULTI_WINDOW | RO_HUD | RO_SCANNER );
00078 # else
00079 setOptions( RO_AUDIO | RO_HUD );
00080 # endif
00081
00082 for( i=1; i<argc; i++ ){
00083 if( strcmp(argv[i],"--fullscreen") == 0 ){
00084 enableOptions( RO_FULLSCREEN );
00085 }else if( strcmp(argv[i],"--width") == 0 ){
00086 if( argc > i+1 ){
00087 screen_width = atoi( argv[i+1] );
00088 }else{
00089 printf( "width needs parameter\n" );
00090 }
00091 }else if( strcmp(argv[i],"--height") == 0 ){
00092 if( argc > i+1 ){
00093 screen_height = atoi( argv[i+1] );
00094 }else{
00095 printf( "height needs parameter\n" );
00096 }
00097 }else if( strcmp(argv[i],"--multi-window") == 0 ){
00098 enableOptions( RO_MULTI_WINDOW );
00099 }else if( strcmp(argv[i],"--no-multi-window") == 0 ){
00100 disableOptions( RO_MULTI_WINDOW );
00101 }else if( strcmp(argv[i],"--audio") == 0 ){
00102 enableOptions( RO_AUDIO );
00103 }else if( strcmp(argv[i],"--no-audio") == 0 ){
00104 disableOptions( RO_AUDIO );
00105 }else if( strcmp(argv[i],"--hud") == 0 ){
00106 enableOptions( RO_HUD );
00107 }else if( strcmp(argv[i],"--no-hud") == 0 ){
00108 disableOptions( RO_HUD );
00109 }else if( strcmp(argv[i],"--scanner") == 0 ){
00110 enableOptions( RO_SCANNER );
00111 }else if( strcmp(argv[i],"--no-scanner") == 0 ){
00112 disableOptions( RO_SCANNER );
00113 }else if( strcmp(argv[i],"--no-cabin") == 0 ){
00114 disableOptions( RO_CABIN );
00115 }else if( strcmp(argv[i],"--debug") == 0 ){
00116 enableOptions( RO_DEBUG );
00117 }
00118 }
00119
00120
00121 if( isEnabled(RO_AUDIO) == true ){
00122 printf( "audio enabled\n" );
00123 }else{
00124 printf( "audio disabled\n" );
00125
00126 }
00127
00128 if( isEnabled(RO_MULTI_WINDOW) ){
00129 init_msg( "multiple windows enabled" );
00130 }else{
00131 init_msg( "multiple windows disabled" );
00132 }
00133
00134 if( isEnabled(RO_CABIN) == true ){
00135 init_msg( "cabin enabled" );
00136 }else{
00137 init_msg( "cabin disabled" );
00138 }
00139
00140 if( isEnabled(RO_FULLSCREEN) == true ){
00141 init_msg( "fullscreen enabled" );
00142 }else{
00143 init_msg( "fullscreen disabled" );
00144 }
00145
00146 if( isEnabled(RO_DEBUG) == true ){
00147 init_msg( "debug enabled" );
00148 }else{
00149 init_msg( "debug disabled" );
00150 }
00151 }
00152
00153
00154 ActionManager *Root::getActionManager(){
00155 return action_manager;
00156 }
00157
00158
00159 AudioManager *Root::getAudioManager(){
00160 return audio_manager;
00161 }
00162
00163
00164 EventManager *Root::getEventManager(){
00165 return event_manager;
00166 }
00167
00168
00169 ObjectManager *Root::getObjectManager(){
00170 return object_manager;
00171 }
00172
00173
00174 SimulationTimer *Root::getSimulationTimer(){
00175 return simulation_timer;
00176 }
00177
00178
00179 UserInterface *Root::getUserInterface(){
00180 return user_interface;
00181 }
00182
00183
00184 int Root::getScreenWidth(){
00185 return screen_width;
00186 }
00187
00188
00189 int Root::getScreenHeight(){
00190 return screen_height;
00191 }
00192
00193
00194 };
00195 };
00196