Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Audio/midi/Song2.mid
Binary file not shown.
23 changes: 16 additions & 7 deletions Classes/MidiMaestro/MidiMaestro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public partial class MidiMaestro : Resource
{
private MidiFile _midiFile;

public static TempoMap TempoMap;
public static TimeSignature TimeSignature;

//The four note rows that we care about
private midiNoteInfo[] _upNotes;
private midiNoteInfo[] _downNotes;
Expand All @@ -28,18 +31,20 @@ public MidiMaestro(string filePath)

if (!FileAccess.FileExists(filePath))
{
GD.PrintErr("ERROR: Unable to load level Midi file: " + filePath);
GD.PushError("ERROR: Unable to load level Midi file: " + filePath);
}

_midiFile = MidiFile.Read(filePath);
TempoMap = _midiFile.GetTempoMap();
TimeSignature = TempoMap.GetTimeSignatureAtTime(new MidiTimeSpan());

//Strip out the notes from the midi file
foreach (var track in _midiFile.GetTrackChunks())
{
string trackName = track.Events.OfType<SequenceTrackNameEvent>().FirstOrDefault()?.Text;
midiNoteInfo[] noteEvents = track
.GetNotes()
.Select(note => new midiNoteInfo(note, _midiFile.GetTempoMap()))
.Select(note => new midiNoteInfo(note))
.ToArray();

switch (trackName)
Expand Down Expand Up @@ -77,19 +82,23 @@ public midiNoteInfo[] GetNotes(ArrowType arrowType)
public class midiNoteInfo
{
private readonly Melanchall.DryWetMidi.Interaction.Note _note;
private readonly TempoMap _tempoMap;

public midiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note, TempoMap tempoMap)
public midiNoteInfo(Melanchall.DryWetMidi.Interaction.Note note)
{
_note = note;
_tempoMap = tempoMap;
}

public long GetStartTimeBeat()
{
var beatsBar = _note.TimeAs<BarBeatTicksTimeSpan>(MidiMaestro.TempoMap);
return beatsBar.Bars * MidiMaestro.TimeSignature.Numerator + beatsBar.Beats;
}

public long GetStartTimeTicks() => _note.Time;

public float GetStartTimeSeconds() =>
_note.TimeAs<MetricTimeSpan>(_tempoMap).Milliseconds / 1000f
+ _note.TimeAs<MetricTimeSpan>(_tempoMap).Seconds;
_note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Milliseconds / 1000f
+ _note.TimeAs<MetricTimeSpan>(MidiMaestro.TempoMap).Seconds;

public long GetEndTime() => _note.EndTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://csx04jwaoo20u"]

[ext_resource type="Script" path="res://Globals/BgAudioPlayer.cs" id="1_w7def"]
[ext_resource type="Script" path="res://Globals/BgAudioPlayer/BgAudioPlayer.cs" id="1_w7def"]

[node name="BgAudioPlayer" type="AudioStreamPlayer"]
script = ExtResource("1_w7def")
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions Globals/Translations/translations.csv.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[remap]

importer="csv_translation"
type="Translation"
uid="uid://drjnsd6mqpxqh"

[deps]

files=["res://Globals/Translations/translations.en.translation", "res://Globals/Translations/translations.cn.translation"]

source_file="res://Globals/Translations/translations.csv"
dest_files=["res://Globals/Translations/translations.en.translation", "res://Globals/Translations/translations.cn.translation"]

[params]

compress=true
delimiter=0
17 changes: 0 additions & 17 deletions Globals/translations.csv.import

This file was deleted.

6 changes: 3 additions & 3 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ buses/default_bus_layout=""
StageProducer="*res://Globals/StageProducer.cs"
TimeKeeper="*res://Globals/TimeKeeper.cs"
Scribe="*res://Globals/Scribe.cs"
BgAudioPlayer="*res://Globals/BGAudioPlayer.tscn"
BgAudioPlayer="*res://Globals/BgAudioPlayer/BGAudioPlayer.tscn"

[display]

window/size/viewport_width=640
window/size/viewport_height=360
window/stretch/mode="viewport"
window/stretch/mode="canvas_items"
window/stretch/scale_mode="integer"

[dotnet]
Expand Down Expand Up @@ -191,7 +191,7 @@ QWERT_arrowRight={

[internationalization]

locale/translations=PackedStringArray("res://Globals/translations.cn.translation", "res://Globals/translations.en.translation")
locale/translations=PackedStringArray("res://Globals/Translations/translations.cn.translation", "res://Globals/Translations/translations.en.translation")

[rendering]

Expand Down
4 changes: 2 additions & 2 deletions scenes/BattleDirector/NotePlacementBar.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ script = ExtResource("1_456es")
notePlacementBar = NodePath("ProgressBar")
currentComboMultText = NodePath("TextEdit")
_particles = NodePath("ProgressBar/Rock")
_currentNote = NodePath("NoteQueueSprite/NextNote")
_nextNote = NodePath("NoteQueueSprite/CurrentNote")
_currentNote = NodePath("NoteQueueSprite/CurrentNote")
_nextNote = NodePath("NoteQueueSprite/NextNote")
fullBarParticles = NodePath("ProgressBar/CPUParticles2D")

[node name="ProgressBar" type="TextureProgressBar" parent="."]
Expand Down
Binary file modified scenes/BattleDirector/assets/bgupdate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions scenes/BattleDirector/notePoofParticles.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[gd_scene load_steps=5 format=3 uid="uid://k21psn7b5sxf"]

[ext_resource type="Texture2D" uid="uid://cdf3g3174du4r" path="res://Classes/Notes/assets/heal_note.png" id="1_hjrch"]

[sub_resource type="Curve" id="Curve_xix4e"]
_data = [Vector2(0, 1), 0.0, 1.4, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2

[sub_resource type="CurveTexture" id="CurveTexture_h7u0t"]
curve = SubResource("Curve_xix4e")

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_k0qar"]
lifetime_randomness = 0.25
particle_flag_disable_z = true
emission_shape = 2
emission_sphere_radius = 3.0
spread = 180.0
initial_velocity_min = 30.77
initial_velocity_max = 61.55
gravity = Vector3(0, 0, 0)
tangential_accel_min = -100.0
tangential_accel_max = 85.12
scale_curve = SubResource("CurveTexture_h7u0t")

[node name="NotePoof" type="GPUParticles2D"]
emitting = false
amount = 10
process_material = SubResource("ParticleProcessMaterial_k0qar")
texture = ExtResource("1_hjrch")
lifetime = 0.75
one_shot = true
preprocess = 0.1
explosiveness = 1.0
7 changes: 2 additions & 5 deletions scenes/BattleDirector/scripts/Conductor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public bool AddNoteToLane(ArrowType type, int beat, Note note, bool isActive = t
else
{
arrow = CM.AddArrowToLane(type, beat, newNote, new Color(1, 0.43f, 0.26f));
NoteQueueParticlesFactory.NoteParticles(arrow, note.Texture, .5f);
}

if (!isActive)
Expand Down Expand Up @@ -87,11 +88,7 @@ private void AddExampleNotes()
{
foreach (midiNoteInfo mNote in MM.GetNotes(type))
{
AddNoteToLane(
type,
(int)(mNote.GetStartTimeSeconds() / (60 / (double)TimeKeeper.Bpm)),
Scribe.NoteDictionary[0]
);
AddNoteToLane(type, (int)mNote.GetStartTimeBeat(), Scribe.NoteDictionary[0]);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions scenes/BattleDirector/scripts/NotePlacementBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class NotePlacementBar : Node
//Juice - https://www.youtube.com/watch?v=LGt-jjVf-ZU
private int _limiter;
private Vector2 _barInitPosition;
private float _randomStrength = 1f;
private float _baseShake = 1f;
private float _shakeFade = 10f;
private RandomNumberGenerator _rng = new();
private float _shakeStrength;
Expand All @@ -50,7 +50,7 @@ private void ProcessShake(double delta)
return;
if (_currentBarValue >= MaxValue)
{
_shakeStrength = _randomStrength;
_shakeStrength = _baseShake;
}
if (_shakeStrength > 0)
{
Expand Down Expand Up @@ -136,15 +136,19 @@ private void UpdateNoteQueue()
private Note GetNote(bool getNextNote = false)
{
Note result;
Sprite2D selectedNote;
if (!getNextNote)
{
selectedNote = _currentNote;
result = _currentNoteInstance;
_currentNoteInstance = null;
}
else
{
selectedNote = _nextNote;
result = _noteQueue.Dequeue();
}
NoteQueueParticlesFactory.NoteParticles(selectedNote, selectedNote.Texture);
ProgressQueue();
return result;
}
Expand All @@ -157,7 +161,6 @@ public void HitNote()
_currentBarValue = Math.Min(_currentBarValue + comboMult, MaxValue);
UpdateNotePlacementBar(_currentBarValue);
UpdateComboMultText();
//fullBarParticles.Emitting = CanPlaceNote();
}

// Missing a note resets combo
Expand Down
28 changes: 28 additions & 0 deletions scenes/BattleDirector/scripts/NoteQueueParticlesFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using Godot;

public static class NoteQueueParticlesFactory
{
private static PackedScene particlesScene = null;

public static GpuParticles2D NoteParticles(
Node parent,
Texture2D texture,
float amountModifier = 1
)
{
particlesScene ??= GD.Load<PackedScene>(
"res://scenes/BattleDirector/notePoofParticles.tscn"
);

GpuParticles2D particles = particlesScene.Instantiate<GpuParticles2D>();

parent.AddChild(particles);
particles.Amount = (int)(particles.Amount * amountModifier);
particles.Texture = texture;
particles.Emitting = true;
particles.Finished += () => particles.QueueFree();

return particles;
}
}
2 changes: 1 addition & 1 deletion scenes/BattleDirector/scripts/TextParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public partial class TextParticle : Label
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
Tween tween = GetTree().CreateTween();
Tween tween = CreateTween();
ZIndex = 2;
Position += Vector2.Left * (GD.Randf() * 40 - 20);
tween.SetTrans(Tween.TransitionType.Elastic);
Expand Down
17 changes: 4 additions & 13 deletions scenes/ChartViewport/scripts/ChartManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void PrepChart(SongData songData)
public void BeginTweens()
{
//This could be good as a function to call on something, to have many things animated to the beat.
var tween = GetTree().CreateTween();
var tween = CreateTween();
tween
.TweenMethod(
Callable.From((Vector2 scale) => TweenArrows(scale)),
Expand Down Expand Up @@ -110,14 +110,13 @@ private NoteArrow CreateNote(ArrowType arrow, Note note, int beat = 0, int loopO
{
var noteScene = ResourceLoader.Load<PackedScene>("res://scenes/NoteManager/note.tscn");
NoteArrow newArrow = noteScene.Instantiate<NoteArrow>();
newArrow.Bounds = (float)(
beat / TrueBeatsPerLoop * (ChartLength / 2) + loopOffset * (ChartLength / 2)
);
newArrow.Init(IH.Arrows[(int)arrow], beat, note);
newArrow.OutlineSprite.Modulate = IH.Arrows[(int)arrow].Color;

_arrowGroup.AddChild(newArrow);
newArrow.Bounds = (float)(
beat / TrueBeatsPerLoop * (ChartLength / 2) + loopOffset * (ChartLength / 2)
);
newArrow.Position += Vector2.Right * newArrow.Bounds * 10; //temporary fix for notes spawning and instantly calling loop from originating at 0,0
return newArrow;
}

Expand All @@ -129,12 +128,4 @@ public void ComboText(string text, ArrowType arrow, int currentCombo)
IH.FeedbackEffect(arrow, text);
newText.Text = text + $" {currentCombo}";
}

public override void _ExitTree()
{
foreach (var tween in GetTree().GetProcessedTweens())
{
tween.Stop();
}
}
}
33 changes: 22 additions & 11 deletions scenes/ChestScene/ChestScene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
[ext_resource type="Texture2D" uid="uid://d0ywqw1j1k71v" path="res://scenes/ChestScene/assets/Chest.png" id="6_58hf4"]
[ext_resource type="Texture2D" uid="uid://dbjotl0v1ymia" path="res://scenes/BattleDirector/assets/BattleFrame1.png" id="7_kkck7"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_4lvcv"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_8x17a"]
shader = ExtResource("5_whthd")
shader_parameter/bg_top_color = Vector4(0.18, 0.08, 0.12, 0)
shader_parameter/bg_bottom_color = Vector4(0.028, 0.008, 0.184, 0)
shader_parameter/gradient_ratio = 1.22
shader_parameter/gradient_ratio = 1.0
shader_parameter/time_scale = 1.0

[node name="ChestScene" type="Node2D" node_paths=PackedStringArray("ChestButton")]
Expand All @@ -33,15 +33,6 @@ offset_right = 640.0
offset_bottom = 178.0
texture = ExtResource("6_37nar")

[node name="StarShader" type="ColorRect" parent="."]
z_index = -1
material = SubResource("ShaderMaterial_4lvcv")
offset_top = 180.0
offset_right = 255.0
offset_bottom = 262.0
scale = Vector2(2.18, 2.18)
color = Color(0, 0, 0, 1)

[node name="BattleFrame" type="TextureRect" parent="."]
z_index = 1
offset_top = 178.0
Expand All @@ -55,3 +46,23 @@ offset_top = 126.0
offset_right = 431.0
offset_bottom = 166.0
icon = ExtResource("6_58hf4")

[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
z_index = -2
offset_top = 178.0
offset_right = 560.0
offset_bottom = 358.0

[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
handle_input_locally = false
size = Vector2i(560, 180)
render_target_update_mode = 4

[node name="StarShader" type="ColorRect" parent="SubViewportContainer/SubViewport"]
z_index = -1
material = SubResource("ShaderMaterial_8x17a")
offset_left = -60.0
offset_right = 415.0
offset_bottom = 177.0
scale = Vector2(2.18, 2.18)
color = Color(0, 0, 0, 1)
Loading