This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
/
DynamicDisplayable.h
81 lines (66 loc) · 2.82 KB
/
DynamicDisplayable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Copyright (C) 2006-2012 Christopho, Solarus - http://www.solarus-games.org
*
* Solarus 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 3 of the License, or
* (at your option) any later version.
*
* Solarus 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLARUS_DYNAMIC_DISPLAYABLE_H
#define SOLARUS_DYNAMIC_DISPLAYABLE_H
#include "Common.h"
#include "lua/ExportableToLua.h"
#include "lowlevel/Rectangle.h"
#include <lua.hpp>
/**
* @brief An object that can be drawn on a surface with additional effects.
*
* Possible additional effects are movements and transitions.
* Lua callbacks may be associated to the end of these effects.
*/
class DynamicDisplayable: public ExportableToLua {
public:
virtual ~DynamicDisplayable();
// dynamic effects
void start_movement(Movement& movement, int callback_ref = LUA_REFNIL);
void stop_movement();
void set_movement_callback(int movement_callback_ref);
void start_transition(Transition& transition, int callback_ref = LUA_REFNIL);
void stop_transition();
void set_transition_callback(int transition_callback_ref);
// displaying with effects
void display(Surface& dst_surface);
void display(Surface& dst_surface, int x, int y);
void display(Surface& dst_surface, Rectangle dst_position);
/**
* @brief Displays this object without applying dynamic effects.
* @param dst_surface the destination surface
* @param dst_position coordinates on the destination surface
*/
virtual void raw_display(Surface& dst_surface,
const Rectangle& dst_position) = 0;
virtual void update();
protected:
DynamicDisplayable();
virtual Surface* get_surface();
private:
Rectangle last_position; /**< position of this object after its last
* movement */
Movement* movement; /**< a movement applied, or NULL (will be
* deleted then if unused elsewhere) */
int movement_callback_ref; /**< Lua registry ref of a function to call
* when the movement finishes */
Transition* transition; /**< a transition applied, or NULL
* (will be deleted then) */
int transition_callback_ref; /**< Lua registry ref of a function to call
* when the transition finishes */
};
#endif