fixing stuff

This commit is contained in:
⍚~Nex
2024-09-02 23:47:11 +02:00
parent c1df80c34e
commit aa22bd6e1d
2 changed files with 4 additions and 33 deletions
@@ -1,28 +1,17 @@
package funkin.backend.system.framerate;
import haxe.ds.Vector;
import openfl.display.Sprite;
import openfl.text.TextField;
import openfl.text.TextFormat;
inline final FRAME_TIME_HISTORY = 20;
class FramerateCounter extends Sprite {
public var fpsNum:TextField;
public var fpsLabel:TextField;
public var fpsHistoryIndex:Int = 0;
public var fpsHistory:Vector<Float>;
public var lastFPS:Float = 0;
public function new() {
super();
fpsHistory = new Vector(FRAME_TIME_HISTORY);
// Initialize to 60 FPS, so that the initial estimation until we get enough data is always reasonable.
for(i in 0...FRAME_TIME_HISTORY) {
fpsHistory[i] = 1000.0 / 60.0;
}
fpsNum = new TextField();
fpsLabel = new TextField();
@@ -43,20 +32,8 @@ class FramerateCounter extends Sprite {
if (alpha <= 0.05) return;
super.__enterFrame(t);
// todo use gpu time
fpsHistory[fpsHistoryIndex] = FlxG.elapsed * 1000;
fpsHistoryIndex = (fpsHistoryIndex + 1) % FRAME_TIME_HISTORY;
// Calculate average CPU time.
// Code based on Godot's FPS counter.
var cpuTime = 0.0;
for(i in 0...FRAME_TIME_HISTORY) {
cpuTime += fpsHistory[i];
}
cpuTime /= FRAME_TIME_HISTORY;
cpuTime = Math.max(0.01, cpuTime); // Prevent unrealistically low values.
fpsNum.text = Std.string(Math.floor(1000.0 / cpuTime));
lastFPS = CoolUtil.fpsLerp(lastFPS, FlxG.elapsed == 0 ? 0 : (1 / FlxG.elapsed), 0.25);
fpsNum.text = Std.string(Math.floor(lastFPS));
fpsLabel.x = fpsNum.x + fpsNum.width;
fpsLabel.y = (fpsNum.y + fpsNum.height) - fpsLabel.height;
}
@@ -80,8 +80,6 @@ class SongCreationScreen extends UISubstateWindow {
stepsPerBeatStepper = new UINumericStepper(beatsPerMeasureStepper.x + 30 + 24, beatsPerMeasureStepper.y, 4, 1, 0, 1, null, 54);
songDataGroup.add(stepsPerBeatStepper);
var voicesUIText:UIText = null;
instExplorer = new UIFileExplorer(songNameTextBox.x, songNameTextBox.y + 32 + 36, null, null, Paths.SOUND_EXT, function (res) {
var audioPlayer:UIAudioPlayer = new UIAudioPlayer(instExplorer.x + 8, instExplorer.y + 8, res);
instExplorer.members.push(audioPlayer);
@@ -98,11 +96,7 @@ class SongCreationScreen extends UISubstateWindow {
voicesExplorer.uiElement = audioPlayer;
});
songDataGroup.add(voicesExplorer);
voicesUIText = addLabelOn(voicesExplorer, "Vocal Audio File");
voicesUIText.applyMarkup(
"Vocal Audio File $* Required$",
[new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAD1212), "$")]);
addLabelOn(voicesExplorer, "Vocal Audio File");
var menuTitle:UIText;
menuDataGroup.add(menuTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, "Menus Data (Freeplay/Story)", 28));