… | |
… | |
17 | die if $@; |
17 | die if $@; |
18 | } |
18 | } |
19 | |
19 | |
20 | use common::sense; |
20 | use common::sense; |
21 | use Carp 'verbose'; |
21 | use Carp 'verbose'; |
|
|
22 | use Cwd (); |
22 | use EV; |
23 | use EV; |
23 | BEGIN { *time = \&EV::time } |
24 | BEGIN { *time = \&EV::time } |
24 | |
25 | |
25 | use List::Util qw(max min); |
26 | use List::Util qw(max min); |
26 | |
27 | |
… | |
… | |
40 | # nop at compiletime |
41 | # nop at compiletime |
41 | } |
42 | } |
42 | |
43 | |
43 | BEGIN { |
44 | BEGIN { |
44 | $SIG{__DIE__} = sub { |
45 | $SIG{__DIE__} = sub { |
45 | return if $^S; |
46 | return if $^S; # quick reject |
|
|
47 | |
|
|
48 | # return if there are any eval contexts in the csall stack |
|
|
49 | for my $i (0..999) { |
|
|
50 | my ($sub, $is_require) = (caller $i)[3, 7] |
|
|
51 | or last; |
|
|
52 | return if $sub eq "(eval)" && !$is_require; |
|
|
53 | } |
|
|
54 | |
46 | crash "CRASH/DIE: $_[0]" => 1; |
55 | crash "CRASH/DIE: $_[0]" => 1; |
47 | DC::fatal Carp::longmess "$_[0]"; |
56 | DC::fatal Carp::longmess "$_[0]"; |
48 | } |
57 | } |
49 | } |
58 | } |
50 | |
59 | |
… | |
… | |
1131 | text => $CFG->{audio_driver}, |
1140 | text => $CFG->{audio_driver}, |
1132 | template => "dsound1234", |
1141 | template => "dsound1234", |
1133 | tooltip => "You can override the audio driver to use here. Leaving it empty will result " |
1142 | tooltip => "You can override the audio driver to use here. Leaving it empty will result " |
1134 | . "in Deliantra picking one automatically. GNU/Linux users often prefer specific " |
1143 | . "in Deliantra picking one automatically. GNU/Linux users often prefer specific " |
1135 | . "drivers though, and can experiment with <b>alsa</b>, <b>dsp</b>, <b>esd</b>, <b>pulse</b>, <b>arts</b>, <b>nas</b> " |
1144 | . "drivers though, and can experiment with <b>alsa</b>, <b>dsp</b>, <b>esd</b>, <b>pulse</b>, <b>arts</b>, <b>nas</b> " |
1136 | . "or other system-specific drivers. Selecting the wrong driver here will simply result" |
1145 | . "or other system-specific drivers. Selecting the wrong driver here will simply result " |
1137 | . "in no sound.", |
1146 | . "in no sound.", |
1138 | on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 } |
1147 | on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 } |
1139 | ); |
1148 | ); |
1140 | |
1149 | |
1141 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); |
1150 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); |
… | |
… | |
1773 | |
1782 | |
1774 | $vbox |
1783 | $vbox |
1775 | } |
1784 | } |
1776 | |
1785 | |
1777 | sub client_setup { |
1786 | sub client_setup { |
|
|
1787 | my $vbox = new DC::UI::VBox; |
|
|
1788 | |
|
|
1789 | $vbox->add (my $top = new DC::UI::FancyFrame expand => 1, label => "Client Settings"); |
|
|
1790 | $vbox->add (my $bot = new DC::UI::FancyFrame expand => 1, label => "Client Info"); |
|
|
1791 | |
|
|
1792 | { |
1778 | my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]; |
1793 | $top->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]); |
1779 | |
1794 | |
1780 | my $row = 0; |
1795 | my $row = 0; |
1781 | |
1796 | |
1782 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1797 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1783 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1798 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1784 | c_colspan => 2, |
1799 | c_colspan => 2, |
1785 | state => $CFG->{show_tips}, |
1800 | state => $CFG->{show_tips}, |
1786 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1801 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1787 | on_changed => sub { |
1802 | on_changed => sub { |
1788 | my ($self, $value) = @_; |
1803 | my ($self, $value) = @_; |
1789 | $CFG->{show_tips} = $value; |
1804 | $CFG->{show_tips} = $value; |
|
|
1805 | 0 |
1790 | 0 |
1806 | } |
1791 | } |
1807 | ); |
1792 | ); |
|
|
1793 | |
1808 | |
1794 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1809 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1795 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1810 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1796 | c_colspan => 2, |
1811 | c_colspan => 2, |
1797 | text => $CFG->{logview_max_par}, |
1812 | text => $CFG->{logview_max_par}, |
1798 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1813 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1799 | . "sends more messages than this number, older messages get removed to save memory and " |
1814 | . "sends more messages than this number, older messages get removed to save memory and " |
1800 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1815 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1801 | on_changed => sub { |
1816 | on_changed => sub { |
1802 | my ($self, $value) = @_; |
1817 | my ($self, $value) = @_; |
1803 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1818 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1804 | 0 |
1819 | 0 |
1805 | }, |
1820 | }, |
1806 | ); |
1821 | ); |
1807 | |
1822 | |
1808 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Config Autosave"); |
1823 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Config Autosave"); |
1809 | $table->add_at (1, $row, new DC::UI::CheckBox |
1824 | $table->add_at (1, $row, new DC::UI::CheckBox |
1810 | state => $CFG->{config_autosave}, |
1825 | state => $CFG->{config_autosave}, |
1811 | tooltip => "Normally, configuration settings and the user interface layout " |
1826 | tooltip => "Normally, configuration settings and the user interface layout " |
1812 | . "are saved on client exit. You can disable this behaviour by " |
1827 | . "are saved on client exit. You can disable this behaviour by " |
1813 | . "unchecking this checkbox.", |
1828 | . "unchecking this checkbox.", |
1814 | on_changed => sub { |
1829 | on_changed => sub { |
1815 | my ($self, $value) = @_; |
1830 | my ($self, $value) = @_; |
1816 | $CFG->{config_autosave} = $value; |
1831 | $CFG->{config_autosave} = $value; |
|
|
1832 | 0 |
1817 | 0 |
1833 | } |
1818 | } |
1834 | ); |
1819 | ); |
|
|
1820 | $table->add_at (2, $row++, new DC::UI::Button |
1835 | $table->add_at (2, $row++, new DC::UI::Button |
1821 | text => "Save Now", |
1836 | text => "Save Now", |
1822 | tooltip => "Use this to manually save configuration and UI layout when " |
1837 | tooltip => "Use this to manually save configuration and UI layout when " |
1823 | . "autosave is disabled.", |
1838 | . "autosave is disabled.", |
1824 | on_activate => sub { |
1839 | on_activate => sub { |
1825 | DC::write_cfg; |
1840 | DC::write_cfg; |
|
|
1841 | 0 |
1826 | 0 |
1842 | } |
1827 | } |
1843 | ); |
1828 | ); |
1844 | } |
1829 | |
1845 | |
1830 | $table |
1846 | { |
|
|
1847 | $bot->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]); |
|
|
1848 | |
|
|
1849 | my $row = 0; |
|
|
1850 | |
|
|
1851 | $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Data Directory"); |
|
|
1852 | $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $Deliantra::VARDIR, tooltip => ""); |
|
|
1853 | $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Database Directory"); |
|
|
1854 | $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $DC::DB::DBDIR, tooltip => ""); |
|
|
1855 | $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Branch (Prebuilt)"); |
|
|
1856 | $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $::EXE_ID, tooltip => ""); |
|
|
1857 | $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Version (Prebuilt)"); |
|
|
1858 | $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $::EXE_VER, tooltip => ""); |
|
|
1859 | $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Update (Prebuilt)"); |
|
|
1860 | $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $::UPDPAR, tooltip => ""); |
|
|
1861 | } |
|
|
1862 | |
|
|
1863 | $vbox |
1831 | } |
1864 | } |
1832 | |
1865 | |
1833 | sub autopickup_setup { |
1866 | sub autopickup_setup { |
1834 | my $r = new DC::UI::ScrolledWindow ( |
1867 | my $r = new DC::UI::ScrolledWindow ( |
1835 | expand => 1, |
1868 | expand => 1, |
… | |
… | |
2632 | |
2665 | |
2633 | our $INPUT_WATCHER = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2666 | our $INPUT_WATCHER = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2634 | $NOW = EV::now; |
2667 | $NOW = EV::now; |
2635 | |
2668 | |
2636 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2669 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2637 | for DC::poll_events; |
2670 | for DC::peep_events; |
2638 | |
2671 | |
2639 | if (%animate_object) { |
2672 | if (%animate_object) { |
2640 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2673 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2641 | $WANT_REFRESH = 1; |
2674 | $WANT_REFRESH = 1; |
2642 | } |
2675 | } |
… | |
… | |
2814 | }; |
2847 | }; |
2815 | } |
2848 | } |
2816 | } |
2849 | } |
2817 | } |
2850 | } |
2818 | |
2851 | |
|
|
2852 | # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed |
|
|
2853 | # these are ignored under windows, for some reason, and thus set in the loader |
2819 | $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; |
2854 | $ENV{FONTCONFIG_FILE} = "fonts.conf"; |
2820 | $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; |
2855 | $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; |
|
|
2856 | $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions |
2821 | |
2857 | |
2822 | { |
2858 | { |
2823 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2859 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2824 | DejaVuSans.ttf |
2860 | DejaVuSans.ttf |
2825 | DejaVuSansMono.ttf |
2861 | DejaVuSansMono.ttf |