Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
made some of the code smaller for making scoreTxt and botplayTxt
The Vanilla scoreTxt is now more accurately positioned

The disappearing speed of the ratings is no longer reliant on BPM (no, this doesn't break the ratings (i think))
  • Loading branch information
JordanSantiagoYT committed Nov 8, 2024
1 parent 8a1688e commit 585e06a
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 199 deletions.
2 changes: 1 addition & 1 deletion source/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class CoolUtil
return str.substr(0, str.length-prec) + '.'+str.substr(str.length-prec);
}
}
public static function getHealthColors(char:Character, precision:Int = 0):Array<Int>
public static function getHealthColors(char:Character):Array<Int>
{
if (char != null) return char.healthColorArray;
else return [255,0,0];
Expand Down
282 changes: 84 additions & 198 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1335,35 +1335,27 @@ class PlayState extends MusicBeatState
timeBar.destroy();
}

if (ClientPrefs.watermarkStyle == 'Vanilla') {
EngineWatermark = new FlxText(4,FlxG.height * 0.9 + 50,0,"", 16);
EngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, OUTLINE,FlxColor.BLACK);
EngineWatermark.scrollFactor.set();
add(EngineWatermark);
EngineWatermark.text = SONG.song + " " + CoolUtil.difficultyString() + " | JSE " + MainMenuState.psychEngineJSVersion;
}
if (ClientPrefs.watermarkStyle == 'Forever Engine') {
EngineWatermark = new FlxText(0, FlxG.height - 30, 0, "JS Engine v" + MainMenuState.psychEngineJSVersion, 16);
EngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, OUTLINE,FlxColor.BLACK);
EngineWatermark.updateHitbox();
EngineWatermark.x = FlxG.width - EngineWatermark.width - 5;
EngineWatermark.scrollFactor.set();
add(EngineWatermark);
}
if (ClientPrefs.watermarkStyle == 'JS Engine') {
EngineWatermark = new FlxText(4,FlxG.height * 0.1 - 70,0,"", 15);
EngineWatermark.setFormat(Paths.font("vcr.ttf"), 18, FlxColor.WHITE, RIGHT, OUTLINE,FlxColor.BLACK);
EngineWatermark.scrollFactor.set();
if (ClientPrefs.downScroll) EngineWatermark.y = (FlxG.height * 0.9 + 50);
add(EngineWatermark);
EngineWatermark.text = "You are now playing " + SONG.song + " on " + CoolUtil.difficultyString() + "! (JSE v" + MainMenuState.psychEngineJSVersion + ")";
}
if (ClientPrefs.watermarkStyle == 'Dave Engine') {
EngineWatermark = new FlxText(4,FlxG.height * 0.9 + 50,0,"", 16);
EngineWatermark.setFormat(Paths.font("comic.ttf"), 16, FlxColor.WHITE, RIGHT, OUTLINE,FlxColor.BLACK);
EngineWatermark.scrollFactor.set();
add(EngineWatermark);
EngineWatermark.text = SONG.song;
//figured i'd optimize the code for the enginewatermark creation. after all a lot of lines here were mostly the same

EngineWatermark = new FlxText(4,FlxG.height * 0.9 + 50,0,"", 16);
EngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, OUTLINE,FlxColor.BLACK);
EngineWatermark.scrollFactor.set();
add(EngineWatermark);

switch(ClientPrefs.watermarkStyle)
{
case 'Vanilla': EngineWatermark.text = SONG.song + " " + CoolUtil.difficultyString() + " | JSE " + MainMenuState.psychEngineJSVersion;
case 'Forever Engine':
EngineWatermark.text = "JS Engine v" + MainMenuState.psychEngineJSVersion;
EngineWatermark.x = FlxG.width - EngineWatermark.width - 5;
case 'JS Engine':
if (!ClientPrefs.downScroll) EngineWatermark.y = FlxG.height * 0.1 + 50;
EngineWatermark.text = "Playing " + SONG.song + " on " + CoolUtil.difficultyString() + " - JSE v" + MainMenuState.psychEngineJSVersion;
case 'Dave Engine':
EngineWatermark.setFormat(Paths.font("comic.ttf"), 16, FlxColor.WHITE, RIGHT, OUTLINE,FlxColor.BLACK);
EngineWatermark.text = SONG.song;

default:
}

if (ClientPrefs.showcaseMode && !ClientPrefs.charsAndBG) {
Expand All @@ -1383,97 +1375,41 @@ class PlayState extends MusicBeatState
}

