feat: add map background color
This commit is contained in:
@@ -37,6 +37,7 @@ bool World::loadMap(const protocol::WorldBeginDataPacket* worldHeader) {
|
||||
m_TowerPlacePalette = worldHeader->getTowerTilePalette();
|
||||
m_WalkablePalette = worldHeader->getWalkableTileColor();
|
||||
m_DecorationPalette = worldHeader->getDecorationPalette();
|
||||
m_Background = worldHeader->getBackgroundColor();
|
||||
|
||||
getRedTeam().getSpawn() = worldHeader->getRedSpawn();
|
||||
getBlueTeam().getSpawn() = worldHeader->getBlueSpawn();
|
||||
|
||||
@@ -93,6 +93,7 @@ void ClientGame::HandlePacket(const protocol::UpdateMoneyPacket* packet) {
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::DisconnectPacket* packet) {
|
||||
m_GameState = game::GameState::Disconnected;
|
||||
m_Renderer->setBackgroundColor({ 0, 0, 0 });
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::WorldDataPacket* packet) {
|
||||
|
||||
@@ -17,6 +17,11 @@ WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::Packet
|
||||
|
||||
void WorldClient::HandlePacket(const protocol::WorldBeginDataPacket* packet) {
|
||||
loadMap(packet);
|
||||
if (m_Game->getGameState() == game::GameState::Game) {
|
||||
const game::Color& backgroundColor = getBackgroundColor();
|
||||
m_Game->getRenderer()->setBackgroundColor({ static_cast<float>(backgroundColor.r / 255.0f), static_cast<float>(backgroundColor.g / 255.0f),
|
||||
static_cast<float>(backgroundColor.b / 255.0f) });
|
||||
}
|
||||
}
|
||||
|
||||
void WorldClient::HandlePacket(const protocol::WorldDataPacket* packet) {
|
||||
|
||||
@@ -91,6 +91,8 @@ DataBuffer WorldBeginDataPacket::SerializeCustom() const {
|
||||
|
||||
memcpy((std::uint8_t*)data.data() + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color));
|
||||
|
||||
data << m_Header.m_Background;
|
||||
|
||||
const game::Spawn& redSpawn = m_Header.m_RedSpawn, blueSpawn = m_Header.m_BlueSpawn;
|
||||
const game::TeamCastle& redCastle = m_Header.m_RedCastle, blueCastle = m_Header.m_BlueCastle;
|
||||
|
||||
@@ -123,6 +125,8 @@ DataBuffer WorldBeginDataPacket::Serialize() const {
|
||||
|
||||
memcpy((std::uint8_t*)data.data() + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color));
|
||||
|
||||
data << m_Header.m_World->getBackgroundColor();
|
||||
|
||||
const game::Spawn& redSpawn = m_Header.m_World->getRedTeam().getSpawn(), blueSpawn = m_Header.m_World->getBlueTeam().getSpawn();
|
||||
const game::TeamCastle& redCastle = m_Header.m_World->getRedTeam().getCastle(), blueCastle = m_Header.m_World->getBlueTeam().getCastle();
|
||||
|
||||
@@ -155,6 +159,8 @@ void WorldBeginDataPacket::Deserialize(DataBuffer& data) {
|
||||
|
||||
data.SetReadOffset(data.GetReadOffset() + decoPalletteSizeByte);
|
||||
|
||||
data >> m_Header.m_Background;
|
||||
|
||||
utils::shape::Rectangle redCastle, blueCastle;
|
||||
|
||||
data >> m_Header.m_RedSpawn >> redCastle;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
namespace td {
|
||||
namespace render {
|
||||
|
||||
Renderer::Renderer() {
|
||||
Renderer::Renderer() : m_BackgroundColor(0, 0, 0) {
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void Renderer::updateIsometricFade() {
|
||||
|
||||
void Renderer::prepare() {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClearColor(m_BackgroundColor.r, m_BackgroundColor.g, m_BackgroundColor.b, 0);
|
||||
updateIsometricFade();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ WorldRenderer::WorldRenderer(game::World* world, client::ClientGame* client) : m
|
||||
m_TowerPlacePopup = std::make_unique<gui::TowerPlacePopup>(m_Client->getClient());
|
||||
m_MobTooltip = std::make_unique<gui::MobTooltip>(m_Client->getClient());
|
||||
m_CastleTooltip = std::make_unique<gui::CastleTooltip>(m_Client->getClient());
|
||||
m_Client->getWorld().getWorldNotifier().bindListener(this);
|
||||
m_Client->getWorldClient().getWorldNotifier().bindListener(this);
|
||||
}
|
||||
|
||||
void WorldRenderer::updateCursorPos() {
|
||||
|
||||
Reference in New Issue
Block a user