Example #1
0
 private void TestSG2()
 {
     var sg2 = new SG3(@"C:\Users\bbdnet6039\Downloads\OpenPharaoh\Data\Pharaoh_General.sg3");
     //var sg2 = new SG3(@"C:\Users\bbdnet6039\Downloads\OpenPharaoh\Data\Expansion.sg3");
 }
Example #2
0
        private void LoadSG3(string filename)
        {
            this.File = new SG3(filename);

            var root = new TreeNode("SG3", 0, 0);
            var rootS = new TreeNode("Sprites", 0, 0);
            var rootSDescription = new TreeNode(string.Format("Total sprites: {0}", this.File.TotalImages), 3, 3);

            var rootB = new TreeNode("Bitmaps", 0, 0);
            var rootBDescription = new TreeNode(string.Format("Total bitmaps: {0}", this.File.TotalFiles1), 3, 3);

            root.Nodes.Add(rootS);
            rootS.Nodes.Add(rootSDescription);
            root.Nodes.Add(rootB);
            rootB.Nodes.Add(rootBDescription);

            root.Expand();
            rootB.Expand();
            rootS.Expand();

            this.treeViewMain.Nodes.Clear();
            this.treeViewMain.Nodes.Add(root);

            for (var s = 0; s < SG3.MAX_SPRITES; s++)
            {
                var name = this.File.SpriteNames[s];
                var value = this.File.SpriteImageIndex[s];

                if (value == 0 && s != 0) break;

                var nodeText = new TreeNode(name, 2, 2);
                var nodeIndex = new TreeNode(string.Format("0x{0:X4} [{0}]", value), 3, 3);
                rootS.Nodes.Add(nodeText);
                nodeText.Nodes.Add(nodeIndex);

                // load bitmaps
                var startIndex = this.File.SpriteImageIndex[s];
                var endIndex = (ushort)this.File.TotalImages + 1;

                for (ushort j = 0; j < SG3.MAX_SPRITES; j++)
                {
                    var index = this.File.SpriteImageIndex[j];

                    if (index >= startIndex && index <= endIndex && j != s && index != 0)
                    {
                        endIndex = index;
                    }
                }

                for (ushort j = startIndex; j < endIndex; j++)
                {
                    var bitmapNode = new TreeNode(j.ToString(), 4, 4);
                    bitmapNode.Tag = this.File.Images[j];

                    nodeText.Nodes.Add(bitmapNode);
                }
            }

            for (int f = 0; f < this.File.TotalFiles1; f++)
            {
                var fobject = this.File.Files[f];

                var nodeBitmap = new TreeNode(fobject.Filename, 5, 5);
                nodeBitmap.Tag = fobject;

                var nodeBitmapDescription = new TreeNode(string.Format("{0}", fobject.Description), 3, 3);
                var nodeBitmapImages = new TreeNode(string.Format("from {0} up to {1}, total {2}", fobject.FirstImage, fobject.LastImage, fobject.Count), 3, 3);
                rootB.Nodes.Add(nodeBitmap);
                nodeBitmap.Nodes.Add(nodeBitmapDescription);
                nodeBitmap.Nodes.Add(nodeBitmapImages);

                for (var j = fobject.FirstImage; j <= fobject.LastImage; j++)
                {
                    var bitmapNode = new TreeNode(j.ToString(), 4, 4);
                    bitmapNode.Tag = this.File.Images[(ushort)j];

                    nodeBitmap.Nodes.Add(bitmapNode);
                }
            }
        }