15 #define GETTEXT_DOMAIN "wesnoth-lib"
27 #include "../../minimap.hpp"
30 #include <boost/make_shared.hpp>
35 #define ERR_CF LOG_STREAM_INDENT(err, log_config)
37 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
38 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
69 : w(w), h(h), map_data(map_data)
141 static bool compare(
const std::pair<unsigned, tcache::iterator>& lhs,
142 const std::pair<unsigned, tcache::iterator>& rhs)
144 return lhs.first < rhs.first;
149 #ifdef DEBUG_MINIMAP_CACHE
150 std::cerr <<
"\nShrink cache from " <<
cache.size();
152 DBG_GUI_D <<
"Shrinking the minimap cache.\n";
155 std::vector<std::pair<unsigned, tcache::iterator> >
items;
158 itor->second.age /= 2;
159 items.push_back(std::make_pair(
itor->second.age,
itor));
162 std::partial_sort(items.begin(),
167 for(std::vector<std::pair<unsigned, tcache::iterator> >::
iterator vitor
172 cache.erase(vitor->second);
175 #ifdef DEBUG_MINIMAP_CACHE
176 std::cerr <<
" to " <<
cache.size() <<
".\n";
192 #ifdef DEBUG_MINIMAP_CACHE
193 std::cerr <<
"\nFlush cache.\n";
195 DBG_GUI_D <<
"Flushing the minimap cache.\n";
204 if(itor !=
cache.end()) {
205 #ifdef DEBUG_MINIMAP_CACHE
209 return itor->second.surf;
221 #ifdef DEBUG_MINIMAP_CACHE
228 ERR_CF <<
"Error while loading the map: " << e.
message <<
'\n';
229 #ifdef DEBUG_MINIMAP_CACHE
252 assert(rect.w > 0 && rect.h > 0);
256 sdl_blit(surf,
nullptr, frame_buffer, &rect);
271 DBG_GUI_P <<
"Parsing minimap " <<
id <<
'\n';
273 load_resolutions<tresolution>(cfg);
341 DBG_GUI_G <<
"Window builder: placed minimap '" <<
id
342 <<
"' with definition '" <<
definition <<
"'.\n";
Define the common log macros for the gui toolkit.
static bool compare(const std::pair< unsigned, tcache::iterator > &lhs, const std::pair< unsigned, tcache::iterator > &rhs)
tkey(const int w, const int h, const std::string &map_data)
surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::map< map_location, unsigned int > *reach_map)
function to create the minimap for a given map the surface returned must be freed by the user ...
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Value type for the cache.
GLuint GLuint GLsizei GLenum type
const int h
Height of the image.
bool disable_click_dismiss() const override
See twidget::disable_click_dismiss.
virtual unsigned get_state() const override
See tcontrol::get_state.
const std::vector< std::string > items
std::map< tkey, tvalue > tcache
The cache.
Base class of a resolution, contains the common keys for a resolution.
A class inherited from ttext_box that displays its input as stars.
void init_control(tcontrol *control) const
std::string definition
Parameters for the control.
const surface surf
The cached image.
static void shrink_cache()
std::string map_data_
The map data to be used to generate the map.
static bool operator<(const tkey &lhs, const tkey &rhs)
GLubyte GLubyte GLubyte GLubyte w
unsigned age
The age of the image.
tresolution(const config &cfg)
Encapsulates the map of the game.
virtual void impl_draw_background(surface &frame_buffer, int x_offset, int y_offset) override
See twidget::impl_draw_background.
static const ::config * terrain
The terrain used to create the cache.
Contains the state info for a resolution.
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
virtual bool get_active() const override
See tcontrol::get_active.
std::map< std::string, tfilter >::iterator itor
const std::string map_data
The data used to generate the image.
GLfloat GLfloat GLfloat GLfloat h
tvalue(const surface &surf)
static const size_t cache_max_size
Maximum number of items in the cache (multiple of 4).
const surface get_image(const int w, const int h) const
Gets the image for the minimap.
std::vector< tstate_definition > state
const int w
Width of the image.
tminimap_definition(const config &cfg)
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
const ::config * terrain_
The config object with the terrain data.
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
Contains the implementation details for lexical_cast and shouldn't be used directly.