1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #3191 from Laserlicht/touch-introduction

Touch introduction
This commit is contained in:
Ivan Savenko 2023-11-20 14:05:47 +02:00 committed by GitHub
commit 07990644b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 209 additions and 4 deletions

View File

@ -150,7 +150,7 @@ jobs:
run: |
find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
-o -path ./osx -prune -o -type f \
-not -name '*.png' -and -not -name '*.vcxproj*' -and -not -name '*.props' -and -not -name '*.wav' -and -not -name '*.ico' -and -not -name '*.bat' -print0 | \
-not -name '*.png' -and -not -name '*.vcxproj*' -and -not -name '*.props' -and -not -name '*.wav' -and -not -name '*.webm' -and -not -name '*.ico' -and -not -name '*.bat' -print0 | \
{ ! xargs -0 grep -l -z -P '\r\n'; }
- name: Validate JSON

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -174,6 +174,15 @@
"vcmi.battleResultsWindow.applyResultsLabel" : "Apply battle result",
"vcmi.tutorialWindow.title" : "Touchscreen Introduction",
"vcmi.tutorialWindow.decription.RightClick" : "Touch and hold the element on which you want to right-click. Touch the free area to close.",
"vcmi.tutorialWindow.decription.MapPanning" : "Touch and drag with one finger to move the map.",
"vcmi.tutorialWindow.decription.MapZooming" : "Pinch with two fingers to change the map zoom.",
"vcmi.tutorialWindow.decription.RadialWheel" : "Swiping opens radial wheel for various actions, such as creature/hero management and town ordering.",
"vcmi.tutorialWindow.decription.BattleDirection" : "To attack from a particular direction, swipe in the direction from which the attack is to be made.",
"vcmi.tutorialWindow.decription.BattleDirectionAbort" : "The attack direction gesture can be cancelled if the finger is far enough away.",
"vcmi.tutorialWindow.decription.AbortSpell" : "Touch and hold to cancel a spell.",
"vcmi.otherOptions.availableCreaturesAsDwellingLabel.hover" : "Show Available Creatures",
"vcmi.otherOptions.availableCreaturesAsDwellingLabel.help" : "{Show Available Creatures}\n\nShow the number of creatures available to purchase instead of their growth in town summary (bottom-left corner of town screen).",
"vcmi.otherOptions.creatureGrowthAsDwellingLabel.hover" : "Show Weekly Growth of Creatures",

View File

@ -214,6 +214,10 @@
"SOUNDS/":
[
{"type" : "dir", "path" : "/Sounds"}
],
"VIDEO/":
[
{"type" : "dir", "path" : "/Video"}
]
}
}

View File

@ -130,6 +130,7 @@ set(client_SRCS
windows/CQuestLog.cpp
windows/CSpellWindow.cpp
windows/CTradeWindow.cpp
windows/CTutorialWindow.cpp
windows/CWindowObject.cpp
windows/CreaturePurchaseCard.cpp
windows/GUIClasses.cpp
@ -301,6 +302,7 @@ set(client_HEADERS
windows/CQuestLog.h
windows/CSpellWindow.h
windows/CTradeWindow.h
windows/CTutorialWindow.h
windows/CWindowObject.h
windows/CreaturePurchaseCard.h
windows/GUIClasses.h

View File

@ -57,6 +57,7 @@
#include "windows/CQuestLog.h"
#include "windows/CSpellWindow.h"
#include "windows/CTradeWindow.h"
#include "windows/CTutorialWindow.h"
#include "windows/GUIClasses.h"
#include "windows/InfoWindows.h"
@ -275,6 +276,8 @@ void CPlayerInterface::gamePause(bool pause)
void CPlayerInterface::yourTurn(QueryID queryID)
{
CTutorialWindow::openWindowFirstTime(TutorialMode::TOUCH_ADVENTUREMAP);
EVENT_HANDLER_CALLED_BY_CLIENT;
{
LOCPLINT = this;

View File

@ -41,8 +41,11 @@ extern "C" {
static int lodRead(void* opaque, uint8_t* buf, int size)
{
auto video = reinterpret_cast<CVideoPlayer *>(opaque);
int bytes = static_cast<int>(video->data->read(buf, size));
if(bytes == 0)
return AVERROR_EOF;
return static_cast<int>(video->data->read(buf, size));
return bytes;
}
static si64 lodSeek(void * opaque, si64 pos, int whence)
@ -59,8 +62,11 @@ static si64 lodSeek(void * opaque, si64 pos, int whence)
static int lodReadAudio(void* opaque, uint8_t* buf, int size)
{
auto video = reinterpret_cast<CVideoPlayer *>(opaque);
int bytes = static_cast<int>(video->dataAudio->read(buf, size));
if(bytes == 0)
return AVERROR_EOF;
return static_cast<int>(video->dataAudio->read(buf, size));
return bytes;
}
static si64 lodSeekAudio(void * opaque, si64 pos, int whence)

View File

@ -29,6 +29,7 @@
#include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h"
#include "../gui/WindowHandler.h"
#include "../windows/CTutorialWindow.h"
#include "../render/Canvas.h"
#include "../adventureMap/AdventureMapInterface.h"
@ -148,6 +149,8 @@ void BattleInterface::openingEnd()
tacticNextStack(nullptr);
activateStack();
battleOpeningDelayActive = false;
CTutorialWindow::openWindowFirstTime(TutorialMode::TOUCH_BATTLE);
}
BattleInterface::~BattleInterface()

View File

@ -0,0 +1,123 @@
/*
* CTutorialWindow.cpp, 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
*
*/
#include "StdInc.h"
#include "CTutorialWindow.h"
#include "../eventsSDL/InputHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CondSh.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../CPlayerInterface.h"
#include "../CGameInfo.h"
#include "../CVideoHandler.h"
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h"
#include "../widgets/Images.h"
#include "../widgets/Buttons.h"
#include "../widgets/TextControls.h"
#include "../render/Canvas.h"
CTutorialWindow::CTutorialWindow(const TutorialMode & m)
: CWindowObject(BORDERED, ImagePath::builtin("DIBOXBCK")), mode { m }, page { 0 }
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
pos = Rect(pos.x, pos.y, 380, 400); //video: 320x240
background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, pos.w, pos.h));
updateShadow();
center();
addUsedEvents(LCLICK);
if(mode == TutorialMode::TOUCH_ADVENTUREMAP) videos = { "RightClick", "MapPanning", "MapZooming", "RadialWheel" };
else if(mode == TutorialMode::TOUCH_BATTLE) videos = { "BattleDirection", "BattleDirectionAbort", "AbortSpell" };
labelTitle = std::make_shared<CLabel>(190, 15, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->translate("vcmi.tutorialWindow.title"));
labelInformation = std::make_shared<CMultiLineLabel>(Rect(5, 40, 370, 60), EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "");
buttonOk = std::make_shared<CButton>(Point(159, 367), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CTutorialWindow::exit, this), EShortcut::GLOBAL_ACCEPT); //62x28
buttonLeft = std::make_shared<CButton>(Point(5, 217), AnimationPath::builtin("HSBTNS3"), CButton::tooltip(), std::bind(&CTutorialWindow::previous, this), EShortcut::MOVE_LEFT); //22x46
buttonRight = std::make_shared<CButton>(Point(352, 217), AnimationPath::builtin("HSBTNS5"), CButton::tooltip(), std::bind(&CTutorialWindow::next, this), EShortcut::MOVE_RIGHT); //22x46
setContent();
}
void CTutorialWindow::setContent()
{
video = "tutorial/" + videos[page];
buttonLeft->block(page<1);
buttonRight->block(page>videos.size() - 2);
labelInformation->setText(CGI->generaltexth->translate("vcmi.tutorialWindow.decription." + videos[page]));
}
void CTutorialWindow::openWindowFirstTime(const TutorialMode & m)
{
if(GH.input().hasTouchInputDevice() && !persistentStorage["gui"]["tutorialCompleted" + std::to_string(m)].Bool())
{
if(LOCPLINT)
LOCPLINT->showingDialog->set(true);
GH.windows().pushWindow(std::make_shared<CTutorialWindow>(m));
Settings s = persistentStorage.write["gui"]["tutorialCompleted" + std::to_string(m)];
s->Bool() = true;
}
}
void CTutorialWindow::exit()
{
if(LOCPLINT)
LOCPLINT->showingDialog->setn(false);
close();
}
void CTutorialWindow::next()
{
page++;
setContent();
deactivate();
activate();
}
void CTutorialWindow::previous()
{
page--;
setContent();
deactivate();
activate();
}
void CTutorialWindow::show(Canvas & to)
{
CCS->videoh->update(pos.x + 30, pos.y + 120, to.getInternalSurface(), true, false,
[&]()
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin(video));
});
CIntObject::show(to);
}
void CTutorialWindow::activate()
{
CCS->videoh->open(VideoPath::builtin(video));
CIntObject::activate();
}
void CTutorialWindow::deactivate()
{
CCS->videoh->close();
}

View File

@ -0,0 +1,54 @@
/*
* CTutorialWindow.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 "../windows/CWindowObject.h"
class CFilledTexture;
class CButton;
class CLabel;
class CMultiLineLabel;
enum TutorialMode
{
TOUCH_ADVENTUREMAP,
TOUCH_BATTLE
};
class CTutorialWindow : public CWindowObject
{
TutorialMode mode;
std::shared_ptr<CFilledTexture> background;
std::shared_ptr<CButton> buttonOk;
std::shared_ptr<CButton> buttonLeft;
std::shared_ptr<CButton> buttonRight;
std::shared_ptr<CLabel> labelTitle;
std::shared_ptr<CMultiLineLabel> labelInformation;
std::string video;
std::vector<std::string> videos;
int page;
void exit();
void next();
void previous();
void setContent();
public:
CTutorialWindow(const TutorialMode & m);
static void openWindowFirstTime(const TutorialMode & m);
void show(Canvas & to) override;
void activate() override;
void deactivate() override;
};

View File

@ -119,6 +119,7 @@ EResType EResTypeHelper::getTypeFromExtension(std::string extension)
{".MJPG", EResType::VIDEO},
{".MPG", EResType::VIDEO},
{".AVI", EResType::VIDEO},
{".WEBM", EResType::VIDEO},
{".ZIP", EResType::ARCHIVE_ZIP},
{".LOD", EResType::ARCHIVE_LOD},
{".PAC", EResType::ARCHIVE_LOD},

View File

@ -28,7 +28,7 @@ class JsonSerializeFormat;
* Font: .fnt
* Image: .bmp, .jpg, .pcx, .png, .tga
* Sound: .wav .82m
* Video: .smk, .bik .mjpg .mpg
* Video: .smk, .bik .mjpg .mpg .webm
* Music: .mp3, .ogg
* Archive: .lod, .snd, .vid .pac .zip
* Palette: .pal