summaryrefslogtreecommitdiffstats
path: root/SelectMark.c4d/Script.c
diff options
context:
space:
mode:
authorMittendrein Markus <maxmitti@gmx.net>2016-05-17 14:10:25 +0200
committerMittendrein Markus <maxmitti@gmx.net>2016-05-17 14:10:25 +0200
commit93ddddae60a39f32f33996190be62c700deeb010 (patch)
tree7dec1000527377eb630b39fe93069606acbdb85e /SelectMark.c4d/Script.c
downloadObjectsAppend-93ddddae60a39f32f33996190be62c700deeb010.tar.gz
ObjectsAppend-93ddddae60a39f32f33996190be62c700deeb010.zip
Initial
Diffstat (limited to 'SelectMark.c4d/Script.c')
-rw-r--r--SelectMark.c4d/Script.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/SelectMark.c4d/Script.c b/SelectMark.c4d/Script.c
new file mode 100644
index 0000000..1a0121c
--- /dev/null
+++ b/SelectMark.c4d/Script.c
@@ -0,0 +1,87 @@
+#strict 2
+
+local attachEffect;
+
+global func CreateSelectMark() { return CreateObject(SELM, 0, 0, GetOwner()); }
+
+func Padding(int forVal) { return (forVal < 3) * 2; }
+
+func Initialize()
+{
+ SetVisibility(VIS_Owner);
+ SetAction("UpperLeft");
+ Primary();
+}
+
+func MarkObject(object obj, int time)
+{
+ var id = GetID(obj);
+ var w = GetObjWidth(obj);
+ var h = GetObjHeight(obj);
+ var x = GetX(obj) + GetDefOffset(id) + (GetDefWidth(id) - w) / 2;
+ var y = GetY(obj) + GetDefOffset(id, 1) + (GetDefHeight(id) - h) / 2;
+ var xOff = 0;
+ var xPad = Padding(w);
+ var yPad = Padding(h);
+ if(x - xPad < 0)
+ {
+ x -= (xOff = -(w + 2 * xPad));
+ }
+ SetPosition(x - xPad, y - yPad);
+ SetObjDrawTransform(1000, 0, xOff * 1000, 0, 1000, 0, this, 0);
+ SetObjDrawTransform(1000, 0, (xOff + w + 2 * xPad) * 1000, 0, 1000, 0, this, 1);
+ SetObjDrawTransform(1000, 0, xOff * 1000, 0, 1000, (h + 2 * yPad) * 1000, this, 2);
+ SetObjDrawTransform(1000, 0, (xOff + w + 2 * xPad) * 1000, 0, 1000, (h + 2 * yPad) * 1000, this, 3);
+
+ if(time != -1)
+ {
+ if(attachEffect && attachEffect[0] != obj)
+ {
+ RemoveEffect(0, attachEffect[0], attachEffect[1]);
+ }
+ if(!attachEffect)
+ {
+ AddEffect("SelectionMarkAttach", obj, 1, 1, this, 0, time);
+ }
+ }
+ return this;
+}
+
+func FxSelectionMarkAttachStart(object target, int effectNumber, int temp, int time)
+{
+ attachEffect = [target, effectNumber];
+ EffectVar(0, target, effectNumber) = time;
+}
+
+func FxSelectionMarkAttachTimer(object target, int effectNumber, int effectTime)
+{
+ var time = EffectVar(0, target, effectNumber);
+ if(time && effectTime > time)
+ {
+ return RemoveObject();
+ }
+ MarkObject(target, -1);
+}
+
+func FxSelectionMarkAttachStop(object target, int effectNumber)
+{
+ attachEffect = 0;
+}
+
+func Primary()
+{
+ SetGraphics();
+ SetGraphics(0, this, GetID(), 1, GFXOV_MODE_Action, "UpperRight");
+ SetGraphics(0, this, GetID(), 2, GFXOV_MODE_Action, "LowerLeft");
+ SetGraphics(0, this, GetID(), 3, GFXOV_MODE_Action, "LowerRight");
+ return this;
+}
+
+func Secondary()
+{
+ SetGraphics("2");
+ SetGraphics("2", this, GetID(), 1, GFXOV_MODE_Action, "UpperRight");
+ SetGraphics("2", this, GetID(), 2, GFXOV_MODE_Action, "LowerLeft");
+ SetGraphics("2", this, GetID(), 3, GFXOV_MODE_Action, "LowerRight");
+ return this;
+}