Adding shiny fronts.
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use v5.16.3;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Path::Tiny;
|
||||
|
||||
my $pokemons_dir = path 'pokeemerald/graphics/pokemon/';
|
||||
my $tempdir = Path::Tiny->tempdir;
|
||||
my $shiny_dir = path 'resources/shiny';
|
||||
$shiny_dir->mkpath;
|
||||
for my $pokemon_dir ( $pokemons_dir->children ) {
|
||||
my $bpp = $tempdir->child( $pokemon_dir->basename . '.4bpp' );
|
||||
say $pokemon_dir->basename;
|
||||
system './pokeemerald/tools/gbagfx/gbagfx',
|
||||
$pokemon_dir->child('front.png'), $bpp;
|
||||
system './pokeemerald/tools/gbagfx/gbagfx',
|
||||
$bpp, $shiny_dir->child( $pokemon_dir->basename . '.png' ),
|
||||
'-palette', $pokemon_dir->child('shiny.pal'), '-mwidth', 8, '-object';
|
||||
}
|
|
@ -20,9 +20,18 @@ sub species {
|
|||
return $substruct_0->{species};
|
||||
}
|
||||
|
||||
sub get_image {
|
||||
sub get_icon {
|
||||
my $self = shift;
|
||||
my $pokemon_name = $Rsaves::Constants::Emerald::Species::SPECIES[$self->species];
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/icon.png";
|
||||
}
|
||||
|
||||
sub get_front {
|
||||
my $self = shift;
|
||||
my $pokemon_name = $Rsaves::Constants::Emerald::Species::SPECIES[$self->species];
|
||||
if (Rsaves::pokemon_is_shiny($self->_pokemon)) {
|
||||
return "resources/shiny/@{[lc($pokemon_name)]}.png";
|
||||
}
|
||||
return "pokeemerald/graphics/pokemon/@{[lc($pokemon_name)]}/front.png";
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -322,8 +322,6 @@ sub activate_about {
|
|||
$about->present;
|
||||
}
|
||||
|
||||
my $root = path(__FILE__)->parent->parent->parent->parent;
|
||||
|
||||
sub activate_view_pc {
|
||||
my $self = shift;
|
||||
GEmeTool::View::PokemonPCWindow->new( _save => $self->_save )->start;
|
||||
|
|
|
@ -63,17 +63,18 @@ sub start {
|
|||
my $width = shift;
|
||||
my $height = shift;
|
||||
|
||||
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 $box_context = Cairo::Context->create($output_box);
|
||||
$self->draw_box($box_context);
|
||||
my $selected_pokemon = $self->get_selected_pokemon;
|
||||
$self->draw_pokemon( $box_context, $selected_pokemon );
|
||||
$self->draw_box_name($box_context);
|
||||
$cairo->set_source_surface( $output_box, $BOX_X, $BOX_Y );
|
||||
$cairo->paint;
|
||||
}
|
||||
$self->draw_pokemon_details($cairo, $selected_pokemon);
|
||||
$self->draw_cursor($cairo);
|
||||
}
|
||||
);
|
||||
|
@ -88,6 +89,21 @@ sub start {
|
|||
);
|
||||
}
|
||||
|
||||
sub draw_pokemon_details {
|
||||
my $self = shift;
|
||||
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 $scale_factor = 2;
|
||||
$cairo->scale( ($scale_factor) x 2 );
|
||||
$cairo->set_source_surface( $surface, 20, 30 );
|
||||
$cairo->get_source()->set_filter('nearest');
|
||||
$cairo->paint;
|
||||
$cairo->scale( (1/$scale_factor) x 2 );
|
||||
|
||||
}
|
||||
|
||||
sub draw_pc {
|
||||
my $self = shift;
|
||||
my $cairo = shift;
|
||||
|
@ -160,7 +176,7 @@ sub draw_pokemon {
|
|||
my $pokemon = $box->get_pokemon( $i * 6 + $j );
|
||||
my $is_selected =
|
||||
defined $selected_pokemon && $pokemon eq $selected_pokemon;
|
||||
my $pokemon_image = $root->child( $pokemon->get_image );
|
||||
my $pokemon_image = $root->child( $pokemon->get_icon );
|
||||
my $p = 25;
|
||||
my $x = $j * ( $p + 1 );
|
||||
my $y = 20 + ( ( $p - 3 ) * $i );
|
||||
|
@ -228,6 +244,16 @@ sub draw_box {
|
|||
$cairo->get_source()->set_filter('nearest');
|
||||
|
||||
$cairo->paint;
|
||||
$surface = Cairo::ImageSurface->create_from_png(
|
||||
$root->child('resources/right_arrow_pc.png') );
|
||||
$cairo->set_source_surface( $surface, $BOX_WIDTH / 2 - 14, 3);
|
||||
$cairo->get_source()->set_filter('nearest');
|
||||
$cairo->paint;
|
||||
$cairo->scale(-1, 1);
|
||||
$cairo->set_source_surface( $surface, - 14, 3);
|
||||
$cairo->get_source()->set_filter('nearest');
|
||||
$cairo->paint;
|
||||
$cairo->scale(-1, 1);
|
||||
$cairo->scale( 1 / 2, 1 / 2 );
|
||||
|
||||
}
|
||||
|
|
|
@ -11,11 +11,13 @@ use Data::Dumper;
|
|||
|
||||
use Rsaves::Constants::Ruby::Flags
|
||||
qw/$FLAG_SYS_HAS_EON_TICKET $FLAG_LEGENDARY_BATTLE_COMPLETED $FLAG_HIDE_LEGEND_MON_CAVE_OF_ORIGIN/;
|
||||
use Rsaves::Constants::Ruby::Vars qw/ $VAR_MIRAGE_RND_H $VAR_CAVE_OF_ORIGIN_B4F_STATE $VARS_START/;
|
||||
use Rsaves::Constants::Ruby::Vars
|
||||
qw/ $VAR_MIRAGE_RND_H $VAR_CAVE_OF_ORIGIN_B4F_STATE $VARS_START/;
|
||||
use Rsaves::Constants::Global
|
||||
qw/$SAPPHIRE_VERSION $RUBY_VERSION $EMERALD_VERSION $FIRERED_VERSION $LEAFGREEN_VERSION $COLOSSEUM_VERSION/;
|
||||
|
||||
use Rsaves::Constants::Firered::Flags qw/$FLAG_RECEIVED_AURORA_TICKET $FLAG_ENABLE_SHIP_BIRTH_ISLAND $FLAG_FOUGHT_DEOXYS $FLAG_DEOXYS_FLEW_AWAY/;
|
||||
use Rsaves::Constants::Firered::Flags
|
||||
qw/$FLAG_RECEIVED_AURORA_TICKET $FLAG_ENABLE_SHIP_BIRTH_ISLAND $FLAG_FOUGHT_DEOXYS $FLAG_DEOXYS_FLEW_AWAY/;
|
||||
use Rsaves::Constants::Firered::Vars qw/$VAR_MAP_SCENE_CERULEAN_CITY_RIVAL/;
|
||||
use Rsaves::Constants::MoveAttributes qw/get_move_attributes/;
|
||||
use Exporter;
|
||||
|
@ -114,9 +116,11 @@ sub parse_version_name {
|
|||
}
|
||||
|
||||
sub pokemon_fill_pp($pokemon) {
|
||||
|
||||
# Not taking pp bonuses in account, work for other day.
|
||||
for my $number_movement ( 0 .. 3 ) {
|
||||
my $movement_id = $pokemon->{substructures}[1]{movements}[$number_movement];
|
||||
my $movement_id =
|
||||
$pokemon->{substructures}[1]{movements}[$number_movement];
|
||||
my $pp = get_move_attributes($movement_id)->{'pp'};
|
||||
$pokemon->{substructures}[1]{pp}[$number_movement] = $pp;
|
||||
}
|
||||
|
@ -137,6 +141,13 @@ sub calculate_shiny_personality {
|
|||
return ( $wanted_high_personality << 16 ) | _lowhalf_u32($personality);
|
||||
}
|
||||
|
||||
sub pokemon_is_shiny {
|
||||
my $pokemon = shift;
|
||||
my ($otid, $personality) = @{$pokemon}{ 'otid', 'personality' };
|
||||
return ( _lowhalf_u32($personality) ^ _hihalf_u32($personality)
|
||||
^ _lowhalf_u32($otid) ^ _hihalf_u32($otid) ) < 8;
|
||||
}
|
||||
|
||||
sub get_first_super_data {
|
||||
my $save = shift;
|
||||
my @sections = _find_sections_save( $save, 1 .. 4 );
|
||||
|
@ -874,7 +885,8 @@ sub get_security_key {
|
|||
read $fh, my $read, 0xf20;
|
||||
read $fh, $read, 4;
|
||||
return unpack 'V', $read;
|
||||
} elsif (_is_ruby_or_sapphire($version)) {
|
||||
}
|
||||
elsif ( _is_ruby_or_sapphire($version) ) {
|
||||
return 0;
|
||||
}
|
||||
close $fh;
|
||||
|
@ -891,6 +903,7 @@ sub add_key_item {
|
|||
open my $fh, '<', $superdata;
|
||||
my $offset = $KEY_ITEMS_OFFSET_RUBY;
|
||||
my $max_key_items = $MAX_KEY_ITEMS_RUBY;
|
||||
|
||||
if ( _is_leafgreen_or_firered($version) ) {
|
||||
$offset = $KEY_ITEMS_OFFSET_FIRERED;
|
||||
$max_key_items = $MAX_KEY_ITEMS_FIRERED;
|
||||
|
@ -929,9 +942,13 @@ sub get_var {
|
|||
my $var = shift;
|
||||
my $section0 = _find_section_save( $save, 0 );
|
||||
my $version = $section0->{version};
|
||||
my $read_until = ( ( $var - $Rsaves::Constants::Ruby::Vars::VARS_START ) * 2 ) + $RUBY_VARS_START;
|
||||
my $read_until =
|
||||
( ( $var - $Rsaves::Constants::Ruby::Vars::VARS_START ) * 2 ) +
|
||||
$RUBY_VARS_START;
|
||||
if ( _is_leafgreen_or_firered($version) ) {
|
||||
$read_until = ( ( $var - $Rsaves::Constants::Firered::Vars::VARS_START ) * 2 ) + $FIRERED_VARS_START;
|
||||
$read_until =
|
||||
( ( $var - $Rsaves::Constants::Firered::Vars::VARS_START ) * 2 ) +
|
||||
$FIRERED_VARS_START;
|
||||
}
|
||||
if ( _is_emerald($version) ) {
|
||||
die "Not implemented.";
|
||||
|
@ -952,9 +969,14 @@ sub set_var {
|
|||
my $section0 = _find_section_save( $save, 0 );
|
||||
my $version = $section0->{version};
|
||||
die "$value bigger than 0xffff" if $value > 0xffff;
|
||||
my $read_until = ( ( $var - $Rsaves::Constants::Ruby::Vars::VARS_START ) * 2 ) + $RUBY_VARS_START;
|
||||
my $read_until =
|
||||
( ( $var - $Rsaves::Constants::Ruby::Vars::VARS_START ) * 2 ) +
|
||||
$RUBY_VARS_START;
|
||||
|
||||
if ( _is_leafgreen_or_firered($version) ) {
|
||||
$read_until = ( ( $var - $Rsaves::Constants::Firered::Vars::VARS_START ) * 2 ) + $FIRERED_VARS_START;
|
||||
$read_until =
|
||||
( ( $var - $Rsaves::Constants::Firered::Vars::VARS_START ) * 2 ) +
|
||||
$FIRERED_VARS_START;
|
||||
}
|
||||
if ( _is_emerald($version) ) {
|
||||
die "Not implemented.";
|
||||
|
@ -1096,7 +1118,8 @@ sub _recalculate_checksum {
|
|||
my $to_add = unpack 'V', $readed;
|
||||
$checksum = 0xffffffff & ( $checksum + $to_add );
|
||||
}
|
||||
my $final_checksum = (_hihalf_u32($checksum) + _lowhalf_u32($checksum)) & 0xffffffff;
|
||||
my $final_checksum =
|
||||
( _hihalf_u32($checksum) + _lowhalf_u32($checksum) ) & 0xffffffff;
|
||||
$section->{checksum} = $final_checksum;
|
||||
}
|
||||
|
||||
|
|
After Width: | Height: | Size: 585 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 923 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 639 B |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 825 B |
After Width: | Height: | Size: 721 B |
After Width: | Height: | Size: 691 B |
After Width: | Height: | Size: 880 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 850 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 631 B |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 416 B |
After Width: | Height: | Size: 546 B |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 815 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 891 B |
After Width: | Height: | Size: 465 B |
After Width: | Height: | Size: 520 B |
After Width: | Height: | Size: 528 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 827 B |
After Width: | Height: | Size: 849 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 739 B |
After Width: | Height: | Size: 662 B |
After Width: | Height: | Size: 917 B |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 692 B |
After Width: | Height: | Size: 493 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 514 B |
After Width: | Height: | Size: 674 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 561 B |
After Width: | Height: | Size: 775 B |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 607 B |
After Width: | Height: | Size: 611 B |
After Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 650 B |
After Width: | Height: | Size: 519 B |
After Width: | Height: | Size: 381 B |
After Width: | Height: | Size: 861 B |
After Width: | Height: | Size: 838 B |
After Width: | Height: | Size: 704 B |
After Width: | Height: | Size: 601 B |
After Width: | Height: | Size: 887 B |
After Width: | Height: | Size: 1006 B |
After Width: | Height: | Size: 780 B |
After Width: | Height: | Size: 730 B |
After Width: | Height: | Size: 604 B |
After Width: | Height: | Size: 546 B |
After Width: | Height: | Size: 765 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 838 B |
After Width: | Height: | Size: 747 B |
After Width: | Height: | Size: 422 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 705 B |
After Width: | Height: | Size: 923 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 549 B |
After Width: | Height: | Size: 703 B |
After Width: | Height: | Size: 635 B |
After Width: | Height: | Size: 645 B |
After Width: | Height: | Size: 741 B |
After Width: | Height: | Size: 616 B |
After Width: | Height: | Size: 724 B |
After Width: | Height: | Size: 557 B |
After Width: | Height: | Size: 621 B |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 511 B |
After Width: | Height: | Size: 490 B |
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 659 B |
After Width: | Height: | Size: 808 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 980 B |
After Width: | Height: | Size: 539 B |
After Width: | Height: | Size: 1.1 KiB |