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.9 by elmex, Fri Apr 7 20:09:52 2006 UTC vs.
Revision 1.10 by root, Fri Apr 7 20:34:44 2006 UTC

11sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS } 11sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS }
12sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS } 12sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS }
13 13
14sub new { 14sub new {
15 my $class = shift; 15 my $class = shift;
16 my $self = { @_ }; 16
17 bless $self, $class; 17 bless { @_ }, $class
18 return $self;
19} 18}
20 19
21sub activate { 20sub activate {
22 $ACTIVE_WIDGETS{$_[0]} = $_[0]; 21 $ACTIVE_WIDGETS{$_[0]} = $_[0];
23} 22}
57 56
58sub bbox { 57sub bbox {
59 my ($widget) = @_; 58 my ($widget) = @_;
60} 59}
61 60
61package Crossfire::Client::Widget::Label;
62
63use SDL::OpenGL;
64
65sub new {
66 my ($class, $ttf, $text) = @_;
67
68 my $self = $class->SUPER::new;
69
70 $self->{texture} = new_from_ttf Crossfire::Client::Texture $ttf, $text;
71
72 $self
73}
74
75sub draw {
76 my ($self) = @_;
77
78 my $tex = $self->{texture};
79
80 glEnable GL_TEXTURE_2D;
81 glBindTexture GL_TEXTURE_2D, $tex->{name};
82
83 glBegin GL_QUADS;
84 glTexCoord 0, 0; glVertex 0 , 0;
85 glTexCoord 0, 1; glVertex 0 , $tex->{height};
86 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height};
87 glTexCoord 1, 0; glVertex $tex->{width}, 0;
88 glEnd;
89
90 glDisable GL_TEXTURE_2D;
91}
92
62package Crossfire::Client::Widget::TextView; 93package Crossfire::Client::Widget::TextView;
63 94
64use strict; 95use strict;
96
65our @ISA = qw/Crossfire::Client::Widget/; 97our @ISA = qw/Crossfire::Client::Widget/;
66 98
67use SDL::OpenGL; 99use SDL::OpenGL;
68use SDL::OpenGL::Constants; 100use SDL::OpenGL::Constants;
69 101
112 my $tex = $::CONN->{face}[$num]{texture} || next; 144 my $tex = $::CONN->{face}[$num]{texture} || next;
113 145
114 glBindTexture GL_TEXTURE_2D, $tex->{name}; 146 glBindTexture GL_TEXTURE_2D, $tex->{name};
115 147
116 glBegin GL_QUADS; 148 glBegin GL_QUADS;
117 glTexCoord 0, 0; glVertex $x, $y; 149 glTexCoord 0, 0; glVertex $x * 32 , $y * 32;
118 glTexCoord 0, 1; glVertex $x, $y + 1; 150 glTexCoord 0, 1; glVertex $x * 32 , $y * 32 + 32;
119 glTexCoord 1, 1; glVertex $x + 1, $y + 1; 151 glTexCoord 1, 1; glVertex $x * 32 + 32, $y * 32 + 32;
120 glTexCoord 1, 0; glVertex $x + 1, $y; 152 glTexCoord 1, 0; glVertex $x * 32 + 32, $y * 32;
121 glEnd; 153 glEnd;
122 } 154 }
123 } 155 }
124 } 156 }
125 157

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines