UI scaling: try to also scale the mini_map

This commit is contained in:
Laurent Alonso(fr)
2020-06-11 14:52:18 +02:00
committed by Celtic Minstrel
parent 5896188094
commit 35e1599f71
2 changed files with 11 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
#include "strdlog.hpp"
#include "3choice.hpp"
#include "message.hpp"
#include "prefs.hpp"
#include <array>
#include <boost/lexical_cast.hpp>
#include "winutil.hpp"
@@ -680,9 +681,17 @@ short get_num_of_items(short max_num) {
}
void init_mini_map() {
mini_map.create(sf::VideoMode(296,277), "Map", sf::Style::Titlebar | sf::Style::Close);
float ui_scale = get_float_pref("UIScale", 1.0);
if (ui_scale < 0.1) ui_scale = 1.0;
if (mini_map.isOpen()) mini_map.close();
mini_map.create(sf::VideoMode(ui_scale*296,ui_scale*277), "Map", sf::Style::Titlebar | sf::Style::Close);
mini_map.setPosition(sf::Vector2i(52,62));
sf::View view;
view.reset(sf::FloatRect(0, 0, ui_scale*296,ui_scale*277));
view.setViewport(sf::FloatRect(0, 0, ui_scale, ui_scale));
mini_map.setView(view);
mini_map.setVisible(false);
map_visible=false;
setWindowFloating(mini_map, true);
makeFrontWindow(mainPtr);

View File

@@ -287,6 +287,7 @@ void handle_events() {
if(changed_display_mode) {
changed_display_mode = false;
adjust_window_mode();
init_mini_map();
}
// Still no idea what this does. It's possible that this does not work at all.