forked from Mirrors/openclonk
Improve GetDefinitionGroupPath script function
* Now works on _this instead of parameter * Now works before editor window openedconsole-destruction
parent
41dde5e7d0
commit
d70506ee2e
|
@ -9,21 +9,14 @@
|
|||
<version>8.0 OC</version>
|
||||
<syntax>
|
||||
<rtype>string</rtype>
|
||||
<params>
|
||||
<param>
|
||||
<type>id</type>
|
||||
<name>definition</name>
|
||||
<desc>Definition to get the path of.</desc>
|
||||
</param>
|
||||
</params>
|
||||
</syntax>
|
||||
<desc>Returns the editor group path of a definition. This is the path at which the definition is shown in the creator window and can be used to gorup definitions in large dropdown enumerations.</desc>
|
||||
<desc>Returns the editor group path of the calling definition. This is the path at which the definition is shown in the creator window and can be used to gorup definitions in large dropdown enumerations.</desc>
|
||||
<examples>
|
||||
<example>
|
||||
<code>var index = 0, weapon_def, weapon_list = [];
|
||||
while (weapon_def = GetDefinition(index))
|
||||
{
|
||||
if (<funclink>WildcardMatch</funclink>(GetDefinitionGroupPath(weapon_def), "*/Weapons")
|
||||
if (<funclink>WildcardMatch</funclink>(weapon_def->GetDefinitionGroupPath(), "*/Weapons")
|
||||
weapon_list[GetLength(weapon_list)] = weapon_def;
|
||||
index++;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ public:
|
|||
bool CreateNewScenario(StdStrBuf *out_filename);
|
||||
void OnStartGame();
|
||||
void ClearGamePointers();
|
||||
void EnsureDefinitionListInitialized();
|
||||
|
||||
// TODO some qt editor stuff is in state and needs to be public
|
||||
// Once other editors are removed, C4ConsoleGUI, C4ConsoleQt and C4ConsoleQtState should be reorganized
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "C4Include.h"
|
||||
#include "editor/C4ConsoleQtState.h"
|
||||
#include "editor/C4ConsoleQtDefinitionListViewer.h"
|
||||
#include "editor/C4Console.h"
|
||||
#include "editor/C4ConsoleGUI.h"
|
||||
#include "landscape/C4Texture.h"
|
||||
|
@ -351,14 +352,19 @@ bool C4ConsoleGUI::CreateNewScenario(StdStrBuf *out_filename)
|
|||
|
||||
void C4ConsoleGUI::OnObjectSelectionChanged(class C4EditCursorSelection &selection)
|
||||
{
|
||||
// selection changed (through other means than creator or object list view)
|
||||
// reflect selection change in dialogues
|
||||
state->SetObjectSelection(selection);
|
||||
// selection changed (through other means than creator or object list view)
|
||||
// reflect selection change in dialogues
|
||||
state->SetObjectSelection(selection);
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::ClearGamePointers()
|
||||
{
|
||||
state->ClearGamePointers();
|
||||
state->ClearGamePointers();
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::EnsureDefinitionListInitialized()
|
||||
{
|
||||
state->definition_list_model->EnsureInit();
|
||||
}
|
||||
|
||||
void C4ToolsDlg::UpdateToolCtrls()
|
||||
|
|
|
@ -55,6 +55,14 @@ C4ConsoleQtDefinitionListModel::~C4ConsoleQtDefinitionListModel()
|
|||
{
|
||||
}
|
||||
|
||||
void C4ConsoleQtDefinitionListModel::EnsureInit()
|
||||
{
|
||||
// Init if not already done
|
||||
if (!root.get() || root->items.empty())
|
||||
if (::Definitions.GetDefCount())
|
||||
ReInit();
|
||||
}
|
||||
|
||||
void C4ConsoleQtDefinitionListModel::ReInit()
|
||||
{
|
||||
// Re-fill definition model with all loaded definitions matching condition
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
|
||||
// Refresh definition list (on initialization or e.g. after ReloadDef)
|
||||
void ReInit();
|
||||
void EnsureInit();
|
||||
void OnItemRemoved(class C4Def *def);
|
||||
|
||||
// Callback from EditCursor when selection was changed e.g. from property window
|
||||
|
|
|
@ -987,11 +987,13 @@ static C4Def * FnGetDefinition(C4PropList * _this, long iIndex)
|
|||
return ::Definitions.GetDef(iIndex);
|
||||
}
|
||||
|
||||
static C4String * FnGetDefinitionGroupPath(C4PropList * _this, C4ID id)
|
||||
static C4String * FnGetDefinitionGroupPath(C4PropList * _this)
|
||||
{
|
||||
// Must have loaded all paths
|
||||
::Console.EnsureDefinitionListInitialized();
|
||||
// Resolve definition
|
||||
C4Def *def = C4Id2Def(id);
|
||||
if (!def) return nullptr;
|
||||
C4Def *def = _this->GetDef();
|
||||
if (!def || !def->ConsoleGroupPath.getData()) return nullptr;
|
||||
return ::Strings.RegString(def->ConsoleGroupPath.getData());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue