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.84 by root, Sun Oct 1 18:17:38 2006 UTC vs.
Revision 1.102 by root, Sun Apr 1 15:08:14 2007 UTC

6use List::Util qw(min max); 6use List::Util qw(min max);
7 7
8use CFPlus; 8use CFPlus;
9use CFPlus::OpenGL; 9use CFPlus::OpenGL;
10use CFPlus::UI; 10use CFPlus::UI;
11use CFPlus::Macro;
11 12
12our @ISA = CFPlus::UI::Base::; 13our @ISA = CFPlus::UI::Base::;
14
15sub ::T() { 64 }
13 16
14my $magicmap_tex = 17my $magicmap_tex =
15 new_from_file CFPlus::Texture CFPlus::find_rcfile "magicmap.png", 18 new_from_file CFPlus::Texture CFPlus::find_rcfile "magicmap.png",
16 mipmap => 1, wrap => 0, internalformat => GL_ALPHA; 19 mipmap => 1, wrap => 0, internalformat => GL_ALPHA;
17 20
59 62
60 $self->{completer}->hide 63 $self->{completer}->hide
61 if $self->{completer}; 64 if $self->{completer};
62} 65}
63 66
64sub test_server_login { 67sub server_login {
65 return unless 68 my ($server) = @_;
66 $::CONN && length $::CONN->{test_server};
67 69
68 my $server = $::CONN->{test_server};
69 ::stop_game (); 70 ::stop_game ();
70 local $::PROFILE->{host} = $server; 71 local $::PROFILE->{host} = $server;
71 ::start_game (); 72 ::start_game ();
72} 73}
73 74
74sub editor_invoke { 75sub editor_invoke {
75 return unless $::CONN; 76 my $editsup = $::CONN && $::CONN->{editor_support}
77 or return;
76 78
77 # putting the password into the env is somewhat tasteless 79 CFPlus::background {
78 local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user}; 80 print "preparing editor startup...\n";
79 local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password};
80 local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload};
81 local $ENV{CROSSFIRE_MAPDIR} = $::CONN->{cvs_root};
82 81
83 CFPlus::set_proxy; 82 my $server = $editsup->{gameserver} || "default";
83 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
84 84
85 my $map = "map:$::CONN->{map_info}[0]"; 85 local $ENV{CROSSFIRE_MAPDIR} = my $mapdir = "$Crossfire::VARDIR/map.$server"; mkdir $mapdir;
86 local $ENV{CROSSFIRE_LIBDIR} = my $libdir = "$Crossfire::VARDIR/lib.$server"; mkdir $libdir;
86 87
87 if (fork == 0) { 88 print "map directory is $mapdir\n";
88 $SIG{__DIE__} = sub { 89 print "lib directory is $libdir\n";
89 warn "@_"; 90
90 CFPlus::_exit 99; 91 my $ua = CFPlus::lwp_useragent;
92
93 for my $file (qw(archetypes crossfire.0)) {
94 my $url = "$editsup->{lib_root}$file";
95 print "mirroring $url...\n";
96 CFPlus::lwp_check $ua->mirror ($url, "$libdir/$file");
97 printf "%s size %d octets\n", $file, -s "$libdir/$file";
91 }; 98 }
92 99
93 # TODO: move into editor 100 if (1) { # upload a map
94 require LWP::UserAgent; 101 my $mapname = $::CONN->{map_info}[0];
95 102
96 my $ua = LWP::UserAgent->new ( 103 my $mappath = "$mapdir/$mapname";
97 agent => "cfplus $CFPlus::VERSION",
98 keep_alive => 1,
99 env_proxy => 1,
100 );
101 104
102 if ($map =~ /^map:(.*)/) { 105 -e $mappath and die "$mappath already exists\n";
103 my $mapname = $1; 106
107 print "getting map revision for $mapname...\n";
108
104 # try to get the most recent head revision, what a hack 109 # try to get the most recent head revision, what a hack,
110 # this should have been returned while downloading *sigh*
105 my $log = $ua->get ("$ENV{CROSSFIRE_MAPDIR}/$mapname?view=log&logsort=rev")->decoded_content; 111 my $log = (CFPlus::lwp_check $ua->get ("$editsup->{cvs_root}/$mapname?view=log&logsort=rev"))->decoded_content;
106 112
107 if ($log =~ /\?rev=(\d+\.\d+)"/) { 113 if ($log =~ /\?rev=(\d+\.\d+)"/) {
108 my $rev = $1; 114 my $rev = $1;
109 my $map = $ua->get ("$ENV{CROSSFIRE_MAPDIR}/$mapname?rev=$rev")->decoded_content; 115
110 warn "revision is $rev " .(length $map)."\n";#d# 116 print "downloading revision $rev...\n";
117
118 my $map = (CFPlus::lwp_check $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content;
119
120 my $meta = {
121 %$editsup,
122 path => $mapname,
123 revision => $rev,
124 cf_login => $::PROFILE->{user},
125 };
126
127 require File::Basename;
128 require File::Path;
129
130 File::Path::mkpath (File::Basename::dirname ($mappath));
131 open my $fh, ">:raw:perlio", "$mappath.meta"
132 or die "$mappath.meta: $!\n";
133 print $fh CFPlus::to_json $meta;
134 close $fh;
135 open my $fh, ">:raw:perlio:utf8", $mappath
136 or die "$mappath: $!\n";
137 print $fh $map;
138 close $fh;
139
140 print "saved as $mappath\n";
141
142 print "invoking editor...\n";
143 exec "/root/s2/gce $mappath";#d#
111 144
112 # now upload it 145 # now upload it
113 my $comment = "some comment";
114
115 require HTTP::Request::Common; 146# require HTTP::Request::Common;
116 147#
117 my $res = $ua->post ( 148# my $res = $ua->post (
118 $ENV{CFPLUS_UPLOAD}, 149# $ENV{CFPLUS_UPLOAD},
119 Content_Type => 'multipart/form-data', 150# Content_Type => 'multipart/form-data',
120 Content => [ 151# Content => [
121 path => $mapname, 152# path => $mapname,
122 mapdir => $ENV{CROSSFIRE_MAPDIR}, 153# mapdir => $ENV{CROSSFIRE_MAPDIR},
123 map => $map, 154# map => $map,
124 revision => $rev, 155# revision => $rev,
125 cf_login => $ENV{CFPLUS_LOGIN}, 156# cf_login => $ENV{CFPLUS_LOGIN},
126 cf_password => $ENV{CFPLUS_PASSWORD}, 157# cf_password => $ENV{CFPLUS_PASSWORD},
127 comment => "", 158# comment => "",
128 ] 159# ]
129 ); 160# );
130 161#
131 if ($res->is_error) { 162# if ($res->is_error) {
132 # fatal condition 163# # fatal condition
133 warn $res->status_line; 164# warn $res->status_line;
134 } else { 165# } else {
135 # script replies are marked as {{..}} 166# # script replies are marked as {{..}}
136 my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g; 167# my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g;
137 warn map "$_\n", @msgs; 168# warn map "$_\n", @msgs;
138 } 169# }
139 } else { 170 } else {
140 # error, could not detect revision 171 die "viewvc parse error, unable to detect revision\n";
141 } 172 }
142 } 173 }
143
144 CFPlus::_exit;
145 } 174 }
146} 175}
147 176
148sub invoke_button_down { 177sub invoke_button_down {
149 my ($self, $ev, $x, $y) = @_; 178 my ($self, $ev, $x, $y) = @_;
150 179
151 if ($ev->{button} == 1) { 180 if ($ev->{button} == 1) {
152 $self->grab_focus; 181 $self->grab_focus;
153 return unless $::CONN; 182 return unless $::CONN;
154 183
155 my $x = 1 + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; 184 my $x = $self->{dx} + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize};
156 my $y = 1 + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; 185 my $y = $self->{dy} + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize};
157 186
158 $x -= int 0.5 * $self->{sw}; 187 $x -= CFPlus::floor $::MAP->w * 0.5;
159 $y -= int 0.5 * $self->{sh}; 188 $y -= CFPlus::floor $::MAP->h * 0.5;
160 189
190 if ($::CONN) {
191 if ($::IN_BUILD_MODE) {
192 $::CONN->buildat ($::IN_BUILD_MODE, $x, $y);
193 } else {
161 $::CONN->lookat ($x, $y) 194 $::CONN->lookat ($x, $y)
162 if $::CONN; 195 }
196 }
163 197
164 } elsif ($ev->{button} == 2) { 198 } elsif ($ev->{button} == 2) {
165 $self->grab_focus; 199 $self->grab_focus;
166 return unless $::CONN; 200 return unless $::CONN;
167 201
177 $::CFG->{map_shift_y} = $bh + $y - $oy; 211 $::CFG->{map_shift_y} = $bh + $y - $oy;
178 212
179 $self->update; 213 $self->update;
180 }; 214 };
181 } elsif ($ev->{button} == 3) { 215 } elsif ($ev->{button} == 3) {
182 (new CFPlus::UI::Menu 216 my @items = (
183 items => [
184 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }], 217 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }],
185 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }], 218 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }],
186 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }], 219 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }],
187 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }], 220 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }],
188 ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }], 221 ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }],
192 $::PICKUP_ENABLE->{state} 225 $::PICKUP_ENABLE->{state}
193 ? "Disable automatic pickup" 226 ? "Disable automatic pickup"
194 : "Enable automatic pickup", 227 : "Enable automatic pickup",
195 sub { $::PICKUP_ENABLE->toggle } 228 sub { $::PICKUP_ENABLE->toggle }
196 ], 229 ],
197 $::CONN && length $::CONN->{cvs_root} 230 );
231
232 if ($::CONN && $::CONN->{editor_support}) {
233 push @items, [
198 ? ["Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>", 234 "Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>",
199 \&editor_invoke] 235 \&editor_invoke,
200 : (), 236 ];
201 $::CONN && length $::CONN->{test_server} 237
238 for my $type (qw(test name)) {
239 $::CONN->{editor_support}{type} ne $type
240 or next;
241 my $server = $::CONN->{editor_support}{"${type}server"}
242 or next;
243
244 push @items, [
202 ? ["Login on Test Server <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{test_server}) . ")</span>", 245 "Login on $type server <span size='xx-small'>(" . (CFPlus::asxml $server) . ")</span>",
203 \&test_server_login] 246 sub { server_login $server },
204 : (), 247 ];
248 }
249 }
250
251 push @items,
205 ["Quit", 252 ["Quit",
206 sub { 253 sub {
207 if ($::CONN) { 254 if ($::CONN) {
208 &::open_quit_dialog; 255 &::open_quit_dialog;
209 } else { 256 } else {
210 exit; 257 exit;
211 }
212 } 258 }
213 ], 259 }
214 ], 260 ],
261 ;
262
263 (new CFPlus::UI::Menu
264 items => \@items,
215 )->popup ($ev); 265 )->popup ($ev);
216 } 266 }
217 267
218 1 268 1
219} 269}
238 1 288 1
239} 289}
240 290
241sub size_request { 291sub size_request {
242 ( 292 (
243 32 * CFPlus::ceil $::WIDTH / 32, 293 ::T * CFPlus::ceil $::WIDTH / ::T,
244 32 * CFPlus::ceil $::HEIGHT / 32, 294 ::T * CFPlus::ceil $::HEIGHT / ::T,
245 ) 295 )
246} 296}
247 297
248sub update { 298sub update {
249 my ($self) = @_; 299 my ($self) = @_;
275 my $sym = $ev->{sym}; 325 my $sym = $ev->{sym};
276 my $uni = $ev->{unicode}; 326 my $uni = $ev->{unicode};
277 327
278 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT; 328 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
279 329
280 if ($uni == ord "\t") { 330 if ($sym == 9) {
281 $::PL_WINDOW->toggle_visibility; 331 ($mod & CFPlus::KMOD_SHIFT ? $::CONSOLE->{window} : $::PL_WINDOW)->toggle_visibility;
282 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) { 332 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
283 $::HELP_WINDOW->toggle_visibility; 333 $::HELP_WINDOW->toggle_visibility;
284 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) { 334 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
285 ::toggle_player_page ($::STATS_PAGE); 335 ::toggle_player_page ($::STATS_PAGE);
286 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) { 336 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
289 ::toggle_player_page ($::SPELL_PAGE); 339 ::toggle_player_page ($::SPELL_PAGE);
290 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) { 340 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
291 ::toggle_player_page ($::INVENTORY_PAGE); 341 ::toggle_player_page ($::INVENTORY_PAGE);
292 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) { 342 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
293 $::SETUP_DIALOG->toggle_visibility; 343 $::SETUP_DIALOG->toggle_visibility;
294 } elsif ($sym == CFPlus::SDLK_INSERT && $mod & CFPlus::KMOD_CTRL) {
295 $::BIND_EDITOR->set_binding (undef, undef, [],
296 sub {
297 my ($mod, $sym, $cmds) = @_;
298 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
299 });
300 $::BIND_EDITOR->start;
301 $::BIND_EDITOR->show;
302#TODO: elmex, what was this supposed to do? it currently crashes the client.
303# } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) {
304# $::BIND_EDITOR->stop;
305# $::BIND_EDITOR->ask_for_bind_and_commit;
306# $::BIND_EDITOR->hide;
307 } elsif (!$::CONN) { 344 } elsif (!$::CONN) {
308 return 0; # bindings further down need a valid connection 345 return 0; # bindings further down need a valid connection
309 346
310 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) { 347 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) {
311 $::CONN->user_send ("stay fire"); 348 $::CONN->user_send ("stay fire");
316 } elsif ($uni == 13) { 353 } elsif ($uni == 13) {
317 $::CONN->user_send ("examine"); 354 $::CONN->user_send ("examine");
318 } elsif ($uni == ord ".") { 355 } elsif ($uni == ord ".") {
319 $::CONN->user_send ($self->{completer}{last_command}) 356 $::CONN->user_send ($self->{completer}{last_command})
320 if exists $self->{completer}{last_command}; 357 if exists $self->{completer}{last_command};
321 } elsif (my $bind_cmd = $::PROFILE->{bindings}{$mod}{$sym}) { 358 } elsif (my @macros = CFPlus::Macro::match_event $ev) {
322 $::CONN->user_send ($_) for @$bind_cmd; 359 $::CONN->macro_send ($_) for @macros;
323 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { 360 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
324 $::CONN->user_send ("rotateshoottype +"); 361 $::CONN->user_send ("rotateshoottype +");
325 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { 362 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
326 $::CONN->user_send ("rotateshoottype -"); 363 $::CONN->user_send ("rotateshoottype -");
364 } elsif ($uni == ord '!') {
365 $self->{completer}->set_prefix ("shout ");
366 $self->{completer}->show;
327 } elsif ($uni == ord '"') { 367 } elsif ($uni == ord '"') {
328 $self->{completer}->set_prefix ("$::CFG->{say_command} "); 368 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
329 $self->{completer}->show; 369 $self->{completer}->show;
330 } elsif ($uni == ord "'") { 370 } elsif ($uni == ord "'") {
331 $self->{completer}->set_prefix (""); 371 $self->{completer}->set_prefix ("");
387} 427}
388 428
389sub set_magicmap { 429sub set_magicmap {
390 my ($self, $w, $h, $x, $y, $data) = @_; 430 my ($self, $w, $h, $x, $y, $data) = @_;
391 431
392 $x -= $::MAP->ox + int 0.5 * $::MAP->w; 432 $x -= $::MAP->ox + 1 + int 0.5 * $::MAP->w;
393 $y -= $::MAP->oy + int 0.5 * $::MAP->h; 433 $y -= $::MAP->oy + 1 + int 0.5 * $::MAP->h;
394 434
395 $self->{magicmap} = [$x, $y, $w, $h, $data]; 435 $self->{magicmap} = [$x, $y, $w, $h, $data];
396 436
397 $self->update; 437 $self->update;
398} 438}
407 447
408 return 448 return
409 unless $focused || !$::FAST; 449 unless $focused || !$::FAST;
410 450
411 if (delete $self->{need_update}) { 451 if (delete $self->{need_update}) {
412 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale}; 452 my $tilesize = $self->{tilesize} = int ::T * $::CFG->{map_scale};
413 453
454 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
455 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
456
414 my $sx = $self->{sx} = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize; 457 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
415 my $sy = $self->{sy} = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize; 458 my $sy = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
416 459
417 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; 460 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
418 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; 461 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
419 462
420 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize; 463 my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx;
421 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize; 464 my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy;
422 465
423 if ($::CFG->{fow_enable}) { 466 if ($::CFG->{fow_enable}) {
424 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); 467 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
425 468
426 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war 469 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war
427 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); 470 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
428 glConvolutionFilter2D ( 471 glConvolutionFilter2D (
429 GL_CONVOLUTION_2D, 472 GL_CONVOLUTION_2D,
451 494
452 glPushMatrix; 495 glPushMatrix;
453 glTranslate $sx0, $sy0; 496 glTranslate $sx0, $sy0;
454 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 497 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
455 498
456 $::MAP->draw ($sx, $sy, 0, 0, $sw, $sh); 499 $::MAP->draw ($dx, $dy, $sw, $sh, ::T);
457 500
458 glScale 32, 32; 501 glScale ::T, ::T;
459 502
460 if (my $tex = $self->{fow_texture}) { 503 if (my $tex = $self->{fow_texture}) {
461 glEnable GL_TEXTURE_2D; 504 glEnable GL_TEXTURE_2D;
462 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 505 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
463 506
468 } 511 }
469 512
470 if ($self->{magicmap}) { 513 if ($self->{magicmap}) {
471 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; 514 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
472 515
473 $x += $::MAP->ox - $sx + int 0.5 * ($::MAP->w - $sw + 1); 516 $x += $::MAP->ox + $self->{dx};
474 $y += $::MAP->oy - $sy + int 0.5 * ($::MAP->h - $sh + 1); 517 $y += $::MAP->oy + $self->{dy};
475 518
476 glTranslate - $x - 1, - $y - 1; 519 glTranslate - $x - 1, - $y - 1;
477 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; 520 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
478 $::MAP->draw_magicmap ($x, $y, $w, $h, $data); 521 $::MAP->draw_magicmap ($x, $y, $w, $h, $data);
479 } 522 }
538 581
539 $::MAP or return; 582 $::MAP or return;
540 583
541 my ($w, $h) = @$self{qw(w h)}; 584 my ($w, $h) = @$self{qw(w h)};
542 585
543 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; 586 my $sw = int $::WIDTH / (::T * $::CFG->{map_scale}) + 0.99;
544 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; 587 my $sh = int $::HEIGHT / (::T * $::CFG->{map_scale}) + 0.99;
545 588
546 my $sx = int $::CFG->{map_shift_x} / 32; 589 my $sx = int $::CFG->{map_shift_x} / ::T;
547 my $sy = int $::CFG->{map_shift_y} / 32; 590 my $sy = int $::CFG->{map_shift_y} / ::T;
548 591
549 my $ox = 0.5 * ($w - $sw); 592 my $ox = 0.5 * ($w - $sw);
550 my $oy = 0.5 * ($h - $sh); 593 my $oy = 0.5 * ($h - $sh);
551 594
552 glEnable GL_BLEND; 595 glEnable GL_BLEND;
625 668
626 if ($ev->{button} == 3) { 669 if ($ev->{button} == 3) {
627 (new CFPlus::UI::Menu 670 (new CFPlus::UI::Menu
628 items => [ 671 items => [
629 ["bind <i>" . (CFPlus::asxml $self->{select}) . "</i> to a key" 672 ["bind <i>" . (CFPlus::asxml $self->{select}) . "</i> to a key"
630 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] 673 => sub { CFPlus::Macro::quick_macro [$self->{select}], sub { $entry->grab_focus } }]
631 ], 674 ],
632 )->popup ($ev); 675 )->popup ($ev);
633 return 1; 676 return 1;
634 } 677 }
635 0 678 0
836 879
837 $self->SUPER::_draw; 880 $self->SUPER::_draw;
838} 881}
839 882
8401 8831
884

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines