Make splash screen load option actually load, and implement load screen (oops!)

Support AVI movies as well as .mp4
This commit is contained in:
ficedula 2023-03-13 12:15:20 +00:00
parent bcc8ec53fb
commit f522093085
4 changed files with 49 additions and 9 deletions

View File

@ -21,7 +21,7 @@ namespace Braver.Field {
private SpriteBatch _spriteBatch;
private GraphicsDevice _graphics;
public int Frame => _frame;
public int Frame => (int)(_frame * _gameFramesPerVideoFrame / 4); //adjust reported frame to reflect 15FPS as the original game expects
public bool Active => (_process != null) && (_frame >= 0);
public Ficedula.FF7.Field.CameraMatrix Camera => _cam.Camera.ElementAtOrDefault(Frame);
@ -41,6 +41,16 @@ namespace Braver.Field {
private Ficedula.FF7.Field.MovieCam _cam;
private static string[] _extensions = new[] { ".mp4", ".avi" };
private string ResolvePath(string name) {
foreach (string ext in _extensions) {
string fn = Path.Combine(_game.GetPath("Movies"), name + ext);
if (File.Exists(fn)) return fn;
}
return Path.Combine(_game.GetPath("Movies"), name + _extensions[0]); //...although it'll fail at runtime, but lets us continue running for now
}
public Movie(FGame g, GraphicsDevice graphics) {
_game = g;
_graphics = graphics;
@ -49,7 +59,7 @@ namespace Braver.Field {
_files = g.OpenString("movies", "movielist.txt")
.Split('\n')
.Select(s => s.Trim('\r'))
.Select(s => Path.Combine(g.GetPath("Movies"), s + ".mp4")) //TODO!!!
.Select(s => ResolvePath(s)) //TODO!!!
.ToArray();
}

View File

@ -25,6 +25,8 @@ namespace Braver.UI.Layout {
public override bool IsRazorModel => true;
public bool IsSaveMenu => ((bool?)_screen.Param).GetValueOrDefault(true);
public List<SaveEntry> Entries { get; } = new();
public List lbSaves;
@ -36,7 +38,16 @@ namespace Braver.UI.Layout {
string path = Path.Combine(g.GetPath("save"), $"save{slot}");
string sav = path + ".sav";
if (File.Exists(sav)) {
var saveData = Serialisation.Deserialise<SaveData>(File.ReadAllText(sav));
SaveData saveData;
using (var fs = File.OpenRead(path + ".sav")) {
if (Pack.IsPack(fs)) {
var pack = new Pack(fs);
using (var data = pack.Read("SaveData"))
saveData = Serialisation.Deserialise<SaveData>(data);
} else {
saveData = Serialisation.Deserialise<SaveData>(fs);
}
}
Entries.Add(new SaveEntry {
Location = saveData.Location,
Timestamp = File.GetLastWriteTime(sav),
@ -69,9 +80,17 @@ namespace Braver.UI.Layout {
public void SaveSelected(Box bSave) {
string path = bSave.ID;
_game.Save(path, !_game.DebugOptions.SeparateSaveFiles);
InputEnabled = false;
_screen.FadeOut(() => _game.PopScreen(_screen));
if (IsSaveMenu) {
_game.Save(path, !_game.DebugOptions.SeparateSaveFiles);
InputEnabled = false;
_screen.FadeOut(() => _game.PopScreen(_screen));
} else {
InputEnabled = false;
_screen.FadeOut(() => {
_game.PopScreen(_screen);
_game.Load(path);
});
}
}
}
}

View File

@ -45,6 +45,11 @@ namespace Braver.UI {
public override Color ClearColor => Color.Black;
public override void Reactivated() {
base.Reactivated();
InputEnabled = true;
}
public override void ProcessInput(InputState input) {
base.ProcessInput(input);
@ -88,13 +93,18 @@ namespace Braver.UI {
break;
case 1:
Game.Load(System.IO.Path.Combine(Game.GetPath("save"), "auto"));
string autoPath = System.IO.Path.Combine(Game.GetPath("save"), "auto");
if (System.IO.File.Exists(autoPath + ".sav"))
Game.Load(autoPath);
else
Game.Audio.PlaySfx(Sfx.Invalid, 1f, 0f);
break;
case 2:
Game.NewGame();
Game.PushScreen(new UI.Layout.LayoutScreen("SaveMenu", parm: false));
//Game.NewGame();
//Game.ChangeScreen(this, new TestScreen());
Game.ChangeScreen(this, new WorldMap.WMScreen(139348, 126329));
//Game.ChangeScreen(this, new WorldMap.WMScreen(139348, 126329));
//Battle.BattleScreen.Launch(Game, 324, Battle.BattleFlags.None);
break;

View File

@ -17,6 +17,7 @@ Console.WriteLine("Enter the FF7 movies folder in MP4 format (contains e.g. open
while (true) {
movies = Console.ReadLine().TrimEnd(Path.DirectorySeparatorChar);
if (File.Exists(Path.Combine(movies, "opening.mp4"))) break;
if (File.Exists(Path.Combine(movies, "opening.avi"))) break;
Console.WriteLine("That folder doesn't seem to contain FF7 movies in mp4 format - please enter another folder");
}