Games-Axmud
view release on metacpan or search on metacpan
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
# This type of window is unique (only one can be open at any time); inform the GA::Client
# it has closed
$axmud::CLIENT->set_aboutWin();
return 1;
}
# sub winShowAll {} # Inherited from GA::Generic::Win
sub drawWidgets {
# Called by $self->winSetup
# Sets up the About window with its standard widgets
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $check) = @_;
# Local variables
my (
$file, $fileHandle,
@aboutList, @helpList, @peekList, @changesList, @installList, @licenseList,
@license2List,
);
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_);
}
# Create a packing box
my $packingBox = Gtk3::VBox->new(FALSE, 0);
$self->winBox->add($packingBox);
$packingBox->set_border_width(0);
# Create an image on the left
my $hBox = Gtk3::HBox->new(FALSE, 0);
$packingBox->pack_start($hBox, TRUE, TRUE, 0);
my $vBox = Gtk3::VBox->new(FALSE, 0);
$hBox->pack_start($vBox, FALSE, FALSE, 0);
my $frame = Gtk3::Frame->new(undef);
$vBox->pack_start($frame, FALSE, FALSE, 0);
$frame->set_size_request(64, 64);
$frame->set_shadow_type($axmud::CLIENT->constShadowType);
my $image = Gtk3::Image->new_from_file($axmud::CLIENT->getDialogueIcon());
$frame->add($image);
# Create a notebook on the right
my $notebook = Gtk3::Notebook->new();
$hBox->pack_start($notebook, TRUE, TRUE, $self->spacingPixels);
$notebook->set_scrollable(TRUE);
$notebook->popup_enable();
# Create a button at the bottom
my $hBox2 = Gtk3::HBox->new(FALSE, 0);
$packingBox->pack_end($hBox2, FALSE, FALSE, $self->spacingPixels);
# The button's label includes some extra space characters to make it a little easier to
# click on
my $button = Gtk3::Button->new(' OK ');
$hBox2->pack_end($button, FALSE, FALSE, 0);
$button->get_child->set_width_chars(10);
$button->signal_connect('clicked' => sub {
$self->winDestroy();
});
# Add the 'about' tab to the notebook
push (@aboutList,
$axmud::SCRIPT . ' v' . $axmud::VERSION . ' (' . $axmud::DATE . ') by '
. $axmud::AUTHORS,
$axmud::COPYRIGHT,
'Website: ' . $axmud::URL,
' ', # Empty line
@axmud::LICENSE_LIST,
);
$self->addTab($notebook, '_About', TRUE, @aboutList);
# Add the 'credits' tab to the notebook
$self->addTab($notebook, '_Credits', TRUE, @axmud::CREDIT_LIST);
# Load the quick help file
$file = $axmud::SHARE_DIR . '/help/misc/quickhelp';
if (! (-e $file)) {
push (@helpList, 'Quick help file missing');
} else {
if (! open($fileHandle, $file)) {
push (@helpList, 'Unable to read quick help file');
} else {
@helpList = <$fileHandle>;
close($fileHandle);
}
}
# Add the 'help' tab to the notebook
$self->addTab($notebook, 'Quick _help', FALSE, @helpList);
# Load the peek/poke help file
$file = $axmud::SHARE_DIR . '/help/misc/peekpoke';
if (! (-e $file)) {
push (@peekList, 'Peek/poke help file missing');
} else {
lib/Games/Axmud/OtherWin.pm view on Meta::CPAN
# Called by $self->winSetup
# Sets up the data viewer window with its standard widgets
#
# Expected arguments
# (none besides $self)
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $check) = @_;
# Check for improper arguments
if (defined $check) {
return $axmud::CLIENT->writeImproper($self->_objClass . '->drawWidgets', @_);
}
# Create a packing box
my $packingBox = Gtk3::VBox->new(FALSE, 0);
$self->winBox->add($packingBox);
$packingBox->set_border_width(0);
# Create a horizontal pane to divide the window into two, with the treeview on the left, and
# everything else on the right
my $hPaned = Gtk3::HPaned->new();
$packingBox->pack_start($hPaned, TRUE, TRUE, 0);
# Add a treeview on the left of the window
my $treeViewModel = Gtk3::TreeStore->new( ['Glib::String'] );
my $treeView = Gtk3::TreeView->new($treeViewModel);
$treeView->set_enable_search(FALSE);
# Append a single column to the treeview
$treeView->append_column(
Gtk3::TreeViewColumn->new_with_attributes(
'Objects',
Gtk3::CellRendererText->new,
text => 0,
)
);
# Make the treeview scrollable
my $treeViewScroller = Gtk3::ScrolledWindow->new();
$hPaned->pack1($treeViewScroller, FALSE, FALSE);
$treeViewScroller->add($treeView);
$treeViewScroller->set_policy(qw/automatic automatic/);
# Make the branches of the list tree clickable, so the rows can be expanded and collapsed
$treeView->signal_connect('row_activated' => \&treeViewRowActivated, $self);
# Respond to clicks on the treeview
$treeView->get_selection->set_mode('browse');
$treeView->get_selection->signal_connect('changed' => \&treeViewChanged, $self);
# Fill the tree
$self->setupTreeView($treeView);
# Add a notebook on the right. Later, this might be replaced by a second Gtk3::HPaned
my $notebook = Gtk3::Notebook->new();
$hPaned->pack2($notebook, TRUE, FALSE);
$notebook->set_scrollable(TRUE);
$notebook->popup_enable();
$hPaned->set_position($self->leftWidth);
# Set up the window's background photo using a CSS style
my $provider = Gtk3::CssProvider->new();
my $display = Gtk3::Gdk::Display::get_default();
my $screen = Gtk3::Gdk::Display::get_default_screen($display);
# (Don't call ->add_provider_for_screen so that the style is only applied to this window)
# Gtk3::StyleContext::add_provider_for_screen($screen, $provider, 600);
my $imagePath = $axmud::SHARE_DIR . '/images/viewerbg.jpg';
my $theming = "#css_oov_id, window.background {\n";
$theming .= " background-image: url(\"$imagePath\");\n";
$theming .= " background-repeat: repeat;\n";
$theming .= " background-position: top left;\n";
$theming .= "}";
$provider->load_from_data ([map ord, split //, $theming]);
my $context = $self->winWidget->get_style_context();
$context->add_provider($provider, 600);
# Update IVs
$self->ivPoke('packingBox', $packingBox);
$self->ivPoke('hPaned', $hPaned);
$self->ivPoke('treeViewModel', $treeViewModel);
$self->ivPoke('treeView', $treeView);
$self->ivPoke('treeViewScroller', $treeViewScroller);
$self->ivPoke('notebook', $notebook);
return 1;
}
# sub redrawWidgets {} # Inherited from GA::Generic::Win
# ->signal_connects
# Other functions
# Set up widgets
sub setupTreeView {
# Called by $self->enable
# Fills the object tree on the left of the window
#
# Expected arguments
# $treeView - The Gtk3::TreeView widget
#
# Return values
# 'undef' on improper arguments
# 1 otherwise
my ($self, $treeView, $check) = @_;
# Local variables
my (
$model, $pointer, $child, $grandChild, $greatGrandChild, $greatGreatGrandChild,
$scriptObj,
( run in 0.912 second using v1.01-cache-2.11-cpan-364913b4093 )