Пример #1
0
 private static void DrawIcon(FF8String buffer, Vector2 zoom, float Fade, bool skipdraw, Point real, ref Point size, ref bool skipletter, ref int i, ref byte c)
 {
     if (i + 3 < buffer.Length)
     {
         c = buffer[++i];
         short ic = c;
         c   = buffer[++i];
         ic |= (short)(c << 8);
         byte pal = buffer[++i];
         Memory.Icons.Trim((Icons.ID)ic, pal);
         EntryGroup icon = Memory.Icons[(Icons.ID)ic];
         //Vector2 scale = Memory.Icons.GetTexture((Icons.ID)ic).ScaleFactor;
         if (icon != null)
         {
             float   adj   = (12 / (float)(icon.Height));
             Vector2 scale = new Vector2(adj * zoom.X);
             size.X = (int)(icon.Width * scale.X);
             size.Y = (int)(icon.Height * scale.X);
             Rectangle destRect = new Rectangle(real, size);
             //real.X += size.X;
             //skipletter = true;
             if (!skipdraw)
             {
                 Memory.Icons.Draw((Icons.ID)ic, pal, destRect, Vector2.Zero, Fade);
             }
         }
     }
 }
Пример #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);
                     }
                 }
             }
         }
     }
 }
Пример #3
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);
        }
