Skip to content

Commit

Permalink
don't autofill key values with defaults in the Smart Edit tab
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wootguy committed Apr 24, 2024
1 parent dbbe0af commit 0ad00b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
11 changes: 10 additions & 1 deletion src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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];
Expand Down
21 changes: 11 additions & 10 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0ad00b9

Please sign in to comment.