Skip to content

Commit

Permalink
Display a description of the mechanics of right-clicking on devices w…
Browse files Browse the repository at this point in the history
…ith touch input (#9346)
  • Loading branch information
oleg-derevenetz authored Dec 20, 2024
1 parent bd18290 commit 60b976b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions docs/README_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ your Heroes 2 installation directory.

## Controls
To simulate a right-click to get info on various items, you need to first touch and keep touching on the item of interest
and then touch anywhere else on the screen. You can then remove your first finger from the screen and keep viewing the info
on the item.
and then touch anywhere else on the screen. While holding the second finger, you can remove the first one from the screen
and keep viewing the information on the item.

By default normal adventure map scrolling on the borders of the screen is disabled. To pane the viewing area around you
need to press anywhere on the adventure map and slide around to change where you are viewing.
Expand Down
6 changes: 6 additions & 0 deletions src/engine/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#pragma GCC diagnostic ignored "-Wswitch-default"
#endif

#include <SDL_touch.h>
#include <SDL_version.h>

#if defined( ANDROID )
Expand Down Expand Up @@ -273,6 +274,11 @@ bool System::isHandheldDevice()
#endif
}

bool System::isTouchInputAvailable()
{
return SDL_GetNumTouchDevices() > 0;
}

bool System::isVirtualKeyboardSupported()
{
#if defined( ANDROID ) || defined( TARGET_PS_VITA ) || defined( TARGET_NINTENDO_SWITCH )
Expand Down
3 changes: 3 additions & 0 deletions src/engine/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace System
{
bool isHandheldDevice();

// Returns true if the target platform supports touch input, otherwise returns false.
bool isTouchInputAvailable();

bool isVirtualKeyboardSupported();

// Returns true if target platform supports shell-level globbing (Unix-like platforms with POSIX-compatible shells).
Expand Down
5 changes: 3 additions & 2 deletions src/fheroes2/dialog/dialog_resolution.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***************************************************************************
* fheroes2: https://github.com/ihhub/fheroes2 *
* Copyright (C) 2020 - 2022 *
* Copyright (C) 2020 - 2024 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
Expand All @@ -22,5 +22,6 @@

namespace Dialog
{
bool SelectResolution(); // returns true if a new resolution is set
// Returns true if the screen resolution has been changed, otherwise returns false.
bool SelectResolution();
}
41 changes: 17 additions & 24 deletions src/fheroes2/game/game_mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <cstdint>
#include <ostream>
#include <string>
#include <utility>
#include <vector>

#include "agg_image.h"
Expand Down Expand Up @@ -58,7 +59,6 @@
#include "ui_button.h"
#include "ui_dialog.h"
#include "ui_language.h"
#include "ui_text.h"
#include "ui_tool.h"

namespace
Expand Down Expand Up @@ -232,40 +232,33 @@ fheroes2::GameMode Game::MainMenu( const bool isFirstGameRun )

fheroes2::Display & display = fheroes2::Display::instance();

// image background
fheroes2::drawMainMenuScreen();

if ( isFirstGameRun ) {
// Fade in Main Menu image before showing messages. This also resets the "need fade" state to have no fade-in after these messages.
fheroes2::validateFadeInAndRender();

fheroes2::selectLanguage( fheroes2::getSupportedLanguages(), fheroes2::getLanguageFromAbbreviation( conf.getGameLanguage() ), true );

if ( System::isHandheldDevice() ) {
// Handheld devices should use the minimal game's resolution. Users on handheld devices aren't asked to choose resolution.
fheroes2::showStandardTextMessage( _( "Greetings!" ), _( "Welcome to Heroes of Might and Magic II powered by fheroes2 engine!" ), Dialog::OK );
}
else {
fheroes2::showStandardTextMessage(
_( "Greetings!" ),
_( "Welcome to Heroes of Might and Magic II powered by the fheroes2 engine!\nBefore starting the game, please select a game resolution." ), Dialog::OK );
const bool isResolutionChanged = Dialog::SelectResolution();
if ( isResolutionChanged ) {
fheroes2::drawMainMenuScreen();
{
std::string body( _( "Welcome to Heroes of Might and Magic II powered by fheroes2 engine!" ) );

if ( System::isTouchInputAvailable() ) {
body += _(
"\n\nTo simulate a right-click with a touch to get info on various items, you need to first touch and keep touching on the item of interest and then touch anywhere else on the screen. While holding the second finger, you can remove the first one from the screen and keep viewing the information on the item." );
}
}

fheroes2::Text header( _( "Please Remember" ), fheroes2::FontType::normalYellow() );
// Handheld devices should use the minimal game's resolution. Users on handheld devices aren't asked to choose resolution.
if ( !System::isHandheldDevice() ) {
body += _( "\n\nBefore starting the game, please select a game resolution." );
}

fheroes2::MultiFontText body;
body.add( { _( "You can always change the language, resolution and settings of the game by clicking on the " ), fheroes2::FontType::normalWhite() } );
body.add( { _( "door" ), fheroes2::FontType::normalYellow() } );
body.add( { _( " on the left side of the Main Menu, or with the " ), fheroes2::FontType::normalWhite() } );
body.add( { _( "CONFIG" ), fheroes2::FontType::normalYellow() } );
body.add( { _( " button from the " ), fheroes2::FontType::normalWhite() } );
body.add( { _( "NEW GAME" ), fheroes2::FontType::normalYellow() } );
body.add( { _( " menu. \n\nEnjoy the game!" ), fheroes2::FontType::normalWhite() } );
fheroes2::showStandardTextMessage( _( "Greetings!" ), std::move( body ), Dialog::OK );

fheroes2::showMessage( header, body, Dialog::OK );
if ( !System::isHandheldDevice() && Dialog::SelectResolution() ) {
fheroes2::drawMainMenuScreen();
}
}

conf.resetFirstGameRun();
conf.Save( Settings::configFileName );
Expand Down

0 comments on commit 60b976b

Please sign in to comment.