From 42ed6f82c8258f2c2f78e7effcf9d757de61accc Mon Sep 17 00:00:00 2001 From: wootguy Date: Sat, 6 Jul 2024 02:03:51 -0700 Subject: [PATCH] list base key before child keys in keyvalue editor important things like "targetname" should always be at the top --- src/editor/Fgd.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/editor/Fgd.cpp b/src/editor/Fgd.cpp index 62a517f6..9e0175d8 100644 --- a/src/editor/Fgd.cpp +++ b/src/editor/Fgd.cpp @@ -382,7 +382,8 @@ void Fgd::processClassInheritance() { if (allBaseClasses.size() != 0) { - vector newKeyvalues; + vector childKeyvalues; + vector baseKeyvalues; vector newSpawnflags; set addedKeys; set addedSpawnflags; @@ -393,7 +394,7 @@ void Fgd::processClassInheritance() { // add in fields from the child class for (int c = 0; c < classes[i]->keyvalues.size(); c++) { if (!addedKeys.count(classes[i]->keyvalues[c].name)) { - newKeyvalues.push_back(classes[i]->keyvalues[c]); + childKeyvalues.push_back(classes[i]->keyvalues[c]); addedKeys.insert(classes[i]->keyvalues[c].name); } if (classes[i]->keyvalues[c].iType == FGD_KEY_FLAGS) { @@ -416,7 +417,7 @@ void Fgd::processClassInheritance() { } for (int c = 0; c < allBaseClasses[k]->keyvalues.size(); c++) { if (!addedKeys.count(allBaseClasses[k]->keyvalues[c].name)) { - newKeyvalues.push_back(allBaseClasses[k]->keyvalues[c]); + baseKeyvalues.push_back(allBaseClasses[k]->keyvalues[c]); addedKeys.insert(allBaseClasses[k]->keyvalues[c].name); } if (allBaseClasses[k]->keyvalues[c].iType == FGD_KEY_FLAGS) { @@ -432,6 +433,13 @@ void Fgd::processClassInheritance() { if (verbose) logf(" %s\n", allBaseClasses[k]->name.c_str()); } + // base keyvalues are usually important things like "targetname" and should come first + vector newKeyvalues; + for (int i = 0; i < baseKeyvalues.size(); i++) + newKeyvalues.push_back(baseKeyvalues[i]); + for (int i = 0; i < childKeyvalues.size(); i++) + newKeyvalues.push_back(childKeyvalues[i]); + classes[i]->keyvalues = newKeyvalues; for (int c = 0; c < classes[i]->keyvalues.size(); c++) {