replaced slateborder_style with bluebg_style for menu list selections

This commit is contained in:
Patrick Parker 2006-05-30 06:39:15 +00:00
parent 173d941815
commit e774ce4de8
15 changed files with 64 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

View file

@ -1573,7 +1573,7 @@ void section::clear()
}
help_menu::help_menu(CVideo &video, section const &toplevel, int max_height)
: gui::menu(video, empty_string_vector, true, max_height, -1, NULL, &gui::menu::slateborder_style),
: gui::menu(video, empty_string_vector, true, max_height, -1, NULL, &gui::menu::bluebg_style),
toplevel_(toplevel), chosen_topic_(NULL), selected_item_(&toplevel, "")
{
update_visible_items(toplevel_);

View file

@ -236,7 +236,7 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
chat_timestamp_button_(disp.video(), _("Chat Timestamping"), gui::button::TYPE_CHECK),
music_label_(disp.video(), _("Music Volume:")), sound_label_(disp.video(), _("SFX Volume:")),
scroll_label_(disp.video(), _("Scroll Speed:")), gamma_label_(disp.video(), _("Gamma:")), chat_lines_label_(disp.video(), ""),
slider_label_width_(0), advanced_(disp.video(),std::vector<std::string>(),false,-1,-1,NULL,&gui::menu::slateborder_style), advanced_selection_(-1),
slider_label_width_(0), advanced_(disp.video(),std::vector<std::string>(),false,-1,-1,NULL,&gui::menu::bluebg_style), advanced_selection_(-1),
tab_(GENERAL_TAB), disp_(disp), game_cfg_(game_cfg)
{
// FIXME: this box should be vertically centered on the screen, but is not
@ -776,7 +776,7 @@ void show_hotkeys_dialog (display & disp, config *save_config)
gui::menu::basic_sorter sorter;
sorter.set_alpha_sort(0).set_alpha_sort(1);
gui::menu menu_(disp.video(), menu_items, false, height, -1, &sorter, &gui::menu::slateborder_style);
gui::menu menu_(disp.video(), menu_items, false, height, -1, &sorter, &gui::menu::bluebg_style);
menu_.sort_by(0);
menu_.reset_selection();
menu_.set_width(font::relative_size(400));

View file

@ -838,7 +838,7 @@ int show_dialog(display& disp, surface image,
return -1;
}
/* show_dialog2: same as show_dialog, but uses the slateborder style
/* show_dialog2: same as show_dialog, but uses the image-select style
provided as a convenience to use default parameters */
//inline
int show_dialog2(display &screen, surface image,
@ -866,7 +866,7 @@ int show_dialog2(display &screen, surface image,
text_widget_max_chars,
action, options, xloc, yloc,
dialog_style, buttons,
help_topic, sorter, &menu::slateborder_style);
help_topic, sorter, &menu::bluebg_style);
}
}

View file

@ -676,12 +676,8 @@ SDL_Rect menu::style::item_size(const std::string& item) const {
return res;
}
void menu::style::draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type)
void menu::style::draw_row_bg(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type)
{
if(rect.w == 0 || rect.h == 0) {
return;
}
menu_ref.bg_restore(rect);
int rgb = 0;
@ -705,6 +701,14 @@ void menu::style::draw_row(const menu& menu_ref, const std::vector<std::string>&
draw_solid_tinted_rectangle(rect.x, rect.y, rect.w, rect.h,
(rgb&0xff0000) >> 16,(rgb&0xff00) >> 8,rgb&0xff,alpha,
menu_ref.video().getSurface());
}
void menu::style::draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type)
{
if(rect.w == 0 || rect.h == 0) {
return;
}
draw_row_bg(menu_ref, row, rect, type);
SDL_Rect const &area = screen_area();
SDL_Rect const &loc = menu_ref.inner_location();

View file

@ -43,6 +43,7 @@ public:
virtual void init() {}
virtual SDL_Rect item_size(const std::string& item) const;
virtual void draw_row_bg(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type);
virtual void draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type);
size_t get_font_size() const;
@ -62,10 +63,13 @@ public:
class imgsel_style : public style
{
public:
imgsel_style(const std::string &img_base);
imgsel_style(const std::string &img_base, bool has_bg,
int normal_rgb, int selected_rgb, int heading_rgb,
double normal_alpha, double selected_alpha, double heading_alpha);
virtual ~imgsel_style();
virtual SDL_Rect item_size(const std::string& item) const;
virtual void draw_row_bg(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type);
virtual void draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type);
virtual void init() { load_images(); }
@ -77,14 +81,17 @@ public:
private:
bool load_image(const std::string &img_sub);
bool has_background_;
bool initialized_;
bool load_failed_;
int normal_rgb2_, selected_rgb2_, heading_rgb2_;
double normal_alpha2_, selected_alpha2_, heading_alpha2_;
};
friend class style;
friend class imgsel_style;
static style default_style;
static imgsel_style slateborder_style;
static imgsel_style bluebg_style;
struct item
{

View file

@ -35,8 +35,13 @@
namespace gui {
//static initializations
menu::style gui::menu::default_style;
menu::imgsel_style gui::menu::slateborder_style("misc/selection");
menu::style menu::default_style;
menu::imgsel_style menu::slateborder_style("misc/selection", false,
0x4a4440, 0x000000, 0x999999,
0.2, 0.9, 0.2);
menu::imgsel_style menu::bluebg_style("misc/selection2", true,
0x000000, 0x000000, 0x333333,
0.2, 0.0, 0.3);
//constructors
menu::style::style() : font_size_(font::SIZE_NORMAL),
@ -47,8 +52,12 @@ menu::style::style() : font_size_(font::SIZE_NORMAL),
menu::style::~style()
{}
menu::imgsel_style::imgsel_style(const std::string &img_base) : img_base_(img_base),
initialized_(false), load_failed_(false)
menu::imgsel_style::imgsel_style(const std::string &img_base, bool has_bg,
int normal_rgb, int selected_rgb, int heading_rgb,
double normal_alpha, double selected_alpha, double heading_alpha)
: img_base_(img_base), initialized_(false), load_failed_(false), has_background_(has_bg),
normal_rgb2_(normal_rgb), selected_rgb2_(selected_rgb), heading_rgb2_(heading_rgb),
normal_alpha2_(normal_alpha), selected_alpha2_(selected_alpha), heading_alpha2_(heading_alpha)
{}
menu::imgsel_style::~imgsel_style()
{}
@ -84,15 +93,22 @@ bool menu::imgsel_style::load_images()
img_map_["border-top"]->h,
img_map_["border-left"]->w);
selected_rgb_ = 0x000000;
selected_alpha_ = 0.9;
normal_rgb_ = 0x4a4440;
normal_alpha_ = 0.2;
heading_rgb_ = 0x999999;
heading_alpha_ = 0.2;
if(has_background_ && !load_image("background"))
{
load_failed_ = true;
}
else
{
normal_rgb_ = normal_rgb2_;
normal_alpha_ = normal_alpha2_;
selected_rgb_ = selected_rgb2_;
selected_alpha_ = selected_alpha2_;
heading_rgb_ = heading_rgb2_;
heading_alpha_ = heading_alpha2_;
load_failed_ = false;
}
initialized_ = true;
load_failed_ = false;
}
else
{
@ -104,6 +120,20 @@ bool menu::imgsel_style::load_images()
return (!load_failed_);
}
void menu::imgsel_style::draw_row_bg(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type)
{
if(type == SELECTED_ROW && has_background_ && !load_failed_) {
//draw scaled background image
//scale image each time (to prevent loss of quality)
surface image = scale_surface(img_map_["background"], rect.w, rect.h);
SDL_Rect clip = rect;
menu_ref.video().blit_surface(rect.x,rect.y,image,NULL,&clip);
}
else {
style::draw_row_bg(menu_ref, row, rect, type);
}
}
void menu::imgsel_style::draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type)
{
if(!load_failed_) {