mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Merge pull request #5164 from Laserlicht/campaign_fix
[1.6.2] multiple fixes
This commit is contained in:
@@ -78,7 +78,8 @@ void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientCon
|
|||||||
GH.windows().popWindows(1);
|
GH.windows().popWindows(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GH.windows().createAndPushWindow<CLobbyScreen>(handler.screenType);
|
bool hideScreen = handler.campaignStateToSend && (!handler.campaignStateToSend->campaignSet.empty() || handler.campaignStateToSend->lastScenario());
|
||||||
|
GH.windows().createAndPushWindow<CLobbyScreen>(handler.screenType, hideScreen);
|
||||||
}
|
}
|
||||||
handler.setState(EClientState::LOBBY);
|
handler.setState(EClientState::LOBBY);
|
||||||
}
|
}
|
||||||
|
@@ -908,7 +908,7 @@ BattleResultResources BattleResultWindow::getResources(const BattleResult & br)
|
|||||||
case EBattleResult::SURRENDER:
|
case EBattleResult::SURRENDER:
|
||||||
resources.resultText.appendTextID("core.genrltxt.309");
|
resources.resultText.appendTextID("core.genrltxt.309");
|
||||||
resources.musicName = AudioPath::builtin("Music/Surrender Battle");
|
resources.musicName = AudioPath::builtin("Music/Surrender Battle");
|
||||||
resources.prologueVideo = VideoPath();
|
resources.prologueVideo = VideoPath::builtin("SURRENDER.BIK");
|
||||||
resources.loopedVideo = VideoPath::builtin("SURRENDER.BIK");
|
resources.loopedVideo = VideoPath::builtin("SURRENDER.BIK");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@@ -484,7 +484,7 @@ void CBonusSelection::decreaseDifficulty()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc)
|
CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc)
|
||||||
: CIntObject(LCLICK | SHOW_POPUP), idOfMapAndRegion(id), accessible(accessible), selectable(selectable), labelOnly(labelOnly)
|
: CIntObject(LCLICK | SHOW_POPUP | TIME), idOfMapAndRegion(id), accessible(accessible), selectable(selectable), labelOnly(labelOnly), blinkAnim({})
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION;
|
OBJECT_CONSTRUCTION;
|
||||||
|
|
||||||
@@ -509,12 +509,18 @@ CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBonusSelection::CRegion::updateState()
|
void CBonusSelection::CRegion::updateState(bool disableAll)
|
||||||
{
|
{
|
||||||
if(labelOnly)
|
if(labelOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!accessible)
|
if(disableAll)
|
||||||
|
{
|
||||||
|
graphicsNotSelected->disable();
|
||||||
|
graphicsSelected->disable();
|
||||||
|
graphicsStriped->disable();
|
||||||
|
}
|
||||||
|
else if(!accessible)
|
||||||
{
|
{
|
||||||
graphicsNotSelected->disable();
|
graphicsNotSelected->disable();
|
||||||
graphicsSelected->disable();
|
graphicsSelected->disable();
|
||||||
@@ -534,6 +540,29 @@ void CBonusSelection::CRegion::updateState()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBonusSelection::CRegion::tick(uint32_t msPassed)
|
||||||
|
{
|
||||||
|
if(!accessible)
|
||||||
|
{
|
||||||
|
removeUsedEvents(TIME);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blinkAnim.msPassed += msPassed;
|
||||||
|
if(blinkAnim.msPassed >= 150)
|
||||||
|
{
|
||||||
|
blinkAnim.state = !blinkAnim.state;
|
||||||
|
blinkAnim.msPassed -= 150;
|
||||||
|
if(blinkAnim.state)
|
||||||
|
blinkAnim.count++;
|
||||||
|
else if(blinkAnim.count >= 3)
|
||||||
|
removeUsedEvents(TIME);
|
||||||
|
}
|
||||||
|
updateState(blinkAnim.state);
|
||||||
|
setRedrawParent(true);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void CBonusSelection::CRegion::clickReleased(const Point & cursorPosition)
|
void CBonusSelection::CRegion::clickReleased(const Point & cursorPosition)
|
||||||
{
|
{
|
||||||
if(!labelOnly && selectable && !graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()))
|
if(!labelOnly && selectable && !graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()))
|
||||||
|
@@ -51,9 +51,16 @@ public:
|
|||||||
bool selectable; // true if region should be selectable
|
bool selectable; // true if region should be selectable
|
||||||
bool labelOnly;
|
bool labelOnly;
|
||||||
std::shared_ptr<CLabel> label;
|
std::shared_ptr<CLabel> label;
|
||||||
|
struct BlinkAnim
|
||||||
|
{
|
||||||
|
uint32_t msPassed;
|
||||||
|
uint32_t count;
|
||||||
|
bool state;
|
||||||
|
} blinkAnim;
|
||||||
public:
|
public:
|
||||||
CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc);
|
CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc);
|
||||||
void updateState();
|
void updateState(bool disableAll = false);
|
||||||
|
void tick(uint32_t msPassed) override;
|
||||||
void clickReleased(const Point & cursorPosition) override;
|
void clickReleased(const Point & cursorPosition) override;
|
||||||
void showPopupWindow(const Point & cursorPosition) override;
|
void showPopupWindow(const Point & cursorPosition) override;
|
||||||
};
|
};
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../gui/Shortcut.h"
|
#include "../gui/Shortcut.h"
|
||||||
#include "../widgets/Buttons.h"
|
#include "../widgets/Buttons.h"
|
||||||
|
#include "../widgets/GraphicalPrimitiveCanvas.h"
|
||||||
#include "../windows/InfoWindows.h"
|
#include "../windows/InfoWindows.h"
|
||||||
#include "../render/Colors.h"
|
#include "../render/Colors.h"
|
||||||
#include "../globalLobby/GlobalLobbyClient.h"
|
#include "../globalLobby/GlobalLobbyClient.h"
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
#include "../../lib/rmg/CMapGenOptions.h"
|
#include "../../lib/rmg/CMapGenOptions.h"
|
||||||
#include "../CGameInfo.h"
|
#include "../CGameInfo.h"
|
||||||
|
|
||||||
CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
CLobbyScreen::CLobbyScreen(ESelectionScreen screenType, bool hideScreen)
|
||||||
: CSelectionBase(screenType), bonusSel(nullptr)
|
: CSelectionBase(screenType), bonusSel(nullptr)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION;
|
OBJECT_CONSTRUCTION;
|
||||||
@@ -114,6 +115,12 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
|||||||
if (wasInLobbyRoom)
|
if (wasInLobbyRoom)
|
||||||
CSH->getGlobalLobby().activateInterface();
|
CSH->getGlobalLobby().activateInterface();
|
||||||
}, EShortcut::GLOBAL_CANCEL);
|
}, EShortcut::GLOBAL_CANCEL);
|
||||||
|
|
||||||
|
if(hideScreen) // workaround to avoid confusing players by custom campaign list displaying for a few ms -> instead of this draw a black screen while "loading"
|
||||||
|
{
|
||||||
|
blackScreen = std::make_shared<GraphicalPrimitiveCanvas>(Rect(Point(0, 0), pos.dimensions()));
|
||||||
|
blackScreen->addBox(Point(0, 0), pos.dimensions(), Colors::BLACK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLobbyScreen::~CLobbyScreen()
|
CLobbyScreen::~CLobbyScreen()
|
||||||
|
@@ -12,13 +12,15 @@
|
|||||||
#include "CSelectionBase.h"
|
#include "CSelectionBase.h"
|
||||||
|
|
||||||
class CBonusSelection;
|
class CBonusSelection;
|
||||||
|
class GraphicalPrimitiveCanvas;
|
||||||
|
|
||||||
class CLobbyScreen final : public CSelectionBase
|
class CLobbyScreen final : public CSelectionBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<CButton> buttonChat;
|
std::shared_ptr<CButton> buttonChat;
|
||||||
|
std::shared_ptr<GraphicalPrimitiveCanvas> blackScreen;
|
||||||
|
|
||||||
CLobbyScreen(ESelectionScreen type);
|
CLobbyScreen(ESelectionScreen type, bool hideScreen = false);
|
||||||
~CLobbyScreen();
|
~CLobbyScreen();
|
||||||
void toggleTab(std::shared_ptr<CIntObject> tab) final;
|
void toggleTab(std::shared_ptr<CIntObject> tab) final;
|
||||||
void startCampaign();
|
void startCampaign();
|
||||||
|
@@ -59,7 +59,7 @@ TConstBonusListPtr IBonusBearer::getBonusesOfType(BonusType type) const
|
|||||||
TConstBonusListPtr IBonusBearer::getBonusesOfType(BonusType type, BonusSubtypeID subtype) const
|
TConstBonusListPtr IBonusBearer::getBonusesOfType(BonusType type, BonusSubtypeID subtype) const
|
||||||
{
|
{
|
||||||
std::string cachingStr = "type_" + std::to_string(static_cast<int>(type)) + "_" + subtype.toString();
|
std::string cachingStr = "type_" + std::to_string(static_cast<int>(type)) + "_" + subtype.toString();
|
||||||
CSelector s = Selector::type()(type);
|
CSelector s = Selector::typeSubtype(type, subtype);
|
||||||
return getBonuses(s, cachingStr);
|
return getBonuses(s, cachingStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -170,8 +170,10 @@ void ApplyOnServerNetPackVisitor::visitLobbySetCampaign(LobbySetCampaign & pack)
|
|||||||
|
|
||||||
bool isCurrentMapConquerable = pack.ourCampaign->currentScenario() && pack.ourCampaign->isAvailable(*pack.ourCampaign->currentScenario());
|
bool isCurrentMapConquerable = pack.ourCampaign->currentScenario() && pack.ourCampaign->isAvailable(*pack.ourCampaign->currentScenario());
|
||||||
|
|
||||||
for(auto scenarioID : pack.ourCampaign->allScenarios())
|
auto scenarios = pack.ourCampaign->allScenarios();
|
||||||
|
for(std::set<CampaignScenarioID>::reverse_iterator itr = scenarios.rbegin(); itr != scenarios.rend(); itr++) // reverse -> on multiple scenario selection set lowest id at the end
|
||||||
{
|
{
|
||||||
|
auto scenarioID = *itr;
|
||||||
if(pack.ourCampaign->isAvailable(scenarioID))
|
if(pack.ourCampaign->isAvailable(scenarioID))
|
||||||
{
|
{
|
||||||
if(!isCurrentMapConquerable || (isCurrentMapConquerable && scenarioID == *pack.ourCampaign->currentScenario()))
|
if(!isCurrentMapConquerable || (isCurrentMapConquerable && scenarioID == *pack.ourCampaign->currentScenario()))
|
||||||
|
Reference in New Issue
Block a user