ClientSchema.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include "ClientSchema.hpp"
00023 #include "../event/ClientListeners.hpp"
00024 #include "../io/all.hpp"
00025 #include "../lang/Phrase.hpp"
00026 #include "sim/InitListeners.hpp"
00027 #include "sim/InitListener.hpp"
00028 #include "sim/schema/SimSchema.hpp"
00029 #include "sim/thing/Actor.hpp"
00030 #include "client/thing/PlayerComponent.hpp"
00031 #include "sim/pos/PosComponent.hpp"
00032 #include "io/schema/IoSchema.hpp"
00033 #include "util/system/util_system.hpp"
00034 
00035 
00036 using namespace se_core;
00037 
00038 namespace se_client {
00039     namespace ClientSchema {
00040         ClientListeners clientListeners; // OBJECT_IN_EWRAM;
00041         Phrase* phrases_ = 0;
00042         Phrase& phrases() {
00043             Assert(phrases_);
00044             return *phrases_;
00045         }
00046 
00047         PlayerComponent* playerX; // VAR_IN_EWRAM;
00048         PosComponent* player; // VAR_IN_EWRAM;
00049         PosComponent* floatingCamera; // VAR_IN_EWRAM;
00050         PosComponent* camera = 0; // VAR_IN_EWRAM;
00051 
00052 
00053         const struct _SeClientExport AutoInit : public se_core::InitListener {
00054             AutoInit() {
00055                 // Register some file loaders
00056                 static PlayerParser playerParser(se_core::IoSchema::parser());
00057                 static PlayerEncoder playerEncoder(se_core::IoSchema::encoder());
00058                 static LanguageParser languageParser(se_core::IoSchema::parser());
00059 
00060                 // Client event bridge should listen to init events.
00061                 SimSchema::initListeners().addListener(*this);
00062                 LogDetail("Registered Client add-on");
00063             }
00064 
00065 
00066             ~AutoInit() {
00067                 SimSchema::initListeners().removeListener(*this);
00068                 LogDetail("Cleaned up Client add-on");
00069             }
00070 
00071 
00072             bool initEngineEvent() {
00073                 phrases_ = new Phrase;
00074                 return true;
00075             }
00076             void cleanupEngineEvent() {
00077                 delete phrases_;
00078             }
00079             bool initGameEvent() {
00080                 // Player and camera objects are initialised from data file.
00081                 return true;
00082             }
00083             void cleanupGameEvent() {
00084                 ClientSchema::playerX = 0;
00085                 ClientSchema::player = 0;
00086                 ClientSchema::floatingCamera = 0;
00087                 ClientSchema::camera = 0;
00088             }
00089 
00090 
00091             bool initLevelEvent() {
00092                 return true;
00093             }
00094 
00095             void cleanupLevelEvent() {
00096             }
00097 
00098             bool startGameEvent() {
00099                 return true;
00100             }
00101 
00102             void stopGameEvent() {
00103             }
00104 
00105         } autoInit;
00106 
00107 
00108         void touch() {
00109             se_core::SimSchema::touch();
00110             se_core::IoSchema::touch();
00111             autoInit;
00112         }
00113     }
00114 }

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:03 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo