forked from FunkinCrew/Funkin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
Submodule assets
updated
1 files
+3 −1 | exclude/data/ui/char-creator/dialogs/playable-character-settings-dialog.xml |
87 changes: 87 additions & 0 deletions
87
source/funkin/ui/debug/char/components/dialogs/PlayableCharacterSettingsDialog.hx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,97 @@ | ||
package funkin.ui.debug.char.components.dialogs; | ||
|
||
import haxe.ui.containers.HBox; | ||
import haxe.ui.components.Button; | ||
import haxe.ui.components.DropDown; | ||
import haxe.ui.components.VerticalScroll; | ||
import haxe.ui.data.ArrayDataSource; | ||
import funkin.data.character.CharacterRegistry; | ||
import funkin.util.SortUtil; | ||
|
||
@:build(haxe.ui.macros.ComponentMacros.build("assets/exclude/data/ui/char-creator/dialogs/playable-character-settings-dialog.xml")) | ||
class PlayableCharacterSettingsDialog extends DefaultPageDialog | ||
{ | ||
var ownedCharBox:AddOwnedCharBox; | ||
|
||
override public function new(daPage:CharCreatorDefaultPage) | ||
{ | ||
super(daPage); | ||
|
||
ownedCharBox = new AddOwnedCharBox(); | ||
|
||
ownedCharsView.addComponent(ownedCharBox); | ||
} | ||
|
||
public function listOwnedCharacters():Array<String> | ||
{ | ||
return ownedCharBox.listOwnedCharacters(); | ||
} | ||
} | ||
|
||
private class AddOwnedCharBox extends HBox | ||
{ | ||
var dropDowns:Array<DropDown> = []; | ||
|
||
override public function new() | ||
{ | ||
super(); | ||
|
||
styleString = "border:1px solid $normal-border-color"; | ||
percentWidth = 100; | ||
height = 25; | ||
verticalAlign = "center"; | ||
|
||
var addButton = new Button(); | ||
addButton.text = "Add New Box"; | ||
var removeButton = new Button(); | ||
removeButton.text = "Remove Last Box"; | ||
|
||
addButton.percentWidth = removeButton.percentWidth = 50; | ||
addButton.percentHeight = removeButton.percentHeight = 100; | ||
|
||
addButton.onClick = function(_) { | ||
var parentList = this.parentComponent; | ||
if (parentList == null) return; | ||
|
||
var newDropDown = new DropDown(); | ||
newDropDown.dataSource = new ArrayDataSource(); | ||
newDropDown.height = 25; | ||
newDropDown.dropdownHeight = 100; | ||
newDropDown.percentWidth = 100; | ||
newDropDown.verticalAlign = "center"; | ||
newDropDown.searchable = true; | ||
var ids = CharacterRegistry.listCharacterIds(); | ||
ids.sort(SortUtil.alphabetically); | ||
for (id in ids) | ||
{ | ||
newDropDown.dataSource.add({text: id, id: id}); | ||
} | ||
dropDowns.push(newDropDown); | ||
|
||
parentList.addComponentAt(newDropDown, parentList.childComponents.length - 1); // considering this box is last | ||
removeButton.disabled = false; | ||
} | ||
|
||
removeButton.disabled = true; | ||
removeButton.onClick = function(_) { | ||
var parentList = this.parentComponent; | ||
if (parentList == null) return; | ||
|
||
dropDowns.pop(); | ||
|
||
parentList.removeComponentAt(parentList.childComponents.length - 2); | ||
if (parentList.childComponents.length <= 2) removeButton.disabled = true; | ||
} | ||
|
||
addComponent(addButton); | ||
addComponent(removeButton); | ||
} | ||
|
||
public function listOwnedCharacters():Array<String> | ||
{ | ||
return [ | ||
for (dropDown in dropDowns) | ||
dropDown.selectedItem.id | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters