Fix #3435 with a warning for too small resolutions

This commit is contained in:
Alayan 2018-10-12 15:17:34 +02:00
parent 52c0ddd718
commit 2e6b7fd8ac
4 changed files with 24 additions and 5 deletions

View File

@ -882,7 +882,10 @@ void IrrDriver::changeResolution(const int w, const int h,
// is actually called from the gui, i.e. the event loop, i.e. while the
// old device is active - so we can't delete this device (which we must
// do in applyResolutionSettings
m_resolution_changing = RES_CHANGE_YES;
if (w < 1024 || h < 720)
m_resolution_changing = RES_CHANGE_YES_WARN;
else
m_resolution_changing = RES_CHANGE_YES;
} // changeResolution
//-----------------------------------------------------------------------------
@ -1859,7 +1862,9 @@ void IrrDriver::update(float dt)
{
applyResolutionSettings();
if(m_resolution_changing==RES_CHANGE_YES)
new ConfirmResolutionDialog();
new ConfirmResolutionDialog(false);
else if(m_resolution_changing==RES_CHANGE_YES_WARN)
new ConfirmResolutionDialog(true);
m_resolution_changing = RES_CHANGE_NONE;
}

View File

@ -114,10 +114,12 @@ private:
/** Flag to indicate if a resolution change is pending (which will be
* acted upon in the next update). None means no change, yes means
* change to new resolution and trigger confirmation dialog.
* Yes_warn means that the new resolution is unsupported and that
* the confirmation dialog needs an additional warning message.
* Same indicates a change of the resolution (back to the original
* one), but no confirmation dialog. */
enum {RES_CHANGE_NONE, RES_CHANGE_YES,
RES_CHANGE_SAME} m_resolution_changing;
RES_CHANGE_SAME, RES_CHANGE_YES_WARN} m_resolution_changing;
public:

View File

@ -31,10 +31,13 @@ using namespace irr::core;
// ------------------------------------------------------------------------------------------------------
ConfirmResolutionDialog::ConfirmResolutionDialog() : ModalDialog(0.7f, 0.7f)
ConfirmResolutionDialog::ConfirmResolutionDialog(bool unsupported_res) : ModalDialog(0.7f, 0.7f)
{
loadFromFile("confirm_resolution_dialog.stkgui");
m_remaining_time = 10.99f;
m_unsupported_resolution = unsupported_res;
if (m_unsupported_resolution)
m_remaining_time += 10.0f;
updateMessage();
}
@ -83,6 +86,13 @@ void ConfirmResolutionDialog::updateMessage()
"Confirm resolution within %i seconds",
(int)m_remaining_time);
if (m_unsupported_resolution)
{
msg += L"\n\n";
msg += _("Resolutions smaller than 1024x768 or 1280x720 are unsupported. "
"Some parts of the UI may not work correctly.");
}
LabelWidget* countdown_message = getWidget<LabelWidget>("title");
countdown_message->setText( msg.c_str(), false );
}

View File

@ -32,12 +32,14 @@ class ConfirmResolutionDialog : public GUIEngine::ModalDialog
private:
/** number of seconds left before resolution is considered unplayable */
float m_remaining_time;
bool m_unsupported_resolution;
/** updates countdown message */
void updateMessage();
public:
ConfirmResolutionDialog();
ConfirmResolutionDialog(bool unsupported_res);
void onEnterPressedInternal() OVERRIDE;
GUIEngine::EventPropagation processEvent(const std::string& eventSource) OVERRIDE;