mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 16:17:53 -05:00
no flashing menu
This commit is contained in:
parent
b470cfc83a
commit
105c05f2e2
4 changed files with 109 additions and 57 deletions
|
@ -1,8 +1,6 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
import NGio;
|
import NGio;
|
||||||
|
|
||||||
import flixel.ui.FlxButton;
|
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
import flixel.FlxObject;
|
import flixel.FlxObject;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
|
@ -14,26 +12,26 @@ import flixel.group.FlxGroup.FlxTypedGroup;
|
||||||
import flixel.text.FlxText;
|
import flixel.text.FlxText;
|
||||||
import flixel.tweens.FlxEase;
|
import flixel.tweens.FlxEase;
|
||||||
import flixel.tweens.FlxTween;
|
import flixel.tweens.FlxTween;
|
||||||
|
import flixel.ui.FlxButton;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
import flixel.util.FlxTimer;
|
import flixel.util.FlxTimer;
|
||||||
import lime.app.Application;
|
import lime.app.Application;
|
||||||
|
import ui.AtlasMenuList;
|
||||||
|
import ui.MenuList;
|
||||||
|
import ui.OptionsState;
|
||||||
|
import ui.PreferencesMenu;
|
||||||
|
import ui.Prompt;
|
||||||
|
|
||||||
|
using StringTools;
|
||||||
|
|
||||||
#if desktop
|
#if desktop
|
||||||
import Discord.DiscordClient;
|
import Discord.DiscordClient;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if newgrounds
|
#if newgrounds
|
||||||
import io.newgrounds.NG;
|
import io.newgrounds.NG;
|
||||||
import ui.NgPrompt;
|
import ui.NgPrompt;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
import ui.AtlasMenuList;
|
|
||||||
import ui.MenuList;
|
|
||||||
import ui.OptionsState;
|
|
||||||
import ui.Prompt;
|
|
||||||
|
|
||||||
using StringTools;
|
|
||||||
|
|
||||||
class MainMenuState extends MusicBeatState
|
class MainMenuState extends MusicBeatState
|
||||||
{
|
{
|
||||||
var menuItems:MainMenuList;
|
var menuItems:MainMenuList;
|
||||||
|
@ -80,7 +78,8 @@ class MainMenuState extends MusicBeatState
|
||||||
magenta.visible = false;
|
magenta.visible = false;
|
||||||
magenta.antialiasing = true;
|
magenta.antialiasing = true;
|
||||||
magenta.color = 0xFFfd719b;
|
magenta.color = 0xFFfd719b;
|
||||||
add(magenta);
|
if (PreferencesMenu.preferences.get('flashing-menu'))
|
||||||
|
add(magenta);
|
||||||
// magenta.scrollFactor.set();
|
// magenta.scrollFactor.set();
|
||||||
|
|
||||||
menuItems = new MainMenuList();
|
menuItems = new MainMenuList();
|
||||||
|
@ -91,17 +90,15 @@ class MainMenuState extends MusicBeatState
|
||||||
FlxFlicker.flicker(magenta, 1.1, 0.15, false, true);
|
FlxFlicker.flicker(magenta, 1.1, 0.15, false, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
menuItems.enabled = false; // disable for intro
|
||||||
|
menuItems.createItem('story mode', function() startExitState(new StoryMenuState()));
|
||||||
menuItems.enabled = false;// disable for intro
|
menuItems.createItem('freeplay', function() startExitState(new FreeplayState()));
|
||||||
menuItems.createItem('story mode', function () startExitState(new StoryMenuState()));
|
|
||||||
menuItems.createItem('freeplay', function () startExitState(new FreeplayState()));
|
|
||||||
// addMenuItem('options', function () startExitState(new OptionMenu()));
|
// addMenuItem('options', function () startExitState(new OptionMenu()));
|
||||||
#if CAN_OPEN_LINKS
|
#if CAN_OPEN_LINKS
|
||||||
var hasPopupBlocker = #if web true #else false #end;
|
var hasPopupBlocker = #if web true #else false #end;
|
||||||
menuItems.createItem('donate', selectDonate, hasPopupBlocker);
|
menuItems.createItem('donate', selectDonate, hasPopupBlocker);
|
||||||
#end
|
#end
|
||||||
menuItems.createItem('options', function () startExitState(new OptionsState()));
|
menuItems.createItem('options', function() startExitState(new OptionsState()));
|
||||||
// #if newgrounds
|
// #if newgrounds
|
||||||
// if (NGio.isLoggedIn)
|
// if (NGio.isLoggedIn)
|
||||||
// menuItems.createItem("logout", selectLogout);
|
// menuItems.createItem("logout", selectLogout);
|
||||||
|
@ -186,7 +183,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();
|
||||||
|
@ -209,7 +206,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)
|
if (onClose != null)
|
||||||
|
@ -226,7 +223,7 @@ class MainMenuState extends MusicBeatState
|
||||||
{
|
{
|
||||||
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});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -255,11 +252,10 @@ private class MainMenuList extends MenuTypedList<MainMenuItem>
|
||||||
{
|
{
|
||||||
public var atlas:FlxAtlasFrames;
|
public var atlas:FlxAtlasFrames;
|
||||||
|
|
||||||
public function new ()
|
public function new()
|
||||||
{
|
{
|
||||||
atlas = Paths.getSparrowAtlas('main_menu');
|
atlas = Paths.getSparrowAtlas('main_menu');
|
||||||
super(Vertical);
|
super(Vertical);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createItem(x = 0.0, y = 0.0, name:String, callback, fireInstantly = false)
|
public function createItem(x = 0.0, y = 0.0, name:String, callback, fireInstantly = false)
|
||||||
|
@ -277,6 +273,7 @@ private class MainMenuList extends MenuTypedList<MainMenuItem>
|
||||||
atlas = null;
|
atlas = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MainMenuItem extends AtlasMenuItem
|
private class MainMenuItem extends AtlasMenuItem
|
||||||
{
|
{
|
||||||
public function new(x = 0.0, y = 0.0, name, atlas, callback)
|
public function new(x = 0.0, y = 0.0, name, atlas, callback)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import flixel.util.FlxTimer;
|
||||||
import lime.app.Application;
|
import lime.app.Application;
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
import shaderslmfao.ColorSwap;
|
import shaderslmfao.ColorSwap;
|
||||||
|
import ui.PreferencesMenu;
|
||||||
|
|
||||||
using StringTools;
|
using StringTools;
|
||||||
|
|
||||||
|
@ -59,6 +60,8 @@ class TitleState extends MusicBeatState
|
||||||
|
|
||||||
super.create();
|
super.create();
|
||||||
|
|
||||||
|
PreferencesMenu.initPrefs();
|
||||||
|
|
||||||
FlxG.save.bind('funkin', 'ninjamuffin99');
|
FlxG.save.bind('funkin', 'ninjamuffin99');
|
||||||
PlayerSettings.init();
|
PlayerSettings.init();
|
||||||
Highscore.load();
|
Highscore.load();
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package ui;
|
package ui;
|
||||||
|
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxSprite;
|
||||||
|
import flixel.group.FlxGroup;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
import ui.AtlasText.AtlasFont;
|
import ui.AtlasText.AtlasFont;
|
||||||
|
import ui.TextMenuList.TextMenuItem;
|
||||||
|
|
||||||
class PreferencesMenu extends ui.OptionsState.Page
|
class PreferencesMenu extends ui.OptionsState.Page
|
||||||
{
|
{
|
||||||
|
@ -9,6 +13,8 @@ class PreferencesMenu extends ui.OptionsState.Page
|
||||||
|
|
||||||
var items:TextMenuList;
|
var items:TextMenuList;
|
||||||
|
|
||||||
|
var checkboxes:Array<Dynamic> = [];
|
||||||
|
|
||||||
public function new()
|
public function new()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -16,6 +22,14 @@ class PreferencesMenu extends ui.OptionsState.Page
|
||||||
|
|
||||||
createPrefItem('naughtyness', 'censor-naughty', false);
|
createPrefItem('naughtyness', 'censor-naughty', false);
|
||||||
createPrefItem('downscroll', 'downscroll', false);
|
createPrefItem('downscroll', 'downscroll', false);
|
||||||
|
createPrefItem('flashing menu', 'flashing-menu', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function initPrefs():Void
|
||||||
|
{
|
||||||
|
preferenceCheck('censor-naughty', false);
|
||||||
|
preferenceCheck('downscroll', false);
|
||||||
|
preferenceCheck('flashing-menu', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createPrefItem(prefName:String, prefString:String, prefValue:Dynamic):Void
|
private function createPrefItem(prefName:String, prefString:String, prefValue:Dynamic):Void
|
||||||
|
@ -34,9 +48,24 @@ class PreferencesMenu extends ui.OptionsState.Page
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
switch (Type.typeof(prefValue).getName())
|
||||||
|
{
|
||||||
|
case 'TBool':
|
||||||
|
createCheckbox(prefString);
|
||||||
|
|
||||||
|
default:
|
||||||
|
trace('swag');
|
||||||
|
}
|
||||||
|
|
||||||
trace(Type.typeof(prefValue).getName());
|
trace(Type.typeof(prefValue).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCheckbox(prefString:String)
|
||||||
|
{
|
||||||
|
var checkbox:CheckboxThingie = new CheckboxThingie(0, 100 * items.length, preferences.get(prefString));
|
||||||
|
add(checkbox);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assumes that the preference has already been checked/set?
|
* Assumes that the preference has already been checked/set?
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +82,7 @@ class PreferencesMenu extends ui.OptionsState.Page
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function preferenceCheck(prefString:String, prefValue:Dynamic):Void
|
private static function preferenceCheck(prefString:String, prefValue:Dynamic):Void
|
||||||
{
|
{
|
||||||
if (preferences.get(prefString) == null)
|
if (preferences.get(prefString) == null)
|
||||||
{
|
{
|
||||||
|
@ -66,3 +95,26 @@ class PreferencesMenu extends ui.OptionsState.Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CheckboxThingie extends FlxSprite
|
||||||
|
{
|
||||||
|
public var daValue(default, set):Bool = false;
|
||||||
|
|
||||||
|
public function new(x:Float, y:Float, daValue:Bool = false)
|
||||||
|
{
|
||||||
|
super(x, y);
|
||||||
|
|
||||||
|
this.daValue = daValue;
|
||||||
|
makeGraphic(50, 50, FlxColor.WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_daValue(value:Bool):Bool
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
color = FlxColor.GREEN;
|
||||||
|
else
|
||||||
|
color = FlxColor.RED;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import ui.MenuList;
|
||||||
|
|
||||||
class TextMenuList extends MenuTypedList<TextMenuItem>
|
class TextMenuList extends MenuTypedList<TextMenuItem>
|
||||||
{
|
{
|
||||||
public function new (navControls:NavControls = Vertical, ?wrapMode)
|
public function new(navControls:NavControls = Vertical, ?wrapMode)
|
||||||
{
|
{
|
||||||
super(navControls, wrapMode);
|
super(navControls, wrapMode);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class TextMenuList extends MenuTypedList<TextMenuItem>
|
||||||
|
|
||||||
class TextMenuItem extends TextTypedMenuItem<AtlasText>
|
class TextMenuItem extends TextTypedMenuItem<AtlasText>
|
||||||
{
|
{
|
||||||
public function new (x = 0.0, y = 0.0, name:String, font:AtlasFont = Bold, callback)
|
public function new(x = 0.0, y = 0.0, name:String, font:AtlasFont = Bold, callback)
|
||||||
{
|
{
|
||||||
super(x, y, new AtlasText(0, 0, name, font), name, callback);
|
super(x, y, new AtlasText(0, 0, name, font), name, callback);
|
||||||
setEmptyBackground();
|
setEmptyBackground();
|
||||||
|
@ -29,12 +29,12 @@ class TextMenuItem extends TextTypedMenuItem<AtlasText>
|
||||||
|
|
||||||
class TextTypedMenuItem<T:AtlasText> extends MenuTypedItem<T>
|
class TextTypedMenuItem<T:AtlasText> extends MenuTypedItem<T>
|
||||||
{
|
{
|
||||||
public function new (x = 0.0, y = 0.0, label:T, name:String, callback)
|
public function new(x = 0.0, y = 0.0, label:T, name:String, callback)
|
||||||
{
|
{
|
||||||
super(x, y, label, name, callback);
|
super(x, y, label, name, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
override function setItem(name:String, ?callback:Void -> Void)
|
override function setItem(name:String, ?callback:Void->Void)
|
||||||
{
|
{
|
||||||
if (label != null)
|
if (label != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue