16 #define GETTEXT_DOMAIN "wesnoth-lib"
30 0x000000, 0x000000, 0x333333,
39 normal_rgb_(0x000000), selected_rgb_(0x000099), heading_rgb_(0x333333),
41 normal_alpha_(50), selected_alpha_(150), heading_alpha_(75),
43 normal_alpha_(0.2), selected_alpha_(0.6), heading_alpha_(0.3),
45 max_img_w_(-1), max_img_h_(-1)
51 int normal_rgb,
int selected_rgb,
int heading_rgb,
52 double normal_alpha,
double selected_alpha,
double heading_alpha)
53 : img_base_(img_base), has_background_(has_bg),
initialized_(false), load_failed_(false),
54 normal_rgb2_(normal_rgb), selected_rgb2_(selected_rgb), heading_rgb2_(heading_rgb),
55 normal_alpha2_(normal_alpha), selected_alpha2_(selected_alpha), heading_alpha2_(heading_alpha)
66 max_img_w_ = max_width;
67 max_img_h_ = max_height;
73 sdl::timage
img = image::get_texture(img_loc);
77 if(max_img_w_ > 0 && img.width() > max_img_w_) {
78 scale = (max_img_w_ * 100) / img.width();
80 if(max_img_h_ > 0 && img.height() > max_img_h_) {
81 scale = std::min<int>(
scale, ((max_img_h_ * 100) / img.height()));
85 img.set_scale(scale, scale);
98 if(max_img_w_ > 0 && surf->w > max_img_w_) {
99 scale = (max_img_w_ * 100) / surf->w;
101 if(max_img_h_ > 0 && surf->h > max_img_h_) {
102 scale = std::min<int>(
scale, ((max_img_h_ * 100) / surf->h));
106 return scale_surface(surf, (scale * surf->w)/100, (scale * surf->h)/100);
118 img_map_[img_sub] =
image;
119 return(!image.null());
121 std::string path = img_base_ +
"-" + img_sub +
".png";
123 img_map_[img_sub] =
image;
124 return(!image.
null());
133 if( load_image(
"border-botleft")
134 && load_image(
"border-botright")
135 && load_image(
"border-topleft")
136 && load_image(
"border-topright")
137 && load_image(
"border-left")
138 && load_image(
"border-right")
139 && load_image(
"border-top")
140 && load_image(
"border-bottom") )
144 img_map_[
"border-top"].
height(),
145 img_map_[
"border-left"].
width());
148 img_map_[
"border-top"]->
h,
149 img_map_[
"border-left"]->
w);
153 if(has_background_ && !load_image(
"background"))
159 normal_rgb_ = normal_rgb2_;
160 normal_alpha_ = normal_alpha2_;
161 selected_rgb_ = selected_rgb2_;
162 selected_alpha_ = selected_alpha2_;
163 heading_rgb_ = heading_rgb2_;
164 heading_alpha_ = heading_alpha2_;
166 load_failed_ =
false;
177 return (!load_failed_);
183 if(type ==
SELECTED_ROW && has_background_ && !load_failed_) {
184 background_image_.set_scale(
float(rect.w) / background_image_.width(),
185 float(rect.h) / background_image_.height());
186 menu_ref.
video().draw_texture(background_image_, rect.x, rect.y);
189 if(type ==
SELECTED_ROW && has_background_ && !load_failed_) {
190 if(bg_cache_.width != rect.w || bg_cache_.height != rect.h)
194 bg_cache_.surf =
scale_surface(img_map_[
"background"], rect.w, rect.h);
195 bg_cache_.width = rect.w;
196 bg_cache_.height = rect.h;
198 SDL_Rect clip = rect;
221 GPU_SetClip(get_render_target(), rect.x, rect.y, rect.w, rect.h);
223 image = img_map_[
"border-top"];
227 menu_ref.
video().draw_texture(image, area.x, area.y);
228 area.x += image.width();
229 }
while( area.x < rect.x + rect.w );
231 image = img_map_[
"border-left"];
235 menu_ref.
video().draw_texture(image, area.x, area.y);
236 area.y += image.height();
237 }
while( area.y < rect.y + rect.h );
239 image = img_map_[
"border-right"];
243 menu_ref.
video().draw_texture(image, area.x, area.y);
244 area.y += image.height();
245 }
while( area.y < rect.y + rect.h );
247 image = img_map_[
"border-bottom"];
251 menu_ref.
video().draw_texture(image, area.x, area.y);
252 area.x += image.width();
253 }
while( area.x < rect.x + rect.w );
255 image = img_map_[
"border-topleft"];
258 menu_ref.
video().draw_texture(image, area.x, area.y);
260 image = img_map_[
"border-topright"];
261 area.x = rect.x + rect.w - image.width();
263 menu_ref.
video().draw_texture(image, area.x, area.y);
265 image = img_map_[
"border-botleft"];
267 area.y = rect.y + rect.h - image.height();
268 menu_ref.
video().draw_texture(image, area.x, area.y);
270 image = img_map_[
"border-botright"];
271 area.x = rect.x + rect.w - image.width();
272 area.y = rect.y + rect.h - image.height();
273 menu_ref.
video().draw_texture(image, area.x, area.y);
283 SDL_Rect clip = rect;
287 image = img_map_[
"border-top"];
293 }
while( area.x < rect.x + rect.w );
295 image = img_map_[
"border-left"];
301 }
while( area.y < rect.y + rect.h );
303 image = img_map_[
"border-right"];
309 }
while( area.y < rect.y + rect.h );
311 image = img_map_[
"border-bottom"];
317 }
while( area.x < rect.x + rect.w );
319 image = img_map_[
"border-topleft"];
324 image = img_map_[
"border-topright"];
325 area.x = rect.x + rect.w - image->w;
329 image = img_map_[
"border-botleft"];
331 area.y = rect.y + rect.h - image->h;
334 image = img_map_[
"border-botright"];
335 area.x = rect.x + rect.w - image->w;
336 area.y = rect.y + rect.h - image->h;
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
void GPU_UnsetClip(GPU_Target *target)
GLenum GLenum GLenum GLenum GLenum scale
GLuint GLuint GLsizei GLenum type
GLenum GLsizei GLenum GLenum const GLvoid * image
surface scale_surface(const surface &surf, int w, int h)
void blit_surface(int x, int y, surface surf, SDL_Rect *srcrect=nullptr, SDL_Rect *clip_rect=nullptr)
unsigned thickness_
The thickness of the line.
GLsizei const char ** path
GLubyte GLubyte GLubyte GLubyte w
GPU_Rect GPU_SetClip(GPU_Target *target, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
GLfloat GLfloat GLfloat GLfloat h
this module manages the cache of images.
GLsizei const GLcharARB ** string