Skip to content

Commit

Permalink
maptext animate
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle committed Nov 27, 2024
1 parent a446492 commit ed5d8bf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
30 changes: 12 additions & 18 deletions OpenDreamClient/Rendering/DreamIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,9 @@ private void UpdateAnimation() {
if (endAppearance.Invisibility != _appearance.Invisibility) {
appearance.Invisibility = endAppearance.Invisibility;
}
/* TODO maptext
if (endAppearance.MapText != _appearance.MapText) {
appearance.MapText = endAppearance.MapText;
if (endAppearance.Maptext != _appearance.Maptext) {
appearance.Maptext = endAppearance.Maptext;
}
*/
/* TODO suffix
if (endAppearance.Suffix != _appearance.Suffix) {
appearance.Suffix = endAppearance.Suffix;
Expand Down Expand Up @@ -383,24 +381,20 @@ private void UpdateAnimation() {
}
*/

/* TODO maptext
if (endAppearance.MapTextWidth != _appearance.MapTextWidth) {
appearance.MapTextWidth = (ushort)Math.Clamp(((1-factor) * _appearance.MapTextWidth) + (factor * endAppearance.MapTextWidth), 0, 65535);
}
if (endAppearance.MapTextHeight != _appearance.MapTextHeight) {
appearance.MapTextHeight = (ushort)Math.Clamp(((1-factor) * _appearance.MapTextHeight) + (factor * endAppearance.MapTextHeight), 0, 65535);
if (endAppearance.MaptextSize != _appearance.MaptextSize) {
appearance.MaptextSize = new Vector2i(
(int)Math.Round(((1-factor) * _appearance.MaptextSize.X) + (factor * endAppearance.MaptextSize.X)),
(int)Math.Round(((1-factor) * _appearance.MaptextSize.Y) + (factor * endAppearance.MaptextSize.Y))
);
}

if (endAppearance.MapTextX != _appearance.MapTextX) {
appearance.MapTextX = (short)Math.Clamp(((1-factor) * _appearance.MapTextX) + (factor * endAppearance.MapTextX), -32768, 32767);
if (endAppearance.MaptextOffset != _appearance.MaptextOffset) {
appearance.MaptextOffset = new Vector2i(
(int)Math.Round(((1-factor) * _appearance.MaptextOffset.X) + (factor * endAppearance.MaptextOffset.X)),
(int)Math.Round(((1-factor) * _appearance.MaptextOffset.Y) + (factor * endAppearance.MaptextOffset.Y))
);
}

if (endAppearance.MapTextY != _appearance.MapTextY) {
appearance.MapTextY = (short)Math.Clamp(((1-factor) * _appearance.MapTextY) + (factor * endAppearance.MapTextY), -32768, 32767);
}
*/

if (endAppearance.PixelOffset != _appearance.PixelOffset) {
Vector2 startingOffset = appearance.PixelOffset;
Vector2 newPixelOffset = Vector2.Lerp(startingOffset, endAppearance.PixelOffset, 1.0f-factor);
Expand Down
33 changes: 24 additions & 9 deletions OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static DreamValue NativeProc_animate(NativeProc.Bundle bundle, DreamObjec
return DreamValue.Null;
chainAnim = true;
}

bundle.LastAnimatedObject = new DreamValue(obj);
if(obj.IsSubtypeOf(bundle.ObjectTree.Filter)) {//TODO animate filters
return DreamValue.Null;
Expand Down Expand Up @@ -210,14 +210,16 @@ public static DreamValue NativeProc_animate(NativeProc.Bundle bundle, DreamObjec
/* TODO these are not yet implemented
if(!pixelZ.IsNull)
pixelZ = new(pixelZ.UnsafeGetValueAsFloat() + obj.GetVariable("pixel_z").UnsafeGetValueAsFloat()); //TODO change to appearance when pixel_z is implemented
*/
if(!maptextWidth.IsNull)
maptextWidth = new(maptextWidth.UnsafeGetValueAsFloat() + obj.GetVariable("maptext_width").UnsafeGetValueAsFloat()); //TODO change to appearance when maptext_width is implemented
maptextWidth = new(maptextWidth.UnsafeGetValueAsFloat() + appearance.MaptextSize.X);
if(!maptextHeight.IsNull)
maptextHeight = new(maptextHeight.UnsafeGetValueAsFloat() + obj.GetVariable("maptext_height").UnsafeGetValueAsFloat()); //TODO change to appearance when maptext_height is implemented
maptextHeight = new(maptextHeight.UnsafeGetValueAsFloat() + appearance.MaptextSize.Y);
if(!maptextX.IsNull)
maptextX = new(maptextX.UnsafeGetValueAsFloat() + obj.GetVariable("maptext_x").UnsafeGetValueAsFloat()); //TODO change to appearance when maptext_x is implemented
maptextX = new(maptextX.UnsafeGetValueAsFloat() + appearance.MaptextOffset.X);
if(!maptextY.IsNull)
maptextY = new(maptextY.UnsafeGetValueAsFloat() + obj.GetVariable("maptext_y").UnsafeGetValueAsFloat()); //TODO change to appearance when maptext_y is implemented
maptextY = new(maptextY.UnsafeGetValueAsFloat() + appearance.MaptextOffset.Y);
/*
if(!luminosity.IsNull)
luminosity = new(luminosity.UnsafeGetValueAsFloat() + obj.GetVariable("luminosity").UnsafeGetValueAsFloat()); //TODO change to appearance when luminosity is implemented
*/
Expand Down Expand Up @@ -273,17 +275,30 @@ public static DreamValue NativeProc_animate(NativeProc.Bundle bundle, DreamObjec
}
*/

/* TODO maptext
if (!maptextX.IsNull) {
obj.SetVariableValue("maptext_x", maptextX);
maptextX.TryGetValueAsInteger(out appearance.MapTextOffset.X);
maptextX.TryGetValueAsInteger(out appearance.MaptextOffset.X);
}

if (!maptextY.IsNull) {
obj.SetVariableValue("maptext_y", maptextY);
maptextY.TryGetValueAsInteger(out appearance.MapTextOffset.Y);
maptextY.TryGetValueAsInteger(out appearance.MaptextOffset.Y);
}

if (!maptextWidth.IsNull) {
obj.SetVariableValue("maptext_width", maptextWidth);
maptextX.TryGetValueAsInteger(out appearance.MaptextSize.X);
}

if (!maptextHeight.IsNull) {
obj.SetVariableValue("maptext_y", maptextHeight);
maptextY.TryGetValueAsInteger(out appearance.MaptextSize.Y);
}

if(!maptext.IsNull){
obj.SetVariableValue("maptext", maptext);
maptext.TryGetValueAsString(out appearance.Maptext);
}
*/

if (!dir.IsNull) {
obj.SetVariableValue("dir", dir);
Expand Down
2 changes: 2 additions & 0 deletions TestGame/code.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@
src.maptext = null;
else
src.maptext = "Hello!"
animate(src, maptext="Hi!", maptext_x=64, maptext_y=64, time=50)
animate(maptext_x=-64, maptext_y=-64, time=50)


verb/demo_filters()
Expand Down

0 comments on commit ed5d8bf

Please sign in to comment.