Skip to content

Commit

Permalink
remove a bunch of unnecessary casts
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 17, 2024
1 parent 7b24398 commit a4f5e94
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AddAnimDialog extends DefaultPageDialog
{
public var linkedChar:CharCreatorCharacter = null;

override public function new(daPage:CharCreatorDefaultPage, char:CharCreatorCharacter)
override public function new(daPage:CharCreatorGameplayPage, char:CharCreatorCharacter)
{
super(daPage);
linkedChar = char;
Expand Down Expand Up @@ -86,7 +86,7 @@ class AddAnimDialog extends DefaultPageDialog

if (linkedChar.generatedParams.importedCharacter == null)
{
cast(page, CharCreatorGameplayPage).ghostCharacter.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos],
daPage.ghostCharacter.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos],
(shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected);
}

Expand All @@ -98,7 +98,7 @@ class AddAnimDialog extends DefaultPageDialog
if ((charAnimName.text ?? "") == "") return;

if (!char.removeAnimation(charAnimName.text)) return;
if (linkedChar.generatedParams.importedCharacter == null) cast(page, CharCreatorGameplayPage).ghostCharacter.removeAnimation(charAnimName.text);
if (linkedChar.generatedParams.importedCharacter == null) daPage.ghostCharacter.removeAnimation(charAnimName.text);

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;
Expand All @@ -107,7 +107,7 @@ class AddAnimDialog extends DefaultPageDialog

var anim:String = charAnimDropdown.value.text;
char.playAnimation(anim);
cast(page, CharCreatorGameplayPage).ghostCharacter.playAnimation(anim);
daPage.ghostCharacter.playAnimation(anim);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class FreeplayDJSettingsDialog extends DefaultPageDialog
return bgTextField3.value ?? bgTextField3.placeholder;
}

override public function new(daPage:CharCreatorDefaultPage)
override public function new(daPage:CharCreatorFreeplayPage)
{
super(daPage);

var data = cast(daPage, CharCreatorFreeplayPage).data;
var data = daPage.data;

var currentChar = PlayerRegistry.instance.fetchEntry(data.importedPlayerData);
if (currentChar != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class GhostSettingsDialog extends DefaultPageDialog
public var attachedMenu:GhostCharacterMenu;
public var charId:String = Constants.DEFAULT_CHARACTER;

override public function new(daPage:CharCreatorDefaultPage)
override public function new(daPage:CharCreatorGameplayPage)
{
super(daPage);

var regularChar = cast(daPage, CharCreatorGameplayPage).currentCharacter;
var ghostChar = cast(daPage, CharCreatorGameplayPage).ghostCharacter;
var regularChar = daPage.currentCharacter;
var ghostChar = daPage.ghostCharacter;
var charData = CharacterRegistry.fetchCharacterData(Constants.DEFAULT_CHARACTER);

ghostTypeButton.icon = (charData == null ? null : CharacterRegistry.getCharPixelIconAsset(Constants.DEFAULT_CHARACTER));
Expand All @@ -33,22 +33,22 @@ class GhostSettingsDialog extends DefaultPageDialog

if (ghostChar.visible) // i love saving on data
{
cast(daPage, CharCreatorGameplayPage).ghostId = (ghostCustomChar.selected ? charId : "");
daPage.ghostId = (ghostCustomChar.selected ? charId : "");
}
}

ghostCurChar.onChange = function(_) {
ghostTypeButton.disabled = ghostCurChar.selected;
if (ghostCurChar.selected) Screen.instance.removeComponent(attachedMenu);

if (ghostChar.visible && ghostCurChar.selected) cast(daPage, CharCreatorGameplayPage).ghostId = "";
if (ghostChar.visible && ghostCurChar.selected) daPage.ghostId = "";
}

ghostCustomChar.onChange = function(_) {
ghostTypeButton.disabled = !ghostCustomChar.selected;
if (!ghostCustomChar.selected) Screen.instance.removeComponent(attachedMenu);

if (ghostChar.visible && ghostCustomChar.selected) cast(daPage, CharCreatorGameplayPage).ghostId = charId;
if (ghostChar.visible && ghostCustomChar.selected) daPage.ghostId = charId;
}

ghostTypeButton.onClick = function(_) {
Expand Down

0 comments on commit a4f5e94

Please sign in to comment.