… | |
… | |
11 | sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS } |
11 | sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS } |
12 | sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS } |
12 | sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS } |
13 | |
13 | |
14 | sub new { |
14 | sub 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 | |
21 | sub activate { |
20 | sub activate { |
22 | $ACTIVE_WIDGETS{$_[0]} = $_[0]; |
21 | $ACTIVE_WIDGETS{$_[0]} = $_[0]; |
23 | } |
22 | } |
… | |
… | |
57 | |
56 | |
58 | sub bbox { |
57 | sub bbox { |
59 | my ($widget) = @_; |
58 | my ($widget) = @_; |
60 | } |
59 | } |
61 | |
60 | |
|
|
61 | package Crossfire::Client::Widget::Label; |
|
|
62 | |
|
|
63 | use SDL::OpenGL; |
|
|
64 | |
|
|
65 | sub 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 | |
|
|
75 | sub 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 | |
62 | package Crossfire::Client::Widget::TextView; |
93 | package Crossfire::Client::Widget::TextView; |
63 | |
94 | |
64 | use strict; |
95 | use strict; |
|
|
96 | |
65 | our @ISA = qw/Crossfire::Client::Widget/; |
97 | our @ISA = qw/Crossfire::Client::Widget/; |
66 | |
98 | |
67 | use SDL::OpenGL; |
99 | use SDL::OpenGL; |
68 | use SDL::OpenGL::Constants; |
100 | use 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 | |