From 0ad00b9b9eac2d95fd36d72a92138d3648dd983a Mon Sep 17 00:00:00 2001 From: wootguy Date: Tue, 23 Apr 2024 21:37:33 -0700 Subject: [PATCH] don't autofill key values with defaults in the Smart Edit tab if a key is not used, don't generate a value for it. If you click the field accidentally then you might add the key to the entity data without realizing it, which could possibly bug the map. Also, it should be possible to delete a key value from the smart edit tab by deleting its value. --- src/bsp/Bsp.cpp | 11 ++++++++++- src/editor/Gui.cpp | 21 +++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/bsp/Bsp.cpp b/src/bsp/Bsp.cpp index 4f56c746..1c8303aa 100644 --- a/src/bsp/Bsp.cpp +++ b/src/bsp/Bsp.cpp @@ -2851,7 +2851,7 @@ bool Bsp::downscale_texture(int textureId, int maxDim) { return false; } - downscale_texture(textureId, newWidth, newHeight); + return downscale_texture(textureId, newWidth, newHeight); } void Bsp::downscale_invalid_textures() { @@ -3543,6 +3543,15 @@ bool Bsp::validate() { isValid = false; } } + + if (nodes[i].nMins[0] > nodes[i].nMaxs[0] || + nodes[i].nMins[1] > nodes[i].nMaxs[1] || + nodes[i].nMins[2] > nodes[i].nMaxs[2]) { + logf("Backwards mins/maxs in node %d. Mins: (%d, %d, %d) Maxs: (%d %d %d)\n", i, + (int)nodes[i].nMins[0], (int)nodes[i].nMins[1], (int)nodes[i].nMins[2], + (int)nodes[i].nMaxs[0], (int)nodes[i].nMaxs[1], (int)nodes[i].nMaxs[2]); + isValid = false; + } } for (int i = 0; i < planeCount; i++) { BSPPLANE& plane = planes[i]; diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 7af0b53a..226a83df 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -1775,9 +1775,16 @@ void Gui::drawKeyvalueEditor_SmartEditTab(Entity* ent) { string value = ent->keyvalues[key]; string niceName = keyvalue.description; - if (value.empty() && keyvalue.defaultValue.length()) { - value = keyvalue.defaultValue; - } + // TODO: ImGui doesn't have placeholder text like in HTML forms, + // but it would be nice to show an example/default value here somehow. + // Forcing the default value is bad because that can change entity behavior + // in unexpected ways. The default should always be an empty string or 0 when + // you don't care about the key. I think I remember there being strange problems + // when JACK would autofill default values for every possible key in an entity. + // + //if (value.empty() && keyvalue.defaultValue.length()) { + // value = keyvalue.defaultValue; + //} strcpy(keyNames[i], niceName.c_str()); strcpy(keyValues[i], value.c_str()); @@ -1840,13 +1847,7 @@ void Gui::drawKeyvalueEditor_SmartEditTab(Entity* ent) { string newVal = data->Buf; if (newVal.empty()) { - if (inputData->defaultValue.length()) { - ent->setOrAddKeyvalue(inputData->key, inputData->defaultValue); - } - else { - ent->removeKeyvalue(inputData->key); - } - + ent->removeKeyvalue(inputData->key); } else { ent->setOrAddKeyvalue(inputData->key, newVal);