SWORD25: Converted kernel/kernel.cpp to compile under ScummVM

This commit creates a skeleton detection and engine class, as well as code necessary to call the kernel initiation.
The kernel/kernel.cpp has been converted to compile under ScummVM, along with all dependant header files.

svn-id: r53184
This commit is contained in:
Paul Gilbert 2010-07-31 06:23:38 +00:00 committed by Eugene Sandulenko
parent 1842de4b00
commit e78b19a650
24 changed files with 2078 additions and 1717 deletions

View File

@ -0,0 +1,123 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "base/plugins.h"
#include "engines/advancedDetector.h"
#include "sword25/sword25.h"
namespace Sword25 {
struct Sword25GameDescription {
ADGameDescription desc;
uint32 features;
};
uint32 Sword25Engine::getFeatures() const { return _gameDescription->features; }
Common::Language Sword25Engine::getLanguage() const { return _gameDescription->desc.language; }
Common::Platform Sword25Engine::getPlatform() const { return _gameDescription->desc.platform; }
}
static const PlainGameDescriptor Sword25Game[] = {
{"sword25", "Broken Sword 2.5"},
{0, 0}
};
namespace Sword25 {
// TODO: Need to decide whether we're going to implement code to detect all the various languages allowed,
// both by the core data package, as well as the extra languages added by the patch file; also, I don't
// think that all the languages supported by the game currently have constants in ScummVM
static const Sword25GameDescription gameDescriptions[] = {
{
{
"sword25",
"",
{
{ "data.b25c", kFileTypeHash, "f8b6e03ada2d2f6cf27fbc11ad1572e9", 654310588},
{ NULL, 0, NULL, 0}
},
Common::EN_ANY,
Common::kPlatformWindows,
ADGF_NO_FLAGS
},
0
},
{ { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, ADGF_NO_FLAGS }, 0 }
};
} // end of namespace Sword25
static const ADParams detectionParams = {
// Pointer to ADGameDescription or its superset structure
(const byte *)Sword25::gameDescriptions,
// Size of that superset structure
sizeof(Sword25::Sword25GameDescription),
// Number of bytes to compute MD5 sum for
5000,
// List of all engine targets
Sword25Game,
// Structure for autoupgrading obsolete targets
0,
// Name of single gameid (optional)
NULL,
// List of files for file-based fallback detection (optional)
0,
// Flags
0
};
class Sword25MetaEngine : public AdvancedMetaEngine {
public:
Sword25MetaEngine() : AdvancedMetaEngine(detectionParams) {}
virtual const char *getName() const {
return "The Broken Sword 2.5 Engine";
}
virtual const char *getOriginalCopyright() const {
return "Broken Sword 2.5 (C) Malte Thiesen, Daniel Queteschiner and Michael Elsdorfer";
}
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Sword25::Sword25GameDescription *gd = (const Sword25::Sword25GameDescription *)desc;
if (gd) {
*engine = new Sword25::Sword25Engine(syst, gd);
}
return gd != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(SWORD25)
REGISTER_PLUGIN_DYNAMIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
#else
REGISTER_PLUGIN_STATIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
#endif

View File

@ -1,21 +1,27 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_MOVIEPLAYER_H
#define SWORD25_MOVIEPLAYER_H
@ -27,112 +33,106 @@
#include "sword25/kernel/common.h"
#include "sword25/kernel/service.h"
#include "sword25/kernel/memlog_off.h"
#include <string>
#include "sword25/kernel/memlog_on.h"
namespace Sword25 {
// -----------------------------------------------------------------------------
// Klassendefinition
// Class definitions
// -----------------------------------------------------------------------------
class BS_MoviePlayer : public BS_Service
{
class BS_MoviePlayer : public BS_Service {
public:
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// Constructor / Destructor
// -----------------------------------------------------------------------------
BS_MoviePlayer(BS_Kernel * pKernel);
BS_MoviePlayer(BS_Kernel *pKernel);
virtual ~BS_MoviePlayer() {};
// -----------------------------------------------------------------------------
// Abstraktes Interface, muss von jedem MoviePlayer implementiert werden
// Abstract interface must be implemented by each Movie Player
// -----------------------------------------------------------------------------
/**
@brief Lädt eine Filmdatei
Diese Methode lädt eine Filmdatei und bereitet sie zur Wiedergabe vor.
Es kann immer nur eine Filmdatei zur Zeit geladen sein. Falls bereits eine Filmdatei geladen
ist, wird diese entladen und nötigenfalls die Wiedergabe gestoppt.
@param Filename der Dateiname der zu ladenden Filmdatei
@param Z gibt die Z Position des Films auf dem Graphik-Hauptlayer an
@return Gibt false zurück, wenn beim Laden ein Fehler aufgetreten ist, ansonsten true.
* Loads a movie file
*
* This method loads a movie file and prepares it for playback.
* There can be oly one movie file loaded at a time. If you already have loaded a
* movie file, it will be unloaded and, if necessary, stopped playing.
* @param Filename The filename of the movie file to be loaded
* @param Z Z indicates the position of the film on the main graphics layer
* @return Returns false if an error occured while loading, otherwise true.
*/
virtual bool LoadMovie(const std::string & Filename, unsigned int Z) = 0;
/**
@brief Entlädt die gerade geladene Filmdatei
@return Gibt false zurück, wenn beim Entladen ein Fehler aufgetreten ist, ansonsten true.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
*/
* Unloads the currently loaded movie file.
* @return Returns false if an error occurred while unloading, otherwise true.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual bool UnloadMovie() = 0;
/**
@brief Spielt den Film ab.
Der Film wird unter Beibehaltung der Seitenverhältnisse auf Bildschirmgröße skaliert.<br>
Falls der Film mit einem Aufruf von Pause() pausiert wurde, fährt der Film an dieser Stelle fort.
@return Gibt false zurück, wenn ein Fehler aufgetreten ist, ansonsten true.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
*/
* Plays the loaded movie.
*
* The film will be keeping the aspect ratio of the screen.
* If the film was previously paused with Pause(), then the film will resume playing.
* @return Returns false if an error occurred while starting, otherwise true.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual bool Play() = 0;
/**
@brief Pausiert die Filmwiedergabe.
Bei einem späteren Aufruf von Play() fährt die Wiedergabe an der Stelle fort an der der Film Pausiert wurde.
@return Gibt false zurück, wenn ein Fehler aufgetreten ist, ansonsten true.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
*/
* Pauses movie playback.
*
* A paused movie can later be resumed by calling the Play() method again.
* @return Returns false if an error occurred while pausing, otherwise true.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual bool Pause() = 0;
/**
@brief Diese Funktion muss ein mal pro Frame aufgerufen werden.
*/
* This function must be called once per frame.
*/
virtual void Update() = 0;
/**
@brief Gibt zurück, ob ein Film zur Wiedergabe geladen wurde.
*/
* Returns whether a film is loaded for playback.
*/
virtual bool IsMovieLoaded() = 0;
/**
@brief Gibt zurück, ob die Filmwiedergabe pausiert wurde.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
* Returns whether the movie playback is paused.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual bool IsPaused() = 0;
/**
@brief Gibt den Faktor zurück um den der geladene Film skaliert wird.
Beim Laden wird der Skalierungsfaktor automatisch so gewählt, dass der Film die maximal mögliche Bildschirmfläche einnimmt, ohne dass der
Film verzerrt wird.
@return Gibt den Skalierungsfaktor des Filmes zurück.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
*/
* Returns the scaling factor for the loaded film.
*
* When a movie is loaded, the scaling factor is automatically selected so that the film
* takes the maximum screen space, without the film being distorted.
* @return Returns the scaling factor of the film.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual float GetScaleFactor() = 0;
/**
@brief Legt den Faktor fest um den der geladene Film skaliert werden soll.
@param ScaleFactor der gewünschte Skalierungsfaktor.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
*/
* Sets the factor by which the loaded film is to be scaled.
* @param ScaleFactor The desired scale factor.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual void SetScaleFactor(float ScaleFactor) = 0;
/**
@brief Gibt die aktuelle Abspielposition in Sekunden zurück.
@remark Diese Methode darf nur aufgerufen werden, wenn IsMovieLoaded() true zurückgibt.
*/
* Returns the current playing position in seconds.
* @remark This method can only be called when IsMovieLoaded() returns true.
*/
virtual double GetTime() = 0;
private:
bool _RegisterScriptBindings();
};
} // End of namespace Sword25
#endif

View File

@ -1,21 +1,27 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_FRAMECOUNTER_H
#define SWORD25_FRAMECOUNTER_H
@ -24,39 +30,39 @@
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
namespace Sword25 {
/**
@brief Eine einfache Klasse die einen Framecounter implementiert.
*/
class BS_Framecounter
{
* A simple class that implements a frame counter
*/
class BS_Framecounter {
private:
enum
{
enum {
DEFAULT_UPDATE_FREQUENCY = 10
};
public:
/**
@brief Erzeugt ein neues BS_Framecounter Objekt.
@param UpdateFrequency gibt an wie oft der Framecounter in einer Sekunde aktualisiert werden soll.<br>
Der Standardwert ist 10.
*/
* Creates a new BS_Framecounter object
* @param UpdateFrequency Specifies how often the frame counter should be updated in a sceond.
* The default value is 10.
*/
BS_Framecounter(int UpdateFrequency = DEFAULT_UPDATE_FREQUENCY);
/**
@brief Bestimmt wie oft der Framecounter in einer Sekunde aktualisiert werden soll.
@param UpdateFrequency gibt an wie oft der Framecounter in einer Sekunde aktualisiert werden soll.
*/
* Determines how often the frame counter should be updated in a second.
* @param UpdateFrequency Specifies how often the frame counter should be updated in a second.
*/
inline void SetUpdateFrequency(int UpdateFrequency);
/**
@brief Diese Methode muss einmal pro Frame aufgerufen werden.
*/
* This method must be called once per frame.
*/
void Update();
/**
@brief Gibt den aktuellen FPS-Wert zurück.
*/
* Returns the current FPS value.
*/
int GetFPS() const { return m_FPS; }
private:
@ -67,10 +73,11 @@ private:
};
// Inlines
void BS_Framecounter::SetUpdateFrequency(int UpdateFrequency)
{
// Frequenz in Laufzeit (in Microsekunden) umrechnen.
void BS_Framecounter::SetUpdateFrequency(int UpdateFrequency) {
// Frequency in time (converted to microseconds)
m_UpdateDelay = 1000000 / UpdateFrequency;
}
} // End of namespace Sword25
#endif

View File

@ -1,39 +1,37 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
BS_GraphicEngine
----------------
Dies ist das Graphik-Engine Interface, dass alle Methoden und Klassen enthält, die eine
Graphik-Engine implementieren muss.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_GraphicEngine
* ----------------
* This the graphics engine interface.
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_GRAPHICENGINE_H
#define SWORD25_GRAPHICENGINE_H
// Includes
#include "sword25/kernel/memlog_off.h"
#include <vector>
#include "sword25/kernel/memlog_on.h"
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
#include "sword25/kernel/resservice.h"
@ -42,6 +40,8 @@
#include "sword25/gfx/framecounter.h"
#include "sword25/gfx/renderobjectptr.h"
namespace Sword25 {
class BS_Kernel;
class BS_Image;
class BS_Panel;
@ -62,54 +62,55 @@ typedef unsigned int BS_COLOR;
Die bisher einzige Implementation ist BS_DDrawGfx.
*/
class BS_GraphicEngine : public BS_ResourceService, public BS_Persistable
{
class BS_GraphicEngine : public BS_ResourceService, public BS_Persistable {
public:
// Enums
// -----
// Farbformate
// Colour formats
//
/**
@brief Die von der Engine benutzten Farbformate
*/
enum COLOR_FORMATS
{
/// Undefiniertes/unbekanntes Farbformat
* The colour format used by the engine
*/
enum COLOR_FORMATS {
/// Undefined/unknown colour format
CF_UNKNOWN = 0,
/// 16 Bit Farbformat (5 Bit Rot, 5 Bit Grün, 5 Bit Blau)
/// 16-bit colour format (R5G5B5)
CF_RGB15,
/// 16 Bit Farbformat (5 Bit Rot, 6 Bit Grün, 5 Bit Blau)
/// 16-bit colour format (R5G6R5)
CF_RGB16,
/**
Spezielles Alpha-Farbformat der Engine, welches besonders schnelles Darstellen unter Benutzung von MMX-Befehlen unterstützt.<br>
Die Pixel sind 16 Bit breit und haben das selbe Format wie #CF_RGB15. Zusätzlich besitzt jeder Pixel noch einen 8 Bit Alphawert.<br>
Es werden jeweils 4 Pixel und 4 Alphawerte zu einem 12 Byte großen Datenblock zusammengefasst.<br>
Dabei werden die Daten in folgender Reihenfolge abgelegt:
Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
Falls die Pixelanzahl einer Zeile nicht durch 4 teilbar ist, wird der letzte Pixelblock trotzdem komplett abgespeichert, die
nicht verwendeten Pixel- und Alphawerte können beliebige Werte haben.
*/
* Special alpha colour format of the engine, which supports very quick display using MMX instructions.
* The pixels are 16-bits wide and have the same format as #CF_RGB15. In addition, each pixel has an 8-bit
* alpha value.
* It summarises groupings of pixels pixels and four alpha values in a 12-byte data block.
* The data is stored in the following order:
* Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
* If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have
* arbitrary values.
*/
CF_RGB15_INTERLEAVED,
/**
Spezielles Alpha-Farbformat der Engine, welches besonders schnelles Darstellen unter Benutzung von MMX-Befehlen unterstützt.<br>
Die Pixel sind 16 Bit breit und haben das selbe Format wie #CF_RGB16. Zusätzlich besitzt jeder Pixel noch einen 8 Bit Alphawert.<br>
Es werden jeweils 4 Pixel und 4 Alphawerte zu einem 12 Byte großen Datenblock zusammengefasst.<br>
Dabei werden die Daten in folgender Reihenfolge abgelegt:
Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
Falls die Pixelanzahl einer Zeile nicht durch 4 teilbar ist, wird der letzte Pixelblock trotzdem komplett abgespeichert, die
nicht verwendeten Pixel- und Alphawerte können beliebige Werte haben.
*/
* Special alpha colour format of the engine, which supports very quick display using MMX instructions.
* The pixels are 16-bits wide and have the same format as #CF_RGB16. In addition, each pixel has an 8-bit
* alpha value.
* It summarises groupings of pixels pixels and four alpha values in a 12-byte data block.
* The data is stored in the following order:
* Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
* If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have
* arbitrary values.
*/
CF_RGB16_INTERLEAVED,
/**
24 Bit Farbformat (8 Bit Rot, 8 Bit Grün, 8 Bit Blau)
*/
* 24-bit colour format (R8G8B8)
*/
CF_RGB24,
/**
32 Bit Farbformat (8 Bit Alpha, 8 Bit Rot, 8 Bit Grün, 8 Bit Blau) (little endian)
* 32-bit colour format (A8R8G8B8) (little endian)
*/
CF_ARGB32,
/**
32 Bit Farbformat (8 Bit Alpha, 8 Bit Blau, 8 Bit Grün, 8 Bit Rot) (little endian)
32-bit colour format (A8B8G8R8) (little endian)
*/
CF_ABGR32
};
@ -118,109 +119,84 @@ public:
// ---------
/**
@brief Initialisiert die Graphikengine und setzt den Bildschirmmodus.
@param Width die Breite des Ausgabepuffers in Pixeln.<br>Der Standardwert ist 800.
@param Height die Höhe des Ausgabepuffers in Pixeln.<br>Der Standardwert ist 600.
@param BitDepth die Bittiefe des gewünschten Ausgabepuffers in Bit.<br>Der Standardwert ist 16.
@param BackbufferCount die Anzahl an Backbuffern die erzeugt werden soll.<br>Der Standardwert ist 2.
@param Windowed gibt an, ob die Engine im Fenstermodus laufen soll. Falls true angegeben wird, wird ein Fenster geöffnet in das
die Ausgaben gerendert werden. Ansonsten wird ein Vollbildmodus gesetzt der den Parametern das Ausgabepuffers
entspricht.
@return Gibt false zurück, falls die Initialisierung fehlgeschlagen ist.
@remark Der Fenstermodus sollte nur zu Debuggingzwecken benutzt werden und ist nicht dafür gedacht im endgültigen Produkt benutzt
zu werden.
@remark Diese Methode sollte direkt nach der Initialisierung aller Services aufgerufen werden.
*/
* Initialises the graphics engine and sets the screen mode. Returns true if initialisation failed.
* Notes: This method should be called immediately after the initialisation of all services.
*
* @param Height The height of the output buffer in pixels. The default value is 600
* @param BitDepth The bit depth of the desired output buffer in bits. The default value is 16
* @param BackbufferCount The number of back buffers to be created. The default value is 2
* @param Windowed Indicates whether the engine is to run in windowed mode.
*/
virtual bool Init(int Width = 800, int Height = 600, int BitDepth = 16, int BackbufferCount = 2, bool Windowed = false) = 0;
//@{
/** @name Frame-Methoden */
/**
@brief Beginnt das Rendern eines neuen Frames.
@param UpdateAll gibt an, ob der Renderer im nächsten Frame alles neu zeichnen soll.<br>
Diese Funktion kann nützlich sein, wenn der Renderer mit Dirty-Rectangles arbeitet, der Benutzer aber gelegentlich
darauf angewiesen ist, dass der gesamte Bildschirminhalt neu gezeichnet werden soll.<br>
Der Standardwert ist false.
Diese Methode muss am Anfang das Main-Loops aufgerufen werden und vor dem Aufruf jeglicher Rendermethoden.
@return Gibt false zurück, falls ein Fehler aufgetreten ist.
@remark Implementationen dieser Methode müssen _UpdateLastFrameDuration() aufrufen.
* Begins rendering a new frame.
* Notes: This method must be called at the beginning of the main loop, before any rendering methods are used.
* Notes: Implementations of this method must call _UpdateLastFrameDuration()
* @param UpdateAll Specifies whether the renderer should redraw everything on the next frame.
* This feature can be useful if the renderer with Dirty Rectangles works, but sometimes the client may
*/
virtual bool StartFrame(bool UpdateAll = false) = 0;
/**
@brief Beendet das Rendern des Frames und stellt diesen auf dem Bildschirm dar.
Diese Methode muss am Ende des Main-Loops aufgerufen werden. Nach dem Aufruf dürfen keine weiteren Rendermethoden mehr aufgerufen
werden. Dafür muss erst wieder ein Aufruf von #StartFrame erfolgen.
@return Gibt false zurück, falls ein Fehler aufgetreten ist:
* Ends the rendering of a frame and draws it on the screen.
*
* This method must be at the end of the main loop. After this call, no further Render method may be called.
* This should only be called once for a given previous call to #StartFrame.
*/
virtual bool EndFrame() = 0;
//@}
//@{
/** @name Debug-Methoden */
// Debug methods
/**
@brief Zeichnet eine Line in den Framebuffer.
Diese Methode muss zwischen StartFrame() und EndFrame() aufgerufen werden und ist nur für Debugzwecke gedacht.
Die Linie erscheint nur für einen Frame. Wenn die Linie dauerhaft zu sehen sein soll, muss sie jeden Frame neu
gezeichnet werden.
@param Start der Startpunkt der Linie
@param End der Endpunkt der Linie
@param Color die Farbe der Linie. Der Standardwert ist BS_RGB(255, 255, 255) (Weiß).
* Draws a line in the frame buffer
*
* This method must be called between calls to StartFrame() and EndFrame(), and is intended only for debugging
* purposes. The line will only appear for a single frame. If the line is to be shown permanently, it must be
* called for every frame.
* @param Start The starting point of the line
* @param End The ending point of the line
* @param Color The colour of the line. The default is BS_RGB (255,255,255) (White)
*/
virtual void DrawDebugLine(const BS_Vertex & Start, const BS_Vertex & End, unsigned int Color = BS_RGB(255, 255, 255)) = 0;
virtual void DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color = BS_RGB(255, 255, 255)) = 0;
/**
@brief Erstellt einen Screenshot.
Erstellt einen Screenshot vom aktuellen Framebuffer und schreibt ihn in eine Grafikdatei.<br>
Das verwendete Dateiformat ist PNG.
@param Der Dateiname des Screenshots.
@return Gibt true zurück, wenn der Screenshot gespeichert werden konnte, ansonsten false.
@remark Diese Methode darf erst nach einem Aufruf von EndFrame() und vor dem nächsten Aufruf von StartFrame() aufgerufen werden.
*/
* Creates a screenshot of the current frame buffer and writes it to a graphic file in PNG format.
* Returns true if the screenshot was saved successfully.
* Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
* @param Filename The filename for the screenshot
*/
bool SaveScreenshot(const std::string & Filename);
/**
@Brief Erstellt einen kleinen Screenshot.
Erstellt einen Screenshot mit den Maßen 200x125. Hierfür werden am oberen und unteren Bildschirmrand die Interfaceleisten abgeschnitten und
das Bild auf ein 16tel seiner Ursprungsgröße verkleinert.
@param Der Dateiname des Screenshots.
@return Gibt true zurück, wenn der Screenshot gespeichert werden konnte, ansonsten false.
@remark Diese Methode darf erst nach einem Aufruf von EndFrame() und vor dem nächsten Aufruf von StartFrame() aufgerufen werden.
@remark Der Framebuffer muss eine Auflösung von 800x600 haben.
*/
* Creates a thumbnail with the dimensions of 200x125. This will not include the top and bottom of the screen..
* the interface boards the the image as a 16th of it's original size.
* Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
* The frame buffer must have a resolution of 800x600.
* @param Filename The filename for the screenshot
*/
bool SaveThumbnailScreenshot(const std::string & Filename);
/**
@brief Liest den aktuellen Inhalt des Framebuffer aus.
@param Width enthält nach einem erfolgreichen Aufruf die Breite des Framebuffers.
@param Height enthält nach einem erfolgreichen Aufruf die Höhe des Framebuffers.
@param Data enthält nach einem erfolgreichen Aufruf den Inhalt des Framebuffers als 32-Bit Farbwerte.
@return Gibt true zurück, wenn der Aufruf erfolgreich war, ansonsten false.
@remark Diese Methode ist für das Erstellen von Screenshots gedacht. Sie muss also nicht sehr effizient sein.
@remark Diese Methode darf erst nach einem Aufruf von EndFrame() und vor dem nächsten Aufruf von StartFrame() aufgerufen werden.
* Reads the current contents of the frame buffer
* Notes: This method is for creating screenshots. It is not very optimised. It should only be called
* after a call to EndFrame(), and before the next call to StartFrame().
* @param Width Returns the width of the frame buffer
* @param Height Returns the height of the frame buffer
* @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
*/
virtual bool GetScreenshot(unsigned int & Width, unsigned int & Height, std::vector<unsigned int> & Data) = 0;
//@}
virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel() = 0;
/**
@brief Gibt die Zeit (in Microsekunden) zurück die seit dem letzten Frame vergangen ist.
*/
* Specifies the time (in microseconds) since the last frame has passed
*/
int GetLastFrameDurationMicro() { if (m_TimerActive) return m_LastFrameDuration; else return 0; }
/**
@brief Gibt die Zeit (in Sekunden) zurück die seit dem letzten Frame vergangen ist.
* Specifies the time (in microseconds) the previous frame took
*/
float GetLastFrameDuration() { if (m_TimerActive) return static_cast<float>(m_LastFrameDuration) / 1000000.0f; else return 0; }
@ -228,85 +204,71 @@ public:
void ResumeMainTimer() { m_TimerActive = true; }
float GetSecondaryFrameDuration() { return static_cast<float>(m_LastFrameDuration) / 1000000.0f; }
//@{
/** @name Accessor-Methoden */
// Accessor methods
/**
@brief Gibt die Breite des Ausgabepuffers in Pixeln zurück.
*/
* Returns the width of the output buffer in pixels
*/
int GetDisplayWidth() { return m_Width; }
/**
@brief Gibt die Höhe des Ausgabepuffers in Pixeln zurück.
*/
* Returns the height of the output buffer in pixels
*/
int GetDisplayHeight() { return m_Height; }
/**
@brief Gibt die Bounding-Box des Ausgabepuffers zurück. (0, 0, Width, Height)
*/
* Returns the bounding box of the output buffer: (0, 0, Width, Height)
*/
BS_Rect& GetDisplayRect() { return m_ScreenRect; }
/**
@brief Gibt die Bittiefe des Ausgabepuffers zurück.
*/
* Returns the bit depth of the output buffer
*/
int GetBitDepth() { return m_BitDepth; }
/**
@brief Legt fest ob der Framebufferwechsel mit dem vertikalen Strahlenrücklauf synchronisiert werden soll.<br>
Vsync ist standardmäßig eingeschaltet.
@param Vsync gibt an, ob der Framebufferwechsel mit dem vertikalen Strahlenrücklauf synchronisiert werden soll.
@remark Im Fenstermodus hat diese Einstellung keine Auswirkung.
*/
* Determines whether the frame buffer change is to be synchronised with Vsync. This is turned on by default.
* Notes: In windowed mode, this setting has no effect.
* @param Vsync Indicates whether the frame buffer changes are to be synchronised with Vsync.
*/
virtual void SetVsync(bool Vsync) = 0;
/**
@brief Gibt true zurück, wenn V-Sync an ist.
@remark Im Fenstermodus hat diese Einstellung keine Auswirkung.
*/
* Returns true if V-Sync is on.
* Notes: In windowed mode, this setting has no effect.
*/
virtual bool GetVsync() const = 0;
/**
@brief Gibt true zurück, falls die Engine im Fenstermodus läuft.
*/
* Returns true if the engine is running in Windowed mode.
*/
bool IsWindowed() { return m_Windowed; }
/**
@brief Füllt einen Rechteckigen Bereich des Framebuffers mit einer Farbe.
@param FillRectPtr Pointer auf ein BS_Rect, welches den Ausschnitt des Framebuffers spezifiziert, der gefüllt
werden soll oder 0, falls das gesamte Bild gefüllt werden soll.<br>
Der Standardwert ist 0.
@param Color der 32 Bit Farbwert mit dem der Bildbereich gefüllt werden soll.<br>
Der Standardwert ist BS_RGB(0, 0, 0) (Schwarz).
@return Gibt true zurück, wenn der Aufruf erfolgreich war, ansonsten false.
@remark Es ist möglich über die Methode transparente Rechtecke darzustellen, indem man eine Farbe mit einem
Alphawert ungleich 255 angibt.
* Fills a rectangular area of the frame buffer with a colour.
* Notes: It is possible to create transparent rectangles by passing a colour with an Alpha value of 255.
* @param FillRectPtr Pointer to a BS_Rect, which specifies the section of the frame buffer to be filled.
* If the rectangle falls partly off-screen, then it is automatically trimmed.
* If a NULL value is passed, then the entire image is to be filled.
* @param Color The 32-bit colour with which the area is to be filled. The default is BS_RGB(0, 0, 0) (black)
@remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
*/
*/
virtual bool Fill(const BS_Rect * FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0)) = 0;
//@}
//@{
/** @name Debugging-Methoden */
// Debugging Methods
int GetFPSCount() const { return m_FPSCounter.GetFPS(); }
int GetRepaintedPixels() const { return m_RepaintedPixels; }
//@}
//@{
/** @name Auskunfts-Methoden */
// Access methods
/**
@brief Gibt die Größe eines Pixeleintrages in Byte für ein bestimmtes Farbformat zurück
@param ColorFormat das gewünschte Farbformat. Der Parameter muss vom Typ COLOR_FORMATS sein.
@return Gibt die Größe eines Pixeleintrages in Byte des Farbsformates ColorFormat zurück.<br>
Falls das Farbformat unbekannt ist, wird -1 zurückgegeben.
*/
static int GetPixelSize(BS_GraphicEngine::COLOR_FORMATS ColorFormat)
{
switch (ColorFormat)
{
* Returns the size of a pixel entry in bytes for a particular colour format
* @param ColorFormat The desired colour format. The parameter must be of type COLOR_FORMATS
* @return Returns the size of a pixel in bytes. If the colour format is unknown, -1 is returned.
*/
static int GetPixelSize(BS_GraphicEngine::COLOR_FORMATS ColorFormat) {
switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16:
case BS_GraphicEngine::CF_RGB15:
return 2;
@ -323,16 +285,14 @@ public:
}
/**
@brief Berechnet die Länge einer Bildzeile eines Bilder in Byte, abhängig vom Farbformat.
@param ColorFormat das Farbformat des Bildes.
@param Width die Länge einer Bildzeile in Pixel.
@return Gibt die Länge einer Bildzeile in Byte wieder.<br>
Falls das Farbformat unbekannt ist, wird -1 zurückgegeben.
*/
static int CalcPitch(BS_GraphicEngine::COLOR_FORMATS ColorFormat, int Width)
{
switch (ColorFormat)
{
* Calculates the length of an image line in bytes, depending on a given colour format.
* @param ColorFormat The colour format
* @param Width The width of the line in pixels
* @return Reflects the length of the line in bytes. If the colour format is
* unknown, -1 is returned
*/
static int CalcPitch(BS_GraphicEngine::COLOR_FORMATS ColorFormat, int Width) {
switch (ColorFormat){
case BS_GraphicEngine::CF_RGB16:
case BS_GraphicEngine::CF_RGB15:
return Width * 2;
@ -352,22 +312,20 @@ public:
return -1;
}
//@}
// Persistenz Methoden
// Persistence Methods
// -------------------
virtual bool Persist(BS_OutputPersistenceBlock & Writer);
virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
static void ARGBColorToLuaColor(lua_State * L, unsigned int Color);
static unsigned int LuaColorToARGBColor(lua_State * L, int StackIndex);
static void ARGBColorToLuaColor(lua_State *L, unsigned int Color);
static unsigned int LuaColorToARGBColor(lua_State *L, int StackIndex);
protected:
// Konstruktor
// Constructor
// -----------
BS_GraphicEngine(BS_Kernel* pKernel);
// Display Variablen
// Display Variables
// -----------------
int m_Width;
int m_Height;
@ -375,27 +333,29 @@ protected:
int m_BitDepth;
bool m_Windowed;
// Debugging-Variablen
// Debugging Variables
// -------------------
BS_Framecounter m_FPSCounter;
unsigned int m_RepaintedPixels;
/**
@brief Berechnet die Zeit die seit dem letzten Framebeginn vergangen ist.
*/
* Calculates the time since the last frame beginning has passed.
*/
void UpdateLastFrameDuration();
private:
bool RegisterScriptBindings();
// LastFrameDuration-Variablen
// LastFrameDuration Variables
// ---------------------------
uint64_t m_LastTimeStamp;
uint64 m_LastTimeStamp;
unsigned int m_LastFrameDuration;
bool m_TimerActive;
std::vector<unsigned int> m_FrameTimeSamples;
Common::Array<unsigned int> m_FrameTimeSamples;
unsigned int m_FrameTimeSampleSlot;
};
} // End of namespace Sword25
#endif

View File

@ -1,30 +1,34 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/**
BS_InputEngine
-------------
Dies ist das Inputengine Interface, dass alle Methoden enthält, die eine Inputengine implementieren muss.
Implementationen der Inputengine müssen von dieser Klasse abgeleitet werden.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Alex Arnst
**/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_InputEngine
* -------------
* This is the input interface engine that contains all the methods that an
* input source must implement.
* All input engines must be derived from this class.
*
* Autor: Alex Arnst
*/
#ifndef SWORD25_INPUTENGINE_H
#define SWORD25_INPUTENGINE_H
@ -34,17 +38,18 @@
#include "sword25/kernel/service.h"
#include "sword25/kernel/persistable.h"
/// Klassendefinition
class BS_InputEngine : public BS_Service, public BS_Persistable
{
namespace Sword25 {
/// Class definitions
class BS_InputEngine : public BS_Service, public BS_Persistable {
public:
BS_InputEngine(BS_Kernel* pKernel);
virtual ~BS_InputEngine(){};
// ACHTUNG: Diese Codes werden in inputengine_script.cpp beim Skript-Service registriert. Bei Änderungen an diesem Enum muss auch diese
// Datei angepasst werden.
enum KEY_CODES
{
// NOTE: These codes are registered in inputengine_script.cpp
// Any changes to these enums must also adjust the above file.
enum KEY_CODES {
KEY_BACKSPACE = 0x08,
KEY_TAB = 0x09,
KEY_CLEAR = 0x0C,
@ -136,10 +141,9 @@ public:
KEY_RCONTROL = 0xA3
};
// ACHTUNG: Diese Codes werden in inputengine_script.cpp beim Skript-Service registriert. Bei Änderungen an diesem Enum muss auch diese
// Datei angepasst werden.
enum KEY_COMMANDS
{
// NOTE: These codes are registered in inputengine_script.cpp.
// Any changes to these enums must also adjust the above file.
enum KEY_COMMANDS {
KEY_COMMAND_ENTER = 1,
KEY_COMMAND_LEFT = 2,
KEY_COMMAND_RIGHT = 3,
@ -152,133 +156,131 @@ public:
};
/// --------------------------------------------------------------
/// DIESE METHODEN MÜSSEN VON DER INPUTENGINE IMPLEMENTIERT WERDEN
/// THESE METHODS MUST BE IMPLEMENTED BY THE INPUT ENGINE
/// --------------------------------------------------------------
/**
@brief Initialisiert die Inputengine
@return Gibt bei Erfolg true zurück, ansonsten false.
*/
* Initialises the input engine
* @return Returns a true on success, otherwise false.
*/
virtual bool Init() = 0;
/**
@brief Führt einen "Tick" der Input-Engine aus
Diese Methode sollte mindestens ein mal pro Frame aufgerufen werden. Sie dient dazu Implementationen der
Input-Engine zu ermöglichen, die nicht in einem eigenen Thread laufen oder zusätzliche Verwaltungsaufgaben
durchführen müssen.
*/
* Performs a "tick" of the input engine.
*
* This method should be called once per frame. It can be used by implementations
* of the input engine that are not running in their own thread, or to perform
* additional administrative tasks that are needed.
*/
virtual void Update() = 0;
/**
@brief Gibt true zurück, wenn die linke Maustaste gedrückt ist.
*/
* Returns true if the left mouse button is pressed
*/
virtual bool IsLeftMouseDown() = 0;
/**
@brief Gibt true zurück, wenn die rechte Maustaste gedrückt ist.
* Returns true if the right mouse button is pressed.
*/
virtual bool IsRightMouseDown() = 0;
/**
@brief Gibt true zurück, wenn die linke Maustaste gedrückt und losgelassen wurde.
Der Unterschied zu IsLeftMouseDown() besteht darin, dass erst true zurückgegegen wird, wenn der Tastendruck beendet ist, die Taste also
wieder losgelassen wurde.
* Returns true if the left mouse button was pressed and released.
*
* The difference between this and IsLeftMouseDown() is that this only returns
* true when the left mouse button is released.
*/
virtual bool WasLeftMouseDown() = 0;
/**
@brief Gibt true zurück, wenn die linke Maustaste gedrückt und losgelassen wurde.
Der Unterschied zu IsRightMouseDown() besteht darin, dass erst true zurückgegegen wird, wenn der Tastendruck beendet ist, die Taste also
wieder losgelassen wurde.
* Returns true if the right mouse button was pressed and released.
*
* The difference between this and IsRightMouseDown() is that this only returns
* true when the right mouse button is released.
*/
virtual bool WasRightMouseDown() = 0;
/**
@brief Gibt true zurück wenn mit der linken Maustaste ein Doppelklick ausgelöst wurde.
*/
* Returns true if the left mouse button double click was done
*/
virtual bool IsLeftDoubleClick() = 0;
/**
@brief Gibt die Position des Mauszeigers auf der X-Achse in Pixeln zurück.
* Returns the X position of the cursor in pixels
*/
virtual int GetMouseX() = 0;
/**
@brief Gibt die Position des Mauszeigers auf der Y-Achse in Pixeln zurück.
*/
* Returns the Y position of the cursor in pixels
*/
virtual int GetMouseY() = 0;
/**
@brief Setzt die Position des Mauszeigers auf der X-Achse in Pixeln.
*/
* Sets the X position of the cursor in pixels
*/
virtual void SetMouseX(int PosX) = 0;
/**
@brief Setzt die Position des Mauszeigers auf der Y-Achse in Pixeln.
*/
* Sets the Y position of the cursor in pixels
*/
virtual void SetMouseY(int PosY) = 0;
/**
@brief Gibt true zurück wenn eine bestimmte Taste gedrückt ist.
@param KeyCode der Key-Code der zu testenden Taste
@return Gibt true zurück, wenn die Taste mit dem übergebenen Key-Code gedrückt ist, ansonsten false.
*/
* Returns true if a given key was pressed
* @param KeyCode The key code to be checked
* @return Returns true if the given key is done, otherwise false.
*/
virtual bool IsKeyDown(unsigned int KeyCode) = 0;
/**
@brief Gibt true zurück wenn eine bestimmte Taste gerückt und losgelassen wurde.
Der Unterschied zu IsKeyDown() besteht darin, dass erst true zurückgegegen wird, wenn der Tastendruck beendet ist, die Taste also
wieder losgelassen wurde. Diese Methode erleichtert das Abfragen von Funktionstasten und das Einlesen von Zeichenketten, die vom
Benutzer getippt werden.
@param KeyCode der Key-Code der zu testenden Taste
*/
* Returns true if a certain key was pushed and released.
*
* The difference between IsKeyDown() is that this only returns true after the key
* has been released. This method facilitates the retrieval of keys, and reading
* strings that users type.
* @param KeyCode The key code to be checked
*/
virtual bool WasKeyDown(unsigned int KeyCode) = 0;
typedef void (*CharacterCallback)(unsigned char Character);
/**
@brief Registriert eine Callbackfunktion für die Eingabe von Buchstaben.
Die Callbacks, die mit dieser Funktion registriert werden, werden immer dann aufgerufen, wenn der Input-Service eine Buchstabeneingabe
feststellt. Eine Buchstabeneingabe unterscheidet sich von der Abfrage mittels der Methoden IsKeyDown() und WasKeyDown() in der Hinsicht,
dass statt Scan-Coded tatsächliche Buchstaben behandelt werden. Dabei wurden unter anderem Berücksichtigt:des Tastaturlayout, der Zustand
der Shift und Caps Lock Tasten und die Wiederholung durch längeres Halten der Taste.<br>
Die Eingabe von Zeichenketten durch den Benutzer sollte durch Benutzung dieses Callbacks realisiert werden.
@return Gibt true zurück, wenn die Funktion registriert werden konnte, ansonsten false.
* Registers a callback function for keyboard input.
*
* The callbacks that are registered with this function will be called whenever an
* input key is pressed. A letter entry is different from the query using the
* methods IsKeyDown () and WasKeyDown () in the sense that are treated instead
* of actual scan-coded letters. These were taken into account, among other things:
* the keyboard layout, the condition the Shift and Caps Lock keys and the repetition
* of longer holding the key.
* The input of strings by the user through use of callbacks should be implemented.
* @return Returns true if the function was registered, otherwise false.
*/
virtual bool RegisterCharacterCallback(CharacterCallback Callback) = 0;
/**
@brief Deregistriert eine Callbackfunktion für die Eingabe von Buchstaben.
@return Gibt true zurück, wenn die Funktion deregistriert werden konnte, ansonsten false.
*/
* De-registeres a previously registered callback function.
* @return Returns true if the function could be de-registered, otherwise false.
*/
virtual bool UnregisterCharacterCallback(CharacterCallback Callback) = 0;
typedef void (*CommandCallback)(KEY_COMMANDS Command);
/**
@brief Registriert eine Callbackfunktion für die Eingabe von Kommandos, die auf die Zeichenketteneingabe Einfluss haben können.
Die Callbacks, die mit dieser Funktion registriert werden , werden immer dann aufgerufen, wenn der Input-Service einen Tastendruck
feststellt, der die Zeichenketteneingabe beeinflussen kann. Dies könnten folgende Tasten sein: Enter, Pos 1, Ende, Links, Rechts, ...<br>
Die Eingabe von Zeichenketten durch den Benutzer sollte durch Benutzung dieses Callbacks realisiert werden.
@return Gibt true zurück, wenn die Funktion registriert werden konnte, ansonsten false.
*/
* Registers a callback function for the input of commands that can have influence on the string input
*
* The callbacks that are registered with this function will be called whenever the input service
* has a key that affects the character string input. This could be the following keys:
* Enter, End, Left, Right, ...
* The input of strings by the user through the use of callbacks should be implemented.
* @return Returns true if the function was registered, otherwise false.
*/
virtual bool RegisterCommandCallback(CommandCallback Callback) = 0;
/**
@brief Deregistriert eine Callbackfunktion für die Eingabe von Kommandos, die auf die Zeichenketteneingabe Einfluss haben können.
@return Gibt true zurück, wenn die Funktion deregistriert werden konnte, ansonsten false.
*/
* Un-register a callback function for the input of commands that can have an influence on the string input.
* @return Returns true if the function could be de-registered, otherwise false.
*/
virtual bool UnregisterCommandCallback(CommandCallback Callback) = 0;
virtual void ReportCharacter(unsigned char Character) = 0;
@ -288,4 +290,6 @@ private:
bool _RegisterScriptBindings();
};
} // End of namespace Sword25
#endif

View File

@ -1,17 +1,20 @@
// TODO: Properly replace all game occurances that use these types with proper ScummVM types, and remove this file
#ifndef SWORD25_STDINT_H
#define SWORD25_STDINT_H
#ifdef _MSC_VER
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
#else
#include <stdint.h>
#endif
#include "common/scummsys.h"
typedef uint8 uint8_t;
typedef uint16 uint16_t;
typedef uint32 uint32_t;
typedef int8 int8_t;
typedef int16 int16_t;
typedef int32 int32_t;
typedef unsigned long long uint64_t;
typedef signed long long int64_t;
typedef unsigned long long uint64;
typedef signed long long int64;
#endif

View File

@ -1,41 +1,44 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
common.h
-----------
Diese Datei enthält Funktionen und Makros, die im gesamten Projekt bekannt sein müssen.
Daher ist es äußerst wichtig, dass diese Headerdatei in jede andere Headerdatei des Projektes
eingefügt wird.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* common.h
* -----------
* This file contains functions or macros that are used across the entire project.
* It is therefore extremely important that this header file be referenced in all
* the other header files in the project.
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_COMMON_H
#define SWORD25_COMMON_H
// Globale Konstanten
// Global constants
#if _DEBUG && !DEBUG
#define DEBUG
#endif
#define BS_ACTIVATE_LOGGING // Wenn definiert, wird Logging aktiviert
#define BS_ACTIVATE_LOGGING // When defined, logging is activated
// Engine Includes
#include "sword25/kernel/memleaks.h"

View File

@ -1,112 +1,89 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <psapi.h>
#pragma comment(lib, "psapi.lib")
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
#include <math.h>
#include <algorithm>
#include "sword25/kernel/kernel.h"
#include "sword25/kernel/timer.h"
#include "sword25/kernel/service_ids.h"
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/system.h"
#include "sword25/gfx/graphicengine.h"
#include "sword25/sfx/soundengine.h"
#include "sword25/fmv/movieplayer.h"
#include "sword25/input/inputengine.h"
#include "sword25/kernel/kernel.h"
#include "sword25/kernel/persistenceservice.h"
#include "sword25/kernel/service_ids.h"
#include "sword25/package/packagemanager.h"
#include "sword25/script/script.h"
#include "sword25/fmv/movieplayer.h"
#include "sword25/kernel/persistenceservice.h"
#include "sword25/sfx/soundengine.h"
namespace Sword25 {
#define BS_LOG_PREFIX "KERNEL"
BS_Kernel * BS_Kernel::_Instance = 0;
BS_Kernel *BS_Kernel::_Instance = 0;
// Konstruktion / Destruktion
// --------------------------
BS_Kernel::BS_Kernel() :
_pWindow(NULL),
_Running(false),
_pResourceManager(NULL),
_InitSuccess(false)
{
// TODO:
// Messagebox ausgeben wenn nicht gelogged werden kann -> log.txt schreibgeschützt
_InitSuccess(false) {
// Log that the kernel is beign created
BS_LOGLN("created.");
// Feststellen, ob der Timer unterstützt wird.
if (!BS_Timer::IsTimerAvaliable())
{
BS_LOG_ERRORLN("This machine doesn't support a performance counter.");
return;
}
// Die BS_SERVICE_TABLE auslesen und kernelinterne Strukturen vorbereiten
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
{
// Ist die Superclass schon registriert?
Superclass* pCurSuperclass = NULL;
std::vector<Superclass*>::iterator Iter;
// Read the BS_SERVICE_TABLE and prepare kernel structures
for (uint i = 0; i < BS_SERVICE_COUNT; i++) {
// Is the superclass already registered?
Superclass *pCurSuperclass = NULL;
Common::Array<Superclass *>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter)
if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier)
{
if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier) {
pCurSuperclass = *Iter;
break;
}
// Falls die Superclass noch nicht registriert war, wird dies jetzt gemacht
// If the superclass isn't already registered, then add it in
if (!pCurSuperclass)
_SuperclassList.push_back(new Superclass(this, BS_SERVICE_TABLE[i].SuperclassIdentifier));
}
// Fensterobjekt erstellen
_pWindow = BS_Window::CreateBSWindow(0,0,0,0,false);
if (!_pWindow)
{
// Create window object
_pWindow = BS_Window::CreateBSWindow(0, 0, 0, 0, false);
if (!_pWindow) {
BS_LOG_ERRORLN("Failed to create the window.");
}
else
} else
BS_LOGLN("Window created.");
// Resource-Manager erstellen
// Create the resource manager
_pResourceManager = new BS_ResourceManager(this);
// Random-Number-Generator initialisieren
srand(GetMilliTicks());
// Die Skriptengine initialisieren
// Die Skriptengine muss bereits von Kernel und nicht vom Benutzer gestartet werden, damit der Kernel seine Funktionen bei seiner Erzeugung
// registrieren kann.
BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(NewService("script", "lua"));
if (!pScript || !pScript->Init())
{
// Initialise the script engine
BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(NewService("script", "lua"));
if (!pScript || !pScript->Init()) {
_InitSuccess = false;
return;
}
// Scriptbindings des Kernels registrieren
if (!_RegisterScriptBindings())
{
// Register kernel script bindings
if (!_RegisterScriptBindings()) {
BS_LOG_ERRORLN("Script bindings could not be registered.");
_InitSuccess = false;
return;
@ -116,24 +93,21 @@ BS_Kernel::BS_Kernel() :
_InitSuccess = true;
}
BS_Kernel::~BS_Kernel()
{
// Services in umgekehrter Reihenfolge der Erstellung endladen.
while (!_ServiceCreationOrder.empty())
{
Superclass * superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top());
BS_Kernel::~BS_Kernel() {
// Services are de-registered in reverse order of creation
while (!_ServiceCreationOrder.empty()) {
Superclass *superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top());
if (superclass) superclass->DisconnectService();
_ServiceCreationOrder.pop();
}
// Superclasslist leeren
while (_SuperclassList.size())
{
// Empty the Superclass list
while (_SuperclassList.size()) {
delete _SuperclassList.back();
_SuperclassList.pop_back();
}
// Fensterobjekt freigeben
// Release the window object
delete _pWindow;
BS_LOGLN("Window destroyed.");
@ -145,7 +119,8 @@ BS_Kernel::~BS_Kernel()
// Service Methoden
// ----------------
BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const std::string& Identifier) :
BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const Common::String& Identifier) :
_pKernel(pKernel),
_Identifier(Identifier),
_ServiceCount(0),
@ -156,18 +131,24 @@ BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const std::string& Identi
_ServiceCount++;
}
BS_Kernel::Superclass::~Superclass()
{
BS_Kernel::Superclass::~Superclass() {
DisconnectService();
}
std::string BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number)
{
/**
* Gets the identifier of a service with a given superclass.
* The number of services in a superclass can be learned with GetServiceCount().
* @param SuperclassIdentifier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
* @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
* Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
* 0 und GetServiceCount() - 1 sein.
*/
Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) {
if (Number > _ServiceCount) return NULL;
unsigned int CurServiceOrd = 0;
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
{
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) {
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
if (Number == CurServiceOrd)
return BS_SERVICE_TABLE[i].ServiceIdentifier;
@ -175,11 +156,19 @@ std::string BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number)
CurServiceOrd++;
}
return std::string("");
return Common::String("");
}
BS_Service* BS_Kernel::Superclass::NewService(const std::string& ServiceIdentifier)
{
/**
* Creates a new service with the given identifier. Returns a pointer to the service, or null if the
* service could not be created
* Note: All services must be registered in service_ids.h, otherwise they cannot be created here
* @param SuperclassIdentifier The name of the superclass of the service
* z.B: "sfx", "gfx", "package" ...
* @param ServiceIdentifier The name of the service
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) {
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier &&
BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier)
@ -205,10 +194,14 @@ BS_Service* BS_Kernel::Superclass::NewService(const std::string& ServiceIdentifi
return NULL;
}
bool BS_Kernel::Superclass::DisconnectService()
{
if (_ActiveService)
{
/**
* Ends the current service of a superclass. Returns true on success, and false if the superclass
* does not exist or if not service was active
* @param SuperclassIdentfier The name of the superclass which is to be disconnected
* z.B: "sfx", "gfx", "package" ...
*/
bool BS_Kernel::Superclass::DisconnectService() {
if (_ActiveService) {
delete _ActiveService;
_ActiveService = 0;
BS_LOGLN("Active service '%s' disconnected from superclass '%s'.", _ActiveServiceName.c_str(), _Identifier.c_str());
@ -218,11 +211,9 @@ bool BS_Kernel::Superclass::DisconnectService()
return false;
}
BS_Kernel::Superclass* BS_Kernel::GetSuperclassByIdentifier(const std::string & Identifier)
{
std::vector<Superclass*>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter)
{
BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) {
Common::Array<Superclass*>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) {
if ((*Iter)->GetIdentifier() == Identifier)
return *Iter;
}
@ -231,48 +222,75 @@ BS_Kernel::Superclass* BS_Kernel::GetSuperclassByIdentifier(const std::string &
return NULL;
}
unsigned int BS_Kernel::GetSuperclassCount()
{
/**
* Returns the number of register superclasses
*/
unsigned int BS_Kernel::GetSuperclassCount() {
return _SuperclassList.size();
}
std::string BS_Kernel::GetSuperclassIdentifier(unsigned int Number)
{
/**
* Returns the name of a superclass with the specified index.
* Note: The number of superclasses can be retrieved using GetSuperclassCount
* @param Number The number of the superclass to return the identifier for.
* It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
*/
Common::String BS_Kernel::GetSuperclassIdentifier(unsigned int Number) {
if (Number > _SuperclassList.size()) return NULL;
unsigned int CurSuperclassOrd = 0;
std::vector<Superclass*>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter)
{
Common::Array<Superclass*>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) {
if (CurSuperclassOrd == Number)
return ((*Iter)->GetIdentifier());
CurSuperclassOrd++;
}
return std::string("");
return Common::String("");
}
unsigned int BS_Kernel::GetServiceCount(const std::string & SuperclassIdentifier)
{
Superclass* pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0;
/**
* Returns the number of services registered with a given superclass
* @param SuperclassIdentifier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier)))
return 0;
return pSuperclass->GetServiceCount();
}
std::string BS_Kernel::GetServiceIdentifier(const std::string & SuperclassIdentifier, unsigned int Number)
{
/**
* Gets the identifier of a service with a given superclass.
* The number of services in a superclass can be learned with GetServiceCount().
* @param SuperclassIdentifier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
* @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
* Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
* 0 und GetServiceCount() - 1 sein.
*/
Common::String BS_Kernel::GetServiceIdentifier(const Common::String & SuperclassIdentifier, unsigned int Number) {
Superclass* pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
return (pSuperclass->GetServiceIdentifier(Number));
}
BS_Service* BS_Kernel::NewService(const std::string& SuperclassIdentifier, const std::string& ServiceIdentifier)
{
Superclass* pSuperclass;
/**
* Creates a new service with the given identifier. Returns a pointer to the service, or null if the
* service could not be created
* Note: All services must be registered in service_ids.h, otherwise they cannot be created here
* @param SuperclassIdentifier The name of the superclass of the service
* z.B: "sfx", "gfx", "package" ...
* @param ServiceIdentifier The name of the service
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, const Common::String& ServiceIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
// Die Reihenfolge merken, in der Services erstellt werden, damit sie später in umgekehrter Reihenfolge entladen werden können.
@ -281,56 +299,82 @@ BS_Service* BS_Kernel::NewService(const std::string& SuperclassIdentifier, const
return pSuperclass->NewService(ServiceIdentifier);
}
bool BS_Kernel::DisconnectService(const std::string& SuperclassIdentifier)
{
Superclass* pSuperclass;
/**
* Ends the current service of a superclass. Returns true on success, and false if the superclass
* does not exist or if not service was active
* @param SuperclassIdentfier The name of the superclass which is to be disconnected
* z.B: "sfx", "gfx", "package" ...
*/
bool BS_Kernel::DisconnectService(const Common::String& SuperclassIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false;
return pSuperclass->DisconnectService();
}
BS_Service* BS_Kernel::GetService(const std::string& SuperclassIdentifier)
{
Superclass* pSuperclass;
/**
* Returns a pointer to the currently active service object of a superclass
* @param SuperclassIdentfier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
return (pSuperclass->GetActiveService());
}
std::string BS_Kernel::GetActiveServiceIdentifier(const std::string& SuperclassIdentifier)
{
/**
* Returns the name of the currentl active service object of a superclass.
* If an error occurs, then an empty string is returned
* @param SuperclassIdentfier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& SuperclassIdentifier) {
Superclass * pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier);
if (!pSuperclass) return std::string("");
if (!pSuperclass) return Common::String("");
return (pSuperclass->GetActiveServiceName());
}
// -----------------------------------------------------------------------------
int BS_Kernel::GetRandomNumber(int Min, int Max)
{
/**
* Returns a random number
* @param Min The minimum allowed value
* @param Max The maximum allowed value
*/
int BS_Kernel::GetRandomNumber(int Min, int Max) {
BS_ASSERT(Min <= Max);
unsigned int MaxInternal = (Min - Max + 1) < 0 ? - (Min - Max + 1) : (Min - Max + 1);
return (rand() % MaxInternal) + Min;
return Min + _rnd.getRandomNumber(Max - Min + 1);
}
// Timer Methoden
// --------------
unsigned int BS_Kernel::GetMilliTicks()
{
return BS_Timer::GetMilliTicks();
/**
* Returns the elapsed time since startup in milliseconds
*/
unsigned int BS_Kernel::GetMilliTicks() {
return g_system->getMillis();
}
uint64_t BS_Kernel::GetMicroTicks()
{
return BS_Timer::GetMicroTicks();
/**
* Returns the elapsed time since the system start in microseconds.
* This method should be used only if GetMilliTick() for the desired application is inaccurate.
*/
uint64 BS_Kernel::GetMicroTicks() {
return g_system->getMillis() * 1000;
}
// Sonstige Methoden
// Other methods
// -----------------
size_t BS_Kernel::GetUsedMemory()
{
/**
* Returns how much memory is being used
*/
size_t BS_Kernel::GetUsedMemory() {
return 0;
#ifdef SCUMMVM_DISABLED_CODE
PROCESS_MEMORY_COUNTERS pmc;
pmc.cb = sizeof(pmc);
if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
@ -342,53 +386,67 @@ size_t BS_Kernel::GetUsedMemory()
BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError());
return 0;
}
#endif
}
// -----------------------------------------------------------------------------
BS_GraphicEngine * BS_Kernel::GetGfx()
{
/**
* Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active
*/
BS_GraphicEngine * BS_Kernel::GetGfx() {
return static_cast<BS_GraphicEngine *>(GetService("gfx"));
}
// -----------------------------------------------------------------------------
BS_SoundEngine * BS_Kernel::GetSfx()
{
/**
* Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active
*/
BS_SoundEngine * BS_Kernel::GetSfx() {
return static_cast<BS_SoundEngine *>(GetService("sfx"));
}
// -----------------------------------------------------------------------------
BS_InputEngine * BS_Kernel::GetInput()
{
/**
* Returns a pointer to the active input service, or NULL if no input service is active
*/
BS_InputEngine * BS_Kernel::GetInput() {
return static_cast<BS_InputEngine *>(GetService("input"));
}
// -----------------------------------------------------------------------------
BS_PackageManager * BS_Kernel::GetPackage()
{
/**
* Returns a pointer to the active package manager, or NULL if no manager is active
*/
BS_PackageManager * BS_Kernel::GetPackage() {
return static_cast<BS_PackageManager *>(GetService("package"));
}
// -----------------------------------------------------------------------------
BS_ScriptEngine * BS_Kernel::GetScript()
{
/**
* Returns a pointer to the script engine, or NULL if it is not active
*/
BS_ScriptEngine * BS_Kernel::GetScript() {
return static_cast<BS_ScriptEngine *>(GetService("script"));
}
// -----------------------------------------------------------------------------
BS_MoviePlayer * BS_Kernel::GetFMV()
{
/**
* Returns a pointer to the movie player, or NULL if it is not active
*/
BS_MoviePlayer * BS_Kernel::GetFMV() {
return static_cast<BS_MoviePlayer *>(GetService("fmv"));
}
// -----------------------------------------------------------------------------
void BS_Kernel::Sleep(unsigned int Msecs) const
{
::Sleep(Msecs);
void BS_Kernel::Sleep(unsigned int Msecs) const {
g_system->delayMillis(Msecs);
}
} // End of namespace Sword25

View File

@ -1,52 +1,53 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
BS_Kernel
---------
Dies ist die Hauptklasse der Engine.
Diese Klasse erzeugt und verwaltet alle anderen Enginelemente, wie Soundengine, Graphikengine...
Es ist nicht notwendig alle Enginenelemente einzeln freizugeben, dieses wird von der Kernelklasse übernommen.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_Kernel
* ---------
* This is the main class of the engine.
* This class creates and manages all other Engine elements: the sound engine, graphics engine ...
* It is not necessary to release all the items individually, this is performed by the Kernel class.
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_KERNEL_H
#define SWORD25_KERNEL_H
// Includes
#include "common/scummsys.h"
#include "common/random.h"
#include "common/stack.h"
#include "common/util.h"
#include "engines/engine.h"
// Includes
#include "sword25/kernel/memlog_off.h"
#include <vector>
#include <stack>
#include <string>
#include "sword25/kernel/memlog_on.h"
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
#include "sword25/kernel/window.h"
#include "sword25/kernel/resmanager.h"
namespace Sword25 {
// Klassendefinition
// Class definitions
class BS_Service;
class BS_GraphicEngine;
class BS_ScriptEngine;
@ -56,244 +57,230 @@ class BS_PackageManager;
class BS_MoviePlayer;
/**
@brief Dies ist die Hauptklasse der Engine.
Diese Klasse erzeugt und verwaltet alle anderen Engineelemente, wie Soundengine, Graphikengine...<br>
Es ist nicht notwendig alle Enginenelemente einzeln freizugeben, dieses wird von der Kernelklasse übernommen.
* This is the main engine class
*
* This class creates and manages all other engine components such as sound engine, graphics engine ...
* It is not necessary to release all the items individually, this is performed by the Kernel class.
*/
class BS_Kernel
{
class BS_Kernel {
public:
// Fenster Methoden
// ----------------
/**
@brief Gibt einen Pointer auf das Fensterobjekt zurück.
@return Gibt einen Pointer auf das Fensterobjekt zurück.
*/
BS_Window* GetWindow() {return _pWindow; }
// Service Methoden
// Window methods
// ----------------
/**
@brief Erzeugt einen neuen Service der angegebenen Superclass mit dem übergebenen Identifier.
@param SuperclassIdentifier der Name der Superclass des Services<br>
z.B: "sfx", "gfx", "package" ...
@param ServiceIdentifier der Name des Services<br>
Für die Superclass "sfx" könnten das z.B. "fmod" oder "directsound" sein.
@return Gibt einen Pointer auf den Service zurück, oder NULL wenn der Service nicht erstellt werden konnte.
@remark Alle Services müssen in service_ids.h eingetragen sein, sonst können sie hier nicht erstellt werden.
*/
BS_Service* NewService(const std::string & SuperclassIdentifier, const std::string & ServiceIdentifier);
/**
@brief Beendet den aktuellen Service einer Superclass.
@param SuperclassIdentfier der Name der Superclass dessen aktiver Service beendet werden soll<br>
z.B: "sfx", "gfx", "package" ...
@return Gibt bei Erfolg true zurück und false wenn die Superclass nicht existiert oder wenn kein Service aktiv war.
*/
bool DisconnectService(const std::string & SuperclassIdentifier);
* Returns a pointer to the window object
*/
BS_Window *GetWindow() { return _pWindow; }
// Service Methods
// ---------------
/**
@brief Gibt einen Pointer auf das momentan aktive Serviceobjekt einer Superclass zurück.
@param SuperclassIdentfier der Name der Superclass<br>
z.B: "sfx", "gfx", "package" ...
@return Gibt einen Pointer auf den Service zurück, oder NULL wenn kein Service aktiv war.
*/
BS_Service* GetService(const std::string& SuperclassIdentifier);
* Creates a new service with the given identifier. Returns a pointer to the service, or null if the
* service could not be created
* Note: All services must be registered in service_ids.h, otherwise they cannot be created here
* @param SuperclassIdentifier The name of the superclass of the service
* z.B: "sfx", "gfx", "package" ...
* @param ServiceIdentifier The name of the service
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
BS_Service *NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier);
/**
@brief Gibt den Namen des aktuell aktiven Serviceobjektes einer Superclass zurück.
@param SuperclassIdentfier der Name der Superclass<br>
z.B: "sfx", "gfx", "package" ...
@return Gibt den Namen des Serviceobjektes zurück, oder einen leeren String, wenn ein Fehler aufgetreten ist.
*/
std::string GetActiveServiceIdentifier(const std::string& SuperclassIdentifier);
* Ends the current service of a superclass. Returns true on success, and false if the superclass
* does not exist or if not service was active
* @param SuperclassIdentfier The name of the superclass which is to be disconnected
* z.B: "sfx", "gfx", "package" ...
*/
bool DisconnectService(const Common::String &SuperclassIdentifier);
/**
@brief Gibt die Anzahl der Registrierten Superclasses zurück.
@return Gibt die Anzahl der Registrierten Superclasses zurück.
*/
* Returns a pointer to the currently active service object of a superclass
* @param SuperclassIdentfier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
BS_Service *GetService(const Common::String &SuperclassIdentifier);
/**
* Returns the name of the currentl active service object of a superclass.
* If an error occurs, then an empty string is returned
* @param SuperclassIdentfier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
Common::String GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier);
/**
* Returns the number of register superclasses
*/
unsigned int GetSuperclassCount();
// Gibt den Identifier der mit Number bezeichneten Superclass zurück
/**
@brief Gibt den Identifier einer Superclass zurück.
@param Number die Nummer der Superclass, dessen Bezeichner man erfahren möchte<br>
Hierbei ist zu beachten, dass die erste Superclass die Nummer 0 erhält. Number muss also eine Zahl zwischen
0 und GetSuperclassCount() - 1 sein.
@return Gibt den Identifier der Superclass zurück.
@remark Die Anzahl der Superclasses kann man mit GetSuperclassCount() erfahren.
*/
std::string GetSuperclassIdentifier(unsigned int Number);
// Gibt die Anzahl der für die mit SuperclassIdentifier bezeichneten Superclass vorhandenen
// Services zurück
/**
@brief Gibt die Anzahl an Services zurück, die in einer Superclass registriert sind.
@param SuperclassIdentifier der Name der Superclass<br>
z.B: "sfx", "gfx", "package" ...
@return Gibt die Anzahl an Services zurück, die in der Superclass registriert sind.
*/
unsigned int GetServiceCount(const std::string & SuperclassIdentifier);
* Returns the name of a superclass with the specified index.
* Note: The number of superclasses can be retrieved using GetSuperclassCount
* @param Number The number of the superclass to return the identifier for.
* It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
*/
Common::String GetSuperclassIdentifier(unsigned int Number);
/**
@brief Gibt den Identifier eines Services in einer Superclass zurück.
@param SuperclassIdentifier der Name der Superclass<br>
z.B: "sfx", "gfx", "package" ...
@param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
0 und GetServiceCount() - 1 sein.
@return Gibt den Identifier des Services zurück
@remark Die Anzahl der Services in einer Superclass kann man mit GetServiceCount() erfahren.
*/
std::string GetServiceIdentifier(const std::string & SuperclassIdentifier, unsigned int Number);
* Returns the number of services registered with a given superclass
* @param SuperclassIdentifier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
unsigned int GetServiceCount(const Common::String & SuperclassIdentifier);
/**
@brief Gibt die vergangene Zeit seit dem Systemstart in Millisekunden zurück.
* Gets the identifier of a service with a given superclass.
* The number of services in a superclass can be learned with GetServiceCount().
* @param SuperclassIdentifier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
* @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
* Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
* 0 und GetServiceCount() - 1 sein.
*/
Common::String GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number);
/**
* Returns the elapsed time since startup in milliseconds
*/
unsigned int GetMilliTicks();
/**
@brief Gibt die vergangene Zeit seit dem Systemstart in Microsekunden zurück.
@remark Diese Methode sollte nur verwendet werden, falls GetMilliTick() für den gewünschten Einsatz zu ungenau ist.
*/
uint64_t GetMicroTicks();
* Returns the elapsed time since the system start in microseconds.
* This method should be used only if GetMilliTick() for the desired application is inaccurate.
*/
uint64 GetMicroTicks();
/**
@brief Gibt an, ob die Konstruktion erfolgreich war.
@return Gibt true zurück, wenn die Konstruktion erfolgreich war.
* Specifies whether the kernel was successfully initialised
*/
bool GetInitSuccess() { return _InitSuccess; }
/**
@brief Gibt einen Pointer auf den BS_ResourceManager zurück.
*/
BS_ResourceManager* GetResourceManager() { return _pResourceManager; }
* Returns a pointer to the BS_ResourceManager
*/
BS_ResourceManager *GetResourceManager() { return _pResourceManager; }
/**
@brief Gibt zurück wie viel Speicher von diesem Prozess belegt ist.
*/
* Returns how much memory is being used
*/
size_t GetUsedMemory();
/**
@brief Gibt eine Zufallszahl zurück.
@param Min der minimale Wert, den die Zufallszahl haben darf
@param Max der maximale Wert, den die Zufallszahl haben darf
@return Gibt eine Zufallszahl zurück, die zwischen Min und Max liegt.
*/
* Returns a random number
* @param Min The minimum allowed value
* @param Max The maximum allowed value
*/
int GetRandomNumber(int Min, int Max);
/**
@brief Gibt einen Pointer auf den aktiven Gfx-Service zurück oder NULL wenn kein Gfx-Service aktiv.
*/
BS_GraphicEngine * GetGfx();
* Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active
*/
BS_GraphicEngine *GetGfx();
/**
@brief Gibt einen Pointer auf den aktiven Sfx-Service zurück oder NULL wenn kein Sfx-Service aktiv.
*/
BS_SoundEngine * GetSfx();
* Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active
*/
BS_SoundEngine *GetSfx();
/**
@brief Gibt einen Pointer auf den aktiven Input-Service zurück oder NULL wenn kein Input-Service aktiv.
*/
BS_InputEngine * GetInput();
* Returns a pointer to the active input service, or NULL if no input service is active
*/
BS_InputEngine *GetInput();
/**
@brief Gibt einen Pointer auf den aktiven Package-Service zurück oder NULL wenn kein Package-Service aktiv.
*/
BS_PackageManager * GetPackage();
* Returns a pointer to the active package manager, or NULL if no manager is active
*/
BS_PackageManager *GetPackage();
/**
@brief Gibt einen Pointer auf den aktiven Script-Service zurück oder NULL wenn kein Script-Service aktiv.
*/
BS_ScriptEngine * GetScript();
* Returns a pointer to the script engine, or NULL if it is not active
*/
BS_ScriptEngine *GetScript();
/**
@brief Gibt einen Pointer auf den aktiven FMV-Service zurück oder NULL wenn kein FMV-Service aktiv.
*/
BS_MoviePlayer * GetFMV();
* Returns a pointer to the movie player, or NULL if it is not active
*/
BS_MoviePlayer *GetFMV();
/**
@brief Stoppt den Prozess für eine gewisse Zeit.
@param Msecs Zeit in Millisekunden, die der Prozess gestoppt werden soll.
@remark Es wird nicht garantiert, dass der Prozess genau nach der angegebenen Zeit wieder aktiv wird.
*/
* Pauses for the specified amount of time
* @param Msecs The amount of time in milliseconds
*/
void Sleep(unsigned int Msecs) const;
/**
@brief Gibt das einzige Exemplar des Kernels zurück (Singleton).
*/
static BS_Kernel * GetInstance()
{
* Returns the singleton instance for the kernel
*/
static BS_Kernel *GetInstance() {
if (!_Instance) _Instance = new BS_Kernel();
return _Instance;
}
/**
@brief Zerstört das einzige Exemplar des Kernels.
@remark Diese Methode darf nur zum Beenden des System aufgerufen werden. Nachfolgende Aufrufe sämtlicher Kernelmethoden liefern
undefinierte Ergebnisse.
*/
static void DeleteInstance()
{
if (_Instance)
{
delete(_Instance);
_Instance = 0;
* Destroys the kernel instance
* This method should only be called when the game is ended. No subsequent calls to any kernel
* methods should be done after calling this method.
*/
static void DeleteInstance() {
if (_Instance) {
delete _Instance;
_Instance = NULL;
}
}
/**
@brief Löst eine Schutzverletzung aus.
@remark Diese Methode dient zum Testen des Crash-Handlings.
*/
void Crash() const
{
error(0);
* Raises an error. This method is used in crashing testing.
*/
void Crash() const {
error("BS_Kernel::Crash");
}
private:
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// Private da Singleton
// Constructor / destructor
// Private singleton methods
// -----------------------------------------------------------------------------
BS_Kernel();
virtual ~BS_Kernel();
// -----------------------------------------------------------------------------
// Singleton-Exemplar
// Singleton instance
// -----------------------------------------------------------------------------
static BS_Kernel * _Instance;
static BS_Kernel *_Instance;
// Service Daten
// -------------
class Superclass
{
// Superclass class
// ----------------
class Superclass {
private:
BS_Kernel* _pKernel;
unsigned int _ServiceCount;
std::string _Identifier;
BS_Service* _ActiveService;
std::string _ActiveServiceName;
BS_Kernel *_pKernel;
unsigned int _ServiceCount;
Common::String _Identifier;
BS_Service *_ActiveService;
Common::String _ActiveServiceName;
public:
Superclass (BS_Kernel* pKernel, const std::string& Identifier);
Superclass (BS_Kernel *pKernel, const Common::String &Identifier);
~Superclass();
unsigned int GetServiceCount() const { return _ServiceCount; }
std::string GetIdentifier() const { return _Identifier; }
BS_Service* GetActiveService() const { return _ActiveService; }
std::string GetActiveServiceName() const { return _ActiveServiceName; }
std::string GetServiceIdentifier(unsigned int Number);
BS_Service* NewService(const std::string& ServiceIdentifier);
Common::String GetIdentifier() const { return _Identifier; }
BS_Service *GetActiveService() const { return _ActiveService; }
Common::String GetActiveServiceName() const { return _ActiveServiceName; }
Common::String GetServiceIdentifier(unsigned int Number);
BS_Service *NewService(const Common::String &ServiceIdentifier);
bool DisconnectService();
};
std::vector<Superclass*> _SuperclassList;
std::stack<std::string> _ServiceCreationOrder;
Superclass* GetSuperclassByIdentifier(const std::string& Identifier);
Common::Array<Superclass*> _SuperclassList;
Common::Stack<Common::String> _ServiceCreationOrder;
Superclass *GetSuperclassByIdentifier(const Common::String &Identifier);
bool _InitSuccess; // Gibt an, ob die Konstruktion erfolgreich war
bool _Running; // Gibt an, ob die Applikation im nächsten Durchlauf des Main-Loops noch weiterlaufen soll
bool _InitSuccess; // Specifies whether the engine was set up correctly
bool _Running; // Specifies whether the application should keep running on the next main loop iteration
// Fenster Variablen
// -----------------
BS_Window* _pWindow;
// Active window
// -------------
BS_Window *_pWindow;
// Random number generator
// -----------------------
Common::RandomSource _rnd;
/*
// CPU-Feature Variablen und Methoden
// Features variables and methods
// ----------------------------------
enum _CPU_FEATURES_BITMASKS
{
@ -312,32 +299,34 @@ private:
bool _3DNowPresent;
bool _3DNowExtPresent;
CPU_TYPES _CPUType;
std::string _CPUVendorID;
Common::String _CPUVendorID;
*/
// Resourcemanager
// ---------------
BS_ResourceManager* _pResourceManager;
BS_ResourceManager *_pResourceManager;
bool _RegisterScriptBindings();
};
// Dies ist nur eine kleine Klasse, die die Daten eines Services verwaltet.
// Ist ein wenig unschön, ich weiss, aber mit std::string ließ sich dass nicht mit einer
// einfachen struct bewerkstelligen.
class BS_ServiceInfo
{
/**
* This is only a small class that manages the data of a service. It is a little ugly, I know,
* but with Common::String a simple struct could not be used.
*/
class BS_ServiceInfo {
public:
BS_ServiceInfo(const std::string& SuperclassIdentifier_, const std::string& ServiceIdentifier_, BS_Service* (*CreateMethod_)(BS_Kernel*))
{
BS_ServiceInfo(const Common::String &SuperclassIdentifier_, const Common::String& ServiceIdentifier_,
BS_Service* (*CreateMethod_)(BS_Kernel*)) {
this->SuperclassIdentifier = SuperclassIdentifier_;
this->ServiceIdentifier = ServiceIdentifier_;
this->CreateMethod = CreateMethod_;
};
std::string SuperclassIdentifier;
std::string ServiceIdentifier;
BS_Service* (*CreateMethod)(BS_Kernel*);
Common::String SuperclassIdentifier;
Common::String ServiceIdentifier;
BS_Service* (*CreateMethod)(BS_Kernel *);
};
}
#endif

View File

@ -1,112 +1,107 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
#include <stdio.h>
#include <stdarg.h>
#include <string>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "sword25/kernel/filesystemutil.h"
#include "sword25/kernel/log.h"
#include "sword25/kernel/debug/debugtools.h"
#include "base/version.h"
#include "common/config-manager.h"
#include "common/fs.h"
// Konstanten
static const char* BF_LOG_FILENAME = "log.txt";
namespace Sword25 {
// Constants
static const char *BF_LOG_FILENAME = "log.txt";
static const size_t LOG_BUFFERSIZE = 1024 * 16;
// Logging soll nur stattfinden wenn es aktiviert ist
// Logging will take place only when it's activated
#ifdef BS_ACTIVATE_LOGGING
FILE* BS_Log::_LogFile = NULL;
bool BS_Log::_LineBegin = true;
const char* BS_Log::_Prefix = NULL;
const char* BS_Log::_File = NULL;
int BS_Log::_Line = 0;
bool BS_Log::_AutoNewline = false;
std::vector<BS_Log::LOG_LISTENER_CALLBACK> BS_Log::_LogListener;
Common::WriteStream* BS_Log::_LogFile = NULL;
bool BS_Log::_LineBegin = true;
const char * BS_Log::_Prefix = NULL;
const char * BS_Log::_File = NULL;
int BS_Log::_Line = 0;
bool BS_Log::_AutoNewline = false;
Common::Array<BS_Log::LOG_LISTENER_CALLBACK> BS_Log::_LogListener;
bool BS_Log::_CreateLog()
{
// Logfile öffnen
BS_FileSystemUtil::GetInstance().CreateDirectory(BS_FileSystemUtil::GetInstance().GetUserdataDirectory());
_LogFile = fopen((BS_FileSystemUtil::GetInstance().GetUserdataDirectory() + "\\" + BF_LOG_FILENAME).c_str(), "w");
bool BS_Log::_CreateLog() {
// Open the log file
Common::FSNode dataDir(ConfMan.get("path"));
Common::FSNode file = dataDir.getChild(BF_LOG_FILENAME);
if (_LogFile)
{
// Sicherstellen, dass es beim Beenden geschlossen wird
atexit(_CloseLog);
// Open the file for saving
_LogFile = file.createWriteStream();
// Titelzeile in das Logfile schreiben
Log("Broken Sword 2.5 Engine - Build: %s - %s - VersionID: %s\n", __DATE__, __TIME__, BS_Debugtools::GetVersionID());
if (_LogFile) {
// Add a title into the log file
Log("Broken Sword 2.5 Engine - Build: %s - %s - VersionID: %s\n", __DATE__, __TIME__, gScummVMFullVersion);
Log("-----------------------------------------------------------------------------------------------------\n");
return true;
}
// Log-File konnte nicht erstellt werden
// Log file could not be created
return false;
}
void BS_Log::_CloseLog()
{
if (_LogFile) fclose(_LogFile);
void BS_Log::_CloseLog() {
delete _LogFile;
_LogFile = NULL;
}
void BS_Log::Log(const char* Format, ...)
{
void BS_Log::Log(const char *Format, ...) {
char Message[LOG_BUFFERSIZE];
// Nachricht erzeugen
// Create the message
va_list ArgList;
va_start(ArgList, Format);
_vsnprintf(Message, sizeof(Message), Format, ArgList);
// Nachricht loggen
// Log the message
_WriteLog(Message);
_FlushLog();
}
void BS_Log::LogPrefix(const char* Prefix, const char* Format, ...)
{
void BS_Log::LogPrefix(const char *Prefix, const char *Format, ...) {
char Message[LOG_BUFFERSIZE];
char ExtFormat[LOG_BUFFERSIZE];
// Falls die Ausgabe am Anfang einer neuen Zeile aufgehört hat, muss die neue Ausgabe mit dem Präfix
// beginnen
// If the issue has ceased at the beginning of a new line, the new issue to begin with the prefix
ExtFormat[0] = 0;
if (_LineBegin)
{
if (_LineBegin) {
_snprintf(ExtFormat, sizeof(ExtFormat), "%s%s: ", ExtFormat, Prefix);
_LineBegin = false;
}
// Formatstring zeilenweise durchgehen und an jeden Zeilenanfang das Präfix setzen
for (;;)
{
const char* NextLine = strstr(Format, "\n");
if (!NextLine || *(NextLine + strlen("\n")) == 0)
{
// Format String pass line by line and each line with the initial prefix
for (;;) {
const char *NextLine = strstr(Format, "\n");
if (!NextLine || *(NextLine + strlen("\n")) == 0) {
_snprintf(ExtFormat, sizeof(ExtFormat), "%s%s", ExtFormat, Format);
if (NextLine) _LineBegin = true;
break;
}
else
{
} else {
strncat(ExtFormat, Format, (NextLine - Format) + strlen("\n"));
_snprintf(ExtFormat, sizeof(ExtFormat), "%s%s: ", ExtFormat, Prefix);
}
@ -114,19 +109,18 @@ void BS_Log::LogPrefix(const char* Prefix, const char* Format, ...)
Format = NextLine + strlen("\n");
}
// Nachricht erzeugen
// Create message
va_list ArgList;
va_start(ArgList, Format);
_vsnprintf(Message, sizeof(Message), ExtFormat, ArgList);
// Nachricht schreiben
// Log the message
_WriteLog(Message);
_FlushLog();
}
void BS_Log::LogDecorated(const char* Format, ...)
{
void BS_Log::LogDecorated(const char *Format, ...) {
// Nachricht erzeugen
char Message[LOG_BUFFERSIZE];
va_list ArgList;
@ -139,15 +133,12 @@ void BS_Log::LogDecorated(const char* Format, ...)
_snprintf(SecondaryPrefix, sizeof(SecondaryPrefix), "(file: %s, line: %d) - ", _File, _Line);
// Nachricht zeilenweise ausgeben und an jeden Zeilenanfang das Präfix setzen
char* MessageWalker = Message;
for (;;)
{
char* NextLine = strstr(MessageWalker, "\n");
if (NextLine)
{
char *MessageWalker = Message;
for (;;) {
char *NextLine = strstr(MessageWalker, "\n");
if (NextLine) {
*NextLine = 0;
if (_LineBegin)
{
if (_LineBegin) {
_WriteLog(_Prefix);
if (_File && _Line)
_WriteLog(SecondaryPrefix);
@ -156,11 +147,8 @@ void BS_Log::LogDecorated(const char* Format, ...)
_WriteLog("\n");
MessageWalker = NextLine + sizeof("\n") - 1;
_LineBegin = true;
}
else
{
if (_LineBegin)
{
} else {
if (_LineBegin) {
_WriteLog(_Prefix);
if (_File && _Line)
_WriteLog(SecondaryPrefix);
@ -172,8 +160,7 @@ void BS_Log::LogDecorated(const char* Format, ...)
}
// Falls gewünscht, wird ans Ende der Nachricht automatisch ein Newline angehängt.
if (_AutoNewline)
{
if (_AutoNewline) {
_WriteLog("\n");
_LineBegin = true;
}
@ -187,38 +174,32 @@ void BS_Log::LogDecorated(const char* Format, ...)
_FlushLog();
}
int BS_Log::_WriteLog(const char* Message)
{
int BS_Log::_WriteLog(const char * Message) {
if (!_LogFile) if (!_CreateLog()) return false;
std::vector<LOG_LISTENER_CALLBACK>::iterator Iter = _LogListener.begin();
Common::Array<LOG_LISTENER_CALLBACK>::iterator Iter = _LogListener.begin();
for (; Iter != _LogListener.end(); ++Iter)
(*Iter)(Message);
fprintf(_LogFile, Message);
_LogFile->writeString(Message);
return true;
}
void BS_Log::_FlushLog()
{
fflush(_LogFile);
void BS_Log::_FlushLog() {
_LogFile->flush();
}
void (*BS_LogPtr)(const char *, ...) = BS_Log::Log;
extern "C"
{
void BS_Log_C(const char* Message)
{
BS_LogPtr(Message);
}
void BS_Log_C(const char *Message) {
BS_LogPtr(Message);
}
#else
extern "C"
{
void BS_Log_C(const char* Message) {};
}
void BS_Log_C(const char* Message) {};
#endif
} // End of namespace Sword25

View File

@ -1,35 +1,38 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_LOG_H
#define SWORD25_LOG_H
// Includes
#include "sword25/kernel/memlog_off.h"
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include "sword25/kernel/memlog_on.h"
#include "common/array.h"
#include "common/file.h"
#include "sword25/kernel/common.h"
namespace Sword25 {
// Logging soll nur stattfinden wenn es aktiviert ist
#ifdef BS_ACTIVATE_LOGGING
@ -59,33 +62,38 @@ public:
typedef void (*LOG_LISTENER_CALLBACK)(const char *);
static void RegisterLogListener(LOG_LISTENER_CALLBACK Callback) { _LogListener.push_back(Callback); }
static bool IsListenerRegistered(LOG_LISTENER_CALLBACK Callback) { return std::find(_LogListener.begin(), _LogListener.end(), Callback) != _LogListener.end(); }
static bool IsListenerRegistered(LOG_LISTENER_CALLBACK Callback) {
Common::Array<LOG_LISTENER_CALLBACK>::iterator i;
for (i = _LogListener.begin(); i != _LogListener.end(); ++i) {
if (**i == Callback)
return true;
}
return false;
}
static void _CloseLog();
private:
static FILE* _LogFile;
static Common::WriteStream * _LogFile;
static bool _LineBegin;
static const char* _Prefix;
static const char* _File;
static const char * _Prefix;
static const char * _File;
static int _Line;
static bool _AutoNewline;
static std::vector<LOG_LISTENER_CALLBACK> _LogListener;
static Common::Array<LOG_LISTENER_CALLBACK> _LogListener;
static bool _CreateLog();
static void _CloseLog();
static int _WriteLog(const char* Message);
static void _FlushLog();
};
// Hilfsfunktion, die es C-Funktionen ermöglicht zu loggen (wird für Lua gebraucht).
extern "C"
{
void BS_Log_C(const char* Message);
}
// Auxiliary function that allows to log C functions (needed for Lua).
#define BS_Log_C error
#else
// Logging-Makros
// Logging-Macros
#define BS_LOG
#define BS_LOGLN
#define BS_LOG_WARNING
@ -95,11 +103,10 @@ extern "C"
#define BS_LOG_EXTERROR
#define BS_LOG_EXTERRORLN
// Die Version der Logging-Klasse mit deaktiviertem Logging
class BS_Log
{
// The version of the logging class with logging disabled
class BS_Log {
public:
// Die Log Funktionen werden zu do-nothing Funktionen und wird daher vom Compiler (hoffentlich) rausoptimiert
// This version implements all the various methods as empty stubs
static void Log(const char* Text, ...) {};
static void LogPrefix(const char* Prefix, const char* Format, ...) {};
static void LogDecorated(const char* Format, ...) {};
@ -113,11 +120,10 @@ public:
static void RegisterLogListener(LOG_LISTENER_CALLBACK Callback) {};
};
extern "C"
{
void BS_Log_C(const char* Message);
}
#define BS_Log_C error
#endif
} // End of namespace Sword25
#endif

View File

@ -1,21 +1,27 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_MEMLEAKS_H
#define SWORD25_MEMLEAKS_H
@ -26,8 +32,6 @@
#pragma warning(disable : 4291)
#endif
#include "sword25/kernel/memlog_off.h"
#include <malloc.h>
void DumpUnfreed(const char * OutputFilename);
@ -55,6 +59,4 @@ inline void __cdecl operator delete[](void *p)
#endif
#include "memlog_on.h"
#endif

View File

@ -1,36 +1,44 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_PERSISTABLE_H
#define SWORD25_PERSISTABLE_H
namespace Sword25 {
class BS_OutputPersistenceBlock;
class BS_InputPersistenceBlock;
class BS_Persistable
{
class BS_Persistable {
public:
virtual ~BS_Persistable() {};
virtual bool Persist(BS_OutputPersistenceBlock & Writer) = 0;
virtual bool Unpersist(BS_InputPersistenceBlock & Reader) = 0;
};
} // End of namespace Sword25
#endif

View File

@ -1,21 +1,27 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_PERSISTENCESERVICE_H
#define SWORD25_PERSISTENCESERVICE_H
@ -25,42 +31,38 @@
// -----------------------------------------------------------------------------
#include "sword25/kernel/common.h"
#include "sword25/kernel/memlog_off.h"
#include <string>
#include <vector>
#include "sword25/kernel/memlog_on.h"
namespace Sword25 {
// -----------------------------------------------------------------------------
// Class declaration
// -----------------------------------------------------------------------------
class BS_PersistenceService
{
class BS_PersistenceService {
public:
BS_PersistenceService();
virtual ~BS_PersistenceService();
// -----------------------------------------------------------------------------
// Singleton-Methode
// Singleton Method
// -----------------------------------------------------------------------------
static BS_PersistenceService & GetInstance();
static BS_PersistenceService &GetInstance();
// -----------------------------------------------------------------------------
// Interface
// -----------------------------------------------------------------------------
static unsigned int GetSlotCount();
static std::string GetSavegameDirectory();
static Common::String GetSavegameDirectory();
void ReloadSlots();
bool IsSlotOccupied(unsigned int SlotID);
bool IsSavegameCompatible(unsigned int SlotID);
std::string & GetSavegameDescription(unsigned int SlotID);
std::string & GetSavegameFilename(unsigned int SlotID);
Common::String &GetSavegameDescription(unsigned int SlotID);
Common::String &GetSavegameFilename(unsigned int SlotID);
bool SaveGame(unsigned int SlotID, const std::string & ScreenshotFilename);
bool SaveGame(unsigned int SlotID, const Common::String & ScreenshotFilename);
bool LoadGame(unsigned int SlotID);
private:
@ -68,4 +70,6 @@ private:
Impl * m_impl;
};
} // End of namespace Sword25
#endif

View File

@ -1,123 +1,119 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*/
#ifndef SWORD25_RESOURCEMANAGER_H
#define SWORD25_RESOURCEMANAGER_H
// Includes
#include "sword25/kernel/memlog_off.h"
#include <vector>
#include <list>
#include "sword25/kernel/memlog_on.h"
#include "common/list.h"
#include "sword25/kernel/common.h"
// Klassendefinition
namespace Sword25 {
// Class definitions
class BS_ResourceService;
class BS_Resource;
class BS_Kernel;
class BS_ResourceManager
{
class BS_ResourceManager {
friend class BS_Kernel;
public:
/**
@brief Fordert eine Resource an.
@param FileName Dateiname
@return Gibt die Resource zurück, falls erfolgreich, sonst NULL
*/
BS_Resource* RequestResource(const std::string& FileName);
* Returns a requested resource. If any error occurs, returns NULL
* @param FileName Filename of resource
*/
BS_Resource *RequestResource(const Common::String &FileName);
/**
@brief Lädt eine Resource in den Cache.
@param FileName der Dateiname der zu cachenden Resource
@param ForceReload gibt an, ob die Datei auch neu geladen werden soll, wenn sie bereits geladen wurde.
Dies ist nützlich bei Dateien, die sich in der Zwischenzeit verändert haben.
@return Gibt true zurück, wenn das Caching durchgeführt werden konnte, ansonsten false.
*/
bool PrecacheResource(const std::string& FileName, bool ForceReload = false);
* Loads a resource into the cache
* @param FileName The filename of the resource to be cached
* @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
* This is useful for files that may have changed in the interim
*/
bool PrecacheResource(const Common::String& FileName, bool ForceReload = false);
/**
@brief Gibt die Anzahl der geladenen Resourcen zurück.
*/
* Returns the number of loaded resources
*/
int GetResourceCount() const { return static_cast<int>(m_Resources.size()); }
/**
@brief Gibt einen Pointer auf eine Resource anhand deren laufender Nummer zurück.
@param Ord laufende Nummer der Resource. Dieser Wert muss zwischen 0 und GetResourceCount() - 1 liegen.
@return Gibt einen Pointer auf die Resource zurück wenn erfolgreich, ansonsten NULL.
@remark Diese Methode ist nicht auf Geschwindigkeit optimiert und sollte nur für Debugzwecke eingesetzt werden.
* Returns a resource by it's ordinal index. Returns NULL if any error occurs
* Note: This method is not optimised for speed and should be used only for debugging purposes
* @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
*/
BS_Resource* GetResourceByOrdinal(int Ord) const;
BS_Resource *GetResourceByOrdinal(int Ord) const;
/**
@brief RegisterResourceService Diese Methode wird vom Konstruktor von
BS_ResourceService aufgerufen und trägt somit alle
Resource-Services in einen Liste des
Resource-Managers ein.
@param pService welches Service
@return gibt true zurück, falls erfolgreich
*/
* Registers a RegisterResourceService. This method is the constructor of
* BS_ResourceService, and thus helps all resource services in the ResourceManager list
* @param pService Which service
*/
bool RegisterResourceService(BS_ResourceService* pService);
/**
* @brief gibt alle Resourcen frei, die nicht gelocked sind.
* Releases all resources that are not locked.
**/
void EmptyCache();
/**
@brief Gibt zurück wie viel Speicher die Engine maximal belegen soll.
*/
* Returns the maximum memory the kernel has used
*/
int GetMaxMemoryUsage() const { return m_MaxMemoryUsage; }
/**
@brief Legt fest wie viel Speicher die Engine maximal belegen soll.
Wenn dieser Wert überschritten wird, werden Resourcen entladen um Platz zu schaffen. Dieser Wert ist als Richtgröße zu verstehen und nicht als feste Grenze.
Es ist unter KEINEN Umständen garantiert, dass die Engine tatsächlich nur so viel Speicher benutzt.
*/
* Specifies the maximum amount of memory the engine is allowed to use.
* If this value is exceeded, resources will be unloaded to make room. This value is meant
* as a guideline, and not as a fixed boundary. It is not guaranteed not to be exceeded;
* the whole game engine may still use more memory than any amount specified.
*/
void SetMaxMemoryUsage(unsigned int MaxMemoryUsage);
/**
@brief Gibt an, ob eine Warnung ins Log geschrieben wird, wenn ein Cache-Miss auftritt.
Der Standardwert ist "false".
*/
* Specifies whether a warning is written to the log when a cache miss occurs.
* THe default value is "false".
*/
bool IsLogCacheMiss() const { return m_LogCacheMiss; }
/**
@brief Legt fest, ob eine Warnung ins Log geschrieben wird, wenn in Cache-Miss auftritt.
@param Flag wenn "true" wird die Warnung in Zukunft ausgegeben, ansonsten nicht.
*/
* Sets whether warnings are written to the log if a cache miss occurs.
* @param Flag If "true", then future warnings will be logged
*/
void SetLogCacheMiss(bool Flag) { m_LogCacheMiss = Flag; }
/**
@brief Schreibt die Namen aller gelockten Resourcen in die Log-Datei.
*/
* Writes the names of all currently locked resources to the log file
*/
void DumpLockedResources();
private:
/**
@brief Erzeugt einen neuen Resource-Manager.
@param pKernel ein Pointer auf den Kernel.
@remark Nur der BS_Kernel darf Exemplare dieser Klasse erzeugen. Daher ist der Konstruktor private.
*/
* Creates a new resource manager
* Only the BS_Kernel class can generate copies this class. Thus, the constructor is private
*/
BS_ResourceManager(BS_Kernel* pKernel) :
m_KernelPtr(pKernel),
m_MaxMemoryUsage(100000000),
@ -131,55 +127,52 @@ private:
};
/**
@brief Verschiebt eine Resource an die Spitze der Resourcenliste.
@param pResource die Resource
*/
void MoveToFront(BS_Resource* pResource);
* Moves a resource to the top of the resource list
* @param pResource The resource
*/
void MoveToFront(BS_Resource *pResource);
/**
@brief Lädt eine Resource und aktualisiert m_UsedMemory.
Die Resource darf nicht bereits geladen sein.
@param FileName der absolute und eindeutige Dateiname der zu ladenen Resource
@return Gibt einen Pointer auf die geladene Resource zurück wenn das Laden erfolgreich war, ansonsten NULL.
*/
BS_Resource* LoadResource(const std::string& FileName);
* Loads a resource and updates the m_UsedMemory total
*
* The resource must not already be loaded
*
* @param FileName The unique filename of the resource to be loaded
*
*/
BS_Resource *LoadResource(const Common::String &FileName);
/**
@brief Gibt zu einer Datei ihren absoluten, eindeutigen Pfad zurück.
@param FileName der Dateiname
@return Der absolute, eindeutige Pfad zur Datei inklusive des Dateinamens.<br>
Gibt einen leeren std::string zurück, wenn der Pfad nicht erzeugt werden konnte.
* Returns the full path of a given resource filename.
* It will return an empty string if a path could not be created.
*/
std::string GetUniqueFileName(const std::string& FileName) const;
Common::String GetUniqueFileName(const Common::String &FileName) const;
/**
@brief Löscht eine Resource entfernt sie aus den Listen und aktualisiert m_UsedMemory.
@param pResource die zu löschende Resource
@return Gibt einen Iterator zurück, der auf die nächste Resource in der Resourcenliste zeigt.
*/
std::list<BS_Resource*>::iterator DeleteResource(BS_Resource* pResource);
* Deletes a resource, removes it from the lists, and updates m_UsedMemory
*/
Common::List<BS_Resource*>::iterator DeleteResource(BS_Resource *pResource);
/**
@brief Holt einen Pointer zu einer geladenen Resource.
@param UniqueFileName der absolute, eindeutige Pfad zur Datei inklusive des Dateinamens.
@return Gibt einen Pointer auf die angeforderte Resource zurück, oder NULL, wenn die Resourcen nicht geladen ist.
*/
BS_Resource* GetResource(const std::string& UniqueFileName) const;
* Returns a pointer to a loaded resource. If any error occurs, NULL will be returned.
* @param UniqueFileName The absolute path and filename
* Gibt einen Pointer auf die angeforderte Resource zurück, oder NULL, wenn die Resourcen nicht geladen ist.
*/
BS_Resource *GetResource(const Common::String &UniqueFileName) const;
/**
@brief Löscht solange Resourcen, bis der Prozess unter das angegebene Maximun an Speicherbelegung kommt.
*/
* Deletes resources as necessary until the specified memory limit is not being exceeded.
*/
void DeleteResourcesIfNecessary();
BS_Kernel* m_KernelPtr;
BS_Kernel * m_KernelPtr;
unsigned int m_MaxMemoryUsage;
std::vector<BS_ResourceService*> m_ResourceServices;
std::list<BS_Resource*> m_Resources;
std::list<BS_Resource*> m_ResourceHashTable[HASH_TABLE_BUCKETS];
Common::Array<BS_ResourceService *> m_ResourceServices;
Common::List<BS_Resource *> m_Resources;
Common::List<BS_Resource *> m_ResourceHashTable[HASH_TABLE_BUCKETS];
bool m_LogCacheMiss;
};
#endif
} // End of namespace Sword25
#endif

View File

@ -1,21 +1,27 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_RESOURCESERVICE_H
#define SWORD25_RESOURCESERVICE_H
@ -26,10 +32,11 @@
#include "sword25/kernel/kernel.h"
#include "sword25/kernel/resmanager.h"
namespace Sword25 {
class BS_Resource;
class BS_ResourceService : public BS_Service
{
class BS_ResourceService : public BS_Service {
public:
BS_ResourceService(BS_Kernel* pKernel) : BS_Service(pKernel)
{
@ -41,70 +48,66 @@ public:
/**
@brief Lädt eine Resource.
@param FileName Dateiname
@return gibt die Resource zurück, falls erfolgreich, ansonsten NULL
*/
virtual BS_Resource* LoadResource(const std::string& FileName) = 0;
* Loads a resource
* @return Returns the resource if successful, otherwise NULL
*/
virtual BS_Resource *LoadResource(const Common::String &FileName) = 0;
/**
@brief CanLoadResource prüft, ob Resource vom Service geladen werden kann.
@param FileName Dateiname
@return true, falls Service Resource laden kann
@remark Überprüfung basiert auf dem Dateinamen, wenn das Dateiformat nicht passt, gibts Ärger.
*/
virtual bool CanLoadResource(const std::string& FileName) = 0;
* Checks whether the given name can be loaded by the resource service
* @param FileName Dateiname
* @return Returns true if the resource can be loaded.
*/
virtual bool CanLoadResource(const Common::String& FileName) = 0;
protected:
// Hilfsmethoden für BS_ResourceService Klassen
// Alternative methods for classes BS_ResourceService
/**
@brief Vergleicht zwei Strings, wobei der zweite String die Wildcards * und ? enthalten darf
@param String der erste Vergleichsstring. Dieser darf keine Wildcards enthalten.
@param Pattern der zweite Vergleichsstring. Dieser darf die Wildcards * und ? enthalten.
@return Gibt true zurück, wenn der String auf das Pattern passt, ansonsten false.
*/
bool _WildCardStringMatch(const std::string& String, const std::string& Pattern)
{
* Compares two strings, with the second string allowed to contain '*' and '?' wildcards
* @param String The first comparison string. This must not contain wildcards
* @param Pattern The sceond comaprison string. Wildcards of '*' and '?' are allowed.
* @return Returns true if the string matches the pattern, otherwise false.
*/
bool _WildCardStringMatch(const Common::String &String, const Common::String &Pattern) {
return _WildCardStringMatchRecursion(String.c_str(), Pattern.c_str());
}
private:
bool _WildCardStringMatchRecursion(const char* String, const char* Pattern)
{
// Rekursionsabschlüsse:
// 1. Der Pattern-String enthält nur noch * -> TRUE
if (*Pattern == '*')
{
// Es muss mit einer Kopie von Pattern gearbeitet werden um den aktuellen Zustand nicht zu zerstören
char* PatternCopy = (char*) Pattern;
bool _WildCardStringMatchRecursion(const char *String, const char *Pattern) {
// Checks:
// 1. The pattern starts with '*' -> TRUE
if (*Pattern == '*') {
// Use a copy of the pattern pointer so as not to destroy the current state
char *PatternCopy = (char *)Pattern;
while (*PatternCopy == '*') { PatternCopy++; }
if (!*PatternCopy) return true;
}
// 2. Der String ist zuende, das Pattern aber noch nicht -> FALSE
// 2. The string is over, but the patern is not -> FALSE
if (!*String && *Pattern) return false;
// 3. Der String ist zuende, also ist auch das Pattern zuende (s.o.) -> TRUE
// 3. The string is over, and the pattern is finished -> TRUE
if (!*String) return true;
// Rekursionsaufruf 1:
// Falls die beiden aktuellen Zeichen gleich sind, oder Pattern '?' ist wird das Ergebnis von restlichen String zurückgegeben
// Recursive check 1:
// If the two current characters are the same, or pattern '?', then keep scanning
if (*String == *Pattern || *Pattern == '?') return _WildCardStringMatchRecursion(String + 1, Pattern + 1);
// Falls nicht, wird untersucht ob ein '*' vorliegt
if (*Pattern == '*')
{
// Rekursionsaufruf 2:
// Zunächst wird das Ergebnis von String und Pattern + 1 untersucht...
if (*Pattern == '*') {
// Recursive check 2:
// First the result of strign and pattern + 1 is examined..
if (_WildCardStringMatchRecursion(String, Pattern + 1)) return true;
// Falls das fehlschlägt, wird das Ergebnis von String + 1 Pattern zurückgegeben
// If this fails, the result of string + 1 pattern is returned
else return _WildCardStringMatchRecursion(String + 1, Pattern);
// Die Rekursion kehrt also immer wieder an diese Stelle zurück, bis das Zeichen in String,
// dem nach dem '*' in Pattern entspricht
// The recursion ends, therefore, keep returning to this place until a character
// in the string which corresponds to the '*' in pattern
}
// Wenn kein '*' in Pattern vorliegt, schlägt der Vergleich fehl
// The match has failed
return false;
}
};
} // End of namespace Sword25
#endif

View File

@ -1,34 +1,35 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
BS_Service
-------------
Dies ist die Basisklasse für alle Services der Engine.
Ein Service ist ein wesentlicher Bestandteil des Engine, z.B. die Graphiksystem.
Das Servicesystem macht es möglich mehrere verschiedene Services für ein System zu haben,
und je nach Betriebssystem einen passenden auszuwählen.
Denkbar wären z.B. zwei Graphiksysteme von denen eines hardwarebeschleunigt ist und ein
anderes nicht.
Die Services werden zur Laufzeit über die Kernelmethode NewService und NIEMALS mit new erzeugt.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_Service
* -------------
* This is the base class for all engine services.
* A serivce is an essential part of the engine, ex. the graphics system.
* This was intended to allow, for example, different plug in modules for
* different kinds of hardware and/or systems.
* The services are created at runtime via the kernel method NewService and NEVER with new.
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_SERVICE_H
@ -37,21 +38,24 @@
// Includes
#include "sword25/kernel/common.h"
namespace Sword25 {
// Klassendefinition
class BS_Kernel;
class BS_Service
{
class BS_Service {
private:
BS_Kernel* _pKernel;
BS_Kernel * _pKernel;
protected:
BS_Service(BS_Kernel* pKernel) : _pKernel(pKernel) {};
BS_Service(BS_Kernel *pKernel) : _pKernel(pKernel) {};
BS_Kernel* GetKernel() const { return _pKernel; }
public:
virtual ~BS_Service(){};
virtual ~BS_Service() {};
};
} // End of namespace Sword25
#endif

View File

@ -1,43 +1,51 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
service_ids.h
-------------
In dieser Datei sind alle Services verzeichnet.
JEDER neuer Service muss hier eingetragen werden, ansonsten kann er nicht mit
pKernel->NewService(..) instanziiert werden.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* service_ids.h
* -------------
* This file lists all the services.
* EVERY new service needs to be entered here, otherwise it cannot be instantiated
* by pKernel->NewService(..)
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_SERVICE_IDS
#define SWORD25_SERVICE_IDS
#include "sword25/kernel/common.h"
BS_Service * BS_OpenGLGfx_CreateObject(BS_Kernel* pKernel);
BS_Service * BS_PhysfsPackageManager_CreateObject(BS_Kernel* pKernel);
BS_Service * BS_StdWinInput_CreateObject(BS_Kernel* pKernel);
BS_Service * BS_FMODExSound_CreateObject(BS_Kernel* pKernel);
BS_Service * BS_LuaScriptEngine_CreateObject(BS_Kernel* pKernel);
BS_Service * BS_Geometry_CreateObject(BS_Kernel* pKernel);
BS_Service * BS_OggTheora_CreateObject(BS_Kernel* pKernel);
namespace Sword25 {
// Services müssen in dieser Tabelle eingetragen werden
BS_Service *BS_OpenGLGfx_CreateObject(BS_Kernel* pKernel);
BS_Service *BS_PhysfsPackageManager_CreateObject(BS_Kernel* pKernel);
BS_Service *BS_StdWinInput_CreateObject(BS_Kernel* pKernel);
BS_Service *BS_FMODExSound_CreateObject(BS_Kernel* pKernel);
BS_Service *BS_LuaScriptEngine_CreateObject(BS_Kernel* pKernel);
BS_Service *BS_Geometry_CreateObject(BS_Kernel* pKernel);
BS_Service *BS_OggTheora_CreateObject(BS_Kernel* pKernel);
// Services are recorded in this table
const BS_ServiceInfo BS_SERVICE_TABLE[] =
{
// Die ersten beiden Parameter sind die Namen der Superclass und des Services.
@ -54,3 +62,7 @@ const BS_ServiceInfo BS_SERVICE_TABLE[] =
};
const unsigned int BS_SERVICE_COUNT = sizeof(BS_SERVICE_TABLE) / sizeof(BS_ServiceInfo);
} // End of namespace Sword25
#endif

View File

@ -1,31 +1,33 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
BS_Window
---------
Simples Fensterklasseninterface.
Ist nur aus Gründen der Portabilität in einer Klasse gekapselt.
TODO: Für andere Betriebssysteme implementieren
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_Window
* ---------
* Simple window class interface. This is being encapsulated in a class for
* reasons of portability.
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_WINDOW_H
#define SWORD25_WINDOW_H
@ -33,15 +35,17 @@
// Includes
#include "sword25/kernel/common.h"
// Klassendefinition
namespace Sword25 {
// Class definitions
/**
@brief Ein Simples Fensterklasseninterface.
Fenster werden ausschließlich mit BS_Window::CreateBSWindow() erstellt. BS_Window wählt
dann selbständig die richtige Klasse für das Betriebssystem aus.
*/
class BS_Window
{
* A simple window class interface
*
* Windows are exclusively created by BS_Window::CreateBSWindow().
* BS_Windows selects the correct class for the environment.
*/
class BS_Window {
protected:
bool _InitSuccess;
bool _CloseWanted;
@ -50,127 +54,111 @@ public:
virtual ~BS_Window(){};
/**
@brief Gibt den Sichtbarkeitsstatus des Fensters zurück
@return Gibt true zurück wenn das Fenster sichtbar ist, andernfalls false
*/
* Returns the visibility of the window.
*/
virtual bool IsVisible() = 0;
/**
@brief Setzt den Sichtbarkeitsstatus des Fensters
@param Visible gibt an, ob das Fenster sichtbar oder versteckt sein soll
*/
* Sets the visibility of the window
* @param Visible Specifies whether the window should be visible or hidden
*/
virtual void SetVisible(bool Visible) = 0;
/**
@brief Gibt die Position des Fensters auf der X-Achse zurück
@return Gibt die Position des Fensters auf der X-Achse zurück
*/
* Returns the X position of the window
*/
virtual int GetX() = 0;
/**
@brief Setzt die Position des Fensters auf der X-Achse
@param X die X-Position des Fensters oder -1 für zentrierte Ausrichtung auf der X-Achse
*/
* Sets the X position of the window
* @paramX The new X position for the window, or -1 for centre aligned
*/
virtual void SetX(int X) = 0;
/**
@brief Gibt die Position des Fensters auf der Y-Achse zurück
@return Gibt die Position des Fensters auf der Y-Achse zurück
*/
* Gets the Y position of the window
*/
virtual int GetY() = 0;
/**
@brief Setzt die Position des Fensters auf der Y-Achse
@param Y die Y-Position des Fensters oder -1 für zentrierte Ausrichtung auf der Y-Achse
*/
* Sets the Y position of the window
* @param Y The new Y position for the window, or -1 for centre aligned
*/
virtual void SetY(int X) = 0;
/**
@brief Gibt die Position des Fensterinhaltes auf der X-Achse zurück
@return Gibt die Position des Fensterinhaltes auf der X-Achse zurück
*/
* Returns the X position of the window's client area
*/
virtual int GetClientX() = 0;
/**
@brief Gibt die Position des Fensterinhaltes auf der Y-Achse zurück
@return Gibt die Position des Fensterinhaltes auf der Y-Achse zurück
*/
/**
* Returns the Y position of the window's client area
*/
virtual int GetClientY() = 0;
/**
@brief Gibt die Breite des Fensters ohne Rahmen zurück
@return Gibt die Breite des Fensters ohne Rahmen zurück
*/
* Returns the width of the window without the frame
*/
virtual int GetWidth() = 0;
/**
@brief Setzt die Breite des Fensters ohne Rahmen
@param Width die Breite des Fensters ohne Rahmen
*/
* Sets the width of the window without the frame
*/
virtual void SetWidth(int Width) = 0;
/**
@brief Gibt die Höhe des Fensters ohne Rahmen und Kopfzeile zurück
@return Gibt die Höhe des Fensters ohne Rahmen und Kopfzeile zurück
*/
* Gets the height of the window without the frame
*/
virtual int GetHeight() = 0;
/**
@brief Setzt die Höhe des Fensters ohne Rahmen und Kopfzeile
@param Height die Höhe des Fensters ohne Rahmen und Kopfzeile
*/
* Sets the height of the window without the frame
*/
virtual void SetHeight(int Height) = 0;
/**
@brief Gibt den Titel der Fensters zurück
@return Gibt den Titel des Fenster zurück
*/
virtual std::string GetTitle() = 0;
* Returns the title of the window
*/
virtual Common::String GetTitle() = 0;
/**
@brief Setzt den Titel des Fensters
@param Title der neue Titel des Fensters
* Sets the title of the window
* @param Title The new window title
*/
virtual void SetTitle(std::string Title) = 0;
virtual void SetTitle(const Common::String &Title) = 0;
/**
@brief Arbeitet die Windowmessages des Fensters ab.
Diese Methode sollte während des Main-Loops aufgerufen werden.
@return Gibt false zurück, falls das Fenster geschlossen wurde.
*/
* Handle the processing of any pending window messages. This method should be called
* during the main loop.
*/
virtual bool ProcessMessages() = 0;
/**
@brief Pausiert die Applikation bis das Fenster wieder den Focus hat oder geschlossen wurde.
@return Gibt false zurück, falls das Fenster geschlossen wurde.
*/
* Pauses the applicaiton until the window has focus, or has been closed.
* Returns false if the window was closed.
*/
virtual bool WaitForFocus() = 0;
/**
@brief Gibt zurück, ob das Fenster den Focus hat.
@return Gibt true zurück, wenn das Fenster den Focus hat, ansonsten false
*/
* Returns true if the window has focus, false otherwise.
*/
virtual bool HasFocus() = 0;
/**
@brief Gibt das Windowhandle, des Systems zurück.
@return Das Windowhandle des Fensters
@remark Wenn das Windowshandle benutzt wird, sind die entsprechenden Codeteile
natürlich nicht mehr portable.
*/
* Returns the system handle that represents the window. Note that any use of the handle
* will not be portable code.
*/
virtual unsigned int GetWindowHandle() = 0;
/**
@brief Setzt den Rückgabewert für den nächsten Aufruf von CloseWanted. Sollte vom
Fenster selbst verwendet werden, wenn es geschlossen werden möchte. Dieser
Mechanismus erlaubt den Scripten abzufragen, wann das Hauptfenster geschlossen
werden soll, und sich entsprechend zu beenden, bzw. beim Nutzer nachzufragen.
**/
* Specifies whether the window is wanted to be closed. This is used together with CloseWanted()
* to allow scripts to query when the main window should be closed, or the user is asking it to close
**/
void SetCloseWanted(bool Wanted);
/**
@brief Gibt einmal den Wert des letztes Aufrufs von SetCloseWanted zurück,
und danach sofort wieder false, solange bis mit SetCloseWanted wieder
ein neuer Wert gesetzt wird.
* Returns the previous value set in a call to SetCloseWanted.
* Note that calling this also resets the value back to false, until such time as the SetCloseWanted()
* method is called again.
**/
bool CloseWanted();
/**
@brief Erstellt eine neue Fensterinstanz.
@param X die X-Position des Fensters oder -1 für zentrierte Ausrichtung auf der X-Achse
@param Y des Y-Position des Fensters oder -1 für zentrierte Ausrichtung auf der Y-Achsen
@param Width die Breite des Fensters ohne Rahmen
@param Height die Höhe des Fensters ohne Rahmen und Kopfzeile
@param Visible gibt an, ob das Fenster dargestellt werden soll
@return Gibt einen Pointer auf ein Fensterobjekt zurück, oder NULL wenn das Erstellen
fehlgeschlagen ist.
@remark Das Fenster muss nach Benutzung mit delete freigegeben werden!
*/
static BS_Window* CreateBSWindow(int X, int Y, int Width, int Height, bool Visible);
* Creates a new window instance. Returns a pointer to the window, or NULL if the creation failed.
* Note: It is the responsibility of the client to free the pointer when done with it.
* @param X The X position of the window, or -1 for centre horizontal alignment
* @param Y The Y position of the window, or -1 for centre vertical alignment
* @param Width The width of the window without the frame
* @param Height The height of the window without the frame
* @param Visible Specifies whether window should be visible
*/
static BS_Window *CreateBSWindow(int X, int Y, int Width, int Height, bool Visible);
};
} // End of namespace Sword25
#endif

View File

@ -1,36 +1,39 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
BS_PackageManager
-------------
Dies ist das Package Manager Interface, dass alle Methoden enthält, die ein Package Manager
implementieren muss.
Beim Package Manager ist folgendes zu beachten:
1. es wird ein komplett neuer (virtueller) Verzeichnisbaum erstellt,
in den Packages und Verzeichnisse gemounted werden können.
2. zum Trennen von Elementen eines Verzeichnisspfades wird '/' statt '\' verwendet.
3. LoadDirectoryAsPackage sollte nur zum Testen benutzt werden. Im Final Release sollen sich
alle Dateien in echten Packages befinden.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen, $author$
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_PackageManager
* -----------------
* This is the package manager interface, that contains all the methods that a package manager
* must implement.
* In the package manager, note the following:
* 1. It creates a completely new (virtual) directory tree in the packages and directories
* can be mounted.
* 2. To seperate elements of a directory path '/' must be used rather than '\'
* 3. LoadDirectoryAsPackage should only be used for testing. The final release will be
* have all files in packages.
*
* Autor: Malte Thiesen, $author$
*/
#ifndef SWORD25_PACKAGE_MANAGER_H
#define SWORD25_PACKAGE_MANAGER_H
@ -40,149 +43,148 @@
#include "sword25/kernel/kernel.h"
#include "sword25/kernel/service.h"
// Klassendefinition
/**
@brief Das Package Manager Interface
namespace Sword25 {
Beim Package Manager ist folgendes zu beachten:<br>
1. es wird ein komplett neuer (virtueller) Verzeichnisbaum erstellt,
in den Packages und Verzeichnisse gemounted werden können.<br>
2. zum Trennen von Elementen eines Verzeichnisspfades wird '/' statt '\' verwendet.<br>
3. LoadDirectoryAsPackage sollte nur zum Testen benutzt werden. Im Final Release sollen sich
alle Dateien in echten Packages befinden.
*/
class BS_PackageManager : public BS_Service
{
// Class definitions
/**
* The Package Manager interface
*
* 1. It creates a completely new (virtual) directory tree in the packages and directories
* can be mounted.
* 2. To seperate elements of a directory path '/' must be used rather than '\'
* 3. LoadDirectoryAsPackage should only be used for testing. The final release will be
* have all files in packages.
*/
class BS_PackageManager : public BS_Service {
public:
BS_PackageManager(BS_Kernel* pKernel);
virtual ~BS_PackageManager() {};
enum FILE_TYPES
{
enum FILE_TYPES {
FT_DIRECTORY = (1<<0),
FT_FILE = (1<<1)
};
/**
@brief Mit Instanzen dieses Objektes wird nach Dateien gesucht.
Objekte diesen Types wird mit BS_PackageManager::CreateSearch erzeugt.
*/
class FileSearch
{
* File search class
*
* These objects are created with BS_PackageManager::CreateSearch
*/
class FileSearch {
public:
virtual ~FileSearch(){};
/**
@brief Gibt den Dateinamen der aktuellen Datei zurück.
@return Gibt den Dateinamen der aktuellen Datei zurück.
*/
virtual std::string GetCurFileName() = 0;
* Returns the filename of the current file
* @return Returns the filename of the current file
*/
virtual Common::String GetCurFileName() = 0;
/**
@brief Gibt den Typ der aktuellen Datei zurück.
@return Gibt den Typ der aktuellen Datei zurück.<br>
Dieses ist entweder BS_PackageManager::FT_FILE oder BS_PackageManager::FT_DIRECTORY.
*/
* Returns the type of the current file
* @return Returns the type of the current file
* This is either BS_PackageManager::FT_FILE or BS_PackageManager::FT_DIRECTORY.
*/
virtual unsigned int GetCurFileType() = 0;
/**
@brief Gibt die Größe der aktuellen Datei zurück.
@return Gibt die Größe der aktuellen Datei zurück.<br>
Bei Verzeichnissen ist dieser Wert immer 0.
*/
* Returns the size of the current file
* @return Returns the size of the current file
* For directories, this value is always 0
*/
virtual unsigned int GetCurFileSize() = 0;
// Sucht die nächste Datei
// Gibt false zurück, falls keine weitere Datei gefunden wurde
// Finds the next file
// Returns false if no more files are found.
/**
@brief Sucht die nächste Datei.
@return Gibt false zurück, falls keine weitere Datei die Suchkriterien erfüllte.
* Finds the next file.
* @return Returns false if no other file fulfills the search criteria
*/
virtual bool NextFile() = 0;
};
/**
@brief Mounted den Inhalt eines Packages in das angegebene Verzeichnis im virtuellen Verzeichnisbaum.
@param FileName der Dateiname des zu mountenden Packages
@param MountPosition der Verzeichnisname, unter dem das Package gemounted werden soll
@return Gibt true zurück falls das mounten erfolgreich war, andernfalls false.
* Mounts the contents of a package in the directory specified in the virtual directory tree.
* @param FileName The filename of the package to mount
* @param MountPosition The directory name under which the package should be mounted
* @return Returns true if the mount was successful, otherwise false.
*/
virtual bool LoadPackage(const std::string& FileName, const std::string& MountPosition) = 0;
virtual bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition) = 0;
/**
@brief Mounted den Inhalt eines Verzeichnisses in das angegebene Verzeichnis im virtuellen Verzeichnisbaum.
@param DirectoryName der Name des zu mountenden Verzeichnisses
@param MountPosition der Verzeichnisname, unter dem das Verzeichnis gemounted werden soll
@return Gibt true zurück falls das mounten erfolgreich war, andernfalls false.
* Mounts the contents of a directory in the specified directory in the virtual directory tree.
* @param The name of the directory to mount
* @param MountPosition The directory name under which the package should be mounted
* @return Returns true if the mount was successful, otherwise false.
*/
virtual bool LoadDirectoryAsPackage(const std::string& DirectoryName, const std::string& MountPosition) = 0;
virtual bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition) = 0;
/**
@brief Lädt eine Datei aus dem virtuellen Verzeichnisbaum.
@param FileName der Dateiname der zu ladenden Datei
@param pFileSize Pointer auf die Variable, die die Größe der geladenen Datei enthalten soll<br>
Der Standardwert ist NULL.
@return Gibt einen Pointer auf die Dateidaten zürück, oder NULL, wenn die Datei nicht geladen werden konnte.
@remark Es darf nicht vergessen werden, die Dateidaten nach Benutzung mit BE_DELETE_A freizugeben.
*/
virtual void* GetFile(const std::string& FileName, unsigned int* pFileSize = NULL) = 0;
* Downloads a file from the virtual directory tree
* @param FileName The filename of the file to load
* @param pFileSize Pointer to the variable that will contain the size of the loaded file. The deafult is NULL.
* @return Specifies a pointer to the loaded data of the file
* @remark The client must not forget to release the data of the file using BE_DELETE_A.
*/
virtual void *GetFile(const Common::String &FileName, unsigned int *pFileSize = NULL) = 0;
/**
@brief Gibt den Pfad zum aktuellen Verzeichnis zurück.
@return Gibt einen String zurück, der den Pfad zum aktuellen Verzeichnis enthält.<br>
Falls der Pfad nicht bestimmt werden konnte wird ein leerer String zurückgegeben.
@remark Zum Trennen von Pfadelementen wird "/" und nicht "\" verwendet.
*/
virtual std::string GetCurrentDirectory() = 0;
* Returns the path to the current directory.
* @return Returns a string containing the path to the current directory.
* If the path could not be determined, an empty string is returned.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
virtual Common::String GetCurrentDirectory() = 0;
/**
@brief Wechselt das aktuelle Verzeichnis.
@param Directory ein String der das Verzeichnis bezeichnet, in dass gewechselt werden soll.<br>
Die Pfadangabe darf relativ sein.
@return Gibt true zurück, falls der Vorgang erfolgreich war, ansonsten false.
@remark Zum Trennen von Pfadelementen wird "/" und nicht "\" verwendet.
*/
virtual bool ChangeDirectory(const std::string& Directory) = 0;
* Changes the current directory.
* @param Directory The path to the new directory. The path can be relative.
* @return Returns true if the operation was successful, otherwise false.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
virtual bool ChangeDirectory(const Common::String& Directory) = 0;
/**
@brief Gibt den absoluten Pfad zu einer Datei im virtuellen Verzeichnisbaum zurück.
@param FileName der Dateiname der Datei, deren absoluter Pfad bestimmt werden soll.<br>
Diese Parameter kann sowohl relative als auch absolute Pfadangaben beinhalten.
@return Gibt einen String zurück, der den absoluten Pfad zur übergebenen Datei enthält.<br>
Falls der absolute Pfad nicht bestimmt werden konnte, wird ein leerer String zurückgegeben.
@remark Zum Trennen von Pfadelementen wird "/" und nicht "\" verwendet.
*/
virtual std::string GetAbsolutePath(const std::string& FileName) = 0;
* Returns the absolute path to a file in the virtual directory tree.
* @param FileName The filename of the file whose absolute path is to be determined.
* These parameters may include both relative and absolute paths.
* @return Returns an absolute path to the given file.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
virtual Common::String GetAbsolutePath(const Common::String& FileName) = 0;
/**
@brief Erstellt ein BS_PackageManager::FileSearch Objekt mit dem Nach Dateien gesucht werden kann.
@param Filter gibt den Suchstring an. Dieser darf die Wildcards '*' und '?' enthalten.
@param Path gibt das Verzeichnis an, welches durchsucht werden soll.
@param TypeFilter ist eine Kombination der Flags BS_PackageManager::FT_DIRECTORY und BS_PackageManager::FT_FILE.<br>
Diese Flags geben an, ob nach Dateien oder Verzeichnissen oder beiden gesucht werden soll.<br>
Der Standardwert ist BS_PackageManager::FT_DIRECTORY | BS_PackageManager::FT_FILE.
@return Gibt einen Pointer auf ein BS_PackageManager::FileSearch Objekt zurück, oder NULL wenn keine Datei gefunden wurde.
@remark Nicht vergessen, das Objekt nach Benutzung mit delete freizugeben.
* Creates a BS_PackageManager::FileSearch object to search for files
* @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
* @param Path Specifies the directory that should be searched.
* @param TypeFilter A combination of flags BS_PackageManager::FT_DIRECTORY and BS_PackageManager::FT_FILE.
* These flags indicate whether to search for files, directories, or both.
* The default is BS_PackageManager::FT_DIRECTORY | BS_PackageManager::FT_FILE
* @return Specifies a pointer to a BS_PackageManager::FileSearch object, or NULL if no file was found.
* @remark Do not forget to delete the object after use.
*/
virtual FileSearch* CreateSearch(const std::string& Filter, const std::string& Path, unsigned int TypeFilter = FT_DIRECTORY | FT_FILE) = 0;
virtual FileSearch *CreateSearch(const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter = FT_DIRECTORY | FT_FILE) = 0;
/**
* @brief Gibt die Dateigröße zurück.
* @param FileName die Datei.
* @return die Dateigröße. Im Falle eines Fehlers wird 0xffffffff zurückgegeben.
* @remarks Bei komprimierten Containern wird die unkomprimierte Größe zurückgegeben.
* Returns a file's size
* @param FileName The filename
* @return The file size. If an error occurs, then 0xffffffff is returned.
* @remarks For files in packages, then uncompressed size is returned.
**/
virtual unsigned int GetFileSize(const std::string& FileName) = 0;
virtual unsigned int GetFileSize(const Common::String &FileName) = 0;
/**
@brief Gibt den Typ einer Datei zurück.
@param FileName der Dateiname
@return Gibt den Dateityp zurück (BS_PackageManager::FT_DIRECTORY oder BS_PackageManager::FT_FILE).<br>
Falls die Datei nicht gefunden wurde wird 0 zurückgegeben.
*/
virtual unsigned int GetFileType(const std::string & FileName) = 0;
* Returns the type of a file.
* @param FileName The filename
* @return Returns the file type, either (BS_PackageManager::FT_DIRECTORY
* or BS_PackageManager::FT_FILE).
* If the file was not found, then 0 is returned.
*/
virtual unsigned int GetFileType(const Common::String &FileName) = 0;
/**
@brief Bestimmt, ob eine Datei existiert.
@param FileName der Dateiname
@return Gibt true zurück, wenn die Datei existiert, ansonsten false.
* Determines whether a file exists
* @param FileName The filename
* @return Returns true if the file exists, otherwise false.
*/
virtual bool FileExists(const std::string & FileName) = 0;
virtual bool FileExists(const Common::String & FileName) = 0;
private:
bool _RegisterScriptBindings();
};
} // ENd of namespace Sword25
#endif

View File

@ -1,21 +1,27 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_SCRIPT_H
#define SWORD25_SCRIPT_H
@ -24,14 +30,13 @@
// Includes
// -----------------------------------------------------------------------------
#include "common/array.h"
#include "common/str.h"
#include "sword25/kernel/common.h"
#include "sword25/kernel/service.h"
#include "sword25/kernel/persistable.h"
#include "sword25/kernel/memlog_off.h"
#include <vector>
#include <string>
#include "sword25/kernel/memlog_on.h"
namespace Sword25 {
// -----------------------------------------------------------------------------
// Forward declarations
@ -45,55 +50,54 @@ class BS_InputPersistenceBlock;
// Class declaration
// -----------------------------------------------------------------------------
class BS_ScriptEngine : public BS_Service, public BS_Persistable
{
class BS_ScriptEngine : public BS_Service, public BS_Persistable {
public:
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// Constructor / destructor
// -----------------------------------------------------------------------------
BS_ScriptEngine(BS_Kernel * KernelPtr) : BS_Service(KernelPtr) {};
virtual ~BS_ScriptEngine() {};
// -----------------------------------------------------------------------------
// DIESE METHODEN MÜSSEN VON DER SCRIPTENGINE IMPLEMENTIERT WERDEN
// This method must be implemented by the script engine
// -----------------------------------------------------------------------------
/**
@brief Initialisiert die Scriptengine.
@return Gibt true bei Erfolg zurück, ansonsten false.
*/
* Initialises the scrip tengine. Returns true if successful, false otherwise.
*/
virtual bool Init() = 0;
/**
@brief Lädt eine Skriptdatei und führt diese aus.
@param FileName der Dateiname der Skriptdatei
@return Gibt true bei Erfolg zurück, ansonsten false.
* Loads a script file and executes it.
* @param FileName The script filename
*/
virtual bool ExecuteFile(const std::string & FileName) = 0;
virtual bool ExecuteFile(const Common::String &FileName) = 0;
/**
@brief Führt einen String mit Skriptcode aus.
@param Code ein String der Skriptcode enthält.
@return Gibt true bei Erfolg zurück, ansonsten false.
*/
virtual bool ExecuteString(const std::string & Code) = 0;
* Executes a specified script fragment
* @param Code String of script code
*/
virtual bool ExecuteString(const Common::String &Code) = 0;
/**
@brief Gibt einen Pointer auf das Hauptobjekt der Skriptsprache zurück.
@remark Durch die Benutzung dieser Methode wird die Kapselung der Sprache vom Rest der Engine aufgehoben.
*/
* Returns a pointer to the main object of the script engine
* Note: Using this method breaks the encapsulation of the language from the rest of the engine.
*/
virtual void * GetScriptObject() = 0;
/**
@brief Macht die Kommandozeilen-Parameter für die Skriptumgebung zugänglich.
@param CommandLineParameters ein string vector der alle Kommandozeilenparameter enthält.
@remark Auf welche Weise die Kommandozeilen-Parameter durch Skripte zugegriffen werden können hängt von der jeweiligen Implementierung ab.
* Makes the command line parameters for the script environment available
* Note: How the command line parameters will be used by scripts is dependant on the
* particular implementation.
* @param CommandLineParameters List containing the command line parameters
*/
virtual void SetCommandLine(const std::vector<std::string> & CommandLineParameters) = 0;
virtual void SetCommandLine(const Common::Array<Common::String> &CommandLineParameters) = 0;
virtual bool Persist(BS_OutputPersistenceBlock & Writer) = 0;
virtual bool Unpersist(BS_InputPersistenceBlock & Reader) = 0;
virtual bool Persist(BS_OutputPersistenceBlock &Writer) = 0;
virtual bool Unpersist(BS_InputPersistenceBlock &Reader) = 0;
};
} // End of namespace Sword25
#endif

View File

@ -1,33 +1,37 @@
// -----------------------------------------------------------------------------
// This file is part of Broken Sword 2.5
// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
//
// Broken Sword 2.5 is free software; you can redistribute it 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.
//
// Broken Sword 2.5 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Broken Sword 2.5; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
/*
BS_SoundEngine
-------------
Dies ist das Soundengine Interface, dass alle Methoden enthält, die eine Soundengine
implementieren muss.
Implementationen der Soundengine müssen von dieser Klasse abgeleitet werden.
Es gilt zu beachten, dass eine Soundengine eine Liste mit ALLEN geladenen Samplen enthalten
muss, und dass diese Samples beim Aufruf des Destruktors freigegeben werden.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
Autor: Malte Thiesen
*/
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
* BS_SoundEngine
* -------------
* This is the sound engine interface that contains all the methods a sound
* engine must implement.
* Implementations of the sound engine have to be derived from this class.
* It should be noted that a sound engine must maintain a list of all the
* samples it uses, and that these samples should be released when the
* destructor is called.
*
* Autor: Malte Thiesen
*/
#ifndef SWORD25_SOUNDENGINE_H
#define SWORD25_SOUNDENGINE_H
@ -40,214 +44,220 @@
#include "sword25/kernel/resservice.h"
#include "sword25/kernel/persistable.h"
namespace Sword25 {
// -----------------------------------------------------------------------------
// Klassendefinition
// Class definitions
// -----------------------------------------------------------------------------
class BS_SoundEngine : public BS_ResourceService, public BS_Persistable
{
class BS_SoundEngine : public BS_ResourceService, public BS_Persistable {
public:
// -----------------------------------------------------------------------------
// Enums und Typen
// Enums and Types
// -----------------------------------------------------------------------------
enum SOUND_TYPES
{
enum SOUND_TYPES {
MUSIC = 0,
SPEECH = 1,
SFX = 2
};
/**
@brief Die Callbackfunktion von PlayDynamicSoundEx
@param UserData Benutzerspezifizierter Pointer
@param Data Pointer auf den zu beschreibenden Puffer
@param DataLength Länge der zu schreibenden Daten in Byte
* The callback function of PlayDynamicSoundEx
* @param UserData User-specified pointer
* @param Data Pointer to the data buffer
* @param DataLength Length of the data to be written in bytes
*/
typedef void (*DynamicSoundReadCallback)(void * UserData, void * Data, unsigned int DataLength);
typedef void (*DynamicSoundReadCallback)(void *UserData, void *Data, unsigned int DataLength);
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// Constructor / destructor
// -----------------------------------------------------------------------------
BS_SoundEngine(BS_Kernel* pKernel);
virtual ~BS_SoundEngine() {};
// --------------------------------------------------------------
// DIESE METHODEN MÜSSEN VON DER SOUNDENGINE IMPLEMENTIERT WERDEN
// THIS METHOD MUST BE IMPLEMENTED BY THE SOUND ENGINE
// --------------------------------------------------------------
/**
@brief Initialisiert die Sound-Engine
@param SampleRate Gibt die zu nutzende SampleRate an
@param Channels die maximale Anzahl der Kanäle.<br>
Der Standardwert ist 32.
@return Gibt bei Erfolg TRUE, ansonsten FALSE zurück
@remark Aufrufe an allen anderen Methoden dürfen erst erfolgen, wenn diese Methode erfolgreich aufgerufen wurde.
*/
* Initialises the sound engine
* @param SampleRate Specifies the sample rate to use.
* @param Channels The maximum number of channels. The default is 32.
* @return Returns true on success, otherwise false.
* @remark Calls to other methods may take place only if this
* method was called successfully.
*/
virtual bool Init(unsigned int SampleRate, unsigned int Channels = 32) = 0;
/**
@brief Führt einen "Tick" der Sound-Engine aus
Diese Methode sollte ein mal pro Frame aufgerufen werden. Sie dient dazu Implementationen der Sound-Engine zu ermöglichen,
die nicht in einem eigenen Thread laufen oder zusätzliche Verwaltungsaufgaben durchführen müssen.
*/
* Performs a "tick" of the sound engine
*
* This method should be called once per frame. It can be used by implementations
* of the sound engine that are not running in their own thread, or to perform
* additional administrative tasks that are needed.
*/
virtual void Update() = 0;
/**
@brief Setzt die Standardlautstärke für die verschiedenen Soundtypen
@param Volume die Standardlautstärke (0 = aus, 1 = volle Lautstärke)
@param Type der Soundtyp dessen Lautstärke geändert werden soll
*/
* Sets the default volume for the different sound types
* @param Volume The default volume level (0 = off, 1 = full volume)
* @param Type The SoundType whose volume is to be changed
*/
virtual void SetVolume(float Volume, SOUND_TYPES Type) = 0;
/**
@brief Gibt die Standardlautstärke der verschiedenen Soundtypen
@param Type der Soundtyp
@return Gibt die Standardlautstärke des übergebenen Soundtyps zurück (0 = aus, 1 = volle Laustärke)
* Specifies the default volume of different sound types
* @param Type The SoundType
* @return Returns the standard sound volume for the given type
* (0 = off, 1 = full volume).
*/
virtual float GetVolume(SOUND_TYPES Type) = 0;
/**
@brief Pausiert alle Sounds die gerade spielen
*/
* Pauses all the sounds that are playing.
*/
virtual void PauseAll() = 0;
/**
@brief Setzt alle gestoppten Sounds fort
*/
* Resumes all currently stopped sounds
*/
virtual void ResumeAll() = 0;
/**
@brief Pausiert alle Sounds eines bestimmten Sound-Layers
@param Layer ein Soundlayer
* Pauses all sounds of a given layer.
* @param Layer The Sound Layer
*/
virtual void PauseLayer(unsigned int Layer) = 0;
/**
@brief Setzt alle Sounds eines Layers fort, die mit PauseLayer() zuvor gestoppt wurden
@param Layer ein Soundlayer
* Resumes all the sounds in a layer that was previously stopped with PauseLayer()
* @param Layer The Sound Layer
*/
virtual void ResumeLayer(unsigned int Layer) = 0;
/**
@brief Spielt einen Sound ab
@param FileName der Dateiname des abzuspielenden Sounds
@param Type der Typ des Sounds
@param Volume die Lautstärke mit der der Soundabgespielt werden soll (0 = aus, 1 = volle Lautstärke)
@param Pan das Panning (-1 = ganz links, 1 = ganz rechts)
@param Loop gibt an ob der Sound geloopt werden soll
@param LoopStart gibt den Start-Looppoint an. Wenn ein Wert kleiner als 0 übergeben wird, wird der Start des Sounds benutzt.
@param LoopEnd gibt den End-Looppoint an. Wenn ein Wert kleiner als 0 übergeben wird, wird das Ende des Sounds benutzt.
@param Layer der Soundlayer
@return Gibt true zurück, wenn das Abspielen des Sounds eingeleitet werden konnte.
@remark Falls eine erweiterte Kontrolle über das Abspielen benötigt wird, z.B. das Ändern der Soundparameter
Volume und Panning während des Abspielvorgangens, sollte PlaySoundEx benutzt werden.
* Plays a sound
* @param FileName The filename of the sound to be played
* @param Type The type of sound
* @param Volume The volume of the sound (0 = off, 1 = full volume)
* @param Pan Panning (-1 = full left, 1 = right)
* @param Loop Indicates whether the sound should be looped
* @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
* of the sound is used.
* @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
* the sound is used.
* @param Layer The sound layer
* @return Returns true if the playback of the sound was started successfully.
* @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
virtual bool PlaySound(const std::string& FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, unsigned int Layer = 0) = 0;
/**
@brief Spielt einen Sound ab
@param FileName der Dateiname des abzuspielenden Sounds
@param Type der Typ des Sounds
@param Volume die Lautstärke mit der der Soundabgespielt werden soll (0 = aus, 1 = volle Lautstärke)
@param Pan das Panning (-1 = ganz links, 1 = ganz rechts)
@param Loop gibt an ob der Sound geloopt werden soll
@param LoopStart gibt den Start-Looppoint an. Wenn ein Wert kleiner als 0 übergeben wird, wird der Start des Sounds benutzt.
@param LoopEnd gibt den End-Looppoint an. Wenn ein Wert kleiner als 0 übergeben wird, wird das Ende des Sounds benutzt.
@param Layer der Soundlayer
@return Gibt ein Handle auf den Sounds zurück. Mit diesem Handle kann der Sound während des Abspielens manipuliert werden.
@remark Falls eine erweiterte Kontrolle über das Abspielen benötigt wird, z.B. das Ändern der Soundparameter
Volume und Panning während des Abspielvorgangens, sollte PlaySoundEx benutzt werden.
*/
* Plays a sound
* @param Type The type of sound
* @param Volume The volume of the sound (0 = off, 1 = full volume)
* @param Pan Panning (-1 = full left, 1 = right)
* @param Loop Indicates whether the sound should be looped
* @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
* of the sound is used.
* @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
* the sound is used.
* @param Layer The sound layer
* @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
* @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
virtual unsigned int PlaySoundEx(const std::string& FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, unsigned int Layer = 0) = 0;
/**
@brief Spielt einen zur Laufzeit generierten Sound ab
@param ReadCallback ein Pointer auf eine Callbackfunktion, die aufgerufen wird, wenn Sounddaten benötigt werden.<br>
Nähere Details zu dieser Funktion gibt es bei der Dokumentation von DynamicSoundReadCallback.
@param UserData ein Pointer auf benutzerdefinierte Daten. Diese werden der Callback-Funktion bei jedem Aufruf übergeben.<br>
Falls keine solche Daten benötigt werden, kann dieser Parameter auf 0 gesetzt werden.
@param Type der Typ des Sounds
@param SampleRate die Sample-Rate des Sounds
@param BitsPerSample die Größe eines Samples in Bits. Hiermit sind tatsächlich nur einzelne Sample gemeint, diese Angabe ist unabhängig von der Anzahl der Kanäle.<br>
Erlaubte Werte sind 8, 16, 24 und 32.
@param Channels die Anzahl der Kanäle.<br>
Erlaubte Werte sind 1 und 2.
@param Volume die Lautstärke mit der der Soundabgespielt werden soll (0 = aus, 1 = volle Lautstärke)
@param Pan das Panning (-1 = ganz links, 1 = ganz rechts)
@param Layer der Soundlayer
@return Gibt ein Handle auf den Sounds zurück. Mit diesem Handle kann der Sound während des Abspielens manipuliert werden.
@remark Dynamische Sounds können nicht persistiert werden.
*/
virtual unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void * UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0) = 0;
* Plays a sound generated at runtime
* @param ReadCallback A pointer to a callback function that is called when sound data is needed.
* See the documentation for DynamicSoundReadCallback for more information.
* @param UserData A pointer to the data. These are passed to the callback function each time.
* If no such data is needed, this parameter can be set to NULL.
* @param Type The type of sound
* @param SampleRate The sample rate for the sound
* @param BitsPerSample The size of the sample in bits. This statement is independant of the number of
* channels. Allowed values are 8, 16, 24, and 32.
* @param Channels The number of channels. Allowed values are 1 and 2.
* @param Volume The volume of the sound (0 = off, 1 = full volume)
* @param Pan Panning (-1 = full left, 1 = right)
* @param Layer The sound layer
* @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
* @remark Dynamic sounds cannot be persisted.
*/
virtual unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0) = 0;
/**
@brief Setzt die Lautstärke eines spielenden Sounds
@param Handle das Handle des Sounds
@param Volume die Lautstärke mit der der Soundabgespielt werden soll (0 = aus, 1 = volle Lautstärke)
*/
* Sets the volume of a playing sound
* @param Handle The sound handle
* @param Volume The volume of the sound (0 = off, 1 = full volume)
*/
virtual void SetSoundVolume(unsigned int Handle, float Volume) = 0;
/**
@brief Setzt das Panning eines spielenden Sounds
@param Handle das Handle des Sounds
@param Pan das Panning (-1 = ganz links, 1 = ganz rechts)
*/
* Sets the panning of a playing sound
* @param Handle The sound handle
* @param Pan Panning (-1 = full left, 1 = right)
*/
virtual void SetSoundPanning(unsigned int Handle, float Pan) = 0;
/**
@brief Pausiert einen Sound
@param Handle das Handle des Sounds
*/
* Pauses a playing sound
* @param Handle The sound handle
*/
virtual void PauseSound(unsigned int Handle) = 0;
/**
@brief Setzt einen Sound fort
@param Handle das Handle des Sounds
*/
* Resumes a paused sound
* @param Handle The sound handle
*/
virtual void ResumeSound(unsigned int Handle) = 0;
/**
@brief Stoppt einen Sound
@param Handle das Handle des Sounds
@remark Nach einem Aufruf dieser Methode ist das Handle ungültig und darf nicht mehr benutzt werden.
*/
* Stops a playing sound
* @param Handle The sound handle
* @remark Calling this method invalidates the passed handle; it can no longer be used.
*/
virtual void StopSound(unsigned int Handle) = 0;
/**
@brief Gibt zurück, ob ein Sound pausiert ist
@param Handle das Handle des Sounds
@return Gibt true zurück, wenn der Sound pausiert ist, ansonsten false.
*/
* Returns whether a sound is paused
* @param Handle The sound handle
* @return Returns true if the sound is paused, false otherwise.
*/
virtual bool IsSoundPaused(unsigned int Handle) = 0;
/**
@brief Gibt zurück, ob ein Sound noch spielt
@param Handle das Handle des Sounds
@return Gibt true zurück, wenn der Sound noch spielt, ansonsten false.
* Returns whether a sound is still playing.
* @param Handle The sound handle
* @return Returns true if the sound is playing, false otherwise.
*/
virtual bool IsSoundPlaying(unsigned int Handle) = 0;
/**
@brief Gibt die Lautstärke eines spielenden Sounds zurück (0 = aus, 1 = volle Lautstärke)
*/
* Returns the volume of a playing sound (0 = off, 1 = full volume)
*/
virtual float GetSoundVolume(unsigned int Handle) = 0;
/**
@brief Gibt das Panning eines spielenden Sounds zurück (-1 = ganz links, 1 = ganz rechts)
*/
* Returns the panning of a playing sound (-1 = full left, 1 = right)
*/
virtual float GetSoundPanning(unsigned int Handle) = 0;
/**
@brief Gibt die Position innerhalb des abgespielten Sounds in Sekunden zurück
*/
* Returns the position within a playing sound in seconds
*/
virtual float GetSoundTime(unsigned int Handle) = 0;
private:
bool _RegisterScriptBindings();
};
} // End of namespace Sword25
#endif

View File

@ -0,0 +1,121 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/config-manager.h"
#include "engines/util.h"
#include "sword25/sword25.h"
#include "kernel/kernel.h"
namespace Sword25 {
#define BS_LOG_PREFIX "MAIN"
void LogToStdout(const char *Message) {
warning(Message);
}
Sword25Engine::Sword25Engine(OSystem *syst, const Sword25GameDescription *gameDesc):
Engine(syst),
_gameDescription(gameDesc) {
}
Sword25Engine::~Sword25Engine() {
}
Common::Error Sword25Engine::run() {
// Engine initialisation
Common::StringArray commandParameters;
if (!AppStart(commandParameters)) {
AppEnd();
error("A fatal error occured during engine startup");
}
// Run the game
bool RunSuccess = AppMain();
// Engine de-initialisation
bool DeinitSuccess = AppEnd();
return (RunSuccess && DeinitSuccess) ? Common::kNoError : Common::kUnknownError;
}
bool Sword25Engine::AppStart(const Common::StringArray &CommandParameters) {
// Alle Lognachrichten werden auch auf die Standardausgabe ausgegeben.
BS_Log::RegisterLogListener(LogToStdout);
// Kernel initialisieren.
if (!BS_Kernel::GetInstance()->GetInitSuccess())
{
BS_LOG_ERRORLN("Kernel initialization failed.");
return false;
}
/*
// Package-Manager starten, damit die Packfiles geladen werden können.
BS_PackageManager * PackageManagerPtr = static_cast<BS_PackageManager *>(BS_Kernel::GetInstance()->NewService("package", PACKAGE_MANAGER));
if (!PackageManagerPtr)
{
BS_LOG_ERRORLN("Packagemanager initialization failed.");
return false;
}
// Packages laden oder das aktuelle Verzeichnis mounten, wenn das über Kommandozeile angefordert wurde.
if (find(CommandLineParameters.begin(), CommandLineParameters.end(), MOUNT_DIR_PARAMETER) != CommandLineParameters.end())
{
if (!PackageManagerPtr->LoadDirectoryAsPackage(".", "/")) return false;
}
else
{
if (!LoadPackages()) return false;
}
// Einen Pointer auf den Skript-Engine holen.
BS_ScriptEngine * ScriptPtr = static_cast<BS_ScriptEngine *>(BS_Kernel::GetInstance()->GetService("script"));
if (!ScriptPtr)
{
BS_LOG_ERRORLN("Skript intialization failed.");
return false;
}
// Die Kommandozeilen-Parameter der Skriptumgebung zugänglich machen.
ScriptPtr->SetCommandLine(CommandLineParameters);
*/
return true;
}
bool Sword25Engine::AppMain() {
return false;
}
bool Sword25Engine::AppEnd() {
// Free the log file if it was used
BS_Log::_CloseLog();
return false;
}
} // End of namespace Sword25

76
engines/sword25/sword25.h Normal file
View File

@ -0,0 +1,76 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef SWORD25_H
#define SWORD25_H
#include "common/scummsys.h"
#include "common/str-array.h"
#include "common/util.h"
#include "engines/engine.h"
#include "sword25/kernel/log.h"
namespace Sword25 {
enum {
kFileTypeHash = 0
};
enum {
kDebugScript = 1 << 0
};
#define MESSAGE_BASIC 1
#define MESSAGE_INTERMEDIATE 2
#define MESSAGE_DETAILED 3
struct Sword25GameDescription;
class Sword25Engine : public Engine {
private:
bool AppStart(const Common::StringArray &CommandParameters);
bool AppMain();
bool AppEnd();
protected:
virtual Common::Error run();
void shutdown();
public:
Sword25Engine(OSystem *syst, const Sword25GameDescription *gameDesc);
virtual ~Sword25Engine();
int getGameType() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
const Sword25GameDescription *_gameDescription;
};
} // End of namespace Sword25
#endif