diff --git a/.gitignore b/.gitignore index 7dbb7d60..b15789ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ export/ .vscode/ -APIStuff.hx \ No newline at end of file +APIStuff.hx +.DS_STORE diff --git a/hxformat.json b/hxformat.json index 4d31f145..5f15f383 100644 --- a/hxformat.json +++ b/hxformat.json @@ -1,16 +1,15 @@ -{ - "lineEnds": { - "leftCurly": "both", - "rightCurly": "both", - "emptyCurly": "break", - "objectLiteralCurly": { - "leftCurly": "after" - } - }, - "sameLine": { - "ifElse": "next", - "doWhile": "next", - "tryBody": "next", - "tryCatch": "next" - } -} +{ + "lineEnds": { + "leftCurly": "both", + "rightCurly": "both", + "objectLiteralCurly": { + "leftCurly": "after" + } + }, + "sameLine": { + "ifElse": "next", + "doWhile": "next", + "tryBody": "next", + "tryCatch": "next" + } +} diff --git a/source/OptionsMenu_old.hx b/source/OptionsMenu_old.hx deleted file mode 100644 index 4ec84432..00000000 --- a/source/OptionsMenu_old.hx +++ /dev/null @@ -1,132 +0,0 @@ -package; - -import Controls.Control; -import flash.text.TextField; -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.addons.display.FlxGridOverlay; -import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.input.keyboard.FlxKey; -import flixel.math.FlxMath; -import flixel.text.FlxText; -import flixel.util.FlxColor; -import lime.utils.Assets; - -class OptionsMenu_old extends MusicBeatState -{ - var selector:FlxText; - var curSelected:Int = 0; - - var controlsStrings:Array = []; - - private var grpControls:FlxTypedGroup; - - override function create() - { - var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat')); - controlsStrings = CoolUtil.coolTextFile(Paths.txt('controls')); - menuBG.color = 0xFFea71fd; - menuBG.setGraphicSize(Std.int(menuBG.width * 1.1)); - menuBG.updateHitbox(); - menuBG.screenCenter(); - menuBG.antialiasing = true; - add(menuBG); - - /* - grpControls = new FlxTypedGroup(); - add(grpControls); - - for (i in 0...controlsStrings.length) - { - if (controlsStrings[i].indexOf('set') != -1) - { - var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i].substring(3) + ': ' + controlsStrings[i + 1], true, false); - controlLabel.isMenuItem = true; - controlLabel.targetY = i; - grpControls.add(controlLabel); - } - // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! - } - */ - - super.create(); - - openSubState(new OptionsSubState()); - } - - override function update(elapsed:Float) - { - super.update(elapsed); - - /* - if (controls.ACCEPT) - { - changeBinding(); - } - - if (isSettingControl) - waitingInput(); - else - { - if (controls.BACK) - FlxG.switchState(new MainMenuState()); - if (controls.UP_P) - changeSelection(-1); - if (controls.DOWN_P) - changeSelection(1); - } - */ - } - - function waitingInput():Void - { - if (FlxG.keys.getIsDown().length > 0) - { - // PlayerSettings.player1.controls.replaceBinding(Control.LEFT, Keys, FlxG.keys.getIsDown()[0].ID, null); - } - // PlayerSettings.player1.controls.replaceBinding(Control) - } - - var isSettingControl:Bool = false; - - function changeBinding():Void - { - if (!isSettingControl) - { - isSettingControl = true; - } - } - - function changeSelection(change:Int = 0) - { - NGio.logEvent('Fresh'); - - FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); - - curSelected += change; - - if (curSelected < 0) - curSelected = grpControls.length - 1; - if (curSelected >= grpControls.length) - curSelected = 0; - - // selector.y = (70 * curSelected) + 30; - - var bullShit:Int = 0; - - for (item in grpControls.members) - { - item.targetY = bullShit - curSelected; - bullShit++; - - item.alpha = 0.6; - // item.setGraphicSize(Std.int(item.width * 0.8)); - - if (item.targetY == 0) - { - item.alpha = 1; - // item.setGraphicSize(Std.int(item.width)); - } - } - } -} diff --git a/source/OptionsSubState.hx b/source/OptionsSubState.hx deleted file mode 100644 index 1b5071c7..00000000 --- a/source/OptionsSubState.hx +++ /dev/null @@ -1,92 +0,0 @@ -package; - -import Controls.Control; -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.text.FlxText; -import flixel.util.FlxColor; -import polymod.Polymod; -#if desktop -import sys.FileSystem; -#end - -class OptionsSubState extends MusicBeatSubstate -{ - var textMenuItems:Array = ['Master Volume', 'Sound Volume', 'Controls', 'Colors', 'Back']; - - var selector:FlxSprite; - var curSelected:Int = 0; - - var grpOptionsTexts:FlxTypedGroup; - - // public static var isDownscroll:Bool = false; - - public function new() - { - super(); - - #if desktop - textMenuItems.push('Mods'); - #end - - grpOptionsTexts = new FlxTypedGroup(); - add(grpOptionsTexts); - - selector = new FlxSprite().makeGraphic(5, 5, FlxColor.RED); - add(selector); - - for (i in 0...textMenuItems.length) - { - var optionText:FlxText = new FlxText(20, 20 + (i * 50), 0, textMenuItems[i], 32); - optionText.ID = i; - grpOptionsTexts.add(optionText); - } - } - - override function update(elapsed:Float) - { - super.update(elapsed); - - if (controls.UI_UP_P) - curSelected -= 1; - - if (controls.UI_DOWN_P) - curSelected += 1; - - if (curSelected < 0) - curSelected = textMenuItems.length - 1; - - if (curSelected >= textMenuItems.length) - curSelected = 0; - - grpOptionsTexts.forEach(function(txt:FlxText) - { - txt.color = FlxColor.WHITE; - - if (txt.ID == curSelected) - txt.color = FlxColor.YELLOW; - }); - - if (controls.BACK) - FlxG.switchState(new MainMenuState()); - - if (controls.ACCEPT) - { - switch (textMenuItems[curSelected]) - { - case "Colors": - FlxG.state.closeSubState(); - - case "Controls": - FlxG.state.closeSubState(); - FlxG.state.openSubState(new ControlsSubState()); - case "Mods": - FlxG.state.closeSubState(); - // FlxG.state.openSubState(new ModdingSubstate()); - case "Back": - FlxG.switchState(new MainMenuState()); - } - } - } -} diff --git a/source/PlayState.hx b/source/PlayState.hx index cc08460c..c6a9e2fa 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1163,9 +1163,7 @@ class PlayState extends MusicBeatState { swagNote.x += FlxG.width / 2; // general offset } - else - { - } + else {} } daBeats += 1; } diff --git a/source/TitleState.hx b/source/TitleState.hx index 3e531bac..11475346 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -63,7 +63,7 @@ class TitleState extends MusicBeatState PlayerSettings.init(); Highscore.load(); - #if newgrounds + #if ng NGio.init(); #end @@ -297,7 +297,7 @@ class TitleState extends MusicBeatState transitioning = true; // FlxG.sound.music.stop(); - #if newgrounds + #if ng if (!OutdatedSubState.leftState) { NGio.checkVersion(function(version) diff --git a/source/ui/OptionsState.hx b/source/ui/OptionsState.hx index 3459c9b1..da51df26 100644 --- a/source/ui/OptionsState.hx +++ b/source/ui/OptionsState.hx @@ -12,7 +12,7 @@ import flixel.util.FlxSignal; class OptionsState extends MusicBeatState { var pages = new Map(); - var currentName:PageName = #if newgrounds Options #else Controls #end; + var currentName:PageName = Options; var currentPage(get, never):Page; inline function get_currentPage() @@ -29,6 +29,7 @@ class OptionsState extends MusicBeatState add(menuBG); var options = addPage(Options, new OptionsMenu(false)); + var preferences = addPage(Preferences, new PreferencesMenu()); var controls = addPage(Controls, new ControlsMenu()); var colors = addPage(Colors, new ColorsMenu()); @@ -41,6 +42,7 @@ class OptionsState extends MusicBeatState options.onExit.add(exitToMainMenu); controls.onExit.add(switchPage.bind(Options)); colors.onExit.add(switchPage.bind(Options)); + preferences.onExit.add(switchPage.bind(Options)); #if cpp mods.onExit.add(switchPage.bind(Options)); @@ -172,6 +174,7 @@ class OptionsMenu extends Page super(); add(items = new TextMenuList()); + createItem('preferences', function() switchPage(Preferences)); createItem("controls", function() switchPage(Controls)); createItem('colors', function() switchPage(Colors)); #if cpp @@ -276,4 +279,5 @@ enum PageName Controls; Colors; Mods; + Preferences; } diff --git a/source/ui/PreferencesMenu.hx b/source/ui/PreferencesMenu.hx new file mode 100644 index 00000000..e5afbf9f --- /dev/null +++ b/source/ui/PreferencesMenu.hx @@ -0,0 +1,68 @@ +package ui; + +import flixel.FlxG; +import ui.AtlasText.AtlasFont; + +class PreferencesMenu extends ui.OptionsState.Page +{ + public static var preferences:Map = new Map(); + + var items:TextMenuList; + + public function new() + { + super(); + add(items = new TextMenuList()); + + createPrefItem('naughtyness', 'censor-naughty', false); + createPrefItem('downscroll', 'downscroll', false); + } + + private function createPrefItem(prefName:String, prefString:String, prefValue:Dynamic):Void + { + items.createItem(100, 100 * items.length, prefName, AtlasFont.Bold, function() + { + preferenceCheck(prefString, prefValue); + + switch (Type.typeof(prefValue).getName()) + { + case 'TBool': + prefToggle(prefString); + + default: + trace('swag'); + } + }); + + trace(Type.typeof(prefValue).getName()); + } + + /** + * Assumes that the preference has already been checked/set? + */ + private function prefToggle(prefName:String) + { + var daSwap:Bool = preferences.get(prefName); + daSwap = !daSwap; + preferences.set(prefName, daSwap); + trace('toggled? ' + preferences.get(prefName)); + } + + override function update(elapsed:Float) + { + super.update(elapsed); + } + + private function preferenceCheck(prefString:String, prefValue:Dynamic):Void + { + if (preferences.get(prefString) == null) + { + preferences.set(prefString, prefValue); + trace('set preference!'); + } + else + { + trace('found preference: ' + preferences.get(prefString)); + } + } +} diff --git a/source/ui/SettingsMenu.hx b/source/ui/SettingsMenu.hx deleted file mode 100644 index 179ff410..00000000 --- a/source/ui/SettingsMenu.hx +++ /dev/null @@ -1,9 +0,0 @@ -package ui; - -class SettingsMenu extends ui.OptionsState.Page -{ - public function new() - { - super(); - } -}