Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
Added Song Credits, which can be placed in the new Data section in Chart Editor
Added events to toggle camera bouncing
Fixed icon positions
Added SUtil.getPath to paths, hoping to fix crashes on Android builds
Added the timebar color change from Leather Engine
  • Loading branch information
JordanSantiagoYT committed Oct 15, 2023
1 parent 54aca3a commit 1ba9fb8
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 17 deletions.
Binary file added assets/shared/images/JSEHeading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions source/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ class CoolUtil
return difficulties[PlayState.storyDifficulty].toUpperCase();
}

public static function getMinAndMax(value1:Float, value2:Float):Array<Float>
{
var minAndMaxs = new Array<Float>();

var min = Math.min(value1, value2);
var max = Math.max(value1, value2);

minAndMaxs.push(min);
minAndMaxs.push(max);

return minAndMaxs;
}

inline public static function boundTo(value:Float, min:Float, max:Float):Float {
return Math.max(min, Math.min(max, value));
}
Expand Down
92 changes: 92 additions & 0 deletions source/CreditsPopUp.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package;

import sys.FileSystem;
import flixel.group.FlxSpriteGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.FlxObject;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import flixel.FlxSprite;
import flixel.math.FlxMath;

typedef SongHeading = {
var path:String;
var antiAliasing:Bool;
var iconOffset:Float;
}
class CreditsPopUp extends FlxSpriteGroup
{
public var bg:FlxSprite;
public var bgHeading:FlxSprite;

public var funnyText:FlxText;
var curHeading:SongHeading;

public function new(x:Float, y:Float)
{
super(x, y);
bg = new FlxSprite().makeGraphic(400, 50, FlxColor.WHITE);
add(bg);
var songCreator:String = '';
var headingPath:SongHeading = null;

songCreator = PlayState.SONG.songCredit;
headingPath = {path: 'JSEHeading', antiAliasing: false, iconOffset: 0};

if (headingPath != null)
{
bg.loadGraphic(Paths.image(headingPath.path));
bg.antialiasing = headingPath.antiAliasing;
curHeading = headingPath;
}
createHeadingText("Song by" + ' ' + songCreator);

rescaleBG();

var yValues = CoolUtil.getMinAndMax(bg.height, funnyText.height);
funnyText.y = funnyText.y + ((yValues[0] - yValues[1]) / 2);
}
public function switchHeading(newHeading:SongHeading)
{
if (bg != null)
{
remove(bg);
}
bg = new FlxSprite().makeGraphic(400, 50, FlxColor.WHITE);
if (newHeading != null)
{
bg.loadGraphic(Paths.image(newHeading.path));
}
bg.antialiasing = newHeading.antiAliasing;
curHeading = newHeading;
add(bg);

rescaleBG();
}
public function changeText(newText:String, rescaleHeading:Bool = true)
{
createHeadingText(newText);

if (rescaleHeading)
{
rescaleBG();
}
}
function createHeadingText(text:String)
{
if (funnyText != null)
{
remove(funnyText);
}
funnyText = new FlxText(1, 0, 650, text, 16);
funnyText.setFormat('vcr.ttf', 30, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
funnyText.borderSize = 2;
funnyText.antialiasing = true;
add(funnyText);
}
function rescaleBG()
{
bg.setGraphicSize(Std.int((funnyText.textField.textWidth + 0.5)), Std.int(funnyText.height + 0.5));
bg.updateHitbox();
}
}
18 changes: 18 additions & 0 deletions source/GameplayChangersSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GameplayChangersSubstate extends MusicBeatSubstate
private var checkboxGroup:FlxTypedGroup<CheckboxThingie>;
private var grpTexts:FlxTypedGroup<AttachedText>;
public static var inThePauseMenu:Bool = false;
public var pauseState:PauseSubState;

function getOptions()
{
Expand Down Expand Up @@ -113,6 +114,7 @@ class GameplayChangersSubstate extends MusicBeatSubstate
option.onChange = onChangeBotplay; //Changing onChange is only needed if you want to make a special interaction after it changes the value

var option:GameplayOption = new GameplayOption('Play as Opponent', 'opponentplay', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Opponent Health Drain', 'opponentdrain', 'bool', false);
Expand All @@ -127,21 +129,27 @@ class GameplayChangersSubstate extends MusicBeatSubstate
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Random Mode', 'randommode', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Stair Mode', 'stairmode', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Wave Mode', 'wavemode', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Flip Mode', 'flip', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('One Key', 'onekey', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Jack Amount: ', 'jacks', 'float', 0);
option.onChange = onChangeChartOption;
option.scrollSpeed = 6;
option.minValue = 0;
option.maxValue = 100;
Expand All @@ -150,9 +158,11 @@ class GameplayChangersSubstate extends MusicBeatSubstate
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Random Playback Rate', 'randomspeed', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);

var option:GameplayOption = new GameplayOption('Troll Mode', 'thetrollingever', 'bool', false);
option.onChange = onChangeChartOption;
optionsArray.push(option);
}

Expand Down Expand Up @@ -459,6 +469,14 @@ class GameplayChangersSubstate extends MusicBeatSubstate
PlayState.playerIsCheating = true;
}
}
function onChangeChartOption()
{
if(inThePauseMenu)
{
trace ("HEY! You changed an option that requires a chart restart!");
PauseSubState.requireRestart = true;
}
}
function onChangeBotplay()
{
if(inThePauseMenu)
Expand Down
13 changes: 13 additions & 0 deletions source/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package;
import flixel.math.FlxMath;
import flixel.FlxSprite;
import openfl.utils.Assets as OpenFlAssets;
import flixel.FlxG;

using StringTools;

Expand Down Expand Up @@ -87,6 +88,18 @@ class HealthIcon extends FlxSprite
}
}

