Skip to content

Commit 7ef491e

Browse files
committed
UNITY: Move UIScreen into new file.
1 parent 7431bf7 commit 7ef491e

File tree

7 files changed

+103
-19
lines changed

7 files changed

+103
-19
lines changed

bridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef UNITY_BRIDGE_H
1818
#define UNITY_BRIDGE_H
1919

20-
#include "unity.h"
20+
#include "screen.h"
2121

2222
namespace Unity {
2323

module.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ MODULE_OBJS := \
99
fvf_decoder.o \
1010
graphics.o \
1111
object.o \
12+
screen.o \
1213
sound.o \
1314
sprite.o \
1415
sprite_player.o \

screen.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This library is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 2.1 of the License, or (at your option) any later version.
6+
*
7+
* This library is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
12+
* You should have received a copy of the GNU Lesser General Public
13+
* License along with this library; if not, write to the Free Software
14+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
*/
16+
17+
#include "screen.h"
18+
19+
namespace Unity {
20+
21+
UIScreen::UIScreen(UnityEngine *vm) : _vm(vm) {
22+
}
23+
24+
UIScreen::~UIScreen() {
25+
for (uint i = 0; i < _controls.size(); i++) {
26+
delete _controls[i];
27+
}
28+
}
29+
30+
UIControl *UIScreen::getControlAt(const Common::Point &pos) {
31+
for (uint i = 0; i < _controls.size(); i++) {
32+
if (_controls[i]->_bounds.contains(pos))
33+
return _controls[i];
34+
}
35+
36+
return NULL;
37+
}
38+
39+
} // Unity
40+

screen.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* This library is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 2.1 of the License, or (at your option) any later version.
6+
*
7+
* This library is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
12+
* You should have received a copy of the GNU Lesser General Public
13+
* License along with this library; if not, write to the Free Software
14+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
*/
16+
17+
#ifndef UNITY_SCREEN_H
18+
#define UNITY_SCREEN_H
19+
20+
#include "common/array.h"
21+
#include "common/rect.h"
22+
23+
namespace Unity {
24+
25+
class UnityEngine;
26+
27+
struct UIControl {
28+
UIControl() : _id(0), _sprite(0xffffffff), _state(0) { }
29+
virtual ~UIControl() { }
30+
31+
uint _id;
32+
uint _sprite;
33+
uint _state;
34+
Common::Rect _bounds;
35+
};
36+
37+
class UIScreen {
38+
public:
39+
UIScreen(UnityEngine *vm);
40+
virtual ~UIScreen();
41+
42+
virtual void start() = 0;
43+
virtual void mouseMove(const Common::Point &pos) = 0;
44+
virtual void mouseClick(const Common::Point &pos) = 0;
45+
virtual void draw() = 0;
46+
47+
protected:
48+
UnityEngine *_vm;
49+
50+
Common::Array<UIControl *> _controls;
51+
UIControl *getControlAt(const Common::Point &pos);
52+
};
53+
54+
} // Unity
55+
56+
#endif
57+

unity.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Sound;
3131
class SpritePlayer;
3232
class Object;
3333
class Trigger;
34-
class UnityEngine;
34+
class UIScreen;
3535

3636
enum AwayTeamMode {
3737
mode_Look,
@@ -61,20 +61,6 @@ enum ScreenType {
6161
ViewscreenScreenType
6262
};
6363

64-
class UIScreen {
65-
public:
66-
UIScreen(UnityEngine *vm) : _vm(vm) { }
67-
virtual ~UIScreen() { }
68-
69-
virtual void start() = 0;
70-
virtual void mouseMove(const Common::Point &pos) = 0;
71-
virtual void mouseClick(const Common::Point &pos) = 0;
72-
virtual void draw() = 0;
73-
74-
protected:
75-
UnityEngine *_vm;
76-
};
77-
7864
class UnityEngine : public Engine {
7965
public:
8066
UnityEngine(class OSystem *syst);

viewscreen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ ViewscreenScreen::~ViewscreenScreen() {
2626
}
2727

2828
void ViewscreenScreen::start() {
29-
Object *obj;
30-
3129
_vm->data._currentScreen.objects.clear();
3230
_vm->data._currentScreen.polygons.clear();
3331
_vm->data._currentScreen.world = 0x5f;
3432
_vm->data._currentScreen.screen = 0xff;
3533

34+
Object *obj;
35+
3636
// TODO: icon at 33, 444
3737

3838
// viewscreen image

viewscreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef UNITY_VIEWSCREEN_H
1818
#define UNITY_VIEWSCREEN_H
1919

20-
#include "unity.h"
20+
#include "screen.h"
2121

2222
namespace Unity {
2323

0 commit comments

Comments
 (0)