Small fixes

This commit is contained in:
NeeEoo
2023-08-12 13:22:28 +02:00
parent 046fdff3b4
commit 4985ffbd86
20 changed files with 72 additions and 56 deletions
-1
View File
@@ -10,7 +10,6 @@ class DebugOptions extends TreeMenu {
super.create();
FlxG.camera.fade(0xFF000000, 0.5, true);
var bg:FlxSprite = new FlxSprite(-80).loadAnimatedGraphic(Paths.image('menus/menuBGBlue'));
// bg.scrollFactor.set();
@@ -58,7 +58,7 @@ class CharacterAnimButtons extends UIButton {
public override function update(elapsed:Float) {
editButton.selectable = ghostButton.selectable = deleteButton.selectable = selectable;
editButton.shouldPress = ghostButton.shouldPress = deleteButton.shouldPress = shouldPress;
hovered = !deleteButton.hovered;
updatePos();
super.update(elapsed);
@@ -117,7 +117,7 @@ class CharacterAnimScreen extends UISubstateWindow {
if (i != null)
animData.indices.push(i);
}
if (onSave != null) onSave(animData);
}
}
@@ -33,7 +33,7 @@ class CharacterEditor extends UIState {
// WINDOWS
public var characterPropertiresWindow:CharacterPropertiesWindow;
public var characterAnimsWindow:UIButtonList<CharacterAnimButtons>;
// camera for the character itself so that it can be unzoomed/zoomed in again
public var charCamera:FlxCamera;
// camera for the animations list
@@ -51,7 +51,7 @@ class CharacterEditor extends UIState {
public override function create() {
super.create();
topMenu = [
{
label: "File",
@@ -334,7 +334,7 @@ class CharacterEditor extends UIState {
function _file_save(_) {
#if sys
sys.io.File.saveContent(
Assets.getPath(Paths.xml('characters/${character.curCharacter}')),
Assets.getPath(Paths.xml('characters/${character.curCharacter}')),
buildCharacter()
);
return;
@@ -386,7 +386,7 @@ class CharacterEditor extends UIState {
character.animOffsets.set(anim, offsets.clone());
ghosts.setOffsets(anim, offsets.clone());
}
for (charButton in characterAnimsWindow.buttons.members)
charButton.updateInfo(charButton.anim, character.getAnimOffset(charButton.anim), ghosts.animGhosts[charButton.anim].visible);
@@ -462,7 +462,7 @@ class CharacterEditor extends UIState {
public function editAnim(name:String, animData:AnimData, addtoUndo:Bool = true) {
var oldAnimData:AnimData = character.animDatas.get(name);
var buttoner:CharacterAnimButtons = null;
for (button in characterAnimsWindow.buttons.members)
for (button in characterAnimsWindow.buttons.members)
if (button.anim == name) buttoner = button;
ghosts.removeGhost(name);
@@ -528,7 +528,7 @@ class CharacterEditor extends UIState {
ghost.visible = !ghost.visible;
var animButton:CharacterAnimButtons = null;
for (button in characterAnimsWindow.buttons.members)
for (button in characterAnimsWindow.buttons.members)
if (button.anim == anim) animButton = button;
animButton.updateInfo(anim, character.getAnimOffset(anim), ghost.visible);
}
@@ -590,8 +590,8 @@ class CharacterEditor extends UIState {
if (character.getNameList().length == 0) return;
character.animOffsets.set(anim, character.getAnimOffset(anim) + change);
for (i in characterAnimsWindow.buttons.members)
if (i.anim == anim)
for (i in characterAnimsWindow.buttons.members)
if (i.anim == anim)
i.updateInfo(anim, character.getAnimOffset(anim), ghosts.animGhosts[anim].visible);
character.frameOffset.set(character.getAnimOffset(anim).x, character.getAnimOffset(anim).y);
@@ -610,8 +610,8 @@ class CharacterEditor extends UIState {
];
for (anim in character.getNameList()) {
character.animOffsets[anim].zero();
for (i in characterAnimsWindow.buttons.members)
if (i.anim == anim)
for (i in characterAnimsWindow.buttons.members)
if (i.anim == anim)
i.updateInfo(anim, character.getAnimOffset(anim), ghosts.animGhosts[anim].visible);
}
@@ -12,7 +12,7 @@ class CharacterGhostsHandler extends FlxTypedGroup<Character> {
this.character = character;
super();
for (anim in character.getNameList())
for (anim in character.getNameList())
createGhost(anim);
}
@@ -21,7 +21,7 @@ class CharacterGhostsHandler extends FlxTypedGroup<Character> {
ghost.applyXML(character.xml); // apply cur character stuff
ghost.playAnim(anim);
ghost.stopAnimation();
ghost.alpha = 0.5;
ghost.alpha = 0.5;
ghost.visible = false;
add(ghost);
@@ -69,7 +69,7 @@ class CharacterGhostsHandler extends FlxTypedGroup<Character> {
}
inline function rePositionGhosts() {
for (ghost in animGhosts)
for (ghost in animGhosts)
ghost.frameOffset.set(ghost.getAnimOffset(ghost.getAnimName()).x, ghost.getAnimOffset(ghost.getAnimName()).y);
}
}
@@ -47,7 +47,7 @@ class ChartDataScreen extends UISubstateWindow {
close();
}, 125);
add(saveButton);
closeButton = new UIButton(saveButton.x - 20, saveButton.y, "Close", function() {
close();
}, 125);
@@ -59,7 +59,7 @@ class ChartDataScreen extends UISubstateWindow {
public function saveInfo()
{
@:privateAccess scrollSpeedStepper.__onChange(scrollSpeedStepper.label.text);
PlayState.SONG.stage = stageTextBox.label.text;
PlayState.SONG.scrollSpeed = scrollSpeedStepper.value;
}
+17 -17
View File
@@ -348,7 +348,7 @@ class Charter extends UIState {
sectionSeparator.y = -2;
sectionSeparator.visible = Options.charterShowSections;
beatSeparator = new FlxBackdrop(null, Y, 0, 0);
beatSeparator.x = -10;
beatSeparator.x = -10;
beatSeparator.y = -1;
sectionSeparator.visible = Options.charterShowBeats;
for(sep in [sectionSeparator, beatSeparator]) {
@@ -414,7 +414,7 @@ class Charter extends UIState {
strumlineAddButton.cameras = [charterCamera];
strumlineInfoBG.cameras = [charterCamera];
strumLines.cameras = [charterCamera];
addEventSpr = new CharterEventAdd();
addEventSpr.alpha = 0;
addEventSpr.cameras = [charterCamera];
@@ -522,7 +522,7 @@ class Charter extends UIState {
cast(group, FlxTypedGroup<Dynamic>).forEach(function(n) {
n.selected = false;
if (n.hovered && gridActionType == NONE) {
if (FlxG.mouse.justReleased) {
if (FlxG.mouse.justReleased) {
if (FlxG.keys.pressed.CONTROL)
selection.push(cast n);
else if (FlxG.keys.pressed.SHIFT)
@@ -559,18 +559,18 @@ class Charter extends UIState {
selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y));
} else {
if (FlxG.keys.pressed.SHIFT) {
for (group in [notesGroup, eventsGroup])
for (group in [notesGroup, eventsGroup])
for(n in cast(group, FlxTypedGroup<Dynamic>))
if (n.handleSelection(selectionBox) && selection.contains(n))
selection.remove(n);
} else if (FlxG.keys.pressed.CONTROL) {
for (group in [notesGroup, eventsGroup])
for (group in [notesGroup, eventsGroup])
for(n in cast(group, FlxTypedGroup<Dynamic>))
if (n.handleSelection(selectionBox) && !selection.contains(n))
selection.push(n);
} else {
selection = [];
for (group in [notesGroup, eventsGroup])
for (group in [notesGroup, eventsGroup])
for(n in cast(group, FlxTypedGroup<Dynamic>))
if (n.handleSelection(selectionBox))
selection.push(n);
@@ -612,7 +612,7 @@ class Charter extends UIState {
currentCursor = ARROW;
}
case NONE:
if (FlxG.mouse.justPressed)
FlxG.mouse.getWorldPosition(charterCamera, dragStartPos);
@@ -786,9 +786,9 @@ class Charter extends UIState {
while(i < notesGroup.members.length) {
var note = notesGroup.members[i];
if (Std.int(note.id / 4) == strumLineID) { // thanks neo lol!!!!!
deletedstrumNotes.push(note);
deletedstrumNotes.push(note);
deleteSingleSelection(note, false);
} else
} else
i++;
}
@@ -803,7 +803,7 @@ class Charter extends UIState {
if (addToUndo) {
var newStrL = Reflect.copy(strL);
newStrL.notes.clear();
for (note in deletedstrumNotes) {
var time = Conductor.getTimeForStep(note.step);
newStrL.notes.push({
@@ -843,7 +843,7 @@ class Charter extends UIState {
}
public inline function removeStrumlineFromSelection(strumLineID:Int) {
var i = 0;
var i = 0;
while(i < selection.length) {
if (selection[i] is CharterNote) {
var note = cast (selection[i], CharterNote);
@@ -1013,7 +1013,7 @@ class Charter extends UIState {
var metaDiffPath = Paths.file('songs/${__song.toLowerCase()}/meta-${__diff.toLowerCase()}.json');
sys.io.File.saveContent(
Assets.getPath(Assets.exists(metaDiffPath) ? metaDiffPath : metaPath),
Assets.getPath(Assets.exists(metaDiffPath) ? metaDiffPath : metaPath),
Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t")
);
return;
@@ -1036,8 +1036,8 @@ class Charter extends UIState {
function _edit_copy(_) {
if(selection.length == 0) return;
var minStep:Float = selection[0].step;
var minStep:Float = selection[0].step;
for(s in selection)
if (s.step < minStep) minStep = s.step;
@@ -1101,7 +1101,7 @@ class Charter extends UIState {
case CDeleteSelection(selection):
createSelection(selection, false);
case CSelectionDrag(selection, change):
for (s in selection)
for (s in selection)
if (s.draggable) s.handleDrag(change * -1);
this.selection = selection;
case CEditSustains(changes):
@@ -1144,7 +1144,7 @@ class Charter extends UIState {
case CDeleteSelection(selection):
deleteSelection(selection, false);
case CSelectionDrag(selection, change):
for (s in selection)
for (s in selection)
if (s.draggable) s.handleDrag(change);
this.selection = selection;
case CEditSustains(changes):
@@ -1176,7 +1176,7 @@ class Charter extends UIState {
FlxG.state.openSubState(new ChartDataScreen(PlayState.SONG));
function chart_edit_metadata(_)
FlxG.state.openSubState(new MetaDataScreen(PlayState.SONG.meta));
function _playback_metronome(t) {
t.icon = (Options.charterMetronomeEnabled = !Options.charterMetronomeEnabled) ? 1 : 0;
}
@@ -8,10 +8,10 @@ class CharterBackdrop extends FlxBackdrop {
public function new() {
super(null, Y, 0, 0);
makeGraphic(160, 160, 0xFF272727, true);
pixels.lock();
// Checkerboard
for(y in 0...4)
for(x in 0...2)
@@ -20,7 +20,7 @@ class CharterEventScreen extends UISubstateWindow {
public var paramsPanel:FlxGroup;
public var paramsFields:Array<FlxBasic> = [];
public var saveButton:UIButton;
public var closeButton:UIButton;
@@ -66,7 +66,7 @@ class CharterEventScreen extends UISubstateWindow {
saveCurTab();
chartEvent.refreshEventIcons();
if (events.length <= 0 && !creatingEvent)
if (events.length <= 0 && !creatingEvent)
Charter.instance.deleteSelection([chartEvent]);
else if (events.length > 0) {
var oldEvents:Array<ChartEvent> = chartEvent.events.copy();
@@ -75,7 +75,7 @@ class CharterEventScreen extends UISubstateWindow {
];
if (creatingEvent && events.length > 0)
Charter.instance.createSelection([chartEvent]);
Charter.instance.createSelection([chartEvent]);
else {
chartEvent.events = [
for (i in eventsList.buttons.members) i.event
@@ -241,7 +241,7 @@ class EventButton extends UIButton {
members.push(deleteButton);
deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 4).loadGraphic(Paths.image('editors/character/delete-button'));
deleteIcon.antialiasing = false;
members.push(deleteIcon);
}
@@ -99,7 +99,7 @@ class CharterStrumlineButton extends UITopMenuButton {
}
},
{
label: "Delete",
label: "Delete",
onSelect: function (_) {
Charter.instance.deleteStrumlineFromData(strLine.strumLine);
}
@@ -13,7 +13,7 @@ class CharterStrumlineExtraButton extends UISprite {
scrollFactor.set(1, 0);
alpha = 0;
button = new UISprite();
button.loadGraphic(Paths.image(imagePath));
button.scale.set(0.75,0.75);
@@ -60,10 +60,10 @@ class CharterStrumlineScreen extends UISubstateWindow {
add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, creatingStrumLine ? "Create New Strumline" : "Edit Strumline Properties", 28));
charactersList = new UIButtonList<CharacterButton>(15, title.y + title.height + 36, 250, 259, "", FlxPoint.get(250, 54), null, 0);
charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0,0,"New Char", charactersList));
charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0, 0, "New Char", charactersList));
charactersList.cameraSpacing = 0;
for (i in strumLine.characters)
charactersList.add(new CharacterButton(0,0,i, charactersList));
for (i in strumLine.characters)
charactersList.add(new CharacterButton(0, 0, i, charactersList));
add(charactersList);
addLabelOn(charactersList, "Characters");
@@ -176,7 +176,11 @@ class CharacterButton extends UIButton {
members.push(textBox = new UITextBox(charIcon.x + charIcon.width + 16, bHeight/2 - (32/2), char, 115));
textBox.antialiasing = true;
textBox.onChange = function(char:String) {
charIcon.loadGraphic(Assets.exists(Paths.image("icons/" + char)) ? Paths.image("icons/" + char) : Paths.image("icons/face"), true, 150, 150);
char = Character.getIconFromCharName(char);
var image = Paths.image("icons/" + char);
if(!Assets.exists(image))
image = Paths.image("icons/face");
charIcon.loadGraphic(image, true, 150, 150);
charIcon.updateHitbox();
}
@@ -185,7 +189,7 @@ class CharacterButton extends UIButton {
}, 32);
deleteButton.color = 0xFFFF0000;
members.push(deleteButton);
deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/character/delete-button'));
deleteIcon.antialiasing = false;
members.push(deleteIcon);
@@ -201,5 +205,5 @@ class CharacterButton extends UIButton {
deleteButton.shouldPress = shouldPress;
super.update(elapsed);
}
}
}
@@ -27,7 +27,6 @@ class CharterWaveForms extends FlxTypedGroup<WaveformSprite> {
Conductor.getTimeForStep((measure+1) * Conductor.getMeasureLength())
);
add(waveFormMeasure);
}
}
@@ -78,7 +77,7 @@ class WaveformSprite extends FlxSprite {
startPos -= startPos % buffer.bitsPerSample;
endPos -= endPos % buffer.bitsPerSample;
pixels.lock();
pixels.fillRect(new Rectangle(0, 0, pixels.width, pixels.height), 0);
pixels.fillRect(new Rectangle(0, 0, pixels.width, pixels.height), 0);
var diff = endPos - startPos;
var diffRange = Math.floor(diff / pixels.height);
for(y in 0...pixels.height) {
@@ -42,10 +42,10 @@ class SongCreationScreen extends UISubstateWindow {
super();
if (onSave != null) this.onSave = onSave;
}
public override function create() {
winTitle = "Creating New Song";
winWidth = 748 - 32 + 40;
winHeight = 520;
@@ -157,7 +157,7 @@ class SongCreationScreen extends UISubstateWindow {
windowSpr.bWidth = Std.int(pageSizes[curPage].x);
windowSpr.bHeight = Std.int(pageSizes[curPage].y);
titleSpr.x = windowSpr.x + 25;
titleSpr.x = windowSpr.x + 25;
titleSpr.y = windowSpr.y + ((30 - titleSpr.height) / 2);
saveButton.field.text = curPage == pages.length-1 ? "Save & Close" : 'Next (${curPage+1+1}/${pages.length}) >';
+1
View File
@@ -7,4 +7,5 @@ interface IUIFocusable {
public function onKeyDown(e:KeyCode, modifier:KeyModifier):Void;
public function onKeyUp(e:KeyCode, modifier:KeyModifier):Void;
public function onTextInput(text:String):Void;
public function onTextEdit(text:String, start:Int, end:Int):Void;
}
+1 -1
View File
@@ -110,7 +110,7 @@ class UIButtonList<T:UIButton> extends UIWindow {
nextscrollY -= Math.min((bHeight - 100) - FlxG.mouse.getWorldPosition(buttonCameras).y, 0) / 8;
nextscrollY += Math.min(FlxG.mouse.getWorldPosition(buttonCameras).y - 100, 0) / 8;
}
buttonCameras.scroll.y = nextscrollY;
for (button in buttons) {
+6
View File
@@ -37,6 +37,7 @@ class UIState extends MusicBeatState {
FlxG.stage.window.onKeyDown.add(onKeyDown);
FlxG.stage.window.onKeyUp.add(onKeyUp);
FlxG.stage.window.onTextInput.add(onTextInput);
FlxG.stage.window.onTextEdit.add(onTextEdit);
}
private function onKeyDown(e:KeyCode, modifier:KeyModifier) {
@@ -53,6 +54,10 @@ class UIState extends MusicBeatState {
if (currentFocus != null)
currentFocus.onTextInput(str);
}
private function onTextEdit(str:String, start:Int, end:Int) {
if (currentFocus != null)
currentFocus.onTextEdit(str, start, end);
}
public function updateButtonHandler(spr:UISprite, buttonHandler:Void->Void) {
spr.__rect.x = spr.x;
@@ -119,6 +124,7 @@ class UIState extends MusicBeatState {
FlxG.stage.window.onKeyDown.remove(onKeyDown);
FlxG.stage.window.onKeyUp.remove(onKeyUp);
FlxG.stage.window.onTextInput.remove(onTextInput);
FlxG.stage.window.onTextEdit.remove(onTextEdit);
}
public function closeCurrentContextMenu() {
+6
View File
@@ -137,4 +137,10 @@ class UITextBox extends UISliceSprite implements IUIFocusable {
label.text = label.text.substr(0, position) + text + label.text.substr(position);
position += text.length;
}
// untested, but this should be a fix for if the text wont type
public function onTextEdit(text:String, start:Int, end:Int):Void {
trace(text, start, end);
label.text = label.text.substr(0, position) + text + label.text.substr(position);
position += text.length;
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ class UIWindow extends UISliceSprite {
public override function new(x:Float, y:Float, w:Int, h:Int, title:String) {
super(x, y, w, h, "editors/ui/warning-popup");
members.push(titleSpr = new UIText(x + 25, y, bWidth - 50, title, 15, -1));
titleSpr.y = y + ((30 - titleSpr.height) / 2);
}
+1
View File
@@ -126,6 +126,7 @@ class FreeplayState extends MusicBeatState
bg = new FlxSprite(0, 0).loadAnimatedGraphic(Paths.image('menus/menuDesat'));
if (songs.length > 0)
bg.color = songs[0].color;
bg.antialiasing = true;
add(bg);
grpSongs = new FlxTypedGroup<Alphabet>();