-
-
Notifications
You must be signed in to change notification settings - Fork 990
/
halo.hpp
101 lines (75 loc) · 2.42 KB
/
halo.hpp
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
Copyright (C) 2003 - 2014 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
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.
See the COPYING file for more details.
*/
/** @file */
#ifndef HALO_HPP_INCLUDED
#define HALO_HPP_INCLUDED
class display;
#include "map_location.hpp"
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
namespace halo
{
class halo_impl;
class halo_record;
typedef boost::shared_ptr<halo_record> handle;
enum ORIENTATION { NORMAL, HREVERSE, VREVERSE, HVREVERSE };
const int NO_HALO = 0;
class manager
{
public:
manager(display& disp);
/**
* Add a haloing effect using 'image centered on (x,y).
* @return The handle to the halo object.
* @retval 0 is the invalid handle.
*
* If the halo is attached to an item, it needs to be hidden if the
* shroud is active. (Note it will be shown with the fog active.)
* If it is not attached to an item, the location should be set to -1, -1
*/
handle add(int x, int y, const std::string& image, const map_location& loc,
halo::ORIENTATION orientation=NORMAL, bool infinite=true);
/** Set the position of an existing haloing effect, according to its handle. */
void set_location(const handle & h, int x, int y);
/** Remove the halo with the given handle. */
void remove(const handle & h);
/**
* Render and unrender haloes.
*
* Which haloes are rendered is determined by invalidated_locations and the
* internal state in the control sets (in halo.cpp).
*/
void unrender(std::set<map_location> invalidated_locations);
void render();
private:
boost::shared_ptr<halo_impl> impl_;
};
/**
* RAII object which manages a halo. When it goes out of scope it removes the corresponding halo entry.
*/
class halo_record : public boost::noncopyable
{
public:
halo_record();
halo_record(int id, const boost::shared_ptr<halo_impl> & my_manager);
~halo_record();
bool valid() const {
return id_ != NO_HALO && !my_manager_.expired();
}
friend class manager;
private:
int id_;
boost::weak_ptr<halo_impl> my_manager_;
};
} // end namespace halo
#endif