Fixed problem with resizing window while dialog is displayed
This commit is contained in:
parent
175282aac9
commit
f3e6bf6d19
5 changed files with 44 additions and 6 deletions
|
@ -23,7 +23,8 @@
|
|||
|
||||
void show_intro(display& screen, config& data)
|
||||
{
|
||||
update_locker lock(screen);
|
||||
//stop the screen being resized while we're in this function
|
||||
const resize_lock stop_resizing;
|
||||
|
||||
CKey key;
|
||||
|
||||
|
@ -131,11 +132,13 @@ void show_intro(display& screen, config& data)
|
|||
|
||||
void show_map_scene(display& screen, config& data)
|
||||
{
|
||||
//stop the screen being resized while we're in this function
|
||||
const resize_lock stop_resizing;
|
||||
|
||||
//clear the screen
|
||||
gui::draw_solid_tinted_rectangle(0,0,screen.x()-1,screen.y()-1,0,0,0,1.0,
|
||||
screen.video().getSurface());
|
||||
|
||||
update_locker lock(screen);
|
||||
|
||||
std::vector<config*>& sequence = data.children["bigmap"];
|
||||
if(sequence.empty()) {
|
||||
|
|
|
@ -436,6 +436,8 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
if(disp.update_locked())
|
||||
return -1;
|
||||
|
||||
const resize_lock prevent_resizing;
|
||||
|
||||
const std::vector<std::string>& menu_items =
|
||||
(menu_items_ptr == NULL) ? std::vector<std::string>() : *menu_items_ptr;
|
||||
const std::vector<unit>& units =
|
||||
|
@ -805,6 +807,8 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
|
||||
TITLE_RESULT show_title(display& screen)
|
||||
{
|
||||
const resize_lock prevent_resizing;
|
||||
|
||||
SDL_Surface* const title_surface = screen.getImage("title.png",
|
||||
display::UNSCALED);
|
||||
|
||||
|
|
|
@ -212,6 +212,8 @@ void set_grid(bool ison)
|
|||
|
||||
void show_preferences_dialog(display& disp)
|
||||
{
|
||||
const resize_lock prevent_resizing;
|
||||
|
||||
const int xpos = disp.x()/2 - 300;
|
||||
const int ypos = disp.y()/2 - 200;
|
||||
const int width = 600;
|
||||
|
@ -366,6 +368,8 @@ void show_preferences_dialog(display& disp)
|
|||
|
||||
void show_video_mode_dialog(display& disp)
|
||||
{
|
||||
const resize_lock prevent_resizing;
|
||||
|
||||
std::vector<std::pair<int,int> > resolutions;
|
||||
std::vector<std::string> options;
|
||||
|
||||
|
|
|
@ -337,21 +337,41 @@ int CVideo::drawText(int x, int y, int pixel, int bg, const char* text, int sz)
|
|||
|
||||
bool CVideo::isFullScreen() const { return fullScreen; }
|
||||
|
||||
namespace {
|
||||
int disallow_resize = 0;
|
||||
}
|
||||
|
||||
resize_lock::resize_lock()
|
||||
{
|
||||
++disallow_resize;
|
||||
}
|
||||
|
||||
resize_lock::~resize_lock()
|
||||
{
|
||||
--disallow_resize;
|
||||
}
|
||||
|
||||
void pump_events()
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
|
||||
static std::pair<int,int> resize_dimensions(0,0);
|
||||
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_VIDEORESIZE: {
|
||||
const SDL_ResizeEvent* const resize
|
||||
= reinterpret_cast<SDL_ResizeEvent*>(&event);
|
||||
size_t newx = resize->w > 1024 ? resize->w : 1024;
|
||||
size_t newy = resize->h > 768 ? resize->h : 768;
|
||||
|
||||
preferences::set_resolution(std::pair<int,int>(newx,newy));
|
||||
resize_dimensions.first = resize->w > 1024 ? resize->w : 1024;
|
||||
resize_dimensions.second = resize->h > 768 ? resize->h : 768;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resize_dimensions.first > 0 && disallow_resize == 0) {
|
||||
preferences::set_resolution(resize_dimensions);
|
||||
resize_dimensions.first = 0;
|
||||
resize_dimensions.second = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,13 @@ class CVideo {
|
|||
char text_[256*8];
|
||||
};
|
||||
|
||||
void allow_resizing(bool);
|
||||
|
||||
struct resize_lock {
|
||||
resize_lock();
|
||||
~resize_lock();
|
||||
};
|
||||
|
||||
void pump_events();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue