ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.83 by root, Wed Apr 12 15:35:55 2006 UTC vs.
Revision 1.84 by root, Wed Apr 12 15:46:14 2006 UTC

63 $DEBUG_STATUS->set_text ($_[0]); 63 $DEBUG_STATUS->set_text ($_[0]);
64 my ($w, $h) = $DEBUG_STATUS->size_request; 64 my ($w, $h) = $DEBUG_STATUS->size_request;
65 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h); 65 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
66} 66}
67 67
68sub start_game {
69 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
70
71 $CONN = new conn
72 host => $CFG->{host},
73 port => $CFG->{port},
74 user => $CFG->{user},
75 pass => $CFG->{password},
76 mapw => $mapsize,
77 maph => $mapsize,
78 ;
79
80 CFClient::lowdelay fileno $CONN->{fh};
81}
82
83sub stop_game {
84 undef $CONN;
85}
86
68sub config_dialog { 87sub config_dialog {
69 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100, 88 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100,
70 child => (my $vbox = new CFClient::UI::VBox); 89 child => (my $vbox = new CFClient::UI::VBox);
71 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); 90 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup");
72 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 91 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
85 }); 104 });
86 $mode_slider->emit (changed => $mode_slider->{range}[0]); 105 $mode_slider->emit (changed => $mode_slider->{range}[0]);
87 106
88 $table->add (1, 1, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 107 $table->add (1, 1, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
89 destroy_screen (); 108 destroy_screen ();
90 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
91 $FULLSCREEN = $CFG->{fullscreen};
92 init_screen (); 109 init_screen ();
93 }); 110 });
94 111
95 $vbox->add (new CFClient::UI::Label align => 0, text => "Server"); 112 $vbox->add (new CFClient::UI::Label align => 0, text => "Server");
96 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 113 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
116 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 133 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
117 }, 134 },
118 ); 135 );
119 136
120 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 137 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub {
121 warn "login\n"; 138 start_game;
122 }); 139 });
123 140
124 $vbox->add (my $hbox = new CFClient::UI::HBox); 141 $vbox->add (my $hbox = new CFClient::UI::HBox);
125 142
126 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { 143 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
127 CFClient::write_cfg "$CFrossfire::VARDIR/pclientrc"; 144 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
128 status "Configuration Saved"; 145 status "Configuration Saved";
129 }); 146 });
130 $CFClient::UI::TOPLEVEL->add ($dialog); 147 $CFClient::UI::TOPLEVEL->add ($dialog);
131} 148}
132 149
133sub init_screen { 150sub init_screen {
151 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
152 $FULLSCREEN = $CFG->{fullscreen};
153
134 $SDL_APP = new SDL::App 154 $SDL_APP = new SDL::App
135 -flags => SDL_ANYFORMAT | SDL_HWSURFACE, 155 -flags => SDL_ANYFORMAT | SDL_HWSURFACE,
136 -title => "Crossfire+ Client", 156 -title => "Crossfire+ Client",
137 -width => $WIDTH, 157 -width => $WIDTH,
138 -height => $HEIGHT, 158 -height => $HEIGHT,
186} 206}
187 207
188sub destroy_screen { 208sub destroy_screen {
189 $CFClient::UI::TOPLEVEL->{children} = []; 209 $CFClient::UI::TOPLEVEL->{children} = [];
190 remove Glib::Source $SDL_TIMER; 210 remove Glib::Source $SDL_TIMER;
211 remove Glib::Source $refresh_handler if $refresh_handler;
212 undef $refresh_handler;
191 undef $SDL_APP; 213 undef $SDL_APP;
192 undef $SDL_EV; 214 undef $SDL_EV;
193 SDL::Quit; 215 SDL::Quit;
194}
195
196sub start_game {
197 $WIDTH = $CFG->{width};
198 $HEIGHT = $CFG->{height};
199 $FULLSCREEN = 0;
200
201 init_screen;
202
203 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
204
205 $CONN = new conn
206 host => $CFG->{host},
207 port => $CFG->{port},
208 user => $CFG->{user},
209 pass => $CFG->{password},
210 mapw => $mapsize,
211 maph => $mapsize,
212 ;
213
214 CFClient::lowdelay fileno $CONN->{fh};
215}
216
217sub stop_game {
218 remove Glib::Source $refresh_handler if $refresh_handler;
219 undef $refresh_handler;
220
221 undef $CONN;
222 destroy_screen;
223} 216}
224 217
225sub force_refresh { 218sub force_refresh {
226 glViewport 0, 0, $WIDTH, $HEIGHT; 219 glViewport 0, 0, $WIDTH, $HEIGHT;
227 220
486 CFClient::set_font $fonts[0]; 479 CFClient::set_font $fonts[0];
487} 480}
488 481
489$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; 482$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {};
490 483
491run_config_dialog 484init_screen;
492 login => sub { start_game },
493 logout => sub { stop_game };
494 485
495main Gtk2; 486main Gtk2;
496 487
497Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; 488Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces";
498 489

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines