added deletion of parameters and adding parameters
This commit is contained in:
parent
18f5c9d025
commit
3442f3b03f
1 changed files with 123 additions and 99 deletions
|
|
@ -9,31 +9,33 @@
|
|||
#include "IconsFontAwesome6.h"
|
||||
#include<array>
|
||||
#include "Config/Configs.h"
|
||||
struct SimpleVec3{
|
||||
float x,y,z;
|
||||
template <typename t>
|
||||
SimpleVec3(t fromobj){
|
||||
|
||||
struct SimpleVec3 {
|
||||
float x, y, z;
|
||||
|
||||
template<typename t>
|
||||
SimpleVec3(t fromobj) {
|
||||
x = fromobj.X;
|
||||
y = fromobj.Y;
|
||||
z = fromobj.Z;
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
void copyto(t* toobj){
|
||||
template<typename t>
|
||||
void copyto(t *toobj) {
|
||||
toobj->X = x;
|
||||
toobj->Y = y;
|
||||
toobj->Z = z;
|
||||
}
|
||||
};
|
||||
|
||||
PropertiesWidget* PropertiesWidgetInst = nullptr;
|
||||
PropertiesWidget *PropertiesWidgetInst = nullptr;
|
||||
|
||||
template<typename t,typename iter,typename stringConv>
|
||||
void ImGuiDrawSelection(std::string id,t& val,iter optsBegin, iter optsEnd,stringConv convert){
|
||||
template<typename t, typename iter, typename stringConv>
|
||||
void ImGuiDrawSelection(std::string id, t &val, iter optsBegin, iter optsEnd, stringConv convert) {
|
||||
|
||||
if(ImGui::BeginCombo(id.c_str(),convert(val).c_str())) {
|
||||
if (ImGui::BeginCombo(id.c_str(), convert(val).c_str())) {
|
||||
while (optsBegin != optsEnd) {
|
||||
if(ImGui::Selectable((convert(*optsBegin) + "##" + id).c_str()))
|
||||
if (ImGui::Selectable((convert(*optsBegin) + "##" + id).c_str()))
|
||||
val = *optsBegin;
|
||||
optsBegin++;
|
||||
}
|
||||
|
|
@ -41,76 +43,79 @@ void ImGuiDrawSelection(std::string id,t& val,iter optsBegin, iter optsEnd,strin
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename t>
|
||||
void ImGuiDrawLayer(t *obj){
|
||||
if(ImGui::BeginCombo("Layer##PropWind",ToString(obj->Layer).c_str())){
|
||||
if(ImGui::Selectable("Common##TeamsPropWind"))
|
||||
void ImGuiDrawLayer(t *obj) {
|
||||
if (ImGui::BeginCombo("Layer##PropWind", ToString(obj->Layer).c_str())) {
|
||||
if (ImGui::Selectable("Common##TeamsPropWind"))
|
||||
obj->Layer = Common;
|
||||
if(ImGui::Selectable("Paint##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Paint##TeamsPropWind"))
|
||||
obj->Layer = Paint;
|
||||
if(ImGui::Selectable("Rainmaker##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Rainmaker##TeamsPropWind"))
|
||||
obj->Layer = Rainmaker;
|
||||
if(ImGui::Selectable("Tower##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Tower##TeamsPropWind"))
|
||||
obj->Layer = Tower;
|
||||
if(ImGui::Selectable("Area##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Area##TeamsPropWind"))
|
||||
obj->Layer = Area;
|
||||
if(ImGui::Selectable("Night##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Night##TeamsPropWind"))
|
||||
obj->Layer = Night;
|
||||
if(ImGui::Selectable("Day##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Day##TeamsPropWind"))
|
||||
obj->Layer = Day;
|
||||
if(ImGui::Selectable("Temporary##TeamsPropWind"))
|
||||
if (ImGui::Selectable("Temporary##TeamsPropWind"))
|
||||
obj->Layer = Temporary;
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
};
|
||||
|
||||
void ImGuiDrawTransform(Transform &tf,std::string id){
|
||||
void ImGuiDrawTransform(Transform &tf, std::string id) {
|
||||
ImGui::Text("Transform:");
|
||||
ImGui::Indent();
|
||||
{
|
||||
//auto simplevec3pos = SimpleVec3(tf.Position);
|
||||
ImGui::DragFloat3(("Position##" + id).c_str(), &(tf.Position.X),0.01);
|
||||
ImGui::DragFloat3(("Position##" + id).c_str(), &(tf.Position.X), 0.01);
|
||||
//simplevec3pos.copyto(&tf.Position);
|
||||
|
||||
//auto simplevec3rot = SimpleVec3(tf.Rotation);
|
||||
ImGui::DragFloat3(("Rotation##" + id).c_str(), &(tf.Rotation.X),0.01);
|
||||
ImGui::DragFloat3(("Rotation##" + id).c_str(), &(tf.Rotation.X), 0.01);
|
||||
//simplevec3rot.copyto(&tf.Rotation);
|
||||
|
||||
//auto simplevec3scale = SimpleVec3(tf.Scale);
|
||||
ImGui::DragFloat3(("Scale##" + id).c_str(), &(tf.Scale.X),0.01);
|
||||
ImGui::DragFloat3(("Scale##" + id).c_str(), &(tf.Scale.X), 0.01);
|
||||
//simplevec3scale.copyto(&tf.Scale);
|
||||
}
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
||||
Rail* rail = dynamic_cast<Rail*>(elem);
|
||||
RailPoint* railPoint = dynamic_cast<RailPoint*>(elem);
|
||||
LevelObject* levelObject = dynamic_cast<LevelObject*>(elem);
|
||||
void ImGuiDrawElem(Element *elem, std::string Id = "") {
|
||||
Rail *rail = dynamic_cast<Rail *>(elem);
|
||||
RailPoint *railPoint = dynamic_cast<RailPoint *>(elem);
|
||||
LevelObject *levelObject = dynamic_cast<LevelObject *>(elem);
|
||||
|
||||
Id += std::to_string(elem->runtimeID);
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetWindowWidth()/3);
|
||||
ImGui::InputText(("##PropWindInputName" + Id).c_str(),&elem->Name);
|
||||
ImGui::PushItemWidth(ImGui::GetWindowWidth() / 3);
|
||||
ImGui::InputText(("##PropWindInputName" + Id).c_str(), &elem->Name);
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine(); ImGui::Text(": "); ImGui::SameLine();
|
||||
ImGui::PushItemWidth(ImGui::GetWindowWidth()/3);
|
||||
ImGui::InputText(("##PropWindInputType" + Id).c_str(),&elem->Type);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text(": ");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(ImGui::GetWindowWidth() / 3);
|
||||
ImGui::InputText(("##PropWindInputType" + Id).c_str(), &elem->Type);
|
||||
ImGui::PopItemWidth();
|
||||
ImGuiDrawTransform(elem->TF,"PropWind" + Id);
|
||||
ImGuiDrawTransform(elem->TF, "PropWind" + Id);
|
||||
ImGuiDrawLayer(elem);
|
||||
ImGui::Checkbox(("Is Link Destination?##PropWindowIsLinkDest" + Id).c_str(),&elem->IsLinkDest);
|
||||
if (ImGui::CollapsingHeader(("Links##" + Id).c_str())){
|
||||
ImGui::Checkbox(("Is Link Destination?##PropWindowIsLinkDest" + Id).c_str(), &elem->IsLinkDest);
|
||||
if (ImGui::CollapsingHeader(("Links##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
unsigned i = 1;
|
||||
for(auto linkIter = elem->Links.begin();linkIter != elem->Links.end();linkIter++){
|
||||
for (auto linkIter = elem->Links.begin(); linkIter != elem->Links.end(); linkIter++) {
|
||||
auto &link = *linkIter;
|
||||
if (ImGui::CollapsingHeader(("Link " + std::to_string(i) + "##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
Configs::g_imguiDrawOpts("Link Type##" + std::to_string(i) + Id, Configs::g_linkOpts, link.Name);
|
||||
ImGui::InputText(("Destination##PropWindLink" + std::to_string(i) + Id).c_str(), &link.Destination);
|
||||
|
||||
if(Element* gotoElem = GetMainWindow()->loadedMap.GetElementById(link.Destination)) {
|
||||
if (Element *gotoElem = GetMainWindow()->loadedMap.GetElementById(link.Destination)) {
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_CHEVRON_RIGHT)) {
|
||||
GetMainWindow()->selectedElem = gotoElem;
|
||||
|
|
@ -118,7 +123,7 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
|||
}
|
||||
|
||||
ImGui::InputText(("Unit File##PropWindLink" + std::to_string(i) + Id).c_str(), &link.UnitFile);
|
||||
if(ImGui::Button((ICON_FA_TRASH "##PropWindLinkDelete" + std::to_string(i) + Id).c_str())) {
|
||||
if (ImGui::Button((ICON_FA_TRASH "##PropWindLinkDelete" + std::to_string(i) + Id).c_str())) {
|
||||
elem->Links.erase(linkIter);
|
||||
ImGui::Unindent();
|
||||
break;
|
||||
|
|
@ -128,28 +133,32 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
|||
i++;
|
||||
}
|
||||
|
||||
if(ImGui::Button(ICON_FA_PLUS)) {
|
||||
if (ImGui::Button(ICON_FA_PLUS)) {
|
||||
elem->Links.emplace_back();
|
||||
}
|
||||
ImGui::Unindent();
|
||||
}
|
||||
if (ImGui::CollapsingHeader(("Element Type Specific Options##" + Id).c_str())){
|
||||
if (ImGui::CollapsingHeader(("Element Type Specific Options##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
if(rail){
|
||||
ImGui::Checkbox(("Is Closed?##" + Id).c_str(),&rail->IsClosed);
|
||||
ImGui::Checkbox(("Is Ladder?##" + Id).c_str(),&rail->IsLadder);
|
||||
ImGui::InputInt(("Priority?##" + Id).c_str(),(int*)&rail->Priority);
|
||||
ImGuiDrawSelection("Rail Type",rail->RailType,AllRailTypeOptions.begin(), AllRailTypeOptions.end(),[](RailType t){return ToString(t);});
|
||||
if(ImGui::CollapsingHeader(("Rail Points##"+Id).c_str())){
|
||||
if (rail) {
|
||||
ImGui::Checkbox(("Is Closed?##" + Id).c_str(), &rail->IsClosed);
|
||||
ImGui::Checkbox(("Is Ladder?##" + Id).c_str(), &rail->IsLadder);
|
||||
ImGui::InputInt(("Priority?##" + Id).c_str(), (int *) &rail->Priority);
|
||||
ImGuiDrawSelection("Rail Type", rail->RailType, AllRailTypeOptions.begin(), AllRailTypeOptions.end(),
|
||||
[](RailType t) { return ToString(t); });
|
||||
if (ImGui::CollapsingHeader(("Rail Points##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
unsigned int i = 1;
|
||||
|
||||
for(auto curRailPointRef = rail->Points.begin(); curRailPointRef != rail->Points.end();curRailPointRef++){
|
||||
for (auto curRailPointRef = rail->Points.begin();
|
||||
curRailPointRef != rail->Points.end(); curRailPointRef++) {
|
||||
RailPoint &curRailPoint = *curRailPointRef;
|
||||
if(ImGui::CollapsingHeader((std::to_string(i) + "##RailPoints").c_str())){
|
||||
if (ImGui::CollapsingHeader((std::to_string(i) + "##RailPoints").c_str())) {
|
||||
ImGui::Indent();
|
||||
ImGuiDrawElem(&curRailPoint,"RailPoint" + std::to_string(i) + std::to_string(curRailPoint.runtimeID));
|
||||
if(ImGui::Button((ICON_FA_TRASH "##PropWindRailPointDelete" + std::to_string(i) + Id).c_str())){
|
||||
ImGuiDrawElem(&curRailPoint,
|
||||
"RailPoint" + std::to_string(i) + std::to_string(curRailPoint.runtimeID));
|
||||
if (ImGui::Button(
|
||||
(ICON_FA_TRASH "##PropWindRailPointDelete" + std::to_string(i) + Id).c_str())) {
|
||||
rail->Points.erase(curRailPointRef);
|
||||
ImGui::Unindent();
|
||||
break;
|
||||
|
|
@ -158,20 +167,16 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
|||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
if(rail->Points.size() != 1) {
|
||||
if (ImGui::Button((ICON_FA_PLUS "##" + Id).c_str())) {
|
||||
if (ImGui::Button((ICON_FA_PLUS "##RailPointAdd" + Id).c_str())) {
|
||||
RailPoint rp = RailPoint(rail->Points.back());
|
||||
rp.runtimeID = rand();
|
||||
rail->Points.push_back(rp);
|
||||
}
|
||||
}
|
||||
|
||||
if(rail->Points.empty()){
|
||||
auto& map = GetMainWindow()->loadedMap;
|
||||
if (rail->Points.empty()) {
|
||||
auto &map = GetMainWindow()->loadedMap;
|
||||
|
||||
std::erase_if(map.Rails,[&](const Rail& rail1){
|
||||
std::erase_if(map.Rails, [&](const Rail &rail1) {
|
||||
return rail1.runtimeID == rail->runtimeID;
|
||||
});
|
||||
|
||||
|
|
@ -181,23 +186,24 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
|||
}
|
||||
}
|
||||
|
||||
if(levelObject) {
|
||||
if (levelObject) {
|
||||
//ImGuiDrawTeamSelect(levelObject,Id);
|
||||
ImGuiDrawSelection("Team##"+Id,levelObject->Team,Teams::AllOptions.begin(), Teams::AllOptions.end(),Teams::TeamToText);
|
||||
ImGuiDrawSelection("Team##" + Id, levelObject->Team, Teams::AllOptions.begin(), Teams::AllOptions.end(),
|
||||
Teams::TeamToText);
|
||||
Configs::g_imguiDrawOpts("Drop##" + Id, Configs::g_dropIdOpts, levelObject->DropId);
|
||||
}
|
||||
|
||||
if(railPoint){
|
||||
ImGui::Checkbox(("Use Offset##" + Id).c_str(),&railPoint->m_useOffset);
|
||||
if(railPoint->m_useOffset) {
|
||||
if (railPoint) {
|
||||
ImGui::Checkbox(("Use Offset##" + Id).c_str(), &railPoint->m_useOffset);
|
||||
if (railPoint->m_useOffset) {
|
||||
ImGui::Indent();
|
||||
ImGui::DragFloat3(("Offset##" + Id).c_str(), &(railPoint->m_offset.X),0.01);
|
||||
ImGui::DragFloat3(("Offset##" + Id).c_str(), &(railPoint->m_offset.X), 0.01);
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
unsigned i = 0;
|
||||
for(Vector3 &ctrlPoint: railPoint->m_controlPoints){
|
||||
ImGui::DragFloat3(("Control point " + std::to_string(i) + "##" + Id).c_str(), &(ctrlPoint.X),0.01);
|
||||
for (Vector3 &ctrlPoint: railPoint->m_controlPoints) {
|
||||
ImGui::DragFloat3(("Control point " + std::to_string(i) + "##" + Id).c_str(), &(ctrlPoint.X), 0.01);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
@ -205,29 +211,47 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
|||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if(!elem->Parameters.empty()) {
|
||||
if (ImGui::CollapsingHeader(("Parameters##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
for (int i = 0; i < elem->Parameters.size(); i++) {
|
||||
ImGui::InputInt(("Parameter " + std::to_string(i) + "##PropWind" + Id).c_str(),
|
||||
(int *) &elem->Parameters[i]);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button((ICON_FA_TRASH "##ParamDelete" + std::to_string(i) + "th" + Id).c_str())) {
|
||||
auto delparam = elem->Parameters.begin() + i;
|
||||
|
||||
elem->Parameters.erase(delparam);
|
||||
break;
|
||||
}
|
||||
ImGui::Unindent();
|
||||
}
|
||||
if (ImGui::Button((ICON_FA_PLUS "##ParamAdd" + Id).c_str())) {
|
||||
elem->Parameters.push_back(-99);
|
||||
}
|
||||
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if(!elem->FloatParameters.empty()) {
|
||||
if (ImGui::CollapsingHeader(("Float Parameters##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
for (int i = 0; i < elem->FloatParameters.size(); i++) {
|
||||
ImGui::InputFloat(("Float Parameter " + std::to_string(i) + "##PropWind" + Id).c_str(),
|
||||
ImGui::InputFloat(("Parameter " + std::to_string(i) + "##FloatParamPropWind" + Id).c_str(),
|
||||
&elem->FloatParameters[i]);
|
||||
}
|
||||
ImGui::Unindent();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button((ICON_FA_TRASH "##FloatParamDelete" + std::to_string(i) + "th" + Id).c_str())) {
|
||||
auto delparam = elem->FloatParameters.begin() + i;
|
||||
|
||||
elem->FloatParameters.erase(delparam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!elem->OtherOptions.empty()) {
|
||||
if (ImGui::Button((ICON_FA_PLUS "##FloatParamAdd" + Id).c_str())) {
|
||||
elem->FloatParameters.push_back(-99.0f);
|
||||
}
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if (!elem->OtherOptions.empty()) {
|
||||
if (ImGui::CollapsingHeader(("Miscellaneous Options##" + Id).c_str())) {
|
||||
ImGui::Indent();
|
||||
for (auto &opt: elem->OtherOptions) {
|
||||
|
|
@ -240,7 +264,7 @@ void ImGuiDrawElem(Element* elem,std::string Id = ""){
|
|||
}
|
||||
}
|
||||
|
||||
PropertiesWidget::PropertiesWidget(): Graphics::Widget("Properties",true) {
|
||||
PropertiesWidget::PropertiesWidget() : Graphics::Widget("Properties", true) {
|
||||
PropertiesWidgetInst = this;
|
||||
|
||||
GetMainWindow()->selectedElem = nullptr;
|
||||
|
|
@ -249,11 +273,11 @@ PropertiesWidget::PropertiesWidget(): Graphics::Widget("Properties",true) {
|
|||
void PropertiesWidget::Draw() {
|
||||
auto wind = GetMainWindow();
|
||||
|
||||
if(wind->selectedElem != nullptr){
|
||||
if (wind->selectedElem != nullptr) {
|
||||
ImGuiDrawElem(wind->selectedElem);
|
||||
}
|
||||
}
|
||||
|
||||
PropertiesWidget* GetPropertiesWidget(){
|
||||
PropertiesWidget *GetPropertiesWidget() {
|
||||
return PropertiesWidgetInst;
|
||||
}
|
||||
Loading…
Reference in a new issue