Skip to content

Commit

Permalink
Merge branch 'ThatRozebudDude:master' into haxeui
Browse files Browse the repository at this point in the history
  • Loading branch information
soushimiya authored Feb 1, 2025
2 parents fe4b6d3 + 17d76d6 commit 8b2b5e1
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 47 deletions.
6 changes: 3 additions & 3 deletions hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
{
"name": "flixel",
"type": "haxelib",
"version": null
"version": "5.9.0"
},
{
"name": "flixel-addons",
"type": "haxelib",
"version": null
"version": "3.3.0"
},
{
"name": "flixel-ui",
"type": "haxelib",
"version": null
"version": "2.6.3"
},
{
"name": "flxanimate",
Expand Down
38 changes: 25 additions & 13 deletions source/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ class Conductor
public static var lastSongPos:Float;
public static var offset:Float = 0;

//public static var safeFrames:Float = 8;

public static var safeZoneOffset:Float = 160; // is calculated in create(), is safeFrames in milliseconds

public static var goodZone:Float = 45;
public static var badZone:Float = 90;
//Reference variables
static inline final defaultSafeZoneOffset:Float = 160;
static inline final defaultShitZone:Float = 135;
static inline final defaultBadZone:Float = 90;
static inline final defaultGoodZone:Float = 45;

//Actual timing variables
public static var safeZoneOffset:Float = 160;
public static var shitZone:Float = 135;
public static var badZone:Float = 90;
public static var goodZone:Float = 45;

public static var bpmChangeMap:Array<BPMChangeEvent> = [];

public function new(){
}
public function new(){}

public static function mapBPMChanges(song:SwagSong)
{
public static function mapBPMChanges(song:SwagSong){
bpmChangeMap = [];

var curBPM:Float = song.bpm;
Expand All @@ -58,14 +60,24 @@ class Conductor
trace("new BPM map BUDDY " + bpmChangeMap);
}

public static function changeBPM(newBpm:Float)
{
public static function changeBPM(newBpm:Float){
bpm = newBpm;

crochet = ((60 / bpm) * 1000);
stepCrochet = crochet / 4;
}

/**
* Returns the time in seconds that a beat will last for at the specified BPM.
*
* @param `_factor` The multiplier to apply to the hit zone timings.
*/
public static function recalculateHitZones(_factor:Float):Void{
safeZoneOffset = defaultSafeZoneOffset * _factor;
shitZone = defaultShitZone * _factor;
badZone = defaultBadZone * _factor;
goodZone = defaultGoodZone * _factor;
}

/**
* Returns the time in seconds that a beat will last for at the specified BPM.
*
Expand Down
1 change: 1 addition & 0 deletions source/GameOverSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GameOverSubstate extends MusicBeatSubstate

camGameOver = new FlxCamera();
camGameOver.zoom = camZoom;
camGameOver.filters = [];
FlxG.cameras.add(camGameOver, false);
cameras = [camGameOver];

Expand Down
1 change: 1 addition & 0 deletions source/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PauseSubState extends MusicBeatSubstate

camPause = new FlxCamera();
camPause.bgColor.alpha = 0;
camPause.filters = [];
FlxG.cameras.add(camPause, false);
cameras = [camPause];

Expand Down
50 changes: 33 additions & 17 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class PlayState extends MusicBeatState
public var vocalsOther:FlxSound;
public var vocalType:VocalType = combinedVocalTrack;
public var canChangeVocalVolume:Bool = true;
public var songPlaybackSpeed(default, set):Float = 1;

public var dad:Character;
public var gf:Character;
Expand Down Expand Up @@ -378,14 +379,16 @@ class PlayState extends MusicBeatState
canHit = !(Config.ghostTapType > 0);

camGame = new FlxCamera();
camGame.filters = [];

camOverlay = new FlxCamera();
camOverlay.bgColor.alpha = 0;
camOverlay.filters = [];

camHUD = new FlxCamera();
camHUD.bgColor.alpha = 0;
camHUD.filters = [new ShaderFilter(hudShader.shader)];

camOverlay = new FlxCamera();
camOverlay.bgColor.alpha = 0;

FlxG.cameras.reset(camGame);
FlxG.cameras.add(camOverlay, false);
FlxG.cameras.add(camHUD, false);
Expand All @@ -399,6 +402,7 @@ class PlayState extends MusicBeatState

Conductor.changeBPM(SONG.bpm);
Conductor.mapBPMChanges(SONG);
Conductor.recalculateHitZones(songPlaybackSpeed);

gfCheck = "Gf";

Expand Down Expand Up @@ -1486,6 +1490,8 @@ class PlayState extends MusicBeatState

if (Binds.justPressed("polymodReload") && !isStoryMode){
FlxG.sound.music.pause();
vocals.pause();
if(vocalType == splitVocalTrack){ vocalsOther.pause(); }
PolymodHandler.reload();
}

Expand Down Expand Up @@ -1546,27 +1552,28 @@ class PlayState extends MusicBeatState
switchState(new AnimationDebug(SONG.player2));
}
}


if (startingSong)
{
if (startedCountdown)
{
FlxG.sound.music.pitch = songPlaybackSpeed;
vocals.pitch = songPlaybackSpeed;
if(vocalType == splitVocalTrack){ vocalsOther.pitch = songPlaybackSpeed; }

if (startingSong){
if (startedCountdown){
Conductor.songPosition += FlxG.elapsed * 1000;
if (Conductor.songPosition >= 0)
if (Conductor.songPosition >= 0){
startSong();
}
}
}
/*else if(inEndingCutscene){
}*/
else{
if(previousReportedSongTime != FlxG.sound.music.time){
Conductor.songPosition = FlxG.sound.music.time;
//Failsafe to make sure that the onComplete actually runs because sometimes it would just not run sometimes when I was doing stuff with the song playback speed.
if(inRange(previousReportedSongTime, FlxG.sound.music.length, 1000) && !inRange(Conductor.songPosition, FlxG.sound.music.length, 1000) && !songEnded){ FlxG.sound.music.onComplete(); }
previousReportedSongTime = FlxG.sound.music.time;
}
else{
Conductor.songPosition += FlxG.elapsed * 1000;
Conductor.songPosition += FlxG.elapsed * 1000 * songPlaybackSpeed;
}
}

Expand Down Expand Up @@ -2378,15 +2385,14 @@ class PlayState extends MusicBeatState
}
}

override function stepHit()
{
override function stepHit(){

if((Math.abs(FlxG.sound.music.time - (Conductor.songPosition)) > 20 || (vocalType != noVocalTrack && Math.abs(vocals.time - (Conductor.songPosition)) > 20)) && FlxG.sound.music.playing){
if((Math.abs(FlxG.sound.music.time - (Conductor.songPosition)) > (20 * songPlaybackSpeed) || (vocalType != noVocalTrack && Math.abs(vocals.time - (Conductor.songPosition)) > (20 * songPlaybackSpeed))) && FlxG.sound.music.playing){
resyncVocals();
}

if(vocalType == splitVocalTrack){
if((Math.abs(vocalsOther.time - (Conductor.songPosition)) > 20) && FlxG.sound.music.playing){
if((Math.abs(vocalsOther.time - (Conductor.songPosition)) > (20 * songPlaybackSpeed)) && FlxG.sound.music.playing){
resyncVocals();
}
}
Expand Down Expand Up @@ -2899,6 +2905,16 @@ class PlayState extends MusicBeatState
for(script in scripts){ script.exit(); }
}

/*
* This is done because changing the playback speed causes the song time to update slower essentially
* causing the hit window to change with the playback speed. This mitigates that.
*/
private function set_songPlaybackSpeed(value:Float):Float{
songPlaybackSpeed = value;
Conductor.recalculateHitZones(value);
return value;
}

}

enum abstract VocalType(Int) {
Expand Down
14 changes: 2 additions & 12 deletions source/VideoHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package;
import flixel.util.FlxSignal;
import flixel.FlxSprite;
import flixel.FlxG;
import openfl.Assets;
import flixel.util.FlxColor;

#if desktop
Expand Down Expand Up @@ -103,7 +104,7 @@ class VideoHandler extends FlxSprite
bitmap.onEndReached.add(onVLCComplete);

FlxG.addChildBelowMouse(bitmap);
bitmap.play(checkFile(path), repeat);
bitmap.play(Assets.getPath(path), repeat);
bitmap.alpha = 0;

if (FlxG.autoPause) {
Expand All @@ -114,17 +115,6 @@ class VideoHandler extends FlxSprite
waitingStart = true;
}

function checkFile(fileName:String):String{
var pDir = "";
var appDir = "file:///" + Sys.getCwd() + "/";
if (fileName.indexOf(":") == -1) // Not a path
pDir = appDir;
else if (fileName.indexOf("file://") == -1 || fileName.indexOf("http") == -1) // C:, D: etc? ..missing "file:///" ?
pDir = "file:///";

return pDir + fileName;
}

function onVLCVideoReady(){
trace("video loaded!");
}
Expand Down
1 change: 1 addition & 0 deletions source/freeplay/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class FreeplayState extends MusicBeatState
}

camMenu = new FlxCamera();
camMenu.filters = [];

camFreeplay = new FlxCamera();
camFreeplay.bgColor.alpha = 0;
Expand Down
7 changes: 5 additions & 2 deletions source/modding/PolymodHandler.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package modding;

import transition.CustomTransition;
import transition.data.InstantTransition;
import caching.*;
import openfl.Assets;
import haxe.Json;
Expand Down Expand Up @@ -33,8 +35,9 @@ class PolymodHandler
public static function reload(?restartState:Bool = true):Void{
reloadScripts();
//scriptableClassCheck();
ImageCache.keepCache = true;
if(restartState){ FlxG.resetState(); }
if(restartState){ //Using CustomTransition since the transition is what handles the cache stuff. This is what FlxUIStateExt uses in it's switchState function.
CustomTransition.transition(new InstantTransition(), Type.createInstance(Type.getClass(FlxG.state), []));
}
}

public static function reInit():Void{
Expand Down
5 changes: 5 additions & 0 deletions source/results/ResultsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,25 @@ class ResultsState extends FlxStateExt
persistentUpdate = persistentDraw = true;

camBg = new FlxCamera();
camBg.filters = [];

camScroll = new FlxCamera(-50, -50, 1280 + 100, 720 + 100);
camScroll.bgColor = FlxColor.TRANSPARENT;
camScroll.angle = -3.8;
camScroll.filters = [];

camCharacter = new FlxCamera();
camCharacter.bgColor = FlxColor.TRANSPARENT;
camCharacter.filters = [];

camTitle = new FlxCamera(-50, -50, 1280 + 100, 720 + 100);
camTitle.bgColor = FlxColor.TRANSPARENT;
camTitle.angle = -3.8;
camTitle.filters = [];

camUi = new FlxCamera();
camUi.bgColor = FlxColor.TRANSPARENT;
camUi.filters = [];

FlxG.cameras.add(camBg, false);
FlxG.cameras.add(camScroll, false);
Expand Down

0 comments on commit 8b2b5e1

Please sign in to comment.