mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
block ui for guest
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "../../lib/GameLibrary.h"
|
#include "../../lib/GameLibrary.h"
|
||||||
#include "../../lib/gameState/CGameState.h"
|
#include "../../lib/gameState/CGameState.h"
|
||||||
|
#include "../../lib/networkPacks/PacksForLobby.h"
|
||||||
#include "../../lib/StartInfo.h"
|
#include "../../lib/StartInfo.h"
|
||||||
#include "../../lib/VCMIDirs.h"
|
#include "../../lib/VCMIDirs.h"
|
||||||
#include "../../lib/CRandomGenerator.h"
|
#include "../../lib/CRandomGenerator.h"
|
||||||
@@ -57,6 +58,7 @@
|
|||||||
|
|
||||||
void BattleOnlyMode::openBattleWindow()
|
void BattleOnlyMode::openBattleWindow()
|
||||||
{
|
{
|
||||||
|
GAME->server().sendGuiAction(LobbyGuiAction::BATTLE_MODE);
|
||||||
ENGINE->windows().createAndPushWindow<BattleOnlyModeWindow>();
|
ENGINE->windows().createAndPushWindow<BattleOnlyModeWindow>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +68,9 @@ BattleOnlyModeStartInfo::BattleOnlyModeStartInfo()
|
|||||||
{
|
{
|
||||||
for(auto & element : selectedArmy)
|
for(auto & element : selectedArmy)
|
||||||
element = std::make_shared<CCreatureSet>();
|
element = std::make_shared<CCreatureSet>();
|
||||||
|
for(auto & element : primSkillLevel)
|
||||||
|
for(size_t i=0; i<GameConstants::PRIMARY_SKILLS; i++)
|
||||||
|
element[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleOnlyModeWindow::BattleOnlyModeWindow()
|
BattleOnlyModeWindow::BattleOnlyModeWindow()
|
||||||
@@ -85,7 +90,10 @@ BattleOnlyModeWindow::BattleOnlyModeWindow()
|
|||||||
backgroundTexture = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
|
backgroundTexture = std::make_shared<FilledTexturePlayerColored>(Rect(0, 0, pos.w, pos.h));
|
||||||
backgroundTexture->setPlayerColor(PlayerColor(1));
|
backgroundTexture->setPlayerColor(PlayerColor(1));
|
||||||
buttonOk = std::make_shared<CButton>(Point(191, 203), AnimationPath::builtin("MuBchck"), CButton::tooltip(), [this](){ startBattle(); }, EShortcut::GLOBAL_ACCEPT);
|
buttonOk = std::make_shared<CButton>(Point(191, 203), AnimationPath::builtin("MuBchck"), CButton::tooltip(), [this](){ startBattle(); }, EShortcut::GLOBAL_ACCEPT);
|
||||||
buttonAbort = std::make_shared<CButton>(Point(265, 203), AnimationPath::builtin("MuBcanc"), CButton::tooltip(), [this](){ close(); }, EShortcut::GLOBAL_CANCEL);
|
buttonAbort = std::make_shared<CButton>(Point(265, 203), AnimationPath::builtin("MuBcanc"), CButton::tooltip(), [this](){
|
||||||
|
GAME->server().sendGuiAction(LobbyGuiAction::NO_TAB);
|
||||||
|
close();
|
||||||
|
}, EShortcut::GLOBAL_CANCEL);
|
||||||
title = std::make_shared<CLabel>(260, 20, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.lobby.battleOnlyMode"));
|
title = std::make_shared<CLabel>(260, 20, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, LIBRARY->generaltexth->translate("vcmi.lobby.battleOnlyMode"));
|
||||||
|
|
||||||
battlefieldSelector = std::make_shared<CButton>(Point(29, 174), AnimationPath::builtin("GSPButtonClear"), CButton::tooltip(), [this](){
|
battlefieldSelector = std::make_shared<CButton>(Point(29, 174), AnimationPath::builtin("GSPButtonClear"), CButton::tooltip(), [this](){
|
||||||
@@ -134,22 +142,28 @@ BattleOnlyModeWindow::BattleOnlyModeWindow()
|
|||||||
setOkButtonEnabled();
|
setOkButtonEnabled();
|
||||||
}, (startInfo->selectedTerrain != TerrainId::NONE ? static_cast<int>(startInfo->selectedTerrain) : static_cast<int>(startInfo->selectedTown + terrains.size())), images, true, true);
|
}, (startInfo->selectedTerrain != TerrainId::NONE ? static_cast<int>(startInfo->selectedTerrain) : static_cast<int>(startInfo->selectedTown + terrains.size())), images, true, true);
|
||||||
});
|
});
|
||||||
|
battlefieldSelector->block(GAME->server().isGuest());
|
||||||
buttonReset = std::make_shared<CButton>(Point(289, 174), AnimationPath::builtin("GSPButtonClear"), CButton::tooltip(), [this](){
|
buttonReset = std::make_shared<CButton>(Point(289, 174), AnimationPath::builtin("GSPButtonClear"), CButton::tooltip(), [this](){
|
||||||
|
if(GAME->server().isHost())
|
||||||
|
{
|
||||||
startInfo->selectedTerrain = TerrainId::DIRT;
|
startInfo->selectedTerrain = TerrainId::DIRT;
|
||||||
startInfo->selectedTown = FactionID::NONE;
|
startInfo->selectedTown = FactionID::NONE;
|
||||||
|
}
|
||||||
setTerrainButtonText();
|
setTerrainButtonText();
|
||||||
setOkButtonEnabled();
|
setOkButtonEnabled();
|
||||||
startInfo->selectedHero[0].reset();
|
if(GAME->server().isHost())
|
||||||
startInfo->selectedHero[1].reset();
|
|
||||||
startInfo->selectedArmy[0]->clearSlots();
|
|
||||||
startInfo->selectedArmy[1]->clearSlots();
|
|
||||||
for(size_t i=0; i<GameConstants::ARMY_SIZE; i++)
|
|
||||||
{
|
{
|
||||||
|
startInfo->selectedHero[0].reset();
|
||||||
|
startInfo->selectedArmy[0]->clearSlots();
|
||||||
|
for(size_t i=0; i<GameConstants::ARMY_SIZE; i++)
|
||||||
heroSelector1->selectedArmyInput.at(i)->setText("1");
|
heroSelector1->selectedArmyInput.at(i)->setText("1");
|
||||||
heroSelector2->selectedArmyInput.at(i)->setText("1");
|
|
||||||
}
|
|
||||||
heroSelector1->setHeroIcon();
|
heroSelector1->setHeroIcon();
|
||||||
heroSelector1->setCreatureIcons();
|
heroSelector1->setCreatureIcons();
|
||||||
|
}
|
||||||
|
startInfo->selectedHero[1].reset();
|
||||||
|
startInfo->selectedArmy[1]->clearSlots();
|
||||||
|
for(size_t i=0; i<GameConstants::ARMY_SIZE; i++)
|
||||||
|
heroSelector2->selectedArmyInput.at(i)->setText("1");
|
||||||
heroSelector2->setHeroIcon();
|
heroSelector2->setHeroIcon();
|
||||||
heroSelector2->setCreatureIcons();
|
heroSelector2->setCreatureIcons();
|
||||||
redraw();
|
redraw();
|
||||||
@@ -161,6 +175,8 @@ BattleOnlyModeWindow::BattleOnlyModeWindow()
|
|||||||
|
|
||||||
heroSelector1 = std::make_shared<BattleOnlyModeHeroSelector>(0, *this, Point(0, 40));
|
heroSelector1 = std::make_shared<BattleOnlyModeHeroSelector>(0, *this, Point(0, 40));
|
||||||
heroSelector2 = std::make_shared<BattleOnlyModeHeroSelector>(1, *this, Point(260, 40));
|
heroSelector2 = std::make_shared<BattleOnlyModeHeroSelector>(1, *this, Point(260, 40));
|
||||||
|
|
||||||
|
heroSelector1->setInputEnabled(GAME->server().isHost());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleOnlyModeWindow::init()
|
void BattleOnlyModeWindow::init()
|
||||||
@@ -186,7 +202,8 @@ void BattleOnlyModeWindow::setOkButtonEnabled()
|
|||||||
{
|
{
|
||||||
bool canStart = (startInfo->selectedTerrain != TerrainId::NONE || startInfo->selectedTown != FactionID::NONE);
|
bool canStart = (startInfo->selectedTerrain != TerrainId::NONE || startInfo->selectedTown != FactionID::NONE);
|
||||||
canStart &= (startInfo->selectedHero[0] && ((startInfo->selectedHero[1]) || (startInfo->selectedTown != FactionID::NONE && startInfo->selectedArmy[1]->stacksCount())));
|
canStart &= (startInfo->selectedHero[0] && ((startInfo->selectedHero[1]) || (startInfo->selectedTown != FactionID::NONE && startInfo->selectedArmy[1]->stacksCount())));
|
||||||
buttonOk->block(!canStart);
|
buttonOk->block(!canStart || GAME->server().isGuest());
|
||||||
|
buttonAbort->block(GAME->server().isGuest());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IImage> drawBlackBox(Point size, std::string text)
|
std::shared_ptr<IImage> drawBlackBox(Point size, std::string text)
|
||||||
|
|||||||
Reference in New Issue
Block a user