Skip to content

Commit

Permalink
Revert "framerate cap option"
Browse files Browse the repository at this point in the history
This reverts commit 820829e.
  • Loading branch information
charlesisfeline committed Jun 25, 2024
1 parent b529664 commit d19ade4
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 260 deletions.
9 changes: 7 additions & 2 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package;

import flixel.FlxGame;
import flixel.FlxState;
import funkin.Preferences;
import funkin.util.logging.CrashHandler;
import funkin.ui.debug.MemoryCounter;
import funkin.save.Save;
Expand Down Expand Up @@ -31,6 +30,12 @@ class Main extends Sprite
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
var initialState:Class<FlxState> = funkin.InitState; // The FlxState the game starts with.
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
#if web
var framerate:Int = 60; // How many frames per second the game should run at.
#else
// TODO: This should probably be in the options menu?
var framerate:Int = 144; // How many frames per second the game should run at.
#end
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets

Expand Down Expand Up @@ -106,7 +111,7 @@ class Main extends Sprite

// George recommends binding the save before FlxGame is created.
Save.load();
var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, Preferences.framerate, Preferences.framerate, skipSplash, startFullscreen);
var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen);

// FlxG.game._customSoundTray wants just the class, it calls new from
// create() in there, which gets called when it's added to stage
Expand Down
29 changes: 0 additions & 29 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,6 @@ import funkin.save.Save;
*/
class Preferences
{
/**
* FPS
* @default `60`
*/
public static var framerate(get, set):Int;

static function get_framerate():Int
{
#if web
return 60;
#else
return Save?.instance?.options?.framerate ?? 60;
#end
}

static function set_framerate(value:Int):Int
{
#if web
return 60;
#else
var save:Save = Save.instance;
save.options.framerate = value;
save.flush();
FlxG.updateFramerate = value;
FlxG.drawFramerate = value;
return value;
#end
}

/**
* Whether some particularly fowl language is displayed.
* @default `true`
Expand Down
7 changes: 0 additions & 7 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class Save
options:
{
// Reasonable defaults.
framerate: 60,
naughtyness: true,
downscroll: false,
flashingLights: true,
Expand Down Expand Up @@ -1056,12 +1055,6 @@ typedef SaveScoreTallyData =
*/
typedef SaveDataOptions =
{
/**
* FPS
* @default `60`
*/
var framerate:Int;

/**
* Whether some particularly fowl language is displayed.
* @default `true`
Expand Down
26 changes: 0 additions & 26 deletions source/funkin/ui/AtlasText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -152,32 +152,6 @@ class AtlasText extends FlxTypedSpriteGroup<AtlasChar>
}
}

public function getWidth():Int
{
var width = 0;
for (char in this.text.split(""))
{
switch (char)
{
case " ":
{
width += 40;
}
case "\n":
{}
case char:
{
var sprite = new AtlasChar(atlas, char);
sprite.revive();
sprite.char = char;
sprite.alpha = 1;
width += Std.int(sprite.width);
}
}
}
return width;
}

override function toString()
{
return "InputItem, " + FlxStringUtil.getDebugString([
Expand Down
94 changes: 54 additions & 40 deletions source/funkin/ui/options/PreferencesMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import flixel.FlxSprite;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import funkin.ui.AtlasText.AtlasFont;
import funkin.ui.options.OptionsState.Page;
import funkin.ui.options.items.CheckboxPreferenceItem;
import funkin.ui.options.items.NumberPreferenceItem;
import funkin.graphics.FunkinCamera;
import funkin.ui.TextMenuList.TextMenuItem;

Expand Down Expand Up @@ -50,11 +48,6 @@ class PreferencesMenu extends Page
*/
function createPrefItems():Void
{
#if !web
createPrefItemNumber('FPS', 'The framerate that the game is running on', function(value:Float) {
Preferences.framerate = Std.int(value);
}, Preferences.framerate, 60, 360, 1, 0);
#end
createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void {
Preferences.naughtyness = value;
}, Preferences.naughtyness);
Expand All @@ -75,54 +68,75 @@ class PreferencesMenu extends Page
}, Preferences.autoPause);
}

override function update(elapsed:Float):Void
function createPrefItemCheckbox(prefName:String, prefDesc:String, onChange:Bool->Void, defaultValue:Bool):Void
{
var checkbox:CheckboxPreferenceItem = new CheckboxPreferenceItem(0, 120 * (items.length - 1 + 1), defaultValue);

items.createItem(120, (120 * items.length) + 30, prefName, AtlasFont.BOLD, function() {
var value = !checkbox.currentValue;
onChange(value);
checkbox.currentValue = value;
});

preferenceItems.add(checkbox);
}

override function update(elapsed:Float)
{
super.update(elapsed);

// Indent the selected item.
// TODO: Only do this on menu change?
items.forEach(function(daItem:TextMenuItem) {
var thyOffset:Int = 0;
if (Std.isOfType(daItem, NumberPreferenceItem)) thyOffset = cast(daItem, NumberPreferenceItem).lefthandText.getWidth();

// Very messy but it works
if (thyOffset == 0)
{
if (items.selectedItem == daItem) thyOffset += 150;
else
thyOffset += 120;
}
else if (items.selectedItem == daItem)
{
thyOffset += 70;
}
if (items.selectedItem == daItem) daItem.x = 150;
else
{
thyOffset += 25;
}

daItem.x = thyOffset;
daItem.x = 120;
});
}
}

function createPrefItemCheckbox(prefName:String, prefDesc:String, onChange:Bool->Void, defaultValue:Bool):Void
class CheckboxPreferenceItem extends FlxSprite
{
public var currentValue(default, set):Bool;

public function new(x:Float, y:Float, defaultValue:Bool = false)
{
var checkbox:CheckboxPreferenceItem = new CheckboxPreferenceItem(0, 120 * (items.length - 1 + 1), defaultValue);
super(x, y);

items.createItem(120, (120 * items.length) + 30, prefName, AtlasFont.BOLD, function() {
var value = !checkbox.currentValue;
onChange(value);
checkbox.currentValue = value;
});
frames = Paths.getSparrowAtlas('checkboxThingie');
animation.addByPrefix('static', 'Check Box unselected', 24, false);
animation.addByPrefix('checked', 'Check Box selecting animation', 24, false);

preferenceItems.add(checkbox);
setGraphicSize(Std.int(width * 0.7));
updateHitbox();

this.currentValue = defaultValue;
}

override function update(elapsed:Float)
{
super.update(elapsed);

switch (animation.curAnim.name)
{
case 'static':
offset.set();
case 'checked':
offset.set(17, 70);
}
}

function createPrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, defaultValue:Float, min:Float, max:Float, step:Float,
precision:Int):Void
function set_currentValue(value:Bool):Bool
{
var item = new NumberPreferenceItem(145, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange);
items.addItem(prefName, item);
preferenceItems.add(item.lefthandText);
if (value)
{
animation.play('checked', true);
}
else
{
animation.play('static');
}

return currentValue = value;
}
}
49 changes: 0 additions & 49 deletions source/funkin/ui/options/items/CheckboxPreferenceItem.hx

This file was deleted.

Loading

0 comments on commit d19ade4

Please sign in to comment.