ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Main.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Main.pm (file contents):
Revision 1.16 by root, Wed Jan 18 00:51:41 2012 UTC vs.
Revision 1.18 by root, Wed Jan 18 15:31:51 2012 UTC

2014 $table->add_at (2, $row++, new DC::UI::Button 2014 $table->add_at (2, $row++, new DC::UI::Button
2015 text => "Save Now", 2015 text => "Save Now",
2016 tooltip => "Use this to manually save configuration and UI layout when " 2016 tooltip => "Use this to manually save configuration and UI layout when "
2017 . "autosave is disabled.", 2017 . "autosave is disabled.",
2018 on_activate => sub { 2018 on_activate => sub {
2019 DC::write_cfg; 2019 DC::save_cfg;
2020 0 2020 0
2021 } 2021 }
2022 ); 2022 );
2023 } 2023 }
2024 2024
2952 EV::unloop; 2952 EV::unloop;
2953 #d# TODO calling exit here hangs the process in some futex 2953 #d# TODO calling exit here hangs the process in some futex
2954}; 2954};
2955 2955
2956# due to mac os x + sdl combined braindamage, we need this contortion 2956# due to mac os x + sdl combined braindamage, we need this contortion
2957sub DC::Main::main { 2957sub DC::Main::run {
2958 { 2958 DC::SDL_main_hack {
2959 {
2959 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; 2960 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst";
2960 2961
2961 if (-e "$Deliantra::VARDIR/client.cf") { 2962 DC::load_cfg;
2962 DC::read_cfg "$Deliantra::VARDIR/client.cf"; 2963 DC::upgrade_cfg;
2963 } else {
2964 #TODO: compatibility cruft
2965 DC::read_cfg "$Deliantra::OLDDIR/cfplusrc";
2966 print STDERR "INFO: used old configuration file\n";
2967 }
2968 2964
2965 DC::Audio::probe;
2966
2969 DC::DB::Server::run; 2967 DC::DB::Server::run;
2970 2968
2971 if ($CFG->{db_schema} < 1) { 2969 if ($CFG->{db_schema} < 1) {
2972 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; 2970 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n";
2973 DC::DB::nuke_db; 2971 DC::DB::nuke_db;
2974 $CFG->{db_schema} = 1; 2972 $CFG->{db_schema} = 1;
2975 DC::write_cfg; 2973 DC::save_cfg;
2976 }
2977
2978 DC::upgrade_cfg;
2979
2980 DC::DB::open_db;
2981
2982 DC::UI::set_layout ($::CFG->{layout});
2983
2984 my @args = @ARGV;
2985
2986 # OS X passes some process serial number of other shit. they
2987 # could have used an env var or any other sane mechanism. but
2988 # would it be os x then? no...
2989 shift @args if $args[0] =~ /^-psn_/;
2990
2991 my $profile = 'default';
2992
2993 for (my $i = 0; $i < @args; $i++) {
2994 if ($args[$i] =~ /^--?profile$/) {
2995 $profile = $args[$i + 1];
2996 splice @args, $i, 2, ();
2997 $i = 0;
2998 } elsif ($args[$i] =~ /^--?h/) {
2999 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
3000 exit 0;
3001 } 2974 }
3002 }
3003 2975
3004 $CFG->{profile}{$profile} ||= {}; 2976 DC::DB::open_db;
3005 $PROFILE = $CFG->{profile}{$profile};
3006 $PROFILE->{host} ||= "gameserver.deliantra.net";
3007 2977
3008 $PROFILE->{host} = $args[0] if @args > 0; 2978 DC::UI::set_layout ($::CFG->{layout});
3009 $PROFILE->{user} = $args[1] if @args > 1;
3010 $PROFILE->{password} = $args[2] if @args > 2;
3011 2979
3012 # convert old bindings (only default profile matters) 2980 my @args = @ARGV;
3013 if (my $bindings = delete $PROFILE->{bindings}) { 2981
3014 while (my ($mod, $syms) = each %$bindings) { 2982 # OS X passes some process serial number of other shit. they
3015 while (my ($sym, $cmds) = each %$syms) { 2983 # could have used an env var or any other sane mechanism. but
3016 push @{ $PROFILE->{macro} }, { 2984 # would it be os x then? no...
3017 accelkey => [$mod*1, $sym*1], 2985 shift @args if $args[0] =~ /^-psn_/;
3018 action => $cmds, 2986
2987 my $profile = 'default';
2988
2989 for (my $i = 0; $i < @args; $i++) {
2990 if ($args[$i] =~ /^--?profile$/) {
2991 $profile = $args[$i + 1];
2992 splice @args, $i, 2, ();
3019 }; 2993 $i = 0;
2994 } elsif ($args[$i] =~ /^--?h/) {
2995 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
2996 exit 0;
3020 } 2997 }
3021 } 2998 }
2999
3000 $CFG->{profile}{$profile} ||= {};
3001 $PROFILE = $CFG->{profile}{$profile};
3002 $PROFILE->{host} ||= "gameserver.deliantra.net";
3003
3004 $PROFILE->{host} = $args[0] if @args > 0;
3005 $PROFILE->{user} = $args[1] if @args > 1;
3006 $PROFILE->{password} = $args[2] if @args > 2;
3007
3008 # convert old bindings (only default profile matters)
3009 if (my $bindings = delete $PROFILE->{bindings}) {
3010 while (my ($mod, $syms) = each %$bindings) {
3011 while (my ($sym, $cmds) = each %$syms) {
3012 push @{ $PROFILE->{macro} }, {
3013 accelkey => [$mod*1, $sym*1],
3014 action => $cmds,
3015 };
3016 }
3017 }
3022 } 3018 }
3023 3019
3024 # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed 3020 # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed
3025 # these are ignored under windows, for some reason, and thus set in the loader 3021 # these are ignored under windows, for some reason, and thus set in the loader
3026 $ENV{FONTCONFIG_FILE} = "fonts.conf"; 3022 $ENV{FONTCONFIG_FILE} = "fonts.conf";
3027 $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; 3023 $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts";
3028 $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions 3024 $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions
3029 3025
3030 { 3026 {
3031 my @fonts = map DC::find_rcfile "fonts/$_", qw( 3027 my @fonts = map DC::find_rcfile "fonts/$_", qw(
3032 DejaVuSans.ttf 3028 DejaVuSans.ttf
3033 DejaVuSansMono.ttf 3029 DejaVuSansMono.ttf
3034 DejaVuSans-Bold.ttf 3030 DejaVuSans-Bold.ttf
3035 DejaVuSansMono-Bold.ttf 3031 DejaVuSansMono-Bold.ttf
3036 DejaVuSans-Oblique.ttf 3032 DejaVuSans-Oblique.ttf
3037 DejaVuSansMono-Oblique.ttf 3033 DejaVuSansMono-Oblique.ttf
3038 DejaVuSans-BoldOblique.ttf 3034 DejaVuSans-BoldOblique.ttf
3039 DejaVuSansMono-BoldOblique.ttf 3035 DejaVuSansMono-BoldOblique.ttf
3040 mona.ttf 3036 mona.ttf
3041 ); 3037 );
3042 3038
3043 DC::add_font $_ for @fonts; 3039 DC::add_font $_ for @fonts;
3044 3040
3045 $FONT_PROP = new_from_file DC::Font $fonts[0]; 3041 $FONT_PROP = new_from_file DC::Font $fonts[0];
3046 $FONT_FIXED = new_from_file DC::Font $fonts[1]; 3042 $FONT_FIXED = new_from_file DC::Font $fonts[1];
3047 3043
3048 $FONT_PROP->make_default; 3044 $FONT_PROP->make_default;
3049 3045
3050 DC::pango_init; 3046 DC::pango_init;
3051 } 3047 }
3052 3048
3053# compare mono (ft) vs. rgba (cairo) 3049# compare mono (ft) vs. rgba (cairo)
3054# ft - 1.8s, cairo 3s, even in alpha-only mode 3050# ft - 1.8s, cairo 3s, even in alpha-only mode
3055# for my $rgba (0..1) { 3051# for my $rgba (0..1) {
3056# my $t1 = Time::HiRes::time; 3052# my $t1 = Time::HiRes::time;
3061# } 3057# }
3062# my $t2 = Time::HiRes::time; 3058# my $t2 = Time::HiRes::time;
3063# warn $t2-$t1; 3059# warn $t2-$t1;
3064# } 3060# }
3065 3061
3062 }
3063
3064 DC::SDL_Init 0;
3066 DC::IMG_Init; video_init; 3065 DC::IMG_Init; video_init;
3067 DC::Mix_Init; audio_init; 3066 DC::Mix_Init; audio_init;
3068 }
3069 3067
3070 show_tip_of_the_day if $CFG->{show_tips}; 3068 show_tip_of_the_day if $CFG->{show_tips};
3071 3069
3072 my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { 3070 my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub {
3073 undef $STARTUP_CANCEL; 3071 undef $STARTUP_CANCEL;
3074 (pop @::STARTUP_DONE)->() 3072 (pop @::STARTUP_DONE)->()
3075 while @::STARTUP_DONE; 3073 while @::STARTUP_DONE;
3074 };
3075
3076 debug_toggle 0;
3077
3078 delete $SIG{__DIE__};
3079 EV::loop;
3080
3081 DC::save_cfg if $CFG->{config_autosave};
3082
3083 #video_shutdown;
3084 #audio_shutdown;
3085
3086 DC::OpenGL::quit;
3087 DC::SDL_Quit;
3088 DC::DB::Server::stop;
3076 }; 3089 };
3077
3078 debug_toggle 0;
3079
3080 delete $SIG{__DIE__};
3081 EV::loop;
3082
3083 DC::write_cfg if $CFG->{config_autosave};
3084
3085 #video_shutdown;
3086 #audio_shutdown;
3087
3088 DC::OpenGL::quit;
3089 DC::SDL_Quit;
3090 DC::DB::Server::stop;
3091} 3090}
3092
3093*DC::Main::run = \&DC::SDL_braino; # see sub above
3094 3091
30951 30921

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines