Icon Fixes
This commit is contained in:
@@ -151,7 +151,8 @@ class CharacterInfoScreen extends UISubstateWindow {
|
||||
if (iconSprite == null) add(iconSprite = new HealthIcon());
|
||||
|
||||
iconSprite.setIcon(icon);
|
||||
iconSprite.scale.set(iconSprite.defaultScale * 0.5, iconSprite.defaultScale * 0.5);
|
||||
var size = Std.int(150 * 0.5);
|
||||
iconSprite.setUnstretchedGraphicSize(size, size, true);
|
||||
iconSprite.updateHitbox();
|
||||
iconSprite.setPosition(iconTextBox.x + iconTextBox.bWidth + 8, iconTextBox.y + (iconTextBox.bHeight / 2) - (iconSprite.height / 2));
|
||||
iconSprite.scrollFactor.set(1, 1);
|
||||
|
||||
@@ -320,7 +320,8 @@ class CompactCharacterButton extends UIButton {
|
||||
autoAlpha = false;
|
||||
|
||||
charIcon = new HealthIcon(funkin.game.Character.getIconFromCharName(char));
|
||||
charIcon.scale.set(charIcon.defaultScale * 0.2, charIcon.defaultScale * 0.2);
|
||||
var size = Std.int(150 * 0.2);
|
||||
charIcon.setUnstretchedGraphicSize(size, size, true);
|
||||
charIcon.updateHitbox();
|
||||
charIcon.setPosition(10, bHeight/2 - charIcon.height / 2);
|
||||
charIcon.scrollFactor.set(1,1);
|
||||
@@ -333,7 +334,7 @@ class CompactCharacterButton extends UIButton {
|
||||
textBox.onChange = function(char:String) {
|
||||
char = funkin.game.Character.getIconFromCharName(char);
|
||||
charIcon.setIcon(char);
|
||||
charIcon.scale.set(charIcon.defaultScale * 0.2, charIcon.defaultScale * 0.2);
|
||||
charIcon.setUnstretchedGraphicSize(size, size, true);
|
||||
charIcon.updateHitbox();
|
||||
charIcon.setPosition(10, bHeight/2 - charIcon.height / 2);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,8 @@ class CharterMetaDataScreen extends UISubstateWindow {
|
||||
if (iconSprite == null) add(iconSprite = new HealthIcon());
|
||||
|
||||
iconSprite.setIcon(icon);
|
||||
iconSprite.scale.set(iconSprite.defaultScale * 0.5, iconSprite.defaultScale * 0.5);
|
||||
var size = Std.int(150 * 0.5);
|
||||
iconSprite.setUnstretchedGraphicSize(size, size, true);
|
||||
iconSprite.updateHitbox();
|
||||
iconSprite.setPosition(iconTextBox.x + iconTextBox.bWidth + 8, iconTextBox.y + (iconTextBox.bHeight / 2) - (iconSprite.height / 2));
|
||||
iconSprite.scrollFactor.set(1, 1);
|
||||
|
||||
@@ -93,7 +93,8 @@ class CharterStrumline extends UISprite {
|
||||
for (i=>icon in icons) {
|
||||
var healthIcon = new HealthIcon(Character.getIconFromCharName(icon));
|
||||
var newScale = 0.6 - (icons.length / 20);
|
||||
healthIcon.scale.x = healthIcon.scale.y = healthIcon.defaultScale * newScale;
|
||||
var size = Std.int(150 * newScale);
|
||||
healthIcon.setUnstretchedGraphicSize(size, size, true);
|
||||
healthIcon.updateHitbox();
|
||||
healthIcon.x = FlxMath.lerp(0, icons.length * 20, (icons.length-1 != 0 ? i / (icons.length-1) : 0));
|
||||
healthIcon.y = draggable ? 14 : 7;
|
||||
|
||||
@@ -194,7 +194,8 @@ class CharacterButton extends UIButton {
|
||||
super(x, y, "", null, 250, 54);
|
||||
|
||||
charIcon = new HealthIcon(Character.getIconFromCharName(char));
|
||||
charIcon.scale.set(charIcon.defaultScale * 0.3, charIcon.defaultScale * 0.3);
|
||||
var size = Std.int(150 * 0.3);
|
||||
charIcon.setUnstretchedGraphicSize(size, size, true);
|
||||
charIcon.updateHitbox();
|
||||
charIcon.setPosition(x + 10, bHeight/2 - charIcon.height / 2);
|
||||
charIcon.scrollFactor.set(1,1);
|
||||
@@ -207,7 +208,7 @@ class CharacterButton extends UIButton {
|
||||
textBox.onChange = function(char:String) {
|
||||
char = Character.getIconFromCharName(char);
|
||||
charIcon.setIcon(char);
|
||||
charIcon.scale.set(charIcon.defaultScale * 0.3, charIcon.defaultScale * 0.3);
|
||||
charIcon.setUnstretchedGraphicSize(size, size, true);
|
||||
charIcon.updateHitbox();
|
||||
charIcon.setPosition(x + 10, bHeight/2 - charIcon.height / 2);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,8 @@ class SongCreationScreen extends UISubstateWindow {
|
||||
if (iconSprite == null) menuDataGroup.add(iconSprite = new HealthIcon());
|
||||
|
||||
iconSprite.setIcon(icon);
|
||||
iconSprite.scale.set(iconSprite.defaultScale * 0.5, iconSprite.defaultScale * 0.5);
|
||||
var size = Std.int(150 * 0.5);
|
||||
iconSprite.setUnstretchedGraphicSize(size, size, true);
|
||||
iconSprite.updateHitbox();
|
||||
iconSprite.setPosition(iconTextBox.x + iconTextBox.bWidth + 8, iconTextBox.y + (iconTextBox.bHeight / 2) - (iconSprite.height / 2));
|
||||
iconSprite.scrollFactor.set(1, 1);
|
||||
|
||||
@@ -162,14 +162,18 @@ class HealthIcon extends FunkinSprite
|
||||
|
||||
animateAtlas = null; // reset
|
||||
if (this.animated)
|
||||
loadSprite(Paths.image(iconPath));
|
||||
loadSprite(Paths.image(newIconPath));
|
||||
else {
|
||||
var iconAsset:FlxGraphic = FlxG.bitmap.add(Paths.image(iconPath));
|
||||
var assetW:Float = iconAsset.width;
|
||||
var assetH:Float = iconAsset.height;
|
||||
|
||||
iconAmt = Math.floor(assetW / assetH);
|
||||
iconAmt = Math.round(assetW / assetH); // Just in case the icon is in a weird aspect ratio
|
||||
iconSize = Math.floor(assetW / iconAmt);
|
||||
if (iconSize * iconAmt > assetW) {
|
||||
iconSize = Math.floor(assetW / iconAmt);
|
||||
iconAmt = Math.floor(assetW / iconSize);
|
||||
}
|
||||
|
||||
loadGraphic(iconAsset, true, Std.int(Math.min(iconSize, assetW)), Std.int(Math.min(iconSize, assetH)));
|
||||
|
||||
@@ -238,8 +242,20 @@ class HealthIcon extends FunkinSprite
|
||||
|
||||
var animName = node.get("name");
|
||||
|
||||
if (node.exists("offsetX") || node.exists("offsetY"))
|
||||
addOffset(animName, Std.parseFloat(node.get("offsetX")).getDefault(0), Std.parseFloat(node.get("offsetY")).getDefault(0));
|
||||
var offsetX:Float = 0;
|
||||
var offsetY:Float = 0;
|
||||
if (node.exists("offsetX"))
|
||||
offsetX = Std.parseFloat(node.get("offsetX")).getDefault(0);
|
||||
else if (node.exists("offsetx"))
|
||||
offsetX = Std.parseFloat(node.get("offsetx")).getDefault(0);
|
||||
|
||||
if (node.exists("offsetY"))
|
||||
offsetY = Std.parseFloat(node.get("offsetY")).getDefault(0);
|
||||
else if (node.exists("offsety"))
|
||||
offsetY = Std.parseFloat(node.get("offsety")).getDefault(0);
|
||||
|
||||
addOffset(animName, offsetX, offsetY);
|
||||
|
||||
addAnim(animName, node.get("anim"), Std.parseInt(node.get("fps")).getDefault(24), node.get("looped").getDefault("true").toLowerCase() == "true");
|
||||
if (animateAtlas == null && animation.exists(animName))
|
||||
animation.getByName(animName).flipX = isPlayer != iconIsPlayer;
|
||||
@@ -299,6 +315,8 @@ class HealthIcon extends FunkinSprite
|
||||
}
|
||||
|
||||
defaultScale = (xmlValid && xmlData.exists("scale")) ? Std.parseFloat(xmlData.get("scale")).getDefault(scale.x) : scale.x;
|
||||
scale.set(defaultScale, defaultScale);
|
||||
updateHitbox();
|
||||
}
|
||||
|
||||
var normalizedNames = ["neutral", "losing", "winning"];
|
||||
|
||||
@@ -141,6 +141,8 @@ class FreeplayState extends MusicBeatState
|
||||
|
||||
var icon:HealthIcon = new HealthIcon(songs[i].icon);
|
||||
icon.sprTracker = songText;
|
||||
icon.setUnstretchedGraphicSize(150, 150, true);
|
||||
icon.updateHitbox();
|
||||
|
||||
// using a FlxGroup is too much fuss!
|
||||
iconArray.push(icon);
|
||||
|
||||
@@ -10,6 +10,10 @@ class IconOption extends TextOption {
|
||||
|
||||
iconSpr = new HealthIcon(icon, false);
|
||||
iconSpr.setPosition(90 - iconSpr.width, (__text.height - iconSpr.height) / 2);
|
||||
iconSpr.setUnstretchedGraphicSize(150, 150, true);
|
||||
iconSpr.updateHitbox();
|
||||
iconSpr.sprTracker = __text;
|
||||
iconSpr.sprTrackerAlignment = LEFT;
|
||||
add(iconSpr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user