… | |
… | |
85 | use CFPlus::DB; |
85 | use CFPlus::DB; |
86 | use CFPlus::UI; |
86 | use CFPlus::UI; |
87 | use CFPlus::UI::Canvas; |
87 | use CFPlus::UI::Canvas; |
88 | use CFPlus::UI::Inventory; |
88 | use CFPlus::UI::Inventory; |
89 | use CFPlus::UI::SpellList; |
89 | use CFPlus::UI::SpellList; |
|
|
90 | use CFPlus::UI::MessageWindow; |
90 | use CFPlus::Pod; |
91 | use CFPlus::Pod; |
91 | use CFPlus::MapWidget; |
92 | use CFPlus::MapWidget; |
92 | use CFPlus::Macro; |
93 | use CFPlus::Macro; |
93 | |
94 | |
94 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
95 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
… | |
… | |
126 | |
127 | |
127 | our $MAP; |
128 | our $MAP; |
128 | our $MAPMAP; |
129 | our $MAPMAP; |
129 | our $MAPWIDGET; |
130 | our $MAPWIDGET; |
130 | our $BUTTONBAR; |
131 | our $BUTTONBAR; |
131 | our $LOGVIEW; |
|
|
132 | our $CONSOLE; |
|
|
133 | our $METASERVER; |
132 | our $METASERVER; |
134 | our $LOGIN_BUTTON; |
133 | our $LOGIN_BUTTON; |
135 | our $QUIT_DIALOG; |
134 | our $QUIT_DIALOG; |
136 | our $HOST_ENTRY; |
135 | our $HOST_ENTRY; |
137 | our $FULLSCREEN_ENABLE; |
136 | our $FULLSCREEN_ENABLE; |
… | |
… | |
179 | our $INVR; |
178 | our $INVR; |
180 | our $INV_RIGHT_HB; |
179 | our $INV_RIGHT_HB; |
181 | |
180 | |
182 | our $PICKUP_CFG; |
181 | our $PICKUP_CFG; |
183 | |
182 | |
184 | our $IN_BUILD_MODE; |
|
|
185 | our $BUILD_BUTTON; |
|
|
186 | |
|
|
187 | sub status { |
183 | sub status { |
188 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
184 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
189 | } |
185 | } |
190 | |
186 | |
191 | sub debug { |
187 | sub debug { |
192 | $DEBUG_STATUS->set_text ($_[0]); |
188 | $DEBUG_STATUS->set_text ($_[0]); |
193 | } |
189 | } |
194 | |
190 | |
195 | sub message { |
191 | sub message { |
196 | my ($para) = @_; |
192 | my ($para) = @_; |
197 | |
193 | $MESSAGE_WINDOW->message ($para); |
198 | my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; |
|
|
199 | |
|
|
200 | $para->{markup} = "<span foreground='#ffffff'>$time</span> $para->{markup}"; |
|
|
201 | |
|
|
202 | $LOGVIEW->add_paragraph ($para); |
|
|
203 | $LOGVIEW->scroll_to_bottom; |
|
|
204 | } |
194 | } |
205 | |
195 | |
206 | sub destroy_query_dialog { |
196 | sub destroy_query_dialog { |
207 | (delete $_[0]{query_dialog})->destroy |
197 | (delete $_[0]{query_dialog})->destroy |
208 | if $_[0]{query_dialog}; |
198 | if $_[0]{query_dialog}; |
… | |
… | |
461 | maph => $mapsize, |
451 | maph => $mapsize, |
462 | |
452 | |
463 | client => "cfplus $CFPlus::VERSION $] $^O", |
453 | client => "cfplus $CFPlus::VERSION $] $^O", |
464 | |
454 | |
465 | map_widget => $MAPWIDGET, |
455 | map_widget => $MAPWIDGET, |
466 | logview => $LOGVIEW, |
|
|
467 | statusbox => $STATUSBOX, |
456 | statusbox => $STATUSBOX, |
468 | map => $MAP, |
457 | map => $MAP, |
469 | mapmap => $MAPMAP, |
458 | mapmap => $MAPMAP, |
470 | query => \&server_query, |
459 | query => \&server_query, |
471 | |
460 | |
… | |
… | |
614 | |
603 | |
615 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
604 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
616 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
605 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
617 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
606 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
618 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
607 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
619 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
608 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
620 | ); |
609 | ); |
621 | |
610 | |
622 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
611 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
623 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
612 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
624 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
613 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
… | |
… | |
1192 | sub client_setup { |
1181 | sub client_setup { |
1193 | my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]; |
1182 | my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]; |
1194 | |
1183 | |
1195 | my $row = 0; |
1184 | my $row = 0; |
1196 | |
1185 | |
1197 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); |
|
|
1198 | $table->add_at (1, $row++, my $saycmd = new CFPlus::UI::Entry |
|
|
1199 | text => $CFG->{say_command}, |
|
|
1200 | tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. " |
|
|
1201 | . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
|
|
1202 | . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", |
|
|
1203 | on_changed => sub { |
|
|
1204 | my ($self, $value) = @_; |
|
|
1205 | $CFG->{say_command} = $value; |
|
|
1206 | 0 |
|
|
1207 | } |
|
|
1208 | ); |
|
|
1209 | |
|
|
1210 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); |
1186 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); |
1211 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1187 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1212 | state => $CFG->{show_tips}, |
1188 | state => $CFG->{show_tips}, |
1213 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1189 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1214 | on_changed => sub { |
1190 | on_changed => sub { |
… | |
… | |
1224 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1200 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1225 | . "sends more messages than this number, older messages get removed to save memory and " |
1201 | . "sends more messages than this number, older messages get removed to save memory and " |
1226 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1202 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1227 | on_changed => sub { |
1203 | on_changed => sub { |
1228 | my ($self, $value) = @_; |
1204 | my ($self, $value) = @_; |
1229 | $LOGVIEW->{max_par} = $CFG->{logview_max_par} = $value*1; |
1205 | $MESSAGE_WINDOW->set_max_para ($CFG->{logview_max_par} = $value*1); |
1230 | 0 |
1206 | 0 |
1231 | }, |
1207 | }, |
1232 | ); |
1208 | ); |
1233 | |
1209 | |
1234 | $table |
1210 | $table |
1235 | } |
|
|
1236 | |
|
|
1237 | sub message_window { |
|
|
1238 | my $window = new CFPlus::UI::Toplevel |
|
|
1239 | name => "message_window", |
|
|
1240 | title => "Messages", |
|
|
1241 | border_bg => [1, 1, 1, 1], |
|
|
1242 | x => "max", |
|
|
1243 | y => 0, |
|
|
1244 | force_w => $::WIDTH * 0.4, |
|
|
1245 | force_h => $::HEIGHT * 0.5, |
|
|
1246 | child => (my $vbox = new CFPlus::UI::VBox), |
|
|
1247 | has_close_button => 1; |
|
|
1248 | |
|
|
1249 | $vbox->add ($LOGVIEW); |
|
|
1250 | |
|
|
1251 | $vbox->add (my $input = new CFPlus::UI::Entry |
|
|
1252 | tooltip => "<b>Chat Box</b>. If you enter a text and press return/enter here, the current <i>communication command</i> " |
|
|
1253 | . "from the client setup will be prepended (e.g. <b>shout</b>, <b>chat</b>...). " |
|
|
1254 | . "If you prepend a slash (/), you will submit a command instead (similar to IRC). " |
|
|
1255 | . "A better way to submit commands (and the occasional chat command) is often the map command completer.", |
|
|
1256 | on_focus_in => sub { |
|
|
1257 | my ($input, $prev_focus) = @_; |
|
|
1258 | |
|
|
1259 | delete $input->{refocus_map}; |
|
|
1260 | |
|
|
1261 | if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) { |
|
|
1262 | $input->{refocus_map} = 1; |
|
|
1263 | } |
|
|
1264 | delete $input->{auto_activated}; |
|
|
1265 | |
|
|
1266 | 0 |
|
|
1267 | }, |
|
|
1268 | on_activate => sub { |
|
|
1269 | my ($input, $text) = @_; |
|
|
1270 | $input->set_text (''); |
|
|
1271 | |
|
|
1272 | if ($text =~ /^\/(.*)/) { |
|
|
1273 | $::CONN->user_send ($1); |
|
|
1274 | } else { |
|
|
1275 | my $say_cmd = $::CFG->{say_command} || 'say'; |
|
|
1276 | $::CONN->user_send ("$say_cmd $text"); |
|
|
1277 | } |
|
|
1278 | if ($input->{refocus_map}) { |
|
|
1279 | delete $input->{refocus_map}; |
|
|
1280 | $MAPWIDGET->focus_in |
|
|
1281 | } |
|
|
1282 | |
|
|
1283 | 0 |
|
|
1284 | }, |
|
|
1285 | on_escape => sub { |
|
|
1286 | $MAPWIDGET->grab_focus; |
|
|
1287 | |
|
|
1288 | 0 |
|
|
1289 | }, |
|
|
1290 | ); |
|
|
1291 | |
|
|
1292 | $CONSOLE = { |
|
|
1293 | window => $window, |
|
|
1294 | input => $input, |
|
|
1295 | }; |
|
|
1296 | |
|
|
1297 | $window |
|
|
1298 | } |
1211 | } |
1299 | |
1212 | |
1300 | sub autopickup_setup { |
1213 | sub autopickup_setup { |
1301 | my $r = new CFPlus::UI::ScrolledWindow ( |
1214 | my $r = new CFPlus::UI::ScrolledWindow ( |
1302 | expand => 1, |
1215 | expand => 1, |
… | |
… | |
1488 | |
1401 | |
1489 | my $ntb = |
1402 | my $ntb = |
1490 | $PL_NOTEBOOK = |
1403 | $PL_NOTEBOOK = |
1491 | new CFPlus::UI::Notebook expand => 1; |
1404 | new CFPlus::UI::Notebook expand => 1; |
1492 | |
1405 | |
1493 | $ntb->add ( |
1406 | $ntb->add_tab ( |
1494 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1407 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1495 | "Shows statistics, where all your Stats and Resistances are shown." |
1408 | "Shows statistics, where all your Stats and Resistances are shown." |
1496 | ); |
1409 | ); |
1497 | $ntb->add ( |
1410 | $ntb->add_tab ( |
1498 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1411 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1499 | "Shows all your Skills." |
1412 | "Shows all your Skills." |
1500 | ); |
1413 | ); |
1501 | |
1414 | |
1502 | my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
1415 | my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
1503 | $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList); |
1416 | $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList); |
1504 | $ntb->add ( |
1417 | $ntb->add_tab ( |
1505 | "Spellbook (F4)" => $spellsw, |
1418 | "Spellbook (F4)" => $spellsw, |
1506 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1419 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1507 | ); |
1420 | ); |
1508 | $ntb->add ( |
1421 | $ntb->add_tab ( |
1509 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1422 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1510 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1423 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1511 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1424 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1512 | ); |
1425 | ); |
1513 | $ntb->add (Pickup => autopickup_setup, |
1426 | $ntb->add_tab (Pickup => autopickup_setup, |
1514 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1427 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1515 | |
1428 | |
1516 | $ntb->set_current_page ($INVENTORY_PAGE); |
1429 | $ntb->set_current_page ($INVENTORY_PAGE); |
1517 | |
1430 | |
1518 | $plwin->add ($ntb); |
1431 | $plwin->add ($ntb); |
… | |
… | |
1801 | |
1714 | |
1802 | $MAPWIDGET = new CFPlus::MapWidget; |
1715 | $MAPWIDGET = new CFPlus::MapWidget; |
1803 | $MAPWIDGET->connect (activate_console => sub { |
1716 | $MAPWIDGET->connect (activate_console => sub { |
1804 | my ($mapwidget, $preset) = @_; |
1717 | my ($mapwidget, $preset) = @_; |
1805 | |
1718 | |
1806 | if ($CONSOLE) { |
1719 | $MESSAGE_WINDOW->activate_console ($preset) |
1807 | $CONSOLE->{input}->{auto_activated} = 1; |
1720 | if $MESSAGE_WINDOW; |
1808 | $CONSOLE->{input}->grab_focus; |
|
|
1809 | |
|
|
1810 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
|
|
1811 | $CONSOLE->{input}->set_text ($preset); |
|
|
1812 | } |
|
|
1813 | } |
|
|
1814 | }); |
1721 | }); |
1815 | $MAPWIDGET->show; |
1722 | $MAPWIDGET->show; |
1816 | $MAPWIDGET->grab_focus; |
1723 | $MAPWIDGET->grab_focus; |
1817 | |
|
|
1818 | $LOGVIEW = new CFPlus::UI::TextScroller |
|
|
1819 | expand => 1, |
|
|
1820 | font => $FONT_FIXED, |
|
|
1821 | fontsize => $::CFG->{log_fontsize}, |
|
|
1822 | indent => -4, |
|
|
1823 | can_hover => 1, |
|
|
1824 | can_events => 1, |
|
|
1825 | max_par => $CFG->{logview_max_par}, |
|
|
1826 | tooltip => "<b>Server Log</b>. This text viewer contains all recent messages sent by the server.", |
|
|
1827 | ; |
|
|
1828 | |
1724 | |
1829 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
1725 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
1830 | title => "Setup", |
1726 | title => "Setup", |
1831 | name => "setup_dialog", |
1727 | name => "setup_dialog", |
1832 | x => 'center', |
1728 | x => 'center', |
… | |
… | |
1836 | force_h => $::HEIGHT * 0.6, |
1732 | force_h => $::HEIGHT * 0.6, |
1837 | has_close_button => 1, |
1733 | has_close_button => 1, |
1838 | ; |
1734 | ; |
1839 | |
1735 | |
1840 | $METASERVER = metaserver_dialog; |
1736 | $METASERVER = metaserver_dialog; |
|
|
1737 | $MESSAGE_WINDOW = new CFPlus::UI::MessageWindow; |
1841 | |
1738 | |
1842 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, |
1739 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, |
1843 | filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1740 | filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1844 | |
1741 | |
1845 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1742 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
1846 | "Configure the server to play on, your username, password and other server-related options."); |
1743 | "Configure the server to play on, your username, password and other server-related options."); |
1847 | $SETUP_NOTEBOOK->add (Client => client_setup, |
1744 | $SETUP_NOTEBOOK->add_tab (Client => client_setup, |
1848 | "Configure various client-specific settings."); |
1745 | "Configure various client-specific settings."); |
1849 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1746 | $SETUP_NOTEBOOK->add_tab (Graphics => graphics_setup, |
1850 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1747 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1851 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1748 | $SETUP_NOTEBOOK->add_tab (Audio => audio_setup, |
1852 | "Configure the use of audio, sound effects and background music."); |
1749 | "Configure the use of audio, sound effects and background music."); |
1853 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1750 | $SETUP_NOTEBOOK->add_tab (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1854 | "Lets you define, edit and delete key bindings." |
1751 | "Lets you define, edit and delete key bindings." |
1855 | . "There is a shortcut for making bindings: <b>Control-Insert</b> opens the binding editor " |
1752 | . "There is a shortcut for making bindings: <b>Control-Insert</b> opens the binding editor " |
1856 | . "with nothing set and the recording started. After doing the actions you " |
1753 | . "with nothing set and the recording started. After doing the actions you " |
1857 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1754 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1858 | . "After pressing the combo the binding will be saved automatically and the " |
1755 | . "After pressing the combo the binding will be saved automatically and the " |
1859 | . "binding editor closes"); |
1756 | . "binding editor closes"); |
1860 | $SETUP_NOTEBOOK->add (Debug => debug_setup, |
1757 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
1861 | "Some debuggin' options. Do not ask."); |
1758 | "Some debuggin' options. Do not ask."); |
1862 | |
1759 | |
1863 | $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1760 | $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1864 | |
1761 | |
1865 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1762 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1866 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1763 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1867 | |
1764 | |
1868 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, |
1765 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
1869 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
1766 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
1870 | |
1767 | |
1871 | 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 |
1768 | 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 |
1872 | |
1769 | |
1873 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, |
1770 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, |
… | |
… | |
1906 | } |
1803 | } |
1907 | |
1804 | |
1908 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
1805 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
1909 | } |
1806 | } |
1910 | |
1807 | |
1911 | sub setup_build_button { |
|
|
1912 | my ($enabled) = @_; |
|
|
1913 | if ($enabled) { |
|
|
1914 | $BUILD_BUTTON->hide if $BUILD_BUTTON; |
|
|
1915 | $BUILD_BUTTON ||= new CFPlus::UI::Button |
|
|
1916 | text => "Build", |
|
|
1917 | tooltip => "Opens the ingame builder", |
|
|
1918 | on_activate => sub { |
|
|
1919 | if ($CONN) { |
|
|
1920 | $CONN->send_ext_req (builder_player_items => sub { |
|
|
1921 | open_ingame_editor ($_[0]) if exists $_[0]->{items}; |
|
|
1922 | }); |
|
|
1923 | } |
|
|
1924 | 0 |
|
|
1925 | }; |
|
|
1926 | $BUTTONBAR->add ($BUILD_BUTTON); |
|
|
1927 | } else { |
|
|
1928 | $BUILD_BUTTON->hide if $BUILD_BUTTON; |
|
|
1929 | } |
|
|
1930 | } |
|
|
1931 | |
|
|
1932 | sub open_ingame_editor { |
|
|
1933 | my ($msg) = @_; |
|
|
1934 | |
|
|
1935 | my $win = new CFPlus::UI::Toplevel |
|
|
1936 | x => 0, |
|
|
1937 | y => 'center', |
|
|
1938 | z => 4, |
|
|
1939 | name => 'builder_window', |
|
|
1940 | force_w => int $WIDTH * 1/4, |
|
|
1941 | force_h => int $HEIGHT * 3/4, |
|
|
1942 | title => "In game builder", |
|
|
1943 | has_close_button => 1; |
|
|
1944 | |
|
|
1945 | my $r = new CFPlus::UI::ScrolledWindow ( |
|
|
1946 | expand => 1, |
|
|
1947 | scroll_y => 1 |
|
|
1948 | ); |
|
|
1949 | $r->add (my $vb = new CFPlus::UI::VBox); |
|
|
1950 | $win->add ($r); |
|
|
1951 | |
|
|
1952 | |
|
|
1953 | $vb->add ( |
|
|
1954 | new CFPlus::UI::Button |
|
|
1955 | text => "Disable build mode", |
|
|
1956 | on_activate => sub { $::IN_BUILD_MODE = undef } |
|
|
1957 | ); |
|
|
1958 | $vb->add ( |
|
|
1959 | new CFPlus::UI::Button |
|
|
1960 | text => "ERASE", |
|
|
1961 | on_activate => sub { $::IN_BUILD_MODE = { do_erase => 1 } } |
|
|
1962 | ); |
|
|
1963 | |
|
|
1964 | for my $itemarchname ( |
|
|
1965 | sort { |
|
|
1966 | $msg->{items}->{$a}->{build_arch_name} |
|
|
1967 | cmp $msg->{items}->{$b}->{build_arch_name} |
|
|
1968 | } keys %{$msg->{items}} |
|
|
1969 | ) { |
|
|
1970 | my $info = $msg->{items}->{$itemarchname}; |
|
|
1971 | $vb->add ( |
|
|
1972 | new CFPlus::UI::Button text => $info->{build_arch_name}, |
|
|
1973 | on_activate => sub { |
|
|
1974 | $::IN_BUILD_MODE = { item => $itemarchname, info => $info }; |
|
|
1975 | |
|
|
1976 | if (grep { $msg->{items}->{$itemarchname}->{$_} } qw/has_connection has_name has_text/) { |
|
|
1977 | build_mode_query_arch_info (); |
|
|
1978 | } |
|
|
1979 | } |
|
|
1980 | ); |
|
|
1981 | } |
|
|
1982 | |
|
|
1983 | $win->show; |
|
|
1984 | } |
|
|
1985 | |
|
|
1986 | sub build_mode_query_arch_info { |
|
|
1987 | my ($iteminfo) = $::IN_BUILD_MODE; |
|
|
1988 | my $itemarchname = $iteminfo->{item}; |
|
|
1989 | my $info = $iteminfo->{info}; |
|
|
1990 | |
|
|
1991 | my $dialog = new CFPlus::UI::Toplevel |
|
|
1992 | x => "center", |
|
|
1993 | y => "center", |
|
|
1994 | z => 50, |
|
|
1995 | force_w => int $WIDTH * 1/2, |
|
|
1996 | title => "Enter information for placement of '$itemarchname'", |
|
|
1997 | has_close_button => 1; |
|
|
1998 | |
|
|
1999 | $dialog->add (my $vb = new CFPlus::UI::VBox expand => 1); |
|
|
2000 | |
|
|
2001 | $vb->add (my $table = new CFPlus::UI::Table expand => 1); |
|
|
2002 | my $row = 0; |
|
|
2003 | if ($info->{has_name}) { |
|
|
2004 | $table->add_at (0, $row, new CFPlus::UI::Label text => "Name:"); |
|
|
2005 | $table->add_at (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{name} = $_[1]; 0 }); |
|
|
2006 | } |
|
|
2007 | if ($info->{has_text}) { |
|
|
2008 | $table->add_at (0, $row, new CFPlus::UI::Label text => "Text:"); |
|
|
2009 | $table->add_at (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{text} = $_[1]; 0 }); |
|
|
2010 | } |
|
|
2011 | if ($info->{has_connection}) { |
|
|
2012 | $table->add_at (0, $row, new CFPlus::UI::Label text => "Connection ID:"); |
|
|
2013 | $table->add_at (1, $row++, |
|
|
2014 | new CFPlus::UI::Entry |
|
|
2015 | expand => 1, |
|
|
2016 | on_changed => sub { $::IN_BUILD_MODE->{connection} = $_[1]; 0 }, |
|
|
2017 | tooltip => "Enter the connection ID here. The connection ID connects actors like a lever to a gate or a magic ear to a gate" |
|
|
2018 | ); |
|
|
2019 | } |
|
|
2020 | |
|
|
2021 | $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); |
|
|
2022 | $hb->add (new CFPlus::UI::Button |
|
|
2023 | text => "Close", |
|
|
2024 | expand => 1, |
|
|
2025 | on_activate => sub { $dialog->hide; 0 }, |
|
|
2026 | ); |
|
|
2027 | $dialog->show; |
|
|
2028 | } |
|
|
2029 | |
|
|
2030 | sub video_shutdown { |
1808 | sub video_shutdown { |
2031 | CFPlus::OpenGL::shutdown; |
1809 | CFPlus::OpenGL::shutdown; |
2032 | |
1810 | |
2033 | undef $SDL_ACTIVE; |
1811 | undef $SDL_ACTIVE; |
2034 | } |
1812 | } |
… | |
… | |
2056 | sub audio_music_start { |
1834 | sub audio_music_start { |
2057 | my $path = $MUSIC_PLAYING->{path} |
1835 | my $path = $MUSIC_PLAYING->{path} |
2058 | or return; |
1836 | or return; |
2059 | |
1837 | |
2060 | CFPlus::DB::prefetch_file $path, 1024_000, sub { |
1838 | CFPlus::DB::prefetch_file $path, 1024_000, sub { |
|
|
1839 | return unless $SDL_MIXER; |
|
|
1840 | |
2061 | # music might have changed... |
1841 | # music might have changed... |
2062 | $path eq $MUSIC_PLAYING->{path} |
1842 | $path eq $MUSIC_PLAYING->{path} |
2063 | or return &audio_music_start (); |
1843 | or return &audio_music_start (); |
2064 | |
1844 | |
2065 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $path; |
1845 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $path; |
… | |
… | |
2080 | } |
1860 | } |
2081 | } |
1861 | } |
2082 | |
1862 | |
2083 | sub audio_music_changed { |
1863 | sub audio_music_changed { |
2084 | return unless $CFG->{bgm_enable}; |
1864 | return unless $CFG->{bgm_enable}; |
|
|
1865 | return unless $SDL_MIXER; |
2085 | |
1866 | |
2086 | # default MUSIC_WANT == MUSIC_DEFAULT |
1867 | # default MUSIC_WANT == MUSIC_DEFAULT |
2087 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
1868 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
2088 | |
1869 | |
2089 | # if the currently playing song is acceptable, let it continue |
1870 | # if the currently playing song is acceptable, let it continue |
… | |
… | |
2149 | }; |
1930 | }; |
2150 | } |
1931 | } |
2151 | } else { |
1932 | } else { |
2152 | status "unable to open sound config: $!"; |
1933 | status "unable to open sound config: $!"; |
2153 | } |
1934 | } |
|
|
1935 | } else { |
|
|
1936 | undef $SDL_MIXER; |
2154 | } |
1937 | } |
2155 | } |
1938 | } |
2156 | |
1939 | |
2157 | sub audio_shutdown { |
1940 | sub audio_shutdown { |
2158 | CFPlus::Mix_CloseAudio if $SDL_MIXER; |
1941 | CFPlus::Mix_CloseAudio if $SDL_MIXER; |
… | |
… | |
2282 | log_fontsize => 0.7, |
2065 | log_fontsize => 0.7, |
2283 | gauge_fontsize => 1, |
2066 | gauge_fontsize => 1, |
2284 | gauge_size => 0.35, |
2067 | gauge_size => 0.35, |
2285 | stat_fontsize => 0.7, |
2068 | stat_fontsize => 0.7, |
2286 | mapsize => 100, |
2069 | mapsize => 100, |
2287 | say_command => 'chat', |
|
|
2288 | audio_enable => 1, |
2070 | audio_enable => 1, |
2289 | bgm_enable => 1, |
2071 | bgm_enable => 1, |
2290 | bgm_volume => 0.25, |
2072 | bgm_volume => 0.25, |
2291 | face_prefetch => 0, |
2073 | face_prefetch => 0, |
2292 | output_sync => 1, |
2074 | output_sync => 1, |