Skip to content

Commit 18d46c3

Browse files
i think this is simpler
apologies for removing the legacy code and the code for the other types of icons, i think this is the most straightforward system. if there's bugs i'll try to correct them soon! i cant do it right now unfortunately
1 parent 2cb5eba commit 18d46c3

File tree

1 file changed

+18
-62
lines changed

1 file changed

+18
-62
lines changed

source/HealthIcon.hx

Lines changed: 18 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ typedef IconMeta = {
1313
?fps:Int,
1414
// ?frameOrder:Array<String> // ["normal", "losing", "winning"]
1515
// ?isAnimated:Bool,
16-
?hasWinIcon:Bool,
17-
?useLegacySystem:Bool
16+
?hasWinIcon:Bool
1817
}
1918
class HealthIcon extends FlxSprite
2019
{
@@ -67,38 +66,12 @@ class HealthIcon extends FlxSprite
6766
// throw "Don't delete the placeholder icon";
6867
trace("Warning: could not find the placeholder icon, expect crashes!");
6968
}
70-
// TODO: clean up this fucking mess
71-
// yanderedev code
72-
final iSize:Float = Math.round(iconAsset.width / iconAsset.height);
73-
if (iconMeta?.useLegacySystem)
74-
{
75-
loadGraphic(iconAsset, true, Math.floor(iconAsset.width / iSize), Math.floor(iconAsset.height));
76-
initialWidth = width;
77-
initialHeight = height;
78-
iconOffsets[0] = (width - 150) / iSize;
79-
iconOffsets[1] = (height - 150) / iSize;
80-
81-
updateHitbox();
8269

83-
animation.add(char, [for(i in 0...frames.frames.length) i], 0, false, isPlayer);
84-
}
85-
else if (iconAsset.width == 300) {
86-
loadGraphic(iconAsset, true, Math.floor(iconAsset.width / 2), Math.floor(iconAsset.height));
87-
iconOffsets[0] = (width - 150) / iSize;
88-
iconOffsets[1] = (height - 150) / iSize;
89-
initialWidth = width;
90-
initialHeight = height;
91-
updateHitbox();
92-
animation.add(char, [0, 1], 0, false, isPlayer);
93-
} else if (iconAsset.width == 450) {
94-
loadGraphic(iconAsset, true, Math.floor(iconAsset.width / 3), Math.floor(iconAsset.height));
95-
iconOffsets[0] = (width - 150) / iSize;
96-
iconOffsets[1] = (height - 150) / iSize;
97-
initialWidth = width;
98-
initialHeight = height;
99-
updateHitbox();
100-
animation.add(char, [0, 1, 2], 0, false, isPlayer);
101-
} else if (Paths.fileExists('images/$name.xml', TEXT)) {
70+
//cleaned up to be less confusing. also floor is used so iSize has to definitively be 3 to use winning icons
71+
final iSize:Float = Math.floor(iconAsset.width / iconAsset.height);
72+
initialWidth = width;
73+
initialHeight = height;
74+
if (Paths.fileExists('images/$name.xml', TEXT)) {
10275
frames = Paths.getSparrowAtlas(name);
10376
final iconPrefixes = checkAvailablePrefixes(Paths.getPath('images/$name.xml', TEXT));
10477
final hasWinning = iconPrefixes.get('winning');
@@ -115,32 +88,16 @@ class HealthIcon extends FlxSprite
11588
// Add "winning", fallback to "normal"
11689
animation.addByPrefix('winning', hasWinning ? 'winning' : 'normal', fps, loop, isPlayer);
11790
playAnim('normal');
118-
} else { // This is just an attempt for other icon support, will detect is less than 300 or more than 300. If 300 or less, only 2 icons, if more, 3 icons.
119-
var num:Int = Std.int(Math.round(iconAsset.width / iconAsset.height));
120-
if (iconAsset.width % iconAsset.height != 0 || num >= 4) {
121-
// weird icon, maybe has padding?
122-
num = 3; // fallback
91+
} else {
92+
if (iconMeta?.hasWinIcon || iSize == 3) {
93+
loadGraphic(file, true, Math.floor(width / 3), Math.floor(height)); //Then load it fr // winning icons go br
94+
iconOffsets[0] = (width - 150) / 3;
95+
iconOffsets[1] = (height - 150) / 3;
96+
} else {
97+
loadGraphic(file, true, Math.floor(width / 2), Math.floor(height)); //Then load it fr // winning icons go br
98+
iconOffsets[0] = (width - 150) / 2;
99+
iconOffsets[1] = (height - 150) / 2;
123100
}
124-
if (iconAsset.width < 300) {
125-
num = 2;
126-
} else if (iconAsset.width >= 300) {
127-
num = 3;
128-
}
129-
130-
loadGraphic(iconAsset, true, Math.floor(iconAsset.width / num), Math.floor(iconAsset.height));
131-
iconOffsets[0] = (width - 150) / iSize;
132-
iconOffsets[1] = (height - 150) / iSize;
133-
initialWidth = width;
134-
initialHeight = height;
135-
updateHitbox();
136-
137-
function getWinIcon():Array<Int>
138-
{
139-
return (iconMeta?.hasWinIcon || num == 3) ? [0, 1, 2] : [0, 1];
140-
}
141-
142-
final winShit:Array<Int> = (num == 2) ? [0, 1] : getWinIcon();
143-
animation.add(char, winShit, 0, false, isPlayer);
144101
}
145102

146103
// animation.add(char, [for(i in 0...frames.frames.length) i], 0, false, isPlayer);
@@ -203,7 +160,6 @@ class HealthIcon extends FlxSprite
203160
if (json.noAntialiasing == null) json.noAntialiasing = false;
204161
if (json.fps == null) json.fps = 24;
205162
if (json.hasWinIcon == null) json.hasWinIcon = false;
206-
if (json.useLegacySystem == null) json.useLegacySystem = false;
207163
// if (json.frameOrder == null) json.frameOrder = ['normal', 'losing', 'winning'];
208164
return json;
209165
}
@@ -212,9 +168,9 @@ class HealthIcon extends FlxSprite
212168
{
213169
if (ClientPrefs.iconBounceType != 'Golden Apple' && ClientPrefs.iconBounceType != 'Dave and Bambi' || !Std.isOfType(FlxG.state, PlayState))
214170
{
215-
super.updateHitbox();
216-
offset.x = iconOffsets[0];
217-
offset.y = iconOffsets[1];
171+
super.updateHitbox();
172+
offset.x = iconOffsets[0];
173+
offset.y = iconOffsets[1];
218174
} else {
219175
super.updateHitbox();
220176
if (initialWidth != (150 * animation.numFrames) || initialHeight != 150) //Fixes weird icon offsets when they're HUMONGUS (sussy)

0 commit comments

Comments
 (0)