Skip to content

Commit 28ddb0d

Browse files
committed
new things
1 parent 973d5fb commit 28ddb0d

File tree

7 files changed

+126
-51
lines changed

7 files changed

+126
-51
lines changed

source/archipelago/APGameState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ class APGameState
586586
}
587587
});
588588

589-
_ap.toggleDeathLink(slotData != null && Reflect.hasField(slotData, "deathLink") ? slotData?.deathLink? : ClientPrefs.data.deathlink);
589+
_ap.toggleDeathLink(slotData != null && Reflect.hasField(slotData, "deathLink") ? slotData?.deathLink : ClientPrefs.data.deathlink);
590590

591591
_ap.onRetrieved.add(handleRetrievedPacket);
592592

source/backend/Paths.hx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,12 @@ class Paths
226226
clearUnusedMemory();
227227
clearStoredMemory();
228228
currentTrackedSounds.clear();
229-
@:privateAccess FlxG.bitmap._cache.clear();
230-
backend.util.MemoryUtilBase.collect(true);
229+
@:privateAccess {
230+
for (key => asset in FlxG.bitmap._cache)
231+
asset.destroy();
232+
}
233+
MemoryUtilBase.compact();
234+
MemoryUtilBase.collect(true);
231235
}
232236

233237
/** returns a FlxRuntimeShader but with file names lol **/

source/objects/HealthIcon.hx

Lines changed: 104 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ enum abstract IconType(Int) to Int from Int //abstract so it can hold int values
55
var SINGLE = 0;
66
var DEFAULT = 1;
77
var WINNING = 2;
8+
var ANIMSINGLE = 3;
9+
var ANIMDEFAULT = 4;
10+
var ANIMWINNING = 5;
11+
var ANIMSINGING = 6;
812
}
913

1014
class HealthIcon extends FlxSprite
@@ -44,6 +48,7 @@ class HealthIcon extends FlxSprite
4448
var name:String = 'icons/' + char;
4549
if(!Paths.fileExists('images/' + name + '.png', IMAGE)) name = 'icons/icon-' + char; //Older versions of psych engine's support
4650
if(!Paths.fileExists('images/' + name + '.png', IMAGE)) name = 'icons/icon-face'; //Prevents crash from missing icon
51+
4752
var file:Dynamic = Paths.image(name);
4853

4954
var jsonPath:String = haxe.io.Path.directory(Paths.file('images/icons/icons/'));
@@ -58,48 +63,110 @@ class HealthIcon extends FlxSprite
5863
}
5964
}
6065

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-
if (!sys.FileSystem.exists(jsonPath)) {
66+
if(Paths.fileExists('images/' + name + '.xml', TEXT)) { //if the icon is animated
67+
frames = Paths.getSparrowAtlas(name);
68+
69+
// Try to load JSON file
70+
if (Paths.fileExists(Paths.json(name), TEXT)) {
8671
try {
87-
var file = sys.io.File.write(jsonPath, true); // ???
88-
file.close();
89-
} catch(e) {trace("Failed to write JSON for " + char);}
72+
jsonData = haxe.Json.parse(File.getContent(Paths.json(name)));
73+
} catch (e:Dynamic) {
74+
trace('Invalid JSON file: ' + jsonPath);
75+
}
76+
var jsonType:String = jsonData.type;
77+
switch (jsonType) {
78+
case 'ANIMSINGLE': type = ANIMSINGLE;
79+
case 'ANIMDEFAULT': type = ANIMDEFAULT;
80+
case 'ANIMWINNING': type = ANIMWINNING;
81+
case 'ANIMSINGING': type = ANIMSINGING;
82+
default:
83+
trace('WRONG TYPE USED! DEFAULTING TO SINGLEANIM!');
84+
type = ANIMSINGLE;
85+
}
86+
}
87+
else {
88+
trace('ANIMATED ICON DETECTED, BUT NO ICON JSON WAS FOUND! DEFAULTING TO ANIMSINGLE');
89+
type = ANIMSINGLE;
90+
}
91+
updateHitbox();
92+
93+
switch (type) {
94+
case DEFAULT:
95+
trace('if you see this trace you messed up somewhere bro');
96+
case SINGLE:
97+
trace('if you see this trace you messed up somewhere bro');
98+
case WINNING:
99+
trace('if you see this trace you messed up somewhere bro');
100+
case ANIMSINGLE:
101+
animation.addByPrefix('idle', 'idle', 24, true);
102+
animation.play('idle');
103+
case ANIMDEFAULT:
104+
animation.addByPrefix('normal', 'normal', 24, true);
105+
animation.addByPrefix('losing', 'losing', 24, true);
106+
animation.play('normal');
107+
case ANIMWINNING:
108+
animation.addByPrefix('winning', 'winning', 24, true);
109+
animation.addByPrefix('normal', 'normal', 24, true);
110+
animation.addByPrefix('losing', 'losing', 24, true);
111+
animation.play('normal');
112+
case ANIMSINGING:
113+
animation.addByPrefix('idle', 'idle', 24, true);
114+
animation.addByPrefix('left', 'left', 24, true);
115+
animation.addByPrefix('down', 'down', 24, true);
116+
animation.addByPrefix('up', 'up', 24, true);
117+
animation.addByPrefix('right', 'right',24, true);
118+
animation.play('idle');
90119
}
91-
sys.io.File.saveContent(jsonPath, haxe.Json.stringify(jsonData, null, '\t'));
92-
//trace('Remembering this type for future use: ' + jsonPath);
93120
}
121+
else {
122+
// Determine type based on JSON or fallback to size-based guessing
123+
if (jsonData != null && Reflect.hasField(jsonData, 'type')) {
124+
var jsonType:String = jsonData.type;
125+
switch (jsonType) {
126+
case 'SINGLE': type = SINGLE;
127+
case 'DEFAULT': type = DEFAULT;
128+
case 'WINNING': type = WINNING;
129+
default:
130+
trace('Invalid type in JSON: ' + jsonType);
131+
loadGraphic(file); // Load to guess size
132+
type = (width < 200 ? SINGLE : ((width > 199 && width < 301) ? DEFAULT : WINNING));
133+
}
134+
} else {
135+
loadGraphic(file); // Load to guess size
136+
type = (width < 200 ? SINGLE : ((width > 199 && width < 301) ? DEFAULT : WINNING));
137+
138+
//trace('No JSON file found, guessing type based on size: ' + type + ' (' + width + 'px)');
139+
140+
// Create or update JSON file with guessed type
141+
jsonData = { type: switch (type) {
142+
case SINGLE: 'SINGLE';
143+
case DEFAULT: 'DEFAULT';
144+
case WINNING: 'WINNING';
145+
case ANIMSINGLE: 'ANIMSINGLE';
146+
case ANIMDEFAULT: 'ANIMDEFAULT';
147+
case ANIMWINNING: 'ANIMWINNING';
148+
case ANIMSINGING: 'ANIMSINGING';
149+
}};
150+
if (!sys.FileSystem.exists(jsonPath)) {
151+
try {
152+
var file = sys.io.File.write(jsonPath, true); // ???
153+
file.close();
154+
} catch(e) {trace("Failed to write JSON for " + char);}
155+
}
156+
sys.io.File.saveContent(jsonPath, haxe.Json.stringify(jsonData, null, '\t'));
157+
//trace('Remembering this type for future use: ' + jsonPath);
158+
}
94159

95-
loadGraphic(file, true, Math.floor(width / (type+1)), Math.floor(height));
96-
iconOffsets[0] = iconOffsets[1] = (width - 150) / (type+1);
97-
var frames:Array<Int> = [];
98-
for (i in 0...type+1) frames.push(i);
99-
updateHitbox();
160+
loadGraphic(file, true, Math.floor(width / (type+1)), Math.floor(height));
161+
iconOffsets[0] = iconOffsets[1] = (width - 150) / (type+1);
162+
var frames:Array<Int> = [];
163+
for (i in 0...type+1) frames.push(i);
164+
updateHitbox();
100165

101-
animation.add(char, frames, 0, false, isPlayer);
102-
animation.play(char);
166+
animation.add(char, frames, 0, false, isPlayer);
167+
animation.play(char);
168+
}
169+
103170
this.char = char;
104171

