mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
node cloner
This commit is contained in:
@@ -281,3 +281,50 @@ itemproperties_panel::render_group() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nodebank_panel::nodebank_panel() : ui_panel("nodebank", true) {
|
||||
size_min = { 100, 50 };
|
||||
size_max = { 1000, 1000 };
|
||||
title = "nodebank";
|
||||
|
||||
std::ifstream file;
|
||||
file.open("nodebank.txt", std::ios_base::in | std::ios_base::binary);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
if (line.size() > 2)
|
||||
m_nodebank.push_back(std::make_unique<std::string>(line));
|
||||
}
|
||||
|
||||
void
|
||||
nodebank_panel::render_contents() {
|
||||
ImGui::RadioButton("modify", (int*)&mode, MODIFY);
|
||||
ImGui::RadioButton("clone", (int*)&mode, COPY);
|
||||
ImGui::RadioButton("add", (int*)&mode, ADD);
|
||||
|
||||
ImGui::PushItemWidth(-1);
|
||||
if (ImGui::ListBoxHeader("##nodebank", ImVec2(-1, -1)))
|
||||
{
|
||||
int i = 0;
|
||||
for (auto const entry : m_nodebank) {
|
||||
std::string label = *entry + "##" + std::to_string(i);
|
||||
if (ImGui::Selectable(label.c_str(), entry == m_selectedtemplate))
|
||||
m_selectedtemplate = entry;
|
||||
i++;
|
||||
}
|
||||
|
||||
ImGui::ListBoxFooter();
|
||||
}
|
||||
}
|
||||
|
||||
void nodebank_panel::add_template(const std::string &desc) {
|
||||
std::ofstream file;
|
||||
file.open("nodebank.txt", std::ios_base::out | std::ios_base::app | std::ios_base::binary);
|
||||
file << desc;
|
||||
|
||||
m_nodebank.push_back(std::make_unique<std::string>(desc));
|
||||
}
|
||||
|
||||
const std::string *nodebank_panel::get_active_template() {
|
||||
return m_selectedtemplate.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user