new stuff
This commit is contained in:
commit
c595421288
44 changed files with 2556 additions and 0 deletions
17
Tools/MapTools/CMakeLists.txt
Normal file
17
Tools/MapTools/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(SpoonMapTools)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS filesystem iostreams)
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
find_package(yaml-cpp REQUIRED)
|
||||
|
||||
add_library(SpoonMapTools STATIC src/Map.cpp include/Map.h include/LevelObject.h include/Transform.h "include/Vector3.h" src/Vectior3.cpp src/Transform.cpp src/LevelObject.cpp include/Link.h src/Link.cpp include/Rail.h src/Rail.cpp include/RailPoint.h src/RailPoint.cpp include/SpecialObjectParams.h src/SpecialObjectParams.cpp include/SpecialObjectParamVersions/All.h include/SpecialObjectParamVersions/Default.h include/LayerConfig.h include/LayerConfig.h include/Element.h src/Element.cpp)
|
||||
|
||||
target_include_directories(SpoonMapTools PUBLIC include)
|
||||
|
||||
target_link_libraries(SpoonMapTools PUBLIC Boost::filesystem Boost::iostreams GLEW::GLEW yaml-cpp)
|
||||
|
||||
116
Tools/MapTools/include/Element.h
Normal file
116
Tools/MapTools/include/Element.h
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
//
|
||||
// Created by tv on 29.06.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_ELEMENT_H
|
||||
#define SPOONTOOL_ELEMENT_H
|
||||
|
||||
#include<list>
|
||||
#include<string>
|
||||
#include"Transform.h"
|
||||
#include"Link.h"
|
||||
|
||||
enum LayerConfig{
|
||||
Common, //Cmn
|
||||
Paint, //Pnt
|
||||
//Online, //Vss
|
||||
Rainmaker, //Vlf
|
||||
Tower, //Vgl
|
||||
Area, //Var
|
||||
Night, //Night
|
||||
Day, //Day
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
class Element{
|
||||
public:
|
||||
Element() = default;
|
||||
|
||||
Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockList = {});
|
||||
unsigned int runtimeID = static_cast<unsigned int>(rand());
|
||||
|
||||
Transform TF = Transform();
|
||||
std::string Type = "Unnamed Type";
|
||||
std::string Name = "Unnamed Element";
|
||||
|
||||
std::string ModelName = "null";
|
||||
|
||||
LayerConfig Layer = Common;
|
||||
|
||||
std::vector<long> Parameters = std::vector<long>();
|
||||
std::vector<float> FloatParameters = std::vector<float>();
|
||||
|
||||
//std::map<std::string,std::vector<Link>> Links = std::map<std::string,std::vector<Link>>();
|
||||
|
||||
std::vector<Link> Links = std::vector<Link>();
|
||||
std::map<std::string,std::string> OtherOptions = std::map<std::string,std::string>();
|
||||
|
||||
bool IsLinkDest = false;
|
||||
void YamlInsert(YAML::Emitter &Emitter);
|
||||
|
||||
virtual ~Element() = default;
|
||||
protected:
|
||||
virtual void YamlInsertBody(YAML::Emitter &Emitter);
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_ELEMENT_H
|
||||
89
Tools/MapTools/include/LevelObject.h
Normal file
89
Tools/MapTools/include/LevelObject.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_LEVELOBJECT_H
|
||||
#define SPOONTOOL_LEVELOBJECT_H
|
||||
|
||||
#include<Transform.h>
|
||||
#include<Link.h>
|
||||
|
||||
#include<yaml-cpp/yaml.h>
|
||||
#include "SpecialObjectParams.h"
|
||||
#include "Element.h"
|
||||
|
||||
|
||||
namespace Teams{
|
||||
constexpr long Player = 0;
|
||||
constexpr long Neutral = 1;
|
||||
constexpr long Enemy = 2;
|
||||
|
||||
constexpr std::array<long,3> AllOptions = {Player,Neutral,Enemy};
|
||||
|
||||
inline constexpr std::string TeamToText(long team) {
|
||||
switch(team){
|
||||
case 0:
|
||||
return "Player";
|
||||
case 1:
|
||||
return "Neutral";
|
||||
case 2:
|
||||
return "Enemy";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace DropId{
|
||||
constexpr long Default = -1;
|
||||
constexpr long Armor = 8;
|
||||
constexpr long Map = 9;
|
||||
constexpr long Key = 10;
|
||||
constexpr long OneSphere = 11;
|
||||
constexpr long FiveSphere = 12;
|
||||
constexpr long TenSphere = 13;
|
||||
constexpr long Bubbler = 14;
|
||||
constexpr long Bazooka = 15;
|
||||
|
||||
constexpr std::array<long,9> AllOptions = {Default,Armor,Map,Key,OneSphere,FiveSphere,TenSphere,Bubbler,Bazooka};
|
||||
|
||||
inline constexpr std::string DropIdToText(long team) {
|
||||
switch(team){
|
||||
case -1:
|
||||
return "Default";
|
||||
case 8:
|
||||
return "Armor";
|
||||
case 9:
|
||||
return "Map";
|
||||
case 10:
|
||||
return "Key";
|
||||
case 11:
|
||||
return "1 Sphere";
|
||||
case 12:
|
||||
return "5 Spheres";
|
||||
case 13:
|
||||
return "10 Spheres";
|
||||
case 14:
|
||||
return "Bubbler";
|
||||
case 15:
|
||||
return "Bazooka";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LevelObject: public Element{
|
||||
LevelObject(const YAML::Node &ObjNode);
|
||||
|
||||
protected:
|
||||
void YamlInsertBody(YAML::Emitter &Emitter) override;
|
||||
public:
|
||||
long Team;
|
||||
long DropId;
|
||||
|
||||
~LevelObject() = default;
|
||||
};
|
||||
|
||||
|
||||
#endif //SPOONTOOL_LEVELOBJECT_H
|
||||
45
Tools/MapTools/include/Link.h
Normal file
45
Tools/MapTools/include/Link.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_LINK_H
|
||||
#define SPOONTOOL_LINK_H
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include<string>
|
||||
|
||||
constexpr std::array<const char*, 12> LinkTypes = {
|
||||
"Spawner",
|
||||
"Rail",
|
||||
"Area",
|
||||
"AutoWarpPointLink",
|
||||
"Switch",
|
||||
"SwitchSender",
|
||||
"LiftBindable",
|
||||
"GraphNode",
|
||||
"ObjToGraphNode",
|
||||
"ObjToGraphNodeOneway",
|
||||
"BoneBindable",
|
||||
"ToGachihokoTargetPoint",
|
||||
};
|
||||
|
||||
struct Link {
|
||||
inline Link() : Name("Rail"), Destination("Undefined Destination"), UnitFile("") {}
|
||||
|
||||
Link(const YAML::Node &ObjNode);
|
||||
|
||||
// DefinitionName in byaml
|
||||
std::string Name;
|
||||
|
||||
// DestUnitId in byaml
|
||||
std::string Destination;
|
||||
|
||||
// UnitFileName in byaml
|
||||
static constexpr char LinkUnitFileID[] = "UnitFile";
|
||||
std::string UnitFile;
|
||||
|
||||
void InsertIntoYaml(YAML::Emitter &Emitter);
|
||||
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_LINK_H
|
||||
33
Tools/MapTools/include/Map.h
Normal file
33
Tools/MapTools/include/Map.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_MAP_H
|
||||
#define SPOONTOOL_MAP_H
|
||||
|
||||
#include<boost/filesystem.hpp>
|
||||
#include<LevelObject.h>
|
||||
#include<Rail.h>
|
||||
|
||||
|
||||
struct Map {
|
||||
//STREEFUNCS
|
||||
Map();
|
||||
|
||||
void Save(boost::filesystem::path FileLocation);
|
||||
|
||||
boost::filesystem::path ActiveLocation = "";
|
||||
|
||||
void Export(boost::filesystem::path YamlOut);
|
||||
|
||||
std::vector<LevelObject> Objects;
|
||||
|
||||
std::vector<Rail> Rails;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Map ConvertFromYaml(boost::filesystem::path File);
|
||||
|
||||
|
||||
#endif //SPOONTOOL_MAP_H
|
||||
57
Tools/MapTools/include/Rail.h
Normal file
57
Tools/MapTools/include/Rail.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_RAIL_H
|
||||
#define SPOONTOOL_RAIL_H
|
||||
|
||||
#include<Transform.h>
|
||||
#include<Link.h>
|
||||
#include<RailPoint.h>
|
||||
|
||||
#include<yaml-cpp/yaml.h>
|
||||
#include<RailPoint.h>
|
||||
#include "Element.h"
|
||||
|
||||
enum RailType{
|
||||
Linear,
|
||||
Bezier
|
||||
};
|
||||
|
||||
inline std::string ToString(RailType railType){
|
||||
if(railType == Linear){
|
||||
return "Linear";
|
||||
} else if(railType == Bezier){
|
||||
return "Bezier";
|
||||
}
|
||||
}
|
||||
|
||||
inline RailType ToRailType(std::string railType){
|
||||
if(railType == "Linear"){
|
||||
return Linear;
|
||||
} else if(railType == "Bezier"){
|
||||
return Bezier;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr std::array<RailType,2> AllRailTypeOptions = {Linear,Bezier};
|
||||
|
||||
struct Rail: public Element{
|
||||
|
||||
Rail(const YAML::Node &ObjNode);
|
||||
explicit Rail(const Vector3 &Position);
|
||||
|
||||
std::list<RailPoint> Points = std::list<RailPoint>();
|
||||
|
||||
RailType RailType = Linear;
|
||||
bool IsClosed = false;
|
||||
bool IsLadder = false;
|
||||
long Priority = 100;
|
||||
|
||||
~Rail() override = default;
|
||||
|
||||
protected:
|
||||
void YamlInsertBody(YAML::Emitter &Emitter) override;
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_RAIL_H
|
||||
33
Tools/MapTools/include/RailPoint.h
Normal file
33
Tools/MapTools/include/RailPoint.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_RAILPOINT_H
|
||||
#define SPOONTOOL_RAILPOINT_H
|
||||
|
||||
#include<Vector3.h>
|
||||
#include<Transform.h>
|
||||
#include<Link.h>
|
||||
|
||||
#include<yaml-cpp/yaml.h>
|
||||
#include"Element.h"
|
||||
|
||||
struct RailPoint: public Element{
|
||||
RailPoint(const YAML::Node &ObjNode);
|
||||
explicit RailPoint(const Vector3& pos);
|
||||
|
||||
protected:
|
||||
|
||||
void YamlInsertBody(YAML::Emitter &Emitter) override;
|
||||
public:
|
||||
|
||||
std::vector<Vector3> m_controlPoints = std::vector<Vector3>();
|
||||
|
||||
Vector3 m_offset = {0,0,0};
|
||||
|
||||
bool m_useOffset = false;
|
||||
|
||||
~RailPoint() override = default;
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_RAILPOINT_H
|
||||
18
Tools/MapTools/include/SpecialObjectParamVersions/All.h
Normal file
18
Tools/MapTools/include/SpecialObjectParamVersions/All.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Created by tv on 09.05.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_ALL_H
|
||||
#define SPOONTOOL_ALL_H
|
||||
#include<SpecialObjectParams.h>
|
||||
|
||||
|
||||
inline SpecialObjectParams* GetSpecParamsBySpoonID(std::string spoontype){
|
||||
return new SpecialObjectParams();
|
||||
}
|
||||
|
||||
inline SpecialObjectParams* GetSpecParamsBySubID(std::string spoontype){
|
||||
return new SpecialObjectParams();
|
||||
}
|
||||
|
||||
#endif //SPOONTOOL_ALL_H
|
||||
24
Tools/MapTools/include/SpecialObjectParamVersions/Default.h
Normal file
24
Tools/MapTools/include/SpecialObjectParamVersions/Default.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Created by tv on 09.05.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_DEFAULT_H
|
||||
#define SPOONTOOL_DEFAULT_H
|
||||
#include<SpecialObjectParams.h>
|
||||
|
||||
class DefaultObjParams : public SpecialObjectParams {
|
||||
public:
|
||||
DefaultObjParams() : SpecialObjectParams(){
|
||||
|
||||
}
|
||||
|
||||
void ParseOut(YAML::Node node) override {
|
||||
return;
|
||||
}
|
||||
|
||||
void InsertYaml(YAML::Emitter &Emitter) override {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_DEFAULT_H
|
||||
23
Tools/MapTools/include/SpecialObjectParams.h
Normal file
23
Tools/MapTools/include/SpecialObjectParams.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Created by tv on 07.05.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_SPECIALOBJECTPARAMS_H
|
||||
#define SPOONTOOL_SPECIALOBJECTPARAMS_H
|
||||
|
||||
#include<yaml-cpp/yaml.h>
|
||||
|
||||
struct SpecialObjectParams {
|
||||
public:
|
||||
SpecialObjectParams();
|
||||
|
||||
virtual void ParseOut(YAML::Node node);
|
||||
|
||||
virtual void InsertYaml(YAML::Emitter& Emitter);
|
||||
|
||||
virtual ~SpecialObjectParams() = default;
|
||||
|
||||
std::vector<std::string> GetMiscParamBlockList();
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_SPECIALOBJECTPARAMS_H
|
||||
19
Tools/MapTools/include/Transform.h
Normal file
19
Tools/MapTools/include/Transform.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_TRANSFORM_H
|
||||
#define SPOONTOOL_TRANSFORM_H
|
||||
#include<Vector3.h>
|
||||
#include<yaml-cpp/yaml.h>
|
||||
|
||||
struct Transform{
|
||||
|
||||
inline Transform(): Position(0,0,0), Scale(1,1,1), Rotation(0,0,0) {}
|
||||
|
||||
Vector3 Position,Scale,Rotation;
|
||||
|
||||
void InsertIntoYaml(YAML::Emitter &Emitter);
|
||||
};
|
||||
|
||||
#endif //SPOONTOOL_TRANSFORM_H
|
||||
29
Tools/MapTools/include/Vector3.h
Normal file
29
Tools/MapTools/include/Vector3.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#ifndef SPOONTOOL_VECTOR3_H
|
||||
#define SPOONTOOL_VECTOR3_H
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include<boost/algorithm/string.hpp>
|
||||
#include<iostream>
|
||||
|
||||
struct Vector3{
|
||||
|
||||
Vector3(YAML::Node node);
|
||||
float X,Y,Z;
|
||||
|
||||
inline Vector3(float x,float y,float z) : X(x),Y(y),Z(z){}
|
||||
|
||||
inline void InsertIntoYaml(YAML::Emitter &Emitter){
|
||||
Emitter << YAML::BeginMap;
|
||||
Emitter << YAML::Key << "X" << YAML::Value << X;
|
||||
Emitter << YAML::Key << "Y" << YAML::Value << Y;
|
||||
Emitter << YAML::Key << "Z" << YAML::Value << Z;
|
||||
Emitter << YAML::EndMap;
|
||||
|
||||
}
|
||||
};
|
||||
#endif //SPOONTOOL_VECTOR3_H
|
||||
143
Tools/MapTools/src/Element.cpp
Normal file
143
Tools/MapTools/src/Element.cpp
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
#include<Element.h>
|
||||
#include<algorithm>
|
||||
|
||||
Element::Element(const YAML::Node &ObjNode,std::list<std::string> PropertyBlockList) {
|
||||
|
||||
PropertyBlockList.emplace_back("Id");
|
||||
PropertyBlockList.emplace_back("UnitConfigName");
|
||||
PropertyBlockList.emplace_back("LayerConfigName");
|
||||
PropertyBlockList.emplace_back("Translate");
|
||||
PropertyBlockList.emplace_back("Rotate");
|
||||
PropertyBlockList.emplace_back("Scale");
|
||||
PropertyBlockList.emplace_back("Links");
|
||||
PropertyBlockList.emplace_back("ModelName");
|
||||
PropertyBlockList.emplace_back("IsLinkDest");
|
||||
|
||||
|
||||
runtimeID = static_cast<unsigned int>(rand());
|
||||
|
||||
Name = ObjNode["Id"].as<std::string>();
|
||||
Type = ObjNode["UnitConfigName"].as<std::string>();
|
||||
|
||||
TF.Position = ObjNode["Translate"];
|
||||
TF.Rotation = ObjNode["Rotate"];
|
||||
TF.Scale = ObjNode["Scale"];
|
||||
|
||||
Layer = ToLayerConfig(ObjNode["LayerConfigName"].as<std::string>());
|
||||
|
||||
ModelName = ObjNode["ModelName"].as<std::string>();
|
||||
IsLinkDest = ObjNode["IsLinkDest"].as<bool>();
|
||||
|
||||
unsigned int ParamId = 1;
|
||||
|
||||
while(YAML::Node ParamNode = ObjNode["Parameter" + std::to_string(ParamId)]){
|
||||
Parameters.push_back(ParamNode.as<long>());
|
||||
ParamId++;
|
||||
}
|
||||
|
||||
unsigned int FloatParamId = 1;
|
||||
|
||||
while(YAML::Node ParamNode = ObjNode["FloatParameter" + std::to_string(FloatParamId)]){
|
||||
FloatParameters.push_back(ParamNode.as<float>());
|
||||
FloatParamId++;
|
||||
}
|
||||
|
||||
YAML::Node LinksNode = ObjNode["Links"];
|
||||
|
||||
for(YAML::const_iterator it2 = LinksNode.begin();it2 != LinksNode.end();++it2) {
|
||||
auto node2 = it2->second;
|
||||
for(auto link: node2){
|
||||
Links.emplace_back(link);
|
||||
}
|
||||
}
|
||||
|
||||
for(YAML::const_iterator it=ObjNode.begin();it != ObjNode.end();++it) {
|
||||
std::string OptName = it->first.as<std::string>();
|
||||
|
||||
if(OptName.starts_with("Parameter") || OptName.starts_with("FloatParameter"))
|
||||
continue;
|
||||
|
||||
if(std::any_of(PropertyBlockList.begin(), PropertyBlockList.end(),[&](std::string str){ return str == OptName;}))
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
auto node = it->second;
|
||||
|
||||
auto str = node.as<std::string>();
|
||||
|
||||
if(node.Tag() == "!l")
|
||||
str = "!l " + str;
|
||||
|
||||
OtherOptions.insert({OptName,str});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Element::YamlInsert(YAML::Emitter &Emitter) {
|
||||
Emitter << YAML::BeginMap;
|
||||
YamlInsertBody(Emitter);
|
||||
Emitter << YAML::EndMap;
|
||||
}
|
||||
|
||||
void Element::YamlInsertBody(YAML::Emitter &Emitter) {
|
||||
Emitter << YAML::Key << "Id" << YAML::Value << Name;
|
||||
|
||||
TF.InsertIntoYaml(Emitter);
|
||||
|
||||
Emitter << YAML::Key << "UnitConfigName" << YAML::Value << Type;
|
||||
|
||||
Emitter << YAML::Key << "LayerConfigName" << YAML::Value << ToStringYaml(Layer);
|
||||
if(ModelName == "null") {
|
||||
Emitter << YAML::Key << "ModelName" << YAML::Value << YAML::LowerNull << YAML::Null;
|
||||
} else {
|
||||
Emitter << YAML::Key << "ModelName" << YAML::Value << ModelName;
|
||||
}
|
||||
|
||||
Emitter << YAML::Key << "IsLinkDest" << YAML::Value << IsLinkDest;
|
||||
|
||||
Emitter << YAML::Key << "Links" << YAML::BeginMap;
|
||||
|
||||
std::map<std::string,std::vector<Link>> linksByType = std::map<std::string,std::vector<Link>>();
|
||||
|
||||
for(Link link: Links){
|
||||
if(!linksByType.contains(link.Name))
|
||||
linksByType.insert({link.Name,std::vector<Link>()});
|
||||
linksByType.find(link.Name)->second.emplace_back(link);
|
||||
}
|
||||
|
||||
|
||||
for(auto links: linksByType){
|
||||
Emitter << YAML::Key << links.first;
|
||||
Emitter << YAML::BeginSeq;
|
||||
for(auto link: links.second){
|
||||
link.InsertIntoYaml(Emitter);
|
||||
}
|
||||
Emitter << YAML::EndSeq;
|
||||
}
|
||||
Emitter << YAML::EndMap;
|
||||
|
||||
for(int i = 1; i <= Parameters.size(); i++){
|
||||
Emitter << YAML::Key << "Parameter" + std::to_string(i) << YAML::Value << YAML::LocalTag("l") << Parameters[i-1];
|
||||
}
|
||||
|
||||
for(int i = 1; i <= FloatParameters.size(); i++){
|
||||
Emitter << YAML::Key << "FloatParameter" + std::to_string(i) << YAML::Value << FloatParameters[i-1];
|
||||
}
|
||||
|
||||
for(auto opts: OtherOptions){
|
||||
Emitter << YAML::Key << opts.first;
|
||||
if(opts.second == "null") {
|
||||
Emitter << YAML::Value << YAML::CamelNull << YAML::Null;
|
||||
}
|
||||
else {
|
||||
if(boost::starts_with(opts.second,"!l ")){
|
||||
auto str = opts.second.substr(3);
|
||||
|
||||
Emitter << YAML::Value << YAML::LocalTag("l") << std::stol(str);
|
||||
} else
|
||||
Emitter << YAML::Value << opts.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Tools/MapTools/src/LevelObject.cpp
Normal file
13
Tools/MapTools/src/LevelObject.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include<LevelObject.h>
|
||||
#include<SpecialObjectParamVersions/All.h>
|
||||
|
||||
LevelObject::LevelObject(const YAML::Node &ObjNode): Element(ObjNode,{"Team","DropId"}) {
|
||||
Team = ObjNode["Team"].as<long>(-1);
|
||||
DropId = ObjNode["DropId"].as<long>(DropId::Default);
|
||||
}
|
||||
|
||||
void LevelObject::YamlInsertBody(YAML::Emitter &Emitter) {
|
||||
Element::YamlInsertBody(Emitter);
|
||||
Emitter << YAML::Key << "Team" << YAML::Value << YAML::LocalTag("l") << Team;
|
||||
Emitter << YAML::Key << "DropId" << YAML::Value << YAML::LocalTag("l") << DropId;
|
||||
}
|
||||
18
Tools/MapTools/src/Link.cpp
Normal file
18
Tools/MapTools/src/Link.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
#include<Link.h>
|
||||
|
||||
Link::Link(const YAML::Node &ObjNode) {
|
||||
Name = ObjNode["DefinitionName"].as<std::string>();
|
||||
Destination = ObjNode["DestUnitId"].as<std::string>();
|
||||
UnitFile = ObjNode["UnitFileName"].as<std::string>();
|
||||
}
|
||||
|
||||
void Link::InsertIntoYaml(YAML::Emitter &Emitter) {
|
||||
Emitter << YAML::BeginMap;
|
||||
Emitter << YAML::Key << "DefinitionName" << YAML::Value << Name;
|
||||
Emitter << YAML::Key << "DestUnitId" << YAML::Value << Destination;
|
||||
Emitter << YAML::Key << "UnitFileName" << YAML::Value << UnitFile;
|
||||
Emitter << YAML::EndMap;
|
||||
}
|
||||
100
Tools/MapTools/src/Map.cpp
Normal file
100
Tools/MapTools/src/Map.cpp
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
//
|
||||
// Created by tv on 30.04.23.
|
||||
//
|
||||
|
||||
#include<Map.h>
|
||||
#include<yaml-cpp/yaml.h>
|
||||
#include<boost/iostreams/filtering_stream.hpp>
|
||||
//#include<boost/iostreams/filter/lzma.hpp>
|
||||
#include <boost/iostreams/device/file.hpp>
|
||||
#include<iostream>
|
||||
#include<boost/algorithm/string.hpp>
|
||||
|
||||
//GENSERIALIZABLECONTENT(Map,(Objects,Rails))
|
||||
|
||||
Map::Map(): Objects(), Rails() {
|
||||
|
||||
}
|
||||
|
||||
void Map::Save(boost::filesystem::path FileLocation) {
|
||||
|
||||
}
|
||||
|
||||
void Map::Export(boost::filesystem::path YamlOut) {
|
||||
YAML::Emitter Emitter;
|
||||
|
||||
Emitter << YAML::BeginMap;
|
||||
Emitter << YAML::Key << "Version" << YAML::Value << "1";
|
||||
Emitter << YAML::Key << "IsBigEndian" << YAML::Value << "True";
|
||||
Emitter << YAML::Key << "SupportPaths" << YAML::Value << "False";
|
||||
Emitter << YAML::Key << "HasReferenceNodes" << YAML::Value << "False";
|
||||
|
||||
|
||||
Emitter << YAML::Key << "root" << YAML::BeginMap;
|
||||
Emitter << YAML::Key << "FilePath" << YAML::Value << "NoFilePathInsertMegamindMemeHere";
|
||||
Emitter << YAML::Key << "Objs" << 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;
|
||||
|
||||
//root
|
||||
Emitter << YAML::EndMap;
|
||||
//main document
|
||||
Emitter << YAML::EndMap;
|
||||
|
||||
std::ofstream file(YamlOut.string());
|
||||
|
||||
std::string str = Emitter.c_str();
|
||||
|
||||
boost::algorithm::replace_all(str,"~","null");
|
||||
|
||||
file << str;
|
||||
file.flush();
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Map ConvertFromYaml(boost::filesystem::path File){
|
||||
Map OutputMap = Map();
|
||||
|
||||
YAML::Node MapYaml = YAML::LoadFile(File.generic_string());
|
||||
auto RootNode = MapYaml["root"];
|
||||
|
||||
auto ObjList = RootNode["Objs"];
|
||||
|
||||
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;
|
||||
|
||||
OutputMap.Objects.push_back(LevelObject(obj));
|
||||
}
|
||||
|
||||
auto RailList = RootNode["Rails"];
|
||||
|
||||
for (YAML::iterator it = RailList.begin(); it != RailList.end(); it++) {
|
||||
const YAML::Node& obj = *it;
|
||||
|
||||
Rail newObj(obj);
|
||||
|
||||
OutputMap.Rails.push_back(newObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::cout << "Successfully converted to smap!" << std::endl;
|
||||
|
||||
return OutputMap;
|
||||
}
|
||||
38
Tools/MapTools/src/Rail.cpp
Normal file
38
Tools/MapTools/src/Rail.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include<Rail.h>
|
||||
|
||||
|
||||
|
||||
Rail::Rail(const YAML::Node &ObjNode) : Element(ObjNode, {"RailPoints","RailType","IsClosed","IsLadder","Priority"}) {
|
||||
YAML::Node railPointsNode = ObjNode["RailPoints"];
|
||||
|
||||
for (auto rlpoint: railPointsNode) {
|
||||
Points.emplace_back(rlpoint);
|
||||
}
|
||||
|
||||
RailType = ToRailType(ObjNode["RailType"].as<std::string>());
|
||||
IsClosed = ObjNode["IsClosed"].as<bool>();
|
||||
IsLadder = ObjNode["IsLadder"].as<bool>();
|
||||
Priority = ObjNode["Priority"].as<long>();
|
||||
}
|
||||
|
||||
Rail::Rail(const Vector3 &Position) {
|
||||
TF.Position = Position;
|
||||
Name = "Unnamed Rail";
|
||||
Type = "Rail";
|
||||
Points.emplace_back(Position);
|
||||
}
|
||||
|
||||
void Rail::YamlInsertBody(YAML::Emitter &Emitter) {
|
||||
Element::YamlInsertBody(Emitter);
|
||||
|
||||
Emitter << YAML::Key << "RailPoints" << YAML::BeginSeq;
|
||||
for (auto point: Points) {
|
||||
point.YamlInsert(Emitter);
|
||||
}
|
||||
Emitter << YAML::EndSeq;
|
||||
|
||||
Emitter << YAML::Key << "RailType" << YAML::Key << ToString(RailType);
|
||||
Emitter << YAML::Key << "IsClosed" << YAML::Key << IsClosed;
|
||||
Emitter << YAML::Key << "IsLadder" << YAML::Key << IsLadder;
|
||||
Emitter << YAML::Key << "Priority" << YAML::Key << YAML::LocalTag("l") << Priority;
|
||||
}
|
||||
40
Tools/MapTools/src/RailPoint.cpp
Normal file
40
Tools/MapTools/src/RailPoint.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include<Rail.h>
|
||||
#include "RailPoint.h"
|
||||
|
||||
|
||||
RailPoint::RailPoint(const YAML::Node &ObjNode): Element(ObjNode,{"ControlPoints","OffsetX","OffsetY","OffsetZ","UseOffset",}) {
|
||||
|
||||
YAML::Node controlPointsNode = ObjNode["ControlPoints"];
|
||||
for(auto controlPoint: controlPointsNode){
|
||||
auto point = Vector3(controlPoint);
|
||||
m_controlPoints.push_back(point);
|
||||
}
|
||||
|
||||
m_offset = {ObjNode["OffsetX"].as<float>(), ObjNode["OffsetY"].as<float>(), ObjNode["OffsetZ"].as<float>()};
|
||||
|
||||
m_useOffset = ObjNode["UseOffset"].as<bool>();
|
||||
}
|
||||
|
||||
RailPoint::RailPoint(const Vector3 &pos) {
|
||||
Name = "Unnamed Rail Point";
|
||||
Type = "Point";
|
||||
|
||||
TF.Position = pos;
|
||||
m_controlPoints.push_back(pos);
|
||||
m_controlPoints.push_back(pos);
|
||||
}
|
||||
|
||||
void RailPoint::YamlInsertBody(YAML::Emitter &Emitter) {
|
||||
Element::YamlInsertBody(Emitter);
|
||||
Emitter << YAML::Key << "ControlPoints" << YAML::BeginSeq;
|
||||
for(auto ctrlPoint: m_controlPoints){
|
||||
ctrlPoint.InsertIntoYaml(Emitter);
|
||||
}
|
||||
Emitter << YAML::EndSeq;
|
||||
|
||||
Emitter << YAML::Key << "OffsetX" << YAML::Value << m_offset.X;
|
||||
Emitter << YAML::Key << "OffsetY" << YAML::Value << m_offset.Y;
|
||||
Emitter << YAML::Key << "OffsetZ" << YAML::Value << m_offset.Z;
|
||||
|
||||
Emitter << YAML::Key << "UseOffset" << YAML::Value << m_useOffset;
|
||||
}
|
||||
19
Tools/MapTools/src/SpecialObjectParams.cpp
Normal file
19
Tools/MapTools/src/SpecialObjectParams.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Created by tv on 07.05.23.
|
||||
//
|
||||
#include "SpecialObjectParams.h"
|
||||
#include"SpecialObjectParamVersions/All.h"
|
||||
|
||||
|
||||
void SpecialObjectParams::ParseOut(YAML::Node node) {}
|
||||
|
||||
void SpecialObjectParams::InsertYaml(YAML::Emitter &Emitter) {}
|
||||
|
||||
SpecialObjectParams::SpecialObjectParams() {
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::string> SpecialObjectParams::GetMiscParamBlockList() {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
13
Tools/MapTools/src/Transform.cpp
Normal file
13
Tools/MapTools/src/Transform.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include<Transform.h>
|
||||
|
||||
void Transform::InsertIntoYaml(YAML::Emitter &Emitter) {
|
||||
Emitter << YAML::Key << "Translate";
|
||||
Position.InsertIntoYaml(Emitter);
|
||||
|
||||
Emitter << YAML::Key << "Scale";
|
||||
Scale.InsertIntoYaml(Emitter);
|
||||
|
||||
Emitter << YAML::Key << "Rotate";
|
||||
Rotation.InsertIntoYaml(Emitter);
|
||||
|
||||
}
|
||||
23
Tools/MapTools/src/Vectior3.cpp
Normal file
23
Tools/MapTools/src/Vectior3.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include<Vector3.h>
|
||||
|
||||
Vector3::Vector3(YAML::Node node) {
|
||||
try {
|
||||
X = node["X"].as<float>();
|
||||
Y = node["Y"].as<float>();
|
||||
Z = node["Z"].as<float>();
|
||||
} catch(...){
|
||||
std::cout << "WER AUCH IMMER HIER SEINEN PC AUF DEUTSCH GESTELLT HAT\n 1. STELL ES UM DAMIT DU KEINE PROBLEME MEHR HAST\n 2. TF\n 3. KEINE KOMPATIBILITÄT GARANTIERT UND NUR FÜR DICH MUSSTE ICH EINEN PATCH SCHREIBEN. \nFFS >:(.\n";
|
||||
|
||||
auto xstr = node["X"].as<std::string>();
|
||||
boost::algorithm::replace_all(xstr,",",".");
|
||||
X = std::stof(xstr);
|
||||
|
||||
auto ystr = node["Y"].as<std::string>();
|
||||
boost::algorithm::replace_all(ystr,",",".");
|
||||
Y = std::stof(ystr);
|
||||
|
||||
auto zstr = node["Z"].as<std::string>();
|
||||
boost::algorithm::replace_all(zstr,",",".");
|
||||
Z = std::stof(zstr);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue