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

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.465 by root, Thu Aug 28 00:53:53 2008 UTC vs.
Revision 1.468 by root, Wed Sep 3 10:36:25 2008 UTC

1256 fontsize => ($arg{border} || 0.8) * 0.75; 1256 fontsize => ($arg{border} || 0.8) * 0.75;
1257 } 1257 }
1258 1258
1259 my $self = $class->SUPER::new ( 1259 my $self = $class->SUPER::new (
1260 # label => "", 1260 # label => "",
1261 fg => [0.6, 0.3, 0.1], 1261 fg => undef,
1262 border => 0.8, 1262 border => 0.8,
1263 style => 'single', 1263 style => 'single',
1264 %arg, 1264 %arg,
1265 ); 1265 );
1266 1266
1319 my $border = $self->border; 1319 my $border = $self->border;
1320 my ($w, $h) = ($self->{w}, $self->{h}); 1320 my ($w, $h) = ($self->{w}, $self->{h});
1321 1321
1322 $child->draw; 1322 $child->draw;
1323 1323
1324 glColor @{$self->{fg}}; 1324 glColor @{$self->{fg} || $DC::THEME{fancyframe}};
1325 glBegin GL_LINE_STRIP; 1325 glBegin GL_LINE_STRIP;
1326 glVertex $border * 1.5 , $border * 0.5 + 0.5; 1326 glVertex $border * 1.5 , $border * 0.5 + 0.5;
1327 glVertex $border * 0.5 + 0.5, $border * 0.5 + 0.5; 1327 glVertex $border * 0.5 + 0.5, $border * 0.5 + 0.5;
1328 glVertex $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; 1328 glVertex $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5;
1329 glVertex $w - $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; 1329 glVertex $w - $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5;
1344our @ISA = DC::UI::Bin::; 1344our @ISA = DC::UI::Bin::;
1345 1345
1346use DC::OpenGL; 1346use DC::OpenGL;
1347 1347
1348my $bg = 1348my $bg =
1349 new_from_file DC::Texture DC::find_rcfile "d1_bg.png", 1349 new_from_resource DC::Texture "d1_bg.png",
1350 mipmap => 1, wrap => 1; 1350 mipmap => 1, wrap => 1;
1351 1351
1352my @border = 1352my @border =
1353 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 1353 map { new_from_resource DC::Texture $_, mipmap => 1 }
1354 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1354 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
1355 1355
1356my @icon = 1356my @icon =
1357 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 1357 map { new_from_resource DC::Texture $_, mipmap => 1 }
1358 qw(x1_move.png x1_resize.png); 1358 qw(x1_move.png x1_resize.png);
1359 1359
1360sub new { 1360sub new {
1361 my ($class, %arg) = @_; 1361 my ($class, %arg) = @_;
1362 1362
1363 my $self = $class->SUPER::new ( 1363 my $self = $class->SUPER::new (
1364 bg => [1, 1, 1, 1], 1364 bg => [1, 1, 1, 1],
1365 border_bg => [1, 1, 1, 1], 1365 border_bg => [1, 1, 1, 1],
1366 border => 0.6, 1366 border => 1,
1367 can_events => 1, 1367 can_events => 1,
1368 min_w => 64, 1368 min_w => 64,
1369 min_h => 32, 1369 min_h => 32,
1370 %arg, 1370 %arg,
1371 ); 1371 );
2090 my $class = shift; 2090 my $class = shift;
2091 2091
2092 $class->SUPER::new ( 2092 $class->SUPER::new (
2093 fg => [1, 1, 1], 2093 fg => [1, 1, 1],
2094 bg => [0, 0, 0, 0.2], 2094 bg => [0, 0, 0, 0.2],
2095 outline => [0.6, 0.3, 0.1], 2095 outline => undef,
2096 active_bg => [0, 0, 1, .2], 2096 active_bg => [0, 0, 1, .2],
2097 active_fg => [1, 1, 1], 2097 active_fg => [1, 1, 1],
2098 active_outline => [1, 1, 0], 2098 active_outline => [1, 1, 0],
2099 can_hover => 1, 2099 can_hover => 1,
2100 can_focus => 1, 2100 can_focus => 1,
2273 glColor @{$self->{active_outline}}; 2273 glColor @{$self->{active_outline}};
2274 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; 2274 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5;
2275 glLineWidth 1; 2275 glLineWidth 1;
2276 2276
2277 } else { 2277 } else {
2278 glColor @{$self->{outline}}; 2278 glColor @{$self->{outline} || $DC::THEME{entry_outline}};
2279 glBegin GL_LINE_STRIP; 2279 glBegin GL_LINE_STRIP;
2280 glVertex .5, $self->{h} * .5; 2280 glVertex .5, $self->{h} * .5;
2281 glVertex .5, $self->{h} - 2.5; 2281 glVertex .5, $self->{h} - 2.5;
2282 glVertex $self->{w} - .5, $self->{h} - 2.5; 2282 glVertex $self->{w} - .5, $self->{h} - 2.5;
2283 glVertex $self->{w} - .5, $self->{h} * .5; 2283 glVertex $self->{w} - .5, $self->{h} * .5;
2405our @ISA = DC::UI::Bin::; 2405our @ISA = DC::UI::Bin::;
2406 2406
2407use DC::OpenGL; 2407use DC::OpenGL;
2408 2408
2409my @tex = 2409my @tex =
2410 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2410 map { new_from_resource DC::Texture $_, mipmap => 1 }
2411 qw(b1_button_inactive.png b1_button_active.png); 2411 qw(b1_button_inactive.png b1_button_active.png);
2412 2412
2413sub new { 2413sub new {
2414 my $class = shift; 2414 my $class = shift;
2415 2415
2454our @ISA = DC::UI::Label::; 2454our @ISA = DC::UI::Label::;
2455 2455
2456use DC::OpenGL; 2456use DC::OpenGL;
2457 2457
2458my @tex = 2458my @tex =
2459 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2459 map { new_from_resource DC::Texture $_, mipmap => 1 }
2460 qw(b1_button_inactive.png b1_button_active.png); 2460 qw(b1_button_inactive.png b1_button_active.png);
2461 2461
2462sub new { 2462sub new {
2463 my $class = shift; 2463 my $class = shift;
2464 2464
2507package DC::UI::CheckBox; 2507package DC::UI::CheckBox;
2508 2508
2509our @ISA = DC::UI::DrawBG::; 2509our @ISA = DC::UI::DrawBG::;
2510 2510
2511my @tex = 2511my @tex =
2512 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2512 map { new_from_resource DC::Texture $_, mipmap => 1 }
2513 qw(c1_checkbox_bg.png c1_checkbox_active.png); 2513 qw(c1_checkbox_bg.png c1_checkbox_active.png);
2514 2514
2515use DC::OpenGL; 2515use DC::OpenGL;
2516 2516
2517sub new { 2517sub new {
2598 2598
2599 $self->{path} || $self->{tex} 2599 $self->{path} || $self->{tex}
2600 or Carp::croak "'path' or 'tex' attributes required"; 2600 or Carp::croak "'path' or 'tex' attributes required";
2601 2601
2602 $self->{tex} ||= $texture_cache{$self->{path}} ||= 2602 $self->{tex} ||= $texture_cache{$self->{path}} ||=
2603 new_from_file DC::Texture DC::find_rcfile $self->{path}, mipmap => 1; 2603 new_from_resource DC::Texture $self->{path}, mipmap => 1;
2604 2604
2605 DC::weaken $texture_cache{$self->{path}}; 2605 DC::weaken $texture_cache{$self->{path}};
2606 2606
2607 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; 2607 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h};
2608 2608
2704 2704
2705use DC::OpenGL; 2705use DC::OpenGL;
2706 2706
2707my %tex = ( 2707my %tex = (
2708 food => [ 2708 food => [
2709 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2709 map { new_from_resource DC::Texture $_, mipmap => 1 }
2710 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ 2710 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/
2711 ], 2711 ],
2712 grace => [ 2712 grace => [
2713 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2713 map { new_from_resource DC::Texture $_, mipmap => 1 }
2714 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ 2714 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/
2715 ], 2715 ],
2716 hp => [ 2716 hp => [
2717 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2717 map { new_from_resource DC::Texture $_, mipmap => 1 }
2718 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ 2718 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/
2719 ], 2719 ],
2720 mana => [ 2720 mana => [
2721 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } 2721 map { new_from_resource DC::Texture $_, mipmap => 1 }
2722 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ 2722 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/
2723 ], 2723 ],
2724); 2724);
2725 2725
2726# eg. VGauge->new (gauge => 'food'), default gauge: food 2726# eg. VGauge->new (gauge => 'food'), default gauge: food
3023use DC::OpenGL; 3023use DC::OpenGL;
3024 3024
3025our @ISA = DC::UI::DrawBG::; 3025our @ISA = DC::UI::DrawBG::;
3026 3026
3027my @tex = 3027my @tex =
3028 map { new_from_file DC::Texture DC::find_rcfile $_ } 3028 map { new_from_resource DC::Texture $_ }
3029 qw(s1_slider.png s1_slider_bg.png); 3029 qw(s1_slider.png s1_slider_bg.png);
3030 3030
3031sub new { 3031sub new {
3032 my $class = shift; 3032 my $class = shift;
3033 3033
3620 3620
3621 $tip =~ s/^\n+//; 3621 $tip =~ s/^\n+//;
3622 $tip =~ s/\n+$//; 3622 $tip =~ s/\n+$//;
3623 3623
3624 $self->add (new DC::UI::Label 3624 $self->add (new DC::UI::Label
3625 fg => $DC::THEME{tooltip_fg},
3625 markup => $tip, 3626 markup => $tip,
3626 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 3627 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
3627 align => 0, 3628 align => 0,
3628 fontsize => 0.8, 3629 fontsize => 0.8,
3629 style => 1, # FLAG_INVERSE 3630 style => $DC::THEME{tooltip_style}, # FLAG_INVERSE
3630 ellipsise => 0, 3631 ellipsise => 0,
3631 font => ($widget->{tooltip_font} || $::FONT_PROP), 3632 font => ($widget->{tooltip_font} || $::FONT_PROP),
3632 ); 3633 );
3633} 3634}
3634 3635
3671sub _draw { 3672sub _draw {
3672 my ($self) = @_; 3673 my ($self) = @_;
3673 3674
3674 my ($w, $h) = @$self{qw(w h)}; 3675 my ($w, $h) = @$self{qw(w h)};
3675 3676
3676 glColor 1, 0.8, 0.4; 3677 glColor @{ $DC::THEME{tooltip_bg} };
3677 glRect 0, 0, $w, $h; 3678 glRect 0, 0, $w, $h;
3678 3679
3679 glColor 0, 0, 0; 3680 glColor @{ $DC::THEME{tooltip_border} };
3680 glRect_lineloop .5, .5, $w + .5, $h + .5; 3681 glRect_lineloop .5, .5, $w + .5, $h + .5;
3681 3682
3682 glTranslate 2, 2; 3683 glTranslate 2, 2;
3683 3684
3684 $self->SUPER::_draw; 3685 $self->SUPER::_draw;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines