Skip to content

Commit

Permalink
source code cleanup part 2
Browse files Browse the repository at this point in the history
smaller commit this time.
just general fixes for now
  • Loading branch information
TheRealJake12 committed Oct 20, 2024
1 parent e00215d commit 78657ba
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 170 deletions.
2 changes: 1 addition & 1 deletion assets/shared/data/editors/character.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</vbox>
<menu-separator />
<hbox>
<label text="Animation Name" verticalAlign="center" />
<label text="Icon Animation Name" verticalAlign="center" />
<textfield id="charIconAnimName" text="" verticalAlign="center" />
</hbox>
</vbox>
Expand Down
Binary file removed assets/shared/music/ke_freakyMenu.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion source/kec/backend/WeekData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Week
{
public static function loadJSONFile(week:String):WeekData
{
var rawJson = Paths.loadJSON('weeks/$week');
var rawJson = Paths.loadJSON('data/weeks/$week');
return parseWeek(rawJson);
}

Expand Down
5 changes: 2 additions & 3 deletions source/kec/backend/util/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Paths
// MISC

public static function video(file:String)
return getPath('videos/$file');
return 'assets/videos/$file';

// GRAPHICS

Expand All @@ -105,8 +105,7 @@ class Paths
if (!OpenFlAssets.exists(img, IMAGE))
{
Debug.logWarn("Couldn't Find Asset At " + img);
path = 'missingMod';
img = getPath('images/missingMod.png');
// shouldn't override it because flixel will handle it for you incase it's an atlas
return null;
}
if (graphics.exists(path))
Expand Down
83 changes: 83 additions & 0 deletions source/kec/objects/MenuButton.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package kec.objects;

/**
* A Multipurpose Button Useful For Many Menus.
Author : TheRealJake_12
*/
class MenuButton extends FlxSprite
{
public var onClick:() -> Void;
public var onRelease:() -> Void;
public var onHover:() -> Void;
public var onExit:() -> Void;
public var blockInput:Bool = false;
public var targSize:Float = 1.0;

private var _hoverCheck:Bool = false;

/**
* An All Purpose Button Used For Main Menu.
* @param x The Starting X Position.
* @param y The Starting Y Position.
* @param image The Image To Load. Has To Be In The `shared/images` Folder. Can Load Any Subfolders From There.
* @param atlas If It Should Look For A SparrowAtlas Instead
*/
public function new(x:Float, y:Float, image:String = "", ?atlas:Bool = false)
{
super(x, y);

onClick = function()
{
};
onRelease = function()
{
};
onHover = function()
{
};
onExit = function()
{
};
loadImage(image, atlas);
}

public function loadImage(path:String, atlas:Bool)
{
switch (atlas)
{
case true:
frames = Paths.getSparrowAtlas(path);
case false:
loadGraphic(Paths.image(path));
}
}

override function update(elapsed:Float)
{
super.update(elapsed);
if (blockInput)
return;

final lerp = CoolUtil.smoothLerp(scale.x, targSize, elapsed, 0.2);
scale.set(lerp, lerp);

if (FlxG.mouse.overlaps(this) && !_hoverCheck)
{
_hoverCheck = true;
onHover();
}
else if (!FlxG.mouse.overlaps(this) && _hoverCheck)
{
_hoverCheck = false;
onExit();
}
if (FlxG.mouse.overlaps(this))
{
if (FlxG.mouse.justPressed)
onClick();
else if (FlxG.mouse.justReleased)
onRelease();
}
}
}
2 changes: 1 addition & 1 deletion source/kec/objects/MenuCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MenuCharacter extends FlxSprite
visible = false;
dontPlayAnim = true;
default:
var jsonPath:String = 'menuCharacters/' + character;
var jsonPath:String = 'data/menuCharacters/' + character;

var charJson:MenuCharData = cast Paths.loadJSON(jsonPath);
var frameRate = charJson.frameRate == null ? 24 : charJson.frameRate;
Expand Down
2 changes: 1 addition & 1 deletion source/kec/states/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class FreeplayState extends MusicBeatState

if (!Constants.freakyPlaying)
{
FlxG.sound.playMusic(Paths.music(FlxG.save.data.watermark ? "freakyMenu" : "ke_freakyMenu"));
FlxG.sound.playMusic(Paths.music("freakyMenu"));
Constants.freakyPlaying = true;
Conductor.bpm = 102;
}
Expand Down
Loading

0 comments on commit 78657ba

Please sign in to comment.