Warning fixes:
not complete, but I stopped pulling the thread before the whole project unravelled 8) (1) team and player numbers should be unsigned. (2) sizes of gui elements should usually be unsigned. This probably introduced some bugs.
This commit is contained in:
parent
42303e0a17
commit
e2feadfc86
30 changed files with 79 additions and 79 deletions
|
@ -87,7 +87,7 @@ namespace dfool {
|
|||
std::string id=(**o)["id"];
|
||||
std::string number=(**o)["number"];
|
||||
std::string priority=(**o)["priority"];
|
||||
int num=atoi(number.c_str());
|
||||
unsigned int num=atoi(number.c_str());
|
||||
int prior=atoi(priority.c_str());
|
||||
bool pers=(id.size()>0);
|
||||
LOG_STREAM(info, ai)<<"dfool order("<<(pers?id:"")<<"): "<<num<<(num==1?" unit":" units")<<" with priority "<<prior<<std::endl;
|
||||
|
|
|
@ -257,7 +257,7 @@ public:
|
|||
std::string ref_at(const int x, const int y);
|
||||
|
||||
protected:
|
||||
virtual void scroll(int pos);
|
||||
virtual void scroll(unsigned int pos);
|
||||
virtual void set_inner_location(const SDL_Rect& rect);
|
||||
|
||||
private:
|
||||
|
@ -2139,7 +2139,7 @@ void help_text_area::draw_contents()
|
|||
update_rect(loc);
|
||||
}
|
||||
|
||||
void help_text_area::scroll(int)
|
||||
void help_text_area::scroll(unsigned int)
|
||||
{
|
||||
// Nothing will be done on the actual scroll event. The scroll
|
||||
// position is checked when drawing instead and things drawn
|
||||
|
|
|
@ -36,7 +36,8 @@ public:
|
|||
//in dynamically because they're special. It's asserted that there will
|
||||
//be corresponding entries for these types of terrain in the terrain
|
||||
//configuration file.
|
||||
enum { FOGGED = '~', VOID_TERRAIN = ' ', KEEP = 'K', CASTLE = 'C', VILLAGE = 't', FOREST = 'f' };
|
||||
static const TERRAIN VOID_TERRAIN = ' ';
|
||||
enum { FOGGED = '~', KEEP = 'K', CASTLE = 'C', VILLAGE = 't', FOREST = 'f' };
|
||||
|
||||
//the name of the terrain is the terrain itself, the underlying terrain
|
||||
//is the name of the terrain for game-logic purposes. I.e. if the terrain
|
||||
|
|
|
@ -314,7 +314,7 @@ std::string word_wrap_text(const std::string& unwrapped_text, int font_size, int
|
|||
if(start_of_line) {
|
||||
line_width = 0;
|
||||
format_string = "";
|
||||
while(ch != end && *ch < 0x100U && is_format_char(*ch)) {
|
||||
while(ch != end && *ch < (wchar_t)0x100 && is_format_char(*ch)) {
|
||||
format_string.append(ch.substr().first, ch.substr().second);
|
||||
++ch;
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ namespace events{
|
|||
start["playing_team"] = buf.str();
|
||||
|
||||
for(std::vector<team>::const_iterator t = teams.begin(); t != teams.end(); ++t) {
|
||||
const int side_num = t - teams.begin() + 1;
|
||||
const unsigned int side_num = t - teams.begin() + 1;
|
||||
|
||||
config& side = start.add_child("side");
|
||||
t->write(side);
|
||||
|
|
|
@ -200,11 +200,11 @@ gamemap::location mouse_handler::current_unit_attacks_from(const gamemap::locati
|
|||
|
||||
if(current_paths_.routes.count(adj[n])) {
|
||||
static const size_t NDIRECTIONS = gamemap::location::NDIRECTIONS;
|
||||
int difference = abs(int(preferred - n));
|
||||
unsigned int difference = abs(int(preferred - n));
|
||||
if(difference > NDIRECTIONS/2) {
|
||||
difference = NDIRECTIONS - difference;
|
||||
}
|
||||
int second_difference = abs(int(second_preferred - n));
|
||||
unsigned int second_difference = abs(int(second_preferred - n));
|
||||
if(second_difference > NDIRECTIONS/2) {
|
||||
second_difference = NDIRECTIONS - second_difference;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
bool browse_;
|
||||
mutable unit_map visible_units_;
|
||||
int path_turns_;
|
||||
int team_num_;
|
||||
unsigned int team_num_;
|
||||
undo_list undo_stack_;
|
||||
undo_list redo_stack_;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
|
|||
//user maps
|
||||
get_files_in_dir(get_user_data_dir() + "/editor/maps",&user_maps_,NULL,FILE_NAME_ONLY);
|
||||
|
||||
for(int i = 0; i < user_maps_.size(); i++)
|
||||
for(unsigned int i = 0; i < user_maps_.size(); i++)
|
||||
map_options_.push_back(user_maps_[i]);
|
||||
|
||||
//standard maps
|
||||
|
|
|
@ -39,11 +39,11 @@ namespace mp {
|
|||
gamebrowser::gamebrowser(CVideo& video) : scrollarea(video),
|
||||
gold_icon_locator_("misc/gold.png"),
|
||||
xp_icon_locator_("misc/units.png"),
|
||||
time_limit_icon_locator_("misc/sand-clock.png"),
|
||||
vision_icon_locator_("misc/invisible.png"),
|
||||
observer_icon_locator_("misc/eye.png"), header_height_(20),
|
||||
time_limit_icon_locator_("misc/sand-clock.png"),
|
||||
observer_icon_locator_("misc/eye.png"),
|
||||
item_height_(100), margin_(5), h_padding_(5),
|
||||
v_padding_(5), selected_(0), visible_range_(std::pair<size_t,size_t>(0,0)),
|
||||
v_padding_(5), header_height_(20), selected_(0), visible_range_(std::pair<size_t,size_t>(0,0)),
|
||||
double_clicked_(false), ignore_next_doubleclick_(false), last_was_doubleclick_(false)
|
||||
{
|
||||
}
|
||||
|
@ -56,9 +56,9 @@ void gamebrowser::set_inner_location(const SDL_Rect& rect)
|
|||
scroll(get_position());
|
||||
}
|
||||
|
||||
void gamebrowser::scroll(int pos)
|
||||
void gamebrowser::scroll(unsigned int pos)
|
||||
{
|
||||
if(pos >= 0 && pos < games_.size()) {
|
||||
if(pos < games_.size()) {
|
||||
visible_range_.first = pos;
|
||||
visible_range_.second = minimum<size_t>(pos + inner_location().h / item_height_, games_.size());
|
||||
set_dirty();
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
bool use_map_settings;
|
||||
};
|
||||
gamebrowser(CVideo& video);
|
||||
void scroll(int pos);
|
||||
void scroll(unsigned int pos);
|
||||
void handle_event(const SDL_Event& event);
|
||||
void set_inner_location(const SDL_Rect& rect);
|
||||
void set_item_height(unsigned int height);
|
||||
|
|
|
@ -726,7 +726,7 @@ void queue_data(const config& cfg, connection connection_num)
|
|||
send_data(cfg,connection_num,0,QUEUE_ONLY);
|
||||
}
|
||||
|
||||
void process_send_queue(connection connection_num, size_t max_size)
|
||||
void process_send_queue(connection, size_t)
|
||||
{
|
||||
check_error();
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ SOCKET_STATE receive_buf(TCPsocket sock, std::vector<char>& buf)
|
|||
return SOCKET_READY;
|
||||
}
|
||||
|
||||
int process_queue(void* data)
|
||||
int process_queue(void*)
|
||||
{
|
||||
LOG_NW << "thread started...\n";
|
||||
for(;;) {
|
||||
|
|
|
@ -292,7 +292,7 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
gui.add_overlay(gamemap::location(**overlay),(**overlay)["image"], (**overlay)["halo"]);
|
||||
}
|
||||
|
||||
int turn = 1, player_number = 0;
|
||||
unsigned int turn = 1, player_number = 0;
|
||||
|
||||
turn_info::floating_textbox textbox_info;
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ struct end_level_exception {
|
|||
};
|
||||
|
||||
struct end_turn_exception {
|
||||
end_turn_exception(int r = 0): redo(r) {}
|
||||
int redo;
|
||||
end_turn_exception(unsigned int r = 0): redo(r) {}
|
||||
unsigned int redo;
|
||||
};
|
||||
|
||||
LEVEL_RESULT play_level(const game_data& gameinfo, const config& terrain_config,
|
||||
|
|
|
@ -67,7 +67,7 @@ command_disabler::~command_disabler()
|
|||
void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
||||
const gamestatus& status, const config& terrain_config,
|
||||
const config& level, CKey& key, display& gui, gamemap& map,
|
||||
std::vector<team>& teams, int team_num,
|
||||
std::vector<team>& teams, unsigned int team_num,
|
||||
std::map<gamemap::location,unit>& units,
|
||||
turn_info::floating_textbox& textbox,
|
||||
replay_network_sender& network_sender)
|
||||
|
@ -191,7 +191,7 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
turn_info::turn_info(const game_data& gameinfo, game_state& state_of_game,
|
||||
const gamestatus& status, const config& terrain_config,
|
||||
const config& level, CKey& key, display& gui, gamemap& map,
|
||||
std::vector<team>& teams, int team_num, unit_map& units,
|
||||
std::vector<team>& teams, unsigned int team_num, unit_map& units,
|
||||
TURN_MODE mode, floating_textbox& textbox,
|
||||
replay_network_sender& replay_sender)
|
||||
: gameinfo_(gameinfo), state_of_game_(state_of_game), status_(status),
|
||||
|
@ -1781,7 +1781,7 @@ void turn_info::write_game_snapshot(config& start) const
|
|||
start["playing_team"] = buf.str();
|
||||
|
||||
for(std::vector<team>::const_iterator t = teams_.begin(); t != teams_.end(); ++t) {
|
||||
const int side_num = t - teams_.begin() + 1;
|
||||
const unsigned int side_num = t - teams_.begin() + 1;
|
||||
|
||||
config& side = start.add_child("side");
|
||||
t->write(side);
|
||||
|
@ -2578,7 +2578,7 @@ void turn_info::do_command(const std::string& str)
|
|||
image::flush_cache();
|
||||
gui_.redraw_everything();
|
||||
} else if (cmd == "droid") {
|
||||
const int side = lexical_cast_default<int>(data, 1);
|
||||
const unsigned int side = lexical_cast_default<unsigned int>(data, 1);
|
||||
const size_t index = static_cast<size_t>(side - 1);
|
||||
if (index >= teams_.size() || teams_[index].is_network()) {
|
||||
//do nothing
|
||||
|
@ -2604,9 +2604,9 @@ void turn_info::do_command(const std::string& str)
|
|||
if(j != data.end()) {
|
||||
const std::string side(data.begin(),j);
|
||||
const std::string player(j+1,data.end());
|
||||
int side_num;
|
||||
unsigned int side_num;
|
||||
try {
|
||||
side_num = lexical_cast<int, std::string>(side);
|
||||
side_num = lexical_cast<unsigned int, std::string>(side);
|
||||
} catch(bad_lexical_cast&) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
turn_info(const game_data& gameinfo, game_state& state_of_game,
|
||||
const gamestatus& status, const config& terrain_config,
|
||||
const config& level, CKey& key, display& gui, gamemap& map,
|
||||
std::vector<team>& teams, int team_num, unit_map& units,
|
||||
std::vector<team>& teams, unsigned int team_num, unit_map& units,
|
||||
TURN_MODE mode, floating_textbox& textbox,
|
||||
replay_network_sender& network_sender);
|
||||
|
||||
|
@ -205,7 +205,7 @@ private:
|
|||
display& gui_;
|
||||
gamemap& map_;
|
||||
std::vector<team>& teams_;
|
||||
int team_num_;
|
||||
unsigned int team_num_;
|
||||
unit_map& units_;
|
||||
|
||||
const unit_map& visible_units() const;
|
||||
|
@ -252,9 +252,9 @@ private:
|
|||
|
||||
void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
||||
const gamestatus& status, const config& terrain_config,
|
||||
const config& level,
|
||||
const config& level,
|
||||
CKey& key, display& gui, gamemap& map,
|
||||
std::vector<team>& teams, int team_num,
|
||||
std::vector<team>& teams, unsigned int team_num,
|
||||
std::map<gamemap::location,unit>& units,
|
||||
turn_info::floating_textbox& textbox,
|
||||
replay_network_sender& network_sender);
|
||||
|
|
|
@ -228,12 +228,12 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
|
|||
hotkeys_button_(disp.video(), _("Hotkeys")),
|
||||
gamma_button_(disp.video(), _("Adjust Gamma"), gui::button::TYPE_CHECK),
|
||||
flip_time_button_(disp.video(), _("Reverse Time Graphics"), gui::button::TYPE_CHECK),
|
||||
chat_timestamp_button_(disp.video(), _("Chat Timestamping"), gui::button::TYPE_CHECK),
|
||||
advanced_button_(disp.video(), "", gui::button::TYPE_CHECK),
|
||||
sound_button_(disp.video(), _("Sound effects"), gui::button::TYPE_CHECK),
|
||||
music_button_(disp.video(), _("Music"), gui::button::TYPE_CHECK),
|
||||
advanced_button_(disp.video(), "", gui::button::TYPE_CHECK),
|
||||
music_label_(disp.video(), _("Music Volume:")), sound_label_(disp.video(), _("SFX Volume:")), chat_lines_label_(disp.video(), ""),
|
||||
scroll_label_(disp.video(), _("Scroll Speed:")), gamma_label_(disp.video(), _("Gamma:")),
|
||||
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),
|
||||
tab_(GENERAL_TAB), disp_(disp), game_cfg_(game_cfg)
|
||||
{
|
||||
|
@ -737,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, 0, &sorter);
|
||||
menu_.sort_by(0);
|
||||
menu_.reset_selection();
|
||||
menu_.set_width(font::relative_size(400));
|
||||
|
|
|
@ -456,14 +456,13 @@ std::string wstring_to_string(const wide_string &src)
|
|||
{
|
||||
wchar_t ch;
|
||||
wide_string::const_iterator i;
|
||||
int j;
|
||||
Uint32 bitmask;
|
||||
std::string ret;
|
||||
|
||||
try {
|
||||
|
||||
for(i = src.begin(); i != src.end(); ++i) {
|
||||
int count;
|
||||
unsigned int count;
|
||||
ch = *i;
|
||||
|
||||
/* Determine the bytes required */
|
||||
|
@ -472,8 +471,8 @@ std::string wstring_to_string(const wide_string &src)
|
|||
count++;
|
||||
|
||||
bitmask = 0x800;
|
||||
for(j = 0; j < 5; ++j) {
|
||||
if(ch >= bitmask)
|
||||
for(unsigned int j = 0; j < 5; ++j) {
|
||||
if(ch >= (wchar_t)bitmask)
|
||||
count++;
|
||||
bitmask <<= 5;
|
||||
}
|
||||
|
@ -484,10 +483,10 @@ std::string wstring_to_string(const wide_string &src)
|
|||
if(count == 1) {
|
||||
push_back(ret,ch);
|
||||
} else {
|
||||
for(j = count-1; j >= 0; --j) {
|
||||
for(int j = (int)count-1; j >= 0; --j) {
|
||||
unsigned char c = (ch >> (6*j)) & 0x3f;
|
||||
c |= 0x80;
|
||||
if(j == count-1)
|
||||
if(j == (int)count-1)
|
||||
c |= 0xff << (8 - count);
|
||||
push_back(ret,c);
|
||||
}
|
||||
|
|
|
@ -375,11 +375,11 @@ int show_dialog(display& disp, surface image,
|
|||
}
|
||||
|
||||
#ifdef USE_TINY_GUI
|
||||
const int max_menu_width = 150;
|
||||
const unsigned int max_menu_width = 150;
|
||||
#else
|
||||
const int max_menu_width = -1;
|
||||
const unsigned int max_menu_width = 0;
|
||||
#endif
|
||||
menu menu_(screen,menu_items,type == MESSAGE,-1,max_menu_width,sorter);
|
||||
menu menu_(screen,menu_items,type == MESSAGE,0,max_menu_width,sorter);
|
||||
|
||||
menu_.set_numeric_keypress_selection(use_textbox == false);
|
||||
|
||||
|
|
|
@ -53,14 +53,13 @@ class theme
|
|||
enum ANCHORING { FIXED, TOP_ANCHORED, PROPORTIONAL, BOTTOM_ANCHORED };
|
||||
|
||||
private:
|
||||
std::string id_;
|
||||
SDL_Rect loc_;
|
||||
mutable SDL_Rect relative_loc_;
|
||||
mutable SDL_Rect last_screen_;
|
||||
|
||||
ANCHORING xanchor_, yanchor_;
|
||||
|
||||
std::string id_;
|
||||
|
||||
static ANCHORING read_anchor(const std::string& str);
|
||||
};
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ bool unit::matches_filter(const config& cfg) const
|
|||
}
|
||||
}
|
||||
|
||||
if(side.empty() == false && this->side() != atoi(side.c_str()))
|
||||
if(side.empty() == false && this->side() != (unsigned)atoi(side.c_str()))
|
||||
{
|
||||
if(std::find(side.begin(),side.end(),',') != side.end()) {
|
||||
const std::vector<std::string>& vals = utils::split(side);
|
||||
|
|
|
@ -151,7 +151,7 @@ bool menu::basic_sorter::less(int column, const item& row1, const item& row2) co
|
|||
}
|
||||
|
||||
menu::menu(CVideo& video, const std::vector<std::string>& items,
|
||||
bool click_selects, int max_height, int max_width,
|
||||
bool click_selects, unsigned int max_height, unsigned int max_width,
|
||||
const sorter* sorter_obj)
|
||||
: scrollarea(video),
|
||||
max_height_(max_height), max_width_(max_width), max_items_(-1), item_height_(-1),
|
||||
|
@ -299,7 +299,7 @@ void menu::update_size()
|
|||
i != i_end; ++i)
|
||||
h += get_item_rect(i).h;
|
||||
h = maximum(h, height());
|
||||
if (max_height_ > 0 && h > max_height_)
|
||||
if (max_height_ != 0 && h > max_height_)
|
||||
h = max_height_;
|
||||
|
||||
std::vector<int> const &widths = column_widths();
|
||||
|
@ -307,7 +307,7 @@ void menu::update_size()
|
|||
if (items_.size() > max_items_onscreen())
|
||||
w += scrollbar_width();
|
||||
w = maximum(w, width());
|
||||
if (max_width_ > 0 && w > max_width_)
|
||||
if (max_width_ != 0 && w > max_width_)
|
||||
w = max_width_;
|
||||
|
||||
update_scrollbar_grip_height();
|
||||
|
@ -408,7 +408,7 @@ void menu::set_items(const std::vector<std::string>& items, bool strip_spaces, b
|
|||
set_dirty();
|
||||
}
|
||||
|
||||
void menu::set_max_height(const int new_max_height)
|
||||
void menu::set_max_height(const unsigned int new_max_height)
|
||||
{
|
||||
max_height_ = new_max_height;
|
||||
itemRects_.clear();
|
||||
|
@ -416,7 +416,7 @@ void menu::set_max_height(const int new_max_height)
|
|||
update_size();
|
||||
}
|
||||
|
||||
void menu::set_max_width(const int new_max_width)
|
||||
void menu::set_max_width(const unsigned int new_max_width)
|
||||
{
|
||||
max_width_ = new_max_width;
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ size_t menu::max_items_onscreen() const
|
|||
return size_t(max_items_);
|
||||
}
|
||||
|
||||
const size_t max_height = (max_height_ == -1 ? (video().gety()*66)/100 : max_height_) - heading_height();
|
||||
const size_t max_height = (max_height_ ? max_height_ : (video().gety()*66)/100) - heading_height();
|
||||
std::vector<int> heights;
|
||||
size_t n;
|
||||
for(n = 0; n != items_.size(); ++n) {
|
||||
|
@ -624,7 +624,7 @@ void menu::set_numeric_keypress_selection(bool value)
|
|||
num_selects_ = value;
|
||||
}
|
||||
|
||||
void menu::scroll(int)
|
||||
void menu::scroll(unsigned int)
|
||||
{
|
||||
itemRects_.clear();
|
||||
set_dirty();
|
||||
|
@ -773,8 +773,8 @@ void menu::draw_row(const std::vector<std::string>& row, const SDL_Rect& rect, R
|
|||
if (!str.empty() && str[0] == IMAGE_PREFIX) {
|
||||
const std::string image_name(str.begin()+1,str.end());
|
||||
const surface img = image::get_image(image_name,image::UNSCALED);
|
||||
const int max_width = max_width_ < 0 ? area.w :
|
||||
minimum<int>(max_width_, area.w - xpos);
|
||||
const int max_width = max_width_ ? minimum<int>(max_width_, area.w - xpos) : area.w;
|
||||
|
||||
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;
|
||||
|
@ -787,7 +787,7 @@ void menu::draw_row(const std::vector<std::string>& row, const SDL_Rect& rect, R
|
|||
}
|
||||
} else {
|
||||
column.x = xpos;
|
||||
const std::string to_show = max_width_ > -1 ?
|
||||
const std::string to_show = max_width_ ?
|
||||
font::make_text_ellipsis(str, menu_font_size, loc.w - (xpos - rect.x)) : str;
|
||||
const SDL_Rect& text_size = font::text_area(str,menu_font_size);
|
||||
const size_t y = rect.y + (rect.h - text_size.h)/2;
|
||||
|
@ -840,7 +840,7 @@ void menu::draw()
|
|||
draw_row(heading_,heading_rect,HEADING_ROW);
|
||||
update_rect(heading_rect);
|
||||
} else if(*i >= 0 && *i < int(item_pos_.size())) {
|
||||
const int pos = item_pos_[*i];
|
||||
const unsigned int pos = item_pos_[*i];
|
||||
const SDL_Rect& rect = get_item_rect(*i);
|
||||
bg_restore(rect);
|
||||
draw_row(items_[pos].fields,rect,pos == selected_ ? SELECTED_ROW : NORMAL_ROW);
|
||||
|
@ -913,7 +913,7 @@ int menu::hit_heading(int x, int y) const
|
|||
{
|
||||
const size_t height = heading_height();
|
||||
const SDL_Rect& loc = inner_location();
|
||||
if(y >= loc.y && y < loc.y + height) {
|
||||
if(y >= loc.y && (size_t)y < loc.y + height) {
|
||||
return hit_column(x,y);
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -928,7 +928,7 @@ SDL_Rect menu::get_item_rect(int item) const
|
|||
SDL_Rect menu::get_item_rect_internal(size_t item) const
|
||||
{
|
||||
const SDL_Rect empty_rect = {0,0,0,0};
|
||||
int first_item_on_screen = get_position();
|
||||
unsigned int first_item_on_screen = get_position();
|
||||
if (item < first_item_on_screen ||
|
||||
size_t(item) >= first_item_on_screen + max_items_onscreen()) {
|
||||
return empty_rect;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
};
|
||||
|
||||
menu(CVideo& video, const std::vector<std::string>& items,
|
||||
bool click_selects=false, int max_height=-1, int max_width=-1,
|
||||
bool click_selects=false, unsigned int max_height=0, unsigned int max_width=0,
|
||||
const sorter* sorter_obj=NULL);
|
||||
|
||||
int selection() const;
|
||||
|
@ -103,8 +103,8 @@ public:
|
|||
/// Set a new max height for this menu. Note that this does not take
|
||||
/// effect immediately, only after certain operations that clear
|
||||
/// everything, such as set_items().
|
||||
void set_max_height(const int new_max_height);
|
||||
void set_max_width(const int new_max_width);
|
||||
void set_max_height(const unsigned int new_max_height);
|
||||
void set_max_width(const unsigned int new_max_width);
|
||||
|
||||
size_t nitems() const { return items_.size(); }
|
||||
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
void set_click_selects(bool value);
|
||||
void set_numeric_keypress_selection(bool value);
|
||||
|
||||
void scroll(int pos);
|
||||
void scroll(unsigned int pos);
|
||||
|
||||
void sort_by(int column);
|
||||
|
||||
|
@ -130,7 +130,7 @@ private:
|
|||
|
||||
size_t heading_height() const;
|
||||
|
||||
int max_height_, max_width_;
|
||||
unsigned int max_height_, max_width_;
|
||||
mutable int max_items_, item_height_;
|
||||
|
||||
void adjust_viewport_to_selection();
|
||||
|
|
|
@ -35,7 +35,7 @@ protected:
|
|||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
virtual void process_event();
|
||||
virtual void scroll(int pos) = 0;
|
||||
virtual void scroll(unsigned int pos) = 0;
|
||||
virtual void set_inner_location(SDL_Rect const &rect) = 0;
|
||||
|
||||
SDL_Rect inner_location() const;
|
||||
|
|
|
@ -86,7 +86,7 @@ unsigned scrollbar::get_max_position() const
|
|||
|
||||
void scrollbar::set_position(unsigned pos)
|
||||
{
|
||||
if (int(pos) > full_height_ - grip_height_)
|
||||
if (pos > full_height_ - grip_height_)
|
||||
pos = full_height_ - grip_height_;
|
||||
if (pos == grip_position_)
|
||||
return;
|
||||
|
@ -98,9 +98,9 @@ void scrollbar::set_position(unsigned pos)
|
|||
|
||||
void scrollbar::adjust_position(unsigned pos)
|
||||
{
|
||||
if (int(pos) < grip_position_)
|
||||
if (pos < grip_position_)
|
||||
set_position(pos);
|
||||
else if (int(pos) >= grip_position_ + grip_height_)
|
||||
else if (pos >= grip_position_ + grip_height_)
|
||||
set_position(pos - (grip_height_ - 1));
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ void scrollbar::move_position(int dep)
|
|||
|
||||
void scrollbar::set_shown_size(unsigned h)
|
||||
{
|
||||
if (int(h) > full_height_)
|
||||
if (h > full_height_)
|
||||
h = full_height_;
|
||||
if (h == grip_height_)
|
||||
return;
|
||||
|
@ -309,7 +309,7 @@ void scrollbar::handle_event(const SDL_Event& event)
|
|||
new_state = on_grip ? ACTIVE : NORMAL;
|
||||
} else if (state_ == DRAGGED && groove.h != grip.h) {
|
||||
int y_dep = e.y - grip.y - mousey_on_grip_;
|
||||
int dep = y_dep * (full_height_ - grip_height_) / (int)(groove.h - grip.h);
|
||||
int dep = y_dep * int(full_height_ - grip_height_) / (int)(groove.h - grip.h);
|
||||
move_position(dep);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -87,7 +87,8 @@ private:
|
|||
|
||||
int minimum_grip_height_, mousey_on_grip_;
|
||||
// Relative data
|
||||
int grip_position_, old_position_, grip_height_, full_height_, scroll_rate_;
|
||||
unsigned int grip_position_, grip_height_, old_position_, full_height_;
|
||||
int scroll_rate_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ void scrollpane::draw()
|
|||
//draws the scrollpane background
|
||||
}
|
||||
|
||||
void scrollpane::scroll(int pos)
|
||||
void scrollpane::scroll(unsigned int pos)
|
||||
{
|
||||
if (pos == content_pos_.y)
|
||||
if ((int)pos == content_pos_.y)
|
||||
return;
|
||||
|
||||
content_pos_.y = pos;
|
||||
|
|
|
@ -59,7 +59,7 @@ protected:
|
|||
//virtual void process_event();
|
||||
virtual void draw();
|
||||
virtual void set_inner_location(SDL_Rect const &rect);
|
||||
virtual void scroll(int pos);
|
||||
virtual void scroll(unsigned int pos);
|
||||
|
||||
private:
|
||||
void update_widget_positions();
|
||||
|
|
|
@ -234,7 +234,7 @@ void textbox::set_location(const SDL_Rect& rect)
|
|||
set_shown_size(location().h);
|
||||
}
|
||||
|
||||
void textbox::scroll(int pos)
|
||||
void textbox::scroll(unsigned int pos)
|
||||
{
|
||||
yscroll_ = pos;
|
||||
set_dirty(true);
|
||||
|
@ -388,7 +388,7 @@ void textbox::handle_event(const SDL_Event& event)
|
|||
int pos = 0;
|
||||
int distance = x;
|
||||
|
||||
for(int i = 1; i < int(char_x_.size()); ++i) {
|
||||
for(unsigned int i = 1; i < char_x_.size(); ++i) {
|
||||
if(yscroll_ + y < char_y_[i]) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
protected:
|
||||
virtual void draw_contents();
|
||||
virtual void set_inner_location(SDL_Rect const &);
|
||||
virtual void scroll(int pos);
|
||||
virtual void scroll(unsigned int pos);
|
||||
|
||||
private:
|
||||
size_t max_size_;
|
||||
|
|
Loading…
Add table
Reference in a new issue