Add script goal editor properties and user actions

console-destruction
Sven Eberhardt 2016-08-20 01:54:49 -04:00
parent 4df8679be2
commit 56adee6bb9
7 changed files with 71 additions and 2 deletions

View File

@ -27,6 +27,12 @@ public func Fulfill()
return;
}
public func SetFulfilled(bool to_val)
{
fulfilled = to_val;
return;
}
public func GetDescription(int plr)
{
return this.Description;
@ -42,6 +48,47 @@ public func GetPictureName()
return this.PictureName ?? "";
}
/* Editor */
local overlay_picture;
public func Definition(def)
{
// Properties
if (!def.EditorProps) def.EditorProps = {};
def.EditorProps.Description = { Name="$PropDescription$", EditorHelp="$PropDescriptionHelp$", Type="string", Save="Description" };
def.EditorProps.overlay_picture = { Name="$Picture$", EditorHelp="$PictureHelp$", Type="def", Set="SetOverlayPicture", Save="Picture" };
// User actions
UserAction->AddEvaluator("Action", "Game", "$SetScriptGoalData$", "$SetScriptGoalDataDesc$", "set_script_goal_data", [def, def.EvalAct_SetData],
{ Target = { Function="action_object" }, Description = { Function="string_constant", Value="$Description$" }, Fulfilled = { Function="bool_constant", Value=false } },
{ Type="proplist", Display="{{Description}}, {{OverlayPicture}}, {{Fulfilled}}",
EditorProps = {
Target = new UserAction->GetObjectEvaluator("IsScriptGoal", "$Goal$") { Priority=50 },
Description = new UserAction.Evaluator.String { Name="$PropDescription$", EditorHelp="$PropDescriptionHelp$" },
OverlayPicture = new UserAction.Evaluator.Definition { Name="$Picture$", EditorHelp="$PictureHelp$" },
Fulfilled = new UserAction.Evaluator.Boolean { Name="$Fulfilled$", EditorHelp="$FulfilledHelp$" }
} } );
}
public func SetOverlayPicture(to_picture_def)
{
// Picutre + Overlay
overlay_picture = to_picture_def;
SetGraphics(nil, to_picture_def, 1, GFXOV_MODE_Picture);
return true;
}
public func IsScriptGoal() { return true; }
private func EvalAct_SetData(props, context)
{
var target = UserAction->EvaluateValue("Objct", props.Target, context);
if (!target || !target->~IsScriptGoal()) return;
target.Description = UserAction->EvaluateValue("String", props.Description, context);
target->~SetOverlayPicture(UserAction->EvaluateValue("Definition", props.OverlayPicture, context));
target->~SetFulfilled(UserAction->EvaluateValue("Boolean", props.Fulfilled, context));
}
/*-- Proplist --*/
local Name = "$Name$";
local Description = "$Description$";

View File

@ -1,2 +1,11 @@
Name=Scriptziel
Description=Script goal description: please change me
PropDescription=Beschreibung
PropDescriptionHelp=Beschreibungstext der angezeigt wird, wenn ein Spieler das Spielziel anklickt.
Picture=Bild
PictureHelp=Grafik, die ueber die Spielzielgrafik gelegt wird.
SetScriptGoalData=Spielzieldaten setzen
SetScriptGoalDataDesc=Setzt Nachricht und Bild eines Script-Spielzieles.
Goal=Spielziel
Fulfilled=Erfuellt
FulfilledHelp=Bestimmt, ob das Spielziel erfuellt ist. Wenn alle Spielziele erfuellt sind, wird die Runde beendet.

View File

@ -1,2 +1,11 @@
Name=Script goal
Description=Script goal description: please change me
Description=Script goal description: please change me
PropDescription=Description
PropDescriptionHelp=Description shown when the user clicks the game goal.
Picture=Picture
PictureHelp=Graphics overlayed on script goal picture.
SetScriptGoalData=Set script goal data
SetScriptGoalDataDesc=Sets script goal, message, picture and filfilled-status.
Goal=Goal
Fulfilled=Fulfilled
FulfilledHelp=Determines if the goal is fulfilled. Once all goals are flfilled, the game is ended.

View File

@ -26,7 +26,7 @@ local EvaluatorDefs;
local DefinitionPriority=99;
// Localized group names
local GroupNames = { Structure="$Structure$" };
local GroupNames = { Structure="$Structure$", Game="$Game$" };
// Storage for global user variables
static g_UserAction_global_vars;

View File

@ -11,6 +11,7 @@ UserPosition=Position
UserOffset=Verschiebung
UserAny=Wert
Structure=Gebaeude
Game=Spiel
None=Nichts
Noone=Niemand
AllPlayers=Alle Spieler

View File

@ -11,6 +11,7 @@ UserPosition=Position
UserOffset=Offset
UserAny=Value
Structure=Structure
Game=Game
None=Nothing
Noone=Noone
AllPlayers=All players

View File

@ -160,3 +160,5 @@ func SetGraphics(string new_gfx, ...)
}
func GetGraphics() { return goal_custom_graphics; }
public func IsGoal() { return true; }