Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 25, 2009, 5:23:00 PM (15 years ago)
Author:
rgrieder
Message:

Implemented new GameState concept. It doesn't differ that much from the old one, but there's still lots of changes.
The most important change is that one GameState can occur multiple times in the hierarchy.

Short log:

  • No RootGameState anymore. Simply the highest is root.
  • Game::requestGameState(name) can refer to the parent, grandparent, great-grandparent, etc. or one of the children.
  • Requested states are saved. So if you select "level", the next request (even right after the call) will be relative to "level"
  • Game::popState() will simply unload the current one
  • Re added Main.cc again because Game as well as GameState have been moved to the core
  • Adapted all GameStates to the new system

Things should already work, except for network support because standalone only works with a little hack.
We can now start creating a better hierarchy.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/Main.cc

    r2801 r2844  
    3636#include "OrxonoxConfig.h"
    3737
    38 #include <exception>
    39 #include <cassert>
     38#include "util/Debug.h"
     39#include "core/Identifier.h"
     40#include "core/Game.h"
    4041
    41 #include "util/Debug.h"
    42 #include "core/Core.h"
    43 #include "core/Identifier.h"
    44 
    45 #include "gamestates/GSRoot.h"
    46 #include "gamestates/GSGraphics.h"
    47 #include "gamestates/GSStandalone.h"
    48 #include "gamestates/GSServer.h"
    49 #include "gamestates/GSClient.h"
    50 #include "gamestates/GSDedicated.h"
    51 #include "gamestates/GSGUI.h"
    52 #include "gamestates/GSIOConsole.h"
    53 
    54 #ifdef ORXONOX_PLATFORM_APPLE
    55 #include <CoreFoundation/CoreFoundation.h>
    56 
    57 // This function will locate the path to our application on OS X,
    58 // unlike windows you can not rely on the curent working directory
    59 // for locating your configuration files and resources.
    60              std::string macBundlePath()
    61 {
    62     char path[1024];
    63     CFBundleRef mainBundle = CFBundleGetMainBundle();
    64     assert(mainBundle);
    65 
    66     CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
    67     assert(mainBundleURL);
    68 
    69     CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
    70     assert(cfStringRef);
    71 
    72     CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
    73 
    74     CFRelease(mainBundleURL);
    75     CFRelease(cfStringRef);
    76 
    77     return std::string(path);
    78 }
    79 #endif
    80 
    81 
    82 
     42/*
     43@brief
     44    Main method. Game starts here (except for static initialisations).
     45*/
    8346int main(int argc, char** argv)
    8447{
    85     orxonox::Core* core = new orxonox::Core(argc, argv);
    86     if (!core->isLoaded())
    8748    {
    88         COUT(0) << "Core was not fully loaded, probably an exception occurred during consruction. Aborting" << std::endl;
    89         abort();
    90     }
    91 
    92     // put GameStates in its own scope so we can destroy the identifiers at the end of main().
    93     {
    94         using namespace orxonox;
    95         // create the gamestates
    96         GSRoot root;
    97         GSGraphics graphics;
    98         GSStandalone standalone;
    99         GSServer server;
    100         GSClient client;
    101         GSDedicated dedicated;
    102         GSGUI gui;
    103         GSIOConsole ioConsole;
    104 
    105         // make the hierarchy
    106         root.addChild(&graphics);
    107         graphics.addChild(&standalone);
    108         graphics.addChild(&server);
    109         graphics.addChild(&client);
    110         graphics.addChild(&gui);
    111         root.addChild(&ioConsole);
    112         root.addChild(&dedicated);
    113 
    114         // Here happens the game
    115         root.start();
    116     }
    117 
    118     // Destroy pretty much everyhting left
    119     delete core;
     49        orxonox::Game orxonox(argc, argv);
     50        orxonox.run();
     51    } // orxonox gets destroyed right here!
    12052
    12153    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
    122     // Needs to be done after 'delete core' because of ~OrxonoxClass
     54    // Needs to be done after Game destructor because of ~OrxonoxClass
    12355    orxonox::Identifier::destroyAllIdentifiers();
    12456
Note: See TracChangeset for help on using the changeset viewer.