Exemple #1
0
        public JazzGraphContainer(int index, JazzPackage jp,
                                  IResourceIndexEntry rie, Control view, TabPage page)
        {
            this.Index     = index;
            this.UndoRedo  = new UndoManager();
            this.SaveState = JazzSaveState.Saved;
            this.Key       = new RK(rie);
            this.Comp      = rie.Compressed == 0xFFFF;
            this.JP        = jp;
            this.RIE       = rie;
            IResource           res  = null;
            GenericRCOLResource rcol = null;

            try
            {
                res = WrapperDealer.GetResource(0, jp.Package, rie);
            }
            catch (Exception ex)
            {
                MainForm.ShowException(ex,
                                       "Could not load JAZZ resource: " + this.Key + "\n",
                                       MainForm.kName + ": Unable to load JAZZ resource");
            }
            if (res != null)
            {
                rcol = res as GenericRCOLResource;
                if (rcol != null)
                {
                    this.Scene = new StateMachineScene(
                        new StateMachine(rcol), view, this);
                    KKLayoutAlgorithm <StateNode, StateEdge> layout
                        = new KKLayoutAlgorithm <StateNode, StateEdge>(
                              this.Scene.StateGraph, this.Scene);
                    layout.LengthFactor = 1.25f;
                    this.Scene.Layout   = layout;
                    layout.ShuffleNodes();
                    this.Scene.LayoutPaused = true;
                    this.Scene.StartLayout();
                }
                else
                {
                    this.Scene = null;
                }
            }
            if (!KeyNameReg.TryFindName(rie.Instance, out this.mName))
            {
                this.mName = "0x" + rie.Instance.ToString("X16");
            }
            if (this.Scene != null)
            {
                this.mPage = page;
                this.mPage.Controls.Add(view);
                this.mPage.Text         = this.mName;
                this.mPage.SizeChanged +=
                    new EventHandler(this.OnTabSizeChanged);
            }
        }
        private JazzStateMachine.Animation ExportEntry(
            string sourceFile, uint code, bool useSourceFile,
            string nameSpace, ActorDefinition actor,
            IDictionary <ulong, string> nameMap, bool ean)
        {
            System.IO.Stream s = null;
            uint             hash;
            string           name;

            JazzStateMachine.Animation animation
                = new JazzStateMachine.Animation(0, null, s);
            if (useSourceFile)
            {
                // TODO: sourceFile should not allow parsable numbers
                // Try to create a better brute force unhasher for
                // reading animation source files.
                if (!sourceFile.StartsWith("0x") ||
                    !uint.TryParse(sourceFile.Substring(2),
                                   System.Globalization.NumberStyles.HexNumber,
                                   null, out hash))
                {
                    hash = FNVHash.HashString32(sourceFile);
                    if (!nameMap.TryGetValue(hash, out name) &&
                        (ean || !KeyNameReg.TryFindName(hash, out name)))
                    {
                        nameMap[hash] = sourceFile;
                    }
                }
                animation.NameHash = hash;
            }
            else
            {
                animation.NameHash = code;
            }
            if (nameSpace.StartsWith("0x") &&
                uint.TryParse(nameSpace.Substring(2),
                              System.Globalization.NumberStyles.HexNumber,
                              null, out hash))
            {
                animation.Actor1Hash = hash;
            }
            else
            {
                hash = FNVHash.HashString32(nameSpace);
                if (!nameMap.TryGetValue(hash, out name) &&
                    (ean || !KeyNameReg.TryFindName(hash, out name)))
                {
                    nameMap[hash] = sourceFile;
                }
                animation.Actor1Hash = hash;
            }

            animation.Actor2Hash = actor == null ? 0 : actor.NameHash;

            return(animation);
        }
        public void RefreshHashNames()
        {
            uint   hash;
            string name;
            SortedDictionary <string, ActorDefinition>     nsd;
            List <KeyValuePair <string, ActorDefinition> > nsl;
            List <KeyValuePair <string,
                                SortedDictionary <string, ActorDefinition> > > sources
                = new List <KeyValuePair <string,
                                          SortedDictionary <string, ActorDefinition> > >(
                      this.mSrcFile2Ns2Actor);

            foreach (KeyValuePair <string,
                                   SortedDictionary <string, ActorDefinition> > source in sources)
            {
                name = source.Key;
                nsd  = source.Value;
                if (name.StartsWith("0x") &&
                    uint.TryParse(name.Substring(2),
                                  System.Globalization.NumberStyles.HexNumber,
                                  null, out hash) &&
                    KeyNameReg.TryFindName(hash, out name))
                {
                    this.mSrcFile2Ns2Actor.Remove(source.Key);
                    this.mSrcFile2Ns2Actor.Add(name, nsd);
                }
                nsl = new List <KeyValuePair <string, ActorDefinition> >(nsd);
                foreach (KeyValuePair <string, ActorDefinition> ns in nsl)
                {
                    name = ns.Key;
                    if (name.StartsWith("0x") &&
                        uint.TryParse(name.Substring(2),
                                      System.Globalization.NumberStyles.HexNumber,
                                      null, out hash) &&
                        KeyNameReg.TryFindName(hash, out name))
                    {
                        nsd.Remove(ns.Key);
                        nsd.Add(name, ns.Value);
                    }
                }
            }
        }
