dialogs: fix a problem with need_redraw + try to avoid dialog being a little too long on mac...

This commit is contained in:
ALONSO Laurent
2021-10-08 15:08:07 +02:00
committed by Celtic Minstrel
parent 4d0da8f6ac
commit 737eb54e3c
2 changed files with 12 additions and 7 deletions

View File

@@ -520,8 +520,13 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
if (desktop.width< ui_scale*winRect.width())
ui_scale=float(desktop.width)/winRect.width();
if ((desktop.height-30)< ui_scale*winRect.height())
ui_scale=float(desktop.height-30)/winRect.height();
int minFreeHeight=30;
#ifndef _WIN32
// Checkme, probably, not on Windows, for some reason
minFreeHeight += getMenubarHeight();
#endif
if ((desktop.height-minFreeHeight)< ui_scale*winRect.height())
ui_scale=float(desktop.height-minFreeHeight)/winRect.height();
}
int wWidth=int(ui_scale*winRect.width()), wHeight=int(ui_scale*winRect.height());
@@ -558,7 +563,7 @@ void cDialog::handle_events() {
cFramerateLimiter fps_limiter;
while(dialogNotToast) {
bool need_redraw=false; // OSNOLA
bool need_redraw=false;
while(win.pollEvent(currentEvent)) handle_one_event(currentEvent, need_redraw);
if(doAnimations && animTimer.getElapsedTime().asMilliseconds() >= 500) {
@@ -585,6 +590,7 @@ void cDialog::handle_one_event(const sf::Event& currentEvent, bool &need_redraw)
static cKey pendingKey = {true};
std::string itemHit = "";
location where;
bool prev_redraw=need_redraw;
need_redraw=true;
switch(currentEvent.type) {
case sf::Event::KeyPressed:
@@ -657,7 +663,7 @@ void cDialog::handle_one_event(const sf::Event& currentEvent, bool &need_redraw)
case kb::RControl:
case kb::LSystem:
case kb::RSystem:
need_redraw=false;
need_redraw=prev_redraw;
return;
default:
key.spec = false;
@@ -711,7 +717,7 @@ void cDialog::handle_one_event(const sf::Event& currentEvent, bool &need_redraw)
process_click(where, key.mod);
break;
default: // To silence warning of unhandled enum values
need_redraw=false;
need_redraw=prev_redraw;
return;
case sf::Event::GainedFocus:
case sf::Event::MouseMoved:

View File

@@ -139,7 +139,6 @@ void adjust_window_mode() {
winSettings.stencilBits = 1;
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
hideMenuBar();
bool firstTime = !mainPtr.isOpen();
float ui_scale = get_float_pref("UIScale", 1.0);
if(ui_scale < 0.1) ui_scale = 1.0;
float width = 605 * ui_scale, height = 430 * ui_scale;
@@ -1106,7 +1105,7 @@ static void init_trim_mask(std::unique_ptr<sf::Texture>& mask, rectangle src_rec
void draw_trim(short q,short r,short which_trim,ter_num_t ground_ter) {
/* TODO: Windows has a check for frills being enabled:
if(!frills_on || (((current_ground == 2) || (current_ground == 36)) && (PSD[SDF_COMPATIBILITY_FULL_TRIMS] == 0)))
return;
return;
*/
// which_trim
// 0 - left, 1 - right, 2 - top, 3 - bottom, 4 - tl, 5 - tr, 6 - bl, 7 - br