… | |
… | |
190 | our $SDL_ACTIVE; |
190 | our $SDL_ACTIVE; |
191 | our %SDL_CB; |
191 | our %SDL_CB; |
192 | |
192 | |
193 | our $ALT_ENTER_MESSAGE; |
193 | our $ALT_ENTER_MESSAGE; |
194 | our $STATUSBOX; |
194 | our $STATUSBOX; |
|
|
195 | our $MODBOX; |
195 | our $DEBUG_STATUS; |
196 | our $DEBUG_STATUS; |
196 | |
197 | |
197 | our $INV; |
198 | our $INV; |
198 | our $INVR; |
199 | our $INVR; |
199 | our $INVR_HB; |
200 | our $INVR_HB; |
… | |
… | |
208 | $DEBUG_STATUS->set_text ($_[0]); |
209 | $DEBUG_STATUS->set_text ($_[0]); |
209 | } |
210 | } |
210 | |
211 | |
211 | sub message { |
212 | sub message { |
212 | $MESSAGE_DIST->message (@_); |
213 | $MESSAGE_DIST->message (@_); |
|
|
214 | } |
|
|
215 | |
|
|
216 | sub update_modbox { |
|
|
217 | my $mod = DC::SDL_GetModState; |
|
|
218 | |
|
|
219 | my $markup; |
|
|
220 | |
|
|
221 | $markup .= $mod & DC::KMOD_CTRL |
|
|
222 | ? ($MAPWIDGET->{ctrl} ? "[REPEAT]" : "[<span foreground='#888'>REPEAT</span>]") |
|
|
223 | : "[<span foreground='#888'> once </span>]"; |
|
|
224 | |
|
|
225 | $markup .= $mod & DC::KMOD_SHIFT |
|
|
226 | ? ($MAPWIDGET->{shft} ? "[FIRE]" : "[<span foreground='#888'>FIRE</span>]") |
|
|
227 | : "[<span foreground='#888'>move</span>]"; |
|
|
228 | |
|
|
229 | $markup .= $mod & (DC::KMOD_ALT | DC::KMOD_META) |
|
|
230 | ? "[ALT]" |
|
|
231 | : "[<span foreground='#888'>alt</span>]"; |
|
|
232 | |
|
|
233 | $markup .= $mod & DC::KMOD_NUM |
|
|
234 | ? "[NUM]" |
|
|
235 | : "[<span foreground='#888'>num</span>]"; |
|
|
236 | |
|
|
237 | # <tt> around next statement works around some bug that keeps the |
|
|
238 | # "font =>" from being used on windows |
|
|
239 | $MODBOX->set_markup ("<tt>$markup</tt>"); |
213 | } |
240 | } |
214 | |
241 | |
215 | ############################################################################# |
242 | ############################################################################# |
216 | #TODO: maybe move into own audio module... |
243 | #TODO: maybe move into own audio module... |
217 | |
244 | |
… | |
… | |
738 | if ($CONN) { |
765 | if ($CONN) { |
739 | DC::lowdelay fileno $CONN->{fh}; |
766 | DC::lowdelay fileno $CONN->{fh}; |
740 | |
767 | |
741 | status "login successful"; |
768 | status "login successful"; |
742 | } else { |
769 | } else { |
|
|
770 | warn $@; |
743 | status "unable to connect"; |
771 | status "unable to connect"; |
744 | stop_game(); |
772 | stop_game(); |
745 | } |
773 | } |
746 | } |
774 | } |
747 | |
775 | |
… | |
… | |
1947 | my @path = DC::Pod::full_path_of $node; |
1975 | my @path = DC::Pod::full_path_of $node; |
1948 | pop @path; # drop current node |
1976 | pop @path; # drop current node |
1949 | |
1977 | |
1950 | for my $node (@path) { |
1978 | for my $node (@path) { |
1951 | $buttons->add (new DC::UI::Button |
1979 | $buttons->add (new DC::UI::Button |
1952 | text => $node->{kw}[0], |
1980 | text => $node->[DC::Pod::N_KW][0], |
1953 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1981 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1954 | on_activate => sub { |
1982 | on_activate => sub { |
1955 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1983 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1956 | $load_node->($node); |
1984 | $load_node->($node); |
1957 | }, |
1985 | }, |
1958 | ); |
1986 | ); |
1959 | $buttons->add (new DC::UI::Label text => "/"); |
1987 | $buttons->add (new DC::UI::Label text => "/"); |
1960 | } |
1988 | } |
1961 | |
1989 | |
1962 | $buttons->add (new DC::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); |
1990 | $buttons->add (new DC::UI::Label text => $node->[DC::Pod::N_KW][0], padding_x => 4, padding_y => 4); |
1963 | |
1991 | |
1964 | $curnode = $node; |
1992 | $curnode = $node; |
1965 | |
1993 | |
1966 | $viewer->clear; |
1994 | $viewer->clear; |
1967 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
1995 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
… | |
… | |
2146 | force_x => "max", |
2174 | force_x => "max", |
2147 | force_y => 0; |
2175 | force_y => 0; |
2148 | $DEBUG_STATUS->show; |
2176 | $DEBUG_STATUS->show; |
2149 | |
2177 | |
2150 | $STATUSBOX = new DC::UI::Statusbox; |
2178 | $STATUSBOX = new DC::UI::Statusbox; |
2151 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); |
2179 | |
|
|
2180 | $MODBOX = new DC::UI::Label |
|
|
2181 | can_events => 1, |
|
|
2182 | can_hover => 1, |
|
|
2183 | markup => "", |
|
|
2184 | align => 0, |
|
|
2185 | font => $FONT_FIXED, |
|
|
2186 | tooltip => "#modifier_box", |
|
|
2187 | tooltip_width => 0.67, |
|
|
2188 | ; |
|
|
2189 | |
|
|
2190 | update_modbox; |
2152 | |
2191 | |
2153 | (new DC::UI::Frame |
2192 | (new DC::UI::Frame |
2154 | bg => [0, 0, 0, 0.4], |
2193 | bg => [0, 0, 0, 0.4], |
2155 | force_x => 0, |
2194 | force_x => 0, |
2156 | force_y => "max", |
2195 | force_y => "max", |
2157 | child => $STATUSBOX, |
2196 | child => (my $LR = new DC::UI::VBox), |
2158 | )->show; |
2197 | )->show; |
|
|
2198 | |
|
|
2199 | $LR->add ($STATUSBOX); |
|
|
2200 | $LR->add ($MODBOX); |
|
|
2201 | $LR->add (new DC::UI::Label |
|
|
2202 | align => 0, |
|
|
2203 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
|
|
2204 | fontsize => 0.5, |
|
|
2205 | fg => [1, 1, 0, 0.7], |
|
|
2206 | ); |
2159 | |
2207 | |
2160 | DC::UI::Toplevel->new ( |
2208 | DC::UI::Toplevel->new ( |
2161 | title => "Minimap", |
2209 | title => "Minimap", |
2162 | name => "mapmap", |
2210 | name => "mapmap", |
2163 | x => 0, |
2211 | x => 0, |
… | |
… | |
2238 | $BUTTONBAR->add (new DC::UI::Button |
2286 | $BUTTONBAR->add (new DC::UI::Button |
2239 | text => "Save Config", |
2287 | text => "Save Config", |
2240 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
2288 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
2241 | on_activate => sub { |
2289 | on_activate => sub { |
2242 | $::CFG->{layout} = DC::UI::get_layout; |
2290 | $::CFG->{layout} = DC::UI::get_layout; |
2243 | DC::write_cfg "$Deliantra::VARDIR/client.cf"; |
2291 | DC::write_cfg; |
2244 | status "Configuration Saved"; |
2292 | status "Configuration Saved"; |
2245 | 0 |
2293 | 0 |
2246 | }, |
2294 | }, |
2247 | ); |
2295 | ); |
2248 | |
2296 | |
… | |
… | |
2345 | # alt-enter |
2393 | # alt-enter |
2346 | $FULLSCREEN_ENABLE->toggle; |
2394 | $FULLSCREEN_ENABLE->toggle; |
2347 | video_shutdown; |
2395 | video_shutdown; |
2348 | video_init; |
2396 | video_init; |
2349 | } else { |
2397 | } else { |
2350 | DC::UI::feed_sdl_key_down_event ($_[0]); |
2398 | &DC::UI::feed_sdl_key_down_event; |
2351 | } |
2399 | } |
|
|
2400 | update_modbox; |
2352 | }, |
2401 | }, |
2353 | DC::SDL_KEYUP => \&DC::UI::feed_sdl_key_up_event, |
2402 | DC::SDL_KEYUP => sub { |
|
|
2403 | &DC::UI::feed_sdl_key_up_event; |
|
|
2404 | update_modbox; |
|
|
2405 | }, |
2354 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2406 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2355 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2407 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2356 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2408 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2357 | DC::SDL_USEREVENT => sub { |
2409 | DC::SDL_USEREVENT => sub { |
2358 | if ($_[0]{code} == 1) { |
2410 | if ($_[0]{code} == 1) { |
… | |
… | |
2369 | EV::unloop; |
2421 | EV::unloop; |
2370 | #d# TODO calling exit here hangs the process in some futex |
2422 | #d# TODO calling exit here hangs the process in some futex |
2371 | }; |
2423 | }; |
2372 | |
2424 | |
2373 | { |
2425 | { |
|
|
2426 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
|
|
2427 | |
2374 | if (-e "$Deliantra::VARDIR/client.cf") { |
2428 | if (-e "$Deliantra::VARDIR/client.cf") { |
2375 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2429 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2376 | } else { |
2430 | } else { |
2377 | #TODO: compatibility cruft |
2431 | #TODO: compatibility cruft |
2378 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2432 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2379 | print STDERR "INFO: used old configuration file\n"; |
2433 | print STDERR "INFO: used old configuration file\n"; |
2380 | } |
2434 | } |
2381 | |
2435 | |
2382 | DC::DB::Server::run; |
2436 | DC::DB::Server::run; |
|
|
2437 | |
|
|
2438 | if ($CFG->{db_schema} < 1) { |
|
|
2439 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
|
|
2440 | DC::DB::nuke_db; |
|
|
2441 | $CFG->{db_schema} = 1; |
|
|
2442 | DC::write_cfg; |
|
|
2443 | } |
|
|
2444 | |
|
|
2445 | DC::DB::open_db; |
2383 | |
2446 | |
2384 | DC::UI::set_layout ($::CFG->{layout}); |
2447 | DC::UI::set_layout ($::CFG->{layout}); |
2385 | |
2448 | |
2386 | my %DEF_CFG = ( |
2449 | my %DEF_CFG = ( |
2387 | sdl_mode => 0, |
2450 | sdl_mode => 0, |
… | |
… | |
2457 | DejaVuSansMono-BoldOblique.ttf |
2520 | DejaVuSansMono-BoldOblique.ttf |
2458 | ); |
2521 | ); |
2459 | |
2522 | |
2460 | DC::add_font $_ for @fonts; |
2523 | DC::add_font $_ for @fonts; |
2461 | |
2524 | |
2462 | DC::pango_init; |
|
|
2463 | |
|
|
2464 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2525 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2465 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2526 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2466 | |
2527 | |
2467 | $FONT_PROP->make_default; |
2528 | $FONT_PROP->make_default; |
|
|
2529 | |
|
|
2530 | DC::pango_init; |
2468 | } |
2531 | } |
2469 | |
2532 | |
2470 | # compare mono (ft) vs. rgba (cairo) |
2533 | # compare mono (ft) vs. rgba (cairo) |
2471 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2534 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2472 | # for my $rgba (0..1) { |
2535 | # for my $rgba (0..1) { |