- [NEW] Updatats de nou els Yamals de les habitacions
- [NEW] Es mostren les propietats dels enemics i els items quan els selecciones. - [NEW] misc::floatToString()
This commit is contained in:
@@ -133,12 +133,32 @@ bool loop()
|
||||
propertygrid::stringProperty("TILESET", room["room"]["tileSetFile"].get_value<std::string>());
|
||||
propertygrid::stringProperty("ITEMCOL1", room["room"]["itemColor1"].get_value<std::string>());
|
||||
propertygrid::stringProperty("ITEMCOL2", room["room"]["itemColor2"].get_value<std::string>());
|
||||
propertygrid::stringProperty("CONVEYOR", SDL_itoa(room["room"]["autoSurface"].get_value<int>(), tmp, 10));
|
||||
propertygrid::stringProperty("CONVEYOR", room["room"]["conveyorBelt"].get_value<std::string>());
|
||||
propertygrid::sectionProperty("CONNECTIONS:");
|
||||
propertygrid::stringProperty("UP", room["room"]["connections"]["up"].is_null()?"null":room["room"]["connections"]["up"].get_value<std::string>()+": "+rooms[room["room"]["connections"]["up"].get_value<std::string>()]);
|
||||
propertygrid::stringProperty("DOWN", room["room"]["connections"]["down"].is_null()?"null":room["room"]["connections"]["down"].get_value<std::string>()+": "+rooms[room["room"]["connections"]["down"].get_value<std::string>()]);
|
||||
propertygrid::stringProperty("LEFT", room["room"]["connections"]["left"].is_null()?"null":room["room"]["connections"]["left"].get_value<std::string>()+": "+rooms[room["room"]["connections"]["left"].get_value<std::string>()]);
|
||||
propertygrid::stringProperty("RIGHT", room["room"]["connections"]["right"].is_null()?"null":room["room"]["connections"]["right"].get_value<std::string>()+": "+rooms[room["room"]["connections"]["right"].get_value<std::string>()]);
|
||||
propertygrid::stringProperty("UP", room["room"]["connections"]["up"].is_null()?"null":room["room"]["connections"]["up"].get_value<std::string>().substr(0,2)+": "+rooms[room["room"]["connections"]["up"].get_value<std::string>().substr(0,2)]);
|
||||
propertygrid::stringProperty("DOWN", room["room"]["connections"]["down"].is_null()?"null":room["room"]["connections"]["down"].get_value<std::string>().substr(0,2)+": "+rooms[room["room"]["connections"]["down"].get_value<std::string>().substr(0,2)]);
|
||||
propertygrid::stringProperty("LEFT", room["room"]["connections"]["left"].is_null()?"null":room["room"]["connections"]["left"].get_value<std::string>().substr(0,2)+": "+rooms[room["room"]["connections"]["left"].get_value<std::string>().substr(0,2)]);
|
||||
propertygrid::stringProperty("RIGHT", room["room"]["connections"]["right"].is_null()?"null":room["room"]["connections"]["right"].get_value<std::string>().substr(0,2)+": "+rooms[room["room"]["connections"]["right"].get_value<std::string>().substr(0,2)]);
|
||||
} else {
|
||||
const int num_enemies = room.at("enemies").as_seq().size();
|
||||
if (treeview::getSelected(2) < num_enemies) {
|
||||
auto enemy = room.at("enemies").as_seq()[treeview::getSelected(2)];
|
||||
propertygrid::sectionProperty("ENEMY:");
|
||||
propertygrid::stringProperty("ANIMATION", enemy["animation"].get_value<std::string>());
|
||||
propertygrid::stringProperty("POSITION", std::to_string(enemy["position"]["x"].get_value<int>())+std::string(", ")+std::to_string(enemy["position"]["y"].get_value<int>()));
|
||||
propertygrid::stringProperty("VELOCITY", misc::floatToString(enemy["velocity"]["x"].get_value<float>())+std::string(", ")+misc::floatToString(enemy["velocity"]["y"].get_value<float>()));
|
||||
propertygrid::stringProperty("COLOR", enemy["color"].get_value<std::string>());
|
||||
propertygrid::sectionProperty("BOUNDARIES:");
|
||||
propertygrid::stringProperty("START", std::to_string(enemy["boundaries"]["position1"]["x"].get_value<int>())+std::string(", ")+std::to_string(enemy["boundaries"]["position1"]["y"].get_value<int>()));
|
||||
propertygrid::stringProperty("END", std::to_string(enemy["boundaries"]["position2"]["x"].get_value<int>())+std::string(", ")+std::to_string(enemy["boundaries"]["position2"]["y"].get_value<int>()));
|
||||
} else {
|
||||
auto item = room.at("items").as_seq()[treeview::getSelected(2)-num_enemies];
|
||||
propertygrid::sectionProperty("ITEM:");
|
||||
propertygrid::stringProperty("TILESET", item["tileSetFile"].get_value<std::string>());
|
||||
propertygrid::stringProperty("TILE", std::to_string(item["tile"].get_value<int>()));
|
||||
propertygrid::stringProperty("POSITION", std::to_string(item["position"]["x"].get_value<int>())+std::string(", ")+std::to_string(item["position"]["y"].get_value<int>()));
|
||||
propertygrid::stringProperty("COUNTER", std::to_string(item["counter"].get_value<int>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
propertygrid::end();
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "misc.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
namespace misc
|
||||
{
|
||||
@@ -8,4 +12,12 @@ namespace misc
|
||||
for (int i=0; i<17; ++i) if (colors[i] == color) return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
std::string floatToString(float value, int decimals)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::fixed << std::setprecision(decimals) << value;
|
||||
return oss.str();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
namespace misc
|
||||
{
|
||||
int getColorByName(std::string color);
|
||||
std::string floatToString(float value, int decimals=2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user