Пример #4
0
        private void GeneratePages(ID label, ID label_pg1, byte count, sbyte offset)
        {
            if (!Entries.ContainsKey(label_pg1) && !Entries.ContainsKey(label) && !Entries.ContainsKey(ID.Size_08x08_P_))
            {
                return;
            }

            count = (byte)MathHelper.Clamp(count, 1, 99);
            var P_ = Entries[ID.Size_08x08_P_][0].Clone();

            P_.Offset.X     += Entries[label][0].Width + offset;
            P_.CustomPalette = 2;

            var _ = new Entry[10];

            _[1]               = Entries[ID.Num_8x8_1_1][0].Clone();
            _[1].Offset.X     += P_.Offset.X + P_.Width + 2;
            _[1].CustomPalette = 7;
            for (byte i = 2; i <= 9 && i <= count; i++)
            {
                _[i]               = Entries[ID.Num_8x8_1_1 + i - 1][0].Clone();
                _[i].Offset.X      = _[1].Offset.X;
                _[i].CustomPalette = _[1].CustomPalette;
            }
            Entry[] __ = null;
            if (count > 9)
            {
                __                  = new Entry[10];
                __[0]               = Entries[ID.Num_8x8_1_0][0].Clone();
                __[0].Offset.X     += P_.Offset.X + P_.Width + 2 + _[1].Width;
                __[0].CustomPalette = 7;
                for (byte i = 1; i <= 9; i++)
                {
                    __[i]          = _[i].Clone();
                    __[i].Offset.X = __[0].Offset.X;
                }
            }
            for (byte i = 1; i <= count; i++)
            {
                if (i < 10)
                {
                    Entries[label_pg1 + i - 1] = new EntryGroup(Entries[label][0], P_, _[i]);
                }
                else if (i >= 10 && __ != null)
                {
                    Entries[label_pg1 + i - 1] = new EntryGroup(Entries[label][0], P_, _[i / 10], __[i % 10]);
                }
            }
        }
        /// <summary>
        /// Add Manual hardcoded entries / settings here.
        /// </summary>
        /// <remarks>Maybe one day we can export these to an xml file and read it in on launch.</remarks>
        protected override void InsertCustomEntries()
        {
            if (Entries == null)
            {
                return;
            }
            Entry BG = new Entry
            {
                X             = 0,
                Y             = 48,
                Width         = 256,
                Height        = 16,
                CustomPalette = 1,
                Fill          = Vector2.UnitX,
                Tile          = Vector2.UnitY,
            };
            Entry Border_TopLeft = new Entry
            {
                X             = 16,
                Y             = 0,
                Width         = 8,
                Height        = 8,
                CustomPalette = 0,
            };
            Entry Border_Top = new Entry
            {
                X             = 24,
                Y             = 0,
                Width         = 8,
                Height        = 8,
                Tile          = Vector2.UnitX,
                Offset        = new Vector2(8, 0),
                End           = new Vector2(-8, 0),
                CustomPalette = 0
            };
            Entry Border_Bottom = new Entry
            {
                X             = 24,
                Y             = 16,
                Width         = 8,
                Height        = 8,
                Tile          = Vector2.UnitX,
                Snap_Bottom   = true,
                Offset        = new Vector2(8, -8),
                End           = new Vector2(-8, 0),
                CustomPalette = 0
            };
            Entry Border_TopRight = new Entry
            {
                X             = 32,
                Y             = 0,
                Width         = 8,
                Height        = 8,
                Snap_Right    = true,
                Offset        = new Vector2(-8, 0),
                CustomPalette = 0
            };
            Entry Border_Left = new Entry
            {
                X             = 16,
                Y             = 8,
                Width         = 8,
                Height        = 8,
                Tile          = Vector2.UnitY,
                Offset        = new Vector2(0, 8),
                End           = new Vector2(0, -8),
                CustomPalette = 0
            };
            Entry Border_Right = new Entry
            {
                X             = 32,
                Y             = 8,
                Width         = 8,
                Height        = 8,
                Tile          = Vector2.UnitY,
                Snap_Right    = true,
                Offset        = new Vector2(-8, 8),
                End           = new Vector2(0, -8),
                CustomPalette = 0
            };
            Entry Border_BottomLeft = new Entry
            {
                X             = 16,
                Y             = 16,
                Width         = 8,
                Height        = 8,
                Snap_Bottom   = true,
                Offset        = new Vector2(0, -8),
                CustomPalette = 0
            };
            Entry Border_BottomRight = new Entry
            {
                X             = 32,
                Y             = 16,
                Width         = 8,
                Height        = 8,
                Snap_Bottom   = true,
                Snap_Right    = true,
                Offset        = new Vector2(-8, -8),
                CustomPalette = 0
            };

            Entries[ID.Bar_BG] = new EntryGroup(new Entry
            {
                X             = 16,
                Y             = 24,
                Width         = 8,
                Height        = 8,
                Tile          = Vector2.UnitX,
                Fill          = Vector2.UnitY,
                CustomPalette = 2, // 2 in 2019, was set to 0 for 2013
            });
            Entries[ID.Bar_Fill] = new EntryGroup(new Entry
            {
                X      = 0,
                Y      = 16,
                Width  = 8,
                Height = 8,
                Tile   = Vector2.UnitX,
                Fill   = Vector2.UnitY,
                //Offset = new Vector2(2, 2),
                //End = new Vector2(-2, 0),
                CustomPalette = 5
            });
            Entries[ID.MenuBorder]  = new EntryGroup(Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
            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        = new Vector2(256, 0), //offset should be 256 but i had issue with 1 pixel gap should be able to get away with losing one pixel.
                Width         = 112,
                Height        = 16,
                CustomPalette = 1,
                Fill          = Vector2.UnitX,
                Tile          = Vector2.UnitY
            }, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);

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

            //2 pages
            GeneratePages(ID.COMMAND, ID.COMMAND_PG1, 4, 4);
            //4 pages
            GeneratePages(ID.ABILITY, ID.ABILITY_PG1, 4, 8);
            //4 pages for 16 gfs
            GeneratePages(ID.GF, ID.GF_PG1, 4, 8);
            //13 pages for 50 spells
            GeneratePages(ID.MAGIC, ID.MAGIC_PG1, 13, 8);

            //18 pages for 198 Items
            //50 pages if squashed to 4 items per page.
            GeneratePages(ID.ITEM, ID.ITEM_PG1, 50, -4);
            //16 spells 4 pages for blue magic
            GeneratePages(ID.SPECIAL, ID.SPECIAL_PG1, 4, 8);

            //revese order of rewind so arrows draw correctly
            if (Entries.ContainsKey(ID.Rewind_Fast))
            {
                Entry _RR_0 = Entries[ID.Rewind_Fast][0].Clone();
                Entry _RR_1 = Entries[ID.Rewind_Fast][1].Clone();

                Entries[ID.Rewind_Fast] = new EntryGroup(_RR_1, _RR_0);
            }

            //override this entry to make it tile instead of have set number of elements.
            if (Entries.ContainsKey(ID.Size_08x64_Bar))
            {
                EntryGroup b      = Entries[ID.Size_08x64_Bar];
                Entry      Left   = b[0].Clone();
                Entry      Center = b[1].Clone();
                Entry      Right  = b[7].Clone();
                Left.Offset                = Vector2.Zero;
                Center.Offset              = Vector2.Zero;
                Right.Offset               = new Vector2(-8f, 0);
                Center.Tile                = Vector2.UnitX;
                Right.Snap_Right           = true;
                Entries[ID.Size_08x64_Bar] = new EntryGroup(Center, Left, Right);
                ID tmp = ID.D_Pad_Up;
                Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
                tmp          = ID.D_Pad_Down;
                Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
                tmp          = ID.D_Pad_Left;
                Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
                tmp          = ID.D_Pad_Right;
                Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
            }
        }
