Initial commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace WacK.Scenes
|
||||
{
|
||||
public partial class DebugChartLoader : Node
|
||||
{
|
||||
[Export]
|
||||
private LineEdit inputField;
|
||||
|
||||
[Export]
|
||||
private LineEdit soundField;
|
||||
|
||||
[Export]
|
||||
private OptionButton difficultyButton;
|
||||
|
||||
[Export]
|
||||
private Button playButton;
|
||||
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
playButton.Pressed += PlayClicked;
|
||||
}
|
||||
|
||||
private void PlayClicked()
|
||||
{
|
||||
// TODO: globally accessible verify song folder and chart/audio function
|
||||
var songPath = $"user://songs/{inputField.Text}";
|
||||
var chartPath = $"{songPath}/{difficultyButton.Selected}.mer";
|
||||
var soundPath = $"{songPath}/{soundField.Text}";
|
||||
GD.Print($"Song: {songPath}\nChart: {chartPath}\nSound: {soundPath}");
|
||||
|
||||
// folder check
|
||||
using var dir = DirAccess.Open(songPath);
|
||||
if (dir == null)
|
||||
{
|
||||
GD.PrintErr($"Error occurred opening song folder!\n{DirAccess.GetOpenError()}");
|
||||
return;
|
||||
}
|
||||
|
||||
// chart check
|
||||
using var chartFile = FileAccess.Open(chartPath, FileAccess.ModeFlags.Read);
|
||||
if (chartFile == null)
|
||||
{
|
||||
GD.PrintErr($"Error occurred opening chart!\n{FileAccess.GetOpenError()}");
|
||||
return;
|
||||
}
|
||||
|
||||
// sound check
|
||||
using var soundFile = FileAccess.Open(soundPath, FileAccess.ModeFlags.Read);
|
||||
if (soundFile == null)
|
||||
{
|
||||
GD.PrintErr($"Error occurred opening sound!\n{FileAccess.GetOpenError()}");
|
||||
return;
|
||||
}
|
||||
|
||||
Play.playParams = new PlayParameters(chartPath, soundPath);
|
||||
GetTree().ChangeSceneToFile("res://Scenes/Play.tscn");
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
playButton.Pressed -= PlayClicked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Godot;
|
||||
|
||||
namespace WacK.Scenes
|
||||
{
|
||||
public class PlayParameters
|
||||
{
|
||||
/* TODO: store song ID from internal database
|
||||
public string songID;
|
||||
public Difficulty diff;
|
||||
*/
|
||||
public string chartPath;
|
||||
public string soundPath;
|
||||
|
||||
public PlayParameters(string chPath, string snPath)
|
||||
{
|
||||
chartPath = chPath;
|
||||
soundPath = snPath;
|
||||
}
|
||||
}
|
||||
public partial class Play : Node
|
||||
{
|
||||
// initialized by another scene, BEFORE loading this one!
|
||||
public static PlayParameters playParams;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
playParams = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace WacK.Scenes
|
||||
{
|
||||
public partial class Startup : Node
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
GD.Print($"User directory: {OS.GetUserDataDir()}");
|
||||
using var songDir = DirAccess.Open("user://songs");
|
||||
if (songDir != null)
|
||||
{
|
||||
GD.Print("Successfully opened songs directory!");
|
||||
// load songs
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Could not find songs directory! Creating it...");
|
||||
|
||||
DirAccess.MakeDirAbsolute("user://songs");
|
||||
using var newSongDir = DirAccess.Open("user://songs");
|
||||
|
||||
if (newSongDir != null)
|
||||
{
|
||||
GD.Print("Songs folder created successfully!");
|
||||
// create note
|
||||
var note = "Place song folders here. Nested folders supported for organization.\n";
|
||||
using var f = FileAccess.Open($"{newSongDir.GetCurrentDir()}/note.txt", FileAccess.ModeFlags.Write);
|
||||
f.StoreString(note);
|
||||
|
||||
// TODO: add in-game notice
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.PrintErr($"Could not create the songs directory!\n{DirAccess.GetOpenError()}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Change scenes
|
||||
GetTree().ChangeSceneToFile("res://Scenes/DebugChartLoader.tscn");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user