Commit Graph

808 Commits (61962fe70abd22a665446cc09fcef163bf0e3862)

Author SHA1 Message Date
Sven Eberhardt bce09d272d Add EditorInitialize callback 2016-08-04 22:12:10 -04:00
Sven Eberhardt 24a5dc33db Qt editor: Sort properties in property list by localized name and priority 2016-08-02 01:12:08 -04:00
Sven Eberhardt b1a1df8dee Add eval parameter to not pass errors 2016-07-31 08:15:54 -04:00
Sven Eberhardt 18444c7e0d Add StringToIdentifier script function
Required to sanitize variables in the editor. Works by stripping all non-identifier characters and preprending a _ if necessery.
2016-07-30 21:43:01 -04:00
Sven Eberhardt 442b8e66df Qt Editor: Add short name for enum delegate options displayed as sub-delegate 2016-07-30 14:50:07 -04:00
Sven Eberhardt 37885a2e4f Qt Editor: Add AllowEditing flag for enum delegates.
Used for sound delegate
2016-07-28 00:24:28 -04:00
Sven Eberhardt ee88a36f73 Qt Editor: Rename EditorInfo to EditorHelp
Fits better with "UsageHelp" and is more precise.
2016-07-24 23:10:43 -04:00
Sven Eberhardt 534e4cc745 Merge branch 'master' into qteditor
Conflicts:
	src/script/C4AulParse.cpp
2016-07-24 10:23:57 -04:00
Sven Eberhardt 4245f60e83 Qt Editor: Add help/description label for current selection 2016-07-24 10:12:38 -04:00
Sven Eberhardt 14d01cd5cd Qt Editor: Add EmptyName option for def property to rename the "nil" entry 2016-07-22 00:28:01 -04:00
Sven Eberhardt 4fad947980 Qt Editor: Add Set function options SetGlobal and SetRoot 2016-07-21 00:24:53 -04:00
Sven Eberhardt d605bab0be Qt Editor: Move EditorActions from EditorAction_* to a proplist EditorAction.* 2016-07-14 00:17:53 -04:00
Sven Eberhardt 28d2172b78 Qt Editor: Move editor props from EditorProp_* to an EditorProp proplist 2016-07-13 17:18:08 -04:00
Sven Eberhardt d9f31b006b Add ReplaceString script function 2016-07-13 02:12:31 -04:00
Lukas Werling 2127e78db1 Fix c4script build 2016-07-07 22:50:13 +02:00
Lukas Werling 791315a54e Fix #include-in-#appendto, but discourage with a warning 2016-07-07 21:13:18 +02:00
Nicolas Hake dcd8d9676a Fix unloading scenarios with Map.c or System.ocg scripts (#1778)
Destruction order matters!
2016-07-07 14:39:18 +02:00
Nicolas Hake 4725043493 Def unload: Fix overloaded function refcount 2016-07-07 14:34:24 +02:00
Sven Eberhardt 85c5deb099 Qt Editor: Add option to auto-select objects created by an EditorAction
To be used by the dialogue so you can press a button on the clonk to add and immediately configure a dialogue.
2016-07-07 01:36:58 -04:00
Nicolas Hake 7ff8c4f95a Remove references to functions defined in unloading defs (#1776) 2016-07-06 14:41:22 +02:00
Sven Eberhardt 990b6ea8f1 Qt Editor: Add option to descend directly into a subpath from array and sequence property delegates 2016-07-06 00:56:08 -04:00
Sven Eberhardt 62c1f4bda5 Qt Editor: Add callback support for dynamic enum values in Enum delegates 2016-07-04 13:21:30 -04:00
Sven Eberhardt b34ae09437 Fix utility builds 2016-06-21 21:48:10 -04:00
Sven Eberhardt a7aa89f168 Merge branch 'master' into qteditor
Conflicts:
	planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c
	src/platform/C4WindowSDL.cpp
	src/script/C4AulParse.cpp
	src/script/C4Effect.cpp
2016-06-20 22:27:03 -04:00
Sven Eberhardt 068004d9af Remove unused variable in C4AulExec 2016-06-20 15:50:36 -04:00
Sven Eberhardt c6e4bfd585 Aul: Add DirectExec method for executing a complete function definition. 2016-06-20 01:37:04 -04:00
Sven Eberhardt 34289fa18a Qt Editor: Add EditorActions.
Replacing the old EditCursorCommands (which nobody knew). Objects now publish their commands directly on the property viewer.
2016-06-19 00:08:09 -04:00
Sven Eberhardt a7bd20a927 Fix server and utility build
Adding missing C4DefList::SortByPriority() stub
2016-06-18 10:35:54 -04:00
Sven Eberhardt ad863836b3 Qt Editor: Add groups to enum 2016-06-15 00:15:47 -04:00
Sven Eberhardt 397dbd867a Add DefinitionPriority property to control call order of Definition()-callbacks. 2016-06-07 18:22:43 -04:00
Sven Eberhardt 16e31098b4 Qt Editor: Improve proplist and array display/editing
* Add/Remove element buttons
* Display customization of user delegates
2016-06-06 01:54:05 -04:00
Sven Eberhardt 4d04135cda Fix GetPropertyBool default value when descending into prototype [Guenther] 2016-06-03 20:17:20 -04:00
Sven Eberhardt b10da0629d Qt Editor: More EditorProps types (string, array) and attributes (EditOnSelection, DefaultEditorProp) 2016-06-03 01:20:43 -04:00
Günther Brammer 57a35bf01b Don't crash on functions declared inside other functions
Declaring a local variable inside any function works the same way as
declaring it in top-level scope, which gets a bit weird if done inside a
function inside a constant proplist, but is at least consistent.

Thanks to Flinti for reporting this.
2016-05-25 01:06:10 +02:00
Sven Eberhardt 8a5dbdc73f Qt Editor: More shape prop storage options 2016-05-23 19:22:49 -04:00
Nicolas Hake 3fd1187833 Don't overload CompileNewFunc with rvalue reference parameters
We don't need to pass the C4ValueNumbers* as a rvalue reference, and
doing so needs const qualifiers on MSVC.
2016-05-21 12:56:57 +02:00
Günther Brammer d23ffde361 Merge script branch 2016-05-15 19:21:26 +02:00
Günther Brammer 6763f2b5c7 Silence complaints about missing functions in EffectCall (#1736)
All the other effect callbacks silently ignored missing functions, either
by using the Call variant that doesn't complain about it, or checking for
the missing function themselves.
2016-05-15 19:20:43 +02:00
Günther Brammer 0559a93f88 Script: CreateEffect effects do not get their target in callbacks
They can use the Target property instead.
2016-05-15 15:20:08 +02:00
Günther Brammer 3aa6978c4e Script: Effects have their target as a property "Target" 2016-05-15 15:17:18 +02:00
Günther Brammer c0d32f8f4e Remove redundant target parameters from effect implementation 2016-05-15 15:17:17 +02:00
Günther Brammer 6aaf7cd2ef Store a pointer to the effect target in the effect itself 2016-05-15 15:17:17 +02:00
Günther Brammer 408ac90cd7 Scenario effects: Use Scenario and not Scenario->GetPrototype() as this() 2016-05-15 15:17:17 +02:00
Günther Brammer f927717458 CreateEffect initializes the name of the new effect
Effects with prototypes were supposed to inherit their names from the
prototype, but the effect prototypes are also supposed to get their names
from ParentKeyName, which is not inherited. Maybe that'll change, but for
now this matches how old effects work.
2016-05-15 15:17:17 +02:00
Günther Brammer 5c6a805fd5 Add move constructor to C4Value 2016-05-15 15:17:17 +02:00
Günther Brammer 9e8d644a26 StdAdaptors: Make mkParAdapt(mkPtrAdaptNoNull(), Par1, Par2) work
Employ variadic template arguments and more rvalue references for this.
Sadly, StdParameterAdapt itself is even more complicated, since it has to
store the parameters instead of just forwarding them, so the limit is still
two parameters. But that's twice as much as before in many cases.
2016-05-14 22:59:59 +02:00
Nicolas Hake 511e3bbb36 Aul: Deprecate implicit conversion from 0 to object/proplist/def/string
Instead of (int)0, nil should be used to signify "no object" etc.
2016-05-13 16:28:45 +02:00
Nicolas Hake 370a1dd3d1 Aul: Re-enable parameter type checking after AST rewrite 2016-05-13 16:22:37 +02:00
Nicolas Hake 3217fbf55b C4AulScriptFunc::AddPar: Accept type in addition to name
This way, we don't have to first add the parameter and then set the type
afterwards via internal members.
2016-05-13 16:22:00 +02:00
Nicolas Hake eca8f2cce8 Aul: && returns either parameter, not bool 2016-05-13 16:20:17 +02:00
Nicolas Hake 43c6f946dd Aul: Split assignment op from standard BinOp
Assignment was special-cased everywhere, so it can just as well get a
separate AST node.
2016-05-13 13:50:29 +02:00
Nicolas Hake daf3424e63 Delete some commented-out legacy function parameters 2016-05-13 13:14:23 +02:00
Nicolas Hake 092a23c2f7 Aul: Parse scripts into an AST, then generate bytecode from that
This commit contains a fairly substantial rewrite of the C4Script code
generator. Instead of generating bytecode while parsing the script,
we're now parsing the script into a syntax tree, and have any further
processing happen on that instead of the raw source.

At this time, the code generator emits the same bytecode as the old
parser; there are several optimization opportunities that arise from the
new possibility to emit code out of order from its specification by the
author.

Compared to the old compiler, this one is still rather deficient when
dealing with incorrect code; it's also not emitting several warnings
that used to be diagnosed.
2016-05-12 19:43:48 +02:00
Nicolas Hake 78e5f8528d C4PropList::GetParent: make const 2016-05-12 18:47:53 +02:00
Nicolas Hake 5872b5e8ae C4AulFunc::GetFullName: make const 2016-05-11 17:15:47 +02:00
Nicolas Hake 10abb1bbdb Remove unused C4AUL_CodeBufSize 2016-05-11 17:15:47 +02:00
Nicolas Hake a100b93e7f DEBUG_BYTECODE_DUMP: Allow setting from build system 2016-05-11 17:15:47 +02:00
Nicolas Hake 16641d3841 C4AulScriptFunc::DumpByteCode: properly align BCC names
The old code just appended eight spaces when the type of the BCC was
shorter than eight chars.
2016-05-11 17:15:47 +02:00
Nicolas Hake 26334cb4d7 Aul: Join AB_INT + AB_Neg 2016-05-09 12:33:59 +02:00
Nicolas Hake 34556e3e81 Aul: Join AB_STRING+AB_ARRAYA to AB_PROP 2016-05-09 12:33:58 +02:00
Nicolas Hake 33f7fb935f C4AulCompiler: Rename iStack to stack_height 2016-05-09 12:33:51 +02:00
Nicolas Hake 41000a8f9a C4AulCompiler: Rename pLoopStack to active_loops 2016-05-09 12:21:33 +02:00
Nicolas Hake d0dbe05876 C4AulCompiler: Rename fJump to at_jump_target
You have no idea how much I hate systems hungarian.
2016-05-09 12:21:33 +02:00
Nicolas Hake f0b4ef46a5 GetStackValue: Remove "default: /* unreachable */"
Without an explicit default case, the compiler can warn about unhandled
enum values inside the switch.
2016-05-09 12:21:33 +02:00
Nicolas Hake 7a135a060f C4AulParse: Take GetTokenName out of public interface 2016-05-09 12:21:33 +02:00
Nicolas Hake 0a3b31e735 C4AulParse::AddVarAccess: Move to C4AulCompiler 2016-05-09 12:21:33 +02:00
Nicolas Hake 0342711cd4 C4AulCompiler: Take GetStackValue out of public interface 2016-05-09 12:21:33 +02:00
Nicolas Hake 792e12adad C4AulCompiler: Split into separate file 2016-05-09 12:21:33 +02:00
Nicolas Hake c8d71d47c0 C4CodeGen: Rename to C4AulCompiler
I need to split up C4CodeGen into smaller parts, and having the bit that
actually generates the bytecode named C4CodeGenCodeGen would be silly.
2016-05-09 12:21:33 +02:00
Günther Brammer 69427a484a C4AulParse: Check for function names after '->' with the helper function 2016-05-05 02:47:17 +02:00
Günther Brammer 994cb52cea C4AulParse: Don't escape spaces in bytecode dumps of strings 2016-05-05 02:38:36 +02:00
Günther Brammer 99f704fbb8 Script: Prevent writes to constant arrays 2016-05-05 02:10:41 +02:00
Günther Brammer 9741af42fd Replace all usages of the old local variables list with properties 2016-05-01 00:28:37 +02:00
Günther Brammer 7792acdff0 Script: Check for functions before keywords
This unifies the lookup for local variables and functions. Its slightly
awkward that global functions can overload if and Par now, but local
variables already could.
2016-05-01 00:28:37 +02:00
Günther Brammer 30f7457d89 Remove unused macros leftover from removed script features 2016-05-01 00:28:37 +02:00
Günther Brammer b8f2d0ca87 Script: Repeat the parser error message when executing a broken function 2016-05-01 00:28:37 +02:00
Günther Brammer 17b18da26c Make bytecode dump work again
Dumping the bytecode before adding EOFN while depending on that to signal
the end isn't such a hot idea.
2016-05-01 00:28:37 +02:00
Günther Brammer 904bf78d68 Don't crash when deserializing an effect with object command target (#1730) 2016-04-29 00:16:20 +02:00
Günther Brammer 4092911349 Move code generation into its own class 2016-04-28 03:25:47 +02:00
Günther Brammer b00b8554ab Merge branch script 2016-04-28 03:25:44 +02:00
Günther Brammer d45ac946fe Add C4AulParseError constructor and cease reusing it for warnings
The nontrivial code that formats the position is now a function of
C4AulParse used by both warnings and errors.
2016-04-28 02:59:12 +02:00
Nicolas Hake a8f4bd3960 C4AulParseError: Avoid the second string parameter
While I'm not a big fan of hiding flow control in a function, Error()
handles formatting and saves me from calling FormatString().getData() a
lot.
2016-04-28 02:59:12 +02:00
Günther Brammer 4b43576f83 Script: Complain about some attempts to Call nonexistant function again
This code got lost in the function pointer rewrite.
2016-04-28 02:59:12 +02:00
Günther Brammer 3760363a3b Script: Add GetPrototype and SetPrototype functions
This should eventually replace the Prototype property, so that proplists
can be used as a key-value-storage without any hidden gotchas.

The Prototype is such a magical property that any code dealing with all
properties has to special-case it anyway, and isn't even returned by
GetProperties().
2016-04-28 02:59:11 +02:00
Günther Brammer 525cdc11a3 Deduplicate calculation of the relative stack position of local variables 2016-04-28 02:59:11 +02:00
Günther Brammer 071feaa78f Deduplicate loop control handling in the script parser 2016-04-28 02:59:11 +02:00
Günther Brammer efd4724084 Script: Add Scenario effects
These work just like global effects, except that effects from CreateEffect
get the scenario as target parameter in the callbacks.
2016-04-28 02:53:21 +02:00
Günther Brammer 97406d24d2 Script: Add Construction and Destruction effect callbacks 2016-04-28 01:08:04 +02:00
Günther Brammer 50378ffda0 Script: CreateEffect starts effects that receive callbacks themselves 2016-04-28 01:08:04 +02:00
Sven Eberhardt 881534bee0 Qt Editor: Shape properties 2016-04-25 16:17:10 -04:00
Lukas Werling aeabe28d82 Remove AsyncRandom() script function
We couldn't think of any reason you'd want to use this over regular
Random() in script.
2016-04-25 17:18:07 +02:00
Günther Brammer e5cfb1858f Script: GetName() can return the property a proplist was defined in
This means that the ActMaps do not need to repeat their name anymore,
provided that all Scripts use GetName() instead of directly accessing .Name.
2016-04-24 19:40:29 +02:00
Günther Brammer 5a470f51f8 Move Effect functions to C4Script.cpp 2016-04-24 19:40:29 +02:00
Günther Brammer 2cdf553953 Change effect list getting function parameter type to C4PropList*
This makes it possible to move the effect functions to C4Script.cpp.
2016-04-24 19:40:29 +02:00
Günther Brammer e8811a7b21 Move global effects from ::Game to ::ScriptEngine
This even enables some simplification in the CompileFuncs, since the global
effects were already put in the same section as the other ScriptEngine
parts. The callback for updates due to relinks also fits nicely.

The reset in C4Game::Default was redundant with C4Game::Clear already.
2016-04-24 19:40:28 +02:00
Günther Brammer e2c6c2a841 Do not use C4Object in C4Effect
Instead, the pointer to the effect list is passed to the functions that
previously used the object to determine it.
2016-04-24 19:40:28 +02:00
Günther Brammer c89e73608b Unite getting the effects list from a C4Object pointer into a function
This way, that function can be re-implemented in standalone c4script.
2016-04-24 19:40:28 +02:00
Günther Brammer 42a15e3be9 Convert C4Effect parameters that do not need to be C4Object* to C4PropList* 2016-04-24 19:40:28 +02:00
Günther Brammer bfb9b6b1fd Drop the roundtrip through C4ID for the effect C4Def command target
Unfortunately, this complicates the C4Effect::CompileFunc to stay
compatible.
2016-04-24 19:40:27 +02:00
Günther Brammer 632c5cbd0f Refactor effect callbacks into helper functions 2016-04-24 19:40:27 +02:00