aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-20 15:47:11 +0000
committerJohannes Schickel2008-04-20 15:47:11 +0000
commitf173041811398817ffce870d30ef3b87d1302736 (patch)
tree78e43d204662641a5d687cbc184ac60913ac870d /engines
parent38319954d1035a7ec8df335c88d455a4042a94fc (diff)
downloadscummvm-rg350-f173041811398817ffce870d30ef3b87d1302736.tar.gz
scummvm-rg350-f173041811398817ffce870d30ef3b87d1302736.tar.bz2
scummvm-rg350-f173041811398817ffce870d30ef3b87d1302736.zip
- moved kyra functor code to common/func.h
- adapted debugger code to use functor code from common/func.h - adapted kyra engine to use functor code from common/func.h svn-id: r31614
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/gui.h6
-rw-r--r--engines/kyra/kyra.h5
-rw-r--r--engines/kyra/kyra_v2.h6
-rw-r--r--engines/kyra/screen.h5
-rw-r--r--engines/kyra/script.h10
-rw-r--r--engines/kyra/script_tim.h5
-rw-r--r--engines/kyra/script_v1.cpp2
-rw-r--r--engines/kyra/script_v2.cpp4
-rw-r--r--engines/kyra/script_v3.cpp2
-rw-r--r--engines/kyra/timer.h5
-rw-r--r--engines/kyra/timer_v1.cpp2
-rw-r--r--engines/kyra/timer_v2.cpp2
-rw-r--r--engines/kyra/timer_v3.cpp2
-rw-r--r--engines/kyra/util.h114
14 files changed, 32 insertions, 138 deletions
diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h
index 214f112995..dfbca22441 100644
--- a/engines/kyra/gui.h
+++ b/engines/kyra/gui.h
@@ -26,18 +26,18 @@
#ifndef KYRA_GUI_H
#define KYRA_GUI_H
-#include "kyra/util.h"
#include "kyra/kyra.h"
#include "common/ptr.h"
#include "common/array.h"
+#include "common/func.h"
namespace Kyra {
-#define BUTTON_FUNCTOR(type, x, y) Button::Callback(new Functor1Mem<Button*, int, type>(x, y))
+#define BUTTON_FUNCTOR(type, x, y) Button::Callback(new Common::Functor1Mem<Button*, int, type>(x, y))
struct Button {
- typedef Functor1<Button*, int> CallbackFunctor;
+ typedef Common::Functor1<Button*, int> CallbackFunctor;
typedef Common::SharedPtr<CallbackFunctor> Callback;
Button *nextButton;
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index f88b23ea05..0fee9e4e3e 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -27,11 +27,13 @@
#define KYRA_KYRA_H
#include "engines/engine.h"
+
#include "common/rect.h"
#include "common/array.h"
#include "common/events.h"
+#include "common/func.h"
-#include "kyra/util.h"
+#include "kyra/script.h"
namespace Common {
class InSaveFile;
@@ -99,7 +101,6 @@ class Movie;
class TextDisplayer;
class StaticResource;
class TimerManager;
-class ScriptHelper;
class KyraEngine : public Engine {
friend class Debugger;
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 10953a71a3..d63f8d6e99 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -28,12 +28,13 @@
#include "kyra/kyra.h"
#include "kyra/script.h"
+#include "kyra/script_tim.h"
#include "kyra/screen_v2.h"
#include "kyra/text_v2.h"
#include "kyra/gui_v2.h"
-#include "kyra/util.h"
#include "common/list.h"
+#include "common/func.h"
namespace Kyra {
@@ -99,7 +100,6 @@ enum kNestedSequencesDemo {
class WSAMovieV2;
class KyraEngine_v2;
class TextDisplayer_v2;
-class TIMInterpreter;
class Debugger_v2;
struct TIM;
@@ -329,7 +329,7 @@ protected:
void update();
void updateWithText();
- Functor0Mem<void, KyraEngine_v2> _updateFunctor;
+ Common::Functor0Mem<void, KyraEngine_v2> _updateFunctor;
void updateMouse();
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 82f550f642..4516d4f907 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -27,14 +27,13 @@
#define KYRA_SCREEN_H
#include "common/util.h"
-
-#include "kyra/util.h"
+#include "common/func.h"
class OSystem;
namespace Kyra {
-typedef Functor0<void> UpdateFunctor;
+typedef Common::Functor0<void> UpdateFunctor;
class KyraEngine;
struct Rect;
diff --git a/engines/kyra/script.h b/engines/kyra/script.h
index 4ea05ea158..bc92aebc5e 100644
--- a/engines/kyra/script.h
+++ b/engines/kyra/script.h
@@ -26,13 +26,14 @@
#ifndef KYRA_SCRIPT_H
#define KYRA_SCRIPT_H
-#include "kyra/kyra.h"
-#include "kyra/util.h"
-
#include "common/stream.h"
+#include "common/func.h"
namespace Kyra {
+struct ScriptState;
+typedef Common::Functor1<ScriptState*, int> Opcode;
+
struct ScriptData {
byte *text;
uint16 *data;
@@ -61,6 +62,9 @@ struct ScriptState {
#define ORDR_CHUNK 0x5244524F
#define AVTL_CHUNK 0x4C545641
+class Resource;
+class KyraEngine;
+
class ScriptFileParser {
public:
ScriptFileParser() : _stream(0), _startOffset(0), _endOffset(0) {}
diff --git a/engines/kyra/script_tim.h b/engines/kyra/script_tim.h
index a76dcccb38..2ffbf89d65 100644
--- a/engines/kyra/script_tim.h
+++ b/engines/kyra/script_tim.h
@@ -27,12 +27,15 @@
#define KYRA_SCRIPT_TIM_H
#include "kyra/kyra.h"
-#include "kyra/util.h"
#include "common/array.h"
+#include "common/func.h"
namespace Kyra {
+struct TIM;
+typedef Common::Functor2<const TIM*, const uint16*, int> TIMOpcode;
+
struct TIM {
int16 procFunc;
uint16 procParam;
diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp
index 226bf140d9..50ad1b8b0c 100644
--- a/engines/kyra/script_v1.cpp
+++ b/engines/kyra/script_v1.cpp
@@ -1820,7 +1820,7 @@ int KyraEngine_v1::o1_dummy(ScriptState *script) {
#pragma mark -
-typedef Functor1Mem<ScriptState*, int, KyraEngine_v1> OpcodeV1;
+typedef Common::Functor1Mem<ScriptState*, int, KyraEngine_v1> OpcodeV1;
#define SetOpcodeTable(x) table = &x;
#define Opcode(x) table->push_back(new OpcodeV1(this, &KyraEngine_v1::x))
void KyraEngine_v1::setupOpcodeTable() {
diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp
index 0c2f1d2c24..e0b863a60d 100644
--- a/engines/kyra/script_v2.cpp
+++ b/engines/kyra/script_v2.cpp
@@ -1872,12 +1872,12 @@ int KyraEngine_v2::t2_playSoundEffect(const TIM *tim, const uint16 *param) {
#pragma mark -
-typedef Functor1Mem<ScriptState*, int, KyraEngine_v2> OpcodeV2;
+typedef Common::Functor1Mem<ScriptState*, int, KyraEngine_v2> OpcodeV2;
#define SetOpcodeTable(x) table = &x;
#define Opcode(x) table->push_back(new OpcodeV2(this, &KyraEngine_v2::x))
#define OpcodeUnImpl() table->push_back(new OpcodeV2(this, 0))
-typedef Functor2Mem<const TIM*, const uint16*, int, KyraEngine_v2> TIMOpcodeV2;
+typedef Common::Functor2Mem<const TIM*, const uint16*, int, KyraEngine_v2> TIMOpcodeV2;
#define OpcodeTim(x) _timOpcodes.push_back(new TIMOpcodeV2(this, &KyraEngine_v2::x))
#define OpcodeTimUnImpl() _timOpcodes.push_back(TIMOpcodeV2(this, 0))
diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp
index 58fe9f9087..e309b1ee1c 100644
--- a/engines/kyra/script_v3.cpp
+++ b/engines/kyra/script_v3.cpp
@@ -580,7 +580,7 @@ int KyraEngine_v3::o3t_getMalcolmShapes(ScriptState *script) {
return _malcolmShapes;
}
-typedef Functor1Mem<ScriptState*, int, KyraEngine_v3> OpcodeV3;
+typedef Common::Functor1Mem<ScriptState*, int, KyraEngine_v3> OpcodeV3;
#define SetOpcodeTable(x) table = &x;
#define Opcode(x) table->push_back(new OpcodeV3(this, &KyraEngine_v3::x))
#define OpcodeUnImpl() table->push_back(new OpcodeV3(this, 0))
diff --git a/engines/kyra/timer.h b/engines/kyra/timer.h
index 44f2e744c6..0991f0a1b1 100644
--- a/engines/kyra/timer.h
+++ b/engines/kyra/timer.h
@@ -27,14 +27,14 @@
#define KYRA_TIMER_H
#include "kyra/kyra.h"
-#include "kyra/util.h"
#include "common/list.h"
#include "common/stream.h"
+#include "common/func.h"
namespace Kyra {
-typedef Functor1<int, void> TimerFunc;
+typedef Common::Functor1<int, void> TimerFunc;
struct TimerEntry {
uint8 id;
@@ -89,3 +89,4 @@ private:
} // end of namespace Kyra
#endif
+
diff --git a/engines/kyra/timer_v1.cpp b/engines/kyra/timer_v1.cpp
index c02042f1cc..f2a31da554 100644
--- a/engines/kyra/timer_v1.cpp
+++ b/engines/kyra/timer_v1.cpp
@@ -33,7 +33,7 @@
namespace Kyra {
-#define TimerV1(x) new Functor1Mem<int, void, KyraEngine_v1>(this, &KyraEngine_v1::x)
+#define TimerV1(x) new Common::Functor1Mem<int, void, KyraEngine_v1>(this, &KyraEngine_v1::x)
void KyraEngine_v1::setupTimers() {
debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::setupTimers()");
diff --git a/engines/kyra/timer_v2.cpp b/engines/kyra/timer_v2.cpp
index 7e21970067..4c97a6dd2d 100644
--- a/engines/kyra/timer_v2.cpp
+++ b/engines/kyra/timer_v2.cpp
@@ -28,7 +28,7 @@
namespace Kyra {
-#define TimerV2(x) new Functor1Mem<int, void, KyraEngine_v2>(this, &KyraEngine_v2::x)
+#define TimerV2(x) new Common::Functor1Mem<int, void, KyraEngine_v2>(this, &KyraEngine_v2::x)
void KyraEngine_v2::setupTimers() {
debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::setupTimers()");
diff --git a/engines/kyra/timer_v3.cpp b/engines/kyra/timer_v3.cpp
index f9e7c1a571..2211fc6337 100644
--- a/engines/kyra/timer_v3.cpp
+++ b/engines/kyra/timer_v3.cpp
@@ -28,7 +28,7 @@
namespace Kyra {
-#define TimerV3(x) new Functor1Mem<int, void, KyraEngine_v3>(this, &KyraEngine_v3::x)
+#define TimerV3(x) new Common::Functor1Mem<int, void, KyraEngine_v3>(this, &KyraEngine_v3::x)
void KyraEngine_v3::setupTimers() {
debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v3::setupTimers()");
diff --git a/engines/kyra/util.h b/engines/kyra/util.h
deleted file mode 100644
index 78925441f3..0000000000
--- a/engines/kyra/util.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* 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 KYRA_UTIL_H
-#define KYRA_UTIL_H
-
-#include "common/func.h"
-
-namespace Kyra {
-
-template<class Res>
-struct Functor0 {
- virtual ~Functor0() {}
-
- virtual bool isValid() const = 0;
- virtual Res operator()() const = 0;
-};
-
-template<class Res, class T>
-class Functor0Mem : public Functor0<Res> {
-public:
- typedef Res (T::*FuncType)();
-
- Functor0Mem(T *t, const FuncType &func) : _t(t), _func(func) {}
-
- bool isValid() const { return _func != 0; }
- Res operator()() const {
- return (_t->*_func)();
- }
-private:
- mutable T *_t;
- Res (T::*_func)();
-};
-
-template<class Arg, class Res>
-struct Functor1 : public Common::UnaryFunction<Arg, Res> {
- virtual ~Functor1() {}
-
- virtual bool isValid() const = 0;
- virtual Res operator()(Arg) const = 0;
-};
-
-template<class Arg, class Res, class T>
-class Functor1Mem : public Functor1<Arg, Res> {
-public:
- typedef Res (T::*FuncType)(Arg);
-
- Functor1Mem(T *t, const FuncType &func) : _t(t), _func(func) {}
-
- bool isValid() const { return _func != 0; }
- Res operator()(Arg v1) const {
- return (_t->*_func)(v1);
- }
-private:
- mutable T *_t;
- Res (T::*_func)(Arg);
-};
-
-template<class Arg1, class Arg2, class Res>
-struct Functor2 : public Common::BinaryFunction<Arg1, Arg2, Res> {
- virtual ~Functor2() {}
-
- virtual bool isValid() const = 0;
- virtual Res operator()(Arg1, Arg2) const = 0;
-};
-
-template<class Arg1, class Arg2, class Res, class T>
-class Functor2Mem : public Functor2<Arg1, Arg2, Res> {
-public:
- typedef Res (T::*FuncType)(Arg1, Arg2);
-
- Functor2Mem(T *t, const FuncType &func) : _t(t), _func(func) {}
-
- bool isValid() const { return _func != 0; }
- Res operator()(Arg1 v1, Arg2 v2) const {
- return (_t->*_func)(v1, v2);
- }
-private:
- mutable T *_t;
- Res (T::*_func)(Arg1, Arg2);
-};
-
-struct ScriptState;
-typedef Functor1<ScriptState*, int> Opcode;
-
-struct TIM;
-typedef Functor2<const TIM*, const uint16*, int> TIMOpcode;
-
-} // end of namespace Kyra
-
-#endif
-