override function updateHitbox()
{
if (ClientPrefs.iconBounceType != 'Golden Apple' && ClientPrefs.iconBounceType != 'Dave and Bambi' || Type.getClassName(Type.getClass(FlxG.state)) != 'PlayState')
{
super.updateHitbox();
offset.x = iconOffsets[0];
offset.y = iconOffsets[1];
} else {
super.updateHitbox();
}
}

public function getCharacter():String {
return char;
}
Expand Down
12 changes: 6 additions & 6 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -177,30 +177,30 @@ class Paths

inline static public function txt(key:String, ?library:String)
{
return getPath('data/$key.txt', TEXT, library);
return getPath(SUtil.getPath() + 'data/$key.txt', TEXT, library);
}

inline static public function xml(key:String, ?library:String)
{
return getPath('data/$key.xml', TEXT, library);
return getPath(SUtil.getPath() + 'data/$key.xml', TEXT, library);
}

inline static public function json(key:String, ?library:String)
{
return getPath('data/$key.json', TEXT, library);
return getPath(SUtil.getPath() + 'data/$key.json', TEXT, library);
}

inline static public function shaderFragment(key:String, ?library:String)
{
return getPath('shaders/$key.frag', TEXT, library);
return getPath(SUtil.getPath() + 'shaders/$key.frag', TEXT, library);
}
inline static public function shaderVertex(key:String, ?library:String)
{
return getPath('shaders/$key.vert', TEXT, library);
return getPath(SUtil.getPath() + 'shaders/$key.vert', TEXT, library);
}
inline static public function lua(key:String, ?library:String)
{
return getPath('$key.lua', TEXT, library);
return getPath(SUtil.getPath() + '$key.lua', TEXT, library);
}
//Video loading (part of it)
static public function video(key:String)
Expand Down
14 changes: 12 additions & 2 deletions source/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ class PauseSubState extends MusicBeatSubstate
//var botplayText:FlxText;
public static var botplayLockout:Bool = false;
public static var inPause:Bool = false;
public static var requireRestart:Bool = false;

public static var songName:String = '';

public function new(x:Float, y:Float)
{
super();
if(CoolUtil.difficulties.length < 2) menuItemsOG.remove('Change Difficulty'); //No need to change difficulty if there is only one!
if(botplayLockout) menuItemsOG.remove('Toggle Botplay'); //you cant toggle it on MWAHAHAHAHAHA

if(PlayState.chartingMode)
{
Expand All @@ -54,7 +56,7 @@ class PauseSubState extends MusicBeatSubstate
}
menuItemsOG.insert(3 + num, 'End Song');
menuItemsOG.insert(4 + num, 'Toggle Practice Mode');
if (!botplayLockout) menuItemsOG.insert(5 + num, 'Toggle Botplay');
menuItemsOG.insert(5 + num, 'Toggle Botplay');
}
menuItems = menuItemsOG;

Expand Down Expand Up @@ -148,6 +150,11 @@ class PauseSubState extends MusicBeatSubstate
var cantUnpause:Float = 0.1;
override function update(elapsed:Float)
{
if(requireRestart) {
menuItemsOG.remove('Resume'); //technically that's the logical thing to do
regenMenu();
requireRestart = false;
}
cantUnpause -= elapsed;
if (pauseMusic.volume < 0.5)
pauseMusic.volume += 0.01 * elapsed;
Expand Down Expand Up @@ -269,9 +276,12 @@ class PauseSubState extends MusicBeatSubstate
case 'Toggle Botplay':
PlayState.instance.cpuControlled = !PlayState.instance.cpuControlled;
PlayState.changedDifficulty = true;
if (PlayState.instance.botplayTxt != null)
{
PlayState.instance.botplayTxt.visible = PlayState.instance.cpuControlled;
PlayState.instance.botplayTxt.alpha = 1;
PlayState.instance.botplaySine = 0;
}
case "Options":
MusicBeatState.switchState(new OptionsState());
inPause = true;
Expand Down Expand Up @@ -370,7 +380,7 @@ class PauseSubState extends MusicBeatSubstate
}
}

function regenMenu():Void {
public function regenMenu():Void {
for (i in 0...grpMenuShit.members.length) {
var obj = grpMenuShit.members[0];
obj.kill();
Expand Down
Loading

0 comments on commit 1ba9fb8

Please sign in to comment.