Adding nature selection screen, very ugly.
This commit is contained in:
parent
899f783cbb
commit
71e5f82d6a
|
@ -14,6 +14,7 @@ use Path::Tiny;
|
|||
|
||||
use Rsaves;
|
||||
use Rsaves::Constants::Emerald::Species;
|
||||
use Rsaves::Constants::Emerald::Natures;
|
||||
|
||||
Glib::Object::Introspection->setup(
|
||||
basename => 'Gtk',
|
||||
|
@ -125,6 +126,8 @@ sub create_modify_personality {
|
|||
sub open_window_personality {
|
||||
my $self = shift;
|
||||
my $window = Gtk4::Window->new;
|
||||
$window->set_default_size(600, 600);
|
||||
my $scroll = Gtk4::ScrolledWindow->new;
|
||||
my $box_window = Gtk4::Box->new('vertical', 1);
|
||||
$box_window->append(Gtk4::Label->new('Select shiny'));
|
||||
|
||||
|
@ -161,11 +164,31 @@ sub open_window_personality {
|
|||
|
||||
$box_window->append($box_gender);
|
||||
|
||||
$box_window->append(Gtk4::Label->new('Select nature'));
|
||||
|
||||
my $box_natures = Gtk4::Box->new('vertical', 1);
|
||||
my @natures = @Rsaves::Constants::Emerald::Natures::NATURES;
|
||||
my %toggle_nature = map { $_ => Gtk4::ToggleButton->new_with_label($_) } @natures;
|
||||
|
||||
my $nature_dont_mind = Gtk4::ToggleButton->new_with_label('Do not matter');
|
||||
$nature_dont_mind->set_active(1);
|
||||
|
||||
$box_natures->append($nature_dont_mind);
|
||||
|
||||
for my $nature (@natures) {
|
||||
my $toggle = $toggle_nature{$nature};
|
||||
$toggle->set_group($nature_dont_mind);
|
||||
$box_natures->append($toggle);
|
||||
}
|
||||
|
||||
$box_window->append($box_natures);
|
||||
|
||||
my $button_generate = Gtk4::Button->new_with_label('Generate personality');
|
||||
$button_generate->signal_connect(clicked => sub {
|
||||
my @gender_buttons = ($gender_male, $gender_female);
|
||||
my $target_shiny = undef;
|
||||
my $target_gender = undef;
|
||||
my $target_nature = undef;
|
||||
if ($shiny_yes->get_active) {
|
||||
$target_shiny = 1;
|
||||
}
|
||||
|
@ -178,14 +201,21 @@ sub open_window_personality {
|
|||
last;
|
||||
}
|
||||
}
|
||||
my $personality = $self->pokemon->generate_personality($target_shiny, $target_gender);
|
||||
for my $i (0..24) {
|
||||
if ($toggle_nature{$natures[$i]}->get_active) {
|
||||
$target_nature = $i;
|
||||
last;
|
||||
}
|
||||
}
|
||||
my $personality = $self->pokemon->generate_personality($target_shiny, $target_gender, $target_nature);
|
||||
if (defined $personality) {
|
||||
$self->_current_personality($personality);
|
||||
}
|
||||
$window->close;
|
||||
});
|
||||
$box_window->append($button_generate);
|
||||
$window->set_child($box_window);
|
||||
$scroll->set_child($box_window);
|
||||
$window->set_child($scroll);
|
||||
$window->present;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue