Tobee_Night_Funkin_PSYCH/source/editors/WeekEditorState.hx

796 lines
24 KiB
Haxe

package editors;
#if desktop
import Discord.DiscordClient;
#end
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.display.FlxGridOverlay;
import flixel.addons.transition.FlxTransitionableState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxMath;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import flixel.system.FlxSound;
import openfl.utils.Assets;
import flixel.addons.ui.FlxInputText;
import flixel.addons.ui.FlxUI9SliceSprite;
import flixel.addons.ui.FlxUI;
import flixel.addons.ui.FlxUICheckBox;
import flixel.addons.ui.FlxUIInputText;
import flixel.addons.ui.FlxUINumericStepper;
import flixel.addons.ui.FlxUITabMenu;
import flixel.ui.FlxButton;
import openfl.net.FileReference;
import openfl.events.Event;
import openfl.events.IOErrorEvent;
import flash.net.FileFilter;
import lime.system.Clipboard;
import haxe.Json;
#if sys
import sys.io.File;
import sys.FileSystem;
#end
import WeekData;
using StringTools;
class WeekEditorState extends MusicBeatState
{
var txtWeekTitle:FlxText;
var bgSprite:FlxSprite;
var lock:FlxSprite;
var txtTracklist:FlxText;
var grpWeekCharacters:FlxTypedGroup<MenuCharacter>;
var weekThing:MenuItem;
var missingFileText:FlxText;
var weekFile:WeekFile = null;
public function new(weekFile:WeekFile = null)
{
super();
this.weekFile = WeekData.createWeekFile();
if(weekFile != null) this.weekFile = weekFile;
else weekFileName = 'week1';
}
override function create() {
txtWeekTitle = new FlxText(FlxG.width * 0.7, 10, 0, "", 32);
txtWeekTitle.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, RIGHT);
txtWeekTitle.alpha = 0.7;
var ui_tex = Paths.getSparrowAtlas('campaign_menu_UI_assets');
var bgYellow:FlxSprite = new FlxSprite(0, 56).makeGraphic(FlxG.width, 386, 0xFFF9CF51);
bgSprite = new FlxSprite(0, 56);
bgSprite.antialiasing = ClientPrefs.globalAntialiasing;
weekThing = new MenuItem(0, bgSprite.y + 396, weekFileName);
weekThing.y += weekThing.height + 20;
weekThing.antialiasing = ClientPrefs.globalAntialiasing;
add(weekThing);
var blackBarThingie:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 56, FlxColor.BLACK);
add(blackBarThingie);
grpWeekCharacters = new FlxTypedGroup<MenuCharacter>();
lock = new FlxSprite();
lock.frames = ui_tex;
lock.animation.addByPrefix('lock', 'lock');
lock.animation.play('lock');
lock.antialiasing = ClientPrefs.globalAntialiasing;
add(lock);
missingFileText = new FlxText(0, 0, FlxG.width, "");
missingFileText.setFormat(Paths.font("vcr.ttf"), 24, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
missingFileText.borderSize = 2;
missingFileText.visible = false;
add(missingFileText);
var charArray:Array<String> = weekFile.weekCharacters;
for (char in 0...3)
{
var weekCharacterThing:MenuCharacter = new MenuCharacter((FlxG.width * 0.25) * (1 + char) - 150, charArray[char]);
weekCharacterThing.y += 70;
grpWeekCharacters.add(weekCharacterThing);
}
add(bgYellow);
add(bgSprite);
add(grpWeekCharacters);
var tracksSprite:FlxSprite = new FlxSprite(FlxG.width * 0.07, bgSprite.y + 435).loadGraphic(Paths.image('Menu_Tracks'));
tracksSprite.antialiasing = ClientPrefs.globalAntialiasing;
add(tracksSprite);
txtTracklist = new FlxText(FlxG.width * 0.05, tracksSprite.y + 60, 0, "", 32);
txtTracklist.alignment = CENTER;
txtTracklist.font = Paths.font("vcr.ttf");
txtTracklist.color = 0xFFe55777;
add(txtTracklist);
add(txtWeekTitle);
addEditorBox();
reloadAllShit();
FlxG.mouse.visible = true;
super.create();
}
var UI_box:FlxUITabMenu;
var blockPressWhileTypingOn:Array<FlxUIInputText> = [];
function addEditorBox() {
var tabs = [
{name: 'Week', label: 'Week'},
{name: 'Lock', label: 'Lock'},
];
UI_box = new FlxUITabMenu(null, tabs, true);
UI_box.resize(250, 375);
UI_box.x = FlxG.width - UI_box.width;
UI_box.y = FlxG.height - UI_box.height;
UI_box.scrollFactor.set();
addWeekUI();
addLockUI();
UI_box.selected_tab_id = 'Week';
add(UI_box);
var loadWeekButton:FlxButton = new FlxButton(0, 650, "Load Week", function() {
loadWeek();
});
loadWeekButton.screenCenter(X);
loadWeekButton.x -= 120;
add(loadWeekButton);
var freeplayButton:FlxButton = new FlxButton(0, 650, "Freeplay", function() {
MusicBeatState.switchState(new WeekEditorFreeplayState(weekFile));
});
freeplayButton.screenCenter(X);
add(freeplayButton);
var saveWeekButton:FlxButton = new FlxButton(0, 650, "Save Week", function() {
saveWeek(weekFile);
});
saveWeekButton.screenCenter(X);
saveWeekButton.x += 120;
add(saveWeekButton);
}
var songsInputText:FlxUIInputText;
var backgroundInputText:FlxUIInputText;
var displayNameInputText:FlxUIInputText;
var weekNameInputText:FlxUIInputText;
var weekFileInputText:FlxUIInputText;
var opponentInputText:FlxUIInputText;
var boyfriendInputText:FlxUIInputText;
var girlfriendInputText:FlxUIInputText;
var hideCheckbox:FlxUICheckBox;
public static var weekFileName:String = 'week1';
function addWeekUI() {
var tab_group = new FlxUI(null, UI_box);
tab_group.name = "Week";
songsInputText = new FlxUIInputText(10, 30, 200, '', 8);
blockPressWhileTypingOn.push(songsInputText);
opponentInputText = new FlxUIInputText(10, songsInputText.y + 40, 70, '', 8);
blockPressWhileTypingOn.push(opponentInputText);
boyfriendInputText = new FlxUIInputText(opponentInputText.x + 75, opponentInputText.y, 70, '', 8);
blockPressWhileTypingOn.push(boyfriendInputText);
girlfriendInputText = new FlxUIInputText(boyfriendInputText.x + 75, opponentInputText.y, 70, '', 8);
blockPressWhileTypingOn.push(girlfriendInputText);
backgroundInputText = new FlxUIInputText(10, opponentInputText.y + 40, 120, '', 8);
blockPressWhileTypingOn.push(backgroundInputText);
displayNameInputText = new FlxUIInputText(10, backgroundInputText.y + 60, 200, '', 8);
blockPressWhileTypingOn.push(backgroundInputText);
weekNameInputText = new FlxUIInputText(10, displayNameInputText.y + 60, 150, '', 8);
blockPressWhileTypingOn.push(weekNameInputText);
weekFileInputText = new FlxUIInputText(10, weekNameInputText.y + 40, 100, '', 8);
blockPressWhileTypingOn.push(weekFileInputText);
reloadWeekThing();
hideCheckbox = new FlxUICheckBox(10, weekFileInputText.y + 40, null, null, "Hide Week from Story Mode?", 100);
hideCheckbox.callback = function()
{
weekFile.hideStoryMode = hideCheckbox.checked;
};
tab_group.add(new FlxText(songsInputText.x, songsInputText.y - 18, 0, 'Songs:'));
tab_group.add(new FlxText(opponentInputText.x, opponentInputText.y - 18, 0, 'Characters:'));
tab_group.add(new FlxText(backgroundInputText.x, backgroundInputText.y - 18, 0, 'Background Asset:'));
tab_group.add(new FlxText(displayNameInputText.x, displayNameInputText.y - 18, 0, 'Display Name:'));
tab_group.add(new FlxText(weekNameInputText.x, weekNameInputText.y - 18, 0, 'Week Name (for Reset Score Menu):'));
tab_group.add(new FlxText(weekFileInputText.x, weekFileInputText.y - 18, 0, 'Week File:'));
tab_group.add(songsInputText);
tab_group.add(opponentInputText);
tab_group.add(boyfriendInputText);
tab_group.add(girlfriendInputText);
tab_group.add(backgroundInputText);
tab_group.add(displayNameInputText);
tab_group.add(weekNameInputText);
tab_group.add(weekFileInputText);
tab_group.add(hideCheckbox);
UI_box.addGroup(tab_group);
}
var weekBeforeInputText:FlxUIInputText;
var lockedCheckbox:FlxUICheckBox;
function addLockUI() {
var tab_group = new FlxUI(null, UI_box);
tab_group.name = "Lock";
lockedCheckbox = new FlxUICheckBox(10, 30, null, null, "Week starts Locked", 100);
lockedCheckbox.callback = function()
{
weekFile.startUnlocked = !lockedCheckbox.checked;
lock.visible = lockedCheckbox.checked;
};
weekBeforeInputText = new FlxUIInputText(10, lockedCheckbox.y + 55, 100, '', 8);
blockPressWhileTypingOn.push(weekBeforeInputText);
tab_group.add(new FlxText(weekBeforeInputText.x, weekBeforeInputText.y - 28, 0, 'Week File name of the Week you have\nto finish for Unlocking:'));
tab_group.add(weekBeforeInputText);
tab_group.add(lockedCheckbox);
UI_box.addGroup(tab_group);
}
//Used on onCreate and when you load a week
function reloadAllShit() {
var weekString:String = weekFile.songs[0][0];
for (i in 1...weekFile.songs.length) {
weekString += ', ' + weekFile.songs[i][0];
}
songsInputText.text = weekString;
backgroundInputText.text = weekFile.weekBackground;
displayNameInputText.text = weekFile.storyName;
weekNameInputText.text = weekFile.weekName;
weekFileInputText.text = weekFileName;
opponentInputText.text = weekFile.weekCharacters[0];
boyfriendInputText.text = weekFile.weekCharacters[1];
girlfriendInputText.text = weekFile.weekCharacters[2];
hideCheckbox.checked = weekFile.hideStoryMode;
weekBeforeInputText.text = weekFile.weekBefore;
lockedCheckbox.checked = !weekFile.startUnlocked;
lock.visible = lockedCheckbox.checked;
reloadBG();
reloadWeekThing();
updateText();
}
function updateText()
{
for (i in 0...grpWeekCharacters.length) {
grpWeekCharacters.members[i].changeCharacter(weekFile.weekCharacters[i]);
}
var stringThing:Array<String> = [];
for (i in 0...weekFile.songs.length) {
stringThing.push(weekFile.songs[i][0]);
}
txtTracklist.text = '';
for (i in 0...stringThing.length)
{
txtTracklist.text += stringThing[i] + '\n';
}
txtTracklist.text = txtTracklist.text.toUpperCase();
txtTracklist.screenCenter(X);
txtTracklist.x -= FlxG.width * 0.35;
txtWeekTitle.text = weekFile.storyName.toUpperCase();
txtWeekTitle.x = FlxG.width - (txtWeekTitle.width + 10);
}
function reloadBG() {
bgSprite.visible = true;
var assetName:String = weekFile.weekBackground;
var isMissing:Bool = true;
if(assetName != null && assetName.length > 0) {
if( #if MODS_ALLOWED FileSystem.exists(Paths.modsImages('menubackgrounds/menu_' + assetName)) || #end
Assets.exists(Paths.image('menubackgrounds/menu_' + assetName), IMAGE)) {
bgSprite.loadGraphic(Paths.image('menubackgrounds/menu_' + assetName));
isMissing = false;
}
}
if(isMissing) {
bgSprite.visible = false;
}
}
function reloadWeekThing() {
weekThing.visible = true;
missingFileText.visible = false;
var assetName:String = weekFileInputText.text.trim();
var isMissing:Bool = true;
if(assetName != null && assetName.length > 0) {
if( #if MODS_ALLOWED FileSystem.exists(Paths.modsImages('storymenu/' + assetName)) || #end
Assets.exists(Paths.image('storymenu/' + assetName), IMAGE)) {
weekThing.loadGraphic(Paths.image('storymenu/' + assetName));
isMissing = false;
}
}
if(isMissing) {
weekThing.visible = false;
missingFileText.visible = true;
missingFileText.text = 'MISSING FILE: images/storymenu/' + assetName + '.png';
}
recalculateStuffPosition();
#if desktop
// Updating Discord Rich Presence
DiscordClient.changePresence("Week Editor", "Editting: " + weekFileName);
#end
}
override function getEvent(id:String, sender:Dynamic, data:Dynamic, ?params:Array<Dynamic>) {
if(id == FlxUIInputText.CHANGE_EVENT && (sender is FlxUIInputText)) {
if(sender == weekFileInputText) {
weekFileName = weekFileInputText.text.trim();
reloadWeekThing();
} else if(sender == opponentInputText || sender == boyfriendInputText || sender == girlfriendInputText) {
weekFile.weekCharacters[0] = opponentInputText.text.trim();
weekFile.weekCharacters[1] = boyfriendInputText.text.trim();
weekFile.weekCharacters[2] = girlfriendInputText.text.trim();
updateText();
} else if(sender == backgroundInputText) {
weekFile.weekBackground = backgroundInputText.text.trim();
reloadBG();
} else if(sender == displayNameInputText) {
weekFile.storyName = displayNameInputText.text.trim();
updateText();
} else if(sender == weekNameInputText) {
weekFile.weekName = weekNameInputText.text.trim();
} else if(sender == songsInputText) {
var splittedText:Array<String> = songsInputText.text.trim().split(',');
for (i in 0...splittedText.length) {
splittedText[i] = splittedText[i].trim();
}
while(splittedText.length < weekFile.songs.length) {
weekFile.songs.pop();
}
for (i in 0...splittedText.length) {
if(i >= weekFile.songs.length) { //Add new song
weekFile.songs.push([splittedText[i], 'dad', [146, 113, 253]]);
} else { //Edit song
weekFile.songs[i][0] = splittedText[i];
if(weekFile.songs[i][1] == null || weekFile.songs[i][1]) {
weekFile.songs[i][1] = 'dad';
weekFile.songs[i][2] = [146, 113, 253];
}
}
}
updateText();
} else if(sender == weekBeforeInputText) {
weekFile.weekBefore = weekBeforeInputText.text.trim();
}
}
}
override function update(elapsed:Float)
{
if(loadedWeek != null) {
weekFile = loadedWeek;
loadedWeek = null;
reloadAllShit();
}
var blockInput:Bool = false;
for (inputText in blockPressWhileTypingOn) {
if(inputText.hasFocus) {
FlxG.sound.muteKeys = [];
FlxG.sound.volumeDownKeys = [];
FlxG.sound.volumeUpKeys = [];
blockInput = true;
if(FlxG.keys.justPressed.ENTER) inputText.hasFocus = false;
break;
}
}
if(!blockInput) {
FlxG.sound.muteKeys = TitleState.muteKeys;
FlxG.sound.volumeDownKeys = TitleState.volumeDownKeys;
FlxG.sound.volumeUpKeys = TitleState.volumeUpKeys;
if(FlxG.keys.justPressed.ESCAPE) {
FlxG.mouse.visible = false;
MusicBeatState.switchState(new editors.MasterEditorMenu());
FlxG.sound.playMusic(Paths.music('freakyMenu'));
}
}
super.update(elapsed);
lock.y = weekThing.y;
missingFileText.y = weekThing.y + 36;
}
function recalculateStuffPosition() {
weekThing.screenCenter(X);
lock.x = weekThing.width + 10 + weekThing.x;
}
private static var _file:FileReference;
public static function loadWeek() {
var jsonFilter:FileFilter = new FileFilter('JSON', 'json');
_file = new FileReference();
_file.addEventListener(Event.SELECT, onLoadComplete);
_file.addEventListener(Event.CANCEL, onLoadCancel);
_file.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
_file.browse([jsonFilter]);
}
public static var loadedWeek:WeekFile = null;
public static var loadError:Bool = false;
private static function onLoadComplete(_):Void
{
_file.removeEventListener(Event.SELECT, onLoadComplete);
_file.removeEventListener(Event.CANCEL, onLoadCancel);
_file.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
#if sys
var fullPath:String = null;
var jsonLoaded = cast Json.parse(Json.stringify(_file)); //Exploit(???) for accessing a private variable
if(jsonLoaded.__path != null) fullPath = jsonLoaded.__path; //I'm either a genious or dangerously dumb
if(fullPath != null) {
var rawJson:String = File.getContent(fullPath);
if(rawJson != null) {
loadedWeek = cast Json.parse(rawJson);
if(loadedWeek.weekCharacters != null && loadedWeek.weekName != null) //Make sure it's really a week
{
var cutName:String = _file.name.substr(0, _file.name.length - 5);
trace("Successfully loaded file: " + cutName);
loadError = false;
weekFileName = cutName;
_file = null;
return;
}
}
}
loadError = true;
loadedWeek = null;
_file = null;
#else
trace("File couldn't be loaded! You aren't on Desktop, are you?");
#end
}
/**
* Called when the save file dialog is cancelled.
*/
private static function onLoadCancel(_):Void
{
_file.removeEventListener(Event.SELECT, onLoadComplete);
_file.removeEventListener(Event.CANCEL, onLoadCancel);
_file.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
_file = null;
trace("Cancelled file loading.");
}
/**
* Called if there is an error while saving the gameplay recording.
*/
private static function onLoadError(_):Void
{
_file.removeEventListener(Event.SELECT, onLoadComplete);
_file.removeEventListener(Event.CANCEL, onLoadCancel);
_file.removeEventListener(IOErrorEvent.IO_ERROR, onLoadError);
_file = null;
trace("Problem loading file");
}
public static function saveWeek(weekFile:WeekFile) {
var data:String = Json.stringify(weekFile, "\t");
if (data.length > 0)
{
_file = new FileReference();
_file.addEventListener(Event.COMPLETE, onSaveComplete);
_file.addEventListener(Event.CANCEL, onSaveCancel);
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
_file.save(data, weekFileName + ".json");
}
}
private static function onSaveComplete(_):Void
{
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
_file.removeEventListener(Event.CANCEL, onSaveCancel);
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
_file = null;
FlxG.log.notice("Successfully saved file.");
}
/**
* Called when the save file dialog is cancelled.
*/
private static function onSaveCancel(_):Void
{
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
_file.removeEventListener(Event.CANCEL, onSaveCancel);
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
_file = null;
}
/**
* Called if there is an error while saving the gameplay recording.
*/
private static function onSaveError(_):Void
{
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
_file.removeEventListener(Event.CANCEL, onSaveCancel);
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
_file = null;
FlxG.log.error("Problem saving file");
}
}
class WeekEditorFreeplayState extends MusicBeatState
{
var weekFile:WeekFile = null;
public function new(weekFile:WeekFile = null)
{
super();
this.weekFile = WeekData.createWeekFile();
if(weekFile != null) this.weekFile = weekFile;
}
var bg:FlxSprite;
private var grpSongs:FlxTypedGroup<Alphabet>;
private var iconArray:Array<HealthIcon> = [];
var curSelected = 0;
override function create() {
bg = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
bg.antialiasing = ClientPrefs.globalAntialiasing;
bg.color = FlxColor.WHITE;
add(bg);
grpSongs = new FlxTypedGroup<Alphabet>();
add(grpSongs);
for (i in 0...weekFile.songs.length)
{
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, weekFile.songs[i][0], true, false);
songText.isMenuItem = true;
songText.targetY = i;
grpSongs.add(songText);
var icon:HealthIcon = new HealthIcon(weekFile.songs[i][1]);
icon.sprTracker = songText;
// using a FlxGroup is too much fuss!
iconArray.push(icon);
add(icon);
// songText.x += 40;
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
// songText.screenCenter(X);
}
addEditorBox();
changeSelection();
super.create();
}
var UI_box:FlxUITabMenu;
var blockPressWhileTypingOn:Array<FlxUIInputText> = [];
function addEditorBox() {
var tabs = [
{name: 'Freeplay', label: 'Freeplay'},
];
UI_box = new FlxUITabMenu(null, tabs, true);
UI_box.resize(250, 200);
UI_box.x = FlxG.width - UI_box.width - 100;
UI_box.y = FlxG.height - UI_box.height - 60;
UI_box.scrollFactor.set();
UI_box.selected_tab_id = 'Week';
addFreeplayUI();
add(UI_box);
var blackBlack:FlxSprite = new FlxSprite(0, 670).makeGraphic(FlxG.width, 50, FlxColor.BLACK);
blackBlack.alpha = 0.6;
add(blackBlack);
var loadWeekButton:FlxButton = new FlxButton(0, 685, "Load Week", function() {
WeekEditorState.loadWeek();
});
loadWeekButton.screenCenter(X);
loadWeekButton.x -= 120;
add(loadWeekButton);
var storyModeButton:FlxButton = new FlxButton(0, 685, "Story Mode", function() {
MusicBeatState.switchState(new WeekEditorState(weekFile));
});
storyModeButton.screenCenter(X);
add(storyModeButton);
var saveWeekButton:FlxButton = new FlxButton(0, 685, "Save Week", function() {
WeekEditorState.saveWeek(weekFile);
});
saveWeekButton.screenCenter(X);
saveWeekButton.x += 120;
add(saveWeekButton);
}
override function getEvent(id:String, sender:Dynamic, data:Dynamic, ?params:Array<Dynamic>) {
if(id == FlxUIInputText.CHANGE_EVENT && (sender is FlxUIInputText)) {
weekFile.songs[curSelected][1] = iconInputText.text;
iconArray[curSelected].changeIcon(iconInputText.text);
} else if(id == FlxUINumericStepper.CHANGE_EVENT && (sender is FlxUINumericStepper)) {
if(sender == bgColorStepperR || sender == bgColorStepperG || sender == bgColorStepperB) {
updateBG();
}
}
}
var bgColorStepperR:FlxUINumericStepper;
var bgColorStepperG:FlxUINumericStepper;
var bgColorStepperB:FlxUINumericStepper;
var iconInputText:FlxUIInputText;
function addFreeplayUI() {
var tab_group = new FlxUI(null, UI_box);
tab_group.name = "Freeplay";
bgColorStepperR = new FlxUINumericStepper(10, 40, 20, 255, 0, 255, 0);
bgColorStepperG = new FlxUINumericStepper(80, 40, 20, 255, 0, 255, 0);
bgColorStepperB = new FlxUINumericStepper(150, 40, 20, 255, 0, 255, 0);
var copyColor:FlxButton = new FlxButton(10, bgColorStepperR.y + 25, "Copy Color", function() {
Clipboard.text = bg.color.red + ',' + bg.color.green + ',' + bg.color.blue;
});
var pasteColor:FlxButton = new FlxButton(140, copyColor.y, "Paste Color", function() {
if(Clipboard.text != null) {
var leColor:Array<Int> = [];
var splitted:Array<String> = Clipboard.text.trim().split(',');
for (i in 0...splitted.length) {
var toPush:Int = Std.parseInt(splitted[i]);
if(!Math.isNaN(toPush)) {
if(toPush > 255) toPush = 255;
else if(toPush < 0) toPush *= -1;
leColor.push(toPush);
}
}
if(leColor.length > 2) {
bgColorStepperR.value = leColor[0];
bgColorStepperG.value = leColor[1];
bgColorStepperB.value = leColor[2];
updateBG();
}
}
});
iconInputText = new FlxUIInputText(10, bgColorStepperR.y + 70, 100, '', 8);
var hideFreeplayCheckbox:FlxUICheckBox = new FlxUICheckBox(10, iconInputText.y + 30, null, null, "Hide Week from Freeplay?", 100);
hideFreeplayCheckbox.checked = weekFile.hideFreeplay;
hideFreeplayCheckbox.callback = function()
{
weekFile.hideFreeplay = hideFreeplayCheckbox.checked;
};
tab_group.add(new FlxText(10, bgColorStepperR.y - 18, 0, 'Selected background Color R/G/B:'));
tab_group.add(new FlxText(10, iconInputText.y - 18, 0, 'Selected icon:'));
tab_group.add(bgColorStepperR);
tab_group.add(bgColorStepperG);
tab_group.add(bgColorStepperB);
tab_group.add(copyColor);
tab_group.add(pasteColor);
tab_group.add(iconInputText);
tab_group.add(hideFreeplayCheckbox);
UI_box.addGroup(tab_group);
}
function updateBG() {
weekFile.songs[curSelected][2][0] = Math.round(bgColorStepperR.value);
weekFile.songs[curSelected][2][1] = Math.round(bgColorStepperG.value);
weekFile.songs[curSelected][2][2] = Math.round(bgColorStepperB.value);
bg.color = FlxColor.fromRGB(weekFile.songs[curSelected][2][0], weekFile.songs[curSelected][2][1], weekFile.songs[curSelected][2][2]);
}
function changeSelection(change:Int = 0) {
FlxG.sound.play(Paths.sound('scrollMenu'), 0.4);
curSelected += change;
if (curSelected < 0)
curSelected = weekFile.songs.length - 1;
if (curSelected >= weekFile.songs.length)
curSelected = 0;
var bullShit:Int = 0;
for (i in 0...iconArray.length)
{
iconArray[i].alpha = 0.6;
}
iconArray[curSelected].alpha = 1;
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));
}
}
trace(weekFile.songs[curSelected]);
iconInputText.text = weekFile.songs[curSelected][1];
bgColorStepperR.value = Math.round(weekFile.songs[curSelected][2][0]);
bgColorStepperG.value = Math.round(weekFile.songs[curSelected][2][1]);
bgColorStepperB.value = Math.round(weekFile.songs[curSelected][2][2]);
updateBG();
}
override function update(elapsed:Float) {
if(WeekEditorState.loadedWeek != null) {
super.update(elapsed);
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
MusicBeatState.switchState(new WeekEditorFreeplayState(WeekEditorState.loadedWeek));
WeekEditorState.loadedWeek = null;
return;
}
if(iconInputText.hasFocus) {
FlxG.sound.muteKeys = [];
FlxG.sound.volumeDownKeys = [];
FlxG.sound.volumeUpKeys = [];
if(FlxG.keys.justPressed.ENTER) {
iconInputText.hasFocus = false;
}
} else {
FlxG.sound.muteKeys = TitleState.muteKeys;
FlxG.sound.volumeDownKeys = TitleState.volumeDownKeys;
FlxG.sound.volumeUpKeys = TitleState.volumeUpKeys;
if(FlxG.keys.justPressed.ESCAPE) {
FlxG.mouse.visible = false;
MusicBeatState.switchState(new editors.MasterEditorMenu());
FlxG.sound.playMusic(Paths.music('freakyMenu'));
}
if(controls.UI_UP_P) changeSelection(-1);
if(controls.UI_DOWN_P) changeSelection(1);
}
super.update(elapsed);
}
}