using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenVIII
{
public static partial class Module_main_menu_debug
{
#region Fields
private static Mitems s_mchoose;
private static TextureHandler start;
///
/// Strings for the main menu
///
private static Dictionary strMainLobby;
#endregion Fields
#region Enums
///
/// Identifiers and Ordering of main menu items
///
private enum Mitems
{
New,
Load,
Debug
}
#endregion Enums
#region Properties
///
/// Current choice on main menu
///
private static Mitems Mchoose
{
get => s_mchoose;
set
{
if (value > s_mchoose && value > (Mitems)Enum.GetValues(typeof(Mitems)).Cast().Max())
{
value = 0;
}
else if (value < s_mchoose && s_mchoose <= 0)
{
value = (Mitems)Enum.GetValues(typeof(Mitems)).Cast().Max();
}
s_mchoose = value;
}
}
#endregion Properties
#region Methods
///
/// Draw Main menu
///
private static void DrawMainLobby()
{
float item = 0;
//TextScale1 = new Vector2(2.545454545f, 3.0375f);// scaled in render function.
Vector2 textStart = new Vector2(0.45078125f, .65f)* vp_per;
Memory.SpriteBatchStartAlpha(tm: IGM_focus);
Rectangle dst = new Rectangle()
{
Location = new Point(0),
Size = vp_per.ToPoint()
};
start.Draw(dst, null, Color.White * fade);
foreach (Mitems i in (Mitems[])Enum.GetValues(typeof(Mitems)))
{
Item c = strMainLobby[i];
c.Loc = (Memory.font.RenderBasicText(c.Text,
(int)(textStart.X), (int)(textStart.Y + ((TextScale.Y + vpSpace) * item++)), TextScale.X, TextScale.Y, 0, Fade));
strMainLobby[i] = c;
}
Menu.DrawPointer(new Point((int)(textStart.X), (int)((((TextScale.Y + vpSpace) * (float)Mchoose)+textStart.Y+(6*TextScale.Y)))));
Memory.SpriteBatchEnd();
}
private static void InitMain()
{
strMainLobby = new Dictionary()
{
{ Mitems.New, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,105) } },
{ Mitems.Load, new Item{Text=Memory.Strings.Read(Strings.FileID.MNGRP, 1 ,106) } },
{ Mitems.Debug, new Item{Text=new FF8String("OpenVIII debug tools") } }
};
if (start == null)
{
start = new TextureHandler("start{0:00}", 2);
}
}
///
/// Update Main Lobby
///
/// true on change
private static bool UpdateMainLobby()
{
bool ret = false;
foreach (KeyValuePair entry in strMainLobby)
{
if (entry.Value.Loc.Contains(ml))
{
Mchoose = (Mitems)entry.Key;
ret = true;
if (Input.Button(Buttons.MouseWheelup) || Input.Button(Buttons.MouseWheeldown))
{
return ret;
}
break;
}
}
if (Input.Button(Buttons.Down))
{
Input.ResetInputLimit();
init_debugger_Audio.PlaySound(0);
Mchoose++;
ret = true;
}
if (Input.Button(Buttons.Up))
{
Input.ResetInputLimit();
init_debugger_Audio.PlaySound(0);
Mchoose--;
ret = true;
}
if (Input.Button(Buttons.Okay))
{
Input.ResetInputLimit();
switch (Mchoose)
{
case Mitems.New:
init_debugger_Audio.PlaySound(28);
State = MainMenuStates.NewGameChoosed;
break;
case Mitems.Load:
init_debugger_Audio.PlaySound(0);
State = MainMenuStates.LoadGameChooseSlot;
break;
case Mitems.Debug:
init_debugger_Audio.PlaySound(0);
Mchoose = 0;
Dchoose = 0;
State = MainMenuStates.DebugScreen;
Fade = 0.0f;
break;
}
ret = true;
}
return ret;
}
///
/// Waits for fade to end then triggers new game.
///
private static void UpdateNewGame()
{
if (Fade > 0.0f)
{
Fade -= Memory.gameTime.ElapsedGameTime.Milliseconds / 1000.0f / 2;
return;
}
/*reverse engineering notes:
*
* we should happen to reset wm2field values
* also the basic party of Squall is now set: SG_PARTY_FIELD1 = 0, and other members are 0xFF
*/
FieldPointer = 74; //RE: startup stage ID is hardcoded. Probably we would want to change it for modding
//the module changes to 1 now
Module_field_debug.ResetField();
Module_movie_test.Index = 30;
Module_movie_test.ReturnState = Memory.MODULE_FIELD_DEBUG;
Memory.module = Memory.MODULE_MOVIETEST;
State = MainMenuStates.MainLobby;
}
#endregion Methods
}
}