a bunch of changes
This commit is contained in:
parent
1e0dfc4570
commit
8f01039689
20 changed files with 577 additions and 120 deletions
|
|
@ -11,7 +11,9 @@ add_subdirectory(Tools/MapTools)
|
||||||
|
|
||||||
add_executable(SpoonEdit src/main.cpp src/PropertiesWidget.cpp src/PropertiesWidget.h src/ObjectSelectWidget.cpp src/ObjectSelectWidget.h src/MainViewport.cpp src/MainViewport.h src/Model.cpp src/Model.h src/RailSelectWidget.cpp src/RailSelectWidget.h src/Config/Configs.h src/Config/Configs.cpp
|
add_executable(SpoonEdit src/main.cpp src/PropertiesWidget.cpp src/PropertiesWidget.h src/ObjectSelectWidget.cpp src/ObjectSelectWidget.h src/MainViewport.cpp src/MainViewport.h src/Model.cpp src/Model.h src/RailSelectWidget.cpp src/RailSelectWidget.h src/Config/Configs.h src/Config/Configs.cpp
|
||||||
src/InstanceVars.h
|
src/InstanceVars.h
|
||||||
src/Objects.cpp)
|
src/Objects.cpp
|
||||||
|
src/MapGenOut.cpp
|
||||||
|
src/MapMirroring.cpp)
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,66 +22,6 @@ enum LayerConfig{
|
||||||
Temporary //Tmp
|
Temporary //Tmp
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::string ToStringYaml(LayerConfig cfg){
|
|
||||||
if(cfg == Common){
|
|
||||||
return "Cmn";
|
|
||||||
} else if(cfg == Paint){
|
|
||||||
return "Pnt";
|
|
||||||
} else if(cfg == Rainmaker) {
|
|
||||||
return "Vlf";
|
|
||||||
} else if(cfg == Tower) {
|
|
||||||
return "Vgl";
|
|
||||||
} else if(cfg == Area) {
|
|
||||||
return "Var";
|
|
||||||
} else if(cfg == Night) {
|
|
||||||
return "Night";
|
|
||||||
} else if(cfg == Day) {
|
|
||||||
return "Day";
|
|
||||||
} else if(cfg == Temporary) {
|
|
||||||
return "Tmp";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string ToString(LayerConfig cfg){
|
|
||||||
if(cfg == Common){
|
|
||||||
return "Common";
|
|
||||||
} else if(cfg == Paint){
|
|
||||||
return "Paint";
|
|
||||||
} else if(cfg == Rainmaker) {
|
|
||||||
return "Rainmaker";
|
|
||||||
} else if(cfg == Tower) {
|
|
||||||
return "Tower";
|
|
||||||
} else if(cfg == Area) {
|
|
||||||
return "Area";
|
|
||||||
} else if(cfg == Night) {
|
|
||||||
return "Night";
|
|
||||||
} else if(cfg == Day) {
|
|
||||||
return "Day";
|
|
||||||
} else if(cfg == Temporary) {
|
|
||||||
return "Temporary";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LayerConfig ToLayerConfig(std::string cfg){
|
|
||||||
if(cfg == "Cmn"){
|
|
||||||
return Common;
|
|
||||||
} else if(cfg == "Pnt"){
|
|
||||||
return Paint;
|
|
||||||
} else if(cfg == "Vlf") {
|
|
||||||
return Rainmaker;
|
|
||||||
} else if(cfg == "Vgl") {
|
|
||||||
return Tower;
|
|
||||||
} else if(cfg == "Var") {
|
|
||||||
return Area;
|
|
||||||
} else if(cfg == "Night") {
|
|
||||||
return Night;
|
|
||||||
} else if(cfg == "Day") {
|
|
||||||
return Day;
|
|
||||||
} else if(cfg == "Tmp") {
|
|
||||||
return Temporary;
|
|
||||||
} else return Temporary;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Element{
|
class Element{
|
||||||
public:
|
public:
|
||||||
Element() = default;
|
Element() = default;
|
||||||
|
|
@ -106,11 +46,11 @@ public:
|
||||||
std::map<std::string,std::string> OtherOptions = std::map<std::string,std::string>();
|
std::map<std::string,std::string> OtherOptions = std::map<std::string,std::string>();
|
||||||
|
|
||||||
bool IsLinkDest = false;
|
bool IsLinkDest = false;
|
||||||
void YamlInsert(YAML::Emitter &Emitter);
|
void YamlInsert(YAML::Emitter &Emitter,bool compiled = false);
|
||||||
|
|
||||||
virtual ~Element() = default;
|
virtual ~Element() = default;
|
||||||
protected:
|
protected:
|
||||||
virtual void YamlInsertBody(YAML::Emitter &Emitter);
|
virtual void YamlInsertBody(YAML::Emitter &Emitter,bool compiled = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SPOONTOOL_ELEMENT_H
|
#endif //SPOONTOOL_ELEMENT_H
|
||||||
|
|
@ -18,18 +18,14 @@ namespace Teams{
|
||||||
constexpr long Enemy = 1;
|
constexpr long Enemy = 1;
|
||||||
constexpr long Neutral = 2;
|
constexpr long Neutral = 2;
|
||||||
|
|
||||||
constexpr std::array<long,3> AllOptions = {Player,Neutral,Enemy};
|
inline long flipTeam(long team){
|
||||||
|
|
||||||
inline constexpr std::string TeamToText(long team) {
|
|
||||||
switch(team){
|
switch(team){
|
||||||
case 0:
|
case Player:
|
||||||
return "Player";
|
return Enemy;
|
||||||
case 1:
|
case Enemy:
|
||||||
return "Enemy";
|
return Player;
|
||||||
case 2:
|
|
||||||
return "Neutral";
|
|
||||||
default:
|
default:
|
||||||
return "Invalid";
|
return team;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,10 +73,11 @@ struct LevelObject: public Element{
|
||||||
LevelObject(const YAML::Node &ObjNode);
|
LevelObject(const YAML::Node &ObjNode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void YamlInsertBody(YAML::Emitter &Emitter) override;
|
void YamlInsertBody(YAML::Emitter &Emitter,bool compiled = false) override;
|
||||||
public:
|
public:
|
||||||
long Team;
|
long Team;
|
||||||
long DropId;
|
long DropId;
|
||||||
|
bool m_isStatic;
|
||||||
|
|
||||||
~LevelObject() = default;
|
~LevelObject() = default;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,17 @@
|
||||||
#include<boost/filesystem.hpp>
|
#include<boost/filesystem.hpp>
|
||||||
#include<LevelObject.h>
|
#include<LevelObject.h>
|
||||||
#include<Rail.h>
|
#include<Rail.h>
|
||||||
|
#include<filesystem>
|
||||||
|
|
||||||
|
struct FieldOptions{
|
||||||
|
std::string m_fieldName = "Fld_Unk";
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
struct Map {
|
struct Map {
|
||||||
//STREEFUNCS
|
|
||||||
Map();
|
Map();
|
||||||
|
//Loads file from custom map format
|
||||||
|
Map(boost::filesystem::path file);
|
||||||
|
|
||||||
void Save(boost::filesystem::path FileLocation);
|
void Save(boost::filesystem::path FileLocation);
|
||||||
|
|
||||||
|
|
@ -20,16 +26,19 @@ struct Map {
|
||||||
|
|
||||||
void Export(boost::filesystem::path YamlOut);
|
void Export(boost::filesystem::path YamlOut);
|
||||||
|
|
||||||
std::vector<LevelObject> Objects;
|
std::list<LevelObject> Objects;
|
||||||
|
|
||||||
std::vector<Rail> Rails;
|
std::list<Rail> Rails;
|
||||||
|
|
||||||
|
std::filesystem::path m_filePath;
|
||||||
|
|
||||||
|
FieldOptions m_fieldOptions;
|
||||||
|
|
||||||
Element* GetElementById(std::string id);
|
Element* GetElementById(std::string id);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Map ConvertFromYaml(boost::filesystem::path File);
|
Map ConvertFromYaml(boost::filesystem::path File);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //SPOONTOOL_MAP_H
|
#endif //SPOONTOOL_MAP_H
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ struct Rail: public Element{
|
||||||
~Rail() override = default;
|
~Rail() override = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void YamlInsertBody(YAML::Emitter &Emitter) override;
|
void YamlInsertBody(YAML::Emitter &Emitter,bool compiled = false) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SPOONTOOL_RAIL_H
|
#endif //SPOONTOOL_RAIL_H
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ struct RailPoint: public Element{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void YamlInsertBody(YAML::Emitter &Emitter) override;
|
void YamlInsertBody(YAML::Emitter &Emitter,bool compiled = false) override;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::vector<Vector3> m_controlPoints = std::vector<Vector3>();
|
std::vector<Vector3> m_controlPoints = std::vector<Vector3>();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockList) {
|
Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockList) {
|
||||||
|
|
||||||
PropertyBlockList.emplace_back("Id");
|
PropertyBlockList.emplace_back("Id");
|
||||||
PropertyBlockList.emplace_back("UnitConfigName");
|
PropertyBlockList.emplace_back("UnitConfigName");
|
||||||
PropertyBlockList.emplace_back("LayerConfigName");
|
PropertyBlockList.emplace_back("LayerConfigName");
|
||||||
|
|
@ -76,13 +75,13 @@ Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Element::YamlInsert(YAML::Emitter &Emitter) {
|
void Element::YamlInsert(YAML::Emitter &Emitter,bool compiled) {
|
||||||
Emitter << YAML::BeginMap;
|
Emitter << YAML::BeginMap;
|
||||||
YamlInsertBody(Emitter);
|
YamlInsertBody(Emitter,compiled);
|
||||||
Emitter << YAML::EndMap;
|
Emitter << YAML::EndMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Element::YamlInsertBody(YAML::Emitter &Emitter) {
|
void Element::YamlInsertBody(YAML::Emitter &Emitter,bool compiled) {
|
||||||
Emitter << YAML::Key << "Id" << YAML::Value << Name;
|
Emitter << YAML::Key << "Id" << YAML::Value << Name;
|
||||||
|
|
||||||
TF.InsertIntoYaml(Emitter);
|
TF.InsertIntoYaml(Emitter);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
#include<LevelObject.h>
|
#include<LevelObject.h>
|
||||||
#include<SpecialObjectParamVersions/All.h>
|
#include<SpecialObjectParamVersions/All.h>
|
||||||
|
|
||||||
LevelObject::LevelObject(const YAML::Node &ObjNode): Element(ObjNode,{"Team","DropId"}) {
|
LevelObject::LevelObject(const YAML::Node &ObjNode): Element(ObjNode,{"Team","DropId","IsStatic"}) {
|
||||||
Team = ObjNode["Team"].as<long>(-1);
|
Team = ObjNode["Team"].as<long>(-1);
|
||||||
DropId = ObjNode["DropId"].as<long>(DropId::Default);
|
DropId = ObjNode["DropId"].as<long>(DropId::Default);
|
||||||
|
m_isStatic = ObjNode["IsStatic"].as<bool>(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelObject::YamlInsertBody(YAML::Emitter &Emitter) {
|
void LevelObject::YamlInsertBody(YAML::Emitter &Emitter,bool compiled) {
|
||||||
Element::YamlInsertBody(Emitter);
|
Element::YamlInsertBody(Emitter);
|
||||||
Emitter << YAML::Key << "Team" << YAML::Value << YAML::LocalTag("l") << Team;
|
Emitter << YAML::Key << "Team" << YAML::Value << YAML::LocalTag("l") << Team;
|
||||||
Emitter << YAML::Key << "DropId" << YAML::Value << YAML::LocalTag("l") << DropId;
|
Emitter << YAML::Key << "DropId" << YAML::Value << YAML::LocalTag("l") << DropId;
|
||||||
|
if(!compiled){
|
||||||
|
Emitter << YAML::Key << "IsStatic" << YAML::Value << m_isStatic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,8 +17,76 @@ Map::Map(): Objects(), Rails() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::Save(boost::filesystem::path FileLocation) {
|
Map::Map(boost::filesystem::path file): Objects(), Rails(), m_fieldOptions() {
|
||||||
|
|
||||||
|
YAML::Node MapYaml = YAML::LoadFile(file.generic_string());
|
||||||
|
|
||||||
|
auto FldOpts = MapYaml["MapGenInfo"];
|
||||||
|
|
||||||
|
m_fieldOptions.m_fieldName = FldOpts["FldName"].as<std::string>();
|
||||||
|
|
||||||
|
auto ObjList = MapYaml["Objects"];
|
||||||
|
|
||||||
|
if(!ObjList.IsSequence()) throw std::runtime_error("Something went Wrong!");
|
||||||
|
|
||||||
|
|
||||||
|
for (YAML::iterator it = ObjList.begin(); it != ObjList.end(); it++) {
|
||||||
|
const YAML::Node& obj = *it;
|
||||||
|
|
||||||
|
Objects.push_back(LevelObject(obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto RailList = MapYaml["Rails"];
|
||||||
|
|
||||||
|
if(!RailList.IsSequence()) throw std::runtime_error("Failed to load map:\n\tRail list isn't a sequence");
|
||||||
|
|
||||||
|
for (YAML::iterator it = RailList.begin(); it != RailList.end(); it++) {
|
||||||
|
const YAML::Node& obj = *it;
|
||||||
|
|
||||||
|
Rail newObj(obj);
|
||||||
|
|
||||||
|
Rails.push_back(newObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Map::Save(boost::filesystem::path FileLocation) {
|
||||||
|
YAML::Emitter Emitter;
|
||||||
|
|
||||||
|
Emitter << YAML::BeginMap;
|
||||||
|
//Emitter << YAML::
|
||||||
|
|
||||||
|
Emitter << YAML::Key << "MapGenInfo" << YAML::BeginMap;
|
||||||
|
{
|
||||||
|
Emitter << YAML::Key << "FldName" << YAML::Value << m_fieldOptions.m_fieldName;
|
||||||
|
}
|
||||||
|
Emitter << YAML::EndMap;
|
||||||
|
|
||||||
|
Emitter << YAML::Key << "Objects" << YAML::BeginSeq;
|
||||||
|
|
||||||
|
for(auto& obj: Objects){
|
||||||
|
obj.YamlInsert(Emitter);
|
||||||
|
}
|
||||||
|
//Objs
|
||||||
|
Emitter << YAML::EndSeq;
|
||||||
|
|
||||||
|
Emitter << YAML::Key << "Rails" << YAML::BeginSeq;
|
||||||
|
|
||||||
|
for(auto obj: Rails){
|
||||||
|
obj.YamlInsert(Emitter);
|
||||||
|
}
|
||||||
|
Emitter << YAML::EndSeq;
|
||||||
|
//main document
|
||||||
|
Emitter << YAML::EndMap;
|
||||||
|
|
||||||
|
std::ofstream file(FileLocation.string());
|
||||||
|
|
||||||
|
std::string str = Emitter.c_str();
|
||||||
|
|
||||||
|
boost::algorithm::replace_all(str,"~","null");
|
||||||
|
|
||||||
|
file << str;
|
||||||
|
file.flush();
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::Export(boost::filesystem::path YamlOut) {
|
void Map::Export(boost::filesystem::path YamlOut) {
|
||||||
|
|
@ -36,7 +104,7 @@ void Map::Export(boost::filesystem::path YamlOut) {
|
||||||
Emitter << YAML::Key << "Objs" << YAML::BeginSeq;
|
Emitter << YAML::Key << "Objs" << YAML::BeginSeq;
|
||||||
|
|
||||||
for(auto& obj: Objects){
|
for(auto& obj: Objects){
|
||||||
obj.YamlInsert(Emitter);
|
obj.YamlInsert(Emitter,true);
|
||||||
}
|
}
|
||||||
//Objs
|
//Objs
|
||||||
Emitter << YAML::EndSeq;
|
Emitter << YAML::EndSeq;
|
||||||
|
|
@ -44,7 +112,7 @@ void Map::Export(boost::filesystem::path YamlOut) {
|
||||||
Emitter << YAML::Key << "Rails" << YAML::BeginSeq;
|
Emitter << YAML::Key << "Rails" << YAML::BeginSeq;
|
||||||
|
|
||||||
for(auto obj: Rails){
|
for(auto obj: Rails){
|
||||||
obj.YamlInsert(Emitter);
|
obj.YamlInsert(Emitter,true);
|
||||||
}
|
}
|
||||||
Emitter << YAML::EndSeq;
|
Emitter << YAML::EndSeq;
|
||||||
|
|
||||||
|
|
@ -104,6 +172,8 @@ Map ConvertFromYaml(boost::filesystem::path File){
|
||||||
|
|
||||||
auto RailList = RootNode["Rails"];
|
auto RailList = RootNode["Rails"];
|
||||||
|
|
||||||
|
if(!RailList.IsSequence()) throw std::runtime_error("Something went Wrong!");
|
||||||
|
|
||||||
for (YAML::iterator it = RailList.begin(); it != RailList.end(); it++) {
|
for (YAML::iterator it = RailList.begin(); it != RailList.end(); it++) {
|
||||||
const YAML::Node& obj = *it;
|
const YAML::Node& obj = *it;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ Rail::Rail(const Vector3 &Position) {
|
||||||
Points.emplace_back(Position);
|
Points.emplace_back(Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rail::YamlInsertBody(YAML::Emitter &Emitter) {
|
void Rail::YamlInsertBody(YAML::Emitter &Emitter,bool compiled) {
|
||||||
Element::YamlInsertBody(Emitter);
|
Element::YamlInsertBody(Emitter);
|
||||||
|
|
||||||
Emitter << YAML::Key << "RailPoints" << YAML::BeginSeq;
|
Emitter << YAML::Key << "RailPoints" << YAML::BeginSeq;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ RailPoint::RailPoint(const Vector3 &pos) {
|
||||||
m_controlPoints.push_back(pos);
|
m_controlPoints.push_back(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RailPoint::YamlInsertBody(YAML::Emitter &Emitter) {
|
void RailPoint::YamlInsertBody(YAML::Emitter &Emitter,bool compiled) {
|
||||||
Element::YamlInsertBody(Emitter);
|
Element::YamlInsertBody(Emitter);
|
||||||
Emitter << YAML::Key << "ControlPoints" << YAML::BeginSeq;
|
Emitter << YAML::Key << "ControlPoints" << YAML::BeginSeq;
|
||||||
for(auto ctrlPoint: m_controlPoints){
|
for(auto ctrlPoint: m_controlPoints){
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,18 @@ namespace Configs {
|
||||||
|
|
||||||
template<typename t>
|
template<typename t>
|
||||||
void g_imguiDrawOpts(std::string id, std::vector<ValueDisplayOptions<t>> opts, t &val){
|
void g_imguiDrawOpts(std::string id, std::vector<ValueDisplayOptions<t>> opts, t &val){
|
||||||
|
std::string disp;
|
||||||
|
|
||||||
auto selOpt = std::find_if(opts.begin(), opts.end(),[&](const ValueDisplayOptions<t> &opt){
|
auto selOpt = std::find_if(opts.begin(), opts.end(),[&](const ValueDisplayOptions<t> &opt){
|
||||||
return val == opt.m_val;
|
return val == opt.m_val;
|
||||||
});
|
});
|
||||||
|
if(selOpt != opts.end())
|
||||||
|
disp = selOpt->m_display;
|
||||||
|
else
|
||||||
|
disp = "Invalid Layer";
|
||||||
|
|
||||||
if(ImGui::BeginCombo(id.c_str(),selOpt->m_display.c_str())){
|
|
||||||
|
if(ImGui::BeginCombo(id.c_str(),disp.c_str())){
|
||||||
for(const auto &opt: opts) {
|
for(const auto &opt: opts) {
|
||||||
if (ImGui::Selectable((opt.m_display + "##" + id).c_str()))
|
if (ImGui::Selectable((opt.m_display + "##" + id).c_str()))
|
||||||
val = opt.m_val;
|
val = opt.m_val;
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,11 @@ MainViewport::MainViewport() : Graphics::ViewportWidget("Main Viewport", true),
|
||||||
CamPosLoc = m_internalFramebuf->m_shader.getUniformLocation("CameraPosition");
|
CamPosLoc = m_internalFramebuf->m_shader.getUniformLocation("CameraPosition");
|
||||||
LightDirId = m_internalFramebuf->m_shader.getUniformLocation("LightDirection");
|
LightDirId = m_internalFramebuf->m_shader.getUniformLocation("LightDirection");
|
||||||
SunVpLoc = m_internalFramebuf->m_shader.getUniformLocation("SunVP");
|
SunVpLoc = m_internalFramebuf->m_shader.getUniformLocation("SunVP");
|
||||||
|
distribLoc = m_internalFramebuf->m_shader.getUniformLocation("distribution");
|
||||||
|
shadHardLoc = m_internalFramebuf->m_shader.getUniformLocation("shadowHardness");
|
||||||
|
|
||||||
|
//Todo: update
|
||||||
|
camFwdDir = flatShader.getUniformLocation("CamFwdDir");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,12 +168,11 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 projectionMatrix = glm::perspective(
|
glm::mat4 projectionMatrix = glm::perspective(
|
||||||
glm::radians(
|
glm::radians(fov),
|
||||||
fov), // The vertical Field of View, in radians: the amount of "zoom". Think "camera lens". Usually between 90° (extra wide) and 30° (quite zoomed in)
|
|
||||||
(float) m_internalFramebuf->getSize().x /
|
(float) m_internalFramebuf->getSize().x /
|
||||||
(float) m_internalFramebuf->getSize().y, // Aspect Ratio. Depends on the size of your window. Notice that 4/3 == 800/600 == 1280/960, sounds familiar ?
|
(float) m_internalFramebuf->getSize().y,
|
||||||
NearClippingPlane, // Near clipping plane. Keep as big as possible, or you'll get precision issues.
|
NearClippingPlane,
|
||||||
FarClippingPlane // Far clipping plane. Keep as little as possible.
|
FarClippingPlane
|
||||||
);
|
);
|
||||||
|
|
||||||
//glm::mat4 ViewMatrix = glm::translate(glm::mat4(1.0f), -camPos);
|
//glm::mat4 ViewMatrix = glm::translate(glm::mat4(1.0f), -camPos);
|
||||||
|
|
@ -176,7 +180,7 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
VP = projectionMatrix * ViewMatrix;// * ViewMatrix * ModelMat;
|
VP = projectionMatrix * ViewMatrix;// * ViewMatrix * ModelMat;
|
||||||
|
|
||||||
glUniform3f(CamPosLoc, camPos.x,camPos.y,camPos.z);
|
|
||||||
|
|
||||||
if (ImGui::BeginPopup("Main VP Debug")) {
|
if (ImGui::BeginPopup("Main VP Debug")) {
|
||||||
ImGui::DragFloat3("Camera Postion", &camPos.x, 0.01);
|
ImGui::DragFloat3("Camera Postion", &camPos.x, 0.01);
|
||||||
|
|
@ -185,6 +189,8 @@ void MainViewport::Draw() {
|
||||||
ImGui::DragFloat("Speed", &speed, 1);
|
ImGui::DragFloat("Speed", &speed, 1);
|
||||||
ImGui::DragFloat("Near Clipping Plane", &NearClippingPlane, 1);
|
ImGui::DragFloat("Near Clipping Plane", &NearClippingPlane, 1);
|
||||||
ImGui::DragFloat("Far Clipping Plane", &FarClippingPlane, 1);
|
ImGui::DragFloat("Far Clipping Plane", &FarClippingPlane, 1);
|
||||||
|
ImGui::DragFloat("Shadow Smoothing", &m_smoothingFactor, 1);
|
||||||
|
ImGui::DragFloat("Shadow Hardness", &m_shadowHardness, 1);
|
||||||
ImGui::DragFloat("Shadow Area", &shadowArea, 0.01);
|
ImGui::DragFloat("Shadow Area", &shadowArea, 0.01);
|
||||||
//ImGui::SliderFloat("Shading Effectiveness", &ShadingEffectiveness, 0, 1);
|
//ImGui::SliderFloat("Shading Effectiveness", &ShadingEffectiveness, 0, 1);
|
||||||
ImGui::DragFloat3("Light Direction", &LightDir.x, 0.01);
|
ImGui::DragFloat3("Light Direction", &LightDir.x, 0.01);
|
||||||
|
|
@ -209,8 +215,12 @@ void MainViewport::Draw() {
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_internalFramebuf->m_shader.use();
|
glUniform3f(CamPosLoc, camPos.x,camPos.y,camPos.z);
|
||||||
|
|
||||||
|
glUniform1f(distribLoc, m_smoothingFactor);
|
||||||
|
glUniform1f(shadHardLoc, m_shadowHardness);
|
||||||
|
|
||||||
|
m_internalFramebuf->m_shader.use();
|
||||||
|
|
||||||
|
|
||||||
if(!flatShading)
|
if(!flatShading)
|
||||||
|
|
@ -218,6 +228,9 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
|
||||||
|
glUniform3f(camFwdDir, cameraDirection.x, cameraDirection.y, cameraDirection.z);
|
||||||
|
|
||||||
glDrawBuffer(GL_COLOR_ATTACHMENT1);
|
glDrawBuffer(GL_COLOR_ATTACHMENT1);
|
||||||
GLuint ClearID[] = {0};
|
GLuint ClearID[] = {0};
|
||||||
glClearBufferuiv(GL_COLOR, 0, ClearID);
|
glClearBufferuiv(GL_COLOR, 0, ClearID);
|
||||||
|
|
@ -232,11 +245,11 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
if(!flatShading) {
|
if(!flatShading) {
|
||||||
|
|
||||||
glm::vec3 SunPos = (glm::normalize(LightDir) * 1500.0f) + camPos;
|
glm::vec3 SunPos = glm::normalize(LightDir) * 2000.0f;
|
||||||
|
|
||||||
glm::mat4 SunProj = glm::ortho(-shadowArea, shadowArea, -shadowArea, shadowArea, 1.0f, 4000.0f);
|
glm::mat4 SunProj = glm::ortho(-shadowArea, shadowArea, -shadowArea, shadowArea, 500.0f, 3000.0f );
|
||||||
|
|
||||||
glm::mat4 SunView = glm::lookAt(SunPos, camPos, {0, 1, 0});
|
glm::mat4 SunView = glm::lookAt(SunPos, {0, 0, 0}, {0, 1, 0});
|
||||||
|
|
||||||
glm::mat4 SunVP = SunProj * SunView;
|
glm::mat4 SunVP = SunProj * SunView;
|
||||||
|
|
||||||
|
|
@ -301,7 +314,6 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
|
|
||||||
for (auto &obj: loadedMap.Objects) {
|
for (auto &obj: loadedMap.Objects) {
|
||||||
if(!flatShading)
|
|
||||||
glUniform1i(TeamId,(GLint)obj.Team);
|
glUniform1i(TeamId,(GLint)obj.Team);
|
||||||
|
|
||||||
if (IsArea(obj.Type) && !drawAllAreas) {
|
if (IsArea(obj.Type) && !drawAllAreas) {
|
||||||
|
|
@ -368,9 +380,9 @@ void MainViewport::Draw() {
|
||||||
|
|
||||||
//mdl.DrawSelection(selobj->TF);
|
//mdl.DrawSelection(selobj->TF);
|
||||||
|
|
||||||
//glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/*if (CurrentGizmoType == Move) {
|
if (CurrentGizmoType == Move) {
|
||||||
static Model Arrow = Model("St_Arrow");
|
static Model Arrow = Model("St_Arrow");
|
||||||
|
|
||||||
auto tf = Transform();
|
auto tf = Transform();
|
||||||
|
|
@ -463,7 +475,7 @@ void MainViewport::Draw() {
|
||||||
Rotator.Draw(tf, m_internalFramebuf->m_shader, VP);
|
Rotator.Draw(tf, m_internalFramebuf->m_shader, VP);
|
||||||
|
|
||||||
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
glUniform4f(ObjColPos, 1, 1, 1, 1);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -624,7 +636,14 @@ void MainViewport::HandleInput(InputEvent event) {
|
||||||
|
|
||||||
obj -= 16;
|
obj -= 16;
|
||||||
|
|
||||||
selectedElem = &loadedMap.Objects[obj];
|
auto iter = loadedMap.Objects.begin();
|
||||||
|
|
||||||
|
while(obj != 0){
|
||||||
|
iter++;
|
||||||
|
obj--;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedElem = &*iter;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case (InputType::MouseHoldL): {
|
case (InputType::MouseHoldL): {
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,14 @@ public:
|
||||||
void clearModels();
|
void clearModels();
|
||||||
|
|
||||||
void cleanUnnescessary();
|
void cleanUnnescessary();
|
||||||
|
|
||||||
|
std::unordered_map<std::string,Model> MdlFromObj;
|
||||||
|
|
||||||
|
glm::mat4 VP;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
float shadowArea = 750.0f;
|
float shadowArea = 1500.0f;
|
||||||
|
|
||||||
Graphics::Shader flatShader;
|
Graphics::Shader flatShader;
|
||||||
Graphics::Shader defaultShader;
|
Graphics::Shader defaultShader;
|
||||||
|
|
@ -56,12 +61,14 @@ private:
|
||||||
|
|
||||||
unsigned int HoveredObjId = 0;
|
unsigned int HoveredObjId = 0;
|
||||||
|
|
||||||
std::unordered_map<std::string,Model> MdlFromObj;
|
|
||||||
|
|
||||||
float FarClippingPlane = 10000.0f;
|
float FarClippingPlane = 10000.0f;
|
||||||
float NearClippingPlane = 0.1f;
|
float NearClippingPlane = 0.1f;
|
||||||
|
float m_smoothingFactor = 1.0f;
|
||||||
|
float m_shadowHardness = 2.5f;
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 VP;
|
|
||||||
|
|
||||||
glm::vec3 LightDir = {1,1,1};
|
glm::vec3 LightDir = {1,1,1};
|
||||||
|
|
||||||
|
|
@ -88,6 +95,9 @@ private:
|
||||||
GLint CamPosLoc;
|
GLint CamPosLoc;
|
||||||
GLint LightDirId;
|
GLint LightDirId;
|
||||||
GLint SunVpLoc;
|
GLint SunVpLoc;
|
||||||
|
GLint distribLoc;
|
||||||
|
GLint shadHardLoc;
|
||||||
|
GLint camFwdDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
219
src/MapGenOut.cpp
Normal file
219
src/MapGenOut.cpp
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
//
|
||||||
|
// Created by tv on 01.10.23.
|
||||||
|
//
|
||||||
|
#include<virintox/gcore/Graphics.h>
|
||||||
|
#include "virintox/gcore/Shader.h"
|
||||||
|
#include "virintox/gcore/Texture.h"
|
||||||
|
#include "virintox/gcore/Framebuffer.h"
|
||||||
|
#include"InstanceVars.h"
|
||||||
|
#include "glm/mat4x4.hpp"
|
||||||
|
#include "MainViewport.h"
|
||||||
|
#include "glm/ext/matrix_transform.hpp"
|
||||||
|
#include "glm/ext/matrix_clip_space.hpp"
|
||||||
|
#include "virintox/gcore/gui/FileSelectDialog.h"
|
||||||
|
#include<imgui.h>
|
||||||
|
#include<boost/filesystem.hpp>
|
||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
#include<virintox/gcore/stb_image_write.h>
|
||||||
|
|
||||||
|
MENU_ITEM(Widgets,MapGeneration){
|
||||||
|
Graphics::window->WidgetByName.find("MapGen")->second->Active ^= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MENU_ITEM(Object, Duenschiss){
|
||||||
|
for(auto iter = loadedMap.Objects.begin(); iter != loadedMap.Objects.end(); iter++){
|
||||||
|
if(iter->Type == "Enm_Takodozer"){
|
||||||
|
auto itertemp = iter;
|
||||||
|
iter--;
|
||||||
|
loadedMap.Objects.erase(itertemp);
|
||||||
|
selectedElem = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(iter->Layer == "Tmp"){
|
||||||
|
auto itertemp = iter;
|
||||||
|
iter--;
|
||||||
|
loadedMap.Objects.erase(itertemp);
|
||||||
|
selectedElem = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Color{
|
||||||
|
unsigned char r;
|
||||||
|
unsigned char g;
|
||||||
|
unsigned char b;
|
||||||
|
unsigned char a;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MapGenWidget: public Graphics::Widget {
|
||||||
|
public:
|
||||||
|
VCLASS(MapGenWidget,ESC({&Graphics::Widget::classInfo,nullptr}))
|
||||||
|
MapGenWidget(): Graphics::Widget("MapGen"), m_shader("MapGen"), m_shaderPP("MapGenPP") , m_maptex(boost::filesystem::current_path() / "Models" / "Maptex.png"),
|
||||||
|
m_quadMesh({
|
||||||
|
{-1,-1},
|
||||||
|
{1 ,-1},
|
||||||
|
{-1, 1},
|
||||||
|
{ 1, 1},
|
||||||
|
},{
|
||||||
|
2,1,0,
|
||||||
|
2,3,1,
|
||||||
|
}){
|
||||||
|
g_instance = this;
|
||||||
|
|
||||||
|
|
||||||
|
setup();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::unique_ptr<Graphics::Framebuffer> m_framebuffer;
|
||||||
|
Graphics::Shader m_shader;
|
||||||
|
Graphics::Texture m_maptex;
|
||||||
|
//PP = post processing
|
||||||
|
std::unique_ptr<Graphics::Framebuffer> m_framebufferPP;
|
||||||
|
Graphics::Shader m_shaderPP;
|
||||||
|
Graphics::Mesh m_quadMesh;
|
||||||
|
glm::mat4 m_camMatrix = glm::mat4(1);
|
||||||
|
int m_size = 1600;
|
||||||
|
int m_imgSize = 1600;
|
||||||
|
void drawTex(){
|
||||||
|
m_framebuffer->bind();
|
||||||
|
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
GLint maptexLoc = m_shader.getUniformLocation("MapTex");
|
||||||
|
glUniform1i(maptexLoc,6);
|
||||||
|
|
||||||
|
m_maptex.setActive(6);
|
||||||
|
|
||||||
|
for (const auto &item: loadedMap.Objects){
|
||||||
|
if(item.Layer == "Tmp")
|
||||||
|
continue;
|
||||||
|
if(!item.m_isStatic)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto mdl = g_getMainViewport()->MdlFromObj.find(item.Type);
|
||||||
|
if(mdl == g_getMainViewport()->MdlFromObj.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mdl->second.Draw(item.TF,m_shader,m_camMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_framebufferPP->bind();
|
||||||
|
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
m_framebuffer->getFbTexByAttachment(GL_COLOR_ATTACHMENT0).m_texture->setActive(0);
|
||||||
|
|
||||||
|
m_quadMesh.Draw();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
m_framebuffer = std::make_unique<Graphics::Framebuffer>(
|
||||||
|
std::vector<Graphics::FramebufferTextureInfo>{
|
||||||
|
{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GL_COLOR_ATTACHMENT0},
|
||||||
|
//{GL_R, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_COLOR_ATTACHMENT0}
|
||||||
|
},
|
||||||
|
m_shader,
|
||||||
|
Math::Vector2i{1600,1600}
|
||||||
|
);
|
||||||
|
|
||||||
|
m_framebufferPP = std::make_unique<Graphics::Framebuffer>(
|
||||||
|
std::vector<Graphics::FramebufferTextureInfo>{
|
||||||
|
{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GL_COLOR_ATTACHMENT0},
|
||||||
|
//{GL_R, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_COLOR_ATTACHMENT0}
|
||||||
|
},
|
||||||
|
m_shaderPP,
|
||||||
|
Math::Vector2i{m_size,m_size}
|
||||||
|
);
|
||||||
|
|
||||||
|
//m_camMatrix = {
|
||||||
|
// {1/500,0,0,0},
|
||||||
|
// {0,0,0,0},
|
||||||
|
// {0,1/500,0,0},
|
||||||
|
// {0,0,0,1}
|
||||||
|
//};
|
||||||
|
|
||||||
|
float dist = (float)m_size / 1.6;
|
||||||
|
|
||||||
|
glm::mat4 orthoProj = glm::ortho(
|
||||||
|
-dist,dist,
|
||||||
|
-dist,dist,0.0f,10000.0f
|
||||||
|
);
|
||||||
|
|
||||||
|
glm::mat4 viewMat = glm::lookAt(glm::vec3{0,5000.0,0},glm::vec3{0,0,0},glm::vec3{0,0,-1.0});
|
||||||
|
|
||||||
|
GLint maptexLoc = m_shader.getUniformLocation("MapTex");
|
||||||
|
glUniform1i(maptexLoc,6);
|
||||||
|
|
||||||
|
GLint pptexLoc = m_shaderPP.getUniformLocation("Tex");
|
||||||
|
glUniform1i(pptexLoc,0);
|
||||||
|
|
||||||
|
m_camMatrix = orthoProj * viewMat;
|
||||||
|
|
||||||
|
std::unique_ptr<Graphics::Texture> &fbTex = m_framebuffer->getFbTexByAttachment(GL_COLOR_ATTACHMENT0).m_texture;
|
||||||
|
|
||||||
|
fbTex->setActive();
|
||||||
|
|
||||||
|
float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
|
||||||
|
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
|
|
||||||
|
m_imgSize = m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draw() override{
|
||||||
|
drawTex();
|
||||||
|
|
||||||
|
m_size = std::max(1,m_size);
|
||||||
|
|
||||||
|
ImGui::InputInt("Size", &m_size);
|
||||||
|
ImGui::SameLine();
|
||||||
|
if(ImGui::Button("Update Size")){
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ImGui::Button("Export Map Texture##ExpMapTexBtn")){
|
||||||
|
Graphics::FileSelectDialog* fsDiag = static_cast <Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Export Map Texture")->second);
|
||||||
|
fsDiag->fileSelectMode = Graphics::Save;
|
||||||
|
fsDiag->Active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Image(reinterpret_cast<ImTextureID>((m_framebufferPP->getFbTexByAttachment(GL_COLOR_ATTACHMENT0))
|
||||||
|
.m_texture->getId()), ImVec2{(float)m_imgSize,(float)m_imgSize});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER,0);
|
||||||
|
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
static inline MapGenWidget* g_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
REGISTERVCLASS(MapGenWidget)
|
||||||
|
|
||||||
|
VGINIT_ACTION(AddMapGenFileselect){
|
||||||
|
Graphics::window->addWidget(new Graphics::FileSelectDialog("Export Map Texture", {".png"},[&](boost::filesystem::path path){
|
||||||
|
//Intentionally left empty
|
||||||
|
},[&](boost::filesystem::path path){
|
||||||
|
std::unique_ptr<Graphics::Framebuffer> &fb = MapGenWidget::g_instance->m_framebufferPP;
|
||||||
|
|
||||||
|
fb->bind();
|
||||||
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
|
|
||||||
|
std::vector<Color> m_colorData(MapGenWidget::g_instance->m_imgSize*MapGenWidget::g_instance->m_imgSize);
|
||||||
|
|
||||||
|
glReadPixels(0, 0, MapGenWidget::g_instance->m_imgSize, MapGenWidget::g_instance->m_imgSize, GL_RGBA, GL_UNSIGNED_BYTE, &m_colorData[0].r);
|
||||||
|
|
||||||
|
std::string str = path.string();
|
||||||
|
|
||||||
|
stbi_write_png(str.c_str(),MapGenWidget::g_instance->m_imgSize,MapGenWidget::g_instance->m_imgSize,4,m_colorData.data(),4*MapGenWidget::g_instance->m_imgSize);
|
||||||
|
}));
|
||||||
|
}
|
||||||
38
src/MapMirroring.cpp
Normal file
38
src/MapMirroring.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// Created by tv on 07.10.23.
|
||||||
|
//
|
||||||
|
#include<virintox/gcore/Graphics.h>
|
||||||
|
#include "InstanceVars.h"
|
||||||
|
|
||||||
|
MENU_ITEM_DISPLAY(Mirror,FlipZ,"Flip Map"){
|
||||||
|
std::list<LevelObject> toBeAdded;
|
||||||
|
|
||||||
|
for(LevelObject lo: loadedMap.Objects){
|
||||||
|
lo.Team = Teams::flipTeam(lo.Team);
|
||||||
|
|
||||||
|
lo.TF.Position.Z = -lo.TF.Position.Z;
|
||||||
|
lo.TF.Position.X = -lo.TF.Position.X;
|
||||||
|
lo.TF.Rotation.Y = lo.TF.Rotation.Y + 180;
|
||||||
|
|
||||||
|
lo.runtimeID = std::rand();
|
||||||
|
|
||||||
|
toBeAdded.push_back(lo);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(LevelObject &lo: toBeAdded){
|
||||||
|
loadedMap.Objects.push_back(lo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MENU_ITEM_DISPLAY(Mirror,DelZ,"Delete +Z"){
|
||||||
|
for(auto iter = loadedMap.Objects.begin(); iter != loadedMap.Objects.end(); iter++) {
|
||||||
|
if(iter->TF.Position.Z > 0){
|
||||||
|
auto itertemp = iter;
|
||||||
|
iter--;
|
||||||
|
loadedMap.Objects.erase(itertemp);
|
||||||
|
selectedElem = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SORT_MENU(Mirror,4)
|
||||||
|
|
@ -27,9 +27,8 @@ void ObjectSelectWidget::Draw() {
|
||||||
static unsigned int counter = 0;
|
static unsigned int counter = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
|
||||||
for(auto &obj: loadedMap.Objects){
|
for(auto iter = loadedMap.Objects.begin(); iter != loadedMap.Objects.end();iter++){
|
||||||
|
LevelObject& obj = *iter;
|
||||||
|
|
||||||
if(ImGui::Selectable((obj.Name + ": " + obj.Type + "##" + std::to_string(obj.runtimeID)).c_str(),selectedElem == &obj)){
|
if(ImGui::Selectable((obj.Name + ": " + obj.Type + "##" + std::to_string(obj.runtimeID)).c_str(),selectedElem == &obj)){
|
||||||
selectedElem = &obj;
|
selectedElem = &obj;
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +42,9 @@ void ObjectSelectWidget::Draw() {
|
||||||
|
|
||||||
if(ImGui::MenuItem((std::string("Delete##: ObjSelect ") + std::to_string(obj.runtimeID)).c_str())){
|
if(ImGui::MenuItem((std::string("Delete##: ObjSelect ") + std::to_string(obj.runtimeID)).c_str())){
|
||||||
std::cout << "Deleting " + obj.Name << std::endl;
|
std::cout << "Deleting " + obj.Name << std::endl;
|
||||||
loadedMap.Objects.erase(loadedMap.Objects.begin()+counter);
|
auto itertemp = iter;
|
||||||
|
iter--;
|
||||||
|
loadedMap.Objects.erase(itertemp);
|
||||||
selectedElem = nullptr;
|
selectedElem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,21 @@
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include "virintox/gcore/gui/FileSelectDialog.h"
|
#include "virintox/gcore/gui/FileSelectDialog.h"
|
||||||
|
#include "InstanceVars.h"
|
||||||
|
#include<fstream>
|
||||||
|
|
||||||
|
void ExportObj(LevelObject obj){
|
||||||
|
YAML::Emitter emitter;
|
||||||
|
|
||||||
|
obj.YamlInsert(emitter);
|
||||||
|
|
||||||
|
auto fstr = std::ofstream((boost::filesystem::current_path() / "Presets" / (obj.Name + ".yaml")).string());
|
||||||
|
|
||||||
|
fstr << emitter.c_str();
|
||||||
|
fstr.flush();
|
||||||
|
fstr.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MENU_ITEM_DISPLAY(Object,Add,ICON_FA_PLUS " Add"){
|
MENU_ITEM_DISPLAY(Object,Add,ICON_FA_PLUS " Add"){
|
||||||
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Load Object from Preset")->second);
|
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Load Object from Preset")->second);
|
||||||
|
|
@ -13,3 +28,66 @@ MENU_ITEM_DISPLAY(Object,Add,ICON_FA_PLUS " Add"){
|
||||||
wid->fileSelectMode = Graphics::Open;
|
wid->fileSelectMode = Graphics::Open;
|
||||||
wid->Active = true;
|
wid->Active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MENU_ITEM_DISPLAY(Object,Kotzen,"Kotzen[!]"){
|
||||||
|
for (LevelObject &obj: loadedMap.Objects) {
|
||||||
|
if(!boost::filesystem::exists(boost::filesystem::current_path() / "Presets" / (obj.Type + ".yaml"))){
|
||||||
|
LevelObject ObjCpy = LevelObject(obj);
|
||||||
|
ObjCpy.Name = ObjCpy.Type;
|
||||||
|
ObjCpy.Links = std::vector<Link>();
|
||||||
|
ObjCpy.TF.Scale = {1, 1, 1};
|
||||||
|
ObjCpy.TF.Rotation = {0, 0, 0};
|
||||||
|
ObjCpy.TF.Position = {0, 0, 0};
|
||||||
|
|
||||||
|
for(int ¶m: ObjCpy.Parameters){
|
||||||
|
param = -99;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(float ¶m: ObjCpy.FloatParameters){
|
||||||
|
param = -99.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjCpy.Layer = Common;
|
||||||
|
|
||||||
|
ExportObj(ObjCpy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MENU_ITEM_DISPLAY(Object,Durchfall,"Durchfall[!]"){
|
||||||
|
|
||||||
|
for(auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(boost::filesystem::current_path() / "Maps"), {})) {
|
||||||
|
|
||||||
|
std::cout << "Exporting all from " << entry << std::endl;
|
||||||
|
|
||||||
|
selectedElem = nullptr;
|
||||||
|
loadedMap = ConvertFromYaml(entry);
|
||||||
|
|
||||||
|
for (LevelObject &obj: loadedMap.Objects) {
|
||||||
|
if (!boost::filesystem::exists(boost::filesystem::current_path() / "Presets" / (obj.Type + ".yaml"))) {
|
||||||
|
LevelObject ObjCpy = LevelObject(obj);
|
||||||
|
ObjCpy.Name = ObjCpy.Type;
|
||||||
|
ObjCpy.Links = std::vector<Link>();
|
||||||
|
|
||||||
|
for(int ¶m: ObjCpy.Parameters){
|
||||||
|
param = -99;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(float ¶m: ObjCpy.FloatParameters){
|
||||||
|
param = -99.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjCpy.Layer = Common;
|
||||||
|
|
||||||
|
ObjCpy.TF.Scale = {1, 1, 1};
|
||||||
|
ObjCpy.TF.Rotation = {0, 0, 0};
|
||||||
|
ObjCpy.TF.Position = {0, 0, 0};
|
||||||
|
|
||||||
|
ExportObj(ObjCpy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,8 +198,8 @@ void ImGuiDrawElem(Element *elem, std::string Id = "") {
|
||||||
if (levelObject) {
|
if (levelObject) {
|
||||||
//ImGuiDrawTeamSelect(levelObject,Id);
|
//ImGuiDrawTeamSelect(levelObject,Id);
|
||||||
Configs::g_imguiDrawOpts("Team##" + Id, Configs::g_teams, levelObject->Team);
|
Configs::g_imguiDrawOpts("Team##" + Id, Configs::g_teams, levelObject->Team);
|
||||||
|
|
||||||
Configs::g_imguiDrawOpts("Drop##" + Id, Configs::g_dropIdOpts, levelObject->DropId);
|
Configs::g_imguiDrawOpts("Drop##" + Id, Configs::g_dropIdOpts, levelObject->DropId);
|
||||||
|
ImGui::Checkbox(("IsStatic##" + Id).c_str(), &(levelObject->m_isStatic));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (railPoint) {
|
if (railPoint) {
|
||||||
|
|
|
||||||
67
src/main.cpp
67
src/main.cpp
|
|
@ -10,16 +10,33 @@
|
||||||
|
|
||||||
VMIRRORASSEMBLYSELFREGISTER(SpoonEdit, VMIRRORVERSION(0,1,0,0),VMirror::AssemblyType::Executable)
|
VMIRRORASSEMBLYSELFREGISTER(SpoonEdit, VMIRRORVERSION(0,1,0,0),VMirror::AssemblyType::Executable)
|
||||||
|
|
||||||
|
enum class FileMode{
|
||||||
|
Compiled,
|
||||||
|
Uncompiled
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static FileMode g_fileMode = FileMode::Uncompiled;
|
||||||
|
|
||||||
VGINIT_ACTION(AddMapSelector){
|
VGINIT_ACTION(AddMapSelector){
|
||||||
Graphics::window->addWidget(new Graphics::FileSelectDialog("Select/Save Map", {".yaml"},[&](boost::filesystem::path path){
|
Graphics::FileSelectDialog* fsdiag = new Graphics::FileSelectDialog("Select/Save Map", {".yaml"},[&](boost::filesystem::path path){
|
||||||
selectedElem = nullptr;
|
selectedElem = nullptr;
|
||||||
|
|
||||||
|
if(g_fileMode == FileMode::Compiled)
|
||||||
loadedMap = ConvertFromYaml(path);
|
loadedMap = ConvertFromYaml(path);
|
||||||
|
if(g_fileMode == FileMode::Uncompiled)
|
||||||
|
loadedMap = Map(path);
|
||||||
|
|
||||||
MainViewport* vp = g_getMainViewport();
|
MainViewport* vp = g_getMainViewport();
|
||||||
vp->cleanUnnescessary();
|
vp->cleanUnnescessary();
|
||||||
},[&](boost::filesystem::path path){
|
},[&](boost::filesystem::path path){
|
||||||
|
if(g_fileMode == FileMode::Compiled)
|
||||||
loadedMap.Export(path);
|
loadedMap.Export(path);
|
||||||
}));
|
if(g_fileMode == FileMode::Uncompiled)
|
||||||
|
loadedMap.Save(path);
|
||||||
|
});
|
||||||
|
|
||||||
|
Graphics::window->addWidget(fsdiag);
|
||||||
}
|
}
|
||||||
|
|
||||||
VGINIT_ACTION(AddObjSelector){
|
VGINIT_ACTION(AddObjSelector){
|
||||||
|
|
@ -32,16 +49,62 @@ VGINIT_ACTION(AddObjSelector){
|
||||||
|
|
||||||
MENU_ITEM_DISPLAY(File,Open,ICON_FA_FOLDER_OPEN " Open"){
|
MENU_ITEM_DISPLAY(File,Open,ICON_FA_FOLDER_OPEN " Open"){
|
||||||
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Select/Save Map")->second);
|
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Select/Save Map")->second);
|
||||||
|
|
||||||
|
g_fileMode = FileMode::Uncompiled;
|
||||||
|
|
||||||
|
std::vector<std::string> strvec;
|
||||||
|
boost::algorithm::split(strvec,(boost::filesystem::current_path() / "Maps").string(),boost::algorithm::is_any_of("/\\"));
|
||||||
|
|
||||||
|
wid->Path = strvec;
|
||||||
|
|
||||||
wid->fileSelectMode = Graphics::Open;
|
wid->fileSelectMode = Graphics::Open;
|
||||||
wid->Active = true;
|
wid->Active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MENU_ITEM_DISPLAY(File,Save,ICON_FA_FLOPPY_DISK " Save"){
|
MENU_ITEM_DISPLAY(File,Save,ICON_FA_FLOPPY_DISK " Save"){
|
||||||
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Select/Save Map")->second);
|
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Select/Save Map")->second);
|
||||||
|
|
||||||
|
g_fileMode = FileMode::Uncompiled;
|
||||||
|
|
||||||
|
std::vector<std::string> strvec;
|
||||||
|
boost::algorithm::split(strvec,(boost::filesystem::current_path() / "Maps").string(),boost::algorithm::is_any_of("/\\"));
|
||||||
|
|
||||||
|
wid->Path = strvec;
|
||||||
|
|
||||||
wid->fileSelectMode = Graphics::Save;
|
wid->fileSelectMode = Graphics::Save;
|
||||||
wid->Active = true;
|
wid->Active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MENU_ITEM_DISPLAY(File,Import,ICON_FA_ARROW_LEFT " Import"){
|
||||||
|
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Select/Save Map")->second);
|
||||||
|
|
||||||
|
g_fileMode = FileMode::Compiled;
|
||||||
|
|
||||||
|
std::vector<std::string> strvec;
|
||||||
|
boost::algorithm::split(strvec,(boost::filesystem::current_path() / "CompiledMaps").string(),boost::algorithm::is_any_of("/\\"));
|
||||||
|
|
||||||
|
wid->Path = strvec;
|
||||||
|
|
||||||
|
wid->fileSelectMode = Graphics::Open;
|
||||||
|
wid->Active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MENU_ITEM_DISPLAY(File,Export,ICON_FA_ARROW_RIGHT " Export"){
|
||||||
|
auto wid = dynamic_cast<Graphics::FileSelectDialog*>(Graphics::window->WidgetByName.find("Select/Save Map")->second);
|
||||||
|
|
||||||
|
g_fileMode = FileMode::Compiled;
|
||||||
|
|
||||||
|
std::vector<std::string> strvec;
|
||||||
|
boost::algorithm::split(strvec,(boost::filesystem::current_path() / "CompiledMaps").string(),boost::algorithm::is_any_of("/\\"));
|
||||||
|
|
||||||
|
wid->Path = strvec;
|
||||||
|
|
||||||
|
wid->fileSelectMode = Graphics::Save;
|
||||||
|
wid->Active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SORT_MENU(File,0)
|
SORT_MENU(File,0)
|
||||||
SORT_MENU(Widgets,1)
|
SORT_MENU(Widgets,1)
|
||||||
SORT_MENU(Object,2)
|
SORT_MENU(Object,2)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue