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