Skip to content

Commit 47ac7a8

Browse files
committed
more things
1 parent 0a44f6a commit 47ac7a8

File tree

4 files changed

+136
-59
lines changed

4 files changed

+136
-59
lines changed

source/managers/FreeplayManager.hx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,25 @@ class FreeplayManager {
140140

141141
try {metadataFile = cast Json.parse(Assets.getText(Paths.json(Paths.formatToSongPath(song[0].toLowerCase()) + '/meta')));}
142142
catch(e) {
143-
trace("can't.");
143+
//trace("can't.");
144144
metadataFile = null;
145145
}
146146

147147
try
148148
{
149149
metadata.set(song[0].toLowerCase(), cast metadataFile);
150-
trace("Found metadata for " + song[0].toLowerCase());
150+
//trace("Found metadata for " + song[0].toLowerCase());
151151
}
152152
catch (e)
153153
{
154-
try
154+
/*try
155155
{
156156
trace("No metadata for " + song[0].toLowerCase());
157157
}
158158
catch (e)
159159
{
160160
trace("No metadata found. No song either apparently.");
161-
}
161+
}*/
162162
}
163163

164164
if ((ClientPrefs.data.showMods && leWeek.folder.toLowerCase() == CategoryState.loadWeekForce.toLowerCase()) || (CategoryState.loadWeekForce == "all" && (leWeek.folder != '' || leWeek.folder != null) && !APEntryState.inArchipelagoMode))
@@ -634,6 +634,8 @@ class FreeplayManager {
634634
}
635635

636636
public static function checkSongStatus() {
637+
trueMissing = [];
638+
unplayedList = [];
637639
for (i in 0...WeekData.weeksList.length) {
638640
var leWeek:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[i]);
639641
WeekData.setDirectoryFromWeek(leWeek);
@@ -647,7 +649,7 @@ class FreeplayManager {
647649
var someLocationsNotMissing:Bool = false;
648650

649651
if (APEntryState.inArchipelagoMode) {
650-
songName = song;
652+
songName = song[0];
651653
modName = leWeek.folder;
652654
locationId = APEntryState.apGame.locationData(songName, modName).concat(APEntryState.apGame.noteData(songName, modName));
653655
isMissing = [for (ID in locationId) APEntryState.apGame.isLocationMissing(APEntryState.apGame.info().get_location_name(ID))].indexOf(true) != -1 || locationId.length == 0;

source/objects/Note.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,11 @@ class Note extends NoteObject
11601160
if (alpha > 0.3)
11611161
alpha = 0.3;
11621162
}
1163+
1164+
if (!inEditor) {
1165+
if (field != null && alpha > field.strumNotes[column].alpha)
1166+
alpha = field.strumNotes[column].alpha;
1167+
}
11631168
}
11641169

11651170
override public function destroy()

source/states/freeplay/FreeplayState.hx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ class FreeplayState extends MusicBeatState
199199
grpLocks = new FlxTypedGroup<FlxSprite>();
200200
add(grpLocks);
201201

202-
// if (!ClientPrefs.data.disableFreeplayAlphabet)
203202
randomText = new Alphabet(90, 320, "RANDOM", true);
204-
// else
205-
// randomText = new online.objects.AlphaLikeText(90, 320, "RANDOM");
206203
randomText.scaleX = Math.min(1, 980 / randomText.width);
207204
randomText.targetY = -1;
208205
randomText.snapToPosition();
@@ -423,8 +420,8 @@ class FreeplayState extends MusicBeatState
423420
return (!leWeek.startUnlocked && leWeek.weekBefore.length > 0 && (!StoryMenuState.weekCompleted.exists(leWeek.weekBefore) || !StoryMenuState.weekCompleted.get(leWeek.weekBefore)));
424421
}
425422

426-
//TODO: Find a way to safely thread this
427-
//or at least make it handle a larger amount of songs without taking forever to load
423+
// TODO: Find a way to safely thread this
424+
// or at least make it handle a larger amount of songs without taking forever to load
428425
public function reloadSongs(?refresh:Bool = false)
429426
{
430427
if (instance != null)

source/states/freeplay/OsuFreeplayState.hx

Lines changed: 122 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ class OsuFreeplayState extends MusicBeatState
5353
var inSub:Bool = false;
5454

5555
var staleBg:FlxSprite;
56-
var ticketCounter:FlxText = null;
56+
var ticketCounterTop:FlxText = null;
57+
var ticketCounterBottom:FlxText = null;
5758
override function create()
5859
{
60+
#if windows
61+
backend.window.CppAPI.resetAffixes();
62+
backend.window.CppAPI.resetTitle();
63+
#end
64+
5965
instance = this; // For Archipelago
66+
67+
Paths.clearStoredWithoutStickers();
6068

6169
Cursor.cursorMode = Default;
6270

@@ -142,11 +150,15 @@ class OsuFreeplayState extends MusicBeatState
142150
changeSong();
143151

144152
if (APEntryState.apGame != null && APEntryState.apGame.info() != null) {
145-
ticketCounter = new FlxText(0, FlxG.height - 630, 0, "0/0", 32);
146-
ticketCounter.setFormat(Paths.font("fnf1.ttf"), 32, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
147-
ticketCounter.scrollFactor.set();
148-
ticketCounter.screenCenter(X);
149-
add(ticketCounter);
153+
ticketCounterTop = new FlxText(albumPhoto.x - 130, albumPhoto.y - 230, 0, "0/0", 32);
154+
ticketCounterTop.setFormat(Paths.font("fnf1.ttf"), 32, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
155+
ticketCounterTop.scrollFactor.set();
156+
add(ticketCounterTop);
157+
158+
ticketCounterBottom = new FlxText(backHitbox.x + 100, backHitbox.y, 0, "0/0", 32);
159+
ticketCounterBottom.setFormat(Paths.font("fnf1.ttf"), 28, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
160+
ticketCounterBottom.scrollFactor.set();
161+
add(ticketCounterBottom);
150162
new FlxTimer().start(1, function(tmr:FlxTimer) {
151163
archipelago.APGameState.haventranyet = false;
152164
});
@@ -156,6 +168,13 @@ class OsuFreeplayState extends MusicBeatState
156168
archipelago.APItem.activeItem = null;
157169

158170
super.create();
171+
172+
#if DISCORD_ALLOWED
173+
// Updating Discord Rich Presence
174+
DiscordClient.changePresence("In the Menus", null);
175+
#end
176+
177+
Mods.loadTopMod();
159178
}
160179

161180
var holdTime:Float = 0;
@@ -164,9 +183,22 @@ class OsuFreeplayState extends MusicBeatState
164183
var e:Int = 0;
165184
override public function update(elapsed:Float)
166185
{
186+
if(WeekData.weeksList.length < 1)
187+
{
188+
FlxTransitionableState.skipNextTransIn = true;
189+
persistentUpdate = false;
190+
MusicBeatState.switchState(new states.ErrorState("NO WEEKS ADDED FOR FREEPLAY\n\nPress ACCEPT to go to the Week Editor Menu.\nPress BACK to return to Main Menu.",
191+
function() MusicBeatState.switchState(new states.editors.WeekEditorState()),
192+
function() MusicBeatState.switchState(new states.MainMenuState())));
193+
return;
194+
}
195+
167196
e++;
168197
FlxG.watch.addQuick('Search Text', searchTypeText.text);
169198

199+
if (FlxG.sound.music.volume < 0.8)
200+
FlxG.sound.music.volume = Math.min(FlxG.sound.music.volume + 0.5 * elapsed, 0.8);
201+
170202
for(item in songBox)
171203
{
172204
var coolEffect:Int = 0;
@@ -180,9 +212,51 @@ class OsuFreeplayState extends MusicBeatState
180212
}
181213

182214
#if ARCHIPELAGO_ALLOWED
183-
victoryColor = FlxColor.fromHSL(((e / 2) / 300 * 360) % 360, 1.0, 0.5 * 1.0);
215+
if (APEntryState.inArchipelagoMode) {
216+
victoryColor = FlxColor.fromHSL(((e / 2) / 300 * 360) % 360, 1.0, 0.5 * 1.0);
217+
218+
for (i in 0...FreeplayManager.songList.length) {
219+
if (FreeplayManager.isVictorySong(FreeplayManager.songList[i].songName, FreeplayManager.songList[i].folder)) {
220+
songBox.members[i].color = victoryColor;
221+
}
222+
}
223+
224+
if (FlxG.keys.justPressed.L && APEntryState.inArchipelagoMode && !isTyping) {
225+
try { //Because this menu has no actual difficulty select, just assume it's the first difficulty
226+
var songLowercase:String = Paths.formatToSongPath(FreeplayManager.songList[curSelected].songName);
227+
var poop:String = Highscore.formatSong(songLowercase, 0);
228+
Mods.currentModDirectory = FreeplayManager.songList[curSelected].folder;
229+
Song.loadFromJson(poop, songLowercase);
230+
PlayState.isStoryMode = false;
231+
PlayState.storyDifficulty = 0;
232+
} catch (e:Dynamic) {
233+
trace('Error loading song: ' + e);
234+
}
235+
try {
236+
FreeplayManager.forceUnlockCheck(FreeplayManager.songList[curSelected].songName, WeekData.getCurrentWeek().folder);
237+
} catch (e:Dynamic) {
238+
trace("You can't check nothing, silly!");
239+
}
240+
MusicBeatState.resetState();
241+
}
242+
243+
if (FlxG.keys.justPressed.H && APEntryState.inArchipelagoMode && !isTyping) {
244+
try {
245+
var SongInfo = APEntryState.apGame.getSongAndMod(FreeplayManager.songList[curSelected].songName + (FreeplayManager.songList[curSelected].folder != "" ? " (" + FreeplayManager.songList[curSelected].folder + ")" : ""));
246+
if (APEntryState.ap != null) {
247+
APEntryState.ap.Say("!hint " + SongInfo.song + ((SongInfo.mod != "" && SongInfo.mod != null) ? " (" + SongInfo.mod + ")" : ""));
248+
archipelago.console.SideUI.instance.active = true;
249+
}
250+
} catch (e:Dynamic) {
251+
trace("You can't hint nothing, silly!");
252+
}
253+
}
254+
}
184255
#end
185256

257+
persistentUpdate = true;
258+
PlayState.isStoryMode = false;
259+
186260
for(icon in iconGrp)
187261
{
188262
var theY:Float = 0;
@@ -283,24 +357,27 @@ class OsuFreeplayState extends MusicBeatState
283357
if (FreeplayManager.isVictorySong(FreeplayManager.songList[curSelected].songName, FreeplayManager.songList[curSelected].folder) && !vicCheck) {
284358
FlxG.camera.shake(0.005, 0.5);
285359
FlxG.sound.play(Paths.sound("badnoise"+FlxG.random.int(1,3)), 1);
360+
var ogColor = songBox.members[curSelected].color;
286361
songBox.forEach(function(item:FlxSprite)
287362
{
288-
if (item.ID == curSelected) FlxTween.color(item, 1, 0xffcc0002, 0xffffffff, {ease: FlxEase.sineIn});
363+
if (item.ID == curSelected) FlxTween.color(item, 1, 0xffcc0002, ogColor, {ease: FlxEase.sineIn});
289364
});
290-
FlxTween.color(ticketCounter, 1, 0xffcc0002, 0xffffffff, {ease: FlxEase.sineIn});
365+
FlxTween.color(ticketCounterTop, 1, 0xffcc0002, 0xffffffff, {ease: FlxEase.sineIn});
291366
return;
292367
}
293368

294369
if (FreeplayManager.trueMissing.contains(FreeplayManager.songList[curSelected].songName) && !FreeplayManager.unplayedList.contains(FreeplayManager.songList[curSelected].songName)) {
295370
FlxG.camera.shake(0.005, 0.5);
296371
FlxG.sound.play(Paths.sound("badnoise"+FlxG.random.int(1,3)), 1);
372+
var ogColor = songBox.members[curSelected].color;
297373
songBox.forEach(function(item:FlxSprite)
298374
{
299-
if (item.ID == curSelected) FlxTween.color(item, 1, 0xffcc0002, 0xffffffff, {ease: FlxEase.sineIn});
375+
if (item.ID == curSelected) FlxTween.color(item, 1, 0xffcc0002, ogColor, {ease: FlxEase.sineIn});
300376
});
301377
return;
302378
}
303379

380+
//loadDiffs(FreeplayManager.songList[curSelected]);
304381
inSub = true;
305382
openSubState(new DifficultySelectorSubState(FreeplayManager.songList[curSelected]));
306383
}
@@ -351,14 +428,14 @@ class OsuFreeplayState extends MusicBeatState
351428

352429
super.update(elapsed);
353430

354-
if (ticketCounter != null) {
355-
ticketCounter.text = 'Current ticket amount: ${APInfo.ticketCount}\n' +
431+
if (ticketCounterTop != null && ticketCounterBottom != null) {
432+
ticketCounterTop.text = 'Current ticket amount: ${APInfo.ticketCount}\n' +
356433
'Tickets Needed: ${APInfo.ticketWinCount}\n' +
357-
'Tickets Left: ${Std.int(APInfo.ticketWinCount - APInfo.ticketCount)}\n' +
358-
'Hint Points Available: ${APInfo.hintPoints}\n' +
359-
'Hint Cost: ${APInfo.hintCost}\n' +
360-
'(L) to release song\n' +
361-
'(H) to hint song';
434+
'Tickets Left: ${Std.int(APInfo.ticketWinCount - APInfo.ticketCount)}\n';
435+
ticketCounterBottom.text = 'Hint Points Available: ${APInfo.hintPoints}' +
436+
' Hint Cost: ${APInfo.hintCost}' +
437+
' (L) to release song' +
438+
' (H) to hint song';
362439
}
363440
}
364441

@@ -445,7 +522,8 @@ class OsuFreeplayState extends MusicBeatState
445522
}
446523
}
447524
}
448-
if(playSound) FlxG.sound.play(Paths.sound('scrollMenu'), 0.4);
525+
if(playSound)
526+
FlxG.sound.play(Paths.sound('scrollMenu'), 0.4);
449527
}
450528

451529
public static var vocals:FlxSound = null;
@@ -463,7 +541,32 @@ class OsuFreeplayState extends MusicBeatState
463541
FlxG.mouse.visible = false;
464542
instance = null;
465543
if (!FlxG.sound.music.playing && !stopMusicPlay)
466-
MusicManager.playMenuMusic(0);
544+
MusicManager.playMenuMusic(1);
545+
}
546+
547+
function loadDiffs(song:Dynamic) {
548+
var week:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[FreeplayManager.songList[curSelected].week]);
549+
Difficulty.loadFromWeek(week);
550+
551+
var diffInt:Int = 0;
552+
for (j in 0...Difficulty.list.length)
553+
{
554+
var songBox:SongBox = new SongBox(320, 100);
555+
songBox.loadGraphic(Paths.image('OSUState/bars/background2'));
556+
songBox.setGraphicSize(650, 50);
557+
songBox.setColorTransform(-1, -1, -1, 1, FreeplayManager.songList[curSelected].color[0][0], FreeplayManager.songList[curSelected].color[0][1], FreeplayManager.songList[curSelected].color[0][2], 1);
558+
songBox.ID = song.ID + diffInt;
559+
this.songBox.add(songBox);
560+
561+
//try {metadata = FreeplayManager.metadata.get(FreeplayManager.songList[i].songName.toLowerCase());}
562+
//catch(e) {metadata = null;}
563+
564+
var text:FlxText = new FlxText(0, 0, 500, '', 20);
565+
text.text = Difficulty.list[j];
566+
text.alignment = 'left';
567+
text.ID = song.ID + diffInt;
568+
this.textGrp.add(text);
569+
}
467570
}
468571

469572
function loadSongArray(reset:Bool, searching:Bool = false, searchQuery:String = '')
@@ -536,36 +639,6 @@ class OsuFreeplayState extends MusicBeatState
536639
text.alignment = 'left';
537640
text.ID = i;
538641
textGrp.add(text);
539-
540-
/*var week:WeekData = WeekData.weeksLoaded.get(WeekData.weeksList[FreeplayManager.songList[i].week]);
541-
Difficulty.loadFromWeek(week);
542-
543-
for (j in 0...Difficulty.list.length)
544-
{
545-
trueInt++;
546-
547-
var songBox:SongBox = new SongBox(320, 100);
548-
songBox.loadGraphic(Paths.image('OSUState/bars/background2'));
549-
songBox.setGraphicSize(650, 100);
550-
songBox.setColorTransform(-1, -1, -1, 1, FreeplayManager.songList[i].color[0][0], FreeplayManager.songList[i].color[0][1], FreeplayManager.songList[i].color[0][2], 1);
551-
songBox.ID = trueInt;
552-
songBoxParent.add(songBox);
553-
554-
var icon:HealthIcon = new HealthIcon(FreeplayManager.songList[i].songCharacter, false);
555-
icon.setPosition(320, 100);
556-
icon.ID = trueInt;
557-
icon.setGraphicSize(Std.int(icon.width / 1.7), Std.int(icon.height / 1.7));
558-
this.iconGrp.add(icon);
559-
560-
try {metadata = FreeplayManager.metadata.get(FreeplayManager.songList[i].songName.toLowerCase());}
561-
catch(e) {metadata = null;}
562-
563-
var text:FlxText = new FlxText(0, 0, 500, '', 20);
564-
text.text = FreeplayManager.songList[i].songName + '\n' + Difficulty.list[j];
565-
text.alignment = 'left';
566-
text.ID = trueInt;
567-
this.textGrp.add(text);
568-
}*/
569642
}
570643

571644
maxSelected = songBox.length;

0 commit comments

Comments
 (0)