Skip to content

Commit

Permalink
slightly better system for multisparrow
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 10, 2024
1 parent bef8ac2 commit 6123419
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class AddCharFilesDialog extends DefaultWizardDialog
addAssetsBox.addComponent(new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG));

case CharacterRenderType.MultiSparrow:
recursiveUploadBox();
addAssetsBox.addComponent(new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG));
addAssetsBox.addComponent(new AddAssetBox());

case CharacterRenderType.Packer:
addAssetsBox.addComponent(new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG));
Expand Down Expand Up @@ -81,7 +82,7 @@ class AddCharFilesDialog extends DefaultWizardDialog
// check if the files even exist
for (thingy in uploadBoxes)
{
if (!FileUtil.doesFileExist(thingy.daField.text)) return false;
if (!FileUtil.doesFileExist(thingy.daField.text) && !openfl.Assets.exists(thingy.daField.text)) return false;
}

// we do a little trollin
Expand All @@ -105,6 +106,7 @@ class AddCharFilesDialog extends DefaultWizardDialog
// testing if we could actually use these
var imgBytes = CharCreatorUtil.gimmeTheBytes(imgPath);
var xmlBytes = CharCreatorUtil.gimmeTheBytes(xmlPath);
if (imgBytes == null || xmlBytes == null) return false;

var tempSprite = new FlxSprite();
try
Expand Down Expand Up @@ -144,6 +146,7 @@ class AddCharFilesDialog extends DefaultWizardDialog
// testing if we could actually use these
var imgBytes = CharCreatorUtil.gimmeTheBytes(imgPath);
var txtBytes = CharCreatorUtil.gimmeTheBytes(txtPath);
if (imgBytes == null || txtBytes == null) return false;

var tempSprite = new FlxSprite();
try
Expand Down Expand Up @@ -230,13 +233,62 @@ class AddCharFilesDialog extends DefaultWizardDialog
}
}

class AddAssetBox extends HBox
{
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 first = parentList.childComponents[0];
if (!Std.isOfType(first, UploadAssetsBox)) return;

var firstBox:UploadAssetsBox = cast first;

var newBox = new UploadAssetsBox(firstBox.daField.placeholder, firstBox.lookFor);
parentList.addComponentAt(newBox, 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;

parentList.removeComponentAt(parentList.childComponents.length - 2);
if (parentList.childComponents.length <= 2) removeButton.disabled = true;
}

addComponent(addButton);
addComponent(removeButton);
}
}

class UploadAssetsBox extends HBox
{
public var daField:TextField;
public var lookFor:FileDialogExtensionInfo = null;

override public function new(title:String = "", lookFor:FileDialogExtensionInfo = null)
{
super();
this.lookFor = lookFor;

styleString = "border:1px solid $normal-border-color";
percentWidth = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CharSelectIndexSubPage extends FlxSpriteGroup
if (!isSelecting)
{
changeSelectedIcon();

updateIconAnims();
handleMousePress();

if (FlxG.keys.justPressed.X)
Expand Down Expand Up @@ -333,4 +333,31 @@ class CharSelectIndexSubPage extends FlxSpriteGroup

cursorLocIntended.put();
}

var selectedBizz:Array<openfl.filters.BitmapFilter> = [
new openfl.filters.DropShadowFilter(0, 0, 0xFFFFFF, 1, 2, 2, 19, 1, false, false, false),
new openfl.filters.DropShadowFilter(5, 45, 0x000000, 1, 2, 2, 1, 1, false, false, false)
];

function updateIconAnims():Void
{
for (index => member in grpIcons.group.members)
{
if (Std.isOfType(member, PixelatedIcon))
{
var memb:PixelatedIcon = cast member;

if (index == cursorIndex)
{
memb.filters = selectedBizz;
memb.scale.set(2.6, 2.6);
}
else
{
memb.filters = null;
memb.scale.set(2, 2);
}
}
}
}
}

0 comments on commit 6123419

Please sign in to comment.