Icons.InsertCustomEntries.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using Microsoft.Xna.Framework;
  2. namespace OpenVIII
  3. {
  4. public sealed partial class Icons
  5. {
  6. #region Methods
  7. /// <summary>
  8. /// Add Manual hardcoded entries / settings here.
  9. /// </summary>
  10. /// <remarks>Maybe one day we can export these to an xml file and read it in on launch.</remarks>
  11. protected override void InsertCustomEntries()
  12. {
  13. if (Entries == null) return;
  14. var BG = new Entry
  15. {
  16. X = 0,
  17. Y = 48,
  18. Width = 256,
  19. Height = 16,
  20. CustomPalette = 1,
  21. Fill = Vector2.UnitX,
  22. Tile = Vector2.UnitY,
  23. };
  24. var Border_TopLeft = new Entry
  25. {
  26. X = 16,
  27. Y = 0,
  28. Width = 8,
  29. Height = 8,
  30. CustomPalette = 0,
  31. };
  32. var Border_Top = new Entry
  33. {
  34. X = 24,
  35. Y = 0,
  36. Width = 8,
  37. Height = 8,
  38. Tile = Vector2.UnitX,
  39. Offset = new Vector2(8, 0),
  40. End = new Vector2(-8, 0),
  41. CustomPalette = 0
  42. };
  43. var Border_Bottom = new Entry
  44. {
  45. X = 24,
  46. Y = 16,
  47. Width = 8,
  48. Height = 8,
  49. Tile = Vector2.UnitX,
  50. Snap_Bottom = true,
  51. Offset = new Vector2(8, -8),
  52. End = new Vector2(-8, 0),
  53. CustomPalette = 0
  54. };
  55. var Border_TopRight = new Entry
  56. {
  57. X = 32,
  58. Y = 0,
  59. Width = 8,
  60. Height = 8,
  61. Snap_Right = true,
  62. Offset = new Vector2(-8, 0),
  63. CustomPalette = 0
  64. };
  65. var Border_Left = new Entry
  66. {
  67. X = 16,
  68. Y = 8,
  69. Width = 8,
  70. Height = 8,
  71. Tile = Vector2.UnitY,
  72. Offset = new Vector2(0, 8),
  73. End = new Vector2(0, -8),
  74. CustomPalette = 0
  75. };
  76. var Border_Right = new Entry
  77. {
  78. X = 32,
  79. Y = 8,
  80. Width = 8,
  81. Height = 8,
  82. Tile = Vector2.UnitY,
  83. Snap_Right = true,
  84. Offset = new Vector2(-8, 8),
  85. End = new Vector2(0, -8),
  86. CustomPalette = 0
  87. };
  88. var Border_BottomLeft = new Entry
  89. {
  90. X = 16,
  91. Y = 16,
  92. Width = 8,
  93. Height = 8,
  94. Snap_Bottom = true,
  95. Offset = new Vector2(0, -8),
  96. CustomPalette = 0
  97. };
  98. var Border_BottomRight = new Entry
  99. {
  100. X = 32,
  101. Y = 16,
  102. Width = 8,
  103. Height = 8,
  104. Snap_Bottom = true,
  105. Snap_Right = true,
  106. Offset = new Vector2(-8, -8),
  107. CustomPalette = 0
  108. };
  109. Entries[ID.Bar_BG] = new EntryGroup(new Entry
  110. {
  111. X = 16,
  112. Y = 24,
  113. Width = 8,
  114. Height = 8,
  115. Tile = Vector2.UnitX,
  116. Fill = Vector2.UnitY,
  117. CustomPalette = 2, // 2 in 2019, was set to 0 for 2013
  118. });
  119. Entries[ID.Bar_Fill] = new EntryGroup(new Entry
  120. {
  121. X = 0,
  122. Y = 16,
  123. Width = 8,
  124. Height = 8,
  125. Tile = Vector2.UnitX,
  126. Fill = Vector2.UnitY,
  127. //Offset = new Vector2(2, 2),
  128. //End = new Vector2(-2, 0),
  129. CustomPalette = 5
  130. });
  131. Entries[ID.MenuBorder] = new EntryGroup(Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
  132. Entries[ID.Menu_BG_256] = new EntryGroup(BG, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
  133. Entries[ID.Menu_BG_368] = new EntryGroup(BG, new Entry
  134. {
  135. X = 0,
  136. Y = 64,
  137. 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.
  138. Width = 112,
  139. Height = 16,
  140. CustomPalette = 1,
  141. Fill = Vector2.UnitX,
  142. Tile = Vector2.UnitY
  143. }, Border_Top, Border_Left, Border_Right, Border_Bottom, Border_TopLeft, Border_TopRight, Border_BottomLeft, Border_BottomRight);
  144. Entries[ID.DEBUG] = new EntryGroup(
  145. new Entry { X = 128, Y = 24, Width = 7, Height = 8, Offset = new Vector2(4, 0) },
  146. new Entry { X = 65, Y = 8, Width = 6, Height = 8, Offset = new Vector2(7 + 4, 0) },
  147. new Entry { X = 147, Y = 24, Width = 6, Height = 8, Offset = new Vector2(13 + 4, 0) },
  148. new Entry { X = 141, Y = 24, Width = 6, Height = 8, Offset = new Vector2(19 + 4, 0) },
  149. new Entry { X = 104, Y = 16, Width = 6, Height = 8, Offset = new Vector2(25 + 4, 0) }
  150. );
  151. //2 pages
  152. GeneratePages(ID.COMMAND, ID.COMMAND_PG1, 4, 4);
  153. //4 pages
  154. GeneratePages(ID.ABILITY, ID.ABILITY_PG1, 4, 8);
  155. //4 pages for 16 gfs
  156. GeneratePages(ID.GF, ID.GF_PG1, 4, 8);
  157. //13 pages for 50 spells
  158. GeneratePages(ID.MAGIC, ID.MAGIC_PG1, 13, 8);
  159. //18 pages for 198 Items
  160. //50 pages if squashed to 4 items per page.
  161. GeneratePages(ID.ITEM, ID.ITEM_PG1, 50, -4);
  162. //16 spells 4 pages for blue magic
  163. GeneratePages(ID.SPECIAL, ID.SPECIAL_PG1, 4, 8);
  164. //revese order of rewind so arrows draw correctly
  165. if (Entries.ContainsKey(ID.Rewind_Fast))
  166. {
  167. var _RR_0 = Entries[ID.Rewind_Fast][0].Clone();
  168. var _RR_1 = Entries[ID.Rewind_Fast][1].Clone();
  169. Entries[ID.Rewind_Fast] = new EntryGroup(_RR_1, _RR_0);
  170. }
  171. //override this entry to make it tile instead of have set number of elements.
  172. if (Entries.ContainsKey(ID.Size_08x64_Bar))
  173. {
  174. var b = Entries[ID.Size_08x64_Bar];
  175. var Left = b[0].Clone();
  176. var Center = b[1].Clone();
  177. var Right = b[7].Clone();
  178. Left.Offset = Vector2.Zero;
  179. Center.Offset = Vector2.Zero;
  180. Right.Offset = new Vector2(-8f, 0);
  181. Center.Tile = Vector2.UnitX;
  182. Right.Snap_Right = true;
  183. Entries[ID.Size_08x64_Bar] = new EntryGroup(Center, Left, Right);
  184. var tmp = ID.D_Pad_Up;
  185. Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
  186. tmp = ID.D_Pad_Down;
  187. Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
  188. tmp = ID.D_Pad_Left;
  189. Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
  190. tmp = ID.D_Pad_Right;
  191. Entries[tmp] = new EntryGroup(Entries[tmp][0], Entries[tmp][2], Entries[tmp][1], Entries[tmp][3]);
  192. }
  193. }
  194. private void GeneratePages(ID label, ID label_pg1, byte count, sbyte offset)
  195. {
  196. if (!Entries.ContainsKey(label_pg1) && !Entries.ContainsKey(label) && !Entries.ContainsKey(ID.Size_08x08_P_))
  197. return;
  198. count = (byte)MathHelper.Clamp(count, 1, 99);
  199. var P_ = Entries[ID.Size_08x08_P_][0].Clone();
  200. P_.Offset.X += Entries[label][0].Width + offset;
  201. P_.CustomPalette = 2;
  202. var _ = new Entry[10];
  203. _[1] = Entries[ID.Num_8x8_1_1][0].Clone();
  204. _[1].Offset.X += P_.Offset.X + P_.Width + 2;
  205. _[1].CustomPalette = 7;
  206. for (byte i = 2; i <= 9 && i <= count; i++)
  207. {
  208. _[i] = Entries[ID.Num_8x8_1_1 + i - 1][0].Clone();
  209. _[i].Offset.X = _[1].Offset.X;
  210. _[i].CustomPalette = _[1].CustomPalette;
  211. }
  212. Entry[] __ = null;
  213. if (count > 9)
  214. {
  215. __ = new Entry[10];
  216. __[0] = Entries[ID.Num_8x8_1_0][0].Clone();
  217. __[0].Offset.X += P_.Offset.X + P_.Width + 2 + _[1].Width;
  218. __[0].CustomPalette = 7;
  219. for (byte i = 1; i <= 9; i++)
  220. {
  221. __[i] = _[i].Clone();
  222. __[i].Offset.X = __[0].Offset.X;
  223. }
  224. }
  225. for (byte i = 1; i <= count; i++)
  226. {
  227. if (i < 10)
  228. Entries[label_pg1 + i - 1] = new EntryGroup(Entries[label][0], P_, _[i]);
  229. else if (i >= 10 && __ != null)
  230. Entries[label_pg1 + i - 1] = new EntryGroup(Entries[label][0], P_, _[i / 10], __[i % 10]);
  231. }
  232. }
  233. #endregion Methods
  234. }
  235. }