Skip to content

Commit

Permalink
reset cam position on changing stages
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed May 14, 2024
1 parent bb9e291 commit 8f4c263
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
8 changes: 6 additions & 2 deletions source/funkin/Controls.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Controls
gamepad = FlxG.gamepads.lastActive;
}

@:unreflective
static function initSave():Void {
var save:Dynamic = SaveData.getSave("controls");
var keyboardSave:Map<String, Array<Dynamic>> = save.get("keyboardBinds");
Expand Down Expand Up @@ -55,6 +56,7 @@ class Controls
}
}

@:unreflective
public static function setupBindings():Void {
controlArray = new Array<String>();
initGamepad();
Expand Down Expand Up @@ -116,9 +118,9 @@ class Controls
//@:deprecated("Use getKey with the inputType argument instead")
public static function getKeyOld(key:String):Bool {
key = key.toUpperCase();
var parts:Array<String> = key.split('-');
var parts:Array<String> = key.split('-');

return getKey(parts[0], switch (parts[1]) {
return getKey(parts[0], switch (parts[1] ?? "") {
case "R": JUST_RELEASED;
case "P": JUST_PRESSED;
default: PRESSED;
Expand Down Expand Up @@ -167,6 +169,7 @@ class Controls
public static var headers:Array<String> = [];
public static var headerContents:Map<String, Array<String>> = [];

@:unreflective
static function addHeader(name:String) {
if (name != curHeader) {
curHeader = name;
Expand All @@ -175,6 +178,7 @@ class Controls
}
}

@:unreflective
private static function addBind(bind:String, keys:Array<FlxKey>, gamepadKeys:Array<FlxGamepadInputID>):Void {
bind = bind.toUpperCase().trim();
controlArray.push(bind);
Expand Down
4 changes: 4 additions & 0 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Preferences
];
#end

@:unreflective
public static function setupPrefs():Void {
prefsArray = [];
preferences = SaveData.getSave('preferences');
Expand Down Expand Up @@ -79,6 +80,7 @@ class Preferences
public static var headers:Array<String> = [];
public static var headerContents:Map<String, Array<String>> = [];

@:unreflective
static function addHeader(name:String) {
if (name != curHeader) {
curHeader = name;
Expand All @@ -87,6 +89,7 @@ class Preferences
}
}

@:unreflective
public static function addPref(id:String, label:String, defaultValue:Dynamic):Void {
id = id.toLowerCase().trim();

Expand Down Expand Up @@ -126,6 +129,7 @@ class Preferences
updateGpuTextures();
}

@:unreflective
private static function fixOldPrefs() {
if (preferences.exists("ghost-tap")) {
if (preferences.get("deghost-tap")) {
Expand Down
7 changes: 4 additions & 3 deletions source/funkin/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,13 @@ class PlayState extends MusicBeatState
final nextSong:String = PlayState.storyPlaylist[0];
trace('LOADING NEXT SONG [$nextSong-$curDifficulty]');

prevCamFollow = camFollow;
seenCutscene = false;

PlayState.SONG = Song.loadFromFile(curDifficulty, nextSong);
Conductor.stop();

// Reset cam follow if the stage changed
prevCamFollow = (SONG.stage == curStage) ? camFollow : null;
seenCutscene = false;

clearCache = true;
clearCacheData = {tempCache: false, skins: false}
ModdingUtil.addCall('switchSong', [nextSong, curDifficulty]); // Could be used to change cache clear
Expand Down
15 changes: 9 additions & 6 deletions source/funkin/states/menus/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package funkin.states.menus;
import flixel.effects.FlxFlicker;
import lime.app.Application;

class MainMenuState extends MusicBeatState {
class MainMenuState extends MusicBeatState
{
var magenta:FunkinSprite;
var versionText:FlxText;
var camFollow:FlxObject;

var optionShit:Array<String> = [
Expand All @@ -12,6 +14,7 @@ class MainMenuState extends MusicBeatState {
'options',
'donate'
];

var curSelected:Int = 0;
var menuItems:TypedGroup<FunkinSprite>;

Expand Down Expand Up @@ -61,12 +64,12 @@ class MainMenuState extends MusicBeatState {

FlxG.camera.follow(camFollow, null, 0.06);

var versionText:String = 'Mau Engin v${Main.engineVersion}\nFriday Night Funkin v${Application.current.meta.get('version')}';
var txt:String = 'Mau Engin v${Main.engineVersion}\nFriday Night Funkin v${Application.current.meta.get('version')}';

var versionShit:FlxText = new FlxText(5, FlxG.height - 18*2, 0, versionText, 12);
versionShit.scrollFactor.set();
versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
add(versionShit);
versionText = new FlxText(5, FlxG.height - 18*2, 0, txt, 12);
versionText.scrollFactor.set();
versionText.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
add(versionText);

changeItem();

Expand Down

0 comments on commit 8f4c263

Please sign in to comment.