// TODO: cleanup playstate, by moving most of this and other duplicate functions like healthbop, etc
if (ClientPrefs.scoreStyle == 'Kade Engine')
{
scoreTxt = new FlxText(0, healthBarBG.y + 50, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, CENTER, OUTLINE,FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'JS Engine')
{
scoreTxt = new FlxText(0, healthBarBG.y + 50, FlxG.width, "", 18);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 18, FlxColor.fromRGB(dad.healthColorArray[0], dad.healthColorArray[1], dad.healthColorArray[2]), CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 2;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'Leather Engine')
{
scoreTxt = new FlxText(0, healthBarBG.y + 50, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, CENTER, OUTLINE,FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'Dave Engine')
{
scoreTxt = new FlxText(0, healthBarBG.y + 40, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("comic.ttf"), 20, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1.25;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'Psych Engine')
{
scoreTxt = new FlxText(0, healthBarBG.y + 36, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 20, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1.25;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'Doki Doki+')
{
scoreTxt = new FlxText(0, healthBarBG.y + 48, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("Aller_rg.ttf"), 20, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1.25;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'TGT V4')
{
scoreTxt = new FlxText(0, healthBarBG.y + 48, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("calibri.ttf"), 20, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1.25;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'VS Impostor')
{
scoreTxt = new FlxText(0, healthBarBG.y + 36, FlxG.width, "", 20);
scoreTxt.scrollFactor.set();
scoreTxt.setFormat(Paths.font("vcr.ttf"), 20, FlxColor.fromRGB(dad.healthColorArray[0], dad.healthColorArray[1], dad.healthColorArray[2]), CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1.25;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'Forever Engine')
{
scoreTxt = new FlxText(0, healthBarBG.y + 40, FlxG.width, "", 18);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 18, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.borderSize = 1.25;
updateScore();
scoreTxt.scrollFactor.set();
add(scoreTxt);
}
if (ClientPrefs.scoreStyle == 'Vanilla')
scoreTxt = new FlxText(0, healthBarBG.y + 50, FlxG.width, "", 20);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, CENTER, OUTLINE,FlxColor.BLACK);
scoreTxt.scrollFactor.set();
scoreTxt.borderSize = 1;
scoreTxt.visible = !ClientPrefs.hideHud || !ClientPrefs.showcaseMode;
add(scoreTxt);

var style:String = ClientPrefs.scoreStyle;
var dadColors:Array<Int> = CoolUtil.getHealthColors(dad);

switch(style)
{
scoreTxt = new FlxText(300, healthBarBG.y + 50, FlxG.width, "", 18);
scoreTxt.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.borderSize = 1.25;
updateScore();
scoreTxt.scrollFactor.set();
add(scoreTxt);
}
case 'Kade Engine', 'Leather Engine': //do nothing lmao
case 'JS Engine':
scoreTxt.setFormat(Paths.font("vcr.ttf"), 18, FlxColor.fromRGB(dadColors[0], dadColors[1], dadColors[2]), CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.borderSize = 2;

case 'Dave Engine', 'Psych Engine', 'VS Impostor':
scoreTxt.y = healthBarBG.y + (style == 'Dave Engine' ? 40 : 36);
scoreTxt.setFormat(Paths.font((style == 'Dave Engine' ? "comic.ttf" : "vcr.ttf")), 20, (style != 'VS Impostor' ? FlxColor.WHITE : FlxColor.fromRGB(dadColors[0], dadColors[1], dadColors[2])), CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.borderSize = 1.25;

case 'Doki Doki+', 'TGT V4':
scoreTxt.y = healthBarBG.y + 48;
scoreTxt.setFormat(Paths.font((ClientPrefs.scoreStyle == 'TGT V4' ? "calibri.ttf" : "Aller_rg.ttf")), 20, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.borderSize = 1.25;

case 'Forever Engine', 'Vanilla':
if (style == 'Vanilla') scoreTxt.x = 200;
scoreTxt.y = healthBarBG.y + (style == 'Forever Engine' ? 40 : 30);
scoreTxt.setFormat(Paths.font("vcr.ttf"), (style == 'Vanilla' ? 16 : 18), FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
scoreTxt.borderSize = 1.25;
updateScore();
}
style = null;
if (ClientPrefs.showcaseMode) {
scoreTxt.visible = false;
healthBarBG.visible = false;
Expand Down Expand Up @@ -1536,88 +1472,38 @@ class PlayState extends MusicBeatState
add(judgementCounter);
if (ClientPrefs.ratingCounter) updateRatingCounter();

//create default botplay text
botplayTxt = new FlxText(400, timeBarBG.y + 55, FlxG.width - 800, "BOTPLAY", 32);
botplayTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;

// just because, people keep making issues about it
try{
if (ClientPrefs.botTxtStyle == 'Vanilla')
{
botplayTxt = new FlxText(400, timeBarBG.y + 55, FlxG.width - 800, "BOTPLAY", 32);
botplayTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;
}
if (ClientPrefs.botTxtStyle == 'JS Engine')
{
botplayTxt = new FlxText(400, timeBarBG.y + 55, FlxG.width - 800, "Botplay Mode", 30);
botplayTxt.setFormat(Paths.font("vcr.ttf"), 30, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.5;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;
}
if (ClientPrefs.botTxtStyle == 'Doki Doki+')
{
botplayTxt = new FlxText(400, timeBarBG.y + 55, FlxG.width - 800, "BOTPLAY", 32);
botplayTxt.setFormat(Paths.font("Aller_rg.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;
}
if (ClientPrefs.botTxtStyle == 'TGT V4')
var botStyle = ClientPrefs.botTxtStyle;
switch(botStyle)
{
botplayTxt = new FlxText(400, timeBarBG.y + (ClientPrefs.downScroll ? -78 : 55), FlxG.width - 800, "[BUTTPLUG]", 32);
botplayTxt.setFormat(Paths.font("calibri.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;
}
if (ClientPrefs.botTxtStyle == 'Dave Engine')
{
botplayTxt = new FlxText(400, timeBarBG.y + 55, FlxG.width - 800, "BOTPLAY", 32);
botplayTxt.setFormat(Paths.font("comic.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;
}
if (ClientPrefs.botTxtStyle == 'VS Impostor')
{
botplayTxt = new FlxText(400, healthBarBG.y - 55, FlxG.width - 800, "BOTPLAY", 32);
botplayTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.fromRGB(dad.healthColorArray[0], dad.healthColorArray[1], dad.healthColorArray[2]), CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
{
botplayTxt.y = timeBarBG.y - 78;
}
case 'Vanilla': //Do nothing.
case 'JS Engine':
botplayTxt.text = 'Botplay Mode';
botplayTxt.borderSize = 1.5;

case 'Doki Doki+':
botplayTxt.setFormat(Paths.font("Aller_rg.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
case 'TGT V4':
botplayTxt.setFormat(Paths.font("calibri.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
case 'Dave Engine':
botplayTxt.setFormat(Paths.font("comic.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
case 'VS Impostor':
botplayTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.fromRGB(dadColors[0], dadColors[1], dadColors[2]), CENTER, OUTLINE, FlxColor.BLACK);
}
}
catch(e){
trace("Failed to display/create botplayTxt " + e);
// just in case, we default it to the regular psych botplayTxt
botplayTxt = new FlxText(400, timeBarBG.y + 55, FlxG.width - 800, "BOTPLAY", 32);
botplayTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK);
botplayTxt.scrollFactor.set();
botplayTxt.borderSize = 1.25;
botplayTxt.visible = cpuControlled && !ClientPrefs.showcaseMode;
add(botplayTxt);
if (ClientPrefs.downScroll)
botplayTxt.y = timeBarBG.y - 78;
trace("Failed to display/create botplayTxt: " + e);
}
if (botplayTxt != null){
if (!cpuControlled && practiceMode) {
Expand Down Expand Up @@ -5214,7 +5100,7 @@ class PlayState extends MusicBeatState

FlxTween.cancelTweensOf(spr);
comboGroup.remove(spr, true);
spr.kill();
spr.destroy();
}

if (showRating && ClientPrefs.ratingPopups && !ClientPrefs.simplePopups) {
Expand Down Expand Up @@ -5255,7 +5141,7 @@ class PlayState extends MusicBeatState
rating.updateHitbox();

FlxTween.tween(rating, {alpha: 0}, 0.2 / playbackRate, {
startDelay: Conductor.crochet * 0.001 / playbackRate,
startDelay: 0.7 / playbackRate,
onComplete: function(tween:FlxTween)
{
rating.destroy();
Expand Down Expand Up @@ -5323,7 +5209,7 @@ class PlayState extends MusicBeatState
{
numScore.destroy();
},
startDelay: Conductor.crochet * 0.002 / playbackRate
startDelay: 1.4 / playbackRate
});
}
}
Expand Down

0 comments on commit 585e06a

Please sign in to comment.