@@ -46,45 +46,8 @@ class HealthIcon extends FlxSprite
4646 if (! Paths .fileExists (' images/' + name + ' .png' , IMAGE )) name = ' icons/icon-face' ; // Prevents crash from missing icon
4747 var file : Dynamic = Paths .image (name );
4848
49- var jsonPath : String = name ;
50- var jsonData : Dynamic = null ;
51-
52- // Try to load JSON file
53- if (Paths .fileExists (jsonPath , TEXT )) {
54- try {
55- jsonData = haxe. Json .parse (Paths .modsImagesJson (jsonPath ));
56- } catch (e : Dynamic ) {
57- trace (' Invalid JSON file: ' + jsonPath );
58- }
59- }
60-
61- // Determine type based on JSON or fallback to size-based guessing
62- if (jsonData != null && Reflect .hasField (jsonData , ' type' )) {
63- var jsonType : String = jsonData .type ;
64- switch (jsonType ) {
65- case ' SINGLE' : type = SINGLE ;
66- case ' DEFAULT' : type = DEFAULT ;
67- case ' WINNING' : type = WINNING ;
68- default :
69- trace (' Invalid type in JSON: ' + jsonType );
70- loadGraphic (file ); // Load to guess size
71- type = (width < 200 ? SINGLE : ((width > 199 && width < 301 ) ? DEFAULT : WINNING ));
72- }
73- } else {
74- loadGraphic (file ); // Load to guess size
75- type = (width < 200 ? SINGLE : ((width > 199 && width < 301 ) ? DEFAULT : WINNING ));
76-
77- trace (' No JSON file found, guessing type based on size: ' + type + ' (' + width + ' px)' );
78-
79- // Create or update JSON file with guessed type
80- jsonData = { type : switch (type ) {
81- case SINGLE : ' SINGLE' ;
82- case DEFAULT : ' DEFAULT' ;
83- case WINNING : ' WINNING' ;
84- }};
85- sys.io. File .saveContent (jsonPath , haxe. Json .stringify (jsonData , null , ' \t ' ));
86- trace (' Remembering this type for future use: ' + jsonPath );
87- }
49+ loadGraphic (file ); // Load stupidly first for getting the file size
50+ type = (width < 200 ? SINGLE : ((width > 199 && width < 301 ) ? DEFAULT : WINNING ));
8851
8952 loadGraphic (file , true , Math .floor (width / (type + 1 )), Math .floor (height ));
9053 iconOffsets [0 ] = iconOffsets [1 ] = (width - 150 ) / (type + 1 );
0 commit comments