… | |
… | |
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 | |
… | |
… | |
38 | use CFClient; |
37 | use CFClient; |
39 | use CFClient::OpenGL (); |
38 | use CFClient::OpenGL (); |
40 | use CFClient::Protocol; |
39 | use CFClient::Protocol; |
41 | use CFClient::UI; |
40 | use CFClient::UI; |
42 | use CFClient::MapWidget; |
41 | use CFClient::MapWidget; |
|
|
42 | |
|
|
43 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
43 | |
44 | |
44 | $Event::DIED = sub { |
45 | $Event::DIED = sub { |
45 | # TODO: display dialog box or so |
46 | # TODO: display dialog box or so |
46 | Carp::confess $_[1];#d#TODO: remove when stable |
47 | Carp::confess $_[1];#d#TODO: remove when stable |
47 | CFClient::error $_[1]; |
48 | CFClient::error $_[1]; |
… | |
… | |
174 | } |
175 | } |
175 | } |
176 | } |
176 | |
177 | |
177 | sub stop_game { |
178 | sub stop_game { |
178 | $LOGIN_BUTTON->set_text ("Login"); |
179 | $LOGIN_BUTTON->set_text ("Login"); |
|
|
180 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
179 | $SETUP_DIALOG->show; |
181 | $SETUP_DIALOG->show; |
180 | $INV_WINDOW->hide; |
182 | $INV_WINDOW->hide; |
181 | $LOGVIEW->hide; |
|
|
182 | |
183 | |
183 | return unless $CONN; |
184 | return unless $CONN; |
184 | |
185 | |
185 | status "connection closed"; |
186 | status "connection closed"; |
186 | |
187 | |
… | |
… | |
711 | my $dialog = new CFClient::UI::FancyFrame |
712 | my $dialog = new CFClient::UI::FancyFrame |
712 | title => "Server List", |
713 | title => "Server List", |
713 | name => 'metaserver_dialog', |
714 | name => 'metaserver_dialog', |
714 | x => 'center', |
715 | x => 'center', |
715 | y => 'center', |
716 | y => 'center', |
|
|
717 | z => 3, |
716 | child => (my $vbox = new CFClient::UI::VBox), |
718 | child => (my $vbox = new CFClient::UI::VBox), |
717 | on_visibility_change => sub { |
719 | on_visibility_change => sub { |
718 | update_metaserver if $_[1]; |
720 | update_metaserver if $_[1]; |
719 | }, |
721 | }, |
720 | ; |
722 | ; |
… | |
… | |
903 | sub open_quit_dialog { |
905 | sub open_quit_dialog { |
904 | unless ($QUIT_DIALOG) { |
906 | unless ($QUIT_DIALOG) { |
905 | $QUIT_DIALOG = new CFClient::UI::FancyFrame |
907 | $QUIT_DIALOG = new CFClient::UI::FancyFrame |
906 | x => "center", |
908 | x => "center", |
907 | y => "center", |
909 | y => "center", |
|
|
910 | z => 50, |
908 | title => "Really Quit?", |
911 | title => "Really Quit?", |
909 | ; |
912 | ; |
910 | |
913 | |
911 | $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); |
914 | $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); |
912 | |
915 | |
… | |
… | |
934 | sub autopickup_setup { |
937 | sub autopickup_setup { |
935 | my $table = new CFClient::UI::Table; |
938 | my $table = new CFClient::UI::Table; |
936 | |
939 | |
937 | for ( |
940 | for ( |
938 | ["General", 0, 0, |
941 | ["General", 0, 0, |
939 | ["Enable autopickup" => CFClient::Pickup::PU_NEWMODE], |
942 | ["Enable autopickup" => PICKUP_NEWMODE], |
940 | ["Inhibit autopickup" => CFClient::Pickup::PU_INHIBIT], |
943 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
941 | ["Stop before pickup" => CFClient::Pickup::PU_STOP], |
944 | ["Stop before pickup" => PICKUP_STOP], |
942 | ["Debug autopickup" => CFClient::Pickup::PU_DEBUG], |
945 | ["Debug autopickup" => PICKUP_DEBUG], |
943 | ], |
946 | ], |
944 | ["Weapons", 0, 6, |
947 | ["Weapons", 0, 6, |
945 | ["All weapons" => CFClient::Pickup::PU_ALLWEAPON], |
948 | ["All weapons" => PICKUP_ALLWEAPON], |
946 | ["Missile weapons" => CFClient::Pickup::PU_MISSILEWEAPON], |
949 | ["Missile weapons" => PICKUP_MISSILEWEAPON], |
947 | ["Bows" => CFClient::Pickup::PU_BOW], |
950 | ["Bows" => PICKUP_BOW], |
948 | ["Arrows" => CFClient::Pickup::PU_ARROW], |
951 | ["Arrows" => PICKUP_ARROW], |
949 | ], |
952 | ], |
950 | ["Armour", 0, 12, |
953 | ["Armour", 0, 12, |
951 | ["Helmets" => CFClient::Pickup::PU_HELMET], |
954 | ["Helmets" => PICKUP_HELMET], |
952 | ["Shields" => CFClient::Pickup::PU_SHIELD], |
955 | ["Shields" => PICKUP_SHIELD], |
953 | ["Body Armour" => CFClient::Pickup::PU_ARMOUR], |
956 | ["Body Armour" => PICKUP_ARMOUR], |
954 | ["Boots" => CFClient::Pickup::PU_BOOTS], |
957 | ["Boots" => PICKUP_BOOTS], |
955 | ["Gloves" => CFClient::Pickup::PU_GLOVES], |
958 | ["Gloves" => PICKUP_GLOVES], |
956 | ["Cloaks" => CFClient::Pickup::PU_CLOAK], |
959 | ["Cloaks" => PICKUP_CLOAK], |
957 | ], |
960 | ], |
958 | |
961 | |
959 | ["Readables", 2, 2, |
962 | ["Readables", 2, 2, |
960 | ["Spellbooks" => CFClient::Pickup::PU_SPELLBOOK], |
963 | ["Spellbooks" => PICKUP_SPELLBOOK], |
961 | ["Skillscrolls" => CFClient::Pickup::PU_SKILLSCROLL], |
964 | ["Skillscrolls" => PICKUP_SKILLSCROLL], |
962 | ["Normal Books/Scrolls" => CFClient::Pickup::PU_READABLES], |
965 | ["Normal Books/Scrolls" => PICKUP_READABLES], |
963 | ], |
966 | ], |
964 | ["Misc", 2, 7, |
967 | ["Misc", 2, 7, |
965 | ["Food" => CFClient::Pickup::PU_FOOD], |
968 | ["Food" => PICKUP_FOOD], |
966 | ["Drinks" => CFClient::Pickup::PU_DRINK], |
969 | ["Drinks" => PICKUP_DRINK], |
967 | ["Valuables (Money, Gems)" => CFClient::Pickup::PU_VALUABLES], |
970 | ["Valuables (Money, Gems)" => PICKUP_VALUABLES], |
968 | ["Keys" => CFClient::Pickup::PU_KEY], |
971 | ["Keys" => PICKUP_KEY], |
969 | ["Magical Items" => CFClient::Pickup::PU_MAGICAL], |
972 | ["Magical Items" => PICKUP_MAGICAL], |
970 | ["Potions" => CFClient::Pickup::PU_POTION], |
973 | ["Potions" => PICKUP_POTION], |
971 | ["Magic Devices" => CFClient::Pickup::PU_MAGIC_DEVICE], |
974 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
972 | ["Ignore cursed" => CFClient::Pickup::PU_NOT_CURSED], |
975 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
973 | ["Jewelery" => CFClient::Pickup::PU_JEWELS], |
976 | ["Jewelery" => PICKUP_JEWELS], |
974 | ], |
977 | ], |
975 | ) |
978 | ) |
976 | { |
979 | { |
977 | my ($title, $x, $y, @bits) = @$_; |
980 | my ($title, $x, $y, @bits) = @$_; |
978 | $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
981 | $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
… | |
… | |
1100 | $SETUP_DIALOG->show; |
1103 | $SETUP_DIALOG->show; |
1101 | }, |
1104 | }, |
1102 | sub { |
1105 | sub { |
1103 | $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); |
1106 | $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); |
1104 | $SETUP_DIALOG->show; |
1107 | $SETUP_DIALOG->show; |
1105 | }); |
1108 | }, |
|
|
1109 | ); |
1106 | $SETUP_DIALOG->hide; |
1110 | $SETUP_DIALOG->hide; |
1107 | $::BIND_EDITOR->show; |
1111 | $::BIND_EDITOR->show; |
1108 | }, |
1112 | }, |
1109 | ); |
1113 | ); |
1110 | |
1114 | |
… | |
… | |
1124 | |
1128 | |
1125 | sub make_help_window { |
1129 | sub make_help_window { |
1126 | my $win = new CFClient::UI::FancyFrame |
1130 | my $win = new CFClient::UI::FancyFrame |
1127 | x => 'center', |
1131 | x => 'center', |
1128 | y => 'center', |
1132 | y => 'center', |
|
|
1133 | z => 2, |
1129 | name => 'doc_browser', |
1134 | name => 'doc_browser', |
1130 | force_w => int $WIDTH * 7/8, |
1135 | force_w => int $WIDTH * 7/8, |
1131 | force_h => int $HEIGHT * 7/8, |
1136 | force_h => int $HEIGHT * 7/8, |
1132 | title => "Documentation"; |
1137 | title => "Documentation"; |
1133 | |
1138 | |
… | |
… | |
1145 | my ($pod, $label) = @$_; |
1150 | my ($pod, $label) = @$_; |
1146 | |
1151 | |
1147 | $buttons->add (new CFClient::UI::Button |
1152 | $buttons->add (new CFClient::UI::Button |
1148 | text => $label, |
1153 | text => $label, |
1149 | on_activate => sub { |
1154 | on_activate => sub { |
1150 | my $parser = new Pod::POM; |
1155 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1151 | my $pom = $parser->parse_file (CFClient::find_rcfile "pod/$pod.pod"); |
1156 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1152 | |
1157 | |
1153 | $viewer->clear; |
1158 | $viewer->clear; |
1154 | |
1159 | |
1155 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1160 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1156 | for @{ CFClient::pod_to_pango_list $pom }; |
1161 | for @$pom; |
1157 | |
1162 | |
1158 | $viewer->set_offset (0); |
1163 | $viewer->set_offset (0); |
1159 | }, |
1164 | }, |
1160 | ); |
1165 | ); |
1161 | } |
1166 | } |
… | |
… | |
1208 | $DEBUG_STATUS->show; |
1213 | $DEBUG_STATUS->show; |
1209 | |
1214 | |
1210 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
1215 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
1211 | |
1216 | |
1212 | $STATUSBOX = new CFClient::UI::Statusbox; |
1217 | $STATUSBOX = new CFClient::UI::Statusbox; |
1213 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); |
1218 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); |
1214 | |
1219 | |
1215 | (new CFClient::UI::Frame |
1220 | (new CFClient::UI::Frame |
1216 | bg => [0, 0, 0, 0.4], |
1221 | bg => [0, 0, 0, 0.4], |
1217 | force_x => 0, |
1222 | force_x => 0, |
1218 | force_y => "max", |
1223 | force_y => "max", |
… | |
… | |
1259 | $SETUP_DIALOG = new CFClient::UI::FancyFrame |
1264 | $SETUP_DIALOG = new CFClient::UI::FancyFrame |
1260 | title => "Setup", |
1265 | title => "Setup", |
1261 | name => "setup_dialog", |
1266 | name => "setup_dialog", |
1262 | x => 'center', |
1267 | x => 'center', |
1263 | y => 'center', |
1268 | y => 'center', |
|
|
1269 | z => 2, |
1264 | force_w => $::WIDTH * 0.6, |
1270 | force_w => $::WIDTH * 0.6, |
1265 | force_h => $::HEIGHT * 0.6, |
1271 | force_h => $::HEIGHT * 0.6, |
1266 | ; |
1272 | ; |
1267 | |
1273 | |
1268 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, |
1274 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, |
1269 | filter => new CFClient::UI::ScrolledWindow xxx => 1, expand => 1, scroll_y => 1); |
1275 | filter => new CFClient::UI::ScrolledWindow xxx => 1, expand => 1, scroll_y => 1); |
1270 | |
1276 | |
1271 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1277 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1272 | "Configure the server to play on, your username, password and other server-related options."); |
1278 | "Configure the server to play on, your username, password and other server-related options."); |
1273 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
1279 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
1274 | "Configure autopicking stetings, i.e. which items you will pick up automatically when walking over them."); |
1280 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1275 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1281 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1276 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1282 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1277 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1283 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1278 | "Configure the use of audio, sound effects and background music."); |
1284 | "Configure the use of audio, sound effects and background music."); |
1279 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1285 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1280 | "Lets you define, edit and delete bindings." |
1286 | "Lets you define, edit and delete bindings." |
1281 | . "There is a shortcut for making bindings: Left Control + Insert opens the binding editor " |
1287 | . "There is a shortcut for making bindings: <b>Left Control + Insert</b> opens the binding editor " |
1282 | . "with nothing set and the recording started. After doing the actions you " |
1288 | . "with nothing set and the recording started. After doing the actions you " |
1283 | . "want to record press Insert and you will be asked to press a key-combo." |
1289 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1284 | . "After pressing the combo the binding will be saved automatically and the " |
1290 | . "After pressing the combo the binding will be saved automatically and the " |
1285 | . "binding editor closes"); |
1291 | . "binding editor closes"); |
1286 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1292 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1287 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
1293 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
1288 | |
1294 | |
1289 | $BUTTONBAR = new CFClient::UI::HBox x => 0, y => 0; |
1295 | $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1290 | |
1296 | |
1291 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1297 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1292 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1298 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1293 | |
1299 | |
1294 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window, |
1300 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window, |
… | |
… | |
1298 | |
1304 | |
1299 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, |
1305 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, |
1300 | tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); |
1306 | tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); |
1301 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, |
1307 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, |
1302 | tooltip => "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1308 | tooltip => "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1303 | ."You can also hit the <b>Tab</b>-key to show/hide the Inventory."); |
1309 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."); |
1304 | |
1310 | |
1305 | $BUTTONBAR->add (new CFClient::UI::Button |
1311 | $BUTTONBAR->add (new CFClient::UI::Button |
1306 | text => "Save Config", |
1312 | text => "Save Config", |
1307 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1313 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1308 | on_activate => sub { |
1314 | on_activate => sub { |