last polishes to this menu
This commit is contained in:
@@ -1,29 +1,24 @@
|
|||||||
package funkin.editors.charter;
|
package funkin.editors.charter;
|
||||||
|
|
||||||
|
import funkin.game.Character;
|
||||||
|
import funkin.game.Stage;
|
||||||
import funkin.game.HealthIcon;
|
import funkin.game.HealthIcon;
|
||||||
import funkin.backend.chart.ChartData;
|
import funkin.backend.chart.ChartData;
|
||||||
import haxe.io.Bytes;
|
import haxe.io.Bytes;
|
||||||
|
|
||||||
typedef ChartCreationData = {
|
|
||||||
var name:String;
|
|
||||||
var chart:ChartData;
|
|
||||||
var ?meta:Dynamic;
|
|
||||||
var ?instBytes:Bytes;
|
|
||||||
var ?voicesBytes:Bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChartCreationScreen extends UISubstateWindow {
|
class ChartCreationScreen extends UISubstateWindow {
|
||||||
private var onSave:Null<ChartCreationData> -> Void = null;
|
private var onSave:(String, ChartData) -> Void = null;
|
||||||
|
public var charFileList:Array<String> = [];
|
||||||
|
|
||||||
public var difficultyNameTextBox:UITextBox;
|
public var difficultyNameTextBox:UITextBox;
|
||||||
public var scrollSpeedTextBox:UINumericStepper;
|
public var scrollSpeedTextBox:UINumericStepper;
|
||||||
public var stageTextBox:UITextBox;
|
public var stageTextBox:UIAutoCompleteTextBox;
|
||||||
public var strumLineList:UIButtonList<StrumLineButton>;
|
public var strumLineList:UIButtonList<StrumLineButton>;
|
||||||
|
|
||||||
public var saveButton:UIButton;
|
public var saveButton:UIButton;
|
||||||
public var closeButton:UIButton;
|
public var closeButton:UIButton;
|
||||||
|
|
||||||
public function new(?onSave:ChartCreationData->Void) {
|
public function new(?onSave:(String, ChartData)->Void) {
|
||||||
super();
|
super();
|
||||||
if (onSave != null) this.onSave = onSave;
|
if (onSave != null) this.onSave = onSave;
|
||||||
}
|
}
|
||||||
@@ -42,18 +37,31 @@ class ChartCreationScreen extends UISubstateWindow {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
charFileList = Character.getList(true);
|
||||||
|
if (charFileList.length == 0) charFileList = Character.getList(false);
|
||||||
|
|
||||||
var chartTitle:UIText;
|
var chartTitle:UIText;
|
||||||
add(chartTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, "Chart Info", 28));
|
add(chartTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, "Chart Info", 28));
|
||||||
|
|
||||||
difficultyNameTextBox = new UITextBox(chartTitle.x, chartTitle.y + chartTitle.height + 36, "Difficulty Name", 200);
|
difficultyNameTextBox = new UITextBox(chartTitle.x, chartTitle.y + chartTitle.height + 36, "difficulty", 200);
|
||||||
add(difficultyNameTextBox);
|
add(difficultyNameTextBox);
|
||||||
addLabelOn(difficultyNameTextBox, "Difficulty Name");
|
addLabelOn(difficultyNameTextBox, "Difficulty Name");
|
||||||
|
|
||||||
stageTextBox = new UITextBox(difficultyNameTextBox.x + 200 + 26, difficultyNameTextBox.y, "Stage", 125);
|
var stageFileList = Stage.getList(true);
|
||||||
|
if (stageFileList.length == 0) stageFileList = Stage.getList(false);
|
||||||
|
|
||||||
|
stageTextBox = new UIAutoCompleteTextBox(difficultyNameTextBox.x + 200 + 26, difficultyNameTextBox.y, "stage", 180);
|
||||||
|
stageTextBox.suggestItems = stageFileList;
|
||||||
add(stageTextBox);
|
add(stageTextBox);
|
||||||
addLabelOn(stageTextBox, "Stage");
|
addLabelOn(stageTextBox, "Stage");
|
||||||
|
|
||||||
scrollSpeedTextBox = new UINumericStepper(stageTextBox.x + 125 + 26, difficultyNameTextBox.y, 1.0, 0.1, 2, null, null, 90);
|
scrollSpeedTextBox = new UINumericStepper(stageTextBox.x + 180 + 26, difficultyNameTextBox.y, 1.0, 0.1, 2, null, null, 90);
|
||||||
|
scrollSpeedTextBox.onChange = function (text:String) {
|
||||||
|
@:privateAccess scrollSpeedTextBox.__onChange(text);
|
||||||
|
for (button in strumLineList.buttons.members)
|
||||||
|
if (button.usesChartscrollSpeed.checked)
|
||||||
|
button.scrollSpeedStepper.value = scrollSpeedTextBox.value;
|
||||||
|
}
|
||||||
add(scrollSpeedTextBox);
|
add(scrollSpeedTextBox);
|
||||||
addLabelOn(scrollSpeedTextBox, "Scroll Speed");
|
addLabelOn(scrollSpeedTextBox, "Scroll Speed");
|
||||||
|
|
||||||
@@ -68,40 +76,22 @@ class ChartCreationScreen extends UISubstateWindow {
|
|||||||
position: "DAD",
|
position: "DAD",
|
||||||
strumPos: [0, 50],
|
strumPos: [0, 50],
|
||||||
strumLinePos: 0.25,
|
strumLinePos: 0.25,
|
||||||
scrollSpeed: 1,
|
|
||||||
}, strumLineList));
|
}, strumLineList));
|
||||||
}
|
}
|
||||||
strumLineList.add(new StrumLineButton(0, {
|
strumLineList.add(new StrumLineButton(strumLineList.buttons.length, {
|
||||||
characters: ["dad"],
|
|
||||||
type: 0,
|
|
||||||
notes: null,
|
|
||||||
position: "DAD",
|
|
||||||
strumPos: [0, 50],
|
|
||||||
strumLinePos: 0.25,
|
|
||||||
scrollSpeed: 1,
|
|
||||||
}, strumLineList));
|
|
||||||
strumLineList.add(new StrumLineButton(1, {
|
|
||||||
characters: ["bf"],
|
characters: ["bf"],
|
||||||
type: 1,
|
type: 0,
|
||||||
notes: null,
|
notes: null,
|
||||||
position: "BOYFRIEND",
|
position: "BOYFRIEND",
|
||||||
strumPos: [0, 50],
|
strumPos: [0, 50],
|
||||||
strumLinePos: 0.75,
|
strumLinePos: 0.75,
|
||||||
scrollSpeed: 1,
|
|
||||||
}, strumLineList));
|
|
||||||
strumLineList.add(new StrumLineButton(1, {
|
|
||||||
characters: ["gf"],
|
|
||||||
type: 2,
|
|
||||||
notes: null,
|
|
||||||
position: "GIRLFRIEND",
|
|
||||||
strumPos: [0, 50],
|
|
||||||
strumLinePos: 0.50,
|
|
||||||
scrollSpeed: 1,
|
|
||||||
visible: false,
|
|
||||||
}, strumLineList));
|
}, strumLineList));
|
||||||
add(strumLineList);
|
add(strumLineList);
|
||||||
addLabelOn(strumLineList, "Strumlines");
|
addLabelOn(strumLineList, "Strumlines");
|
||||||
|
|
||||||
|
strumLineList.dragCallback = (object:StrumLineButton, oldIndex:Int, newIndex:Int) -> {object.idText.text = 'Strumline - #${newIndex}';};
|
||||||
|
scrollSpeedTextBox.onChange(scrollSpeedTextBox.label.text);
|
||||||
|
|
||||||
saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Create Chart", function() {
|
saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Create Chart", function() {
|
||||||
createChart();
|
createChart();
|
||||||
close();
|
close();
|
||||||
@@ -116,9 +106,14 @@ class ChartCreationScreen extends UISubstateWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createChart() {
|
function createChart() {
|
||||||
var strlines = [];
|
scrollSpeedTextBox.onChange(scrollSpeedTextBox.label.text);
|
||||||
|
|
||||||
|
var strumLines:Array<ChartStrumLine> = [];
|
||||||
for (strline in strumLineList.buttons.members) {
|
for (strline in strumLineList.buttons.members) {
|
||||||
strlines.push({
|
for (stepper in [strline.hudXStepper, strline.hudYStepper, strline.hudScaleStepper])
|
||||||
|
@:privateAccess stepper.__onChange(stepper.label.text);
|
||||||
|
|
||||||
|
strumLines.push({
|
||||||
characters: [for (charb in strline.charactersList.buttons.members) charb.textBox.label.text],
|
characters: [for (charb in strline.charactersList.buttons.members) charb.textBox.label.text],
|
||||||
type: strline.typeDropdown.index,
|
type: strline.typeDropdown.index,
|
||||||
notes: [],
|
notes: [],
|
||||||
@@ -130,9 +125,10 @@ class ChartCreationScreen extends UISubstateWindow {
|
|||||||
scrollSpeed: strline.usesChartscrollSpeed.checked ? strline.scrollSpeedStepper.value : null
|
scrollSpeed: strline.usesChartscrollSpeed.checked ? strline.scrollSpeedStepper.value : null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var chartData:ChartData = {
|
var chartData:ChartData = {
|
||||||
codenameChart: true,
|
codenameChart: true,
|
||||||
strumLines: strlines,
|
strumLines: strumLines,
|
||||||
stage: stageTextBox.label.text,
|
stage: stageTextBox.label.text,
|
||||||
scrollSpeed: scrollSpeedTextBox.value,
|
scrollSpeed: scrollSpeedTextBox.value,
|
||||||
events: [],
|
events: [],
|
||||||
@@ -140,10 +136,7 @@ class ChartCreationScreen extends UISubstateWindow {
|
|||||||
meta: null
|
meta: null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onSave != null) onSave({
|
if (onSave != null) onSave(difficultyNameTextBox.label.text, chartData);
|
||||||
name: difficultyNameTextBox.label.text,
|
|
||||||
chart: chartData,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +162,7 @@ class StrumLineButton extends UIButton {
|
|||||||
public function new(id:Int, strumLine:ChartStrumLine, parent:UIButtonList<StrumLineButton>) {
|
public function new(id:Int, strumLine:ChartStrumLine, parent:UIButtonList<StrumLineButton>) {
|
||||||
super(0, 0, '', function () {}, 620, 246);
|
super(0, 0, '', function () {}, 620, 246);
|
||||||
|
|
||||||
|
var subState:ChartCreationScreen = cast FlxG.state.subState;
|
||||||
autoAlpha = false; frames = Paths.getFrames('editors/ui/inputbox');
|
autoAlpha = false; frames = Paths.getFrames('editors/ui/inputbox');
|
||||||
|
|
||||||
function addLabelOn(ui:UISprite, text:String, ?size:Int):UIText {
|
function addLabelOn(ui:UISprite, text:String, ?size:Int):UIText {
|
||||||
@@ -180,7 +174,7 @@ class StrumLineButton extends UIButton {
|
|||||||
charactersList = new UIButtonList<CompactCharacterButton>(16, 8+26, 210, 160, "", FlxPoint.get(200, 40), null, 5);
|
charactersList = new UIButtonList<CompactCharacterButton>(16, 8+26, 210, 160, "", FlxPoint.get(200, 40), null, 5);
|
||||||
charactersList.frames = Paths.getFrames('editors/ui/inputbox');
|
charactersList.frames = Paths.getFrames('editors/ui/inputbox');
|
||||||
charactersList.cameraSpacing = 0;
|
charactersList.cameraSpacing = 0;
|
||||||
charactersList.add(new CompactCharacterButton(strumLine.characters[0], [], charactersList));
|
charactersList.add(new CompactCharacterButton(strumLine.characters[0], subState.charFileList, charactersList));
|
||||||
members.push(charactersList);
|
members.push(charactersList);
|
||||||
idText = addLabelOn(charactersList, 'Strumline - #$id');
|
idText = addLabelOn(charactersList, 'Strumline - #$id');
|
||||||
|
|
||||||
@@ -217,24 +211,17 @@ class StrumLineButton extends UIButton {
|
|||||||
members.push(visibleCheckbox);
|
members.push(visibleCheckbox);
|
||||||
|
|
||||||
scrollSpeedStepper = new UINumericStepper(typeDropdown.x, typeDropdown.y + 128, strumLine.scrollSpeed, 0.1, 2, 0, 10, 82);
|
scrollSpeedStepper = new UINumericStepper(typeDropdown.x, typeDropdown.y + 128, strumLine.scrollSpeed, 0.1, 2, 0, 10, 82);
|
||||||
if(strumLine.scrollSpeed == null)
|
scrollSpeedStepper.selectable = strumLine.scrollSpeed != null;
|
||||||
{
|
|
||||||
scrollSpeedStepper.selectable = false;
|
|
||||||
} else {
|
|
||||||
scrollSpeedStepper.selectable = true;
|
|
||||||
}
|
|
||||||
members.push(scrollSpeedStepper);
|
members.push(scrollSpeedStepper);
|
||||||
addLabelOn(scrollSpeedStepper, "Scroll Speed");
|
addLabelOn(scrollSpeedStepper, "Scroll Speed");
|
||||||
|
|
||||||
usesChartscrollSpeed = new UICheckbox(scrollSpeedStepper.x + 104, typeDropdown.y + 135, "Uses charts scroll speed?", strumLine.scrollSpeed == null);
|
usesChartscrollSpeed = new UICheckbox(scrollSpeedStepper.x + 104, typeDropdown.y + 135, "Uses charts scroll speed?", strumLine.scrollSpeed == null);
|
||||||
usesChartscrollSpeed.onChecked = function(b) {
|
usesChartscrollSpeed.onChecked = function(b) {
|
||||||
if(b)
|
if(b) {
|
||||||
{
|
scrollSpeedStepper.value = subState.scrollSpeedTextBox.value;
|
||||||
scrollSpeedStepper.value = PlayState.SONG.scrollSpeed;
|
|
||||||
scrollSpeedStepper.selectable = false;
|
scrollSpeedStepper.selectable = false;
|
||||||
} else {
|
} else
|
||||||
scrollSpeedStepper.selectable = true;
|
scrollSpeedStepper.selectable = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
members.push(usesChartscrollSpeed);
|
members.push(usesChartscrollSpeed);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package funkin.editors.charter;
|
package funkin.editors.charter;
|
||||||
|
|
||||||
|
import funkin.backend.chart.ChartData;
|
||||||
import funkin.backend.chart.ChartData.ChartMetaData;
|
import funkin.backend.chart.ChartData.ChartMetaData;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
import funkin.backend.assets.ModsFolder;
|
import funkin.backend.assets.ModsFolder;
|
||||||
import funkin.editors.charter.SongCreationScreen.SongCreationData;
|
import funkin.editors.charter.SongCreationScreen.SongCreationData;
|
||||||
import funkin.editors.charter.ChartCreationScreen.ChartCreationData;
|
|
||||||
import funkin.options.type.NewOption;
|
import funkin.options.type.NewOption;
|
||||||
import funkin.backend.system.framerate.Framerate;
|
import funkin.backend.system.framerate.Framerate;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
@@ -133,8 +133,8 @@ class CharterSelection extends EditorTreeMenu {
|
|||||||
main.insert(1, option);
|
main.insert(1, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveChart(creation:ChartCreationData) {
|
public function saveChart(name:String, data:ChartData) {
|
||||||
var difficultyAlreadlyExsits:Bool = curSong.difficulties.contains(creation.name);
|
var difficultyAlreadlyExsits:Bool = curSong.difficulties.contains(name);
|
||||||
|
|
||||||
if (difficultyAlreadlyExsits) {
|
if (difficultyAlreadlyExsits) {
|
||||||
openSubState(new UIWarningSubstate("Creating Chart: Error!", "The chart you are trying to create alreadly exists, if you would like to override it delete the chart first!", [
|
openSubState(new UIWarningSubstate("Creating Chart: Error!", "The chart you are trying to create alreadly exists, if you would like to override it delete the chart first!", [
|
||||||
@@ -148,20 +148,20 @@ class CharterSelection extends EditorTreeMenu {
|
|||||||
|
|
||||||
// Save Files
|
// Save Files
|
||||||
#if sys
|
#if sys
|
||||||
sys.io.File.saveContent('$songFolder/charts/${creation.name}.json', Json.stringify(creation.chart, "\t"));
|
sys.io.File.saveContent('$songFolder/charts/${name}.json', Json.stringify(data, "\t"));
|
||||||
#end
|
#end
|
||||||
|
|
||||||
// Add to List
|
// Add to List
|
||||||
curSong.difficulties.push(creation.name);
|
curSong.difficulties.push(name);
|
||||||
var option = new TextOption(creation.name, "Press ACCEPT to edit the chart for the selected difficulty", function() {
|
var option = new TextOption(name, "Press ACCEPT to edit the chart for the selected difficulty", function() {
|
||||||
FlxG.switchState(new Charter(curSong.name, creation.name));
|
FlxG.switchState(new Charter(curSong.name, name));
|
||||||
});
|
});
|
||||||
main.insert(main.length - 2, option);
|
main.insert(main.length - 2, option);
|
||||||
|
|
||||||
// Add to Meta
|
// Add to Meta
|
||||||
var meta = Json.parse(sys.io.File.getContent('$songFolder/meta.json'));
|
var meta = Json.parse(sys.io.File.getContent('$songFolder/meta.json'));
|
||||||
if (meta.difficulties != null && !meta.difficulties.contains(creation.name)) {
|
if (meta.difficulties != null && !meta.difficulties.contains(name)) {
|
||||||
meta.difficulties.push(creation.name);
|
meta.difficulties.push(name);
|
||||||
sys.io.File.saveContent('$songFolder/meta.json', Json.stringify(meta));
|
sys.io.File.saveContent('$songFolder/meta.json', Json.stringify(meta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user