node cloner

This commit is contained in:
milek7
2019-02-23 01:03:18 +01:00
parent 939aa73384
commit 5fe4e1213e
12 changed files with 205 additions and 18 deletions

View File

@@ -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();
}