… | |
… | |
51 | Carp::cluck $_[1];#d#TODO: remove when stable |
51 | Carp::cluck $_[1];#d#TODO: remove when stable |
52 | return;#d# |
52 | return;#d# |
53 | CFPlus::fatal ($_[1]); |
53 | CFPlus::fatal ($_[1]); |
54 | }; |
54 | }; |
55 | |
55 | |
56 | our $VERSION = '0.9'; |
|
|
57 | |
|
|
58 | my $MAX_FPS = 60; |
56 | my $MAX_FPS = 60; |
59 | my $MIN_FPS = 5; # unused as of yet |
57 | my $MIN_FPS = 5; # unused as of yet |
60 | |
58 | |
61 | our $META_SERVER = "crossfire.real-time.com:13326"; |
59 | our $META_SERVER = "crossfire.real-time.com:13326"; |
62 | |
60 | |
63 | our $LAST_REFRESH; |
61 | our $LAST_REFRESH; |
64 | our $NOW; |
62 | our $NOW; |
65 | |
63 | |
66 | our $CFG; |
64 | our $CFG; |
67 | our $CONN; |
65 | our $CONN; |
|
|
66 | our $PROFILE; # current profile |
68 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
67 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
69 | |
68 | |
70 | our $WANT_REFRESH; |
69 | our $WANT_REFRESH; |
71 | our $CAN_REFRESH; |
70 | our $CAN_REFRESH; |
72 | |
71 | |
… | |
… | |
344 | status "logging in..."; |
343 | status "logging in..."; |
345 | |
344 | |
346 | $LOGIN_BUTTON->set_text ("Logout"); |
345 | $LOGIN_BUTTON->set_text ("Logout"); |
347 | $SETUP_DIALOG->hide; |
346 | $SETUP_DIALOG->hide; |
348 | |
347 | |
|
|
348 | $PROFILE = $CFG->{profile}{default}; |
|
|
349 | |
349 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
350 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
350 | |
351 | |
351 | my ($host, $port) = split /:/, $CFG->{profile}{default}{host}; |
352 | my ($host, $port) = split /:/, $PROFILE->{host}; |
352 | |
353 | |
353 | $MAP = new CFPlus::Map $mapsize, $mapsize; |
354 | $MAP = new CFPlus::Map $mapsize, $mapsize; |
354 | |
355 | |
355 | $CONN = eval { |
356 | $CONN = eval { |
356 | new CFPlus::Protocol |
357 | new CFPlus::Protocol |
357 | host => $host, |
358 | host => $host, |
358 | port => $port || 13327, |
359 | port => $port || 13327, |
359 | user => $CFG->{profile}{default}{user}, |
360 | user => $PROFILE->{user}, |
360 | pass => $CFG->{profile}{default}{password}, |
361 | pass => $PROFILE->{password}, |
361 | mapw => $mapsize, |
362 | mapw => $mapsize, |
362 | maph => $mapsize, |
363 | maph => $mapsize, |
363 | |
364 | |
364 | client => "cfplus $VERSION $] $^O", |
365 | client => "cfplus $CFPlus::VERSION $] $^O", |
365 | |
366 | |
366 | map_widget => $MAPWIDGET, |
367 | map_widget => $MAPWIDGET, |
367 | logview => $LOGVIEW, |
368 | logview => $LOGVIEW, |
368 | statusbox => $STATUSBOX, |
369 | statusbox => $STATUSBOX, |
369 | map => $MAP, |
370 | map => $MAP, |
… | |
… | |
1054 | $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox |
1055 | $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox |
1055 | state => $CFG->{show_tips}, |
1056 | state => $CFG->{show_tips}, |
1056 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1057 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1057 | on_changed => sub { |
1058 | on_changed => sub { |
1058 | my ($self, $value) = @_; |
1059 | my ($self, $value) = @_; |
1059 | $CFG->{shop_tips} = $value; |
1060 | $CFG->{show_tips} = $value; |
1060 | 0 |
1061 | 0 |
1061 | } |
1062 | } |
1062 | ); |
1063 | ); |
1063 | |
1064 | |
1064 | $vbox->add (new CFPlus::UI::FancyFrame |
1065 | $vbox->add (new CFPlus::UI::FancyFrame |
… | |
… | |
1346 | |
1347 | |
1347 | my $refresh; |
1348 | my $refresh; |
1348 | $refresh = $BIND_UPD_CB = sub { |
1349 | $refresh = $BIND_UPD_CB = sub { |
1349 | $binding_list->clear (); |
1350 | $binding_list->clear (); |
1350 | |
1351 | |
|
|
1352 | return unless $PROFILE; |
|
|
1353 | |
1351 | for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) { |
1354 | for my $mod (keys %{$PROFILE->{bindings}}) { |
1352 | for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) { |
1355 | for my $sym (keys %{$PROFILE->{bindings}{$mod}}) { |
1353 | my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym}; |
1356 | my $cmds = $PROFILE->{bindings}{$mod}{$sym}; |
1354 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
1357 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
1355 | |
1358 | |
1356 | my $lbl = join "; ", @$cmds; |
1359 | my $lbl = join "; ", @$cmds; |
1357 | my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); |
1360 | my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); |
1358 | $binding_list->add (my $hb = new CFPlus::UI::HBox); |
1361 | $binding_list->add (my $hb = new CFPlus::UI::HBox); |
1359 | $hb->add (new CFPlus::UI::Button |
1362 | $hb->add (new CFPlus::UI::Button |
1360 | text => "delete", |
1363 | text => "delete", |
1361 | tooltip => "Deletes the binding", |
1364 | tooltip => "Deletes the binding", |
1362 | on_activate => sub { |
1365 | on_activate => sub { |
1363 | $binding_list->remove ($hb); |
1366 | $binding_list->remove ($hb); |
1364 | delete $::CFG->{profile}{default}{bindings}{$mod}{$sym}; |
1367 | delete $PROFILE->{bindings}{$mod}{$sym}; |
1365 | 0 |
1368 | 0 |
1366 | }); |
1369 | }); |
1367 | |
1370 | |
1368 | $hb->add (new CFPlus::UI::Button |
1371 | $hb->add (new CFPlus::UI::Button |
1369 | text => "edit", |
1372 | text => "edit", |
1370 | tooltip => "Edits the binding", |
1373 | tooltip => "Edits the binding", |
1371 | on_activate => sub { |
1374 | on_activate => sub { |
1372 | $::BIND_EDITOR->set_binding ( |
1375 | $::BIND_EDITOR->set_binding ( |
1373 | $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym}, |
1376 | $mod, $sym, $PROFILE->{bindings}{$mod}{$sym}, |
1374 | sub { |
1377 | sub { |
1375 | my ($nmod, $nsym, $ncmds) = @_; |
1378 | my ($nmod, $nsym, $ncmds) = @_; |
1376 | $::BIND_EDITOR->cfg_unbind ($mod, $sym); |
1379 | $::BIND_EDITOR->cfg_unbind ($mod, $sym); |
1377 | $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); |
1380 | $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); |
1378 | $refresh->(); |
1381 | $refresh->(); |