Add fractional input in nodebox properties
parent
383827e697
commit
87750e42d3
|
@ -5,6 +5,9 @@ snapping = true
|
||||||
# limiting stops node boxes going out of node bounds
|
# limiting stops node boxes going out of node bounds
|
||||||
limiting = true
|
limiting = true
|
||||||
|
|
||||||
|
# If true, positions in nodebox properties are shown as multiples of 1/16
|
||||||
|
fractional_positions = false
|
||||||
|
|
||||||
# Directory to save projects and export to.
|
# Directory to save projects and export to.
|
||||||
# Should be absolute path.
|
# Should be absolute path.
|
||||||
save_directory =
|
save_directory =
|
||||||
|
@ -14,7 +17,7 @@ save_directory =
|
||||||
# c://Games/Minetest/
|
# c://Games/Minetest/
|
||||||
# /home/rubenwardy/Game/Minetest/
|
# /home/rubenwardy/Game/Minetest/
|
||||||
# Do not include bin/minetest or bin/minetest.exe in the root.
|
# Do not include bin/minetest or bin/minetest.exe in the root.
|
||||||
minetest_root =
|
minetest_root =
|
||||||
|
|
||||||
# The view of each viewport
|
# The view of each viewport
|
||||||
# can be: pers, front, back, top, bottom, left, right
|
# can be: pers, front, back, top, bottom, left, right
|
||||||
|
|
|
@ -41,6 +41,6 @@ void addBox(IGUIElement* parent, IGUIEnvironment* guienv, vector2di pos, int ind
|
||||||
|
|
||||||
void addXYZ(IGUIElement* parent,IGUIEnvironment* guienv, vector2di pos, int startIndex){
|
void addXYZ(IGUIElement* parent,IGUIEnvironment* guienv, vector2di pos, int startIndex){
|
||||||
addBox(parent, guienv, vector2di(pos.X, pos.Y), startIndex, L"X"); // 0,0
|
addBox(parent, guienv, vector2di(pos.X, pos.Y), startIndex, L"X"); // 0,0
|
||||||
addBox(parent, guienv, vector2di(pos.X, pos.Y + 30), startIndex + 1, L"Y"); // 80, 0
|
addBox(parent, guienv, vector2di(pos.X, pos.Y + 25), startIndex + 1, L"Y"); // 80, 0
|
||||||
addBox(parent, guienv, vector2di(pos.X, pos.Y + 60), startIndex + 2, L"Z"); // 160, 0
|
addBox(parent, guienv, vector2di(pos.X, pos.Y + 50), startIndex + 2, L"Z"); // 160, 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
conf->set("snapping", "true");
|
conf->set("snapping", "true");
|
||||||
conf->set("limiting", "true");
|
conf->set("limiting", "true");
|
||||||
|
conf->set("fractional_positions", "false");
|
||||||
conf->set("driver", "opengl");
|
conf->set("driver", "opengl");
|
||||||
conf->set("hide_sidebar", "false");
|
conf->set("hide_sidebar", "false");
|
||||||
conf->set("save_directory", "");
|
conf->set("save_directory", "");
|
||||||
|
|
|
@ -19,6 +19,7 @@ enum NODEBOX_EDITOR_GUI_IDS {
|
||||||
ENB_GUI_PROP_Y2,
|
ENB_GUI_PROP_Y2,
|
||||||
ENB_GUI_PROP_Z2,
|
ENB_GUI_PROP_Z2,
|
||||||
ENB_GUI_PROP_NAME,
|
ENB_GUI_PROP_NAME,
|
||||||
|
ENB_GUI_PROP_DECIMALS,
|
||||||
ENB_GUI_PROP_UPDATE,
|
ENB_GUI_PROP_UPDATE,
|
||||||
ENB_GUI_PROP_REVERT,
|
ENB_GUI_PROP_REVERT,
|
||||||
ENB_GUI_FLP_X,
|
ENB_GUI_FLP_X,
|
||||||
|
@ -128,13 +129,19 @@ void NBEditor::load()
|
||||||
|
|
||||||
// Add positioning
|
// Add positioning
|
||||||
addXYZ(t, guienv, vector2di(10, 60), ENB_GUI_PROP_X1);
|
addXYZ(t, guienv, vector2di(10, 60), ENB_GUI_PROP_X1);
|
||||||
addXYZ(t, guienv, vector2di(10, 160), ENB_GUI_PROP_X2); // 60
|
addXYZ(t, guienv, vector2di(10, 140), ENB_GUI_PROP_X2);
|
||||||
|
|
||||||
|
// Add show decimals checkbox
|
||||||
|
bool fp = state->settings->getBool("fractional_positions");
|
||||||
|
guienv->addCheckBox(fp, rect<s32>(30, 215, 200, 245), t,
|
||||||
|
ENB_GUI_PROP_DECIMALS, L"As fractions of 16")->setNotClipped(true);
|
||||||
|
|
||||||
// Add buttons
|
// Add buttons
|
||||||
guienv->addButton(rect<s32>(30, 250, 100, 280), t, ENB_GUI_PROP_UPDATE,
|
guienv->addButton(rect<s32>(30, 250, 100, 250+30), t, ENB_GUI_PROP_UPDATE,
|
||||||
L"Update", L"")->setNotClipped(true);
|
L"Update", L"")->setNotClipped(true);
|
||||||
guienv->addButton(rect<s32>(110, 250, 180, 280), t, ENB_GUI_PROP_REVERT,
|
guienv->addButton(rect<s32>(110, 250, 180, 250+30), t, ENB_GUI_PROP_REVERT,
|
||||||
L"Revert", L"")->setNotClipped(true);
|
L"Revert", L"")->setNotClipped(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
load_ui();
|
load_ui();
|
||||||
}
|
}
|
||||||
|
@ -179,23 +186,30 @@ void NBEditor::fillProperties()
|
||||||
IGUIStaticText *sidebar = state->menu->sidebar;
|
IGUIStaticText *sidebar = state->menu->sidebar;
|
||||||
Node *node = state->project->GetCurrentNode();
|
Node *node = state->project->GetCurrentNode();
|
||||||
|
|
||||||
if (!sidebar || !node) {
|
if (!sidebar || !node)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
NodeBox *nb = node->GetCurrentNodeBox();
|
NodeBox *nb = node->GetCurrentNodeBox();
|
||||||
|
|
||||||
if (!nb) {
|
if (!nb)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
sidebar->getElementFromId(ENB_GUI_PROP)->setVisible(true);
|
sidebar->getElementFromId(ENB_GUI_PROP)->setVisible(true);
|
||||||
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_X1, nb->one.X);
|
|
||||||
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Y1, nb->one.Y);
|
vector3df one = nb->one;
|
||||||
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Z1, nb->one.Z);
|
vector3df two = nb->two;
|
||||||
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_X2, nb->two.X);
|
|
||||||
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Y2, nb->two.Y);
|
if (state->settings->getBool("fractional_positions")) {
|
||||||
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Z2, nb->two.Z);
|
one *= 16;
|
||||||
|
two *= 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_X1, one.X);
|
||||||
|
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Y1, one.Y);
|
||||||
|
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Z1, one.Z);
|
||||||
|
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_X2, two.X);
|
||||||
|
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Y2, two.Y);
|
||||||
|
fillTB(sidebar, ENB_GUI_PROP, ENB_GUI_PROP_Z2, two.Z);
|
||||||
|
|
||||||
IGUIElement* element = sidebar->getElementFromId(ENB_GUI_PROP)
|
IGUIElement* element = sidebar->getElementFromId(ENB_GUI_PROP)
|
||||||
->getElementFromId(ENB_GUI_PROP_NAME);
|
->getElementFromId(ENB_GUI_PROP_NAME);
|
||||||
|
@ -346,8 +360,8 @@ void CDR::update(NBEditor* editor, bool drag, rect<s32> offset)
|
||||||
|
|
||||||
// Snapping
|
// Snapping
|
||||||
wpos -= vector3df(
|
wpos -= vector3df(
|
||||||
(f32)node->position.X,
|
(f32)node->position.X,
|
||||||
(f32)node->position.Y,
|
(f32)node->position.Y,
|
||||||
(f32)node->position.Z
|
(f32)node->position.Z
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -382,6 +396,7 @@ void CDR::update(NBEditor* editor, bool drag, rect<s32> offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call required function
|
// Call required function
|
||||||
|
editor->fillProperties();
|
||||||
if (actualType < CDR_XZ) {
|
if (actualType < CDR_XZ) {
|
||||||
box->resizeNodeBoxFace(editor->state, actualType, wpos,
|
box->resizeNodeBoxFace(editor->state, actualType, wpos,
|
||||||
editor->state->keys[KEY_LCONTROL] == EKS_DOWN);
|
editor->state->keys[KEY_LCONTROL] == EKS_DOWN);
|
||||||
|
@ -435,7 +450,16 @@ void CDR::update(NBEditor* editor, bool drag, rect<s32> offset)
|
||||||
|
|
||||||
bool NBEditor::OnEvent(const irr::SEvent &event) {
|
bool NBEditor::OnEvent(const irr::SEvent &event) {
|
||||||
if (event.EventType == EET_GUI_EVENT) {
|
if (event.EventType == EET_GUI_EVENT) {
|
||||||
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) {
|
if (event.GUIEvent.EventType == EGET_CHECKBOX_CHANGED) {
|
||||||
|
switch (event.GUIEvent.Caller->getID()) {
|
||||||
|
case ENB_GUI_PROP_DECIMALS: {
|
||||||
|
bool fp = state->settings->getBool("fractional_positions");
|
||||||
|
state->settings->set("fractional_positions",
|
||||||
|
fp?"false":"true");
|
||||||
|
fillProperties();
|
||||||
|
return true;
|
||||||
|
}}
|
||||||
|
} else if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) {
|
||||||
switch (event.GUIEvent.Caller->getID()) {
|
switch (event.GUIEvent.Caller->getID()) {
|
||||||
case GUI_PROJ_NEW_BOX: {
|
case GUI_PROJ_NEW_BOX: {
|
||||||
Node* node = state->project->GetCurrentNode();
|
Node* node = state->project->GetCurrentNode();
|
||||||
|
@ -579,16 +603,27 @@ void NBEditor::updateProperties()
|
||||||
try {
|
try {
|
||||||
irr::core::stringc name = prop->getElementFromId(ENB_GUI_PROP_NAME)->getText();
|
irr::core::stringc name = prop->getElementFromId(ENB_GUI_PROP_NAME)->getText();
|
||||||
nb->name = str_replace(std::string(name.c_str(), name.size()), ' ', '_');
|
nb->name = str_replace(std::string(name.c_str(), name.size()), ' ', '_');
|
||||||
nb->one = vector3df(
|
vector3df one(
|
||||||
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_X1)->getText(), NULL),
|
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_X1)->getText(), NULL),
|
||||||
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Y1)->getText(), NULL),
|
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Y1)->getText(), NULL),
|
||||||
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Z1)->getText(), NULL)
|
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Z1)->getText(), NULL)
|
||||||
);
|
);
|
||||||
nb->two = vector3df(
|
vector3df two(
|
||||||
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_X2)->getText(), NULL),
|
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_X2)->getText(), NULL),
|
||||||
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Y2)->getText(), NULL),
|
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Y2)->getText(), NULL),
|
||||||
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Z2)->getText(), NULL)
|
(f32)wcstod(prop->getElementFromId(ENB_GUI_PROP_Z2)->getText(), NULL)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (state->settings->getBool("fractional_positions")) {
|
||||||
|
one /= 16;
|
||||||
|
two /= 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (one != nb->one || two != nb->two) {
|
||||||
|
nb->one = one;
|
||||||
|
nb->two = two;
|
||||||
|
nb->rebuild_needed = true;
|
||||||
|
}
|
||||||
node->remesh();
|
node->remesh();
|
||||||
load_ui();
|
load_ui();
|
||||||
} catch(void* e) {
|
} catch(void* e) {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
class EditorState;
|
class EditorState;
|
||||||
class NBEditor;
|
class NBEditor;
|
||||||
|
|
||||||
class CDR
|
class CDR
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -24,6 +23,7 @@ public:
|
||||||
class EditorMode;
|
class EditorMode;
|
||||||
class NBEditor :public EditorMode
|
class NBEditor :public EditorMode
|
||||||
{
|
{
|
||||||
|
friend class CDR;
|
||||||
public:
|
public:
|
||||||
NBEditor(EditorState* st);
|
NBEditor(EditorState* st);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue