Skip to content

Commit

Permalink
make healthbar be UI skin dependant
Browse files Browse the repository at this point in the history
also made some changes to titlescreen n stuff, just so I don't use a dynamic object (typedef) and instead use a class.
  • Loading branch information
crowplexus committed Nov 24, 2023
1 parent 4a105ce commit 53f8f2f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
6 changes: 5 additions & 1 deletion source/funkin/objects/PlayField.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ class PlayField extends FlxGroup {

final hbY:Float = Settings.downScroll ? FlxG.height * 0.1 : FlxG.height * 0.875;

add(healthBar = new ProgressBar(0, hbY, "images/ui/normal/healthBar"));
var hbPath:String = 'images/ui/${skin}/healthBar';
if (!Tools.fileExists(AssetHelper.getPath(hbPath, IMAGE)))
hbPath = hbPath.replace(skin, "normal");

add(healthBar = new ProgressBar(0, hbY, hbPath));
healthBar.screenCenter(X);

add(iconP1 = new HealthIcon(PlayState.current?.player?.icon ?? "face", true));
Expand Down
6 changes: 3 additions & 3 deletions source/funkin/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ class PlayState extends FNFState {
}

override function onStep(step:Int):Void {
var soundTime:Float = vocals.time / 1000.0;
final soundTime:Float = vocals.time / 1000.0;
if (Math.abs(Conductor.time - soundTime) > 20.0)
vocals.time = FlxG.sound.music.time;
callFunPack("onStep", [step]);
}

override function onBar(bar:Int):Void {
for (contextNames in ["onBar", "onSection", "onMeasure"])
callFunPack(contextNames, [bar]);
final names:Array<String> = ["onBar", "onSection", "onMeasure"];
for (contextNames in names) callFunPack(contextNames, [bar]);
}

function doDancersDance(beat:Int, ?forced:Bool = false):Void {
Expand Down
22 changes: 8 additions & 14 deletions source/funkin/states/menus/TitleScreen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import forever.display.ForeverSprite;
import funkin.states.base.FNFState;
import funkin.ui.Alphabet;

typedef IntroTextSection = {
public var exec:String;
@:structInit class IntroTextSection {
public var exec:String; // TODO: make this a void but let YAML still use it as string
@:optional public var beat:Int;
@:optional public var text:String;
@:optional public var force:Bool;
Expand Down Expand Up @@ -42,15 +42,13 @@ class TitleScreen extends FNFState {
final introData = AssetHelper.parseAsset("data/titleScreen", YAML);
if (introData.introSections != null) {
introSections = [];

final dataArray:Array<Dynamic> = introData.introSections;
for (i in dataArray) {
if (i.exec == null)
continue;
if (i.exec == null) continue;
introSections.push({
beat: i.beat,
step: i.step,
text: i.text,
exec: i.exec,
beat: i.beat, step: i.step,
text: i.text, exec: i.exec,
force: i.force
});
}
Expand Down Expand Up @@ -152,18 +150,14 @@ class TitleScreen extends FNFState {
gfBopped = !gfBopped;
}

if (seenIntro)
return;

if (seenIntro) return;
for (i in 0...introSections.length)
if (introSections[i].beat == beat)
parseIntroEvent(introSections[i]);
}

override function onStep(step:Int):Void {
if (seenIntro)
return;

if (seenIntro) return;
for (i in 0...introSections.length)
if (introSections[i].step == step)
parseIntroEvent(introSections[i]);
Expand Down

0 comments on commit 53f8f2f

Please sign in to comment.