lil polish stuff!

This commit is contained in:
Cameron Taylor 2023-03-16 00:55:25 -04:00
parent 4a6b961046
commit 91724133d7
2 changed files with 33 additions and 14 deletions

View file

@ -797,6 +797,12 @@ class FreeplayState extends MusicBeatSubstate
caps.doJumpOut = true; caps.doJumpOut = true;
} }
if (Type.getClass(FlxG.state) == MainMenuState)
{
FlxG.state.persistentUpdate = true;
FlxG.state.persistentDraw = true;
}
new FlxTimer().start(longestTimer, (_) -> { new FlxTimer().start(longestTimer, (_) -> {
FlxTransitionableState.skipNextTransIn = true; FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true; FlxTransitionableState.skipNextTransOut = true;

View file

@ -88,8 +88,7 @@ class MainMenuState extends MusicBeatState
menuItems = new MenuTypedList<AtlasMenuItem>(); menuItems = new MenuTypedList<AtlasMenuItem>();
add(menuItems); add(menuItems);
menuItems.onChange.add(onMenuItemChange); menuItems.onChange.add(onMenuItemChange);
menuItems.onAcceptPress.add(function(_) menuItems.onAcceptPress.add(function(_) {
{
if (_.name == 'freeplay') if (_.name == 'freeplay')
{ {
magenta.visible = true; magenta.visible = true;
@ -102,8 +101,7 @@ class MainMenuState extends MusicBeatState
menuItems.enabled = true; // can move on intro menuItems.enabled = true; // can move on intro
createMenuItem('storymode', 'mainmenu/storymode', function() startExitState(new StoryMenuState())); createMenuItem('storymode', 'mainmenu/storymode', function() startExitState(new StoryMenuState()));
createMenuItem('freeplay', 'mainmenu/freeplay', function() createMenuItem('freeplay', 'mainmenu/freeplay', function() {
{
persistentDraw = true; persistentDraw = true;
persistentUpdate = false; persistentUpdate = false;
openSubState(new FreeplayState()); openSubState(new FreeplayState());
@ -114,8 +112,7 @@ class MainMenuState extends MusicBeatState
createMenuItem('donate', 'mainmenu/donate', selectDonate, hasPopupBlocker); createMenuItem('donate', 'mainmenu/donate', selectDonate, hasPopupBlocker);
#end #end
createMenuItem('options', 'mainmenu/options', function() createMenuItem('options', 'mainmenu/options', function() {
{
startExitState(new OptionsState()); startExitState(new OptionsState());
}); });
@ -129,8 +126,21 @@ class MainMenuState extends MusicBeatState
menuItem.y = top + spacing * i; menuItem.y = top + spacing * i;
} }
FlxG.cameras.reset(new SwagCamera()); resetCamStuff();
FlxG.camera.follow(camFollow, null, 0.06);
subStateClosed.add(_ -> {
resetCamStuff();
});
subStateOpened.add(sub -> {
if (Type.getClass(sub) == FreeplayState)
{
new FlxTimer().start(0.5, _ -> {
magenta.visible = false;
});
}
});
// FlxG.camera.setScrollBounds(bg.x, bg.x + bg.width, bg.y, bg.y + bg.height * 1.2); // FlxG.camera.setScrollBounds(bg.x, bg.x + bg.width, bg.y, bg.y + bg.height * 1.2);
super.create(); super.create();
@ -142,6 +152,12 @@ class MainMenuState extends MusicBeatState
// NG.core.calls.event.logEvent('swag').send(); // NG.core.calls.event.logEvent('swag').send();
} }
function resetCamStuff()
{
FlxG.cameras.reset(new SwagCamera());
FlxG.camera.follow(camFollow, null, 0.06);
}
function createMenuItem(name:String, atlas:String, callback:Void->Void, fireInstantly:Bool = false):Void function createMenuItem(name:String, atlas:String, callback:Void->Void, fireInstantly:Bool = false):Void
{ {
var item = new AtlasMenuItem(name, Paths.getSparrowAtlas(atlas), callback); var item = new AtlasMenuItem(name, Paths.getSparrowAtlas(atlas), callback);
@ -214,8 +230,7 @@ class MainMenuState extends MusicBeatState
var onPromptClose = checkLoginStatus; var onPromptClose = checkLoginStatus;
if (onClose != null) if (onClose != null)
{ {
onPromptClose = function() onPromptClose = function() {
{
checkLoginStatus(); checkLoginStatus();
onClose(); onClose();
} }
@ -235,8 +250,7 @@ class MainMenuState extends MusicBeatState
public function openPrompt(prompt:Prompt, onClose:Void->Void) public function openPrompt(prompt:Prompt, onClose:Void->Void)
{ {
menuItems.enabled = false; menuItems.enabled = false;
prompt.closeCallback = function() prompt.closeCallback = function() {
{
menuItems.enabled = true; menuItems.enabled = true;
if (onClose != null) onClose(); if (onClose != null) onClose();
} }
@ -248,8 +262,7 @@ class MainMenuState extends MusicBeatState
{ {
menuItems.enabled = false; // disable for exit menuItems.enabled = false; // disable for exit
var duration = 0.4; var duration = 0.4;
menuItems.forEach(function(item) menuItems.forEach(function(item) {
{
if (menuItems.selectedIndex != item.ID) if (menuItems.selectedIndex != item.ID)
{ {
FlxTween.tween(item, {alpha: 0}, duration, {ease: FlxEase.quadOut}); FlxTween.tween(item, {alpha: 0}, duration, {ease: FlxEase.quadOut});