forked from Mirrors/openclonk
Sort UserAction evaluators and groups by name
Also merge effect group into ambience group.console-destruction
parent
e2e9248d89
commit
6b9df3118c
|
@ -26,7 +26,7 @@ local EvaluatorDefs;
|
|||
local DefinitionPriority=99;
|
||||
|
||||
// Localized group names
|
||||
local GroupNames = { Structure="$Structure$", Game="$Game$", Effect="$Effect$" };
|
||||
local GroupNames = { Structure="$Structure$", Game="$Game$", Ambience="$Ambience$" };
|
||||
|
||||
// Storage for global user variables
|
||||
static g_UserAction_global_vars;
|
||||
|
@ -69,19 +69,19 @@ func Definition(def)
|
|||
{
|
||||
// Typed evaluator base definitions
|
||||
Evaluator = {};
|
||||
Evaluator.Action = { Name="$UserAction$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.Object = { Name="$UserObject$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.ObjectList = { Name="$UserObjectList$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.Definition = { Name="$UserDefinition$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.Player = { Name="$UserPlayer$", Type="enum", OptionKey="Function", Options = [ { Name="$Noone$" } ] };
|
||||
Evaluator.PlayerList = { Name="$UserPlayerList$", Type="enum", OptionKey="Function", Options = [ { Name="$Noone$" } ] };
|
||||
Evaluator.Boolean = { Name="$UserBoolean$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.Integer = { Name="$UserInteger$", Type="enum", OptionKey="Function", Options = [ {Name="0"} ] };
|
||||
Evaluator.Color = { Name="$UserColor$", Type="enum", OptionKey="Function", Options = [ {Name="$Default$"} ] };
|
||||
Evaluator.String = { Name="$UserString$", Type="enum", OptionKey="Function", Options = [ {Name="($EmptyString$)"} ] };
|
||||
Evaluator.Position = { Name="$UserPosition$", Type="enum", OptionKey="Function", Options = [ { Name="$Here$" } ] };
|
||||
Evaluator.Offset = { Name="$UserOffset$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.Any = { Name="$UserAny$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
|
||||
Evaluator.Action = { Name="$UserAction$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
Evaluator.Object = { Name="$UserObject$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
Evaluator.ObjectList = { Name="$UserObjectList$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
Evaluator.Definition = { Name="$UserDefinition$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
Evaluator.Player = { Name="$UserPlayer$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$Noone$", Priority=100 } ] };
|
||||
Evaluator.PlayerList = { Name="$UserPlayerList$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$Noone$", Priority=100 } ] };
|
||||
Evaluator.Boolean = { Name="$UserBoolean$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
Evaluator.Integer = { Name="$UserInteger$", Type="enum", OptionKey="Function", Sorted=true, Options = [ {Name="0", Priority=100 } ] };
|
||||
Evaluator.Color = { Name="$UserColor$", Type="enum", OptionKey="Function", Sorted=true, Options = [ {Name="$Default$", Priority=100 } ] };
|
||||
Evaluator.String = { Name="$UserString$", Type="enum", OptionKey="Function", Sorted=true, Options = [ {Name="($EmptyString$)", Priority=100 } ] };
|
||||
Evaluator.Position = { Name="$UserPosition$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$Here$", Priority=100 } ] };
|
||||
Evaluator.Offset = { Name="$UserOffset$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
Evaluator.Any = { Name="$UserAny$", Type="enum", OptionKey="Function", Sorted=true, Options = [ { Name="$None$", Priority=100 } ] };
|
||||
// Action evaluators
|
||||
EvaluatorCallbacks = {};
|
||||
EvaluatorDefs = {};
|
||||
|
@ -150,7 +150,7 @@ func Definition(def)
|
|||
Object = new Evaluator.Object { Name="$Object$", EditorHelp="$DoEnergyObjectHelp$" },
|
||||
Value = new Evaluator.Integer { Name="$ValueChange$", EditorHelp="$DoEnergyValueChangeHelp$" }
|
||||
} } );
|
||||
AddEvaluator("Action", "Effect", "$CastParticles$", "$CastParticlesHelp$", "cast_particles", [def, def.EvalAct_CastParticles], {
|
||||
AddEvaluator("Action", "Ambience", "$CastParticles$", "$CastParticlesHelp$", "cast_particles", [def, def.EvalAct_CastParticles], {
|
||||
Name="StarFlash",
|
||||
Amount={Function="int_constant", Value=8},
|
||||
Speed={Function="int_constant", Value=20},
|
||||
|
|
|
@ -304,7 +304,6 @@ FlingSpeedXHelp=Horizontale Geschwindigkeit in 1/10px pro Frame.
|
|||
FlingSpeedYHelp=Vertikale Geschwindigkeit in 1/10px pro Frame.
|
||||
AddSpeedY=Geschwindigkeit addieren
|
||||
FlingAddSpeedHelp=Ob die schon vorhandene Objektgeschwindigkeit addiert werden soll.
|
||||
Effect=Effekt
|
||||
DoWealth=Reichtum aendern
|
||||
DoWealthHelp=Fuegt dem Spieler Clunker hinzu oder nimmt sie weg.
|
||||
Change=Aenderung
|
||||
|
|
|
@ -304,7 +304,6 @@ FlingSpeedXHelp=Horizontal speed in 1/10px per frame.
|
|||
FlingSpeedYHelp=Vertical speed in 1/10px per frame.
|
||||
AddSpeedY=Add speed
|
||||
FlingAddSpeedHelp=Whether existing speed should be added to the fling speed.
|
||||
Effect=Effect
|
||||
DoWealth=Change wealth
|
||||
DoWealthHelp=Adds or removes clunker from the player's account.
|
||||
Change=Change
|
||||
|
|
|
@ -888,7 +888,7 @@ void C4PropertyDelegateEnumEditor::paintEvent(QPaintEvent *ev)
|
|||
/* Enumeration (dropdown list) delegate */
|
||||
|
||||
C4PropertyDelegateEnum::C4PropertyDelegateEnum(const C4PropertyDelegateFactory *factory, C4PropList *props, const C4ValueArray *poptions)
|
||||
: C4PropertyDelegate(factory, props), allow_editing(false)
|
||||
: C4PropertyDelegate(factory, props), allow_editing(false), sorted(false)
|
||||
{
|
||||
// Build enum options from C4Value definitions in script
|
||||
if (!poptions && props) poptions = props->GetPropertyArray(P_Options);
|
||||
|
@ -899,6 +899,7 @@ C4PropertyDelegateEnum::C4PropertyDelegateEnum(const C4PropertyDelegateFactory *
|
|||
default_value_key = props->GetPropertyStr(P_ValueKey);
|
||||
allow_editing = props->GetPropertyBool(P_AllowEditing);
|
||||
empty_name = props->GetPropertyStr(P_EmptyName);
|
||||
sorted = props->GetPropertyBool(P_Sorted);
|
||||
}
|
||||
if (poptions)
|
||||
{
|
||||
|
@ -933,6 +934,7 @@ C4PropertyDelegateEnum::C4PropertyDelegateEnum(const C4PropertyDelegateFactory *
|
|||
option.storage_type = Option::StorageByValue;
|
||||
// Child delegate for value (resolved at runtime because there may be circular references)
|
||||
props->GetProperty(P_Delegate, &option.adelegate_val);
|
||||
option.priority = props->GetPropertyInt(P_Priority);
|
||||
options.push_back(option);
|
||||
}
|
||||
}
|
||||
|
@ -963,12 +965,22 @@ QStandardItemModel *C4PropertyDelegateEnum::CreateOptionModel() const
|
|||
if (row_index < 0)
|
||||
{
|
||||
QStandardItem *new_group = new QStandardItem(group_name);
|
||||
if (sorted)
|
||||
{
|
||||
// Groups always sorted by name. Could also sort by priority of highest priority element?
|
||||
new_group->setData(group_name, C4DeepQComboBox::PriorityNameSortRole);
|
||||
}
|
||||
parent->appendRow(new_group);
|
||||
parent = new_group;
|
||||
}
|
||||
}
|
||||
}
|
||||
QStandardItem *new_item = new QStandardItem(QString(opt.name->GetCStr()));
|
||||
if (sorted)
|
||||
{
|
||||
// Reverse priority and make positive, so we can sort by descending priority but ascending name
|
||||
new_item->setData(QString(FormatString("%09d%s", (int)(10000000-opt.priority), opt.name->GetCStr()).getData()), C4DeepQComboBox::PriorityNameSortRole);
|
||||
}
|
||||
new_item->setData(QVariant(idx), C4DeepQComboBox::OptionIndexRole);
|
||||
C4Object *item_obj_data = opt.value.getObj();
|
||||
if (item_obj_data) new_item->setData(QVariant(item_obj_data->Number), C4DeepQComboBox::ObjectHighlightRole);
|
||||
|
@ -983,6 +995,12 @@ QStandardItemModel *C4PropertyDelegateEnum::CreateOptionModel() const
|
|||
parent->appendRow(new_item);
|
||||
++idx;
|
||||
}
|
||||
// Sort model and all groups
|
||||
if (sorted)
|
||||
{
|
||||
model->setSortRole(C4DeepQComboBox::PriorityNameSortRole);
|
||||
model->sort(0, Qt::AscendingOrder);
|
||||
}
|
||||
return model.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,7 @@ public:
|
|||
OptionIndexRole = Qt::UserRole + 1,
|
||||
ObjectHighlightRole = Qt::UserRole + 2,
|
||||
ValueStringRole = Qt::UserRole + 3,
|
||||
PriorityNameSortRole = Qt::UserRole + 4,
|
||||
};
|
||||
|
||||
C4DeepQComboBox(QWidget *parent, C4StyledItemDelegateWithButton::ButtonType button_type, bool editable);
|
||||
|
@ -328,8 +329,9 @@ public:
|
|||
StorageByValue=2, // This option sets a constant value
|
||||
StorageByKey=3, // Assume value is a proplist; identify option by field option_key
|
||||
} storage_type;
|
||||
int32_t priority; // Custom sort order
|
||||
|
||||
Option() : type(C4V_Any), adelegate(NULL), storage_type(StorageNone) {}
|
||||
Option() : type(C4V_Any), adelegate(NULL), storage_type(StorageNone), priority(0) {}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
@ -338,6 +340,7 @@ protected:
|
|||
private:
|
||||
std::vector<Option> options;
|
||||
bool allow_editing;
|
||||
bool sorted;
|
||||
|
||||
protected:
|
||||
C4RefCntPointer<C4String> empty_name; // Override for name of empty option
|
||||
|
|
|
@ -291,6 +291,7 @@ C4StringTable::C4StringTable()
|
|||
P[P_AllowEditing] = "AllowEditing";
|
||||
P[P_EditorInitialize] = "EditorInitialize";
|
||||
P[P_EditorPlacementLimit] = "EditorPlacementLimit";
|
||||
P[P_Sorted] = "Sorted";
|
||||
P[DFA_WALK] = "WALK";
|
||||
P[DFA_FLIGHT] = "FLIGHT";
|
||||
P[DFA_KNEEL] = "KNEEL";
|
||||
|
|
|
@ -515,6 +515,7 @@ enum C4PropertyName
|
|||
P_AllowEditing,
|
||||
P_EditorInitialize,
|
||||
P_EditorPlacementLimit,
|
||||
P_Sorted,
|
||||
// Default Action Procedures
|
||||
DFA_WALK,
|
||||
DFA_FLIGHT,
|
||||
|
|
Loading…
Reference in New Issue