… | |
… | |
272 | |
272 | |
273 | return unless $self->{visible}; |
273 | return unless $self->{visible}; |
274 | |
274 | |
275 | $_->set_invisible for $self->children; |
275 | $_->set_invisible for $self->children; |
276 | |
276 | |
|
|
277 | delete $self->{visible}; |
277 | delete $self->{root}; |
278 | delete $self->{root}; |
278 | delete $self->{visible}; |
|
|
279 | |
279 | |
280 | undef $GRAB if $GRAB == $self; |
280 | undef $GRAB if $GRAB == $self; |
281 | undef $HOVER if $HOVER == $self; |
281 | undef $HOVER if $HOVER == $self; |
282 | |
282 | |
283 | $CFClient::UI::TOOLTIP_WATCHER->cb->() |
283 | $CFClient::UI::TOOLTIP_WATCHER->cb->() |
… | |
… | |
593 | |
593 | |
594 | sub DESTROY { |
594 | sub DESTROY { |
595 | my ($self) = @_; |
595 | my ($self) = @_; |
596 | |
596 | |
597 | delete $WIDGET{$self+0}; |
597 | delete $WIDGET{$self+0}; |
598 | #$self->deactivate; |
598 | |
|
|
599 | eval { $self->destroy }; |
|
|
600 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
599 | } |
601 | } |
600 | |
602 | |
601 | ############################################################################# |
603 | ############################################################################# |
602 | |
604 | |
603 | package CFClient::UI::DrawBG; |
605 | package CFClient::UI::DrawBG; |
… | |
… | |
768 | } |
770 | } |
769 | |
771 | |
770 | sub add { |
772 | sub add { |
771 | my ($self, $child) = @_; |
773 | my ($self, $child) = @_; |
772 | |
774 | |
773 | $self->{children} = []; |
775 | $self->SUPER::remove ($_) for @{ $self->{children} }; |
774 | |
|
|
775 | $self->SUPER::add ($child); |
776 | $self->SUPER::add ($child); |
776 | } |
777 | } |
777 | |
778 | |
778 | sub remove { |
779 | sub remove { |
779 | my ($self, $widget) = @_; |
780 | my ($self, $widget) = @_; |
… | |
… | |
1071 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1072 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1072 | qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
1073 | qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
1073 | |
1074 | |
1074 | sub new { |
1075 | sub new { |
1075 | my ($class, %arg) = @_; |
1076 | my ($class, %arg) = @_; |
1076 | |
|
|
1077 | my $title = delete $arg{title}; |
|
|
1078 | |
1077 | |
1079 | my $self = $class->SUPER::new ( |
1078 | my $self = $class->SUPER::new ( |
1080 | bg => [1, 1, 1, 1], |
1079 | bg => [1, 1, 1, 1], |
1081 | border_bg => [1, 1, 1, 1], |
1080 | border_bg => [1, 1, 1, 1], |
1082 | border => 0.6, |
1081 | border => 0.6, |
… | |
… | |
1084 | min_w => 16, |
1083 | min_w => 16, |
1085 | min_h => 16, |
1084 | min_h => 16, |
1086 | %arg, |
1085 | %arg, |
1087 | ); |
1086 | ); |
1088 | |
1087 | |
1089 | $self->{title} = new CFClient::UI::Label |
1088 | $self->{title_widget} = new CFClient::UI::Label |
1090 | align => 0, |
1089 | align => 0, |
1091 | valign => 1, |
1090 | valign => 1, |
1092 | text => $title, |
1091 | text => $self->{title}, |
1093 | fontsize => $self->{border} |
1092 | fontsize => $self->{border}, |
1094 | if defined $title; |
1093 | if exists $self->{title}; |
1095 | |
1094 | |
1096 | $self |
1095 | $self |
1097 | } |
1096 | } |
1098 | |
1097 | |
1099 | sub add { |
1098 | sub add { |
1100 | my ($self, @widgets) = @_; |
1099 | my ($self, @widgets) = @_; |
1101 | |
1100 | |
1102 | $self->SUPER::add (@widgets); |
1101 | $self->SUPER::add (@widgets); |
1103 | $self->CFClient::UI::Container::add ($self->{title}) if $self->{title}; |
1102 | $self->CFClient::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; |
1104 | } |
1103 | } |
1105 | |
1104 | |
1106 | sub border { |
1105 | sub border { |
1107 | int $_[0]{border} * $::FONTSIZE |
1106 | int $_[0]{border} * $::FONTSIZE |
1108 | } |
1107 | } |
1109 | |
1108 | |
1110 | sub size_request { |
1109 | sub size_request { |
1111 | my ($self) = @_; |
1110 | my ($self) = @_; |
1112 | |
1111 | |
1113 | $self->{title}->size_request |
1112 | $self->{title_widget}->size_request |
1114 | if $self->{title}; |
1113 | if $self->{title_widget}; |
1115 | |
1114 | |
1116 | my ($w, $h) = $self->SUPER::size_request; |
1115 | my ($w, $h) = $self->SUPER::size_request; |
1117 | |
1116 | |
1118 | ( |
1117 | ( |
1119 | $w + $self->border * 2, |
1118 | $w + $self->border * 2, |
… | |
… | |
1122 | } |
1121 | } |
1123 | |
1122 | |
1124 | sub size_allocate { |
1123 | sub size_allocate { |
1125 | my ($self, $w, $h) = @_; |
1124 | my ($self, $w, $h) = @_; |
1126 | |
1125 | |
1127 | if ($self->{title}) { |
1126 | if ($self->{title_widget}) { |
1128 | $self->{title}{w} = $w; |
1127 | $self->{title_widget}{w} = $w; |
1129 | $self->{title}{h} = $h; |
1128 | $self->{title_widget}{h} = $h; |
1130 | $self->{title}->size_allocate ($w, $h); |
1129 | $self->{title_widget}->size_allocate ($w, $h); |
1131 | } |
1130 | } |
1132 | |
1131 | |
1133 | my $border = $self->border; |
1132 | my $border = $self->border; |
1134 | |
1133 | |
1135 | $h -= List::Util::max 0, $border * 2; |
1134 | $h -= List::Util::max 0, $border * 2; |
… | |
… | |
1233 | |
1232 | |
1234 | glDisable GL_TEXTURE_2D; |
1233 | glDisable GL_TEXTURE_2D; |
1235 | |
1234 | |
1236 | $child->draw; |
1235 | $child->draw; |
1237 | |
1236 | |
1238 | if ($self->{title}) { |
1237 | if ($self->{title_widget}) { |
1239 | glTranslate 0, $border - $self->{h}; |
1238 | glTranslate 0, $border - $self->{h}; |
1240 | $self->{title}->_draw; |
1239 | $self->{title_widget}->_draw; |
1241 | } |
1240 | } |
1242 | } |
1241 | } |
1243 | |
1242 | |
1244 | ############################################################################# |
1243 | ############################################################################# |
1245 | |
1244 | |
… | |
… | |
1269 | |
1268 | |
1270 | $child->set_parent ($self); |
1269 | $child->set_parent ($self); |
1271 | $self->{children}[$y][$x] = $child; |
1270 | $self->{children}[$y][$x] = $child; |
1272 | |
1271 | |
1273 | $self->realloc; |
1272 | $self->realloc; |
|
|
1273 | } |
|
|
1274 | |
|
|
1275 | sub remove { |
|
|
1276 | my ($self, $child) = @_; |
|
|
1277 | |
|
|
1278 | # TODO: not yet implemented |
1274 | } |
1279 | } |
1275 | |
1280 | |
1276 | # TODO: move to container class maybe? send children a signal on removal? |
1281 | # TODO: move to container class maybe? send children a signal on removal? |
1277 | sub clear { |
1282 | sub clear { |
1278 | my ($self) = @_; |
1283 | my ($self) = @_; |
… | |
… | |
2897 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2902 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2898 | glDisable GL_TEXTURE_2D; |
2903 | glDisable GL_TEXTURE_2D; |
2899 | } |
2904 | } |
2900 | } |
2905 | } |
2901 | |
2906 | |
2902 | sub DESTROY { |
2907 | sub destroy { |
2903 | my ($self) = @_; |
2908 | my ($self) = @_; |
2904 | |
2909 | |
2905 | $self->{timer}->cancel |
2910 | $self->{timer}->cancel |
2906 | if $self->{timer}; |
2911 | if $self->{timer}; |
2907 | |
2912 | |
2908 | $self->SUPER::DESTROY; |
2913 | $self->SUPER::destroy; |
2909 | } |
2914 | } |
2910 | |
2915 | |
2911 | ############################################################################# |
2916 | ############################################################################# |
2912 | |
2917 | |
2913 | package CFClient::UI::Buttonbar; |
2918 | package CFClient::UI::Buttonbar; |
… | |
… | |
3292 | |
3297 | |
3293 | $self->reorder; |
3298 | $self->reorder; |
3294 | $self->SUPER::reconfigure; |
3299 | $self->SUPER::reconfigure; |
3295 | } |
3300 | } |
3296 | |
3301 | |
3297 | sub DESTROY { |
3302 | sub destroy { |
3298 | my ($self) = @_; |
3303 | my ($self) = @_; |
3299 | |
3304 | |
3300 | $self->{timer}->cancel; |
3305 | $self->{timer}->cancel; |
3301 | |
3306 | |
3302 | $self->SUPER::DESTROY; |
3307 | $self->SUPER::destroy; |
3303 | } |
3308 | } |
3304 | |
3309 | |
3305 | ############################################################################# |
3310 | ############################################################################# |
3306 | |
3311 | |
3307 | package CFClient::UI::Inventory; |
3312 | package CFClient::UI::Inventory; |
… | |
… | |
3573 | sub rebuild_spell_list { |
3578 | sub rebuild_spell_list { |
3574 | my ($self) = @_; |
3579 | my ($self) = @_; |
3575 | |
3580 | |
3576 | $CFClient::UI::ROOT->on_refresh ($self => sub { |
3581 | $CFClient::UI::ROOT->on_refresh ($self => sub { |
3577 | $self->clear; |
3582 | $self->clear; |
|
|
3583 | |
|
|
3584 | return unless $::CONN; |
3578 | |
3585 | |
3579 | $self->add (1, 0, new CFClient::UI::Label text => "Spell Name", @TOOLTIP_NAME); |
3586 | $self->add (1, 0, new CFClient::UI::Label text => "Spell Name", @TOOLTIP_NAME); |
3580 | $self->add (2, 0, new CFClient::UI::Label text => "Skill", @TOOLTIP_SKILL); |
3587 | $self->add (2, 0, new CFClient::UI::Label text => "Skill", @TOOLTIP_SKILL); |
3581 | $self->add (3, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); |
3588 | $self->add (3, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); |
3582 | $self->add (4, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); |
3589 | $self->add (4, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); |