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

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.4 by root, Wed Apr 19 23:37:49 2006 UTC vs.
Revision 1.6 by root, Thu Apr 20 08:11:57 2006 UTC

37sub button_down { 37sub button_down {
38 my ($self, $ev, $x, $y) = @_; 38 my ($self, $ev, $x, $y) = @_;
39 39
40 $self->focus_in; 40 $self->focus_in;
41 41
42 if ($ev->button == 2) { 42 if ($ev->{button} == 2) {
43 my ($ox, $oy) = ($ev->button_x, $ev->button_y); 43 my ($ox, $oy) = ($ev->{x}, $ev->{y});
44 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); 44 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y});
45 45
46 $self->{motion} = sub { 46 $self->{motion} = sub {
47 my ($ev, $x, $y) = @_; 47 my ($ev, $x, $y) = @_;
48 48
49 ($x, $y) = ($ev->motion_x, $ev->motion_y); 49 ($x, $y) = ($ev->{x}, $ev->{y});
50 50
51 $::CFG->{map_shift_x} = $bw + $x - $ox; 51 $::CFG->{map_shift_x} = $bw + $x - $ox;
52 $::CFG->{map_shift_y} = $bh + $y - $oy; 52 $::CFG->{map_shift_y} = $bh + $y - $oy;
53 53
54 $self->update; 54 $self->update;
137 } 137 }
138 138
139 # HACK BEGIN 139 # HACK BEGIN
140 { 140 {
141 glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove 141 glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove
142
143 glTranslate 0, 30;
142 my ($w, $h) = (250, 250); 144 my ($w, $h) = (250, 250);
145
146 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
143 147
144 glEnable GL_BLEND; 148 glEnable GL_BLEND;
145 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 149 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
146 glEnable GL_TEXTURE_2D; 150 glEnable GL_TEXTURE_2D;
147 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 151 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
148 152
149 $self->{mapmap_texture} = 153 $self->{mapmap_texture} =
150 new CFClient::Texture 154 new CFClient::Texture
151 w => $w, 155 w => $w,
152 h => $h, 156 h => $h,
153 data => $::MAP->mapmap ($w, $h), 157 data => $::MAP->mapmap (- $w * 0.5, - $h * 0.5, $w, $h),
154 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; 158 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
155 159
156 $self->{mapmap_texture}->draw_quad (100, 100); 160 $self->{mapmap_texture}->draw_quad (0, 0);
157 161
158 glDisable GL_TEXTURE_2D; 162 glDisable GL_TEXTURE_2D;
163
164 glTranslate 0.375, 0.375;
165
166 glColor 1, 1, 0, 1;
167 glBegin GL_LINE_LOOP;
168 glVertex $w * 0.5 - $sx , $h * 0.5 - $sy ;
169 glVertex $w * 0.5 - $sx , $h * 0.5 - $sy + $sh;
170 glVertex $w * 0.5 - $sx + $sw, $h * 0.5 - $sy + $sh;
171 glVertex $w * 0.5 - $sx + $sw, $h * 0.5 - $sy ;
172 glEnd;
173
159 glDisable GL_BLEND; 174 glDisable GL_BLEND;
160 } 175 }
161 # HACK END 176 # HACK END
162 } 177 }
163 178
199); 214);
200 215
201sub key_down { 216sub key_down {
202 my ($self, $ev) = @_; 217 my ($self, $ev) = @_;
203 218
204 my $mod = $ev->key_mod; 219 my $mod = $ev->{mod};
205 my $sym = $ev->key_sym; 220 my $sym = $ev->{sym};
206 221
207 if ($sym == CFClient::SDLK_KP5) { 222 if ($sym == CFClient::SDLK_KP5) {
208 $::CONN->user_send ("stay fire"); 223 $::CONN->user_send ("stay fire");
209 } elsif ($sym == ord "a") { 224 } elsif ($sym == ord "a") {
210 $::CONN->user_send ("apply"); 225 $::CONN->user_send ("apply");
226} 241}
227 242
228sub key_up { 243sub key_up {
229 my ($self, $ev) = @_; 244 my ($self, $ev) = @_;
230 245
231 my $mod = $ev->key_mod; 246 my $mod = $ev->{mod};
232 my $sym = $ev->key_sym; 247 my $sym = $ev->{sym};
233 248
234 if (!($mod & CFClient::KMOD_SHIFT) && delete $self->{shft}) { 249 if (!($mod & CFClient::KMOD_SHIFT) && delete $self->{shft}) {
235 $::CONN->user_send ("fire_stop"); 250 $::CONN->user_send ("fire_stop");
236 } 251 }
237 if (!($mod & CFClient::KMOD_CTRL ) && delete $self->{ctrl}) { 252 if (!($mod & CFClient::KMOD_CTRL ) && delete $self->{ctrl}) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines