summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mittendrein <maxmitti@maxmitti.tk>2022-02-20 17:13:55 +0100
committerMarkus Mittendrein <maxmitti@maxmitti.tk>2022-02-20 17:13:55 +0100
commit4ffbace3cc065a7272bc6a7b205a7ef18a249192 (patch)
tree1ee83bb4d76339f24cdce6b1ed6d05b34bf227f2
parent497fe739cf81cb73630098e629cb5a96f02c755a (diff)
downloadObjectsAppend-4ffbace3cc065a7272bc6a7b205a7ef18a249192.tar.gz
ObjectsAppend-4ffbace3cc065a7272bc6a7b205a7ef18a249192.zip
Update TodsStuff components
-rw-r--r--DTMenu.c4d/Script.c54
-rw-r--r--System.c4g/DTCallback.c1
-rw-r--r--System.c4g/DTUtility.c58
3 files changed, 58 insertions, 55 deletions
diff --git a/DTMenu.c4d/Script.c b/DTMenu.c4d/Script.c
index 2089a8d..bc92b7d 100644
--- a/DTMenu.c4d/Script.c
+++ b/DTMenu.c4d/Script.c
@@ -29,8 +29,7 @@ static const Menu_React_SelectionOffset = 5;
static const Menu_React_SelectionChange = 6;
static const Menu_React_ShowSubMenu = 7;
static const Menu_React_OverrideReaction = -1;
-static Menu_React_None; // constants with nil is somehow broken?
-// static const Menu_React_None = nil;
+static const Menu_React_None = nil;
static const Menu_React_Max = Menu_React_ShowSubMenu;
global func Menu_React_OffsetSelection(int offset) { return [Menu_React_SelectionOffset, offset]; }
@@ -548,6 +547,10 @@ func HandleEntries(array factoryEntries, int& i, array& ret, map& retSettings, a
{
newSettings = factoryResult.Settings;
newEntries = factoryResult.Entries;
+ if (GetType(newSettings.Selection) == C4V_Int)
+ {
+ newSettings.Selection = [newSettings.Selection, 0];
+ }
}
else if(GetType(factoryResult) == C4V_Array)
{
@@ -743,7 +746,7 @@ func AddEntries()
text = Format("%s {{MN7I:7}}", text);
}
- AddMenuItem(text, !noCommand && "MenuItemCommand", iconID, settings.Object, entry.Count, entryIndex, showDesc && entry.Description || nil, entry.Extra, entry.XPar1, entry.XPar2);
+ AddMenuItem(text, !noCommand && "MenuItemCommand" || nil, iconID, settings.Object, entry.Count, entryIndex, showDesc && entry.Description || nil, entry.Extra, entry.XPar1, entry.XPar2);
if(deleteIcon)
{
@@ -804,7 +807,8 @@ func React(reaction, array entryIndex, int refreshDelayed)
func CheckCondition(map entry)
{
var condition = entry.Condition;
- return !condition || (CallA(condition.Callback, [entry.Icon, settings.Object, entry.Args]) || settings.Condition.DisableMode) == Menu_ConditionReact_Show;
+ var result = !condition || (CallA(condition.Callback, [entry.Icon, settings.Object, entry.Args]) || settings.Condition.DisableMode);
+ return result == Menu_ConditionReact_Show || result == true;
}
func MenuItemCommand(id ID, int itemNumber, int action)
@@ -866,6 +870,7 @@ func SubMenuItemCallback(int action, object menuObject, args, array allArgs)
func DecodeSelection(int& selection)
{
+ selection ??= 0;
var column = selection % columnCount;
selection /= columnCount;
selection -= columnOffsets[column];
@@ -1233,14 +1238,11 @@ global func Menu_Entry(map entry)
{
entry = { Placeholder = false };
}
- else
- {
- entry = Extend({
- Text = "",
- Placeholder = -1,
- Extra = 0,
- }, entry, true);
- }
+ entry = Extend({
+ Text = "",
+ Placeholder = -1,
+ Extra = 0,
+ }, entry, true);
if(!entry.Description)
{
@@ -1505,7 +1507,7 @@ global func Menu_Adaptor(map settings)
}
settings.Adaptor.BitField.Values = fieldVals;
settings.Adaptor.BitField.Layout = layout;
-
+
var valuePos = layout[Menu_Layout__ValuePos] - 1;
for(var fieldPart in fieldVals)
{
@@ -1670,7 +1672,7 @@ func AdaptorFactory(args, int entryIndex, int entryColumn)
else if(args.Type == Menu_AdaptorType_ID)
{
if(!(GetType(val) == C4V_Any || GetType(val) == C4V_C4ID)) { FatalError("Assertion failed: AdaptorFactory: Value of Menu_Adaptor_Variable has wrong type; assertion code: GetType(val) == C4V_Any || GetType(val) == C4V_C4ID"); }
- text = Format(entry.Text, val && GetName(0, val) || "");
+ text = Format(entry.Text, val && GetName(nil, val) || "");
if(val)
{
ExtraIcon(text, icon, val);
@@ -1971,9 +1973,9 @@ func AdaptorCommand(int action, object obj, args, array allArgs)
}
if(action == Menu_CallbackType_Special2)
{
- if(msgBoardMode == 0)
+ if(msgBoardMode == nil)
{
- msgBoardMode = Menu_AdaptorType_Integer + 1;
+ msgBoardMode = Menu_AdaptorType_Integer;
msgBoardEntry = args.EntryIndex;
CallMessageBoard(this, false, args.MessageBoardText, GetOwner(obj));
}
@@ -2012,9 +2014,9 @@ func AdaptorCommand(int action, object obj, args, array allArgs)
{
if(action & (Menu_CallbackType_Normal | Menu_CallbackType_Special2))
{
- if(msgBoardMode == 0)
+ if(msgBoardMode == nil)
{
- msgBoardMode = Menu_AdaptorType_String + 1;
+ msgBoardMode = Menu_AdaptorType_String;
msgBoardEntry = args.EntryIndex;
CallMessageBoard(this, false, args.MessageBoardText, GetOwner(obj));
}
@@ -2032,9 +2034,9 @@ func AdaptorCommand(int action, object obj, args, array allArgs)
{
if(action & (Menu_CallbackType_Normal | Menu_CallbackType_Special2))
{
- if(msgBoardMode == 0)
+ if(msgBoardMode == nil)
{
- msgBoardMode = Menu_AdaptorType_ID + 1;
+ msgBoardMode = Menu_AdaptorType_ID;
msgBoardEntry = args.EntryIndex;
CallMessageBoard(this, false, args.MessageBoardText, GetOwner(obj));
}
@@ -2124,7 +2126,7 @@ func InputCallback(string input, int plr)
var callbackArgs = args.Args;
var oldVal = ScopedVar(args.Variable);
var val = input;
- if(msgBoardMode - 1 == Menu_AdaptorType_Integer)
+ if(msgBoardMode == Menu_AdaptorType_Integer)
{
var int = ParseInt(input);
var limits = AdaptorGetLimits(args.Limits);
@@ -2151,7 +2153,7 @@ func InputCallback(string input, int plr)
val = oldVal;
}
}
- else if(msgBoardMode - 1 == Menu_AdaptorType_String)
+ else if(msgBoardMode == Menu_AdaptorType_String)
{
if(args.NoEmptyString && (!input || input == ""))
{
@@ -2162,14 +2164,14 @@ func InputCallback(string input, int plr)
ScopedVar(args.Variable) = input;
}
}
- else if(msgBoardMode - 1 == Menu_AdaptorType_ID)
+ else if(msgBoardMode == Menu_AdaptorType_ID)
{
val = GetIDByName(input); // WARNING: desyncs between clients with different languages
if(!val && GetLength(input) == 4) val = C4Id(input);
- if(!GetName(0, val)) val = 0;
+ if(!GetName(nil, val)) val = 0;
ScopedVar(args.Variable) = val;
}
- msgBoardMode = 0;
+ msgBoardMode = nil;
if(val != oldVal)
{
var reaction = CallCallbacks(args.Callbacks, Menu_CallbackType_ValueChanged, [Menu_CallbackType_ValueChanged, entry.Icon, settings.Object, callbackArgs, 0, 0, val, oldVal]);
@@ -2234,7 +2236,7 @@ global func CreateNewMenu(map settings, map inheritSettings, object parentMenu)
Flags = MSG_Left | MSG_Bottom,
Position = [40, -60]
},
- KeepOpen = 0,
+ KeepOpen = Menu_KeepOpen_Not,
}
}, { Settings = inheritSettings }, true), {
Settings = {
diff --git a/System.c4g/DTCallback.c b/System.c4g/DTCallback.c
index 58f6403..5ec876d 100644
--- a/System.c4g/DTCallback.c
+++ b/System.c4g/DTCallback.c
@@ -172,6 +172,7 @@ global func BindArgs(array binding, array args, bool safe, array& refs)
var ret = CreateArray(GetLength(binding)), pos = 0;
for(var bind in binding)
{
+ bind ??= 0; // necessary for non-#strict 3 compatibility
if(GetType(bind) == C4V_Int || GetType(bind) == C4V_Any && bind >= 0)
{
ret[pos] = args[bind];
diff --git a/System.c4g/DTUtility.c b/System.c4g/DTUtility.c
index 752000b..be8200e 100644
--- a/System.c4g/DTUtility.c
+++ b/System.c4g/DTUtility.c
@@ -315,9 +315,9 @@ global func GetIDByName(string name, int category) // WARNING: desyncs between c
var i, id;
while(id = GetDefinition(i++, category))
{
- if(GetName(0, id) == name) return id;
+ if(GetName(nil, id) == name) return id;
}
- return 0;
+ return nil;
}
global func GetIDsByName(string name, int category) // WARNING: desyncs between clients with different languages
@@ -325,7 +325,7 @@ global func GetIDsByName(string name, int category) // WARNING: desyncs between
var i, id, ret = [];
while(id = GetDefinition(i++, category))
{
- if(GetName(0, id) == name)
+ if(GetName(nil, id) == name)
{
ret[] = id;
}
@@ -598,9 +598,9 @@ global func GetSolidMask(object obj)
obj = obj || this;
return
[
- GetObjectVal("SolidMask", 0, obj, 0), GetObjectVal("SolidMask", 0, obj, 1),
- GetObjectVal("SolidMask", 0, obj, 2), GetObjectVal("SolidMask", 0, obj, 3),
- GetObjectVal("SolidMask", 0, obj, 4), GetObjectVal("SolidMask", 0, obj, 5)
+ GetObjectVal("SolidMask", nil, obj, 0), GetObjectVal("SolidMask", nil, obj, 1),
+ GetObjectVal("SolidMask", nil, obj, 2), GetObjectVal("SolidMask", nil, obj, 3),
+ GetObjectVal("SolidMask", nil, obj, 4), GetObjectVal("SolidMask", nil, obj, 5)
];
}
@@ -628,7 +628,7 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
{
if(getValue == 0)
{
- if(GetObjectVal("GfxOverlay", 0, obj, startIndex) == 0)
+ if(GetObjectVal("GfxOverlay", nil, obj, startIndex) == 0)
{
// there is no such overlay
return -1;
@@ -640,13 +640,13 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
}
else if(getValue == 1)
{
- return GetObjectVal("GfxOverlay", 0, obj, startIndex);
+ return GetObjectVal("GfxOverlay", nil, obj, startIndex);
}
found = true;
}
for(var i = startIndex + 1, foundIndex = 0; ;) // skip overlay ID
{
- var val = GetObjectVal("GfxOverlay", 0, obj, i);
+ var val = GetObjectVal("GfxOverlay", nil, obj, i);
if(val == 0)
{
// there is no overlay left
@@ -674,13 +674,13 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
}
else if(getValue == 4)
{
- return GetObjectVal("GfxOverlay", 0, obj, i + 1);
+ return GetObjectVal("GfxOverlay", nil, obj, i + 1);
}
}
i += 2; // skip Graphics-Definition and -Name, so i points to OverlayMode here too
if(found && getValue == 2)
{
- return GetObjectVal("GfxOverlay", 0, obj, i);
+ return GetObjectVal("GfxOverlay", nil, obj, i);
}
}
else
@@ -693,11 +693,11 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
{
if(getValue == 5)
{
- return GetObjectVal("GfxOverlay", 0, obj, i + 1);
+ return GetObjectVal("GfxOverlay", nil, obj, i + 1);
}
else if(getValue == 6)
{
- return GetObjectVal("GfxOverlay", 0, obj, i + 2);
+ return GetObjectVal("GfxOverlay", nil, obj, i + 2);
}
else if(getValue == 7)
{
@@ -706,7 +706,7 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
}
i += 10; // this is either the last row of the Transformation matrix or the Color-Modulation
- val = GetObjectVal("GfxOverlay", 0, obj, i);
+ val = GetObjectVal("GfxOverlay", nil, obj, i);
if(GetType(val) == C4V_String)
{
@@ -716,14 +716,14 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
if(found && getValue == 8)
{
- return GetObjectVal("GfxOverlay", 0, obj, i + 2);
+ return GetObjectVal("GfxOverlay", nil, obj, i + 2);
}
i += 3; // and the rest
if(++foundIndex == index)
{
- if(GetObjectVal("GfxOverlay", 0, obj, i) == 0)
+ if(GetObjectVal("GfxOverlay", nil, obj, i) == 0)
{
// there is no overlay left
return -1;
@@ -737,7 +737,7 @@ global func GetOverlayValueByIndex(int index, int startIndex, int getValue, obje
}
else if(getValue == 1)
{
- return GetObjectVal("GfxOverlay", 0, obj, i);
+ return GetObjectVal("GfxOverlay", nil, obj, i);
}
}
}
@@ -771,20 +771,20 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
obj = obj || this;
if(overlay == 0)
{
- var first = GetObjectVal("DrawTransform", 0, obj, 0);
+ var first = GetObjectVal("DrawTransform", nil, obj, 0);
if(first == 0)
{
return [1000, 0, 0, 0, 1000, 0];
}
- var ret = [ParseFloat(first, 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 1), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 2), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 3), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 4), 3), ParseFloat(GetObjectVal("DrawTransform", 0, obj, 5), 3)];
+ var ret = [ParseFloat(first, 3), ParseFloat(GetObjectVal("DrawTransform", nil, obj, 1), 3), ParseFloat(GetObjectVal("DrawTransform", nil, obj, 2), 3), ParseFloat(GetObjectVal("DrawTransform", nil, obj, 3), 3), ParseFloat(GetObjectVal("DrawTransform", nil, obj, 4), 3), ParseFloat(GetObjectVal("DrawTransform", nil, obj, 5), 3)];
- var rest = GetObjectVal("DrawTransform", 0, obj, 7); // 6 is left out intentionally, because its only FlipDir (used internally for Actions with FlipDir)
+ var rest = GetObjectVal("DrawTransform", nil, obj, 7); // 6 is left out intentionally, because its only FlipDir (used internally for Actions with FlipDir)
if(GetType(rest) == C4V_String) // the last 3 matrix-values are only decompiled if they are not the default of [0, 0, 1.0]
{
SetLength(ret, 9);
ret[6] = ParseFloat(rest, 3);
- ret[7] = ParseFloat(GetObjectVal("DrawTransform", 0, obj, 8), 3);
- ret[8] = ParseFloat(GetObjectVal("DrawTransform", 0, obj, 9), 3);
+ ret[7] = ParseFloat(GetObjectVal("DrawTransform", nil, obj, 8), 3);
+ ret[8] = ParseFloat(GetObjectVal("DrawTransform", nil, obj, 9), 3);
}
return ret;
@@ -810,15 +810,15 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
return index;
}
- var ret = [ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 1), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 2), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 3), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 4), 3), ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 5), 3)];
+ var ret = [ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index), 3), ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 1), 3), ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 2), 3), ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 3), 3), ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 4), 3), ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 5), 3)];
- var rest = GetObjectVal("GfxOverlay", 0, obj, index + 7); // 6 is left out intentionally, because its only FlipDir (used internally for Actions with FlipDir)
+ var rest = GetObjectVal("GfxOverlay", nil, obj, index + 7); // 6 is left out intentionally, because its only FlipDir (used internally for Actions with FlipDir)
if(GetType(rest) == C4V_String) // the last 3 matrix-values are only decompiled if they are not the default of [0, 0, 1.0]
{
SetLength(ret, 9);
ret[6] = ParseFloat(rest, 3);
- ret[7] = ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 8), 3);
- ret[8] = ParseFloat(GetObjectVal("GfxOverlay", 0, obj, index + 9), 3);
+ ret[7] = ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 8), 3);
+ ret[8] = ParseFloat(GetObjectVal("GfxOverlay", nil, obj, index + 9), 3);
}
return ret;
@@ -827,8 +827,8 @@ global func GetObjDrawTransform(int overlay, int overlayOffset, object obj)
global func GetShape(object obj)
{
- obj = obj || this;
- return [GetObjectVal("Offset", 0, obj, 0), GetObjectVal("Offset", 0, obj, 1), GetObjectVal("Width", 0, obj), GetObjectVal("Height", 0, obj)];
+ obj ??= this;
+ return [GetObjectVal("Offset", nil, obj, 0) ?? 0, GetObjectVal("Offset", nil, obj, 1) ?? 0, GetObjectVal("Width", nil, obj), GetObjectVal("Height", nil, obj)];
}
global func InRect(array point, array rect)
@@ -885,4 +885,4 @@ global func InitMap(array init)
ret[init[i]] = init[i + 1];
}
return ret;
-} \ No newline at end of file
+}