Example #1
0
        public override GenericRCOLResource.ChunkEntry Export(
            IDictionary <ulong, string> nameMap, bool exportAllNames)
        {
            System.IO.Stream s = null;
            TGIBlock         tgi
                = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
            JazzParameterDefinition jpd
                = new JazzParameterDefinition(0, null, s);

            jpd.NameHash     = this.mNameHash;
            jpd.DefaultValue = this.mDefaultHash;
            if (!this.bNameIsHash &&
                nameMap != null && !nameMap.ContainsKey(this.mNameHash) &&
                (exportAllNames || !KeyNameReg.HasName(this.mNameHash)))
            {
                nameMap[this.mNameHash] = this.mName;
            }
            if (!this.bDefaultIsHash &&
                nameMap != null && !nameMap.ContainsKey(this.mDefaultHash) &&
                (exportAllNames || !KeyNameReg.HasName(this.mDefaultHash)))
            {
                nameMap[this.mDefaultHash] = this.mDefaultValue;
            }
            return(new GenericRCOLResource.ChunkEntry(0, null, tgi, jpd));
        }
Example #2
0
 public static void Load()
 {
     FileTable.FileTableEnabled = true;
     // Load all the name maps into the registry
     if (StatusMessage != null)
     {
         StatusMessage("Loading Key Name Maps...");
     }
     KeyNameReg.RefreshKeyNameMaps();
     // Load all the available jazz graphs into their manager
     if (StatusMessage != null)
     {
         StatusMessage("Searching for Jazz Graph Resources...");
     }
     JazzManager = ResourceMgr.GetResourceManager(kJazzTID);
     JazzManager.LoadAll();
     // Load all the available animations into their manager
     if (StatusMessage != null)
     {
         StatusMessage("Searching for Animation Resources...");
     }
     ClipManager = ResourceMgr.GetResourceManager(kClipTID);
     ClipManager.LoadAll();
     // Close all open package file streams after loading
     if (StatusMessage != null)
     {
         StatusMessage("Closing Package Filestreams...");
     }
     FileTableExt.Reset();
     FileTableExt.CloseCustomContent();
     FileTable.Reset();
 }
Example #3
0
        public override GenericRCOLResource.ChunkEntry Export(
            IDictionary <ulong, string> nameMap, bool exportAllNames)
        {
            System.IO.Stream s = null;
            TGIBlock         tgi
                = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
            JazzState js = new JazzState(0, null, s);

            js.NameHash           = this.mNameHash;
            js.Properties         = this.mFlags;
            js.DecisionGraphIndex = this.mDecisionGraph == null
                ? NullCRef : this.mDecisionGraph.ChunkReference;

            State[] transitions = this.mTransitions.ToArray();
            Array.Sort(transitions, 0, transitions.Length,
                       NameComparer.Instance);
            JazzChunk.ChunkReferenceList osi = js.OutboundStateIndexes;
            foreach (State state in transitions)
            {
                osi.Add(state == null ? NullCRef : state.ChunkReference);
            }
            js.AwarenessOverlayLevel = this.mAwarenessOverlayLevel;

            if (!this.bNameIsHash &&
                nameMap != null && !nameMap.ContainsKey(this.mNameHash) &&
                (exportAllNames || !KeyNameReg.HasName(this.mNameHash)))
            {
                nameMap[this.mNameHash] = this.mName;
            }
            return(new GenericRCOLResource.ChunkEntry(0, null, tgi, js));
        }
Example #4
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);
            }
        }
Example #5
0
        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);
        }
Example #6
0
 public static void RefreshCurrent()
 {
     // Reset Key Name Map Registry
     KeyNameMap.ResetCurrent();
     KeyNameS3SA.ResetCurrent();
     KeyNameReg.RefreshKeyNameMaps();
     // Reset Resource Managers
     JazzManager.RefreshCurrent();
     ClipManager.RefreshCurrent();
 }
Example #7
0
        public override GenericRCOLResource.ChunkEntry Export(
            IDictionary <ulong, string> nameMap, bool exportAllNames)
        {
            System.IO.Stream s = null;
            TGIBlock         tgi
                = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
            JazzSelectOnParameterNode jsopn
                = new JazzSelectOnParameterNode(0, null, s);

            jsopn.ParameterDefinitionIndex = this.mParameter == null
                ? NullCRef : this.mParameter.ChunkReference;
            if (this.mCases.Count > 0)
            {
                int  j;
                uint hash = 0;
                JazzSelectOnParameterNode.Match     match;
                JazzSelectOnParameterNode.MatchList mList = jsopn.Matches;
                JazzChunk.ChunkReferenceList        dgi;
                List <DecisionGraphNode>            targets;
                foreach (CaseImpl c in this.mCases)
                {
                    match = new JazzSelectOnParameterNode.Match(0, null);
                    if (c.Value == null)
                    {
                        hash = 0;
                    }
                    else if (!c.Value.StartsWith("0x") ||
                             !uint.TryParse(c.Value.Substring(2),
                                            System.Globalization.NumberStyles.HexNumber,
                                            null, out hash))
                    {
                        hash = FNVHash.HashString32(c.Value);
                        if (nameMap != null && !nameMap.ContainsKey(hash) &&
                            (exportAllNames || !KeyNameReg.HasName(hash)))
                        {
                            nameMap[hash] = c.Value;
                        }
                    }
                    match.TestValue = hash;
                    dgi             = match.DecisionGraphIndexes;
                    targets         = c.Targets;
                    for (j = 0; j < targets.Count; j++)
                    {
                        dgi.Add(targets[j] == null
                            ? NullCRef : targets[j].ChunkReference);
                    }
                    mList.Add(match);
                }
            }
            return(new GenericRCOLResource.ChunkEntry(0, null, tgi, jsopn));
        }
Example #8
0
        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);
                    }
                }
            }
        }
Example #9
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;
             }
         }
     }
 }
Example #10
0
        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;
                }
            }
        }
Example #11
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);
        }
Example #12
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);
        }