… | |
… | |
25 | # need to do it again because that pile of garbage called PAR nukes it before main |
25 | # need to do it again because that pile of garbage called PAR nukes it before main |
26 | unshift @INC, $ENV{PAR_TEMP} |
26 | unshift @INC, $ENV{PAR_TEMP} |
27 | if %PAR::LibCache; |
27 | if %PAR::LibCache; |
28 | |
28 | |
29 | use Time::HiRes 'time'; |
29 | use Time::HiRes 'time'; |
30 | use Pod::POM; |
|
|
31 | use Event; |
30 | use Event; |
32 | |
31 | |
33 | use Crossfire; |
32 | use Crossfire; |
34 | use Crossfire::Protocol::Constants; |
33 | use Crossfire::Protocol::Constants; |
35 | |
34 | |
… | |
… | |
174 | } |
173 | } |
175 | } |
174 | } |
176 | |
175 | |
177 | sub stop_game { |
176 | sub stop_game { |
178 | $LOGIN_BUTTON->set_text ("Login"); |
177 | $LOGIN_BUTTON->set_text ("Login"); |
|
|
178 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
179 | $SETUP_DIALOG->show; |
179 | $SETUP_DIALOG->show; |
180 | $INV_WINDOW->hide; |
180 | $INV_WINDOW->hide; |
181 | $LOGVIEW->hide; |
|
|
182 | |
181 | |
183 | return unless $CONN; |
182 | return unless $CONN; |
184 | |
183 | |
185 | status "connection closed"; |
184 | status "connection closed"; |
186 | |
185 | |
… | |
… | |
711 | my $dialog = new CFClient::UI::FancyFrame |
710 | my $dialog = new CFClient::UI::FancyFrame |
712 | title => "Server List", |
711 | title => "Server List", |
713 | name => 'metaserver_dialog', |
712 | name => 'metaserver_dialog', |
714 | x => 'center', |
713 | x => 'center', |
715 | y => 'center', |
714 | y => 'center', |
|
|
715 | z => 3, |
716 | child => (my $vbox = new CFClient::UI::VBox), |
716 | child => (my $vbox = new CFClient::UI::VBox), |
717 | on_visibility_change => sub { |
717 | on_visibility_change => sub { |
718 | update_metaserver if $_[1]; |
718 | update_metaserver if $_[1]; |
719 | }, |
719 | }, |
720 | ; |
720 | ; |
… | |
… | |
903 | sub open_quit_dialog { |
903 | sub open_quit_dialog { |
904 | unless ($QUIT_DIALOG) { |
904 | unless ($QUIT_DIALOG) { |
905 | $QUIT_DIALOG = new CFClient::UI::FancyFrame |
905 | $QUIT_DIALOG = new CFClient::UI::FancyFrame |
906 | x => "center", |
906 | x => "center", |
907 | y => "center", |
907 | y => "center", |
|
|
908 | z => 50, |
908 | title => "Really Quit?", |
909 | title => "Really Quit?", |
909 | ; |
910 | ; |
910 | |
911 | |
911 | $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); |
912 | $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); |
912 | |
913 | |
… | |
… | |
930 | |
931 | |
931 | $QUIT_DIALOG->show; |
932 | $QUIT_DIALOG->show; |
932 | } |
933 | } |
933 | |
934 | |
934 | sub autopickup_setup { |
935 | sub autopickup_setup { |
935 | my $vb = new CFClient::UI::VBox; |
936 | my $table = new CFClient::UI::Table; |
936 | |
|
|
937 | $vb->add (my $gen_tbl = new CFClient::UI::Table expand => 1); |
|
|
938 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
|
|
939 | $hb->add (my $ltbl = new CFClient::UI::Table expand => 1); |
|
|
940 | $hb->add (my $rtbl = new CFClient::UI::Table expand => 1); |
|
|
941 | |
|
|
942 | my $tbl = 0; |
|
|
943 | my $tblrow = 0; |
|
|
944 | |
937 | |
945 | for ( |
938 | for ( |
946 | ["General", $gen_tbl], |
939 | ["General", 0, 0, |
947 | ["Enable autopickup" => CFClient::Pickup::PU_NEWMODE], |
940 | ["Enable autopickup" => PICKUP_NEWMODE], |
948 | ["Inhibit autopickup" => CFClient::Pickup::PU_INHIBIT], |
941 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
949 | ["Stop before pickup" => CFClient::Pickup::PU_STOP], |
942 | ["Stop before pickup" => PICKUP_STOP], |
950 | ["Debug autopickup" => CFClient::Pickup::PU_DEBUG], |
943 | ["Debug autopickup" => PICKUP_DEBUG], |
|
|
944 | ], |
951 | ["Weapons", $ltbl], |
945 | ["Weapons", 0, 6, |
952 | ["All weapons" => CFClient::Pickup::PU_ALLWEAPON], |
946 | ["All weapons" => PICKUP_ALLWEAPON], |
953 | ["Missile weapons" => CFClient::Pickup::PU_MISSILEWEAPON], |
947 | ["Missile weapons" => PICKUP_MISSILEWEAPON], |
954 | ["Bows" => CFClient::Pickup::PU_BOW], |
948 | ["Bows" => PICKUP_BOW], |
955 | ["Arrows" => CFClient::Pickup::PU_ARROW], |
949 | ["Arrows" => PICKUP_ARROW], |
|
|
950 | ], |
956 | ["Armour"], |
951 | ["Armour", 0, 12, |
957 | ["Helmets" => CFClient::Pickup::PU_HELMET], |
952 | ["Helmets" => PICKUP_HELMET], |
958 | ["Shields" => CFClient::Pickup::PU_SHIELD], |
953 | ["Shields" => PICKUP_SHIELD], |
959 | ["Body Armour" => CFClient::Pickup::PU_ARMOUR], |
954 | ["Body Armour" => PICKUP_ARMOUR], |
960 | ["Boots" => CFClient::Pickup::PU_BOOTS], |
955 | ["Boots" => PICKUP_BOOTS], |
961 | ["Gloves" => CFClient::Pickup::PU_GLOVES], |
956 | ["Gloves" => PICKUP_GLOVES], |
962 | ["Cloaks" => CFClient::Pickup::PU_CLOAK], |
957 | ["Cloaks" => PICKUP_CLOAK], |
|
|
958 | ], |
|
|
959 | |
963 | ["Readables", $rtbl], |
960 | ["Readables", 2, 2, |
964 | ["Spellbooks" => CFClient::Pickup::PU_SPELLBOOK], |
961 | ["Spellbooks" => PICKUP_SPELLBOOK], |
965 | ["Skillscrolls" => CFClient::Pickup::PU_SKILLSCROLL], |
962 | ["Skillscrolls" => PICKUP_SKILLSCROLL], |
966 | ["Normal Books/Scrolls" => CFClient::Pickup::PU_READABLES], |
963 | ["Normal Books/Scrolls" => PICKUP_READABLES], |
|
|
964 | ], |
967 | ["Misc"], |
965 | ["Misc", 2, 7, |
968 | ["Food" => CFClient::Pickup::PU_FOOD], |
966 | ["Food" => PICKUP_FOOD], |
969 | ["Drinks" => CFClient::Pickup::PU_DRINK], |
967 | ["Drinks" => PICKUP_DRINK], |
970 | ["Valuables (Money, Gems)" => CFClient::Pickup::PU_VALUABLES], |
968 | ["Valuables (Money, Gems)" => PICKUP_VALUABLES], |
971 | ["Keys" => CFClient::Pickup::PU_KEY], |
969 | ["Keys" => PICKUP_KEY], |
972 | ["Magical Items" => CFClient::Pickup::PU_MAGICAL], |
970 | ["Magical Items" => PICKUP_MAGICAL], |
973 | ["Potions" => CFClient::Pickup::PU_POTION], |
971 | ["Potions" => PICKUP_POTION], |
974 | ["Magic Devices" => CFClient::Pickup::PU_MAGIC_DEVICE], |
972 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
975 | ["Ignore cursed" => CFClient::Pickup::PU_NOT_CURSED], |
973 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
976 | ["Jewelery" => CFClient::Pickup::PU_JEWELS], |
974 | ["Jewelery" => PICKUP_JEWELS], |
|
|
975 | ], |
977 | ) |
976 | ) |
978 | { |
977 | { |
979 | if (ref $_->[1]) { |
978 | my ($title, $x, $y, @bits) = @$_; |
980 | $tbl = $_->[1]; |
|
|
981 | $tblrow = 0; |
|
|
982 | $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => -1); |
979 | $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
983 | } elsif (not defined $_->[1]) { |
980 | |
984 | $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => -1); |
981 | for (@bits) { |
985 | } else { |
982 | ++$y; |
|
|
983 | |
986 | my $mask = $_->[1]; |
984 | my $mask = $_->[1]; |
987 | $tbl->add (0, $tblrow, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); |
985 | $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); |
988 | $tbl->add (1, $tblrow++, new CFClient::UI::CheckBox |
986 | $table->add ($x+1, $y, new CFClient::UI::CheckBox |
989 | state => $CFG->{pickup} & $mask, |
987 | state => $CFG->{pickup} & $mask, |
990 | on_changed => sub { |
988 | on_changed => sub { |
991 | my ($box, $value) = @_; |
989 | my ($box, $value) = @_; |
992 | if ($value) { |
990 | if ($value) { |
993 | $::CFG->{pickup} |= $mask; |
991 | $::CFG->{pickup} |= $mask; |
… | |
… | |
998 | if defined $::CONN; |
996 | if defined $::CONN; |
999 | }); |
997 | }); |
1000 | } |
998 | } |
1001 | } |
999 | } |
1002 | |
1000 | |
1003 | $vb |
1001 | $table |
1004 | } |
1002 | } |
1005 | |
1003 | |
1006 | sub make_inventory_window { |
1004 | sub make_inventory_window { |
1007 | my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame |
1005 | my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame |
1008 | x => "center", |
1006 | x => "center", |
… | |
… | |
1103 | $SETUP_DIALOG->show; |
1101 | $SETUP_DIALOG->show; |
1104 | }, |
1102 | }, |
1105 | sub { |
1103 | sub { |
1106 | $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); |
1104 | $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); |
1107 | $SETUP_DIALOG->show; |
1105 | $SETUP_DIALOG->show; |
1108 | }); |
1106 | }, |
|
|
1107 | ); |
1109 | $SETUP_DIALOG->hide; |
1108 | $SETUP_DIALOG->hide; |
1110 | $::BIND_EDITOR->show; |
1109 | $::BIND_EDITOR->show; |
1111 | }, |
1110 | }, |
1112 | ); |
1111 | ); |
1113 | |
1112 | |
… | |
… | |
1127 | |
1126 | |
1128 | sub make_help_window { |
1127 | sub make_help_window { |
1129 | my $win = new CFClient::UI::FancyFrame |
1128 | my $win = new CFClient::UI::FancyFrame |
1130 | x => 'center', |
1129 | x => 'center', |
1131 | y => 'center', |
1130 | y => 'center', |
|
|
1131 | z => 2, |
1132 | name => 'doc_browser', |
1132 | name => 'doc_browser', |
1133 | force_w => int $WIDTH * 7/8, |
1133 | force_w => int $WIDTH * 7/8, |
1134 | force_h => int $HEIGHT * 7/8, |
1134 | force_h => int $HEIGHT * 7/8, |
1135 | title => "Documentation"; |
1135 | title => "Documentation"; |
1136 | |
1136 | |
… | |
… | |
1148 | my ($pod, $label) = @$_; |
1148 | my ($pod, $label) = @$_; |
1149 | |
1149 | |
1150 | $buttons->add (new CFClient::UI::Button |
1150 | $buttons->add (new CFClient::UI::Button |
1151 | text => $label, |
1151 | text => $label, |
1152 | on_activate => sub { |
1152 | on_activate => sub { |
1153 | my $parser = new Pod::POM; |
1153 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1154 | my $pom = $parser->parse_file (CFClient::find_rcfile "pod/$pod.pod"); |
1154 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1155 | |
1155 | |
1156 | $viewer->clear; |
1156 | $viewer->clear; |
1157 | |
1157 | |
1158 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1158 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1159 | for @{ CFClient::pod_to_pango_list $pom }; |
1159 | for @$pom; |
1160 | |
1160 | |
1161 | $viewer->set_offset (0); |
1161 | $viewer->set_offset (0); |
1162 | }, |
1162 | }, |
1163 | ); |
1163 | ); |
1164 | } |
1164 | } |
… | |
… | |
1211 | $DEBUG_STATUS->show; |
1211 | $DEBUG_STATUS->show; |
1212 | |
1212 | |
1213 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
1213 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
1214 | |
1214 | |
1215 | $STATUSBOX = new CFClient::UI::Statusbox; |
1215 | $STATUSBOX = new CFClient::UI::Statusbox; |
1216 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); |
1216 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); |
1217 | |
1217 | |
1218 | (new CFClient::UI::Frame |
1218 | (new CFClient::UI::Frame |
1219 | bg => [0, 0, 0, 0.4], |
1219 | bg => [0, 0, 0, 0.4], |
1220 | force_x => 0, |
1220 | force_x => 0, |
1221 | force_y => "max", |
1221 | force_y => "max", |
… | |
… | |
1262 | $SETUP_DIALOG = new CFClient::UI::FancyFrame |
1262 | $SETUP_DIALOG = new CFClient::UI::FancyFrame |
1263 | title => "Setup", |
1263 | title => "Setup", |
1264 | name => "setup_dialog", |
1264 | name => "setup_dialog", |
1265 | x => 'center', |
1265 | x => 'center', |
1266 | y => 'center', |
1266 | y => 'center', |
|
|
1267 | z => 2, |
1267 | force_w => $::WIDTH * 0.6, |
1268 | force_w => $::WIDTH * 0.6, |
1268 | force_h => $::HEIGHT * 0.6, |
1269 | force_h => $::HEIGHT * 0.6, |
1269 | ; |
1270 | ; |
1270 | |
1271 | |
1271 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, |
1272 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, |
1272 | filter => new CFClient::UI::ScrolledWindow xxx => 1, expand => 1, scroll_y => 1); |
1273 | filter => new CFClient::UI::ScrolledWindow xxx => 1, expand => 1, scroll_y => 1); |
1273 | |
1274 | |
1274 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1275 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1275 | "Configure the server to play on, your username, password and other server-related options."); |
1276 | "Configure the server to play on, your username, password and other server-related options."); |
1276 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
1277 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
1277 | "Configure autopicking stetings, i.e. which items you will pick up automatically when walking over them."); |
1278 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1278 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1279 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1279 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1280 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1280 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1281 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1281 | "Configure the use of audio, sound effects and background music."); |
1282 | "Configure the use of audio, sound effects and background music."); |
1282 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1283 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1283 | "Lets you define, edit and delete bindings." |
1284 | "Lets you define, edit and delete bindings." |
1284 | . "There is a shortcut for making bindings: Left Control + Insert opens the binding editor " |
1285 | . "There is a shortcut for making bindings: <b>Left Control + Insert</b> opens the binding editor " |
1285 | . "with nothing set and the recording started. After doing the actions you " |
1286 | . "with nothing set and the recording started. After doing the actions you " |
1286 | . "want to record press Insert and you will be asked to press a key-combo." |
1287 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1287 | . "After pressing the combo the binding will be saved automatically and the " |
1288 | . "After pressing the combo the binding will be saved automatically and the " |
1288 | . "binding editor closes"); |
1289 | . "binding editor closes"); |
1289 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1290 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1290 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
1291 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
1291 | |
1292 | |
1292 | $BUTTONBAR = new CFClient::UI::HBox x => 0, y => 0; |
1293 | $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1293 | |
1294 | |
1294 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1295 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1295 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1296 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1296 | |
1297 | |
1297 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window, |
1298 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window, |
… | |
… | |
1300 | make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
1301 | make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
1301 | |
1302 | |
1302 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, |
1303 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, |
1303 | tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); |
1304 | tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); |
1304 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, |
1305 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, |
1305 | tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)." |
1306 | tooltip => "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1306 | ."You can also hit the <b>Tab</b>-key to show/hide the Inventory."); |
1307 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."); |
1307 | |
1308 | |
1308 | $BUTTONBAR->add (new CFClient::UI::Button |
1309 | $BUTTONBAR->add (new CFClient::UI::Button |
1309 | text => "Save Config", |
1310 | text => "Save Config", |
1310 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1311 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1311 | on_activate => sub { |
1312 | on_activate => sub { |