fix: compiler warnings
This commit is contained in:
@@ -95,10 +95,10 @@ public:
|
|||||||
void heal(float heal){ m_Health = std::min((float)getStats()->getMaxLife(), m_Health + heal); }
|
void heal(float heal){ m_Health = std::min((float)getStats()->getMaxLife(), m_Health + heal); }
|
||||||
|
|
||||||
float getX() const{ return m_X; }
|
float getX() const{ return m_X; }
|
||||||
float setX(float x){ m_X = x; }
|
void setX(float x){ m_X = x; }
|
||||||
|
|
||||||
float getY() const{ return m_Y; }
|
float getY() const{ return m_Y; }
|
||||||
float setY(float y){ m_Y = y; }
|
void setY(float y){ m_Y = y; }
|
||||||
|
|
||||||
Direction getDirection() const{ return m_Direction; }
|
Direction getDirection() const{ return m_Direction; }
|
||||||
void setDirection(Direction dir){ m_Direction = dir; }
|
void setDirection(Direction dir){ m_Direction = dir; }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ private:
|
|||||||
game::TeamColor m_TeamColor = game::TeamColor::None;
|
game::TeamColor m_TeamColor = game::TeamColor::None;
|
||||||
|
|
||||||
std::uint32_t m_Gold = 0;
|
std::uint32_t m_Gold = 0;
|
||||||
std::int32_t m_EXP;
|
std::int32_t m_EXP = 0;
|
||||||
std::string m_Name;
|
std::string m_Name;
|
||||||
std::uint8_t m_ID;
|
std::uint8_t m_ID;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ enum class TowerSize : bool{
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class TowerPath : std::uint8_t{
|
enum class TowerPath : std::uint8_t{
|
||||||
Top = 1, // Base path
|
Top = 0, // Base path
|
||||||
Bottom
|
Bottom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public:
|
|||||||
const MobList& getMobList() const{ return m_Mobs; }
|
const MobList& getMobList() const{ return m_Mobs; }
|
||||||
MobList& getMobList(){ return m_Mobs; }
|
MobList& getMobList(){ return m_Mobs; }
|
||||||
|
|
||||||
const Color& getTileColor(TilePtr tile) const;
|
const Color* getTileColor(TilePtr tile) const;
|
||||||
|
|
||||||
Team& getRedTeam();
|
Team& getRedTeam();
|
||||||
const Team& getRedTeam() const;
|
const Team& getRedTeam() const;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class ServerGame;
|
|||||||
|
|
||||||
class ServerWorld : public game::World{
|
class ServerWorld : public game::World{
|
||||||
private:
|
private:
|
||||||
game::MobID m_CurrentMobID = 0;
|
game::MobID m_CurrentMobID;
|
||||||
Server* m_Server;
|
Server* m_Server;
|
||||||
public:
|
public:
|
||||||
ServerWorld(Server* server, ServerGame* game);
|
ServerWorld(Server* server, ServerGame* game);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void pollEvents();
|
|||||||
|
|
||||||
bool isCloseRequested();
|
bool isCloseRequested();
|
||||||
|
|
||||||
const bool isMouseDown(int button);
|
bool isMouseDown(int button);
|
||||||
|
|
||||||
float getAspectRatio();
|
float getAspectRatio();
|
||||||
int getWindowWidth();
|
int getWindowWidth();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Connexion::Connexion() : protocol::PacketHandler(nullptr){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connexion::Connexion(Connexion&& move) : m_Socket(std::move(move.m_Socket)), protocol::PacketHandler(&m_Dispatcher){
|
Connexion::Connexion(Connexion&& move) : protocol::PacketHandler(&m_Dispatcher), m_Socket(std::move(move.m_Socket)){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ Connexion::Connexion(protocol::PacketDispatcher* dispatcher) : protocol::PacketH
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connexion::Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket) : protocol::PacketHandler(dispatcher), m_Socket(std::move(socket)){
|
Connexion::Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket) : protocol::PacketHandler(dispatcher), m_Socket(std::move(socket)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,8 +316,7 @@ bool World::saveMap(const std::string& fileName) const{
|
|||||||
|
|
||||||
DataBuffer buffer = mapHeaderCompressed << mapDataCompressed;
|
DataBuffer buffer = mapHeaderCompressed << mapDataCompressed;
|
||||||
std::cout << "Total Size : " << buffer.GetSize() << std::endl;
|
std::cout << "Total Size : " << buffer.GetSize() << std::endl;
|
||||||
buffer.WriteFile(fileName);
|
return buffer.WriteFile(fileName);
|
||||||
std::cout << "----- Map Saved ! -----\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::tick(std::uint64_t delta){
|
void World::tick(std::uint64_t delta){
|
||||||
@@ -336,8 +335,6 @@ void World::moveMobs(std::uint64_t delta){
|
|||||||
for(MobPtr mob : m_Mobs){
|
for(MobPtr mob : m_Mobs){
|
||||||
TilePtr tile = getTile(mob->getX(), mob->getY());
|
TilePtr tile = getTile(mob->getX(), mob->getY());
|
||||||
|
|
||||||
Direction tileDir;
|
|
||||||
|
|
||||||
if(tile != nullptr && tile->getType() == TileType::Walk){
|
if(tile != nullptr && tile->getType() == TileType::Walk){
|
||||||
WalkableTile* walkTile = dynamic_cast<WalkableTile*>(tile.get());
|
WalkableTile* walkTile = dynamic_cast<WalkableTile*>(tile.get());
|
||||||
mob->setDirection(walkTile->direction);
|
mob->setDirection(walkTile->direction);
|
||||||
@@ -368,22 +365,25 @@ void World::moveMobs(std::uint64_t delta){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Color& World::getTileColor(TilePtr tile) const{
|
const Color* World::getTileColor(TilePtr tile) const{
|
||||||
switch(tile->getType()){
|
switch(tile->getType()){
|
||||||
case TileType::Tower:{
|
case TileType::Tower:{
|
||||||
TowerTile* towerTile = (TowerTile*) tile.get();
|
TowerTile* towerTile = (TowerTile*) tile.get();
|
||||||
return m_TowerPlacePalette[towerTile->color_palette_ref];
|
return &m_TowerPlacePalette[towerTile->color_palette_ref];
|
||||||
}
|
}
|
||||||
case TileType::Walk:{
|
case TileType::Walk:{
|
||||||
return m_WalkablePalette;
|
return &m_WalkablePalette;
|
||||||
}
|
}
|
||||||
case TileType::Decoration:{
|
case TileType::Decoration:{
|
||||||
DecorationTile* towerTile = (DecorationTile*) tile.get();
|
DecorationTile* towerTile = (DecorationTile*) tile.get();
|
||||||
return m_DecorationPalette[towerTile->color_palette_ref];
|
return &m_DecorationPalette[towerTile->color_palette_ref];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case TileType::None:{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return m_DecorationPalette[0];
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Team& World::getRedTeam(){
|
Team& World::getRedTeam(){
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace td{
|
namespace td{
|
||||||
namespace client{
|
namespace client{
|
||||||
|
|
||||||
WorldClient::WorldClient(ClientGame* game) : m_Game(game), game::World(game), protocol::PacketHandler(game->GetDispatcher()){
|
WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::PacketHandler(game->GetDispatcher()), m_Game(game){
|
||||||
GetDispatcher()->RegisterHandler(protocol::PacketType::WorldBeginData, this);
|
GetDispatcher()->RegisterHandler(protocol::PacketType::WorldBeginData, this);
|
||||||
GetDispatcher()->RegisterHandler(protocol::PacketType::WorldData, this);
|
GetDispatcher()->RegisterHandler(protocol::PacketType::WorldData, this);
|
||||||
GetDispatcher()->RegisterHandler(protocol::PacketType::SpawnMob, this);
|
GetDispatcher()->RegisterHandler(protocol::PacketType::SpawnMob, this);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
ServerGame::ServerGame(server::Server* server) : m_Server(server), m_ServerWorld(server, this), game::Game(&m_ServerWorld){
|
ServerGame::ServerGame(server::Server* server) : game::Game(&m_ServerWorld), m_Server(server), m_ServerWorld(server, this){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
|
||||||
ServerWorld::ServerWorld(Server* server, ServerGame* game) : m_Server(server), game::World(game){
|
ServerWorld::ServerWorld(Server* server, ServerGame* game) : game::World(game), m_CurrentMobID(0), m_Server(server){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,14 @@ namespace network {
|
|||||||
|
|
||||||
/* Create an invalid address */
|
/* Create an invalid address */
|
||||||
IPAddress::IPAddress() noexcept
|
IPAddress::IPAddress() noexcept
|
||||||
: m_Valid(false), m_Address(0)
|
: m_Address(0), m_Valid(false){
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize by string IP */
|
/* Initialize by string IP */
|
||||||
IPAddress::IPAddress(const std::string& ip)
|
IPAddress::IPAddress(const std::string& ip)
|
||||||
: m_Valid(false), m_Address(0)
|
: m_Address(0), m_Valid(false){
|
||||||
{
|
|
||||||
std::sregex_iterator begin(ip.begin(), ip.end(), IPRegex);
|
std::sregex_iterator begin(ip.begin(), ip.end(), IPRegex);
|
||||||
std::sregex_iterator end;
|
std::sregex_iterator end;
|
||||||
|
|
||||||
@@ -42,8 +41,8 @@ IPAddress::IPAddress(const std::string& ip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPAddress::IPAddress(const std::wstring& ip)
|
IPAddress::IPAddress(const std::wstring& ip)
|
||||||
: m_Address(0), m_Valid(false)
|
: m_Address(0), m_Valid(false){
|
||||||
{
|
|
||||||
std::wsregex_iterator begin(ip.begin(), ip.end(), IPRegexW);
|
std::wsregex_iterator begin(ip.begin(), ip.end(), IPRegexW);
|
||||||
std::wsregex_iterator end;
|
std::wsregex_iterator end;
|
||||||
|
|
||||||
@@ -62,8 +61,7 @@ IPAddress::IPAddress(const std::wstring& ip)
|
|||||||
|
|
||||||
/* Initialize by octets */
|
/* Initialize by octets */
|
||||||
IPAddress::IPAddress(uint8_t octet1, uint8_t octet2, uint8_t octet3, uint8_t octet4) noexcept
|
IPAddress::IPAddress(uint8_t octet1, uint8_t octet2, uint8_t octet3, uint8_t octet4) noexcept
|
||||||
: m_Valid(true)
|
: m_Valid(true){
|
||||||
{
|
|
||||||
m_Address = (octet1 << 24) | (octet2 << 16) | (octet3 << 8) | octet4;
|
m_Address = (octet1 << 24) | (octet2 << 16) | (octet3 << 8) | octet4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ namespace td {
|
|||||||
namespace network {
|
namespace network {
|
||||||
|
|
||||||
Socket::Socket(Type type)
|
Socket::Socket(Type type)
|
||||||
: m_Handle(INVALID_SOCKET),
|
: m_Blocking(false),
|
||||||
m_Type(type),
|
m_Type(type),
|
||||||
m_Blocking(false),
|
m_Status(Disconnected),
|
||||||
m_Status(Disconnected)
|
m_Handle(INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,8 @@ bool Socket::SetBlocking(bool block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Blocking = block;
|
m_Blocking = block;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Socket::IsBlocking() const noexcept {
|
bool Socket::IsBlocking() const noexcept {
|
||||||
|
|||||||
@@ -19,20 +19,22 @@ DataBuffer& operator<<(DataBuffer& buffer, game::TilePtr tile){
|
|||||||
buffer << tile->getType();
|
buffer << tile->getType();
|
||||||
switch (tile->getType()){
|
switch (tile->getType()){
|
||||||
case game::TileType::Tower:{
|
case game::TileType::Tower:{
|
||||||
const std::shared_ptr<game::TowerTile>& towerTile = (const std::shared_ptr<game::TowerTile>&) tile;
|
const game::TowerTile* towerTile = (const game::TowerTile*) tile.get();
|
||||||
buffer << towerTile->color_palette_ref << towerTile->team_owner;
|
buffer << towerTile->color_palette_ref << towerTile->team_owner;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case game::TileType::Walk:{
|
case game::TileType::Walk:{
|
||||||
const std::shared_ptr<game::WalkableTile>& walkTile = (const std::shared_ptr<game::WalkableTile>&) tile;
|
const game::WalkableTile* walkTile = (const game::WalkableTile*) tile.get();
|
||||||
buffer << walkTile->direction;
|
buffer << walkTile->direction;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case game::TileType::Decoration:{
|
case game::TileType::Decoration:{
|
||||||
const std::shared_ptr<game::DecorationTile>& decoTile = (const std::shared_ptr<game::DecorationTile>&) tile;
|
const game::DecorationTile* decoTile = (const game::DecorationTile*) tile.get();
|
||||||
buffer << decoTile->color_palette_ref;
|
buffer << decoTile->color_palette_ref;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -59,6 +61,8 @@ DataBuffer& operator>>(DataBuffer& buffer, game::TilePtr& tile){
|
|||||||
tile = tilePtr;
|
tile = tilePtr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -85,7 +89,7 @@ DataBuffer WorldBeginDataPacket::Serialize() const{
|
|||||||
std::size_t bufferSize = data.GetSize();
|
std::size_t bufferSize = data.GetSize();
|
||||||
data.Resize(bufferSize + decoTilePalette.size() * sizeof(game::Color));
|
data.Resize(bufferSize + decoTilePalette.size() * sizeof(game::Color));
|
||||||
|
|
||||||
memcpy((void*)data.data() + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color));
|
memcpy((std::uint8_t*)data.data() + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color));
|
||||||
|
|
||||||
const game::Spawn& redSpawn = m_World->getRedTeam().getSpawn(), blueSpawn = m_World->getBlueTeam().getSpawn();
|
const game::Spawn& redSpawn = m_World->getRedTeam().getSpawn(), blueSpawn = m_World->getBlueTeam().getSpawn();
|
||||||
const game::TeamCastle& redCastle = m_World->getRedTeam().getCastle(), blueCastle = m_World->getBlueTeam().getCastle();
|
const game::TeamCastle& redCastle = m_World->getRedTeam().getCastle(), blueCastle = m_World->getBlueTeam().getCastle();
|
||||||
@@ -127,7 +131,7 @@ void WorldBeginDataPacket::Deserialize(DataBuffer& data){
|
|||||||
|
|
||||||
m_TilePalette.reserve(tilePaletteSize);
|
m_TilePalette.reserve(tilePaletteSize);
|
||||||
|
|
||||||
for (int i = 0; i < tilePaletteSize; i++){
|
for (std::uint64_t tileNumber = 0; tileNumber < tilePaletteSize; tileNumber++){
|
||||||
game::TilePtr tile;
|
game::TilePtr tile;
|
||||||
data >> tile;
|
data >> tile;
|
||||||
m_TilePalette.push_back(tile);
|
m_TilePalette.push_back(tile);
|
||||||
@@ -149,7 +153,7 @@ DataBuffer WorldDataPacket::Serialize() const{
|
|||||||
|
|
||||||
std::size_t bufferSize = data.GetSize();
|
std::size_t bufferSize = data.GetSize();
|
||||||
data.Resize(data.GetSize() + chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
|
data.Resize(data.GetSize() + chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
|
||||||
memcpy((void*)data.data() + bufferSize, chunk->palette.data(), chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
|
memcpy((std::uint8_t*)data.data() + bufferSize, chunk->palette.data(), chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
|
||||||
|
|
||||||
std::uint8_t bitsPerTile = countBits(chunk->palette.size());
|
std::uint8_t bitsPerTile = countBits(chunk->palette.size());
|
||||||
|
|
||||||
@@ -176,7 +180,7 @@ DataBuffer WorldDataPacket::Serialize() const{
|
|||||||
|
|
||||||
bufferSize = data.GetSize();
|
bufferSize = data.GetSize();
|
||||||
data.Resize(data.GetSize() + chunkData.size() * sizeof(ChunkPackedData::value_type));
|
data.Resize(data.GetSize() + chunkData.size() * sizeof(ChunkPackedData::value_type));
|
||||||
memcpy((void*)data.data() + bufferSize, chunkData.data(), chunkData.size() * sizeof(ChunkPackedData::value_type));
|
memcpy((std::uint8_t*)data.data() + bufferSize, chunkData.data(), chunkData.size() * sizeof(ChunkPackedData::value_type));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -185,7 +189,7 @@ void WorldDataPacket::Deserialize(DataBuffer& data){
|
|||||||
std::uint64_t chunkCount;
|
std::uint64_t chunkCount;
|
||||||
data >> chunkCount;
|
data >> chunkCount;
|
||||||
|
|
||||||
for (int chunkNumber = 0; chunkNumber < chunkCount; chunkNumber++){
|
for (std::uint64_t chunkNumber = 0; chunkNumber < chunkCount; chunkNumber++){
|
||||||
game::ChunkPtr chunk = std::make_shared<game::Chunk>();
|
game::ChunkPtr chunk = std::make_shared<game::Chunk>();
|
||||||
|
|
||||||
game::ChunkCoord::first_type chunkX, chunkY;
|
game::ChunkCoord::first_type chunkX, chunkY;
|
||||||
|
|||||||
@@ -161,12 +161,13 @@ void renderMainMenu(){
|
|||||||
ImVec4 getImGuiTeamColor(td::game::TeamColor color){
|
ImVec4 getImGuiTeamColor(td::game::TeamColor color){
|
||||||
switch (color){
|
switch (color){
|
||||||
case td::game::TeamColor::None:
|
case td::game::TeamColor::None:
|
||||||
return ImVec4(1, 1, 1, 1);
|
break;
|
||||||
case td::game::TeamColor::Red:
|
case td::game::TeamColor::Red:
|
||||||
return ImVec4(1, 0, 0, 1);
|
return ImVec4(1, 0, 0, 1);
|
||||||
case td::game::TeamColor::Blue:
|
case td::game::TeamColor::Blue:
|
||||||
return ImVec4(0, 0, 1, 1);
|
return ImVec4(0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
return ImVec4(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showPlayers(){
|
void showPlayers(){
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ namespace imgui_addons
|
|||||||
ImGui::BeginChild("##NavigationWindow", nw_size, true, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
|
ImGui::BeginChild("##NavigationWindow", nw_size, true, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f));
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f));
|
||||||
for(int i = 0; i < current_dirlist.size(); i++)
|
for(std::size_t i = 0; i < current_dirlist.size(); i++)
|
||||||
{
|
{
|
||||||
if( ImGui::Button(current_dirlist[i].c_str()) )
|
if( ImGui::Button(current_dirlist[i].c_str()) )
|
||||||
{
|
{
|
||||||
@@ -259,7 +259,7 @@ namespace imgui_addons
|
|||||||
if(ImGui::ListBoxHeader("##NavBarDropBox", ImVec2(0, list_item_height* 5)))
|
if(ImGui::ListBoxHeader("##NavBarDropBox", ImVec2(0, list_item_height* 5)))
|
||||||
{
|
{
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f));
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f));
|
||||||
for(int j = i+1; j < current_dirlist.size(); j++)
|
for(std::size_t j = i+1; j < current_dirlist.size(); j++)
|
||||||
{
|
{
|
||||||
if(ImGui::Selectable(current_dirlist[j].c_str(), false) && j != current_dirlist.size() - 1)
|
if(ImGui::Selectable(current_dirlist[j].c_str(), false) && j != current_dirlist.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -345,12 +345,12 @@ namespace imgui_addons
|
|||||||
//Output directories in yellow
|
//Output directories in yellow
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f));
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.882f, 0.745f, 0.078f,1.0f));
|
||||||
int items = 0;
|
int items = 0;
|
||||||
for (int i = 0; i < filtered_dirs.size(); i++)
|
for (std::size_t i = 0; i < filtered_dirs.size(); i++)
|
||||||
{
|
{
|
||||||
if(!filtered_dirs[i]->is_hidden || show_hidden)
|
if(!filtered_dirs[i]->is_hidden || show_hidden)
|
||||||
{
|
{
|
||||||
items++;
|
items++;
|
||||||
if(ImGui::Selectable(filtered_dirs[i]->name.c_str(), selected_idx == i && is_dir, ImGuiSelectableFlags_AllowDoubleClick))
|
if(ImGui::Selectable(filtered_dirs[i]->name.c_str(), selected_idx == (int) i && is_dir, ImGuiSelectableFlags_AllowDoubleClick))
|
||||||
{
|
{
|
||||||
selected_idx = i;
|
selected_idx = i;
|
||||||
is_dir = true;
|
is_dir = true;
|
||||||
@@ -372,14 +372,13 @@ namespace imgui_addons
|
|||||||
ImGui::PopStyleColor(1);
|
ImGui::PopStyleColor(1);
|
||||||
|
|
||||||
//Output files
|
//Output files
|
||||||
for (int i = 0; i < filtered_files.size(); i++)
|
for (std::size_t i = 0; i < filtered_files.size(); i++)
|
||||||
{
|
{
|
||||||
if(!filtered_files[i]->is_hidden || show_hidden)
|
if(!filtered_files[i]->is_hidden || show_hidden)
|
||||||
{
|
{
|
||||||
items++;
|
items++;
|
||||||
if(ImGui::Selectable(filtered_files[i]->name.c_str(), selected_idx == i && !is_dir, ImGuiSelectableFlags_AllowDoubleClick))
|
if(ImGui::Selectable(filtered_files[i]->name.c_str(), selected_idx == (int) i && !is_dir, ImGuiSelectableFlags_AllowDoubleClick))
|
||||||
{
|
{
|
||||||
int len = filtered_files[i]->name.length();
|
|
||||||
selected_idx = i;
|
selected_idx = i;
|
||||||
is_dir = false;
|
is_dir = false;
|
||||||
|
|
||||||
@@ -406,7 +405,6 @@ namespace imgui_addons
|
|||||||
{
|
{
|
||||||
std::string label = (dialog_mode == DialogMode::SAVE) ? "Save As:" : "Open:";
|
std::string label = (dialog_mode == DialogMode::SAVE) ? "Save As:" : "Open:";
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
ImVec2 pw_pos = ImGui::GetWindowPos();
|
ImVec2 pw_pos = ImGui::GetWindowPos();
|
||||||
ImVec2 pw_content_sz = ImGui::GetWindowSize() - style.WindowPadding * 2.0;
|
ImVec2 pw_content_sz = ImGui::GetWindowSize() - style.WindowPadding * 2.0;
|
||||||
@@ -452,7 +450,7 @@ namespace imgui_addons
|
|||||||
if(dialog_mode == DialogMode::OPEN || dialog_mode == DialogMode::SAVE)
|
if(dialog_mode == DialogMode::OPEN || dialog_mode == DialogMode::SAVE)
|
||||||
{
|
{
|
||||||
inputcb_filter_files.clear();
|
inputcb_filter_files.clear();
|
||||||
for(int i = 0; i < subfiles.size(); i++)
|
for(std::size_t i = 0; i < subfiles.size(); i++)
|
||||||
{
|
{
|
||||||
if(ImStristr(subfiles[i].name.c_str(), nullptr, input_fn, nullptr) != nullptr)
|
if(ImStristr(subfiles[i].name.c_str(), nullptr, input_fn, nullptr) != nullptr)
|
||||||
inputcb_filter_files.push_back(std::ref(subfiles[i].name));
|
inputcb_filter_files.push_back(std::ref(subfiles[i].name));
|
||||||
@@ -463,7 +461,7 @@ namespace imgui_addons
|
|||||||
else if(dialog_mode == DialogMode::SELECT)
|
else if(dialog_mode == DialogMode::SELECT)
|
||||||
{
|
{
|
||||||
inputcb_filter_files.clear();
|
inputcb_filter_files.clear();
|
||||||
for(int i = 0; i < subdirs.size(); i++)
|
for(std::size_t i = 0; i < subdirs.size(); i++)
|
||||||
{
|
{
|
||||||
if(ImStristr(subdirs[i].name.c_str(), nullptr, input_fn, nullptr) != nullptr)
|
if(ImStristr(subdirs[i].name.c_str(), nullptr, input_fn, nullptr) != nullptr)
|
||||||
inputcb_filter_files.push_back(std::ref(subdirs[i].name));
|
inputcb_filter_files.push_back(std::ref(subdirs[i].name));
|
||||||
@@ -642,7 +640,7 @@ namespace imgui_addons
|
|||||||
ImGui::PushItemWidth(ext_box_width);
|
ImGui::PushItemWidth(ext_box_width);
|
||||||
if(ImGui::BeginCombo("##FileTypes", valid_exts[selected_ext_idx].c_str()))
|
if(ImGui::BeginCombo("##FileTypes", valid_exts[selected_ext_idx].c_str()))
|
||||||
{
|
{
|
||||||
for(int i = 0; i < valid_exts.size(); i++)
|
for(std::size_t i = 0; i < valid_exts.size(); i++)
|
||||||
{
|
{
|
||||||
if(ImGui::Selectable(valid_exts[i].c_str(), selected_ext_idx == i))
|
if(ImGui::Selectable(valid_exts[i].c_str(), selected_ext_idx == i))
|
||||||
{
|
{
|
||||||
@@ -653,7 +651,7 @@ namespace imgui_addons
|
|||||||
size_t idx = name.find_last_of(".");
|
size_t idx = name.find_last_of(".");
|
||||||
if(idx == std::string::npos)
|
if(idx == std::string::npos)
|
||||||
idx = strlen(input_fn);
|
idx = strlen(input_fn);
|
||||||
for(int j = 0; j < valid_exts[selected_ext_idx].size(); j++)
|
for(std::size_t j = 0; j < valid_exts[selected_ext_idx].size(); j++)
|
||||||
input_fn[idx++] = valid_exts[selected_ext_idx][j];
|
input_fn[idx++] = valid_exts[selected_ext_idx][j];
|
||||||
input_fn[idx++] = '\0';
|
input_fn[idx++] = '\0';
|
||||||
}
|
}
|
||||||
@@ -910,8 +908,6 @@ namespace imgui_addons
|
|||||||
bool ret_val = false;
|
bool ret_val = false;
|
||||||
if (ImGui::BeginPopupModal(repfile_modal_id.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize))
|
if (ImGui::BeginPopupModal(repfile_modal_id.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize))
|
||||||
{
|
{
|
||||||
float frame_height = ImGui::GetFrameHeightWithSpacing();
|
|
||||||
|
|
||||||
std::string text = "A file with the following filename already exists. Are you sure you want to replace the existing file?";
|
std::string text = "A file with the following filename already exists. Are you sure you want to replace the existing file?";
|
||||||
ImGui::TextWrapped("%s", text.c_str());
|
ImGui::TextWrapped("%s", text.c_str());
|
||||||
|
|
||||||
@@ -942,9 +938,7 @@ namespace imgui_addons
|
|||||||
|
|
||||||
void ImGuiFileBrowser::showInvalidFileModal()
|
void ImGuiFileBrowser::showInvalidFileModal()
|
||||||
{
|
{
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
std::string text = "Selected file either doesn't exist or is not supported. Please select a file with the following extensions...";
|
std::string text = "Selected file either doesn't exist or is not supported. Please select a file with the following extensions...";
|
||||||
ImVec2 text_size = ImGui::CalcTextSize(text.c_str(), nullptr, true, 350 - style.WindowPadding.x * 2.0);
|
|
||||||
ImVec2 button_size = getButtonSize("OK");
|
ImVec2 button_size = getButtonSize("OK");
|
||||||
|
|
||||||
float frame_height = ImGui::GetFrameHeightWithSpacing();
|
float frame_height = ImGui::GetFrameHeightWithSpacing();
|
||||||
@@ -958,7 +952,7 @@ namespace imgui_addons
|
|||||||
|
|
||||||
ImGui::TextWrapped("%s", text.c_str());
|
ImGui::TextWrapped("%s", text.c_str());
|
||||||
ImGui::BeginChild("##SupportedExts", ImVec2(0, cw_height), true);
|
ImGui::BeginChild("##SupportedExts", ImVec2(0, cw_height), true);
|
||||||
for(int i = 0; i < valid_exts.size(); i++)
|
for(std::size_t i = 0; i < valid_exts.size(); i++)
|
||||||
ImGui::BulletText("%s", valid_exts[i].c_str());
|
ImGui::BulletText("%s", valid_exts[i].c_str());
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
@@ -1010,7 +1004,7 @@ namespace imgui_addons
|
|||||||
{
|
{
|
||||||
if(dialog_mode == DialogMode::SELECT)
|
if(dialog_mode == DialogMode::SELECT)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < subdirs.size(); i++)
|
for(std::size_t i = 0; i < subdirs.size(); i++)
|
||||||
{
|
{
|
||||||
if(subdirs[i].name == selected_fn)
|
if(subdirs[i].name == selected_fn)
|
||||||
{
|
{
|
||||||
@@ -1022,7 +1016,7 @@ namespace imgui_addons
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int i = 0; i < subfiles.size(); i++)
|
for(std::size_t i = 0; i < subfiles.size(); i++)
|
||||||
{
|
{
|
||||||
if(subfiles[i].name == selected_fn)
|
if(subfiles[i].name == selected_fn)
|
||||||
{
|
{
|
||||||
@@ -1051,7 +1045,7 @@ namespace imgui_addons
|
|||||||
if(ext == "*.*")
|
if(ext == "*.*")
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int idx = selected_fn.find_last_of('.');
|
auto idx = selected_fn.find_last_of('.');
|
||||||
std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx, selected_fn.length() - idx);
|
std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx, selected_fn.length() - idx);
|
||||||
return (std::find(valid_exts.begin(), valid_exts.end(), file_ext) != valid_exts.end());
|
return (std::find(valid_exts.begin(), valid_exts.end(), file_ext) != valid_exts.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ namespace imgui_addons
|
|||||||
|
|
||||||
ImVec2 min_size, max_size, input_combobox_pos, input_combobox_sz;
|
ImVec2 min_size, max_size, input_combobox_pos, input_combobox_sz;
|
||||||
DialogMode dialog_mode;
|
DialogMode dialog_mode;
|
||||||
int filter_mode, col_items_limit, selected_idx, selected_ext_idx;
|
std::size_t filter_mode, col_items_limit, selected_ext_idx;
|
||||||
|
int selected_idx;
|
||||||
float col_width, ext_box_width;
|
float col_width, ext_box_width;
|
||||||
bool show_hidden, show_inputbar_combobox, is_dir, is_appearing, filter_dirty, validate_file;
|
bool show_hidden, show_inputbar_combobox, is_dir, is_appearing, filter_dirty, validate_file;
|
||||||
char input_fn[256];
|
char input_fn[256];
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace GL{
|
|||||||
void VBO::bindVertexAttribs() const{
|
void VBO::bindVertexAttribs() const{
|
||||||
for(const VertexAttribPointer& pointer : m_VertexAttribs){
|
for(const VertexAttribPointer& pointer : m_VertexAttribs){
|
||||||
glEnableVertexAttribArray(pointer.m_Index);
|
glEnableVertexAttribArray(pointer.m_Index);
|
||||||
glVertexAttribPointer(pointer.m_Index, pointer.m_Size, GL_FLOAT, false, m_DataStride * sizeof(float), (void*) pointer.m_Offset);
|
glVertexAttribPointer(pointer.m_Index, pointer.m_Size, GL_FLOAT, false, m_DataStride * sizeof(float), (void*)(intptr_t) pointer.m_Offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,13 +98,13 @@ GL::VAO loadWorldModel(const td::game::World* world){
|
|||||||
positions.push_back(chunkX + tileX + 1);
|
positions.push_back(chunkX + tileX + 1);
|
||||||
positions.push_back(chunkY + tileY + 1);*/
|
positions.push_back(chunkY + tileY + 1);*/
|
||||||
|
|
||||||
const td::game::Color& tileColor = world->getTileColor(tile);
|
const td::game::Color* tileColor = world->getTileColor(tile);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++){
|
for (int i = 0; i < 6; i++){
|
||||||
int color = 255;
|
int color = 255;
|
||||||
color |= tileColor.r << 24;
|
color |= tileColor->r << 24;
|
||||||
color |= tileColor.g << 16;
|
color |= tileColor->g << 16;
|
||||||
color |= tileColor.b << 8;
|
color |= tileColor->b << 8;
|
||||||
|
|
||||||
int newColorIndex = colors.size();
|
int newColorIndex = colors.size();
|
||||||
colors.push_back(0);
|
colors.push_back(0);
|
||||||
|
|||||||
@@ -35,14 +35,6 @@ int ShaderProgram::getUniformLocation(const std::string& uniformName) const{
|
|||||||
const int location = glGetUniformLocation(programID, uniformName.c_str());
|
const int location = glGetUniformLocation(programID, uniformName.c_str());
|
||||||
if (location == -1){
|
if (location == -1){
|
||||||
std::cout << "Warning ! Uniform variable " << uniformName << " not found !\n";
|
std::cout << "Warning ! Uniform variable " << uniformName << " not found !\n";
|
||||||
const GLenum error = glGetError();
|
|
||||||
switch (error){
|
|
||||||
case GL_INVALID_VALUE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_INVALID_OPERATION:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
namespace Display {
|
namespace Display {
|
||||||
|
|
||||||
static GLFWwindow* window;
|
static GLFWwindow* window;
|
||||||
static bool closeRequested = false;
|
|
||||||
|
|
||||||
static int lastWidth = 0, lastHeight = 0;
|
static int lastWidth = 0, lastHeight = 0;
|
||||||
static float aspectRatio;
|
static float aspectRatio;
|
||||||
@@ -83,7 +82,7 @@ bool isCloseRequested() {
|
|||||||
return glfwWindowShouldClose(window);
|
return glfwWindowShouldClose(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool isMouseDown(int button) {
|
bool isMouseDown(int button) {
|
||||||
return glfwGetMouseButton(window, button);
|
return glfwGetMouseButton(window, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,16 @@ target("Tower Defense")
|
|||||||
-- strip all symbols
|
-- strip all symbols
|
||||||
add_ldflags("-s")
|
add_ldflags("-s")
|
||||||
|
|
||||||
|
set_warnings("all", "error")
|
||||||
|
|
||||||
set_optimize("smallest")
|
set_optimize("smallest")
|
||||||
|
|
||||||
if is_os("windows") then
|
if is_os("windows") then
|
||||||
add_ldflags("-static-libgcc", "-static-libstdc++", "-pthread")
|
add_ldflags("-static-libgcc", "-static-libstdc++", "-pthread")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
add_cxflags("-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused")
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user