Esempio n. 1
0
        private void UpdateLayersView()
        {
            LayersListBox.SuspendLayout();
            LayersListBox.BeginUpdate();
            LayersListBox.Items.Clear();

            //Early out if the worldspace project is null (ie: We just unloaded the project)
            if (_loadedWorldspaceProject == null)
            {
                LayersListBox.EndUpdate();
                LayersListBox.ResumeLayout();

                return;
            }

            WindWakerEntityData entData = _selectedEntityFile;
            List <EditorHelpers.EntityLayer> validLayers = new List <EditorHelpers.EntityLayer>();

            foreach (var kvPair in entData.GetAllChunks())
            {
                foreach (WindWakerEntityData.BaseChunk chunk in kvPair.Value)
                {
                    if (validLayers.Contains(chunk.ChunkLayer))
                    {
                        continue;
                    }

                    validLayers.Add(chunk.ChunkLayer);
                }
            }

            for (int i = validLayers.Count - 1; i >= 0; i--)
            {
                LayersListBox.Items.Add(EditorHelpers.LayerIdToString(validLayers[i]));
            }

            //Select the Default layer by uh... default.
            if (LayersListBox.Items.Count > 0)
            {
                LayersListBox.SetSelected(LayersListBox.Items.Count - 1, true);
            }

            LayersListBox.ResumeLayout();
            LayersListBox.EndUpdate();
        }
Esempio n. 2
0
        private void PerformTestsForWorldspaceProject(WorldspaceProject project)
        {
            Console.WriteLine("Performing tests on {0}", project.Name);

            foreach (ZArchive archive in project.GetAllArchives())
            {
                WindWakerEntityData data = archive.GetFileByType <WindWakerEntityData>();
                if (data == null)
                {
                    continue;
                }

                foreach (List <WindWakerEntityData.BaseChunk> chunkList in data.GetAllChunks().Values)
                {
                    int chunkId = 0;
                    foreach (WindWakerEntityData.BaseChunk chunk in chunkList)
                    {
                        foreach (FieldInfo field in chunk.GetType().GetFields())
                        {
                            UnitTestValue attribute = (UnitTestValue)Attribute.GetCustomAttribute(field, typeof(UnitTestValue));
                            if (attribute != null)
                            {
                                object testValue   = field.GetValue(chunk);
                                object attribValue = attribute.Value;

                                bool bEquals = attribValue.Equals(testValue);
                                if (bEquals)
                                {
                                    continue;
                                }

                                //If they're not equals, we're going to want to print them to disk.
                                string failureText = string.Format("{0}|{1} #{2} failed. Field \"{5}\" Expected: {3} Got: {4}", project.Name, chunk.ChunkName, chunkId, attribValue, testValue, field.Name);
                                File.AppendAllText(_outputDir + "//results.txt", failureText + Environment.NewLine);
                            }
                        }

                        chunkId++;
                    }
                }
            }
        }
Esempio n. 3
0
        private void UpdateEntityTreeview()
        {
            Stopwatch timer = Stopwatch.StartNew();

            toolStripStatusLabel1.Text = "Updating Entity Treeview...";

            EntityTreeview.SuspendLayout();
            EntityTreeview.BeginUpdate();
            EntityTreeview.Nodes.Clear();

            //Early out in case we just unloaded a project.
            if (_loadedWorldspaceProject == null || _selectedEntityFile == null)
            {
                EntityTreeview.ResumeLayout();
                EntityTreeview.EndUpdate();
                return;
            }

            foreach (var kvPair in _selectedEntityFile.GetAllChunks())
            {
                //This is the top-level grouping, ie: "Doors". We don't know the name yet though.
                TreeNode topLevelNode      = EntityTreeview.Nodes.Add("ChunkHeader");
                TreeNode topLevelNodeLayer = null;
                int      i = 0;

                foreach (var chunk in kvPair.Value)
                {
                    if (chunk.ChunkLayer != EditorHelpers.EntityLayer.DefaultLayer && chunk.ChunkLayer != _selectedEntityLayer)
                    {
                        continue;
                    }

                    TreeNode curParentNode = topLevelNode;

                    //If it's a non-default layer we want to put them under a different TLN
                    if (chunk.ChunkLayer != EditorHelpers.EntityLayer.DefaultLayer)
                    {
                        if (topLevelNodeLayer == null)
                        {
                            topLevelNodeLayer = EntityTreeview.Nodes.Add("ChunkHeaderLayer");
                        }
                        topLevelNodeLayer.Text      = "[" + chunk.ChunkName.ToUpper() + "] " + chunk.ChunkDescription + " [" + EditorHelpers.LayerIdToString(chunk.ChunkLayer) + "]";
                        topLevelNodeLayer.BackColor = EditorHelpers.LayerIdToColor(chunk.ChunkLayer);
                        curParentNode = topLevelNodeLayer;
                    }
                    else
                    {
                        topLevelNode.Text = "[" + chunk.ChunkName.ToUpper() + "] " + chunk.ChunkDescription;
                    }

                    string displayName = string.Empty;
                    //Now generate the name for our current node. If it doesn't have a DisplayName attribute then we'll just
                    //use an index, otherwise we'll use the display name + index.
                    foreach (var field in chunk.GetType().GetFields())
                    {
                        DisplayName dispNameAttribute =
                            (DisplayName)Attribute.GetCustomAttribute(field, typeof(DisplayName));
                        if (dispNameAttribute != null)
                        {
                            displayName = (string)field.GetValue(chunk);
                        }
                    }

                    TreeNode newNode = curParentNode.Nodes.Add("[" + i + "] " + displayName);
                    newNode.Tag = chunk;


                    if (chunk.ChunkLayer != EditorHelpers.EntityLayer.DefaultLayer)
                    {
                        newNode.BackColor = EditorHelpers.LayerIdToColor(chunk.ChunkLayer);
                    }
                    i++;
                }

                //Some maps only have copies of things on sub-layers and not the main
                //layer, so we're going to remove the main layer one if it hasn't been
                //used.
                if (topLevelNode.Text == "ChunkHeader")
                {
                    EntityTreeview.Nodes.Remove(topLevelNode);
                }
            }

            EntityTreeview.EndUpdate();
            EntityTreeview.ResumeLayout();
            Console.WriteLine("Updating ETV took: " + timer.Elapsed);
            toolStripStatusLabel1.Text = "Completed.";
        }