mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Added GameInstance class
- available as global GAME - integrates LOCPLINT (CPlayerInterface) - integrates CGI->mh (CMapHandler) - integrates CSH (CServerHandler)
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#include "../battle/BattleInterface.h"
|
||||
#include "../battle/BattleStacksController.h"
|
||||
#include "../GameEngine.h"
|
||||
#include "../GameInstance.h"
|
||||
#include "../media/ISoundPlayer.h"
|
||||
#include "../render/Graphics.h"
|
||||
#include "../widgets/Images.h"
|
||||
@ -40,7 +41,7 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player)
|
||||
pos.w = 0;
|
||||
pos.h = 0;
|
||||
recActions &= ~DEACTIVATE;
|
||||
const auto & timers = LOCPLINT->cb->getStartInfo()->turnTimerInfo;
|
||||
const auto & timers = GAME->interface()->cb->getStartInfo()->turnTimerInfo;
|
||||
|
||||
backgroundTexture = std::make_shared<CFilledTexture>(ImagePath::builtin("DiBoxBck"), pos); // 1 px smaller on all sides
|
||||
|
||||
@ -68,7 +69,7 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player)
|
||||
playerLabelsUnit[player] = std::make_shared<CLabel>(pos.w / 2, pos.h - 10, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player], "");
|
||||
}
|
||||
|
||||
updateTextLabel(player, LOCPLINT->cb->getPlayerTurnTime(player));
|
||||
updateTextLabel(player, GAME->interface()->cb->getPlayerTurnTime(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -79,16 +80,16 @@ TurnTimerWidget::TurnTimerWidget(const Point & position, PlayerColor player)
|
||||
|
||||
for(PlayerColor player(0); player < PlayerColor::PLAYER_LIMIT; ++player)
|
||||
{
|
||||
if (LOCPLINT->cb->getStartInfo()->playerInfos.count(player) == 0)
|
||||
if (GAME->interface()->cb->getStartInfo()->playerInfos.count(player) == 0)
|
||||
continue;
|
||||
|
||||
if (!LOCPLINT->cb->getStartInfo()->playerInfos.at(player).isControlledByHuman())
|
||||
if (!GAME->interface()->cb->getStartInfo()->playerInfos.at(player).isControlledByHuman())
|
||||
continue;
|
||||
|
||||
pos.h += 20;
|
||||
playerLabelsMain[player] = std::make_shared<CLabel>(pos.w / 2, pos.h - 10, FONT_BIG, ETextAlignment::CENTER, graphics->playerColors[player], "");
|
||||
|
||||
updateTextLabel(player, LOCPLINT->cb->getPlayerTurnTime(player));
|
||||
updateTextLabel(player, GAME->interface()->cb->getPlayerTurnTime(player));
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ void TurnTimerWidget::show(Canvas & to)
|
||||
|
||||
void TurnTimerWidget::updateNotifications(PlayerColor player, int timeMs)
|
||||
{
|
||||
if(player != LOCPLINT->playerID)
|
||||
if(player != GAME->interface()->playerID)
|
||||
return;
|
||||
|
||||
int newTimeSeconds = timeMs / 1000;
|
||||
@ -124,7 +125,7 @@ static std::string msToString(int timeMs)
|
||||
|
||||
void TurnTimerWidget::updateTextLabel(PlayerColor player, const TurnTimerInfo & timer)
|
||||
{
|
||||
const auto & timerSettings = LOCPLINT->cb->getStartInfo()->turnTimerInfo;
|
||||
const auto & timerSettings = GAME->interface()->cb->getStartInfo()->turnTimerInfo;
|
||||
auto mainLabel = playerLabelsMain[player];
|
||||
|
||||
if (isBattleMode)
|
||||
@ -165,7 +166,7 @@ void TurnTimerWidget::updateTextLabel(PlayerColor player, const TurnTimerInfo &
|
||||
|
||||
void TurnTimerWidget::updateTimer(PlayerColor player, uint32_t msPassed)
|
||||
{
|
||||
const auto & gamestateTimer = LOCPLINT->cb->getPlayerTurnTime(player);
|
||||
const auto & gamestateTimer = GAME->interface()->cb->getPlayerTurnTime(player);
|
||||
updateNotifications(player, gamestateTimer.valueMs());
|
||||
updateTextLabel(player, gamestateTimer);
|
||||
}
|
||||
@ -174,9 +175,9 @@ void TurnTimerWidget::tick(uint32_t msPassed)
|
||||
{
|
||||
for(const auto & player : playerLabelsMain)
|
||||
{
|
||||
if (LOCPLINT->battleInt)
|
||||
if (GAME->interface()->battleInt)
|
||||
{
|
||||
const auto & battle = LOCPLINT->battleInt->getBattle();
|
||||
const auto & battle = GAME->interface()->battleInt->getBattle();
|
||||
|
||||
bool isDefender = battle->sideToPlayer(BattleSide::DEFENDER) == player.first;
|
||||
bool isAttacker = battle->sideToPlayer(BattleSide::ATTACKER) == player.first;
|
||||
|
Reference in New Issue
Block a user