Skip to content

Commit

Permalink
fixed discord rpc and fps
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyrid19 committed Sep 9, 2024
1 parent 7fb8886 commit 8fc97a8
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 232 deletions.
5 changes: 1 addition & 4 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<!-- ____________________________ Window Settings ___________________________ -->

<!--These window settings apply to all targets-->
<window width="1280" height="720" fps="" background="#000000" hardware="true" vsync="false" />
<window width="1280" height="720" fps="60" background="#000000" hardware="true" vsync="false" />

<!--HTML5-specific-->
<window if="html5" resizable="true" />
Expand Down Expand Up @@ -116,9 +116,6 @@
<!--HXSDL-->
<haxelib name="hxsdl" />

<!--Outlined OpenFL Text Fields-->
<haxelib name="stroked-textfield" />

<!-- <haxelib name="hxCodec" if="desktop || mobile" /> -->

<section if="cpp">
Expand Down
5 changes: 0 additions & 5 deletions cmd/data/haxelibs.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@
"name": "flxpartialsound",
"version": "",
"git": "https://github.com/FunkinCrew/FlxPartialSound"
},
{
"name": "stroked-textfield",
"version": "",
"git": "https://github.com/Fyrid19/StrokedTextField"
}
]
}
26 changes: 10 additions & 16 deletions source/backend/framerate/EngineWatermark.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@ import openfl.text.TextField;
import openfl.text.TextFormat;

