Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
sort shiz
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDrawingCoder-Gamer committed Feb 18, 2021
1 parent 4750f68 commit cd49f1f
Show file tree
Hide file tree
Showing 5 changed files with 465 additions and 4 deletions.
11 changes: 8 additions & 3 deletions source/CategoryState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using StringTools;
class CategoryState extends MusicBeatState
{
var categories:Array<String> = [];
public static var choosingFor:String = "freeplay";
var categorySongs:Array<Array<String>> =[];
var selector:FlxText;
var curSelected:Int = 0;
Expand All @@ -37,7 +38,7 @@ class CategoryState extends MusicBeatState
{
// it's a js file to make syntax highlighting acceptable
var epicCategoryJs:Array<Dynamic> = CoolUtil.parseJson(Assets.getText('assets/data/freeplaySongJson.jsonc'));
if (epicCategoryJs.length > 1) {
if (epicCategoryJs.length > 1 || choosingFor != "freeplay") {
for (category in epicCategoryJs) {
categories.push(category.name);
categorySongs.push(category.songs);
Expand Down Expand Up @@ -144,12 +145,16 @@ class CategoryState extends MusicBeatState
}
// make sure it isn't a header

if (accepted && categorySongs[curSelected].length > 0)
if (accepted && categorySongs[curSelected].length > 0 && choosingFor == "freeplay")
{
FreeplayState.currentSongList = categorySongs[curSelected];
FlxG.switchState(new FreeplayState());

}
} else if (accepted && categorySongs[curSelected].length > 0) {
SortState.stuffToSort = categorySongs[curSelected];
SortState.category = categories[curSelected];
FlxG.switchState(new SortState());
}
}


Expand Down
1 change: 1 addition & 0 deletions source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class MainMenuState extends MusicBeatState
FlxG.switchState(new StoryMenuState());
trace("Story Menu Selected");
case 'freeplay':
CategoryState.choosingFor = "freeplay";
FlxG.switchState(new CategoryState());

trace("Freeplay Menu Selected");
Expand Down
11 changes: 10 additions & 1 deletion source/SaveDataState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class SaveDataState extends MusicBeatState
{name:"New Character...", value: false},
{name:"New Stage...", value:false},
{name: "New Song...", value: false},
{name: "New Week...", value: false}
{name: "New Week...", value: false},
{name: "Sort...", value: false}
];
optionList[0].value = FlxG.save.data.options.alwaysDoCutscenes;
optionList[1].value = FlxG.save.data.options.skipModifierMenu;
Expand Down Expand Up @@ -203,6 +204,14 @@ class SaveDataState extends MusicBeatState
};
trace(FlxG.save.data.options);
FlxG.switchState(new NewWeekState());
case "Sort...":
FlxG.save.data.options = {
"skipVictoryScreen": optionList[2].value,
"skipModifierMenu": optionList[1].value,
"alwaysDoCutscenes": optionList[0].value
};
trace(FlxG.save.data.options);
FlxG.switchState(new SelectSortState());
default:
checkmarks.members[optionsSelected].visible = !checkmarks.members[optionsSelected].visible;
optionList[optionsSelected].value = checkmarks.members[optionsSelected].visible;
Expand Down
185 changes: 185 additions & 0 deletions source/SelectSortState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
package;

import haxe.macro.Expr.Case;
import flash.text.TextField;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.display.FlxGridOverlay;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxMath;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import lime.utils.Assets;
import DifficultyIcons;
import lime.system.System;
#if sys
import sys.io.File;
import haxe.io.Path;
import openfl.utils.ByteArray;
import lime.media.AudioBuffer;
import sys.FileSystem;
import flash.media.Sound;
#end
import haxe.Json;
import tjson.TJSON;
using StringTools;

class SelectSortState extends MusicBeatState
{

var songs:Array<String> = [];

var selector:FlxText;
var curSelected:Int = 0;
var curDifficulty:Int = 1;

var scoreText:FlxText;
var diffText:FlxText;
var lerpScore:Int = 0;
var intendedScore:Int = 0;
var usingCategoryScreen:Bool = false;
private var grpSongs:FlxTypedGroup<Alphabet>;
private var curPlaying:Bool = false;

override function create()
{
songs = ["songs", "categories", "weeks"];


// LOAD MUSIC

// LOAD CHARACTERS

var bg:FlxSprite = new FlxSprite().loadGraphic('assets/images/menuBGBlue.png');
add(bg);

grpSongs = new FlxTypedGroup<Alphabet>();
add(grpSongs);

for (i in 0...songs.length)
{
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i], true, false);
songText.isMenuItem = true;
songText.targetY = i;
grpSongs.add(songText);
// songText.x += 40;
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
// songText.screenCenter(X);
}


changeSelection();

// FlxG.sound.playMusic('assets/music/title' + TitleState.soundExt, 0);
// FlxG.sound.music.fadeIn(2, 0, 0.8);

// JUST DOIN THIS SHIT FOR TESTING!!!
/*
var md:String = Markdown.markdownToHtml(Assets.getText('CHANGELOG.md'));
var texFel:TextField = new TextField();
texFel.width = FlxG.width;
texFel.height = FlxG.height;
// texFel.
texFel.htmlText = md;
FlxG.stage.addChild(texFel);
// scoreText.textField.htmlText = md;
trace(md);
*/

super.create();
}

override function update(elapsed:Float)
{
super.update(elapsed);

if (FlxG.sound.music.volume < 0.7)
{
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
}


var upP = controls.UP_P;
var downP = controls.DOWN_P;
var accepted = controls.ACCEPT;

if (upP)
{
changeSelection(-1);
}
if (downP)
{
changeSelection(1);
}

if (controls.BACK)
{
FlxG.switchState(new SaveDataState());
}

if (accepted)
{
trace(songs[curSelected]);
switch (songs[curSelected]) {
case "songs":
CategoryState.choosingFor = "sorting";
FlxG.switchState(new CategoryState());
case "categories":
var coolCategoryJson:Array<SelectSongsState.TCategory> = CoolUtil.parseJson(Assets.getText('assets/data/freeplaySongJson.jsonc'));
var coolCategories:Array<String> = [];
for (coolCategory in coolCategoryJson)
{
coolCategories.push(coolCategory.name);
}
SortState.stuffToSort = coolCategories;
SortState.sorting = "categories";
FlxG.switchState(new SortState());
case "weeks":
// gonna be reallllllllll fucky renaming files
SortState.sorting = "weeks";
// gonna do weeks ourselves?
var coolWeekJson:StoryMenuState.StorySongsJson = CoolUtil.parseJson(Assets.getText('assets/data/storySonglist.json'));
var coolWeeks:Array<String> = [];
for (i in 0...coolWeekJson.songs.length) {
coolWeeks.push("week"+i);
}
SortState.stuffToSort = coolWeeks;
FlxG.switchState(new SortState());
}

}
}

function changeSelection(change:Int = 0)
{

FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt, 0.4);

curSelected += change;

if (curSelected < 0)
curSelected = songs.length - 1;
if (curSelected >= songs.length)
curSelected = 0;
var bullShit:Int = 0;

for (item in grpSongs.members)
{
item.targetY = bullShit - curSelected;
bullShit++;

item.alpha = 0.6;
// item.setGraphicSize(Std.int(item.width * 0.8));

if (item.targetY == 0)
{
item.alpha = 1;
// item.setGraphicSize(Std.int(item.width));
}
}
}
}
Loading

0 comments on commit cd49f1f

Please sign in to comment.