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.347 by root, Mon Aug 14 03:41:28 2006 UTC vs.
Revision 1.356 by root, Wed Dec 6 00:15:12 2006 UTC

514); 514);
515 515
516sub emit { 516sub emit {
517 my ($self, $signal, @args) = @_; 517 my ($self, $signal, @args) = @_;
518 518
519 # I do not really like this solution, but I dislike duplication 519 # I do not really like this solution, but I do not like duplication
520 # and needlessly verbose code, too. 520 # and needlessly verbose code, either.
521 my @append 521 my @append
522 = $has_coords{$signal} 522 = $has_coords{$signal}
523 ? $args[0]->xy ($self) 523 ? $args[0]->xy ($self)
524 : (); 524 : ();
525 525
898 glClear GL_COLOR_BUFFER_BIT; 898 glClear GL_COLOR_BUFFER_BIT;
899 899
900 { 900 {
901 package CFPlus::UI::Base; 901 package CFPlus::UI::Base;
902 902
903 ($draw_x, $draw_y, $draw_w, $draw_h) = 903 local ($draw_x, $draw_y, $draw_w, $draw_h) =
904 (0, 0, $self->{w}, $self->{h}); 904 (0, 0, $self->{w}, $self->{h});
905
906 $self->_render;
905 } 907 }
906
907 $self->_render;
908 }; 908 };
909} 909}
910 910
911sub _draw { 911sub _draw {
912 my ($self) = @_; 912 my ($self) = @_;
1966 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1966 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1967 } elsif ($sym == CFPlus::SDLK_HOME) { 1967 } elsif ($sym == CFPlus::SDLK_HOME) {
1968 $self->{cursor} = 0; 1968 $self->{cursor} = 0;
1969 } elsif ($sym == CFPlus::SDLK_END) { 1969 } elsif ($sym == CFPlus::SDLK_END) {
1970 $self->{cursor} = length $text; 1970 $self->{cursor} = length $text;
1971 } elsif ($uni == 21) { # ctrl-u
1972 $text = "";
1973 $self->{cursor} = 0;
1971 } elsif ($uni == 27) { 1974 } elsif ($uni == 27) {
1972 $self->emit ('escape'); 1975 $self->emit ('escape');
1973 } elsif ($uni) { 1976 } elsif ($uni) {
1974 substr $text, $self->{cursor}++, 0, chr $uni; 1977 substr $text, $self->{cursor}++, 0, chr $uni;
1975 } else { 1978 } else {
2956 2959
2957 $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub { 2960 $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub {
2958 glClearColor 0, 0, 0, 0; 2961 glClearColor 0, 0, 0, 0;
2959 glClear GL_COLOR_BUFFER_BIT; 2962 glClear GL_COLOR_BUFFER_BIT;
2960 2963
2964 package CFPlus::UI::Base;
2965 local ($draw_x, $draw_y, $draw_w, $draw_h) =
2966 (0, 0, $self->{w}, $self->{h});
2967
2961 my $top = int $self->{children}[1]{range}[0]; 2968 my $top = int $self->{children}[1]{range}[0];
2962 2969
2963 my $paridx = 0; 2970 my $paridx = 0;
2964 my $top_paragraph; 2971 my $top_paragraph;
2965 my $top = int $self->{children}[1]{range}[0]; 2972 my $top = int $self->{children}[1]{range}[0];
3281 3288
3282package CFPlus::UI::Buttonbar; 3289package CFPlus::UI::Buttonbar;
3283 3290
3284our @ISA = CFPlus::UI::HBox::; 3291our @ISA = CFPlus::UI::HBox::;
3285 3292
3286# TODO: should actualyl wrap buttons and other goodies. 3293# TODO: should actually wrap buttons and other goodies.
3287 3294
3288############################################################################# 3295#############################################################################
3289 3296
3290package CFPlus::UI::Menu; 3297package CFPlus::UI::Menu;
3291 3298
3820 if ($ev->{button} == 1) { 3827 if ($ev->{button} == 1) {
3821 $::CONN->user_send ("cast $spell->{name}"); 3828 $::CONN->user_send ("cast $spell->{name}");
3822 } elsif ($ev->{button} == 2) { 3829 } elsif ($ev->{button} == 2) {
3823 $::CONN->user_send ("invoke $spell->{name}"); 3830 $::CONN->user_send ("invoke $spell->{name}");
3824 } elsif ($ev->{button} == 3) { 3831 } elsif ($ev->{button} == 3) {
3832 my $shortname = CFPlus::shorten $spell->{name}, 14;
3825 (new CFPlus::UI::Menu 3833 (new CFPlus::UI::Menu
3826 items => [ 3834 items => [
3827 ["bind <i>cast $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }], 3835 ["bind <i>cast $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
3828 ["bind <i>invoke $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }], 3836 ["bind <i>invoke $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
3829 ], 3837 ],
3830 )->popup ($ev); 3838 )->popup ($ev);
3831 } else { 3839 } else {
3832 return 0; 3840 return 0;
3833 } 3841 }
3834 3842
3835 1 3843 1
3836 }; 3844 };
3837 3845
3838 my $tooltip = "$spell->{message}$TOOLTIP_ALL"; 3846 my $tooltip = (CFPlus::asxml $spell->{message}) . $TOOLTIP_ALL;
3839 3847
3840 #TODO: add path info to tooltip 3848 #TODO: add path info to tooltip
3841 #$self->add (6, $row, new CFPlus::UI::Label text => $spell->{path}); 3849 #$self->add (6, $row, new CFPlus::UI::Label text => $spell->{path});
3842 3850
3843 $self->add (0, $row, new CFPlus::UI::Face 3851 $self->add (0, $row, new CFPlus::UI::Face
4121 glLoadIdentity; 4129 glLoadIdentity;
4122 4130
4123 { 4131 {
4124 package CFPlus::UI::Base; 4132 package CFPlus::UI::Base;
4125 4133
4126 ($draw_x, $draw_y, $draw_w, $draw_h) = 4134 local ($draw_x, $draw_y, $draw_w, $draw_h) =
4127 (0, 0, $self->{w}, $self->{h}); 4135 (0, 0, $self->{w}, $self->{h});
4128 }
4129 4136
4130 $self->_draw; 4137 $self->_draw;
4138 }
4131} 4139}
4132 4140
4133############################################################################# 4141#############################################################################
4134 4142
4135package CFPlus::UI; 4143package CFPlus::UI;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines