--- deliantra/Deliantra-Client/DC/Util.pm 2006/04/07 18:27:54 1.8 +++ deliantra/Deliantra-Client/DC/Util.pm 2006/04/07 19:58:55 1.9 @@ -1,8 +1,12 @@ -package Client::Util; +package Crossfire::Client::Util; use strict; use base 'Exporter'; use Data::Dumper; -our @EXPORT = qw(find_rcfile); +our @EXPORT = qw(find_rcfile read_cfg write_cfg); +use SDL; +use SDL::App; +use SDL::Event; +use SDL::Surface; use Gtk2; @@ -10,7 +14,7 @@ my $path; for (@INC) { - $path = "$_/Crossfire/Client/$_[0]"; + $path = "$_/Crossfire/resources/$_[0]"; return $path if -r $path; } @@ -71,8 +75,6 @@ my $w = Gtk2::Window->new; my @cfg = ( - [qw/Width width/], - [qw/Height height/], [qw/Host host/], [qw/Port port/], [qw/Username user/], @@ -81,8 +83,32 @@ my $cfg = {}; + my $a = SDL::ListModes (0, SDL_FULLSCREEN|SDL_HWSURFACE); + my @modes = map { [SDL::RectW ($_), SDL::RectH ($_)] } @$a; + $w->add (my $vb = Gtk2::VBox->new); $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0); + my $selmode = $::CFG->{width} . 'x' . $::CFG->{height}; + $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1); + $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1); + my $i = 0; + my $act = 0; + for (map { "$_->[0]x$_->[1]" } reverse @modes) { + if ($_ eq $selmode) { $act = $i } + $cb->append_text ($_); + $i++; + } + $cb->set_active ($act); + $cb->signal_connect (changed => sub { + my ($cb) = @_; + my $txt = $cb->get_active_text; + if ($txt =~ m/(\d+)x(\d+)/) { + $::CFG->{width} = $1; + $::CFG->{height} = $2; + } + }); + + $cfg->{_i} = 1; for (@cfg) { gtk_add_cfg_field ($t, $cfg, $_->[0], $_->[1], $::CFG->{$_->[1]}); }