Fixed the window not always refreshing on resizing

Made default savegame names be ellipsed when they are too long
This commit is contained in:
Philippe Plantier 2004-10-27 20:42:37 +00:00
parent 7311794fb4
commit 0bd2381c63
6 changed files with 24 additions and 24 deletions

View file

@ -42,8 +42,8 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data, dialo
std::cerr << "entered multiplayer lobby...\n";
const preferences::display_manager disp_manager(&disp);
const hotkey::basic_handler key_handler(&disp);
const video_change_detector disp_change_detector(disp.video());
const tooltips::manager tooltips_manager(disp);
disp.video().modeChanged(); // resets modeChanged value
CKey key;
@ -378,7 +378,7 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data, dialo
}
}
if(disp_change_detector.changed()) {
if(disp.video().modeChanged()) {
return CONTINUE;
}

View file

@ -1382,7 +1382,10 @@ bool is_illegal_file_char(char c)
void turn_info::save_game(const std::string& message, gui::DIALOG_TYPE dialog_type)
{
std::stringstream stream;
stream << state_of_game_.label << " " << _("Turn")
const std::string ellipsed_name = font::make_text_ellipsis(state_of_game_.label,
font::SIZE_NORMAL, 200);
stream << ellipsed_name << " " << _("Turn")
<< " " << status_.turn();
std::string label = stream.str();
if(dialog_type == gui::NULL_DIALOG && message != "") {

View file

@ -45,8 +45,6 @@ void fade_logo(display& screen, int xpos, int ypos)
LOG_DP << "logo size: " << logo->w << "," << logo->h << "\n";
const video_change_detector disp_change_detector(screen.video());
for(int x = 0; x != logo->w; ++x) {
SDL_Rect srcrect = {x,0,1,logo->h};
SDL_Rect dstrect = {xpos+x,ypos,1,logo->h};
@ -69,7 +67,7 @@ void fade_logo(display& screen, int xpos, int ypos)
SDL_Delay(10);
events::pump();
if(disp_change_detector.changed()) {
if(screen.video().modeChanged()) {
faded_in = true;
fade_logo(screen,xpos,ypos);
return;
@ -132,12 +130,11 @@ TITLE_RESULT show_title(display& screen, int* ntip)
const preferences::display_manager disp_manager(&screen);
const hotkey::basic_handler key_handler(&screen);
const video_change_detector disp_change_detector(screen.video());
const font::floating_label_context label_manager;
const surface title_surface_unscaled(image::get_image(game_config::game_title,image::UNSCALED));
const surface title_surface(scale_surface(title_surface_unscaled,screen.x(),screen.y()));
screen.video().modeChanged(); // resets modeChanged value
if(title_surface == NULL) {
ERR_DP << "Could not find title image\n";
@ -282,7 +279,7 @@ TITLE_RESULT show_title(display& screen, int* ntip)
//if the resolution has changed due to the user resizing the screen,
//or from changing between windowed and fullscreen
if(disp_change_detector.changed()) {
if(screen.video().modeChanged()) {
return TITLE_CONTINUE;
}

View file

@ -249,6 +249,7 @@ int CVideo::modePossible( int x, int y, int bits_per_pixel, int flags )
int CVideo::setMode( int x, int y, int bits_per_pixel, int flags )
{
update_rects.clear();
mode_changed_ = true;
flags = get_flags(flags);
const int res = SDL_VideoModeOK( x, y, bits_per_pixel, flags );
@ -265,6 +266,13 @@ int CVideo::setMode( int x, int y, int bits_per_pixel, int flags )
} else return 0;
}
bool CVideo::modeChanged()
{
bool ret = mode_changed_;
mode_changed_ = false;
return ret;
}
int CVideo::setGamma(float gamma)
{
SDL_SetGamma(gamma, gamma, gamma);

View file

@ -40,6 +40,9 @@ class CVideo {
int modePossible( int x, int y, int bits_per_pixel, int flags );
int setMode( int x, int y, int bits_per_pixel, int flags );
//did the mode change, since the last call to the modeChanged() method?
bool modeChanged();
int setGamma(float gamma);
//functions to get the dimensions of the current video-mode
@ -74,23 +77,12 @@ class CVideo {
private:
bool mode_changed_;
int bpp; // Store real bits per pixel
//if there is no display at all, but we 'fake' it for clients
bool fake_screen;
};
//a structure which will detect if the resolution or fullscreen mode has changed
struct video_change_detector {
video_change_detector(CVideo& video) : video_(video), full_(video.isFullScreen()), x_(video.getx()), y_(video.gety())
{}
bool changed() const { return full_ != video_.isFullScreen() || x_ != video_.getx() || y_ != video_.gety(); }
private:
CVideo& video_;
bool full_;
int x_, y_;
};
#endif

View file

@ -78,8 +78,8 @@ bool combo::process(int x, int y, bool button)
if(button_.process(x,y,button)) {
const SDL_Rect rect = button_.location();
set_selected(gui::show_dialog(*display_,NULL,"","",
gui::MESSAGE,&items_,NULL,"",NULL,-1,NULL,NULL,
rect.x,rect.y+rect.h));
gui::MESSAGE,&items_,NULL,"",NULL,-1,NULL,NULL,
rect.x,rect.y+rect.h));
button_.draw();