Exemple #4
0
 public void RefreshHashNames()
 {
     if (this.mCases.Count > 0)
     {
         uint   hash;
         string value;
         foreach (CaseImpl c in this.mCases)
         {
             value = c.Value;
             if (value != null && value.StartsWith("0x") &&
                 uint.TryParse(value.Substring(2),
                               System.Globalization.NumberStyles.HexNumber,
                               null, out hash) &&
                 KeyNameReg.TryFindName(hash, out value))
             {
                 c.Value = value;
             }
         }
     }
 }
        public void UpdateKeyToFilenameMap(
            IDictionary <ulong, string> keyNameMap)
        {
            if (keyNameMap == null)
            {
                throw new ArgumentNullException("keyNameMap");
            }
            this.mKeyToFilenameMap.Clear();
            string    name;
            List <RK> rks = this.mStateMachine.SlurpReferencedRKs();

            foreach (RK rk in rks)
            {
                if (rk.TID == 0x6b20c4f3 &&
                    (keyNameMap.TryGetValue(rk.IID, out name) ||
                     KeyNameReg.TryFindName(rk.IID, out name)))
                {
                    this.mKeyToFilenameMap[rk] = name;
                }
            }
        }
Exemple #6
0
        public override void UpdateVisualization()
        {
            if (this.mScene.StateView == null)
            {
                return;
            }
            SizeF        size;
            float        w = 40;
            float        h = 15;
            string       name;
            IResourceKey rk;

            Graphics      g  = this.mScene.StateView.CreateGraphics();
            StringBuilder sb = new StringBuilder();

            ActorDefinition ad = this.mPlayNode.Actor;

            /*this.mActorString = "Actor: " + (ad == null ? "" : ad.Name);
             * //w = Math.Max(w, kAGW * this.mActorString.Length + 4);
             * size = g.MeasureString(this.mActorString, TextFont);
             * w = Math.Max(w, size.Width + 5);/* */
            sb.AppendLine("Actor: " + (ad == null ? "" : ad.Name));

            /*this.mPropsString = "Flags: "
             + AnimFlagString(this.mPlayNode.Flags);
             + //w = Math.Max(w, kAGW * this.mPropsString.Length + 4);
             + size = g.MeasureString(this.mPropsString, TextFont);
             + w = Math.Max(w, size.Width + 5);/* */
            sb.Append("Flags: ");
            sb.Append(AnimFlagString(this.mPlayNode.Flags));

            JazzAnimationFlags flags = this.mPlayNode.Flags;

            rk = this.mPlayNode.ClipKey;
            if (!string.IsNullOrEmpty(this.mPlayNode.ClipPattern))
            {
                /*this.mBaseClipString = "Base: "
                 + this.mPlayNode.ClipPattern;
                 + //w = Math.Max(w, kAGW * this.mBaseClipString.Length + 4);
                 + size = g.MeasureString(this.mBaseClipString, TextFont);
                 + w = Math.Max(w, size.Width + 5);
                 + h += kMGH;/* */
                sb.AppendLine();
                sb.Append("Base: ");
                sb.Append(this.mPlayNode.ClipPattern);

                if ((flags & kBaseClipMask)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social | Object Only)");
                }
                else if (
                    (flags & JazzAnimationFlags.BaseClipIsSocial)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social)");
                }
                else if (
                    (flags & JazzAnimationFlags.BaseClipIsObjectOnly)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Object Only)");
                }
            }
            else if (rk != null && !rk.Equals(sZeroKey) && rk.Instance != 0)
            {
                /*this.mBaseClipString = "Base: " + rk.ToString();
                 * if (KeyNameReg.TryFindName(rk.Instance, out name))
                 * {
                 *  this.mBaseClipString += string.Concat(" ", name);
                 * }
                 * //w = Math.Max(w, kAGW * this.mBaseClipString.Length + 4);
                 * size = g.MeasureString(this.mBaseClipString, TextFont);
                 * w = Math.Max(w, size.Width + 5);
                 * h += kMGH;/* */
                sb.AppendLine();
                sb.Append("Base: ");
                if (KeyNameReg.TryFindName(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else if (KeyNameReg.TryFindGenCLIP(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else if (KeyNameReg.TryFindLabel(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else
                {
                    sb.Append("0x" + rk.Instance.ToString("X16"));
                }
                if ((flags & kBaseClipMask)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social | Object Only)");
                }
                else if (
                    (flags & JazzAnimationFlags.BaseClipIsSocial)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social)");
                }
                else if (
                    (flags & JazzAnimationFlags.BaseClipIsObjectOnly)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Object Only)");
                }
            }

            /*else
            *  {
            *   this.mBaseClipString = null;
            *  }/* */

            rk = this.mPlayNode.TrackMaskKey;
            if (rk != null && !rk.Equals(sZeroKey) && rk.Instance != 0)
            {
                /*this.mTkMkString = "TkMk: " + rk.ToString();
                 * if (KeyNameReg.TryFindName(rk.Instance, out name))
                 * {
                 *  this.mTkMkString += string.Concat(" ", name);
                 * }
                 * //w = Math.Max(w, kAGW * this.mTkMkString.Length + 4);
                 * size = g.MeasureString(this.mTkMkString, TextFont);
                 * w = Math.Max(w, size.Width + 5);
                 * h += kMGH;/* */
                sb.AppendLine();
                sb.Append("TkMk: ");
                if (KeyNameReg.TryFindNameOrLabel(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else
                {
                    sb.Append("0x" + rk.Instance.ToString("X16"));
                }
            }

            /*else
            *  {
            *   this.mTkMkString = null;
            *  }/* */

            rk = this.mPlayNode.AdditiveClipKey;
            if (!string.IsNullOrEmpty(this.mPlayNode.AdditiveClipPattern))
            {
                /*this.mAddiClipString = "Addi: "
                 + this.mPlayNode.AdditiveClipPattern;
                 + //w = Math.Max(w, kAGW * this.mAddiClipString.Length + 4);
                 + size = g.MeasureString(this.mAddiClipString, TextFont);
                 + w = Math.Max(w, size.Width + 5);
                 + h += kMGH;/* */
                sb.AppendLine();
                sb.Append("Addi: ");
                sb.Append(this.mPlayNode.AdditiveClipPattern);

                if ((flags & kAdditiveClipMask)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social | Object Only)");
                }
                else if (
                    (flags & JazzAnimationFlags.AdditiveClipIsSocial)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social)");
                }
                else if (
                    (flags & JazzAnimationFlags.AdditiveClipIsObjectOnly)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Object Only)");
                }
            }
            else if (rk != null && !rk.Equals(sZeroKey) && rk.Instance != 0)
            {
                /*this.mAddiClipString = "Addi: " + rk.ToString();
                 * if (KeyNameReg.TryFindName(rk.Instance, out name))
                 * {
                 *  this.mAddiClipString += string.Concat(" ", name);
                 * }
                 * //w = Math.Max(w, kAGW * this.mAddiClipString.Length + 4);
                 * size = g.MeasureString(this.mAddiClipString, TextFont);
                 * w = Math.Max(w, size.Width + 5);
                 * h += kMGH;/* */
                sb.AppendLine();
                sb.Append("Addi: ");
                if (KeyNameReg.TryFindName(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else if (KeyNameReg.TryFindGenCLIP(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else if (KeyNameReg.TryFindLabel(rk.Instance, out name))
                {
                    sb.Append(name);
                }
                else
                {
                    sb.Append("0x" + rk.Instance.ToString("X16"));
                }
                if ((flags & kAdditiveClipMask)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social | Object Only)");
                }
                else if (
                    (flags & JazzAnimationFlags.AdditiveClipIsSocial)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Social)");
                }
                else if (
                    (flags & JazzAnimationFlags.AdditiveClipIsObjectOnly)
                    != JazzAnimationFlags.TimingNormal)
                {
                    sb.Append(" (Object Only)");
                }
            }

            /*else
            *  {
            *   this.mAddiClipString = null;
            *  }/* */

            this.mTextString = sb.ToString();
            size             = g.MeasureString(this.mTextString, sTextFont);
            w = Math.Max(w, size.Width + 5);
            h = Math.Max(h, size.Height + 5);

            this.mEntryAnchor.SetPosition(0, h / 2);
            this.mTargetAnchor.SetPosition(w, h / 2);

            if (this.mBorderPath == null)
            {
                this.mBorderPath = new GraphicsPath();
            }
            this.mBorderPath.Reset();
            AddRoundedRectangle(this.mBorderPath, 0, 0, w, h, 5);

            float bbp = 2 * AnchorPoint.Radius;

            this.BoundingBox = new RectangleF(
                -bbp, -bbp, w + 2 * bbp, h + 2 * bbp);
        }
Exemple #7
0
        public override void UpdateVisualization()
        {
            if (this.mScene.StateView == null)
            {
                return;
            }
            SizeF size;
            float w = 20;
            float h = 15;

            Graphics      g  = this.mScene.StateView.CreateGraphics();
            StringBuilder sb = new StringBuilder();

            ActorDefinition ad = this.mPropNode.PropActor;

            /*this.mActorString = "A: " + (ad == null ? "" : ad.Name);
             * //w = Math.Max(w, kAGW * this.mActorString.Length + 4);
             * size = g.MeasureString(this.mActorString, TextFont);
             * w = Math.Max(w, size.Width + 5);/* */
            sb.AppendLine(string.Concat("A: ", (ad == null ? "" : ad.Name)));

            ParamDefinition pd = this.mPropNode.PropParam;

            /*this.mParamString = "P: " + (pd == null ? "" : pd.Name);
             * //w = Math.Max(w, kAGW * this.mParamString.Length + 4);
             * size = g.MeasureString(this.mParamString, TextFont);
             * w = Math.Max(w, size.Width + 5);/* */
            sb.AppendLine(string.Concat("P: ", (pd == null ? "" : pd.Name)));

            IResourceKey rk = this.mPropNode.PropKey;

            /*this.mKeyString = "K: " + rk.ToString();
             * string name;
             * if (KeyNameReg.TryFindName(rk.Instance, out name))
             * {
             *  this.mKeyString += string.Concat(" ", name);
             * }
             * //w = Math.Max(w, kAGW * this.mKeyString.Length + 4);
             * size = g.MeasureString(this.mKeyString, TextFont);
             * w = Math.Max(w, size.Width + 5);/* */
            sb.Append(string.Concat("K: ", rk.ToString()));
            string name;

            if (KeyNameReg.TryFindName(rk.Instance, out name))
            {
                sb.Append(string.Concat(" ", name));
            }

            this.mTextString = sb.ToString();
            size             = g.MeasureString(this.mTextString, sTextFont);
            w = Math.Max(w, size.Width + 5);
            h = Math.Max(h, size.Height + 5);

            this.mEntryAnchor.SetPosition(0, h / 2);
            this.mTargetAnchor.SetPosition(w, h / 2);

            if (this.mBorderPath == null)
            {
                this.mBorderPath = new GraphicsPath();
            }
            this.mBorderPath.Reset();
            AddRoundedRectangle(this.mBorderPath, 0, 0, w, h, 5);

            float bbp = 2 * AnchorPoint.Radius;

            this.BoundingBox = new RectangleF(
                -bbp, -bbp, w + 2 * bbp, h + 2 * bbp);
        }