ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.219 by root, Tue Aug 21 00:59:34 2007 UTC vs.
Revision 1.226 by root, Sat Sep 1 07:22:21 2007 UTC

86use CFPlus::DB; 86use CFPlus::DB;
87use CFPlus::UI; 87use CFPlus::UI;
88use CFPlus::UI::Canvas; 88use CFPlus::UI::Canvas;
89use CFPlus::UI::Inventory; 89use CFPlus::UI::Inventory;
90use CFPlus::UI::SpellList; 90use CFPlus::UI::SpellList;
91use CFPlus::UI::Dockable;
91use CFPlus::UI::MessageWindow; 92use CFPlus::UI::MessageWindow;
93use CFPlus::UI::ChatView;
92use CFPlus::Pod; 94use CFPlus::Pod;
93use CFPlus::MapWidget; 95use CFPlus::MapWidget;
94use CFPlus::Macro; 96use CFPlus::Macro;
95 97
96$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 98$SIG{QUIT} = sub { Carp::cluck "QUIT" };
126our $FONT_FIXED; 128our $FONT_FIXED;
127 129
128our $MAP; 130our $MAP;
129our $MAPMAP; 131our $MAPMAP;
130our $MAPWIDGET; 132our $MAPWIDGET;
133our $COMPLETER;
131our $BUTTONBAR; 134our $BUTTONBAR;
132our $METASERVER; 135our $METASERVER;
133our $LOGIN_BUTTON; 136our $LOGIN_BUTTON;
134our $QUIT_DIALOG; 137our $QUIT_DIALOG;
135our $HOST_ENTRY; 138our $HOST_ENTRY;
146our $PL_WINDOW; 149our $PL_WINDOW;
147 150
148our $MUSIC_PLAYING_WIDGET; 151our $MUSIC_PLAYING_WIDGET;
149our $LICENSE_WIDGET; 152our $LICENSE_WIDGET;
150 153
154our $PICKUP_PAGE;
151our $INVENTORY_PAGE; 155our $INVENTORY_PAGE;
152our $STATS_PAGE; 156our $STATS_PAGE;
153our $SKILL_PAGE; 157our $SKILL_PAGE;
154our $SPELL_PAGE; 158our $SPELL_PAGE;
155our $SPELL_LIST; 159our $SPELL_LIST;
180sub debug { 184sub debug {
181 $DEBUG_STATUS->set_text ($_[0]); 185 $DEBUG_STATUS->set_text ($_[0]);
182} 186}
183 187
184sub message { 188sub message {
185 my ($para) = @_;
186 $MESSAGE_WINDOW->message ($para); 189 $MESSAGE_WINDOW->message (@_);
187} 190}
188 191
189############################################################################# 192#############################################################################
190#TODO: maybe move into own audio module... 193#TODO: maybe move into own audio module...
191 194
313 316
314 my $NOW = time; 317 my $NOW = time;
315 318
316 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { 319 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) {
317 my $pos = $MUSIC_PLAYING_META->{stop_pos}; 320 my $pos = $MUSIC_PLAYING_META->{stop_pos};
318 $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos); 321 $MUSIC_PLAYER->fade_in_pos (0, 700, $pos);
319 $MUSIC_START = time - $pos; 322 $MUSIC_START = time - $pos;
320 } else { 323 } else {
321 $MUSIC_PLAYER->play (0); 324 $MUSIC_PLAYER->play (0);
322 $MUSIC_START = time; 325 $MUSIC_START = time;
323 } 326 }
341 my @have = 344 my @have =
342 grep $_ && $_->{data}, 345 grep $_ && $_->{data},
343 map $CONN->{face}[$_], 346 map $CONN->{face}[$_],
344 @$MUSIC_WANT; 347 @$MUSIC_WANT;
345 348
349 # randomize music a bit so that the order is not always the same
350 $_->{stop_time} ||= rand for @have;
351
346 @MUSIC_HAVE = @have 352 @MUSIC_HAVE = @have
347 if @have; 353 if @have;
348 354
349 # default MUSIC_HAVE == MUSIC_DEFAULT 355 # default MUSIC_HAVE == MUSIC_DEFAULT
350 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; 356 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE;
351 $fade_out = 1000; 357 $fade_out = 700;
352 } 358 }
353 359
354 # if the currently playing song is acceptable, let it continue 360 # if the currently playing song is acceptable, let it continue
355 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; 361 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE;
356 362
365 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; 371 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE;
366 372
367 # if the most recently-played piece played very recently, 373 # if the most recently-played piece played very recently,
368 # resume it, else choose the oldest piece for rotation. 374 # resume it, else choose the oldest piece for rotation.
369 audio_music_set_meta 375 audio_music_set_meta
370 $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME 376 $MUSIC_HAVE[-1]{stop_pos} && $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME
371 ? $MUSIC_HAVE[-1] 377 ? $MUSIC_HAVE[-1]
372 : $MUSIC_HAVE[0]; 378 : $MUSIC_HAVE[0];
373 379
374 audio_music_start; 380 audio_music_start;
375 } 381 }
381 $MUSIC_WANT = $songs; 387 $MUSIC_WANT = $songs;
382 audio_music_push; 388 audio_music_push;
383} 389}
384 390
385sub audio_music_finished { 391sub audio_music_finished {
392 if ($MUSIC_PLAYING_META) {
393 $MUSIC_PLAYING_META->{stop_time} = time;
394 }
395
386 # we compress multiple jingles of the same type 396 # we compress multiple jingles of the same type
387 shift @MUSIC_JINGLE 397 shift @MUSIC_JINGLE
388 while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; 398 while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0];
389 399
390 $MUSIC_PLAYING_WIDGET->clear; 400 $MUSIC_PLAYING_WIDGET->clear;
984 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); 994 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health");
985 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); 995 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana");
986 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); 996 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace");
987 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); 997 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food");
988 998
989 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); 999 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
1000 $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress);
1001 $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress);
990 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); 1002 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
991 1003
992 $GAUGES = { 1004 $GAUGES = {
1005 exp => $exp, prg => $prg, sklprg => $sklprg,
993 exp => $exp, win => $win, range => $rng, 1006 win => $win, range => $rng,
994 food => $fg, mana => $mg, hp => $hg, grace => $gg 1007 hp => $hg, mana => $mg, grace => $gg, food => $fg,
995 }; 1008 };
996 1009
997 &set_gauge_window_fontsize; 1010 &set_gauge_window_fontsize;
998 1011
999 $win 1012 $win
1200 $r 1213 $r
1201} 1214}
1202 1215
1203sub skill_window { 1216sub skill_window {
1204 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); 1217 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1);
1218
1205 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); 1219 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]);
1220
1206 $sw 1221 $sw
1207} 1222}
1208 1223
1209sub formsep($) { 1224sub formsep($) {
1210 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 1225 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
1719 $ntb->add_tab ( 1734 $ntb->add_tab (
1720 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, 1735 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1721 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1736 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1722 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." 1737 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1723 ); 1738 );
1724 $ntb->add_tab (Pickup => autopickup_setup, 1739 $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup,
1725 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); 1740 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1726 1741
1727 $ntb->add_tab (Media => media_window, 1742 $ntb->add_tab (Media => media_window,
1728 "License, Author and Source info for media sent by the server."); 1743 "License, Author and Source info for media sent by the server.");
1729 1744
1970 1985
1971 $SDL_ACTIVE = 1; 1986 $SDL_ACTIVE = 1;
1972 $LAST_REFRESH = time - 0.01; 1987 $LAST_REFRESH = time - 0.01;
1973 1988
1974 CFPlus::OpenGL::init; 1989 CFPlus::OpenGL::init;
1990 CFPlus::Macro::init;
1975 1991
1976 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 1992 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
1977 1993
1978 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# 1994 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
1979 1995
1980 ############################################################################# 1996 #############################################################################
1981 1997
1982 if ($DEBUG_STATUS) { 1998 if ($DEBUG_STATUS) {
1983 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; 1999 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
1984 } else { 2000 } else {
1985 # create the widgets 2001 # create/configure the widgets
2002
2003 $CFPlus::UI::ROOT->connect (key_down => sub {
2004 my (undef, $ev) = @_;
2005
2006 if (my @macros = CFPlus::Macro::find $ev) {
2007 CFPlus::Macro::execute $_ for @macros;
2008
2009 return 1;
2010 }
2011
2012 0
2013 });
1986 2014
1987 $DEBUG_STATUS = new CFPlus::UI::Label 2015 $DEBUG_STATUS = new CFPlus::UI::Label
1988 padding => 0, 2016 padding => 0,
1989 z => 100, 2017 z => 100,
1990 force_x => "max", 2018 force_x => "max",
2020 $MESSAGE_WINDOW->activate_console ($preset) 2048 $MESSAGE_WINDOW->activate_console ($preset)
2021 if $MESSAGE_WINDOW; 2049 if $MESSAGE_WINDOW;
2022 }); 2050 });
2023 $MAPWIDGET->show; 2051 $MAPWIDGET->show;
2024 $MAPWIDGET->grab_focus; 2052 $MAPWIDGET->grab_focus;
2053
2054 $COMPLETER = new CFPlus::MapWidget::Command::
2055 command => { },
2056 tooltip => "#completer_help",
2057 ;
2025 2058
2026 $SETUP_DIALOG = new CFPlus::UI::Toplevel 2059 $SETUP_DIALOG = new CFPlus::UI::Toplevel
2027 title => "Setup", 2060 title => "Setup",
2028 name => "setup_dialog", 2061 name => "setup_dialog",
2029 x => 'center', 2062 x => 'center',
2154 delete $animate_object{$widget}; 2187 delete $animate_object{$widget};
2155} 2188}
2156 2189
2157%SDL_CB = ( 2190%SDL_CB = (
2158 CFPlus::SDL_QUIT => sub { 2191 CFPlus::SDL_QUIT => sub {
2159 exit; 2192 Event::unloop_all;
2160 }, 2193 },
2161 CFPlus::SDL_VIDEORESIZE => sub { 2194 CFPlus::SDL_VIDEORESIZE => sub {
2162 }, 2195 },
2163 CFPlus::SDL_VIDEOEXPOSE => sub { 2196 CFPlus::SDL_VIDEOEXPOSE => sub {
2164 CFPlus::UI::full_refresh; 2197 CFPlus::UI::full_refresh;
2297# } 2330# }
2298# my $t2 = Time::HiRes::time; 2331# my $t2 = Time::HiRes::time;
2299# warn $t2-$t1; 2332# warn $t2-$t1;
2300# } 2333# }
2301 2334
2302 $startup_done->();
2303
2304 video_init; 2335 video_init;
2305 audio_init; 2336 audio_init;
2306} 2337}
2307 2338
2308show_tip_of_the_day if $CFG->{show_tips}; 2339show_tip_of_the_day if $CFG->{show_tips};
2340
2341Event->idle (cb => sub {
2342 $_[0]->w->cancel;
2343 $startup_done->();
2344});
2309 2345
2310Event::loop; 2346Event::loop;
2311 2347
2312#video_shutdown; 2348#video_shutdown;
2313#audio_shutdown; 2349#audio_shutdown;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines