1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

Merge pull request #5127 from IvanSavenko/hotfix

[1.6.1] Fixes for 1.6.0 issues reported on Discord
This commit is contained in:
Ivan Savenko 2024-12-25 00:12:55 +02:00 committed by GitHub
commit 0620161287
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 115 additions and 42 deletions

View File

@ -356,6 +356,10 @@ EUpscalingFilter ScreenHandler::loadUpscalingFilter() const
return filter;
// else - autoselect
#ifdef VCMI_MOBILE
// to help with performance - only if player explicitly enabled xbrz
return EUpscalingFilter::NONE;
#else
Point outputResolution = getRenderResolution();
Point logicalResolution = getPreferredLogicalResolution();
@ -363,6 +367,14 @@ EUpscalingFilter ScreenHandler::loadUpscalingFilter() const
float scaleY = static_cast<float>(outputResolution.x) / logicalResolution.x;
float scaling = std::min(scaleX, scaleY);
if (scaling <= 1.001f)
return EUpscalingFilter::NONE; // running at original resolution or even lower than that - no need for xbrz
else
return EUpscalingFilter::XBRZ_2;
#endif
#if 0
// Old version, most optimal, but rather performance-heavy
if (scaling <= 1.001f)
return EUpscalingFilter::NONE; // running at original resolution or even lower than that - no need for xbrz
if (scaling <= 2.001f)
@ -371,6 +383,7 @@ EUpscalingFilter ScreenHandler::loadUpscalingFilter() const
return EUpscalingFilter::XBRZ_3; // resolutions below 2400p (including 1440p and 2160p / 4K)
return EUpscalingFilter::XBRZ_4; // Only for massive displays, e.g. 8K
#endif
}
void ScreenHandler::selectUpscalingFilter()

View File

@ -19,6 +19,7 @@
#include "../../lib/texts/Languages.h"
#include "../../lib/VCMIDirs.h"
#include "../../lib/filesystem/Filesystem.h"
#include "../../vcmiqt/MessageBox.h"
#include "../helper.h"
#include "../languages.h"
#include "../innoextract.h"
@ -122,7 +123,7 @@ void FirstLaunchView::on_pushButtonDataCopy_clicked()
#else
// iOS can't display modal dialogs when called directly on button press
// https://bugreports.qt.io/browse/QTBUG-98651
QTimer::singleShot(0, this, [this]{ copyHeroesData(); });
MessageBoxCustom::showDialog(this, [this]{ copyHeroesData(); });
#endif
}
@ -130,7 +131,7 @@ void FirstLaunchView::on_pushButtonGogInstall_clicked()
{
// iOS can't display modal dialogs when called directly on button press
// https://bugreports.qt.io/browse/QTBUG-98651
QTimer::singleShot(0, this, &FirstLaunchView::extractGogData);
MessageBoxCustom::showDialog(this, [this]{extractGogData();});
}
void FirstLaunchView::enterSetup()

View File

@ -19,6 +19,7 @@
#include "../../lib/filesystem/Filesystem.h"
#include "../../lib/VCMIDirs.h"
#include "../../vcmiqt/MessageBox.h"
void StartGameTab::changeEvent(QEvent *event)
{
@ -258,7 +259,7 @@ void StartGameTab::on_buttonImportFiles_clicked()
// iOS can't display modal dialogs when called directly on button press
// https://bugreports.qt.io/browse/QTBUG-98651
QTimer::singleShot(0, this, importFunctor);
MessageBoxCustom::showDialog(this, importFunctor);
}
void StartGameTab::on_buttonInstallTranslation_clicked()
@ -300,7 +301,7 @@ void StartGameTab::on_buttonHelpImportFiles_clicked()
" - VCMI configuration files (.json)\n"
);
QMessageBox::information(this, ui->buttonImportFiles->text(), message);
MessageBoxCustom::information(this, ui->buttonImportFiles->text(), message);
}
void StartGameTab::on_buttonInstallTranslationHelp_clicked()
@ -310,7 +311,7 @@ void StartGameTab::on_buttonInstallTranslationHelp_clicked()
"VCMI provides translations of the game into various languages that you can use. "
"Use this option to automatically install such translation to your language."
);
QMessageBox::information(this, ui->buttonInstallTranslation->text(), message);
MessageBoxCustom::information(this, ui->buttonInstallTranslation->text(), message);
}
void StartGameTab::on_buttonActivateTranslationHelp_clicked()
@ -320,7 +321,7 @@ void StartGameTab::on_buttonActivateTranslationHelp_clicked()
"Use this option to enable it."
);
QMessageBox::information(this, ui->buttonActivateTranslation->text(), message);
MessageBoxCustom::information(this, ui->buttonActivateTranslation->text(), message);
}
void StartGameTab::on_buttonUpdateModsHelp_clicked()
@ -332,7 +333,7 @@ void StartGameTab::on_buttonUpdateModsHelp_clicked()
"You many want to postpone mod update until you finish any of your ongoing games."
);
QMessageBox::information(this, ui->buttonUpdateMods->text(), message);
MessageBoxCustom::information(this, ui->buttonUpdateMods->text(), message);
}
void StartGameTab::on_buttonChroniclesHelp_clicked()
@ -345,7 +346,7 @@ void StartGameTab::on_buttonChroniclesHelp_clicked()
"This will generate and install mod for VCMI that contains imported chronicles"
);
QMessageBox::information(this, ui->labelChronicles->text(), message);
MessageBoxCustom::information(this, ui->labelChronicles->text(), message);
}
void StartGameTab::on_buttonMissingSoundtrackHelp_clicked()
@ -356,7 +357,7 @@ void StartGameTab::on_buttonMissingSoundtrackHelp_clicked()
"To resolve this problem, please copy missing mp3 files from Heroes III to VCMI data files directory manually "
"or reinstall VCMI and re-import Heroes III data files"
);
QMessageBox::information(this, ui->labelMissingSoundtrack->text(), message);
MessageBoxCustom::information(this, ui->labelMissingSoundtrack->text(), message);
}
void StartGameTab::on_buttonMissingVideoHelp_clicked()
@ -367,7 +368,7 @@ void StartGameTab::on_buttonMissingVideoHelp_clicked()
"To resolve this problem, please copy VIDEO.VID file from Heroes III to VCMI data files directory manually "
"or reinstall VCMI and re-import Heroes III data files"
);
QMessageBox::information(this, ui->labelMissingVideo->text(), message);
MessageBoxCustom::information(this, ui->labelMissingVideo->text(), message);
}
void StartGameTab::on_buttonMissingFilesHelp_clicked()
@ -378,7 +379,7 @@ void StartGameTab::on_buttonMissingFilesHelp_clicked()
"To resolve this problem, please reinstall game and reimport data files using supported version of Heroes III. "
"VCMI requires Heroes III: Shadow of Death or Complete Edition to run, which you can get (for example) from gog.com"
);
QMessageBox::information(this, ui->labelMissingFiles->text(), message);
MessageBoxCustom::information(this, ui->labelMissingFiles->text(), message);
}
void StartGameTab::on_buttonMissingCampaignsHelp_clicked()
@ -389,7 +390,7 @@ void StartGameTab::on_buttonMissingCampaignsHelp_clicked()
"To resolve this problem, please copy missing data files from Heroes III to VCMI data files directory manually "
"or reinstall VCMI and re-import Heroes III data files"
);
QMessageBox::information(this, ui->labelMissingCampaigns->text(), message);
MessageBoxCustom::information(this, ui->labelMissingCampaigns->text(), message);
}
void StartGameTab::on_buttonPresetExport_clicked()
@ -414,21 +415,24 @@ void StartGameTab::on_buttonPresetImport_clicked()
void StartGameTab::on_buttonPresetNew_clicked()
{
bool ok;
QString presetName = QInputDialog::getText(
this,
ui->buttonPresetNew->text(),
tr("Enter preset name:"),
QLineEdit::Normal,
QString(),
&ok);
const auto & functor = [this](){
bool ok;
QString presetName = QInputDialog::getText(
this,
ui->buttonPresetNew->text(),
tr("Enter preset name:"),
QLineEdit::Normal,
QString(),
&ok);
if (ok && !presetName.isEmpty())
{
getMainWindow()->getModView()->createNewPreset(presetName);
getMainWindow()->getModView()->activatePreset(presetName);
refreshPresets();
}
if (ok && !presetName.isEmpty())
{
getMainWindow()->getModView()->createNewPreset(presetName);
getMainWindow()->getModView()->activatePreset(presetName);
refreshPresets();
}
};
MessageBoxCustom::showDialog(this, functor);
}
void StartGameTab::on_buttonPresetDelete_clicked()
@ -452,21 +456,23 @@ void StartGameTab::on_comboBoxModPresets_currentTextChanged(const QString &prese
void StartGameTab::on_buttonPresetRename_clicked()
{
QString currentName = getMainWindow()->getModView()->getActivePreset();
const auto & functor = [this](){
QString currentName = getMainWindow()->getModView()->getActivePreset();
bool ok;
QString newName = QInputDialog::getText(
this,
ui->buttonPresetNew->text(),
tr("Rename preset '%1' to:").arg(currentName),
QLineEdit::Normal,
currentName,
&ok);
bool ok;
QString newName = QInputDialog::getText(
this,
ui->buttonPresetNew->text(),
tr("Rename preset '%1' to:").arg(currentName),
QLineEdit::Normal,
currentName,
&ok);
if (ok && !newName.isEmpty())
{
getMainWindow()->getModView()->renamePreset(currentName, newName);
refreshPresets();
}
if (ok && !newName.isEmpty())
{
getMainWindow()->getModView()->renamePreset(currentName, newName);
refreshPresets();
}
};
MessageBoxCustom::showDialog(this, functor);
}

View File

@ -299,8 +299,10 @@ CConsoleHandler::CConsoleHandler():
GetConsoleScreenBufferInfo(handleErr, &csbi);
defErrColor = csbi.wAttributes;
#ifdef NDEBUG
#ifndef VCMI_ANDROID
SetUnhandledExceptionFilter(onUnhandledException);
#endif
#endif
#else
defColor = "\x1b[0m";
#endif

View File

@ -8,6 +8,7 @@ set(vcmiqt_SRCS
set(vcmiqt_HEADERS
StdInc.h
MessageBox.h
jsonutils.h
launcherdirs.h
convpathqstring.h
@ -32,7 +33,7 @@ if(WIN32)
)
endif()
target_link_libraries(vcmiqt vcmi Qt${QT_VERSION_MAJOR}::Core)
target_link_libraries(vcmiqt vcmi Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets)
target_include_directories(vcmiqt PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}

50
vcmiqt/MessageBox.h Normal file
View File

@ -0,0 +1,50 @@
/*
* MessageBox.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "vcmiqt.h"
#include <QMessageBox>
#include <QTimer>
namespace MessageBoxCustom
{
#ifdef VCMI_IOS
// iOS can't display modal dialogs when called directly on button press
// https://bugreports.qt.io/browse/QTBUG-98651
template<typename Functor>
inline void showDialog(QWidget *parent, const Functor & f)
{
QTimer::singleShot(0, parent, f);
}
inline void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
{
QTimer::singleShot(0, parent, [=](){
QMessageBox::information(parent, title, text, buttons, defaultButton);
});
}
#else
template<typename Functor>
inline void showDialog(QWidget *parent, const Functor & f)
{
f();
}
inline void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
{
QMessageBox::information(parent, title, text, buttons, defaultButton);
}
#endif
}