Fixing pokemon with alternative forms.
This commit is contained in:
parent
dfc2abf809
commit
fe98d9a8d9
@ -14,9 +14,18 @@ $shiny_dir->mkpath;
|
||||
for my $pokemon_dir ( $pokemons_dir->children ) {
|
||||
my $bpp = $tempdir->child( $pokemon_dir->basename . '.4bpp' );
|
||||
say $pokemon_dir->basename;
|
||||
my $front = $pokemon_dir->child('front.png');
|
||||
my $shiny = $pokemon_dir->child('shiny.pal');
|
||||
if ($pokemon_dir->basename eq 'unown') {
|
||||
$front = $pokemon_dir->child('z/front.png');
|
||||
}
|
||||
if ($pokemon_dir->basename eq 'castform') {
|
||||
$front = $pokemon_dir->child('normal/front.png');
|
||||
$shiny = $pokemon_dir->child('normal/shiny.pal');
|
||||
}
|
||||
system './pokeemerald/tools/gbagfx/gbagfx',
|
||||
$pokemon_dir->child('front.png'), $bpp;
|
||||
$front, $bpp;
|
||||
system './pokeemerald/tools/gbagfx/gbagfx',
|
||||
$bpp, $shiny_dir->child( $pokemon_dir->basename . '.png' ),
|
||||
'-palette', $pokemon_dir->child('shiny.pal'), '-mwidth', 8, '-object';
|
||||
'-palette', $shiny, '-mwidth', 8, '-object';
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ sub species {
|
||||
sub get_icon {
|
||||
my $self = shift;
|
||||
my $pokemon_name = $Rsaves::Constants::Emerald::Species::SPECIES[$self->species];
|
||||
if (lc($pokemon_name) eq 'unown') {
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/z/icon.png";
|
||||
}
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/icon.png";
|
||||
}
|
||||
|
||||
@ -32,6 +35,12 @@ sub get_front {
|
||||
if (Rsaves::pokemon_is_shiny($self->_pokemon)) {
|
||||
return "resources/shiny/@{[lc($pokemon_name)]}.png";
|
||||
}
|
||||
if (lc($pokemon_name) eq 'castform') {
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/normal/front.png";
|
||||
}
|
||||
if (lc($pokemon_name) eq 'unown') {
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/z/front.png";
|
||||
}
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/front.png";
|
||||
}
|
||||
1;
|
||||
|
@ -30,10 +30,7 @@ has _save => (
|
||||
required => 1,
|
||||
);
|
||||
|
||||
has _current_box => (
|
||||
is => 'rw',
|
||||
);
|
||||
|
||||
has _current_box => ( is => 'rw', );
|
||||
|
||||
my $BOX_X = 275;
|
||||
my $BOX_Y = 50;
|
||||
@ -87,7 +84,9 @@ sub start {
|
||||
my $selected_pokemon = $self->get_selected_pokemon;
|
||||
$self->draw_pc( $cairo, $scale_factor_pc );
|
||||
{
|
||||
my $output_box = Cairo::ImageSurface->create( 'argb32', $BOX_WIDTH, $BOX_HEIGHT );
|
||||
my $output_box =
|
||||
Cairo::ImageSurface->create( 'argb32', $BOX_WIDTH,
|
||||
$BOX_HEIGHT );
|
||||
my $box_context = Cairo::Context->create($output_box);
|
||||
$self->draw_box($box_context);
|
||||
$self->draw_pokemon( $box_context, $selected_pokemon );
|
||||
@ -113,10 +112,10 @@ sub start {
|
||||
sub _on_primary_click {
|
||||
my $self = shift;
|
||||
my ( $gesture, $n_press, $x, $y ) = @_;
|
||||
return if $self->_check_click_next_box($gesture, $n_press, $x, $y);
|
||||
return if $self->_check_click_next_prev_box( $gesture, $n_press, $x, $y );
|
||||
}
|
||||
|
||||
sub _check_click_next_box {
|
||||
sub _check_click_next_prev_box {
|
||||
my $self = shift;
|
||||
my ( $gesture, $n_press, $x, $y ) = @_;
|
||||
|
||||
@ -129,9 +128,8 @@ sub _check_click_next_box {
|
||||
return if $x >= $BOX_WIDTH;
|
||||
return if $y >= $BOX_HEIGHT;
|
||||
|
||||
my ($x_arrow, $width_arrow) = ($BOX_WIDTH - $ARROW_X, $BOX_WIDTH - $ARROW_X + $ARROW_WIDTH);
|
||||
my ($y_arrow, $height_arrow) = ($ARROW_Y, $ARROW_Y + $ARROW_HEIGHT);
|
||||
my $x_matches = $x >= $BOX_WIDTH - $ARROW_X && $x <= $BOX_WIDTH - $ARROW_X + $ARROW_WIDTH;
|
||||
my $x_matches =
|
||||
$x >= $BOX_WIDTH - $ARROW_X && $x <= $BOX_WIDTH - $ARROW_X + $ARROW_WIDTH;
|
||||
my $y_matches = $y >= $ARROW_Y && $y <= $ARROW_Y + $ARROW_HEIGHT;
|
||||
if ( $x_matches && $y_matches ) {
|
||||
my $box = $self->_current_box;
|
||||
@ -144,6 +142,19 @@ sub _check_click_next_box {
|
||||
$self->_current_box( $pc->get_box( $box->number + 1 ) );
|
||||
return 1;
|
||||
}
|
||||
$x_matches = $x >= $ARROW_X - $ARROW_WIDTH && $x <= $ARROW_X;
|
||||
$y_matches = $y >= $ARROW_Y && $y <= $ARROW_Y + $ARROW_HEIGHT;
|
||||
if ( $x_matches && $y_matches ) {
|
||||
my $box = $self->_current_box;
|
||||
my $save = $self->_save;
|
||||
my $pc = $save->get_pc_system;
|
||||
if ( $box->number == 0 ) {
|
||||
$self->_current_box( $pc->get_box(13) );
|
||||
return 1;
|
||||
}
|
||||
$self->_current_box( $pc->get_box( $box->number - 1 ) );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub draw_pokemon_details {
|
||||
@ -151,13 +162,19 @@ sub draw_pokemon_details {
|
||||
my $cairo = shift;
|
||||
my $selected_pokemon = shift;
|
||||
return if !defined $selected_pokemon;
|
||||
my $surface = Cairo::ImageSurface->create_from_png($root->child($selected_pokemon->get_front));
|
||||
my $output_image = Cairo::ImageSurface->create( 'argb32', 64, 64 );
|
||||
my $image_context = Cairo::Context->create($output_image);
|
||||
my $surface = Cairo::ImageSurface->create_from_png(
|
||||
$root->child( $selected_pokemon->get_front ) );
|
||||
my $scale_factor = 2;
|
||||
$cairo->scale( ($scale_factor) x 2 );
|
||||
$cairo->set_source_surface( $surface, 20, 30 );
|
||||
$image_context->set_source_surface( $surface, 0, 0 );
|
||||
$image_context->get_source()->set_filter('nearest');
|
||||
$image_context->paint;
|
||||
$cairo->set_source_surface( $output_image, 20, 30 );
|
||||
$cairo->get_source()->set_filter('nearest');
|
||||
$cairo->paint;
|
||||
$cairo->scale( ( 1 / $scale_factor ) x 2 );
|
||||
$cairo->paint;
|
||||
|
||||
}
|
||||
|
||||
@ -166,7 +183,8 @@ sub draw_pc {
|
||||
my $cairo = shift;
|
||||
my $scale_factor = shift;
|
||||
$cairo->scale( ($scale_factor) x 2 );
|
||||
my $surface = Cairo::ImageSurface->create_from_png($root->child('resources/pc_background.png'));
|
||||
my $surface = Cairo::ImageSurface->create_from_png(
|
||||
$root->child('resources/pc_background.png') );
|
||||
$cairo->set_source_surface( $surface, 0, 0 );
|
||||
$cairo->get_source()->set_filter('nearest');
|
||||
$cairo->paint;
|
||||
@ -303,7 +321,11 @@ sub draw_box {
|
||||
$cairo->paint;
|
||||
$surface = Cairo::ImageSurface->create_from_png(
|
||||
$root->child('resources/right_arrow_pc.png') );
|
||||
$cairo->set_source_surface( $surface, $BOX_WIDTH / 2 - $ARROW_X / 2, $ARROW_Y / 2);
|
||||
$cairo->set_source_surface(
|
||||
$surface,
|
||||
$BOX_WIDTH / 2 - $ARROW_X / 2,
|
||||
$ARROW_Y / 2
|
||||
);
|
||||
$cairo->get_source()->set_filter('nearest');
|
||||
$cairo->paint;
|
||||
$cairo->scale( -1, 1 );
|
||||
|
BIN
resources/shiny/castform.png
Normal file
BIN
resources/shiny/castform.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 382 B |
BIN
resources/shiny/unown.png
Normal file
BIN
resources/shiny/unown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 324 B |
Loading…
Reference in New Issue
Block a user