Beispiel #1
0
        static public new string ToString()
        {
            string output = "{Enum Name},{Enum ID}," + Memory.Icons.GetEntry(Icons.ID.Finger_Right).ToStringHeader;

            for (uint i = 0; i < Memory.Icons.Count; i++)
            {
                EntryGroup eg = Memory.Icons.GetEntryGroup((Icons.ID)i);
                foreach (Entry e in eg)
                {
                    output += $"{((Icons.ID)i).ToString().Replace('_', ' ')},{i}," + e.ToString();
                }
            }
            return(output);
        }
Beispiel #2
0
 protected override void InitEntries(ArchiveWorker aw = null)
 {
     if (Entries == null)
     {
         //read from icon.sp1
         using (MemoryStream ms = new MemoryStream(ArchiveWorker.GetBinaryFile(ArchiveString,
                                                                               aw.GetListOfFiles().First(x => x.IndexOf(IndexFilename, StringComparison.OrdinalIgnoreCase) >= 0))))
         {
             using (BinaryReader br = new BinaryReader(ms))
             {
                 Loc[] locs = new Loc[br.ReadUInt32()];
                 for (int i = 0; i < locs.Length; i++)
                 {
                     locs[i].seek   = br.ReadUInt16();
                     locs[i].length = br.ReadUInt16();
                 }
                 Entries = new Dictionary <ID, EntryGroup>(locs.Length + 10);
                 for (int i = 0; i < locs.Length; i++)
                 {
                     ms.Seek(locs[i].seek, SeekOrigin.Begin);
                     byte c = (byte)locs[i].length;
                     Entries[(ID)i] = new EntryGroup(c);
                     for (int e = 0; e < c; e++)
                     {
                         Entry tmp = new Entry();
                         tmp.LoadfromStreamSP1(br);
                         tmp.Part = (byte)e;
                         tmp.SetLoc(locs[i]);
                         Entries[(ID)i].Add(tmp);
                     }
                 }
             }
             //custom stuff not in sp1
             InsertCustomEntries();
         }
     }
 }
Beispiel #3
0
        public Icons()
        {
            if (entries == null)
            {
                ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
                TEX           tex;
                byte[]        test = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                                 aw.GetListOfFiles().First(x => x.ToLower().Contains("icon.tex")));

                tex         = new TEX(test);
                PalletCount = tex.TextureData.NumOfPalettes;
                icons       = new Texture2D[PalletCount];
                for (int i = 0; i < PalletCount; i++)
                {
                    icons[i] = tex.GetTexture(i);
                    //using (FileStream fs = File.OpenWrite($"d:\\icons.{i}.png"))
                    //{
                    //    //fs.Write(test, 0, test.Length);

                    //    icons[i].SaveAsPng(fs, 256, 256);
                    //}
                }
                test = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU,
                                                   aw.GetListOfFiles().First(x => x.ToLower().Contains("icon.sp1")));
                //using (FileStream fs = File.OpenWrite(Path.Combine("d:\\", "icons.sp1")))
                //{
                //    fs.Write(test, 0, test.Length);
                //}
                //read from icon.sp1
                using (MemoryStream ms = new MemoryStream(test))
                {
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Count = br.ReadUInt32();
                        Loc[] locs = new Loc[Count];
                        for (int i = 0; i < Count; i++)
                        {
                            locs[i].pos   = br.ReadUInt16();
                            locs[i].count = br.ReadUInt16();
                            //if (locs[i].count > 1) Count += (uint)(locs[i].count - 1);
                        }
                        entries = new Dictionary <ID, EntryGroup>((int)Count + 10);
                        for (int i = 0; i < Count; i++)
                        {
                            ms.Seek(locs[i].pos, SeekOrigin.Begin);
                            byte c = (byte)locs[i].count;
                            entries[(ID)i] = new EntryGroup(c);
                            for (int e = 0; e < c; e++)
                            {
                                Entry tmp = new Entry();
                                tmp.LoadfromStreamSP1(br);
                                tmp.Part = (byte)e;
                                tmp.SetLoc(locs[i]);
                                entries[(ID)i].Add(tmp);
                            }
                        }
                    }
                    //custom stuff not in sp1
                    Entry BG = new Entry
                    {
                        X            = 0,
                        Y            = 48,
                        Width        = 256,
                        Height       = 16,
                        CustomPallet = 1,
                        Tile         = Vector2.UnitY,
                    };
                    Entry Border_TopLeft = new Entry
                    {
                        X            = 16,
                        Y            = 0,
                        Width        = 8,
                        Height       = 8,
                        CustomPallet = 0,
                    };
                    Entry Border_Top = new Entry
                    {
                        X            = 24,
                        Y            = 0,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        Offset_X     = 8,
                        Offset_X2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_Bottom = new Entry
                    {
                        X            = 24,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        Snap_Bottom  = true,
                        Offset_Y     = -8,
                        Offset_X     = 8,
                        Offset_X2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_TopRight = new Entry
                    {
                        X            = 32,
                        Y            = 0,
                        Width        = 8,
                        Height       = 8,
                        Snap_Right   = true,
                        Offset_X     = -8,
                        CustomPallet = 0
                    };
                    Entry Border_Left = new Entry
                    {
                        X            = 16,
                        Y            = 8,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitY,
                        Offset_Y     = 8,
                        Offset_Y2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_Right = new Entry
                    {
                        X            = 32,
                        Y            = 8,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitY,
                        Snap_Right   = true,
                        Offset_X     = -8,
                        Offset_Y     = 8,
                        Offset_Y2    = -8,
                        CustomPallet = 0
                    };
                    Entry Border_BottomLeft = new Entry
                    {
                        X            = 16,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Snap_Bottom  = true,
                        Offset_Y     = -8,
                        CustomPallet = 0
                    };
                    Entry Border_BottomRight = new Entry
                    {
                        X            = 32,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Snap_Bottom  = true,
                        Snap_Right   = true,
                        Offset_X     = -8,
                        Offset_Y     = -8,
                        CustomPallet = 0
                    };

                    entries[ID.Bar_BG] = new EntryGroup(new Entry
                    {
                        X            = 16,
                        Y            = 24,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        CustomPallet = 0
                    });
                    entries[ID.Bar_Fill] = new EntryGroup(new Entry
                    {
                        X            = 0,
                        Y            = 16,
                        Width        = 8,
                        Height       = 8,
                        Tile         = Vector2.UnitX,
                        Offset_Y     = 1,
                        CustomPallet = 5
                    });
                    entries[ID.Menu_BG_256] = new EntryGroup(BG, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
                    entries[ID.Menu_BG_368] = new EntryGroup(BG, new Entry
                    {
                        X            = 0,
                        Y            = 64,
                        Offset_X     = 256,
                        Width        = 112,
                        Height       = 16,
                        CustomPallet = 1,
                        Tile         = Vector2.UnitY
                    }, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
                    Count = (uint)entries.Count;

                    entries[ID.DEBUG] = new EntryGroup(
                        new Entry {
                        X = 128, Y = 24, Width = 7, Height = 8
                    },
                        new Entry {
                        X = 65, Y = 8, Width = 6, Height = 8, Offset_X = 7
                    },
                        new Entry {
                        X = 147, Y = 24, Width = 6, Height = 8, Offset_X = 13
                    },
                        new Entry {
                        X = 141, Y = 24, Width = 6, Height = 8, Offset_X = 19
                    },
                        new Entry {
                        X = 104, Y = 16, Width = 6, Height = 8, Offset_X = 25
                    }
                        );
                }
            }
        }