105172
if(char.endsWith('-pixel'))

source/states/FirstCheckState.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class FirstCheckState extends MusicBeatState
5252
}
5353
}
5454

55+
MemoryUtilBase.enable();
56+
5557
super.create();
5658

5759
// // Colored Text Test

source/states/LoadingState.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class LoadingState extends MusicBeatState
9090
override function create()
9191
{
9292
MemoryUtilBase.compact();
93+
MemoryUtilBase.collect(true);
94+
9395
persistentUpdate = true;
9496
barGroup = new FlxSpriteGroup();
9597
add(barGroup);

source/states/PlayState.hx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,6 @@ class PlayState extends MusicBeatState
12021202
uiGroup.cameras = [camHUD];
12031203
hearts.cameras = [camHUD];
12041204
noteGroup.cameras = [camHUD];
1205-
comboGroup.cameras = [camHUD];
12061205

12071206
startingSong = true;
12081207

@@ -1790,15 +1789,6 @@ class PlayState extends MusicBeatState
17901789

17911790
trace("Starting Countdown!");
17921791
canPause = true;
1793-
for (i in 0...playerStrums.length) {
1794-
setOnScripts('defaultPlayerStrumX' + i, playerField.baseXPositions[i]);
1795-
setOnScripts('defaultPlayerStrumY' + i, playerStrums.members[i].y);
1796-
}
1797-
for (i in 0...opponentStrums.length) {
1798-
setOnScripts('defaultOpponentStrumX' + i, dadField.baseXPositions[i]);
1799-
setOnScripts('defaultOpponentStrumY' + i, opponentStrums.members[i].y);
1800-
//if(ClientPrefs.data.middleScroll) opponentStrums.members[i].visible = false;
1801-
}
18021792

18031793
if (skipCountdown || startOnTime > 0)
18041794
skipArrowStartTween = true;
@@ -1839,6 +1829,16 @@ class PlayState extends MusicBeatState
18391829
dadField.baseXPositions[i] = dadField.strumNotes[i].x;
18401830
}
18411831

1832+
for (i in 0...playerStrums.length) {
1833+
setOnScripts('defaultPlayerStrumX' + i, playerField.baseXPositions[i]);
1834+
setOnScripts('defaultPlayerStrumY' + i, playerStrums.members[i].y);
1835+
}
1836+
for (i in 0...opponentStrums.length) {
1837+
setOnScripts('defaultOpponentStrumX' + i, dadField.baseXPositions[i]);
1838+
setOnScripts('defaultOpponentStrumY' + i, opponentStrums.members[i].y);
1839+
//if(ClientPrefs.data.middleScroll) opponentStrums.members[i].visible = false;
1840+
}
1841+
18421842
startedCountdown = true;
18431843
Conductor.songPosition = -Conductor.crochet * 5 + Conductor.offset;
18441844
setOnScripts('startedCountdown', true);

source/yutautil/TypeUtils.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ abstract HxVector<T>(haxe.ds.Vector<T>) {
12341234
var len = this.length;
12351235
return {
12361236
hasNext: function() return i < len,
1237-
next: function() return this[i++];
1237+
next: function() return this[i++]
12381238
};
12391239
}
12401240
}

0 commit comments

Comments
 (0)