Пример #6
0
        protected override void Init()
        {
            Texture2D pixel = new Texture2D(Memory.graphics.GraphicsDevice, 1, 1);

            pixel.SetData(new Color[] { Color.White });

            Memory.Icons[Icons.ID.Text_Cursor][0].Offset = Vector2.Zero;
            Memory.Icons.Trim(Icons.ID.Text_Cursor, 6);
            EntryGroup split = Memory.Icons[Icons.ID.Text_Cursor];
            EntryGroup e     = Memory.Icons[Icons.ID.Text_Cursor];

            Rectangle r = CONTAINER.Pos; //new Rectangle(40, 524, 880, 84);

            r.Inflate(-16, -20);
            r.X       += r.X % 4;
            r.Y       += r.Y % 4;
            r.Width   += r.Width % 4;
            r.Height  += r.Height % 4;
            rc         = Memory.Icons.MostSaturated(Icons.ID.Text_Cursor, 6);
            rcdim      = Memory.Icons.MostSaturated(Icons.ID.Text_Cursor, 2);
            ITEM[0, 0] = new IGMDataItem.Texture(pixel, r, rcdim);
            r.Inflate(-4, -4);
            ITEM[1, 0] = new IGMDataItem.Texture(pixel, r, Color.Black);
            float scale = (float)r.Height / e.Height;
            int   w     = (int)(e.Width * scale);

            ITEM[Count - 3, 0] = new IGMDataItem.Icon(Icons.ID.Text_Cursor, new Rectangle(r.X + 80, r.Y, w, r.Height), 2, scale: new Vector2(scale));
            ITEM[Count - 2, 0] = new IGMDataItem.Icon(Icons.ID.Text_Cursor, new Rectangle(r.X + 208, r.Y, w, r.Height), 2, scale: new Vector2(scale));
            Rectangle hotspot = new Rectangle(r.X + 80 + (w / 2), r.Y + 4, 208 - 80, r.Height - 8);

            ITEM[Count - 4, 0] = new IGMDataItem.Texture(pixel, hotspot, Color.TransparentBlack);
            //Rectangle hotspotbox = hotspot;
            hotspot.Width += (int)(hotspot.Width * .50f);
            Rectangle tr = new Rectangle(r.X + 208 + (w / 2), r.Y + 4, 0, r.Height - 4);

            Memory.Icons[Icons.ID.Trigger_][0].Offset = Vector2.Zero;
            Memory.Icons.Trim(Icons.ID.Trigger_, 2);
            e     = Memory.Icons[Icons.ID.Trigger_];
            scale = ((float)r.Height - 8) / e.Height;
            w     = (int)(e.Width * scale);
            int trigwidtharea = (r.Right - tr.Left);
            int xbak          = tr.X;

            tr.X += trigwidtharea / 2 - w / 2;

            ITEM[Count - 1, 0] = new IGMDataItem.Icon(Icons.ID.Trigger_, tr, 6, scale: new Vector2(scale));// { Color = rc};

            newattack = new Color(104, 80, 255);
            int       delay = 500;
            const int Time  = 2000;
            Rectangle pos   = new Rectangle(r.X, r.Y + 4, 0, r.Height - 8);

            r.Inflate(-4, -4);
            for (int x = 0; x <= _hits && x <= 7; x++)
            {
                ITEM[2 + x, 0] = new IGMDataItem.Gradient.Renzokeken(pos, newattack, rc, 1f, hotspot, r, time: Time, delay * (x));
            }
            float totalx = 0;

            for (byte i = 0; i <= 7; i++)
            {
                Memory.Icons.Trim(Icons.ID._0_Hit_ + i, 2);
                e       = Memory.Icons[Icons.ID._0_Hit_ + i];
                totalx += e[0].Offset.X;
            }
            float avgx = (float)Math.Round(totalx / 8);

            for (byte i = 0; i <= 7; i++)
            {
                Memory.Icons[Icons.ID._0_Hit_ + i][0].Offset.X = avgx;
            }
            e     = Memory.Icons[Icons.ID._0_Hit_];
            scale = ((float)r.Height) / e.Height;
            w     = (int)(e.Width * scale);
            tr.X  = xbak + trigwidtharea / 2 - w / 2;
            ITEM[Count - 5, 0] = new IGMDataItem.Icon(Icons.ID._0_Hit_, tr, 2, scale: new Vector2(scale));
            Memory.Icons.Trim(Icons.ID.Perfect__, 2);
            e     = Memory.Icons[Icons.ID.Perfect__];
            scale = ((float)r.Height) / e.Height;
            w     = (int)(e.Width * scale);
            tr.X  = xbak + trigwidtharea / 2 - w / 2;
            ITEM[Count - 6, 0] = new IGMDataItem.Icon(Icons.ID.Perfect__, tr, 8, scale: new Vector2(scale));
            base.Init();
            Reset();
            Cursor_Status = Cursor_Status.Enabled | Cursor_Status.Static | Cursor_Status.Hidden;
        }
Пример #7
0
        public new void Trim(Enum ic, byte pal)
        {
            EntryGroup eg = this[(ID)ic];

            eg.Trim(Textures[pal]);
        }
Пример #8
0
        public Color MostSaturated(Enum ic, byte pal)
        {
            EntryGroup eg = this[(ID)ic];

            return(eg.MostSaturated(Textures[pal], pal));
        }