Fix risk of bad initial fullscreen mode

This commit is contained in:
Lorenzooone 2024-05-24 22:01:47 +02:00
parent ad56c2814e
commit 573050b312
4 changed files with 15 additions and 6 deletions

View File

@ -24,6 +24,7 @@
#define SIMPLE_RESET_DATA_INDEX -2
#define CREATE_NEW_FILE_INDEX -3
std::string get_version_string();
std::string LayoutNameGenerator(int index);
std::string LayoutPathGenerator(int index);
std::string load_layout_name(int index, bool &success);

View File

@ -63,7 +63,7 @@ void ResolutionMenu::prepare(float menu_scaling_factor, int view_size_x, int vie
continue;
int mode_index = start + i;
sf::VideoMode mode = this->get_resolution(mode_index);
if((mode.width == curr_desk_mode->width) && (mode.height == curr_desk_mode->height) && (mode.bitsPerPixel == curr_desk_mode->bitsPerPixel))
if((mode.width == curr_desk_mode->width) && (mode.height == curr_desk_mode->height))
this->labels[index]->setText("<" + this->get_string_option(mode_index, DEFAULT_ACTION) + ">");
else
this->labels[index]->setText(this->get_string_option(mode_index, DEFAULT_ACTION));

View File

@ -2120,11 +2120,7 @@ void WindowScreen::create_window(bool re_prepare_size) {
}
}
if(!success) {
std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
if(modes.size() > 0)
this->curr_desk_mode = modes[0];
else
this->curr_desk_mode = sf::VideoMode::getDesktopMode();
this->curr_desk_mode = sf::VideoMode::getDesktopMode();
}
this->m_window_width = curr_desk_mode.width;
this->m_window_height = curr_desk_mode.height;

View File

@ -9,6 +9,14 @@
#include <queue>
#include <cmath>
#define xstr(a) str(a)
#define str(a) #a
#define APP_VERSION_MAJOR 0
#define APP_VERSION_MINOR 0
#define APP_VERSION_REVISION 0
#define APP_VERSION_LETTER M
bool is_big_endian(void) {
union {
uint32_t i;
@ -18,6 +26,10 @@ bool is_big_endian(void) {
return value.c[0] == 1;
}
std::string get_version_string() {
return std::to_string(APP_VERSION_MAJOR) + "." + std::to_string(APP_VERSION_MINOR) + "." + std::to_string(APP_VERSION_REVISION) + xstr(APP_VERSION_LETTER);
}
std::string get_float_str_decimals(float value, int decimals) {
float approx_factor = pow(0.1, decimals) * (0.5);
int int_part = (int)(value + approx_factor);