Merge pull request #80 from Saalvage/fps
Implement FPS counter toggle and options refactor
This commit is contained in:
commit
f79de1e064
@ -5,27 +5,30 @@ class KadeEngineData
|
|||||||
public static function initSave()
|
public static function initSave()
|
||||||
{
|
{
|
||||||
if (FlxG.save.data.newInput == null)
|
if (FlxG.save.data.newInput == null)
|
||||||
FlxG.save.data.newInput = true;
|
FlxG.save.data.newInput = true;
|
||||||
|
|
||||||
if (FlxG.save.data.downscroll == null)
|
if (FlxG.save.data.downscroll == null)
|
||||||
FlxG.save.data.downscroll = false;
|
FlxG.save.data.downscroll = false;
|
||||||
|
|
||||||
if (FlxG.save.data.dfjk == null)
|
if (FlxG.save.data.dfjk == null)
|
||||||
FlxG.save.data.dfjk = false;
|
FlxG.save.data.dfjk = false;
|
||||||
|
|
||||||
if (FlxG.save.data.accuracyDisplay == null)
|
if (FlxG.save.data.accuracyDisplay == null)
|
||||||
FlxG.save.data.accuracyDisplay = true;
|
FlxG.save.data.accuracyDisplay = true;
|
||||||
|
|
||||||
if (FlxG.save.data.offset == null)
|
if (FlxG.save.data.offset == null)
|
||||||
FlxG.save.data.offset = 0;
|
FlxG.save.data.offset = 0;
|
||||||
|
|
||||||
if (FlxG.save.data.offset == null)
|
if (FlxG.save.data.offset == null)
|
||||||
FlxG.save.data.offset = 0;
|
FlxG.save.data.offset = 0;
|
||||||
|
|
||||||
if (FlxG.save.data.songPosition == null)
|
if (FlxG.save.data.songPosition == null)
|
||||||
FlxG.save.data.songPosition = false;
|
FlxG.save.data.songPosition = false;
|
||||||
|
|
||||||
if (FlxG.save.data.etternaMode == null)
|
if (FlxG.save.data.etternaMode == null)
|
||||||
FlxG.save.data.etternaMode = false;
|
FlxG.save.data.etternaMode = false;
|
||||||
}
|
|
||||||
|
if (FlxG.save.data.fps == null)
|
||||||
|
FlxG.save.data.fps = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package;
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
import flixel.FlxGame;
|
import flixel.FlxGame;
|
||||||
import flixel.FlxState;
|
import flixel.FlxState;
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
@ -70,7 +71,15 @@ class Main extends Sprite
|
|||||||
addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
|
addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
|
||||||
|
|
||||||
#if !mobile
|
#if !mobile
|
||||||
addChild(new FPS(10, 3, 0xFFFFFF));
|
fpsCounter = new FPS(10, 3, 0xFFFFFF);
|
||||||
|
addChild(fpsCounter);
|
||||||
|
toggleFPS(FlxG.save.data.fps);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fpsCounter:FPS;
|
||||||
|
|
||||||
|
public function toggleFPS(fpsEnabled:Bool):Void {
|
||||||
|
fpsCounter.visible = fpsEnabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,159 @@
|
|||||||
package;
|
package;
|
||||||
|
|
||||||
class Options
|
import Controls.KeyboardScheme;
|
||||||
|
import flixel.FlxG;
|
||||||
|
import openfl.display.FPS;
|
||||||
|
import openfl.Lib;
|
||||||
|
|
||||||
|
class Option
|
||||||
{
|
{
|
||||||
public static var masterVolume:Float = 1;
|
public function new()
|
||||||
|
{
|
||||||
|
display = updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
private var display:String;
|
||||||
|
public final function getDisplay():String
|
||||||
|
{
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns whether the label is to be updated.
|
||||||
|
public function press():Bool { return throw "stub!"; }
|
||||||
|
private function updateDisplay():String { return throw "stub!"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class DFJKOption extends Option
|
||||||
|
{
|
||||||
|
private var controls:Controls;
|
||||||
|
|
||||||
|
public function new(controls:Controls)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.controls = controls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.dfjk = !FlxG.save.data.dfjk;
|
||||||
|
|
||||||
|
if (FlxG.save.data.dfjk)
|
||||||
|
controls.setKeyboardScheme(KeyboardScheme.Solo, true);
|
||||||
|
else
|
||||||
|
controls.setKeyboardScheme(KeyboardScheme.Duo(true), true);
|
||||||
|
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return FlxG.save.data.dfjk ? "DFJK" : "WASD";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewInputOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.newInput = !FlxG.save.data.newInput;
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return FlxG.save.data.newInput ? "New input" : "Old Input";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DownscrollOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.downscroll = !FlxG.save.data.downscroll;
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return FlxG.save.data.downscroll ? "Downscroll" : "Upscroll";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AccuracyOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.accuracyDisplay = !FlxG.save.data.accuracyDisplay;
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return "Accuracy " + (!FlxG.save.data.accuracyDisplay ? "off" : "on");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SongPositionOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.songPosition = !FlxG.save.data.songPosition;
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return "Song Position " + (!FlxG.save.data.songPosition ? "off" : "on");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EtternaModeOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.etternaMode = !FlxG.save.data.etternaMode;
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return "Etterna Mode " + (!FlxG.save.data.etternaMode ? "off" : "on");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FPSOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
FlxG.save.data.fps = !FlxG.save.data.fps;
|
||||||
|
(cast (Lib.current.getChildAt(0), Main)).toggleFPS(FlxG.save.data.fps);
|
||||||
|
display = updateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return "FPS Counter " + (!FlxG.save.data.fps ? "off" : "on");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReplayOption extends Option
|
||||||
|
{
|
||||||
|
public override function press():Bool
|
||||||
|
{
|
||||||
|
trace("switch");
|
||||||
|
FlxG.switchState(new LoadReplayState());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private override function updateDisplay():String
|
||||||
|
{
|
||||||
|
return "Load replays";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package;
|
package;
|
||||||
|
|
||||||
import Controls.KeyboardScheme;
|
import Options;
|
||||||
import Controls.Control;
|
import Controls.Control;
|
||||||
import flash.text.TextField;
|
import flash.text.TextField;
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
@ -18,23 +18,24 @@ class OptionsMenu extends MusicBeatState
|
|||||||
var selector:FlxText;
|
var selector:FlxText;
|
||||||
var curSelected:Int = 0;
|
var curSelected:Int = 0;
|
||||||
|
|
||||||
var controlsStrings:Array<String> = [];
|
var options:Array<Option> = [
|
||||||
|
new DFJKOption(controls),
|
||||||
|
new NewInputOption(),
|
||||||
|
new DownscrollOption(),
|
||||||
|
new AccuracyOption(),
|
||||||
|
new SongPositionOption(),
|
||||||
|
#if !mobile
|
||||||
|
new FPSOption(),
|
||||||
|
#end
|
||||||
|
new EtternaModeOption(),
|
||||||
|
new ReplayOption()
|
||||||
|
];
|
||||||
|
|
||||||
private var grpControls:FlxTypedGroup<Alphabet>;
|
private var grpControls:FlxTypedGroup<Alphabet>;
|
||||||
var versionShit:FlxText;
|
var versionShit:FlxText;
|
||||||
override function create()
|
override function create()
|
||||||
{
|
{
|
||||||
var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
|
var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image("menuDesat"));
|
||||||
controlsStrings = CoolUtil.coolStringFile(
|
|
||||||
(FlxG.save.data.dfjk ? 'DFJK' : 'WASD') +
|
|
||||||
"\n" + (FlxG.save.data.newInput ? "New input" : "Old Input") +
|
|
||||||
"\n" + (FlxG.save.data.downscroll ? 'Downscroll' : 'Upscroll') +
|
|
||||||
"\nAccuracy " + (!FlxG.save.data.accuracyDisplay ? "off" : "on") +
|
|
||||||
"\nSong Position " + (!FlxG.save.data.songPosition ? "off" : "on") +
|
|
||||||
"\nEtterna Mode " + (!FlxG.save.data.etternaMode ? "off" : "on") +
|
|
||||||
"\nLoad replays");
|
|
||||||
|
|
||||||
trace(controlsStrings);
|
|
||||||
|
|
||||||
menuBG.color = 0xFFea71fd;
|
menuBG.color = 0xFFea71fd;
|
||||||
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
|
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
|
||||||
@ -46,12 +47,12 @@ class OptionsMenu extends MusicBeatState
|
|||||||
grpControls = new FlxTypedGroup<Alphabet>();
|
grpControls = new FlxTypedGroup<Alphabet>();
|
||||||
add(grpControls);
|
add(grpControls);
|
||||||
|
|
||||||
for (i in 0...controlsStrings.length)
|
for (i in 0...options.length)
|
||||||
{
|
{
|
||||||
var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i], true, false);
|
var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, options[i].getDisplay(), true, false);
|
||||||
controlLabel.isMenuItem = true;
|
controlLabel.isMenuItem = true;
|
||||||
controlLabel.targetY = i;
|
controlLabel.targetY = i;
|
||||||
grpControls.add(controlLabel);
|
grpControls.add(controlLabel);
|
||||||
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
|
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,54 +91,11 @@ class OptionsMenu extends MusicBeatState
|
|||||||
|
|
||||||
if (controls.ACCEPT)
|
if (controls.ACCEPT)
|
||||||
{
|
{
|
||||||
if (curSelected != 6)
|
if (options[curSelected].press()) {
|
||||||
grpControls.remove(grpControls.members[curSelected]);
|
grpControls.remove(grpControls.members[curSelected]);
|
||||||
switch(curSelected)
|
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, options[curSelected].getDisplay(), true, false);
|
||||||
{
|
ctrl.isMenuItem = true;
|
||||||
case 0:
|
grpControls.add(ctrl);
|
||||||
FlxG.save.data.dfjk = !FlxG.save.data.dfjk;
|
|
||||||
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, (FlxG.save.data.dfjk ? 'DFJK' : 'WASD'), true, false);
|
|
||||||
ctrl.isMenuItem = true;
|
|
||||||
ctrl.targetY = curSelected;
|
|
||||||
grpControls.add(ctrl);
|
|
||||||
if (FlxG.save.data.dfjk)
|
|
||||||
controls.setKeyboardScheme(KeyboardScheme.Solo, true);
|
|
||||||
else
|
|
||||||
controls.setKeyboardScheme(KeyboardScheme.Duo(true), true);
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
FlxG.save.data.newInput = !FlxG.save.data.newInput;
|
|
||||||
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, (FlxG.save.data.newInput ? "New input" : "Old Input"), true, false);
|
|
||||||
ctrl.isMenuItem = true;
|
|
||||||
ctrl.targetY = curSelected - 1;
|
|
||||||
grpControls.add(ctrl);
|
|
||||||
case 2:
|
|
||||||
FlxG.save.data.downscroll = !FlxG.save.data.downscroll;
|
|
||||||
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, (FlxG.save.data.downscroll ? 'Downscroll' : 'Upscroll'), true, false);
|
|
||||||
ctrl.isMenuItem = true;
|
|
||||||
ctrl.targetY = curSelected - 2;
|
|
||||||
grpControls.add(ctrl);
|
|
||||||
case 3:
|
|
||||||
FlxG.save.data.accuracyDisplay = !FlxG.save.data.accuracyDisplay;
|
|
||||||
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, "Accuracy " + (!FlxG.save.data.accuracyDisplay ? "off" : "on"), true, false);
|
|
||||||
ctrl.isMenuItem = true;
|
|
||||||
ctrl.targetY = curSelected - 3;
|
|
||||||
grpControls.add(ctrl);
|
|
||||||
case 4:
|
|
||||||
FlxG.save.data.songPosition = !FlxG.save.data.songPosition;
|
|
||||||
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, "Song Position " + (!FlxG.save.data.songPosition ? "off" : "on"), true, false);
|
|
||||||
ctrl.isMenuItem = true;
|
|
||||||
ctrl.targetY = curSelected - 4;
|
|
||||||
grpControls.add(ctrl);
|
|
||||||
case 5:
|
|
||||||
FlxG.save.data.etternaMode = !FlxG.save.data.etternaMode;
|
|
||||||
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, "Etterna Mode " + (!FlxG.save.data.etternaMode ? "off" : "on"), true, false);
|
|
||||||
ctrl.isMenuItem = true;
|
|
||||||
ctrl.targetY = curSelected - 5;
|
|
||||||
grpControls.add(ctrl);
|
|
||||||
case 6:
|
|
||||||
trace('switch');
|
|
||||||
FlxG.switchState(new LoadReplayState());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlxG.save.flush();
|
FlxG.save.flush();
|
||||||
@ -148,10 +106,10 @@ class OptionsMenu extends MusicBeatState
|
|||||||
function changeSelection(change:Int = 0)
|
function changeSelection(change:Int = 0)
|
||||||
{
|
{
|
||||||
#if !switch
|
#if !switch
|
||||||
// NGio.logEvent('Fresh');
|
// NGio.logEvent("Fresh");
|
||||||
#end
|
#end
|
||||||
|
|
||||||
FlxG.sound.play(Paths.sound('scrollMenu'), 0.4);
|
FlxG.sound.play(Paths.sound("scrollMenu"), 0.4);
|
||||||
|
|
||||||
curSelected += change;
|
curSelected += change;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user