mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
commit
d9e7a8f88a
@ -76,7 +76,7 @@ std::vector<EShortcut> ShortcutHandler::translateKeycode(SDL_Keycode key) const
|
||||
{SDLK_r, EShortcut::GAME_RESTART_GAME },
|
||||
{SDLK_m, EShortcut::GAME_TO_MAIN_MENU },
|
||||
{SDLK_q, EShortcut::GAME_QUIT_GAME },
|
||||
{SDLK_t, EShortcut::GAME_OPEN_MARKETPLACE },
|
||||
{SDLK_b, EShortcut::GAME_OPEN_MARKETPLACE },
|
||||
{SDLK_g, EShortcut::GAME_OPEN_THIEVES_GUILD },
|
||||
{SDLK_TAB, EShortcut::GAME_ACTIVATE_CONSOLE },
|
||||
{SDLK_o, EShortcut::ADVENTURE_GAME_OPTIONS },
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "CursorHardware.h"
|
||||
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../render/Colors.h"
|
||||
#include "../render/IImage.h"
|
||||
#include "SDL_Extensions.h"
|
||||
@ -18,10 +19,6 @@
|
||||
#include <SDL_render.h>
|
||||
#include <SDL_events.h>
|
||||
|
||||
#ifdef VCMI_APPLE
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
CursorHardware::CursorHardware():
|
||||
cursor(nullptr)
|
||||
{
|
||||
@ -36,16 +33,13 @@ CursorHardware::~CursorHardware()
|
||||
|
||||
void CursorHardware::setVisible(bool on)
|
||||
{
|
||||
#ifdef VCMI_APPLE
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#endif
|
||||
if (on)
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
#ifdef VCMI_APPLE
|
||||
GH.dispatchMainThread([on]()
|
||||
{
|
||||
if (on)
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
|
||||
@ -63,16 +57,13 @@ void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivot
|
||||
logGlobal->error("Failed to set cursor! SDL says %s", SDL_GetError());
|
||||
|
||||
SDL_FreeSurface(cursorSurface);
|
||||
#ifdef VCMI_APPLE
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#endif
|
||||
SDL_SetCursor(cursor);
|
||||
|
||||
if (oldCursor)
|
||||
SDL_FreeCursor(oldCursor);
|
||||
#ifdef VCMI_APPLE
|
||||
GH.dispatchMainThread([this, oldCursor](){
|
||||
SDL_SetCursor(cursor);
|
||||
|
||||
if (oldCursor)
|
||||
SDL_FreeCursor(oldCursor);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void CursorHardware::setCursorPosition( const Point & newPos )
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "InfoWindows.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "QuickRecruitmentWindow.h"
|
||||
#include "CCreatureWindow.h"
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CMusicHandler.h"
|
||||
@ -1653,6 +1654,8 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
|
||||
if(!town->creatures[level].second.empty())
|
||||
addUsedEvents(LCLICK | HOVER);//Activate only if dwelling is present
|
||||
|
||||
addUsedEvents(SHOW_POPUP);
|
||||
|
||||
icons = std::make_shared<CPicture>("TPCAINFO", 261, 3);
|
||||
|
||||
if(getMyBuilding() != nullptr)
|
||||
@ -1740,6 +1743,12 @@ void CFortScreen::RecruitArea::clickPressed(const Point & cursorPosition)
|
||||
LOCPLINT->castleInt->builds->enterDwelling(level);
|
||||
}
|
||||
|
||||
void CFortScreen::RecruitArea::showPopupWindow(const Point & cursorPosition)
|
||||
{
|
||||
if (getMyCreature() != nullptr)
|
||||
GH.windows().createAndPushWindow<CStackWindow>(getMyCreature(), true);
|
||||
}
|
||||
|
||||
CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem)
|
||||
: CStatusbarWindow(BORDERED, imagem)
|
||||
{
|
||||
|
@ -347,6 +347,8 @@ class CFortScreen : public CStatusbarWindow
|
||||
void creaturesChangedEventHandler();
|
||||
void hover(bool on) override;
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
|
||||
};
|
||||
std::shared_ptr<CLabel> title;
|
||||
std::vector<std::shared_ptr<RecruitArea>> recAreas;
|
||||
|
@ -151,7 +151,7 @@
|
||||
"message" : 170,
|
||||
"resources" : [
|
||||
{
|
||||
"list" : [ "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"anyOf" : [ "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"min" : 3,
|
||||
"max" : 6
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
"message" : 64,
|
||||
"resources" : [
|
||||
{
|
||||
"list" : [ "wood", "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"anyOf" : [ "wood", "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"min" : 1,
|
||||
"max" : 5
|
||||
}
|
||||
@ -115,7 +115,7 @@
|
||||
"appearChance" : { "min" : 40, "max" : 90 },
|
||||
"resources" : [
|
||||
{
|
||||
"list" : [ "wood", "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"anyOf" : [ "wood", "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"min" : 2,
|
||||
"max" : 5
|
||||
},
|
||||
|
@ -30,7 +30,7 @@
|
||||
"removeObject" : true,
|
||||
"resources" : [
|
||||
{
|
||||
"list" : [ "wood", "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"anyOf" : [ "wood", "ore", "mercury", "gems", "sulfur", "crystal" ],
|
||||
"min" : 4,
|
||||
"max" : 6
|
||||
},
|
||||
|
@ -7,7 +7,7 @@
|
||||
"name": "lineLabelsEnd",
|
||||
"type": "texture",
|
||||
"image": "settingsWindow/lineHorizontal",
|
||||
"rect": { "x" : 5, "y" : 289, "w": 365, "h": 3}
|
||||
"rect": { "x" : 5, "y" : 229, "w": 365, "h": 3}
|
||||
},
|
||||
/////////////////////////////////////// Left section - Hero Speed and Map Scrolling
|
||||
{
|
||||
@ -323,7 +323,7 @@
|
||||
{
|
||||
"type": "verticalLayout",
|
||||
"customType": "labelDescription",
|
||||
"position": {"x": 45, "y": 295},
|
||||
"position": {"x": 45, "y": 235},
|
||||
"items":
|
||||
[
|
||||
{
|
||||
@ -353,7 +353,7 @@
|
||||
{
|
||||
"type": "verticalLayout",
|
||||
"customType": "checkbox",
|
||||
"position": {"x": 10, "y": 293},
|
||||
"position": {"x": 10, "y": 233},
|
||||
"items":
|
||||
[
|
||||
{
|
||||
|
@ -313,6 +313,18 @@ void CGeneralTextHandler::registerStringOverride(const std::string & modContext,
|
||||
assert(!modContext.empty());
|
||||
assert(!language.empty());
|
||||
|
||||
std::string baseModLanguage = getModLanguage(modContext);
|
||||
|
||||
if (baseModLanguage != language)
|
||||
{
|
||||
// this is translation - only add text to existing strings, do not register new ones
|
||||
if (stringsLocalizations.count(UID.get()) == 0)
|
||||
{
|
||||
logMod->warn("Unknown string '%s' in mod '%s' for language '%s'. Ignoring", UID.get(), modContext, language);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: implicitly creates entry, intended - strings added by vcmi (and potential UI mods) are not registered anywhere at the moment
|
||||
auto & entry = stringsLocalizations[UID.get()];
|
||||
|
||||
|
@ -141,8 +141,11 @@ class DLL_LINKAGE CGeneralTextHandler
|
||||
std::vector<size_t> scenariosCountPerCampaign;
|
||||
|
||||
std::string getModLanguage(const std::string & modContext);
|
||||
public:
|
||||
|
||||
/// add selected string to internal storage as high-priority strings
|
||||
void registerStringOverride(const std::string & modContext, const std::string & language, const TextIdentifier & UID, const std::string & localized);
|
||||
|
||||
public:
|
||||
/// validates translation of specified language for specified mod
|
||||
/// returns true if localization is valid and complete
|
||||
/// any error messages will be written to log file
|
||||
@ -155,9 +158,6 @@ public:
|
||||
/// add selected string to internal storage
|
||||
void registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized);
|
||||
|
||||
/// add selected string to internal storage as high-priority strings
|
||||
void registerStringOverride(const std::string & modContext, const std::string & language, const TextIdentifier & UID, const std::string & localized);
|
||||
|
||||
// returns true if identifier with such name was registered, even if not translated to current language
|
||||
// not required right now, can be added if necessary
|
||||
// bool identifierExists( const std::string identifier) const;
|
||||
|
@ -1718,22 +1718,25 @@ bool CGHeroInstance::isMissionCritical() const
|
||||
{
|
||||
for(const TriggeredEvent & event : IObjectInterface::cb->getMapHeader()->triggeredEvents)
|
||||
{
|
||||
if(event.trigger.test([&](const EventCondition & condition)
|
||||
if (event.effect.type != EventEffect::DEFEAT)
|
||||
continue;
|
||||
|
||||
auto const & testFunctor = [&](const EventCondition & condition)
|
||||
{
|
||||
if ((condition.condition == EventCondition::CONTROL || condition.condition == EventCondition::HAVE_0) && condition.object)
|
||||
{
|
||||
const auto * hero = dynamic_cast<const CGHeroInstance *>(condition.object);
|
||||
return (hero != this);
|
||||
}
|
||||
else if(condition.condition == EventCondition::IS_HUMAN)
|
||||
{
|
||||
|
||||
if(condition.condition == EventCondition::IS_HUMAN)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}))
|
||||
{
|
||||
};
|
||||
|
||||
if(event.trigger.test(testFunctor))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user