| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using System;
- using System.IO;
- using System.Linq;
- using System.Text;
- namespace FF8
- {
- public static class Module_icon_test
- {
- #region Fields
- private static Mode currentMode;
- private static Icons.ID icon;
- private const int DefaultPallet = 2;
- private static int pallet = DefaultPallet;
- #endregion Fields
- #region Enums
- private enum Mode
- {
- Initialize,
- Draw,
- Wait
- }
- #endregion Enums
- #region Methods
- public static void Draw()
- {
- switch (currentMode)
- {
- case Mode.Initialize:
- break;
- case Mode.Wait:
- case Mode.Draw:
- DrawIcons();
- break;
- }
- }
- public static void Update()
- {
- if (Input.Button(Keys.Up))
- {
- if (pallet <= 0)
- pallet = (int)Memory.Icons.PalletCount - 1;
- else
- pallet--;
- currentMode = Mode.Draw;
- }
- if (Input.Button(Keys.Down))
- {
- if (pallet >= Memory.Icons.PalletCount - 1)
- pallet = 0;
- else
- pallet++;
- currentMode = Mode.Draw;
- }
- //if ((Input.Button(Keys.Up) || Input.Button(Keys.Down)) && Memory.Icons.GetEntry(icon) != null && (Memory.Icons.GetEntry(icon).GetLoc.count > 1))
- // icon -= (Memory.Icons.GetEntry(icon).GetLoc.count - 1);
- if (Input.Button(Keys.Right))
- {
- do
- {
- if (icon >= Enum.GetValues(typeof(Icons.ID)).Cast<Icons.ID>().Max())
- icon = 0;
- else
- icon++;
- }
- while (Memory.Icons.GetEntry(icon) == null);
- currentMode = Mode.Draw;
- }
- if (Input.Button(Keys.Left))
- {
- do
- {
- if (icon <= 0)
- icon = Enum.GetValues(typeof(Icons.ID)).Cast<Icons.ID>().Max();
- //else if (Memory.Icons.GetEntry(icon) != null && Memory.Icons.GetEntry(icon).GetLoc.count > 1)
- // icon -= Memory.Icons.GetEntry(icon).GetLoc.count;
- else
- icon--;
- }
- while (Memory.Icons.GetEntry(icon) == null);
- currentMode = Mode.Draw;
- }
- switch (currentMode)
- {
- case Mode.Initialize:
- //SaveStringToFile();
- currentMode++;
- break;
- case Mode.Draw:
- currentMode++;
- break;
- case Mode.Wait:
- Memory.SuppressDraw = true;
- break;
- }
- }
- private static void DrawIcons()
- {
- Memory.SpriteBatchStartAlpha(SamplerState.PointClamp);
- Memory.spriteBatch.GraphicsDevice.Clear(Color.Black);
- Memory.SpriteBatchEnd();
- Viewport vp = Memory.graphics.GraphicsDevice.Viewport;
- Vector2 scale = new Vector2(4f);
- Rectangle dst = new Rectangle()
- {
- Width = (int)(Memory.Icons.GetEntryGroup(icon).Width * scale.X),
- Height = (int)(Memory.Icons.GetEntryGroup(icon).Height * scale.Y)
- };
- if (icon == Icons.ID.Menu_BG_368)
- {
- dst.Width = vp.Width;
- dst.Height = vp.Height - 50;
- scale = Vector2.Zero;
- }
- else
- {
- dst.X = vp.Width / 2 - dst.Width / 2;
- dst.Y = vp.Height / 2 - dst.Height / 2;
- }
- Memory.SpriteBatchStartAlpha(SamplerState.PointClamp);
- Memory.Icons.Draw(icon, pallet, dst, scale);
- Memory.font.RenderBasicText(new FF8String($"{(icon).ToString().Replace('_', ' ')}\nid: {(ushort)icon}\n\npallet: {pallet}\n\nwidth: {Memory.Icons[icon].Width}\nheight: {Memory.Icons[icon].Height}"), (int)(vp.Width * 0.10f), (int)(vp.Height * 0.05f), 1f, 2f, 0, 1);
- Memory.SpriteBatchEnd();
- }
- static public void SaveStringToFile()
- {
- using (FileStream fs = File.Create("D:\\iconsdatadump.csv"))
- using (BinaryWriter bw = new BinaryWriter(fs))
- {
- bw.Write(Encoding.UTF8.GetBytes(ToString()));
- }
- }
- 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;
- }
- #endregion Methods
- }
- }
|