2021-07-11 22:59:29 -05:00
|
|
|
// Decompiled with JetBrains decompiler
|
|
|
|
|
// Type: Microsoft.Iris.Render.Graphics.Sprite
|
|
|
|
|
// Assembly: UIX.RenderApi, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
|
|
|
|
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
|
|
|
|
|
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
|
|
|
|
|
|
|
|
|
|
using Microsoft.Iris.Input;
|
|
|
|
|
using Microsoft.Iris.Render.Common;
|
|
|
|
|
using Microsoft.Iris.Render.Internal;
|
|
|
|
|
using Microsoft.Iris.Render.Protocols.Splash.Rendering;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Iris.Render.Graphics
|
|
|
|
|
{
|
2021-07-11 23:04:40 -05:00
|
|
|
internal class Sprite : Visual, ISprite, IVisual, IRawInputSite, IAnimatable, ISharedRenderObject
|
2021-07-11 22:59:29 -05:00
|
|
|
{
|
2021-07-11 23:04:40 -05:00
|
|
|
private Effect m_effect;
|
2021-10-06 13:24:32 -05:00
|
|
|
private CoordMap m_coordMap;
|
2021-07-11 22:59:29 -05:00
|
|
|
|
2021-07-29 14:02:25 -05:00
|
|
|
public Sprite(RenderSession session, RenderWindowBase window, object objOwnerData)
|
2021-07-11 23:04:40 -05:00
|
|
|
: base(session, window, objOwnerData)
|
2021-07-11 22:59:29 -05:00
|
|
|
{
|
2021-10-06 13:24:32 -05:00
|
|
|
base.Visible = true;
|
2021-07-11 22:59:29 -05:00
|
|
|
}
|
|
|
|
|
|
2021-07-11 23:04:40 -05:00
|
|
|
protected override void Dispose(bool fInDispose)
|
2021-07-11 22:59:29 -05:00
|
|
|
{
|
2021-07-11 23:04:40 -05:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (fInDispose && this.m_effect != null)
|
|
|
|
|
{
|
2021-07-11 23:07:04 -05:00
|
|
|
this.m_effect.UnregisterUsage(this);
|
|
|
|
|
this.m_effect = null;
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
2021-07-11 23:07:04 -05:00
|
|
|
this.PropertyManager.RemoveCoordmapProp(this);
|
|
|
|
|
this.m_effect = null;
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(fInDispose);
|
|
|
|
|
}
|
2021-07-11 22:59:29 -05:00
|
|
|
}
|
|
|
|
|
|
2021-07-11 23:04:40 -05:00
|
|
|
Vector3 ISprite.Position
|
|
|
|
|
{
|
|
|
|
|
get => this.Position;
|
|
|
|
|
set => this.Position = value;
|
|
|
|
|
}
|
2021-07-11 22:59:29 -05:00
|
|
|
|
2021-07-11 23:04:40 -05:00
|
|
|
Vector2 ISprite.Size
|
|
|
|
|
{
|
|
|
|
|
get => this.Size;
|
|
|
|
|
set => this.Size = value;
|
|
|
|
|
}
|
2021-07-11 22:59:29 -05:00
|
|
|
|
2021-07-11 23:04:40 -05:00
|
|
|
bool ISprite.Visible
|
|
|
|
|
{
|
|
|
|
|
get => this.Visible;
|
|
|
|
|
set => this.Visible = value;
|
|
|
|
|
}
|
2021-07-11 22:59:29 -05:00
|
|
|
|
2021-07-11 23:04:40 -05:00
|
|
|
Vector3 ISprite.Scale
|
|
|
|
|
{
|
|
|
|
|
get => this.Scale;
|
|
|
|
|
set => this.Scale = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AxisAngle ISprite.Rotation
|
|
|
|
|
{
|
|
|
|
|
get => this.Rotation;
|
|
|
|
|
set => this.Rotation = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float ISprite.Alpha
|
|
|
|
|
{
|
|
|
|
|
get => this.Alpha;
|
|
|
|
|
set => this.Alpha = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector3 ISprite.CenterPoint
|
|
|
|
|
{
|
|
|
|
|
get => this.CenterPointScale;
|
|
|
|
|
set => this.CenterPointScale = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint ISprite.Layer
|
|
|
|
|
{
|
|
|
|
|
get => this.Layer;
|
|
|
|
|
set => this.Layer = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEffect ISprite.Effect
|
|
|
|
|
{
|
2021-07-11 23:07:04 -05:00
|
|
|
get => Effect;
|
2021-07-11 23:04:40 -05:00
|
|
|
set => this.Effect = (Effect)value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal Effect Effect
|
|
|
|
|
{
|
|
|
|
|
get => this.m_effect;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Effect effect = value;
|
|
|
|
|
if (this.m_effect == effect)
|
|
|
|
|
return;
|
|
|
|
|
if (this.m_effect != null)
|
2021-07-11 23:07:04 -05:00
|
|
|
this.m_effect.UnregisterUsage(this);
|
2021-07-11 23:04:40 -05:00
|
|
|
this.m_effect = effect;
|
|
|
|
|
if (this.m_effect != null)
|
2021-07-11 23:07:04 -05:00
|
|
|
this.m_effect.RegisterUsage(this);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ISprite.RelativeSize
|
|
|
|
|
{
|
|
|
|
|
get => this.RelativeSize;
|
|
|
|
|
set => this.RelativeSize = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ISprite.AddGradient(IGradient gradient) => this.AddGradient((Gradient)gradient);
|
|
|
|
|
|
|
|
|
|
void ISprite.RemoveAllGradients() => this.RemoveAllGradients();
|
|
|
|
|
|
|
|
|
|
void ISprite.SetNineGrid(int left, int top, int right, int bottom)
|
|
|
|
|
{
|
|
|
|
|
Debug2.Validate(left >= 0 && right >= 0 && top >= 0 && bottom >= 0, typeof(ArgumentNullException), "invalid nine grid params");
|
2021-07-11 23:07:04 -05:00
|
|
|
this.PropertyManager.RemoveCoordmapProp(this);
|
2021-10-06 13:24:32 -05:00
|
|
|
// TODO: Set nine grid
|
|
|
|
|
//this.m_remoteSprite.SendSetNineGrid(left, top, right, bottom);
|
2021-07-11 23:07:04 -05:00
|
|
|
this.SetPropFlag(PropId.MaxDynamicProp, true);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ISprite.SetCoordMap(int idxLayer, CoordMap coordMap)
|
|
|
|
|
{
|
|
|
|
|
Debug2.Validate(idxLayer >= 0, typeof(ArgumentOutOfRangeException), "idxLayer must be >= 0");
|
|
|
|
|
Debug2.Validate(idxLayer < 4, typeof(ArgumentOutOfRangeException), "quick-check, currently we only support 4 layers/stages");
|
2021-07-11 23:07:04 -05:00
|
|
|
if (this.IsPropFlagSet(PropId.MaxDynamicProp))
|
2021-07-11 23:04:40 -05:00
|
|
|
{
|
2021-10-06 13:24:32 -05:00
|
|
|
this.m_coordMap.Clear();
|
2021-07-11 23:07:04 -05:00
|
|
|
this.SetPropFlag(PropId.MaxDynamicProp, false);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
if (!this.UpdateCoordMap(idxLayer, coordMap))
|
|
|
|
|
return;
|
2021-10-06 13:24:32 -05:00
|
|
|
this.m_coordMap.Clear();
|
2021-07-11 23:07:04 -05:00
|
|
|
if (!this.IsDynamicValueSet(PropId.CoordMap))
|
2021-07-11 23:04:40 -05:00
|
|
|
return;
|
|
|
|
|
ArrayList result;
|
2021-07-11 23:07:04 -05:00
|
|
|
this.PropertyManager.GetCoordmapProp(this, out result);
|
2021-07-11 23:04:40 -05:00
|
|
|
foreach (Sprite.CoordMapEntry coordMapEntry in result)
|
|
|
|
|
{
|
|
|
|
|
foreach (CoordMap.CoordMapSample rampSample in coordMapEntry.coordMap.RampSamples)
|
2021-10-06 13:24:32 -05:00
|
|
|
this.m_coordMap.InsertValue(coordMapEntry.idxLayer, rampSample.flPosition, rampSample.flValue, rampSample.Orientation);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool UpdateCoordMap(int idxLayer, CoordMap coordMap)
|
|
|
|
|
{
|
|
|
|
|
ArrayList result;
|
2021-07-11 23:07:04 -05:00
|
|
|
if (this.IsDynamicValueSet(PropId.CoordMap))
|
2021-07-11 23:04:40 -05:00
|
|
|
{
|
2021-07-11 23:07:04 -05:00
|
|
|
this.PropertyManager.GetCoordmapProp(this, out result);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (coordMap == null)
|
|
|
|
|
return false;
|
|
|
|
|
result = new ArrayList();
|
2021-07-11 23:07:04 -05:00
|
|
|
this.PropertyManager.SetCoordmapProp(this, result);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
2021-07-11 23:07:04 -05:00
|
|
|
Sprite.CoordMapEntry coordMapEntry1 = null;
|
2021-07-11 23:04:40 -05:00
|
|
|
foreach (Sprite.CoordMapEntry coordMapEntry2 in result)
|
|
|
|
|
{
|
|
|
|
|
if (coordMapEntry2.idxLayer == idxLayer)
|
|
|
|
|
{
|
|
|
|
|
coordMapEntry1 = coordMapEntry2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (coordMapEntry1 == null)
|
|
|
|
|
{
|
|
|
|
|
if (coordMap == null)
|
|
|
|
|
return false;
|
2021-07-11 23:07:04 -05:00
|
|
|
result.Add(new Sprite.CoordMapEntry(idxLayer, coordMap));
|
2021-07-11 23:04:40 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (coordMap == null)
|
2021-07-11 23:07:04 -05:00
|
|
|
result.Remove(coordMapEntry1);
|
2021-07-11 23:04:40 -05:00
|
|
|
else
|
|
|
|
|
coordMapEntry1.coordMap = coordMap;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ResetCoordmaps()
|
|
|
|
|
{
|
2021-07-11 23:07:04 -05:00
|
|
|
if (this.IsPropFlagSet(PropId.MaxDynamicProp) || this.IsDynamicValueSet(PropId.CoordMap))
|
2021-07-11 23:04:40 -05:00
|
|
|
{
|
2021-10-06 13:24:32 -05:00
|
|
|
this.m_coordMap.Clear();
|
2021-07-11 23:07:04 -05:00
|
|
|
this.SetPropFlag(PropId.MaxDynamicProp, false);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
2021-07-11 23:07:04 -05:00
|
|
|
this.PropertyManager.RemoveCoordmapProp(this);
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override void Reset()
|
|
|
|
|
{
|
|
|
|
|
base.Reset();
|
|
|
|
|
this.ResetCoordmaps();
|
2021-07-11 23:07:04 -05:00
|
|
|
this.Effect = null;
|
2021-07-11 23:04:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class CoordMapEntry
|
|
|
|
|
{
|
|
|
|
|
internal int idxLayer;
|
|
|
|
|
internal CoordMap coordMap;
|
|
|
|
|
|
|
|
|
|
internal CoordMapEntry(int idxLayerParam, CoordMap coordMapParam)
|
|
|
|
|
{
|
|
|
|
|
this.idxLayer = idxLayerParam;
|
|
|
|
|
this.coordMap = coordMapParam;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-11 22:59:29 -05:00
|
|
|
}
|
|
|
|
|
}
|