ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Util.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Util.pm (file contents):
Revision 1.8 by elmex, Fri Apr 7 18:27:54 2006 UTC vs.
Revision 1.9 by elmex, Fri Apr 7 19:58:55 2006 UTC

1package Client::Util; 1package Crossfire::Client::Util;
2use strict; 2use strict;
3use base 'Exporter'; 3use base 'Exporter';
4use Data::Dumper; 4use Data::Dumper;
5our @EXPORT = qw(find_rcfile); 5our @EXPORT = qw(find_rcfile read_cfg write_cfg);
6use SDL;
7use SDL::App;
8use SDL::Event;
9use SDL::Surface;
6 10
7use Gtk2; 11use Gtk2;
8 12
9sub find_rcfile($) { 13sub find_rcfile($) {
10 my $path; 14 my $path;
11 15
12 for (@INC) { 16 for (@INC) {
13 $path = "$_/Crossfire/Client/$_[0]"; 17 $path = "$_/Crossfire/resources/$_[0]";
14 return $path if -r $path; 18 return $path if -r $path;
15 } 19 }
16 20
17 die "FATAL: can't find required file $_[0]\n"; 21 die "FATAL: can't find required file $_[0]\n";
18} 22}
69 my (%events) = @_; 73 my (%events) = @_;
70 74
71 my $w = Gtk2::Window->new; 75 my $w = Gtk2::Window->new;
72 76
73 my @cfg = ( 77 my @cfg = (
74 [qw/Width width/],
75 [qw/Height height/],
76 [qw/Host host/], 78 [qw/Host host/],
77 [qw/Port port/], 79 [qw/Port port/],
78 [qw/Username user/], 80 [qw/Username user/],
79 [qw/Password password/], 81 [qw/Password password/],
80 ); 82 );
81 83
82 my $cfg = {}; 84 my $cfg = {};
83 85
86 my $a = SDL::ListModes (0, SDL_FULLSCREEN|SDL_HWSURFACE);
87 my @modes = map { [SDL::RectW ($_), SDL::RectH ($_)] } @$a;
88
84 $w->add (my $vb = Gtk2::VBox->new); 89 $w->add (my $vb = Gtk2::VBox->new);
85 $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0); 90 $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0);
91 my $selmode = $::CFG->{width} . 'x' . $::CFG->{height};
92 $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1);
93 $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1);
94 my $i = 0;
95 my $act = 0;
96 for (map { "$_->[0]x$_->[1]" } reverse @modes) {
97 if ($_ eq $selmode) { $act = $i }
98 $cb->append_text ($_);
99 $i++;
100 }
101 $cb->set_active ($act);
102 $cb->signal_connect (changed => sub {
103 my ($cb) = @_;
104 my $txt = $cb->get_active_text;
105 if ($txt =~ m/(\d+)x(\d+)/) {
106 $::CFG->{width} = $1;
107 $::CFG->{height} = $2;
108 }
109 });
110
111 $cfg->{_i} = 1;
86 for (@cfg) { 112 for (@cfg) {
87 gtk_add_cfg_field ($t, $cfg, $_->[0], $_->[1], $::CFG->{$_->[1]}); 113 gtk_add_cfg_field ($t, $cfg, $_->[0], $_->[1], $::CFG->{$_->[1]});
88 } 114 }
89 115
90 $vb->pack_start (my $hb = Gtk2::HBox->new, 0, 0, 0); 116 $vb->pack_start (my $hb = Gtk2::HBox->new, 0, 0, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines