Example #1
0
        public override bool SetSpriteDataView(GameSetPresenter gsp)
        {
            DataView dv;

            dv            = new DataView(gsp.GameObject?.Tables?[this.SpriteId]);
            this.DataView = dv;

            return(this.GameObject.SetSpriteDataView(dv));
        }
        public override bool SetSpriteDataView(GameSetPresenter gsp)
        {
            DataView dv;

            dv           = new DataView(gsp.GameObject?.Tables?["SFRAME"]);
            dv.RowFilter = $"SPRITE = '{this.SpriteId.ToUpper()}'";

            this.DataView = dv;

            var result = this.GameObject.SetSpriteDataView(dv);

            if (result)
            {
                UpdateFrameNamesAndOffsets();
            }
            return(result);
        }
        public override bool SetSpriteDataView(GameSetPresenter gsp)
        {
            if (this.SpriteId == "i_town")
            {
                this.StandardSetTableName = "TOWNBULD";
            }
            else
            {
                return(true);
            }

            this.DataView = new DataView(gsp.GameObject?.Tables?[this.StandardSetTableName]);

            var result = this.GameObject.SetSpriteDataView(this.DataView);

            if (result)
            {
                UpdateFrameNamesAndOffsets();
            }
            return(result);
        }
Example #4
0
        public override SkaaSprite Load(string filePath, params object[] param)
        {
            GameSetPresenter gsp = null;

            try
            {
                gsp = (GameSetPresenter)param[0];
                if (gsp == null)
                {
                    throw new ArgumentNullException();
                }
            }
            catch (Exception e)
            {
                string errorMsg;

                if (e is IndexOutOfRangeException)      //param wasn't passed at all
                {
                    errorMsg = $"You must pass a non-null {typeof(GameSetPresenter)} so the ResIdx's {typeof(DataSet)} can be set.";
                    Logger.TraceEvent(TraceEventType.Error, 0, errorMsg);
                    throw new IndexOutOfRangeException(errorMsg);
                }
                else if (e is ArgumentNullException)     //thrown above
                {
                    errorMsg = $"You must pass a non-null {typeof(GameSetPresenter)} so the ResIdx's {typeof(DataSet)} can be set.";
                    Logger.TraceEvent(TraceEventType.Error, 0, errorMsg);
                    throw new ArgumentNullException(errorMsg);
                }
                else
                {
                    Logger.TraceEvent(TraceEventType.Error, 0, e.Message);
                    throw e;
                }
            }

            //hack: This is for files like i_raw.res which are just like normal ResIdx files,
            //except they have no name records, just offsets. We end up getting another params
            //array that was passed in to this params.
            bool offsetsOnly = false;

            if (param.Length >= 2)
            {
                var arr = (object[])param[1];
                if (arr.Length > 0)
                {
                    offsetsOnly = (bool)arr[0];
                }
            }

            Tuple <SkaaSprite, DataTable> tup = ReadFrames(filePath, this.PalettePresenter.GameObject, offsetsOnly);

            gsp.GameObject = gsp.GameObject ?? new DataSet();
            DataSet ds = gsp.GameObject;

            if (ds.Tables.Contains(tup.Item2.TableName))
            {
                var newName = tup.Item2.TableName + "_2";
                tup.Item1.SpriteId  = newName;
                tup.Item2.TableName = newName;
            }

            gsp.AddTable(tup.Item2);

            this.GameObject = tup.Item1;
            this.SpriteId   = this.GameObject.SpriteId;

            BuildFramePresenters();
            return(this.GameObject);
        }
 public void Merge(GameSetPresenter gsp)
 {
     this.GameObject.Merge(gsp.GameObject);
     OnPropertyChanged("GameObject");
 }
 public abstract bool SetSpriteDataView(GameSetPresenter gsp);