Made the chart editor read the xml for the icons

This commit is contained in:
NeeEoo
2023-06-10 12:47:40 +02:00
parent 256c7ae40a
commit c3e42e0f7e
6 changed files with 45 additions and 5 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE codename-engine-character>
<character isPlayer="false" flipX="false" isGF="true" x="75" y="335">
<character isPlayer="false" flipX="false" isGF="true" x="75" y="335" icon="gf">
<anim name="danceLeft" anim="GF Dancing Beat Hair blowing CAR" fps="24" loop="false" x="0" y="0" indices="30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14" />
<anim name="danceRight" anim="GF Dancing Beat Hair blowing CAR" fps="24" loop="false" x="0" y="0" indices="15,16,17,18,19,20,21,22,23,24,25,26,27,28,29" />
</character>
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE codename-engine-character>
<character isPlayer="false" flipX="false" isGF="true" x="115" y="325">
<character isPlayer="false" flipX="false" isGF="true" x="115" y="325" icon="gf">
<anim name="cheer" anim="GF Cheer" fps="24" loop="false" />
<anim name="singUP" anim="GF Up Note" fps="24" loop="false" x="0" y="4" />
<anim name="singLEFT" anim="GF left note" fps="24" loop="false" x="0" y="-19" />
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE codename-engine-character>
<character isPlayer="false" flipX="false" isGF="true" x="100" y="275">
<character isPlayer="false" flipX="false" isGF="true" x="100" y="275" icon="gf">
<anim name="danceLeft" anim="GF Dancing at Gunpoint" fps="24" loop="false" indices="30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14" />
<anim name="danceRight" anim="GF Dancing at Gunpoint" fps="24" loop="false" indices="15,16,17,18,19,20,21,22,23,24,25,26,27,28,29" />
<anim name="dance-cutscene" anim="GF Dancing at Gunpoint" fps="24" loop="true" />
@@ -1,5 +1,6 @@
package funkin.editors.charter;
import funkin.game.Character;
import funkin.backend.system.Conductor;
import funkin.game.HealthIcon;
import funkin.backend.chart.ChartData.ChartEvent;
@@ -43,8 +44,10 @@ class CharterEvent extends UISliceSprite {
var state = cast(FlxG.state, Charter);
if (event.params != null && event.params[0] != null && event.params[0] >= 0 && event.params[0] < state.strumLines.length) {
// camera movement, use health icon
var healthIcon = new HealthIcon('${state.strumLines.members[event.params[0]].strumLine.characters[0]}');
var icon = Character.getIconFromCharName(state.strumLines.members[event.params[0]].strumLine.characters[0]);
var healthIcon = new HealthIcon(icon);
healthIcon.setUnstretchedGraphicSize(32, 32, false);
healthIcon.active = false;
healthIcon;
} else
generateDefaultIcon(event.name);
@@ -1,5 +1,6 @@
package funkin.editors.charter;
import funkin.game.Character;
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
import funkin.editors.ui.UITopMenu.UITopMenuButton;
import funkin.game.HealthIcon;
@@ -21,7 +22,9 @@ class CharterStrumline extends UISprite {
scrollFactor.set(1, 0);
alpha = 0;
healthIcon = new HealthIcon(strumLine.characters != null ? strumLine.characters[0] : null);
var icon = Character.getIconFromCharName(strumLine.characters != null ? strumLine.characters[0] : null);
healthIcon = new HealthIcon(icon);
healthIcon.scale.set(80 / 150, 80 / 150);
healthIcon.updateHitbox();
if(strumLine.visible == null)
+34
View File
@@ -361,6 +361,40 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public inline function getIcon() {
return (icon != null) ? icon : curCharacter;
}
public static function getIconFromCharName(?curCharacter:String) {
if(curCharacter == null) return "face";
var icon = curCharacter;
while(true) {
switch (curCharacter)
{
// case 'your-char': // To hardcode characters icons
default:
// load xml
var xmlPath = Paths.xml('characters/$curCharacter');
if (!Assets.exists(xmlPath)) {
curCharacter = "bf";
continue;
}
var xml = null;
var plainXML = Assets.getText(xmlPath);
try {
var charXML = Xml.parse(plainXML).firstElement();
if (charXML == null) throw new Exception("Missing \"character\" node in XML.");
xml = new Access(charXML);
} catch(e) {
Logs.trace('Error while loading character ${curCharacter}: ${e}', ERROR);
curCharacter = "bf";
continue;
}
if (xml.has.icon) icon = xml.att.icon;
}
break;
}
return icon;
}
}
typedef CharacterShadowFrame = {