… | |
… | |
175 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
175 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
176 | |
176 | |
177 | $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); |
177 | $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); |
178 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
178 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
179 | |
179 | |
180 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 1, 1]); |
180 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]); |
181 | $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
181 | $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
182 | |
182 | |
183 | $mode_slider->connect (changed => sub { |
183 | $mode_slider->connect (changed => sub { |
184 | my ($self, $value) = @_; |
184 | my ($self, $value) = @_; |
185 | |
185 | |
… | |
… | |
210 | } |
210 | } |
211 | ); |
211 | ); |
212 | |
212 | |
213 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); |
213 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); |
214 | $table->add (1, $row++, new CFClient::UI::Slider |
214 | $table->add (1, $row++, new CFClient::UI::Slider |
215 | range => [$CFG->{map_scale}, 0.25, 2, 0.05, 0.05], |
215 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
216 | tooltip => "Enlarge or shrink the displayed map", |
216 | tooltip => "Enlarge or shrink the displayed map", |
217 | connect_changed => sub { |
217 | connect_changed => sub { |
218 | my ($self, $value) = @_; |
218 | my ($self, $value) = @_; |
219 | $CFG->{map_scale} = $value; |
219 | $CFG->{map_scale} = 2 ** $value; |
220 | } |
220 | } |
221 | ); |
221 | ); |
222 | |
222 | |
223 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
223 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
224 | $table->add (1, $row++, new CFClient::UI::CheckBox |
224 | $table->add (1, $row++, new CFClient::UI::CheckBox |
… | |
… | |
230 | } |
230 | } |
231 | ); |
231 | ); |
232 | |
232 | |
233 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
233 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
234 | $table->add (1, $row++, new CFClient::UI::Slider |
234 | $table->add (1, $row++, new CFClient::UI::Slider |
235 | range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], |
235 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
236 | tooltip => "The higher the intensity, the lighter the Fog-of-War color", |
236 | tooltip => "The higher the intensity, the lighter the Fog-of-War color", |
237 | connect_changed => sub { |
237 | connect_changed => sub { |
238 | my ($self, $value) = @_; |
238 | my ($self, $value) = @_; |
239 | $CFG->{fow_intensity} = $value; |
239 | $CFG->{fow_intensity} = $value; |
240 | } |
240 | } |
… | |
… | |
251 | } |
251 | } |
252 | ); |
252 | ); |
253 | |
253 | |
254 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
254 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
255 | $table->add (1, $row++, new CFClient::UI::Slider |
255 | $table->add (1, $row++, new CFClient::UI::Slider |
256 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1, 0.1], |
256 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
257 | tooltip => "The font size used by most GUI elements", |
257 | tooltip => "The font size used by most GUI elements", |
258 | connect_changed => sub { $CFG->{gui_fontsize} = $_[1] }, |
258 | connect_changed => sub { $CFG->{gui_fontsize} = $_[1] }, |
259 | ); |
259 | ); |
260 | |
260 | |
261 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); |
261 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); |
262 | $table->add (1, $row++, new CFClient::UI::Slider |
262 | $table->add (1, $row++, new CFClient::UI::Slider |
263 | range => [$CFG->{log_fontsize}, 0.5, 2, 0.1, 0.1], |
263 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
264 | tooltip => "The font size used by the server log window only", |
264 | tooltip => "The font size used by the server log window only", |
265 | connect_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]) }, |
265 | connect_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]) }, |
266 | ); |
266 | ); |
267 | |
267 | |
268 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
268 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
269 | |
269 | |
270 | $table->add (1, $row++, new CFClient::UI::Slider |
270 | $table->add (1, $row++, new CFClient::UI::Slider |
271 | range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1, 0.1], |
271 | range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1], |
272 | tooltip => "The font size used by the statistics window only", |
272 | tooltip => "The font size used by the statistics window only", |
273 | connect_changed => sub { |
273 | connect_changed => sub { |
274 | $CFG->{stat_fontsize} = $_[1]; |
274 | $CFG->{stat_fontsize} = $_[1]; |
275 | &set_stats_window_fontsize; |
275 | &set_stats_window_fontsize; |
276 | } |
276 | } |
277 | ); |
277 | ); |
278 | |
278 | |
279 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size"); |
|
|
280 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
281 | range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02], |
|
|
282 | tooltip => "Adjust the size of the stats gauges at the bottom right", |
|
|
283 | connect_changed => sub { |
|
|
284 | $CFG->{gauge_size} = $_[1]; |
|
|
285 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
|
|
286 | } |
|
|
287 | ); |
|
|
288 | |
|
|
289 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
279 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
290 | $table->add (1, $row++, new CFClient::UI::Slider |
280 | $table->add (1, $row++, new CFClient::UI::Slider |
291 | range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1, 0.1], |
281 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
292 | tooltip => "Adjusts the fontsize of the gauges at the bottom right", |
282 | tooltip => "Adjusts the fontsize of the gauges at the bottom right", |
293 | connect_changed => sub { |
283 | connect_changed => sub { |
294 | $CFG->{gauge_fontsize} = $_[1]; |
284 | $CFG->{gauge_fontsize} = $_[1]; |
295 | &set_gauge_window_fontsize; |
285 | &set_gauge_window_fontsize; |
|
|
286 | } |
|
|
287 | ); |
|
|
288 | |
|
|
289 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size"); |
|
|
290 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
291 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
|
|
292 | tooltip => "Adjust the size of the stats gauges at the bottom right", |
|
|
293 | connect_changed => sub { |
|
|
294 | $CFG->{gauge_size} = $_[1]; |
|
|
295 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
296 | } |
296 | } |
297 | ); |
297 | ); |
298 | |
298 | |
299 | $table->add (1, $row++, new CFClient::UI::Button |
299 | $table->add (1, $row++, new CFClient::UI::Button |
300 | expand => 1, align => 0, text => "Apply", |
300 | expand => 1, align => 0, text => "Apply", |
… | |
… | |
325 | connect_changed => sub { |
325 | connect_changed => sub { |
326 | $CFG->{bgm_enable} = $_[1]; |
326 | $CFG->{bgm_enable} = $_[1]; |
327 | } |
327 | } |
328 | ); |
328 | ); |
329 | $hbox->add (new CFClient::UI::Slider |
329 | $hbox->add (new CFClient::UI::Slider |
330 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], |
330 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
331 | tooltip => "The volume of the background music", |
331 | tooltip => "The volume of the background music", |
332 | connect_changed => sub { |
332 | connect_changed => sub { |
333 | $CFG->{bgm_volume} = $_[1]; |
333 | $CFG->{bgm_volume} = $_[1]; |
334 | CFClient::MixMusic::volume $_[1] * 128; |
334 | CFClient::MixMusic::volume $_[1] * 128; |
335 | } |
335 | } |
… | |
… | |
425 | |
425 | |
426 | $win |
426 | $win |
427 | } |
427 | } |
428 | |
428 | |
429 | sub make_stats_window { |
429 | sub make_stats_window { |
430 | my $tgw = new CFClient::UI::FancyFrame x => $WIDTH * 2/5, y => 0, title => "Stats"; |
430 | my $tgw = new CFClient::UI::FancyFrame title => "Stats"; |
431 | |
431 | |
432 | $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox); |
432 | $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox); |
433 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
433 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
434 | can_hover => 1, can_events => 1, |
434 | can_hover => 1, can_events => 1, |
435 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
435 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
… | |
… | |
438 | tooltip => "The map you are currently on (if supported by the server)."); |
438 | tooltip => "The map you are currently on (if supported by the server)."); |
439 | |
439 | |
440 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
440 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
441 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
441 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
442 | |
442 | |
443 | my $black = [0, 0, 0]; |
443 | my $color2 = [1, 1, 0]; |
444 | |
444 | |
445 | for ( |
445 | for ( |
446 | [0, 0, st_str => "Str", 30, "<b>Physical Strength</b>, determines damage dealt with weapons, how much you can carry, and how often you can attack"], |
446 | [0, 0, st_str => "Str", 30, "<b>Physical Strength</b>, determines damage dealt with weapons, how much you can carry, and how often you can attack"], |
447 | [0, 1, st_dex => "Dex", 30, "<b>Dexterity</b>, your physical agility. Determines chance of being hit and affects armor class and speed"], |
447 | [0, 1, st_dex => "Dex", 30, "<b>Dexterity</b>, your physical agility. Determines chance of being hit and affects armor class and speed"], |
448 | [0, 2, st_con => "Con", 30, "<b>Constitution</b>, physical health and toughness. Determines how many healthpoints you can have"], |
448 | [0, 2, st_con => "Con", 30, "<b>Constitution</b>, physical health and toughness. Determines how many healthpoints you can have"], |
… | |
… | |
461 | my ($col, $row, $id, $label, $template, $tooltip) = @$_; |
461 | my ($col, $row, $id, $label, $template, $tooltip) = @$_; |
462 | |
462 | |
463 | $tbl->add ($col , $row, $STATWIDS->{$id} = new CFClient::UI::Label |
463 | $tbl->add ($col , $row, $STATWIDS->{$id} = new CFClient::UI::Label |
464 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
464 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
465 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
465 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
466 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $black, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
466 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
467 | } |
467 | } |
468 | |
468 | |
469 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
469 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
470 | |
470 | |
471 | my $row = 0; |
471 | my $row = 0; |
… | |
… | |
744 | ); |
744 | ); |
745 | |
745 | |
746 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
746 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
747 | $table->add (1, 7, new CFClient::UI::Slider |
747 | $table->add (1, 7, new CFClient::UI::Slider |
748 | req_w => 100, |
748 | req_w => 100, |
749 | range => [$CFG->{mapsize}, 10, 100 + 1, 1, 1], |
749 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
750 | tooltip => "This is the size of the portion of the map update the server sends you. " |
750 | tooltip => "This is the size of the portion of the map update the server sends you. " |
751 | ."If you set this to a high value you will be able to see further for example.", |
751 | . "If you set this to a high value you will be able to see further for example.", |
752 | connect_changed => sub { |
752 | connect_changed => sub { |
753 | my ($self, $value) = @_; |
753 | my ($self, $value) = @_; |
754 | |
754 | |
755 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
755 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
756 | }, |
756 | }, |
… | |
… | |
843 | $QUIT_DIALOG = new CFClient::UI::FancyFrame title => "Really Quit?"; |
843 | $QUIT_DIALOG = new CFClient::UI::FancyFrame title => "Really Quit?"; |
844 | |
844 | |
845 | $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); |
845 | $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); |
846 | |
846 | |
847 | $vb->add (new CFClient::UI::Label |
847 | $vb->add (new CFClient::UI::Label |
848 | text => "You should find a savebed and apply it first!", |
848 | text => "You should find a savebed and apply it first!", |
849 | max_w => $WIDTH * 0.25 |
849 | max_w => $WIDTH * 0.25, |
|
|
850 | ellipsize => 0, |
850 | ); |
851 | ); |
851 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
852 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
852 | $hb->add (new CFClient::UI::Button |
853 | $hb->add (new CFClient::UI::Button |
853 | text => "Ok", |
854 | text => "Ok", |
|
|
855 | expand => 1, |
854 | connect_activate => sub { $QUIT_DIALOG->hide }, |
856 | connect_activate => sub { $QUIT_DIALOG->hide }, |
855 | expand => 1 |
|
|
856 | ); |
857 | ); |
857 | $hb->add (new CFClient::UI::Button |
858 | $hb->add (new CFClient::UI::Button |
858 | text => "Quit anyway", |
859 | text => "Quit anyway", |
|
|
860 | expand => 1, |
859 | connect_activate => sub { exit 1 }, |
861 | connect_activate => sub { exit }, |
860 | expand => 1 |
|
|
861 | ); |
862 | ); |
862 | $hb->add (new CFClient::UI::Label "You should find a savebed and apply it first!"); |
|
|
863 | |
863 | |
864 | $QUIT_DIALOG->show_centered; |
864 | $QUIT_DIALOG->show_centered; |
865 | } else { |
865 | } else { |
866 | $QUIT_DIALOG->show_centered; |
866 | $QUIT_DIALOG->show_centered; |
867 | } |
867 | } |
868 | } |
868 | } |
869 | |
869 | |
870 | sub make_inventory_window { |
870 | sub make_inventory_window { |
871 | my $invwin = new CFClient::UI::FancyFrame |
871 | my $invwin = new CFClient::UI::FancyFrame |
872 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
872 | user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Inventory"; |
873 | |
873 | |
874 | $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); |
874 | $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); |
875 | |
875 | |
876 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
876 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
877 | $vb1->add (my $lbl = new CFClient::UI::Label); |
877 | $vb1->add (my $lbl = new CFClient::UI::Label); |
… | |
… | |
884 | $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); |
884 | $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); |
885 | |
885 | |
886 | $invwin |
886 | $invwin |
887 | } |
887 | } |
888 | |
888 | |
|
|
889 | sub make_help_window { |
|
|
890 | my $win = new CFClient::UI::FancyFrame |
|
|
891 | user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Documentation"; |
|
|
892 | |
|
|
893 | $win->add (my $vbox = new CFClient::UI::VBox); |
|
|
894 | |
|
|
895 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
|
|
896 | $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); |
|
|
897 | |
|
|
898 | for ( |
|
|
899 | [intro => "Introduction"], |
|
|
900 | [command_help => "Commands"], |
|
|
901 | [skill_help => "Skills"], |
|
|
902 | ) { |
|
|
903 | my ($pod, $label) = @$_; |
|
|
904 | |
|
|
905 | $buttons->add (new CFClient::UI::Button |
|
|
906 | text => $label, |
|
|
907 | connect_activate => sub { |
|
|
908 | my $parser = new Pod::POM; |
|
|
909 | my $pom = $parser->parse_file (CFClient::find_rcfile "pod/$pod.pod"); |
|
|
910 | |
|
|
911 | $viewer->clear; |
|
|
912 | |
|
|
913 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
|
|
914 | for @{ CFClient::pod_to_pango_list $pom }; |
|
|
915 | |
|
|
916 | $viewer->set_offset (0); |
|
|
917 | }, |
|
|
918 | ); |
|
|
919 | } |
|
|
920 | |
|
|
921 | $viewer->add_paragraph ([1, 1, 0, 1], "<big>Use one of the buttons above to display a document.</big>"); |
|
|
922 | |
|
|
923 | $win |
|
|
924 | } |
|
|
925 | |
889 | sub sdl_init { |
926 | sub sdl_init { |
890 | CFClient::SDL_Init |
927 | CFClient::SDL_Init |
891 | and die "SDL::Init failed!\n"; |
928 | and die "SDL::Init failed!\n"; |
892 | } |
929 | } |
893 | |
930 | |
894 | sub video_init { |
931 | sub video_init { |
895 | sdl_init; |
932 | sdl_init; |
896 | |
933 | |
897 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
934 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
898 | |
935 | |
|
|
936 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
|
|
937 | |
899 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
938 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
900 | $FULLSCREEN = $CFG->{fullscreen}; |
939 | $FULLSCREEN = $CFG->{fullscreen}; |
901 | $FAST = $CFG->{fast}; |
940 | $FAST = $CFG->{fast}; |
902 | |
941 | |
903 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
942 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
… | |
… | |
912 | |
951 | |
913 | $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
952 | $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
914 | |
953 | |
915 | ############################################################################# |
954 | ############################################################################# |
916 | |
955 | |
917 | unless ($DEBUG_STATUS) { |
956 | if ($DEBUG_STATUS) { |
|
|
957 | CFClient::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
|
|
958 | } else { |
918 | # create the widgets |
959 | # create the widgets |
919 | |
960 | |
920 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1; |
961 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1; |
921 | $DEBUG_STATUS->show; |
962 | $DEBUG_STATUS->show; |
922 | |
963 | |
… | |
… | |
985 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
1026 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
986 | status "Configuration Saved"; |
1027 | status "Configuration Saved"; |
987 | }, |
1028 | }, |
988 | ); |
1029 | ); |
989 | |
1030 | |
|
|
1031 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, |
|
|
1032 | tooltip => "View Documentation"); |
|
|
1033 | |
990 | $BUTTONBAR->add (new CFClient::UI::Button |
1034 | $BUTTONBAR->add (new CFClient::UI::Button |
991 | text => "Quit", |
1035 | text => "Quit", |
992 | tooltip => "Terminates the program", |
1036 | tooltip => "Terminates the program", |
993 | connect_activate => sub { |
1037 | connect_activate => sub { |
994 | if ($CONN) { |
1038 | if ($CONN) { |
995 | open_quit_dialog |
1039 | open_quit_dialog; |
996 | } else { |
1040 | } else { |
997 | exit 1 |
1041 | exit; |
998 | } |
1042 | } |
999 | }, |
1043 | }, |
1000 | ); |
1044 | ); |
1001 | |
1045 | |
1002 | $BUTTONBAR->show; |
1046 | $BUTTONBAR->show; |
… | |
… | |
1038 | |
1082 | |
1039 | sub audio_init { |
1083 | sub audio_init { |
1040 | if ($CFG->{audio_enable}) { |
1084 | if ($CFG->{audio_enable}) { |
1041 | if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { |
1085 | if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { |
1042 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
1086 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
|
|
1087 | |
|
|
1088 | unless ($SDL_MIXER) { |
|
|
1089 | status "Unable to open sound device: there will be no sound"; |
|
|
1090 | return; |
|
|
1091 | } |
|
|
1092 | |
1043 | CFClient::Mix_AllocateChannels 8; |
1093 | CFClient::Mix_AllocateChannels 8; |
1044 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
1094 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
1045 | |
1095 | |
1046 | audio_music_finished; |
1096 | audio_music_finished; |
1047 | |
1097 | |
… | |
… | |
1201 | |
1251 | |
1202 | $MAPWIDGET->add_command ("$cmd$arg", $text); |
1252 | $MAPWIDGET->add_command ("$cmd$arg", $text); |
1203 | } |
1253 | } |
1204 | } |
1254 | } |
1205 | |
1255 | |
|
|
1256 | $self->{noface} = new_from_file CFClient::Texture |
|
|
1257 | CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; |
|
|
1258 | |
1206 | $self |
1259 | $self |
1207 | } |
1260 | } |
1208 | |
1261 | |
1209 | sub conn::stats_update { |
1262 | sub conn::stats_update { |
1210 | my ($self, $stats) = @_; |
1263 | my ($self, $stats) = @_; |
… | |
… | |
1307 | |
1360 | |
1308 | return; |
1361 | return; |
1309 | } |
1362 | } |
1310 | } |
1363 | } |
1311 | |
1364 | |
1312 | $self->SUPER::send_mapinfo ($data, $cb); |
1365 | $self->Crossfire::Protocol::send_mapinfo ($data, $cb); |
1313 | } |
1366 | } |
1314 | |
1367 | |
1315 | # this method does a "flood fill" into every tile direction |
1368 | # this method does a "flood fill" into every tile direction |
1316 | # it assumes that tiles are arranged in a rectangular grid, |
1369 | # it assumes that tiles are arranged in a rectangular grid, |
1317 | # i.e. a map is the same as the left of the right map etc. |
1370 | # i.e. a map is the same as the left of the right map etc. |
… | |
… | |
1406 | |
1459 | |
1407 | my $id = $FACEMAP->get ($hash); |
1460 | my $id = $FACEMAP->get ($hash); |
1408 | |
1461 | |
1409 | unless ($id) { |
1462 | unless ($id) { |
1410 | # create new id for face |
1463 | # create new id for face |
1411 | # i love transactions |
1464 | # I love transactions |
1412 | for (1..100) { |
1465 | for (1..100) { |
1413 | my $txn = $CFClient::DB_ENV->txn_begin; |
1466 | my $txn = $CFClient::DB_ENV->txn_begin; |
1414 | my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); |
1467 | my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); |
1415 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
1468 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
1416 | $id++; |
1469 | $id = ($id || 16) + 1; |
1417 | if ($FACEMAP->put (id => $id) == 0 |
1470 | if ($FACEMAP->put (id => $id) == 0 |
1418 | && $FACEMAP->put ($hash => $id) == 0) { |
1471 | && $FACEMAP->put ($hash => $id) == 0) { |
1419 | $txn->txn_commit; |
1472 | $txn->txn_commit; |
1420 | |
1473 | |
1421 | goto gotid; |
1474 | goto gotid; |
… | |
… | |
1429 | |
1482 | |
1430 | gotid: |
1483 | gotid: |
1431 | $face->{id} = $id; |
1484 | $face->{id} = $id; |
1432 | $MAP->set_face ($facenum => $id); |
1485 | $MAP->set_face ($facenum => $id); |
1433 | $self->{faceid}[$facenum] = $id;#d# |
1486 | $self->{faceid}[$facenum] = $id;#d# |
|
|
1487 | |
1434 | $TILECACHE->get ($id) |
1488 | $TILECACHE->get ($id) || do { |
|
|
1489 | my $tex = $self->{noface}; |
|
|
1490 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
1491 | undef |
|
|
1492 | }; |
1435 | } |
1493 | } |
1436 | |
1494 | |
1437 | sub conn::face_update { |
1495 | sub conn::face_update { |
1438 | my ($self, $facenum, $face) = @_; |
1496 | my ($self, $facenum, $face) = @_; |
1439 | |
1497 | |
… | |
… | |
1628 | return unless $CONN; |
1686 | return unless $CONN; |
1629 | |
1687 | |
1630 | $FLOORBOX->clear; |
1688 | $FLOORBOX->clear; |
1631 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1689 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1632 | |
1690 | |
1633 | my $count = 4; |
1691 | my $count = 7; |
1634 | for (@{ $CONN->{container}{0} }) { |
1692 | for (@{ $CONN->{container}{0} }) { |
1635 | if (--$count) { |
1693 | if (--$count) { |
1636 | $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_); |
1694 | $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_); |
1637 | } else { |
1695 | } else { |
1638 | $FLOORBOX->add (new CFClient::UI::Label text => "More..."); |
1696 | $FLOORBOX->add (new CFClient::UI::Label text => "More..."); |
… | |
… | |
1862 | |
1920 | |
1863 | Event::loop; |
1921 | Event::loop; |
1864 | |
1922 | |
1865 | END { CFClient::SDL_Quit } |
1923 | END { CFClient::SDL_Quit } |
1866 | |
1924 | |
|
|
1925 | =head1 NAME |
|
|
1926 | |
1867 | =head1 pclient - Crossfire+ and Crossfire game client |
1927 | pclient - A Crossfire+ and Crossfire game client |
1868 | |
1928 | |
1869 | Pclient is a Crossfire+ and Crossfire game client. |
1929 | =head1 SYNOPSIS |
1870 | |
1930 | |
1871 | =head2 Features |
1931 | Just run it - no commandline arguments are supported. |
1872 | |
|
|
1873 | =over 4 |
|
|
1874 | |
|
|
1875 | =item Fullscreen Map |
|
|
1876 | |
|
|
1877 | PClient can uses a fullscreen map, which greatly enhances how much of the |
|
|
1878 | game world you can see. |
|
|
1879 | |
|
|
1880 | =item Persistent Map Cache (Crossfire+ only) |
|
|
1881 | |
|
|
1882 | PClient can persistently cache all map data it received from the |
|
|
1883 | server. This not only allows it to display an overview map, but also |
|
|
1884 | ensures that once-explored areas will be available the next time you want |
|
|
1885 | to explore more. |
|
|
1886 | |
|
|
1887 | =item Hardware acceleration |
|
|
1888 | |
|
|
1889 | Unlike most Crossfire clients, PClient take advantage of OpenGL hardware |
|
|
1890 | acceleration. Most modern graphics cards have difficulties with 2D |
|
|
1891 | acceleration, while 3D graphics is accelerated well. |
|
|
1892 | |
|
|
1893 | =item No arbitrary limits |
|
|
1894 | |
|
|
1895 | Unlike other Crossfire clients, pclient does not suffer from arbitrary |
|
|
1896 | limits (like a fixed amount of face numbers). There are still limits, but |
|
|
1897 | they are not arbitrarily low :) |
|
|
1898 | |
|
|
1899 | =back |
|
|
1900 | |
1932 | |
1901 | =head1 USAGE |
1933 | =head1 USAGE |
1902 | |
1934 | |
1903 | =head2 The Map |
1935 | Pclient utilises OpenGL for all UI elements and the game. It is supposed to be used |
1904 | |
1936 | fullscreen and interactively. |
1905 | The map is always displayed in the background, behind all other windows and UI elements. |
|
|
1906 | |
|
|
1907 | #TODO# middle-click scrolls |
|
|
1908 | # |
|
|
1909 | # keys: |
|
|
1910 | # |
|
|
1911 | # a apply |
|
|
1912 | # keypad moves, kp_5 applies ranged attack to self |
|
|
1913 | |
|
|
1914 | Starting to type enters the I<completion mode>. In that mode, you can type |
|
|
1915 | abbreviations or commands and have them executed as soon as they match a |
|
|
1916 | valid command. This is best explained by a few examples: |
|
|
1917 | |
|
|
1918 | Typing B<climb> will display a list of commands with I<climb> in their |
|
|
1919 | name, such as I<ready_skill climbing> and I<use_skill climbing>. |
|
|
1920 | |
|
|
1921 | You can abbreviate commands by typing only the first character of every |
|
|
1922 | word (or even characters within the word - the client will try to make |
|
|
1923 | a good guess, as long as the characters are in order). For example, |
|
|
1924 | typing I<iwor> will likely select I<invoke word of recall>, while I<ccfo> |
|
|
1925 | will select I<cast create food>. Likewise, I<rscli> will likely select |
|
|
1926 | I<ready_skill climbing> and I<usl> will give you I<use_skill levitation>. |
|
|
1927 | |
|
|
1928 | You can enter space and other text as arguemnt to the command. For |
|
|
1929 | example, C<cfoo waybread> will expand to C<cast create food waybread>. |
|
|
1930 | |
|
|
1931 | =head2 The map overview |
|
|
1932 | |
|
|
1933 | #TODO# |
|
|
1934 | |
|
|
1935 | =head2 The Status area in the lower right corner |
|
|
1936 | |
|
|
1937 | #TODO# |
|
|
1938 | |
|
|
1939 | =head2 The I<Statistics>/I>Stats> window |
|
|
1940 | |
|
|
1941 | #TODO# |
|
|
1942 | |
|
|
1943 | =head1 FAQ |
|
|
1944 | |
|
|
1945 | =over 4 |
|
|
1946 | |
|
|
1947 | =item The client is very sluggish and slow, what can I do about this? |
|
|
1948 | |
|
|
1949 | Most likely, you don't have accelerated OpenGL support. Try to find a |
|
|
1950 | newer driver, or a driver from your hardware vendor, that features OpenGL |
|
|
1951 | support. |
|
|
1952 | |
|
|
1953 | If this is not an option, the following Setup options reduce the load and |
|
|
1954 | will likely make the client playable with sofwtare rendering (it will |
|
|
1955 | still be slow, though): |
|
|
1956 | |
|
|
1957 | =over 4 |
|
|
1958 | |
|
|
1959 | =item B<Video Mode> should be set as low as possible (e.g. 640x480) |
|
|
1960 | |
|
|
1961 | =item Enable B<Fast & Ugly> mode |
|
|
1962 | |
|
|
1963 | =item Disable B<Fog of War> |
|
|
1964 | |
|
|
1965 | =item Increase B<Map Scale> |
|
|
1966 | |
|
|
1967 | =back |
|
|
1968 | |
|
|
1969 | =back |
|
|
1970 | |
1937 | |
1971 | =head1 AUTHOR |
1938 | =head1 AUTHOR |
1972 | |
1939 | |
1973 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
1940 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
1974 | |
1941 | |