1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

add help text

This commit is contained in:
Laserlicht 2024-07-29 00:54:58 +02:00 committed by GitHub
parent 2e2d8f8833
commit 6adc49b814
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 2 deletions

View File

@ -74,7 +74,10 @@
"vcmi.lobby.backToLobby" : "Return to lobby",
"vcmi.lobby.author" : "Author",
"vcmi.lobby.handicap" : "Handicap",
"vcmi.lobby.handicap.resource" : "Gives players appropriate resources to start with in addition to the normal starting resources. Negative values are allowed, but are limited to 0 in total (the player never starts with negative resources).",
"vcmi.lobby.handicap.income" : "Changes the player's various incomes by the percentage. Mines still give at least 1 resource per mine.",
"vcmi.lobby.handicap.growth" : "Changes the growth rate of creatures in the towns owned by the player. At least 1 is still generated per creature.",
"vcmi.lobby.login.title" : "VCMI Online Lobby",
"vcmi.lobby.login.username" : "Username:",
"vcmi.lobby.login.connecting" : "Connecting...",

View File

@ -74,6 +74,9 @@
"vcmi.lobby.backToLobby" : "Zur Lobby zurückkehren",
"vcmi.lobby.author" : "Author",
"vcmi.lobby.handicap" : "Handicap",
"vcmi.lobby.handicap.resource" : "Gibt den Spielern entsprechende Ressourcen zum Start zusätzlich zu den normalen Startressourcen. Negative Werte sind erlaubt, werden aber insgesamt auf 0 begrenzt (der Spieler beginnt nie mit negativen Ressourcen).",
"vcmi.lobby.handicap.income" : "Verändert die verschiedenen Einkommen des Spielers um den Prozentsatz. Minen geben aber weiterhin mindestens 1 Ressource pro Mine.",
"vcmi.lobby.handicap.growth" : "Verändert die Wachstumsrate der Kreaturen in den Städten, die der Spieler besitzt. Pro Kreatur wird weiterhin mindestens 1 erzeugt.",
"vcmi.lobby.login.title" : "VCMI Online Lobby",
"vcmi.lobby.login.username" : "Benutzername:",

View File

@ -849,6 +849,14 @@ OptionsTab::HandicapWindow::HandicapWindow()
tmp = tmp.substr(0, isIncome || isGrowth ? 3 : 5);
textinputs[player][resource]->setText(tmp.length() == 0 ? "0" : (negative ? "-" : "") + std::to_string(stoi(tmp)));
});
textinputs[player][resource]->setPopupCallback([isIncome, isGrowth](){
if(isIncome)
CRClickPopup::createAndPush(CGI->generaltexth->translate("vcmi.lobby.handicap.income"));
else if(isGrowth)
CRClickPopup::createAndPush(CGI->generaltexth->translate("vcmi.lobby.handicap.growth"));
else
CRClickPopup::createAndPush(CGI->generaltexth->translate("vcmi.lobby.handicap.resource"));
});
if(isIncome || isGrowth)
labels.push_back(std::make_shared<CLabel>(area.topRight().x, area.center().y, FONT_SMALL, ETextAlignment::CENTERRIGHT, Colors::WHITE, "%"));
}

View File

@ -30,7 +30,7 @@ CTextInput::CTextInput(const Rect & Pos)
pos.h = Pos.h;
pos.w = Pos.w;
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
addUsedEvents(LCLICK | SHOW_POPUP | KEYBOARD | TEXTINPUT);
}
void CTextInput::createLabel(bool giveFocusToInput)
@ -106,6 +106,11 @@ void CTextInput::setCallback(const TextEditedCallback & cb)
onTextEdited = cb;
}
void CTextInput::setPopupCallback(const std::function<void()> & cb)
{
callbackPopup = cb;
}
void CTextInput::setFilterFilename()
{
assert(!onTextFiltering);
@ -122,6 +127,12 @@ std::string CTextInput::getVisibleText() const
return hasFocus() ? currentText + composedText + "_" : currentText;
}
void CTextInput::showPopupWindow(const Point & cursorPosition)
{
if(callbackPopup)
callbackPopup();
}
void CTextInput::clickPressed(const Point & cursorPosition)
{
// attempt to give focus unconditionally, even if we already have it

View File

@ -14,6 +14,7 @@
#include "../render/EFont.h"
#include "../../lib/filesystem/ResourcePath.h"
#include "../../lib/FunctionList.h"
class CLabel;
class IImage;
@ -58,6 +59,7 @@ class CTextInput final : public CFocusable
TextEditedCallback onTextEdited;
TextFilterCallback onTextFiltering;
CFunctionList<void()> callbackPopup;
//Filter that will block all characters not allowed in filenames
static void filenameFilter(std::string & text, const std::string & oldText);
@ -74,6 +76,7 @@ class CTextInput final : public CFocusable
void textEdited(const std::string & enteredText) final;
void onFocusGot() final;
void onFocusLost() final;
void showPopupWindow(const Point & cursorPosition) final;
CTextInput(const Rect & Pos);
public:
@ -89,6 +92,9 @@ public:
/// Set callback that will be called whenever player enters new text
void setCallback(const TextEditedCallback & cb);
/// Set callback when player want to open popup
void setPopupCallback(const std::function<void()> & cb);
/// Enables filtering entered text that ensures that text is valid filename (existing or not)
void setFilterFilename();
/// Enable filtering entered text that ensures that text is valid number in provided range [min, max]