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.27 by root, Wed May 17 20:21:27 2006 UTC vs.
Revision 1.34 by root, Tue May 23 21:14:41 2006 UTC

115 0.05, 0.13, 0.05, 115 0.05, 0.13, 0.05,
116 ); 116 );
117 glEnable GL_CONVOLUTION_2D; 117 glEnable GL_CONVOLUTION_2D;
118 } 118 }
119 119
120 # try to re-use the texture name: TODO improve texture class instead
121 my $prev_name = ((delete $self->{fow_texture}) || {})->{name};
122
120 $self->{fow_texture} = new CFClient::Texture 123 $self->{fow_texture} = new CFClient::Texture
121 w => $w, 124 w => $w,
122 h => $h, 125 h => $h,
123 data => $data, 126 data => $data,
127 name => $prev_name, # a bit hackish
124 internalformat => GL_ALPHA, 128 internalformat => GL_ALPHA,
125 format => GL_ALPHA; 129 format => GL_ALPHA;
126 130
127 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; 131 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
128 132
129 glEnable GL_BLEND;
130 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
131 glEnable GL_TEXTURE_2D; 133 glEnable GL_TEXTURE_2D;
132 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 134 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
133 135
134 glColor +($::CFG->{fow_intensity}) x 3, 0.8; 136 glColor +($::CFG->{fow_intensity}) x 3, 0.8;
135 $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32); 137 $self->{fow_texture}->draw_quad_alpha (0, 0, $w * 32, $h * 32);
136 138
137 glDisable GL_TEXTURE_2D; 139 glDisable GL_TEXTURE_2D;
138 glDisable GL_BLEND;
139 } 140 }
140 141
141 glPopMatrix; 142 glPopMatrix;
142 } 143 }
143 144
146 147
147 glPushMatrix; 148 glPushMatrix;
148 glCallList $self->{list}; 149 glCallList $self->{list};
149 glPopMatrix; 150 glPopMatrix;
150 151
152 # TNT2 emulates logops in software (or worse :)
151 if ($CFClient::UI::FOCUS != $self) { 153 if ($CFClient::UI::FOCUS == $self) {
152 glColor 64/255, 64/255, 64/255; 154 (delete $self->{out_of_focus})->destroy
153 glLogicOp GL_AND; 155 if $self->{out_of_focus};
154 glEnable GL_COLOR_LOGIC_OP; 156 } else {
157 glColor 0.4, 0.2, 0.2, 0.6;
158 glEnable GL_BLEND;
159 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
155 glBegin GL_QUADS; 160 glBegin GL_QUADS;
156 glVertex 0, 0; 161 glVertex 0, 0;
157 glVertex 0, $::HEIGHT; 162 glVertex 0, $::HEIGHT;
158 glVertex $::WIDTH, $::HEIGHT; 163 glVertex $::WIDTH, $::HEIGHT;
159 glVertex $::WIDTH, 0; 164 glVertex $::WIDTH, 0;
160 glEnd; 165 glEnd;
161 glDisable GL_COLOR_LOGIC_OP; 166 glDisable GL_BLEND;
167
168 $self->{out_of_focus} ||= do {
169 my $label = new CFClient::UI::Label
170 x => 0,
171 y => 0,
172 z => 1,
173 ellipsise => 0,
174 text => "map out of focus (click map to play)";
175
176 $label->show;
177 $label->update;
178
179 $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub {
180 $label->move (
181 ($::WIDTH - $label->{w}) * 0.5,
182 ($::HEIGHT - $label->{h}) * 0.5,
183 );
184 });
185
186 $label
187 };
162 } 188 }
163} 189}
164 190
165my %DIR = ( 191my %DIR = (
166 CFClient::SDLK_KP8, [1, "north"], 192 CFClient::SDLK_KP8, [1, "north"],
189 215
190 if ($sym == CFClient::SDLK_KP5) { 216 if ($sym == CFClient::SDLK_KP5) {
191 $::CONN->user_send ("stay fire"); 217 $::CONN->user_send ("stay fire");
192 } elsif ($uni == ord ",") { 218 } elsif ($uni == ord ",") {
193 $::CONN->user_send ("take"); 219 $::CONN->user_send ("take");
194 } elsif ($uni == ord "\t") { 220 } elsif ($uni == ord "\t" or $uni == ord " ") {
195 $::CONN->user_send ("apply"); 221 $::CONN->user_send ("apply");
196 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { 222 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") {
197 $::CONN->user_send ("rotateshoottype +"); 223 $::CONN->user_send ("rotateshoottype +");
198 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { 224 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") {
199 $::CONN->user_send ("rotateshoottype -"); 225 $::CONN->user_send ("rotateshoottype -");
454 480
455 @match = map $self->{command}{$_->[0]}, 481 @match = map $self->{command}{$_->[0]},
456 sort { 482 sort {
457 $a->[1] <=> $b->[1] 483 $a->[1] <=> $b->[1]
458 or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] 484 or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4]
485 or (length $a->[0]) <=> (length $b->[0])
459 } @match; 486 } @match;
460 487
461 $self->{last_search} = $cmd; 488 $self->{last_search} = $cmd;
462 $self->{last_match} = \@match; 489 $self->{last_match} = \@match;
463 490

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines