expansion and improvement of the slateborder menu style
|
@ -40,7 +40,8 @@ SVN trunk (1.1.2+svn):
|
|||
orcish sword, pike, pincers, plaguestaff, sling, thorns, torch, touch,
|
||||
wail, zombie touch
|
||||
* hitpoint distribution graphs under Damage Calculations
|
||||
* stylistic improvements to loadscreen progressbar
|
||||
* improvements to loadscreen progressbar
|
||||
* new selection stlye for menu listboxes
|
||||
* multiplayer maps:
|
||||
* added multiplayer maps: 8p Morituri
|
||||
* revised multiplayer maps: Blitz, Charge, Cynsaun Battlefield, Den of Onis,
|
||||
|
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 337 B After Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 344 B |
|
@ -102,7 +102,7 @@ void advance_unit(const game_data& info,
|
|||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
res = gui::show_dialog(gui,NULL,_("Advance Unit"),
|
||||
res = gui::show_dialog2(gui,NULL,_("Advance Unit"),
|
||||
_("What should our victorious unit become?"),
|
||||
gui::OK_ONLY, &lang_options, &preview_panes);
|
||||
}
|
||||
|
|
14
src/game.cpp
|
@ -752,10 +752,9 @@ bool game_controller::new_campaign()
|
|||
preview_panes.push_back(&campaign_preview);
|
||||
|
||||
wassert(campaign_names.size() > 0);
|
||||
res = gui::show_dialog(disp(),NULL,_("Campaign"),
|
||||
res = gui::show_dialog2(disp(),NULL,_("Campaign"),
|
||||
_("Choose the campaign you want to play:"),
|
||||
gui::OK_CANCEL,&campaign_names,&preview_panes,
|
||||
"",NULL,256,NULL,NULL,-1,-1,NULL,NULL,"",NULL,&gui::menu::slateborder_style);
|
||||
gui::OK_CANCEL,&campaign_names,&preview_panes);
|
||||
|
||||
if(res == -1) {
|
||||
return false;
|
||||
|
@ -782,7 +781,7 @@ bool game_controller::new_campaign()
|
|||
std::copy(difficulties.begin(),difficulties.end(),difficulty_options.begin());
|
||||
}
|
||||
|
||||
const int res = gui::show_dialog(disp(),NULL,_("Difficulty"),
|
||||
const int res = gui::show_dialog2(disp(),NULL,_("Difficulty"),
|
||||
_("Select difficulty level:"),
|
||||
gui::OK_CANCEL,&difficulty_options);
|
||||
if(res == -1) {
|
||||
|
@ -963,8 +962,7 @@ void game_controller::download_campaigns()
|
|||
gui::menu::basic_sorter sorter;
|
||||
sorter.set_alpha_sort(1).set_alpha_sort(2).set_alpha_sort(3).set_numeric_sort(4).set_position_sort(5,sizes);
|
||||
|
||||
const int index = gui::show_dialog(disp(),NULL,_("Get Campaign"),_("Choose the campaign to download."),gui::OK_CANCEL,&options,
|
||||
NULL,"",NULL,0,NULL,NULL,-1,-1,NULL,NULL,"",&sorter,&gui::menu::slateborder_style);
|
||||
const int index = gui::show_dialog2(disp(),NULL,_("Get Campaign"),_("Choose the campaign to download."),gui::OK_CANCEL,&options);
|
||||
if(index < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -1150,7 +1148,7 @@ bool game_controller::play_multiplayer()
|
|||
|
||||
int res;
|
||||
do {
|
||||
res = gui::show_dialog(disp(), NULL, _("Multiplayer"), "",
|
||||
res = gui::show_dialog2(disp(), NULL, _("Multiplayer"), "",
|
||||
gui::OK_CANCEL, &host_or_join, NULL,
|
||||
_("Login: "), &login);
|
||||
if(login.size() > 18) {
|
||||
|
@ -1226,7 +1224,7 @@ bool game_controller::change_language()
|
|||
}
|
||||
}
|
||||
|
||||
const int res = gui::show_dialog(disp(),NULL,_("Language"),
|
||||
const int res = gui::show_dialog2(disp(),NULL,_("Language"),
|
||||
_("Choose your preferred language:"),
|
||||
gui::OK_CANCEL,&langs);
|
||||
if(size_t(res) < langs.size()) {
|
||||
|
|
|
@ -1339,7 +1339,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
if(get_replay_source().at_end() || options.empty()) {
|
||||
const std::string msg = utils::interpolate_variables_into_string(cfg["message"], *state_of_game);
|
||||
const SDL_Rect& map_area = screen->map_area();
|
||||
option_chosen = gui::show_dialog(*screen,surface,caption,msg,
|
||||
option_chosen = gui::show_dialog2(*screen,surface,caption,msg,
|
||||
options.empty() ? gui::MESSAGE : gui::OK_ONLY,
|
||||
options.empty() ? NULL : &options,
|
||||
NULL, "", NULL, 256, NULL, NULL, -1, map_area.y+4);
|
||||
|
|
|
@ -1546,7 +1546,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),
|
||||
: gui::menu(video, empty_string_vector, true, max_height, -1, NULL, &gui::menu::slateborder_style),
|
||||
toplevel_(toplevel), chosen_topic_(NULL), selected_item_(&toplevel, "")
|
||||
{
|
||||
update_visible_items(toplevel_);
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace events{
|
|||
}
|
||||
|
||||
for(;;) {
|
||||
const int res = gui::show_dialog(*gui_, NULL, _("Statistics"), "", gui::OK_CANCEL, &items);
|
||||
const int res = gui::show_dialog2(*gui_, NULL, _("Statistics"), "", gui::OK_CANCEL, &items);
|
||||
std::string title;
|
||||
std::vector<std::string> items_sub;
|
||||
|
||||
|
@ -187,7 +187,7 @@ namespace events{
|
|||
}
|
||||
|
||||
if (items_sub.empty() == false)
|
||||
gui::show_dialog(*gui_, NULL, "", title, gui::OK_ONLY, &items_sub);
|
||||
gui::show_dialog2(*gui_, NULL, "", title, gui::OK_ONLY, &items_sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ namespace events{
|
|||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
selected = gui::show_dialog(*gui_,NULL,_("Unit List"),"",
|
||||
selected = gui::show_dialog2(*gui_,NULL,_("Unit List"),"",
|
||||
gui::OK_ONLY,&items,&preview_panes,
|
||||
"",NULL,0,NULL,NULL,-1,-1,NULL,NULL,"",&sorter);
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ namespace events{
|
|||
items.push_back(IMAGE_PREFIX + std::string("random-enemy.png") + COLUMN_SEPARATOR +
|
||||
IMAGE_PREFIX + "random-enemy.png");
|
||||
|
||||
gui::show_dialog(*gui_,NULL,"","",gui::CLOSE_ONLY,&items,
|
||||
gui::show_dialog2(*gui_,NULL,"","",gui::CLOSE_ONLY,&items,
|
||||
NULL,"",NULL,0,NULL,NULL,-1,-1,NULL,NULL,"",&sorter);
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ namespace events{
|
|||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
recruit_res = gui::show_dialog(*gui_,NULL,_("Recruit"),
|
||||
recruit_res = gui::show_dialog2(*gui_,NULL,_("Recruit"),
|
||||
_("Select unit:") + std::string("\n"),
|
||||
gui::OK_CANCEL,&items,&preview_panes,"",NULL,-1,NULL,NULL,-1,-1,
|
||||
NULL,NULL,"recruit_and_recall");
|
||||
|
@ -680,7 +680,7 @@ namespace events{
|
|||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
res = gui::show_dialog(*gui_,NULL,_("Recall"),
|
||||
res = gui::show_dialog2(*gui_,NULL,_("Recall"),
|
||||
_("Select unit:") + std::string("\n"),
|
||||
gui::OK_CANCEL,&options,
|
||||
&preview_panes,"",NULL,-1,
|
||||
|
@ -1072,7 +1072,7 @@ namespace events{
|
|||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
choice = gui::show_dialog(*gui_,NULL,"",dsgettext(PACKAGE "-lib","Create Unit (Debug!)"),
|
||||
choice = gui::show_dialog2(*gui_,NULL,"",dsgettext(PACKAGE "-lib","Create Unit (Debug!)"),
|
||||
gui::OK_CANCEL,&options,&preview_panes);
|
||||
}
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ void wait::join_game(bool observe)
|
|||
possible_sides);
|
||||
preview_panes.push_back(&leader_selector);
|
||||
|
||||
const int res = gui::show_dialog(disp(), NULL, "", _("Choose your side:"),
|
||||
const int res = gui::show_dialog2(disp(), NULL, "", _("Choose your side:"),
|
||||
gui::OK_CANCEL, &choices, &preview_panes);
|
||||
if(res < 0) {
|
||||
set_result(QUIT);
|
||||
|
|
|
@ -181,7 +181,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
|||
}
|
||||
|
||||
const std::string msg = leader->second.description() + " " + _("has left the game. What do you want to do?");
|
||||
action = gui::show_dialog(gui_,NULL,"",msg,gui::OK_ONLY,&options);
|
||||
action = gui::show_dialog2(gui_,NULL,"",msg,gui::OK_ONLY,&options);
|
||||
}
|
||||
|
||||
//make the player an AI, and redo this turn, in case
|
||||
|
|
|
@ -234,7 +234,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>()), advanced_selection_(-1),
|
||||
slider_label_width_(0), advanced_(disp.video(),std::vector<std::string>(),false,-1,-1,NULL,&gui::menu::slateborder_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
|
||||
|
@ -606,8 +606,7 @@ void show_preferences_dialog(display& disp, const config& game_cfg)
|
|||
std::vector<gui::preview_pane*> panes;
|
||||
panes.push_back(&dialog);
|
||||
|
||||
gui::show_dialog(disp,NULL,_("Preferences"),"",gui::CLOSE_ONLY,&items,&panes,
|
||||
"",NULL,256,NULL,NULL,-1,-1,NULL,NULL,"",NULL,&gui::menu::slateborder_style);
|
||||
gui::show_dialog2(disp,NULL,_("Preferences"),"",gui::CLOSE_ONLY,&items,&panes);
|
||||
return;
|
||||
} catch(preferences_dialog::video_mode_change_exception& e) {
|
||||
switch(e.type) {
|
||||
|
@ -676,7 +675,7 @@ bool show_video_mode_dialog(display& disp)
|
|||
options.push_back(option.str());
|
||||
}
|
||||
|
||||
const int result = gui::show_dialog(disp,NULL,"",
|
||||
const int result = gui::show_dialog2(disp,NULL,"",
|
||||
_("Choose Resolution"),
|
||||
gui::OK_CANCEL,&options);
|
||||
if(size_t(result) < resolutions.size() && resolutions[result] != current_res) {
|
||||
|
@ -738,7 +737,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 menu_(disp.video(), menu_items, false, height, -1, &sorter, &gui::menu::slateborder_style);
|
||||
menu_.sort_by(0);
|
||||
menu_.reset_selection();
|
||||
menu_.set_width(font::relative_size(400));
|
||||
|
@ -828,7 +827,7 @@ bool show_theme_dialog(display& disp)
|
|||
std::vector<std::string> options = disp.get_theme().get_known_themes();
|
||||
if(options.size()){
|
||||
std::string current_theme=_("Saved Theme Preference: ")+preferences::theme();
|
||||
action = gui::show_dialog(disp,NULL,"",current_theme,gui::OK_CANCEL,&options);
|
||||
action = gui::show_dialog2(disp,NULL,"",current_theme,gui::OK_CANCEL,&options);
|
||||
if(action >= 0){
|
||||
preferences::set_theme(options[action]);
|
||||
//it would be preferable for the new theme to take effect
|
||||
|
|
|
@ -837,6 +837,37 @@ int show_dialog(display& disp, surface image,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* show_dialog2: same as show_dialog, but uses the slateborder style
|
||||
provided as a convenience to use default parameters */
|
||||
//inline
|
||||
int show_dialog2(display &screen, surface image,
|
||||
const std::string& caption, const std::string& message,
|
||||
DIALOG_TYPE type,
|
||||
const std::vector<std::string>* menu_items,
|
||||
const std::vector<preview_pane*>* preview_panes,
|
||||
const std::string& text_widget_label,
|
||||
std::string* text_widget_text,
|
||||
const int text_widget_max_chars,
|
||||
dialog_action* action,
|
||||
std::vector<check_item>* options, int xloc, int yloc,
|
||||
const std::string* dialog_style,
|
||||
std::vector<dialog_button>* buttons,
|
||||
const std::string& help_topic,
|
||||
const menu::sorter* sorter
|
||||
)
|
||||
{
|
||||
return show_dialog(screen, image,
|
||||
caption, message,
|
||||
type, menu_items,
|
||||
preview_panes,
|
||||
text_widget_label,
|
||||
text_widget_text,
|
||||
text_widget_max_chars,
|
||||
action, options, xloc, yloc,
|
||||
dialog_style, buttons,
|
||||
help_topic, sorter, &menu::slateborder_style);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace gui {
|
||||
|
|
|
@ -140,6 +140,25 @@ int show_dialog(display &screen, surface image,
|
|||
menu::style* menu_style=NULL
|
||||
);
|
||||
|
||||
|
||||
/* show_dialog2: same as show_dialog, but uses the slateborder style
|
||||
provided as a convenience to use default parameters */
|
||||
int show_dialog2(display &screen, surface image,
|
||||
const std::string& caption, const std::string& message,
|
||||
DIALOG_TYPE type=MESSAGE,
|
||||
const std::vector<std::string>* menu_items=NULL,
|
||||
const std::vector<preview_pane*>* preview_panes=NULL,
|
||||
const std::string& text_widget_label="",
|
||||
std::string* text_widget_text=NULL,
|
||||
const int text_widget_max_chars = 256,
|
||||
dialog_action* action=NULL,
|
||||
std::vector<check_item>* options=NULL, int xloc=-1, int yloc=-1,
|
||||
const std::string* dialog_style=NULL,
|
||||
std::vector<dialog_button>* buttons=NULL,
|
||||
const std::string& help_topic="",
|
||||
const menu::sorter* sorter=NULL
|
||||
);
|
||||
|
||||
void show_error_message(display &disp, std::string const &message);
|
||||
|
||||
network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
|
||||
|
|
|
@ -76,7 +76,7 @@ void combo::process_event()
|
|||
if (!pressed())
|
||||
return;
|
||||
SDL_Rect const &loc = location();
|
||||
set_selected_internal(gui::show_dialog(*disp_, NULL, "", "", gui::MESSAGE, &items_,
|
||||
set_selected_internal(gui::show_dialog2(*disp_, NULL, "", "", gui::MESSAGE, &items_,
|
||||
NULL, "", NULL, -1, NULL, NULL, loc.x, loc.y + loc.h));
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ menu::menu(CVideo& video, const std::vector<std::string>& items,
|
|||
sorter_(sorter_obj), sortby_(-1), sortreversed_(false), highlight_heading_(-1)
|
||||
{
|
||||
style_ = (menu_style) ? menu_style : &default_style;
|
||||
style_->init();
|
||||
fill_items(items, true);
|
||||
}
|
||||
|
||||
|
@ -707,15 +708,20 @@ void menu::style::draw_row(const menu& menu_ref, const std::vector<std::string>&
|
|||
|
||||
SDL_Rect const &area = screen_area();
|
||||
SDL_Rect const &loc = menu_ref.inner_location();
|
||||
SDL_Rect minirect = rect;
|
||||
minirect.x += thickness_;
|
||||
minirect.y += thickness_;
|
||||
minirect.w -= 2*thickness_;
|
||||
minirect.h -= 2*thickness_;
|
||||
|
||||
const std::vector<int>& widths = menu_ref.column_widths();
|
||||
bool lang_rtl = current_language_rtl();
|
||||
int dir = (lang_rtl) ? -1 : 1;
|
||||
SDL_Rect column = loc;
|
||||
|
||||
int xpos = rect.x;
|
||||
int xpos = minirect.x;
|
||||
if(lang_rtl)
|
||||
xpos += rect.w;
|
||||
xpos += minirect.w;
|
||||
for(size_t i = 0; i != row.size(); ++i) {
|
||||
|
||||
if(lang_rtl)
|
||||
|
@ -736,9 +742,9 @@ void menu::style::draw_row(const menu& menu_ref, const std::vector<std::string>&
|
|||
const surface img = image::get_image(image_name,image::UNSCALED);
|
||||
const int max_width = menu_ref.max_width_ < 0 ? area.w :
|
||||
minimum<int>(menu_ref.max_width_, area.w - xpos);
|
||||
if(img != NULL && (xpos - rect.x) + img->w < max_width
|
||||
&& rect.y + img->h < area.h) {
|
||||
const size_t y = rect.y + (rect.h - img->h)/2;
|
||||
if(img != NULL && (xpos - minirect.x) + img->w < max_width
|
||||
&& minirect.y + img->h < area.h) {
|
||||
const size_t y = minirect.y + (minirect.h - img->h)/2;
|
||||
const size_t w = img->w + 5;
|
||||
const size_t x = xpos + ((lang_rtl) ? widths[i] - w : 0);
|
||||
menu_ref.video().blit_surface(x,y,img);
|
||||
|
@ -749,17 +755,17 @@ void menu::style::draw_row(const menu& menu_ref, const std::vector<std::string>&
|
|||
} else {
|
||||
column.x = xpos;
|
||||
const std::string to_show = menu_ref.max_width_ > -1 ?
|
||||
font::make_text_ellipsis(str, get_font_size(), loc.w - (xpos - rect.x)) : str;
|
||||
font::make_text_ellipsis(str, get_font_size(), loc.w - (xpos - minirect.x)) : str;
|
||||
const SDL_Rect& text_size = font::text_area(str,get_font_size());
|
||||
const size_t y = rect.y + (rect.h - text_size.h)/2;
|
||||
const size_t y = minirect.y + (minirect.h - text_size.h)/2;
|
||||
font::draw_text(&menu_ref.video(),column,get_font_size(),font::NORMAL_COLOUR,to_show,xpos,y);
|
||||
|
||||
if(type == HEADING_ROW && menu_ref.sortby_ == int(i)) {
|
||||
const surface sort_img = image::get_image(menu_ref.sortreversed_ ? "misc/sort-arrow.png" :
|
||||
"misc/sort-arrow-reverse.png", image::UNSCALED);
|
||||
if(sort_img != NULL && sort_img->w <= widths[i] && sort_img->h <= rect.h) {
|
||||
if(sort_img != NULL && sort_img->w <= widths[i] && sort_img->h <= minirect.h) {
|
||||
const size_t sort_x = xpos + widths[i] - sort_img->w;
|
||||
const size_t sort_y = rect.y + rect.h/2 - sort_img->h/2;
|
||||
const size_t sort_y = minirect.y + minirect.h/2 - sort_img->h/2;
|
||||
menu_ref.video().blit_surface(sort_x,sort_y,sort_img);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,15 +40,19 @@ public:
|
|||
public:
|
||||
style();
|
||||
|
||||
virtual void init() {}
|
||||
|
||||
virtual SDL_Rect item_size(const std::string& item) const;
|
||||
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;
|
||||
virtual size_t get_cell_padding();
|
||||
size_t get_cell_padding() const;
|
||||
size_t get_thickness() const;
|
||||
|
||||
protected:
|
||||
size_t font_size_;
|
||||
size_t cell_padding_;
|
||||
size_t thickness_; //additional cell padding for style use only
|
||||
|
||||
int normal_rgb_, selected_rgb_, heading_rgb_;
|
||||
double normal_alpha_, selected_alpha_, heading_alpha_;
|
||||
|
@ -62,15 +66,14 @@ public:
|
|||
|
||||
virtual SDL_Rect item_size(const std::string& item) const;
|
||||
virtual void draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type);
|
||||
virtual size_t get_cell_padding();
|
||||
|
||||
virtual void init() { load_images(); }
|
||||
bool load_images();
|
||||
|
||||
protected:
|
||||
size_t thickness_; //image-border width/height
|
||||
const std::string img_base_;
|
||||
|
||||
std::map<std::string,surface> img_map_;
|
||||
|
||||
private:
|
||||
bool load_image(const std::string &img_sub);
|
||||
bool initialized_;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "image.hpp"
|
||||
#include "marked-up_text.hpp"
|
||||
#include "sdl_utils.hpp"
|
||||
#include "SDL.h"
|
||||
#include "SDL_image.h"
|
||||
#include "util.hpp"
|
||||
#include "video.hpp"
|
||||
|
@ -31,48 +32,41 @@
|
|||
#include <cassert>
|
||||
#include <numeric>
|
||||
|
||||
namespace {
|
||||
//const size_t menu_font_size = font::SIZE_NORMAL;
|
||||
//const size_t menu_cell_padding = font::SIZE_NORMAL * 3/5;
|
||||
//gui::menu::style gui::menu::default_style;
|
||||
//gui::menu::imgsel_style gui::menu::slateborder_style("misc/selection");
|
||||
}
|
||||
|
||||
namespace gui {
|
||||
|
||||
//static initializations
|
||||
menu::style gui::menu::default_style;
|
||||
#ifdef WESNOTH_PATH
|
||||
menu::imgsel_style gui::menu::slateborder_style( WESNOTH_PATH "/images/misc/selection");
|
||||
#else
|
||||
menu::imgsel_style gui::menu::slateborder_style("./images/misc/selection");
|
||||
#endif
|
||||
menu::imgsel_style gui::menu::slateborder_style("misc/selection");
|
||||
|
||||
//constructors
|
||||
menu::style::style() : font_size_(font::SIZE_NORMAL), cell_padding_(font::SIZE_NORMAL * 3/5),
|
||||
menu::style::style() : font_size_(font::SIZE_NORMAL),
|
||||
cell_padding_(font::SIZE_NORMAL * 3/5), thickness_(0),
|
||||
normal_rgb_(0x000000), normal_alpha_(0.2),
|
||||
selected_rgb_(0x990000), selected_alpha_(0.6),
|
||||
heading_rgb_(0x333333), heading_alpha_(0.3)
|
||||
{}
|
||||
menu::imgsel_style::imgsel_style(const std::string &img_base) : img_base_(img_base), thickness_(3),
|
||||
menu::imgsel_style::imgsel_style(const std::string &img_base) : img_base_(img_base),
|
||||
initialized_(false), load_failed_(false)
|
||||
{}
|
||||
|
||||
size_t menu::style::get_font_size() const { return font_size_; }
|
||||
size_t menu::style::get_cell_padding() { return cell_padding_; }
|
||||
|
||||
size_t menu::style::get_cell_padding() const { return cell_padding_; }
|
||||
size_t menu::style::get_thickness() const { return thickness_; }
|
||||
|
||||
|
||||
bool menu::imgsel_style::load_image(const std::string &img_sub)
|
||||
{
|
||||
std::string path = img_base_ + "-" + img_sub + ".png";
|
||||
surface image(IMG_Load(path.c_str()));
|
||||
const surface image = image::get_image(path,image::UNSCALED);
|
||||
img_map_[img_sub] = image;
|
||||
return(!image.null());
|
||||
}
|
||||
|
||||
bool menu::imgsel_style::load_images()
|
||||
{
|
||||
if(!initialized_)
|
||||
{
|
||||
|
||||
if( load_image("border-botleft")
|
||||
&& load_image("border-botright")
|
||||
&& load_image("border-topleft")
|
||||
|
@ -82,6 +76,9 @@ bool menu::imgsel_style::load_images()
|
|||
&& load_image("border-top")
|
||||
&& load_image("border-bottom") )
|
||||
{
|
||||
thickness_ = minimum(
|
||||
img_map_["border-top"]->h,
|
||||
img_map_["border-left"]->w);
|
||||
cell_padding_ = maximum(cell_padding_, thickness_);
|
||||
|
||||
selected_rgb_ = 0x000000;
|
||||
|
@ -96,28 +93,34 @@ bool menu::imgsel_style::load_images()
|
|||
}
|
||||
else
|
||||
{
|
||||
thickness_ = 0;
|
||||
initialized_ = true;
|
||||
load_failed_ = true;
|
||||
}
|
||||
return (!load_failed_);
|
||||
}
|
||||
return (!load_failed_);
|
||||
}
|
||||
|
||||
void menu::imgsel_style::draw_row(const menu& menu_ref, const std::vector<std::string>& row, const SDL_Rect& rect, ROW_TYPE type)
|
||||
{
|
||||
if(!initialized_) load_images();
|
||||
style::draw_row(menu_ref, row, rect, type);
|
||||
if(type == SELECTED_ROW) {
|
||||
if(!load_failed_) {
|
||||
SDL_Rect item_rect = rect;
|
||||
//item_rect.x += thickness_;
|
||||
//item_rect.y += thickness_;
|
||||
//item_rect.w -= 2*thickness_;
|
||||
//item_rect.h -= 2*thickness_;
|
||||
|
||||
/* Draw border if it was succesfully loaded. */
|
||||
if(!load_failed_) {
|
||||
//draw item inside
|
||||
style::draw_row(menu_ref, row, item_rect, type);
|
||||
|
||||
if(type == SELECTED_ROW) {
|
||||
|
||||
// draw border
|
||||
surface image;
|
||||
SDL_Rect area;
|
||||
SDL_Rect clip = rect;
|
||||
area.x = rect.x;
|
||||
area.y = rect.y;
|
||||
//area.w = minimum(image->w,rect->w);
|
||||
//area.h = minimum(image->h,rect->h);
|
||||
//SDL_BlitSurface(image, 0, gdis, &area);
|
||||
|
||||
image = img_map_["border-top"];
|
||||
area.x = rect.x;
|
||||
|
@ -135,11 +138,6 @@ void menu::imgsel_style::draw_row(const menu& menu_ref, const std::vector<std::s
|
|||
area.y += image->h;
|
||||
} while( area.y < rect.y + rect.h );
|
||||
|
||||
image = img_map_["border-topleft"];
|
||||
area.x = rect.x;
|
||||
area.y = rect.y;
|
||||
menu_ref.video().blit_surface(area.x,area.y,image);
|
||||
|
||||
image = img_map_["border-right"];
|
||||
area.x = rect.x + rect.w - thickness_;
|
||||
area.y = rect.y;
|
||||
|
@ -148,11 +146,6 @@ void menu::imgsel_style::draw_row(const menu& menu_ref, const std::vector<std::s
|
|||
area.y += image->h;
|
||||
} while( area.y < rect.y + rect.h );
|
||||
|
||||
image = img_map_["border-topright"];
|
||||
area.x = rect.x + rect.w - image->w;
|
||||
area.y = rect.y;
|
||||
menu_ref.video().blit_surface(area.x,area.y,image);
|
||||
|
||||
image = img_map_["border-bottom"];
|
||||
area.x = rect.x;
|
||||
area.y = rect.y + rect.h - thickness_;
|
||||
|
@ -161,9 +154,14 @@ void menu::imgsel_style::draw_row(const menu& menu_ref, const std::vector<std::s
|
|||
area.x += image->w;
|
||||
} while( area.x < rect.x + rect.w );
|
||||
|
||||
image = img_map_["border-botright"];
|
||||
image = img_map_["border-topleft"];
|
||||
area.x = rect.x;
|
||||
area.y = rect.y;
|
||||
menu_ref.video().blit_surface(area.x,area.y,image);
|
||||
|
||||
image = img_map_["border-topright"];
|
||||
area.x = rect.x + rect.w - image->w;
|
||||
area.y = rect.y + rect.h - image->h;
|
||||
area.y = rect.y;
|
||||
menu_ref.video().blit_surface(area.x,area.y,image);
|
||||
|
||||
image = img_map_["border-botleft"];
|
||||
|
@ -171,19 +169,26 @@ void menu::imgsel_style::draw_row(const menu& menu_ref, const std::vector<std::s
|
|||
area.y = rect.y + rect.h - image->h;
|
||||
menu_ref.video().blit_surface(area.x,area.y,image);
|
||||
|
||||
image = img_map_["border-botright"];
|
||||
area.x = rect.x + rect.w - image->w;
|
||||
area.y = rect.y + rect.h - image->h;
|
||||
menu_ref.video().blit_surface(area.x,area.y,image);
|
||||
}
|
||||
} else {
|
||||
//default drawing
|
||||
style::draw_row(menu_ref, row, rect, type);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Rect menu::imgsel_style::item_size(const std::string& item) const
|
||||
{
|
||||
return style::item_size(item);
|
||||
SDL_Rect bounds = style::item_size(item);
|
||||
|
||||
bounds.w += 2 * thickness_;
|
||||
bounds.h += 2 * thickness_;
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
size_t menu::imgsel_style::get_cell_padding()
|
||||
{
|
||||
if(!initialized_) load_images();
|
||||
return cell_padding_;
|
||||
}
|
||||
|
||||
}
|
||||
} //namesapce gui
|
||||
|
|