class EngineWatermark extends Sprite {
var watermarkTxt:StrokedTextField;
var commitTxt:StrokedTextField;
var watermarkTxt:TextField;
var commitTxt:TextField;
public function new() {
super();

watermarkTxt = new StrokedTextField(FullFPS.fpsFontBytes);
commitTxt = new StrokedTextField(FullFPS.fpsFontBytes);
watermarkTxt = new TextField();
commitTxt = new TextField();

var col:Array<UInt> = FullFPS.fpsColors;
var alp:Array<Float> = [1, 1];
var rat:Array<Int> = [255, 255];
var mtx:Matrix = new Matrix();
mtx.createGradientBox(400, 125, Math.PI / 2, 0, 0);

for(text in [watermarkTxt, commitTxt]) {
addChild(text);
text.lineStyle(4, 0x000000);
text.gradientFill(GradientType.LINEAR, col, alp, rat, mtx, SpreadMethod.PAD);
text.fontSize = 14;
// text.update();
for(text in [watermarkTxt, commitTxt]) {
text.text = "";
text.autoSize = LEFT;
text.multiline = false;
text.defaultTextFormat = new TextFormat(FullFPS.fpsFont, 10, 0xFFFFFF);
addChild(text);
}

watermarkTxt.text = 'Prototype Engine ' + EngineMain.engineVer;
Expand Down
30 changes: 10 additions & 20 deletions source/backend/framerate/FPSCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,28 @@ import backend.framerate.FullFPS;
import openfl.system.System;

class FPSCounter extends Sprite {
public var fpsCountTxt:StrokedTextField;
public var fpsLabelTxt:StrokedTextField;
public var fpsCountTxt:TextField;
public var fpsLabelTxt:TextField;

private var times:Array<Float>;

public function new() {
super();

fpsCountTxt = new StrokedTextField(FullFPS.fpsFontBytes);
fpsLabelTxt = new StrokedTextField(FullFPS.fpsFontBytes);

var col:Array<UInt> = FullFPS.fpsColors;
var alp:Array<Float> = [1, 1];
var rat:Array<Int> = [255, 255];
var mtx:Matrix = new Matrix();
mtx.createGradientBox(400, 125, Math.PI / 2, 0, 0);
fpsCountTxt = new TextField();
fpsLabelTxt = new TextField();

for(text in [fpsCountTxt, fpsLabelTxt]) {
addChild(text);
text.lineStyle(4, 0x000000);
text.gradientFill(GradientType.LINEAR, col, alp, rat, mtx, SpreadMethod.PAD);
text.fontSize = 14;
// text.update();
text.text = "";
text.autoSize = LEFT;
text.multiline = false;
addChild(text);
}

fpsCountTxt.fontSize = 18;
fpsLabelTxt.fontSize = 14;
fpsCountTxt.defaultTextFormat = new TextFormat(FullFPS.fpsFont, 14, 0xFFFFFF);
fpsLabelTxt.defaultTextFormat = new TextFormat(FullFPS.fpsFont, 10, 0xFFFFFF);
fpsLabelTxt.text = "FPS";

fpsCountTxt.update();
fpsLabelTxt.update();

times = [];
}

Expand Down
30 changes: 24 additions & 6 deletions source/backend/framerate/FullFPS.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,59 @@ package backend.framerate;

import openfl.Assets;
import openfl.display.Sprite;
import openfl.utils.ByteArray;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import backend.framerate.FPSCounter;
import backend.framerate.MemoryCounter;
import backend.framerate.EngineWatermark;

class FullFPS extends Sprite {
public static var fpsFont:String;
public static var fpsFontBytes:ByteArray;

public static var fpsColors:Array<UInt> = [0xFFFFFF, 0xFFFFFF];

public var backGraphic:Bitmap;

public var fpsCount:FPSCounter;
public var memCount:MemoryCounter;
public var watermark:EngineWatermark;

var offset:Array<Float> = [2, 2];
var boxBorder:Float = 2;

public function new() {
super();

fpsFont = Assets.getFont(Paths.font('nokia.ttf')).fontName;
fpsFontBytes = Assets.getBytes(Paths.font('nokia.ttf'));
fpsFont = Assets.getFont(Paths.defaultFont).fontName;

fpsCount = new FPSCounter();
memCount = new MemoryCounter();
watermark = new EngineWatermark();

fpsCount.x = boxBorder;
memCount.x = fpsCount.x;
watermark.x = fpsCount.x;

fpsCount.y = boxBorder;
memCount.y = fpsCount.y + fpsCount.height + 2;
watermark.y = memCount.y + memCount.height + fpsCount.height - 3;

var _bitmap:BitmapData = new BitmapData(1, 1, false, 0x000000);
backGraphic = new Bitmap(_bitmap);
backGraphic.alpha = 0.6;

addChild(backGraphic);
addChild(fpsCount);
addChild(memCount);
addChild(watermark);

x = offset[0];
y = offset[1];
}

public override function __enterFrame(delta:Int) {
fpsCount.__enterFrame(delta);
memCount.__enterFrame(delta);

backGraphic.scaleX = memCount.width + boxBorder + 4;
backGraphic.scaleY = fpsCount.height + memCount.height + watermark.height + boxBorder + 4;
}
}
22 changes: 7 additions & 15 deletions source/backend/framerate/MemoryCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@ import openfl.text.TextFormat;
import openfl.system.System;

class MemoryCounter extends Sprite {
public var memText:StrokedTextField;
public var memText:TextField;
public function new() {
super();

memText = new StrokedTextField(FullFPS.fpsFontBytes);
addChild(memText);
memText.lineStyle(4, 0x000000);

var col:Array<UInt> = FullFPS.fpsColors;
var alp:Array<Float> = [1, 1];
var rat:Array<Int> = [255, 255];
var mtx:Matrix = new Matrix();
mtx.createGradientBox(400, 125, Math.PI / 2, 0, 0);

memText.gradientFill(GradientType.LINEAR, col, alp, rat, mtx, SpreadMethod.PAD);

memText.fontSize = 14;
memText.mode = "outline";
memText = new TextField();
memText.text = "";
memText.autoSize = LEFT;
memText.multiline = false;
memText.defaultTextFormat = new TextFormat(FullFPS.fpsFont, 10, 0xFFFFFF);
addChild(memText);
}

private var memPeak:Float = 0;
Expand Down
6 changes: 0 additions & 6 deletions source/backend/framerate/import.hx

This file was deleted.

13 changes: 7 additions & 6 deletions source/funkin/states/WarningState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@ class WarningState extends MusicBeatState {
add(background);

warningTxt = new FlxText(0, 5, FlxG.width, '!! WARNING !!', 64);
warningTxt.setFormat(Paths.font('vcr.ttf'), 64, FlxColor.RED, CENTER, OUTLINE_FAST, FlxColor.BLACK);
warningTxt.setFormat(Paths.defaultFont, 64, FlxColor.RED, CENTER, OUTLINE_FAST, FlxColor.BLACK);
add(warningTxt);

versionInfoTxt = new FlxText(0, 0, FlxG.width, '', 24);
versionInfoTxt.setFormat(Paths.font('vcr.ttf'), 24, FlxColor.WHITE, CENTER, OUTLINE_FAST, FlxColor.BLACK);
versionInfoTxt.setFormat(Paths.defaultFont, 24, FlxColor.WHITE, CENTER, OUTLINE_FAST, FlxColor.BLACK);
versionInfoTxt.y = warningTxt.y + warningTxt.height + 5;
versionInfoTxt.text = 'Version: ${EngineMain.engineVer} | Current Commit: ${EngineMain.getRepoCommits()}';
add(versionInfoTxt);

warningTxt2 = new FlxText(0, 0, FlxG.width, '', 32);
warningTxt2.setFormat(Paths.font('vcr.ttf'), 32, FlxColor.WHITE, CENTER, OUTLINE_FAST, FlxColor.BLACK);
warningTxt2.setFormat(Paths.defaultFont, 32, FlxColor.WHITE, CENTER, OUTLINE_FAST, FlxColor.BLACK);

warningTxt2.text += "This engine is in active development, by one developer for that matter.\n";
warningTxt2.text += "There WILL be broken things, and some things that just aren't there yet, be patient with me.\n\n";
warningTxt2.text += "There WILL be broken things, and some things that just aren't there yet.\n";
warningTxt2.text += "Nothing is final, everything is subject to change.\n\n";
warningTxt2.text += "With that being said, I present to you:";

warningTxt2.screenCenter();
add(warningTxt2);

logoPlaceholder = new FlxText(0, 0, FlxG.width, '- PROTOTYPE ENGINE -', 46);
logoPlaceholder.setFormat(Paths.font('vcr.ttf'), 46, FlxColor.CYAN, CENTER, OUTLINE_FAST, FlxColor.BLACK);
logoPlaceholder.setFormat(Paths.defaultFont, 46, FlxColor.CYAN, CENTER, OUTLINE_FAST, FlxColor.BLACK);
logoPlaceholder.y = warningTxt2.y + warningTxt2.height + 10;
add(logoPlaceholder);

var confirmationTxt:FlxText = new FlxText(0, 0, FlxG.width, 'Press ACCEPT to proceed', 64);
confirmationTxt.setFormat(Paths.font('vcr.ttf'), 64, FlxColor.BLUE, CENTER, OUTLINE_FAST, FlxColor.BLACK);
confirmationTxt.setFormat(Paths.defaultFont, 64, FlxColor.BLUE, CENTER, OUTLINE_FAST, FlxColor.BLACK);
confirmationTxt.y = FlxG.height - confirmationTxt.height - 5;
add(confirmationTxt);
}
Expand Down
Loading

0 comments on commit 8fc97a8

Please sign in to comment.