130130local function line_handler ()
131131 if not ShowMap then return end
132132
133- local closestLine
133+ local closestLine , selectedSector
134134 local player = select (2 , next (Players )) -- first present player only for now
135135 local mousePos = client .transformPoint (Mouse .X , Mouse .Y )
136136 local gameMousePos = screen_to_game (mousePos )
@@ -318,41 +318,67 @@ local function tracked_handler()
318318end
319319
320320local function draw_grid ()
321- if ShowMap and ShowGrid then
322- local size = GRID_SIZE * FRACUNIT
323- local step = GRID_SIZE * Zoom
324- local bmorg = game_to_screen (BlockmapOrigin )
325- local bmend = game_to_screen (BlockmapEnd )
326- local start = { x = bmorg .x , y = bmend .y }
327- local stop = { x = bmend .x , y = bmorg .y }
321+ if not (ShowMap and ShowGrid ) then return end
322+
323+ local size = GRID_SIZE * FRACUNIT
324+ local step = GRID_SIZE * Zoom
325+ local bmorg = game_to_screen (BlockmapOrigin )
326+ local bmend = game_to_screen (BlockmapEnd )
327+ local start = { x = bmorg .x , y = bmend .y }
328+ local stop = { x = bmend .x , y = bmorg .y }
329+
330+ for x = start .x , stop .x - 1 , step do
331+ drawline (x , start .y , x , stop .y , MapPrefs .grid .color )
332+ end
333+ for y = start .y , stop .y - 1 , step do
334+ drawline (start .x , y , stop .x , y , MapPrefs .grid .color )
335+ end
336+
337+ -- due to step being float in screen coords, we can't avoid rounding error
338+ -- so final 2 lines won't match grid size and sometimes won't even be drawn
339+ -- so we draw them separately where they "should be"
340+ -- while embracing the rounding error of all the rest
341+ -- since drawing them all perfectly is too complicated
342+ drawline (stop .x , start .y , stop .x , stop .y , MapPrefs .grid .color )
343+ drawline (start .x , stop .y , stop .x , stop .y , MapPrefs .grid .color )
344+
345+ for block ,timer in pairs (MapBlocks ) do
346+ local forecolor
347+ local backcolor
348+ local delta = timer - Framecount
328349
329- for x = start .x , stop .x - 1 , step do
330- drawline (x , start .y , x , stop .y , MapPrefs .grid .color )
331- end
332- for y = start .y , stop .y - 1 , step do
333- drawline (start .x , y , stop .x , y , MapPrefs .grid .color )
350+ -- red or grey with dynamically reduced alpha
351+ if delta == FADEOUT_TIMER - 1 then
352+ forecolor = 0xffff0000
353+ backcolor = 0x33ff0000
354+ else
355+ forecolor = 0x88888888
356+ backcolor = (math.floor (0x88 / FADEOUT_TIMER * delta ) << 24 ) | 0x888888
334357 end
335358
336- -- due to step being float in screen coords, we can't avoid rounding error
337- -- so final 2 lines won't match grid size and sometimes won't even be drawn
338- -- so we draw them separately where they "should be"
339- -- while embracing the rounding error of all the rest
340- -- since drawing them all perfectly is too complicated
341- drawline (stop .x , start .y , stop .x , stop .y , MapPrefs .grid .color )
342- drawline (start .x , stop .y , stop .x , stop .y , MapPrefs .grid .color )
359+ if delta > 0 then
360+ local origin = game_to_screen (BlockmapOrigin )
361+ local x = origin .x + block % BlockmapWidth * GRID_SIZE * Zoom
362+ local y = origin .y - math.floor (block / BlockmapWidth ) * GRID_SIZE * Zoom
363+ -- positioning precision is a bit higher than of the overall grid
364+ -- so it may look off at some zoom levels
365+ box (x , y , x + GRID_SIZE * Zoom , y - GRID_SIZE * Zoom , forecolor , backcolor )
366+ else
367+ MapBlocks [block ] = nil
368+ end
343369 end
344370end
345371
346372local function draw_tracelines ()
347373 if not ShowMap then return end
348374
349- for k , v in pairs (DivLines ) do
375+ for key , timer in pairs (DivLines ) do
350376 local color
351377 local i = 0
352378 local line = {}
353- local delta = v - Framecount
379+ local delta = timer - Framecount
354380
355- for token in string.gmatch (k , " ([^%s]+)" ) do
381+ for token in string.gmatch (key , " ([^%s]+)" ) do
356382 line [i ] = tonumber (token )
357383 i = i + 1
358384 end
@@ -367,7 +393,7 @@ local function draw_tracelines()
367393 local x1 , y1 , x2 , y2 = game_to_screen (line [0 ], line [1 ], line [2 ], line [3 ])
368394 drawline (x1 , y1 , x2 , y2 , color )
369395 else
370- DivLines [k ] = nil
396+ DivLines [key ] = nil
371397 end
372398 end
373399end
@@ -442,15 +468,16 @@ local function make_buttons()
442468 elseif LineCrossLog == LineLogType .ALL then crossName = " ALL"
443469 end
444470
445- make_button (- 170 , h * 1 , " Log Use " .. useName , function () cycle_log_types (true ) end )
446- make_button (- 170 , h * 2 , " Log Cross " .. crossName , function () cycle_log_types (false ) end )
447- make_button (- 170 , h * 3 , " Log P_Random " .. (RNGLog and " ON" or " OFF" ), prandom_toggle )
448- make_button (- 170 , h * 4 , " Log Interc. " .. (InterceptLog and " ON" or " OFF" ),intercept_toggle )
449- make_button (- 110 , h * 5 , " Map " .. (ShowMap and " ON" or " OFF" ), map_toggle )
450- make_button (- 110 , h * 6 , " Grid " .. (ShowGrid and " ON" or " OFF" ), grid_toggle )
451- make_button (- 110 , h * 7 , " Hilite " .. (Hilite and " ON" or " OFF" ), hilite_toggle )
452- make_button (- 110 , h * 8 , " Follow " .. (Follow and " ON" or " OFF" ), follow_toggle )
453- make_button (- 110 , h * 9 , " Reset View" , reset_view )
471+ make_button (- 170 , h * 1 , " Log Use " .. useName , function () cycle_log_types (true ) end )
472+ make_button (- 170 , h * 2 , " Log Cross " .. crossName , function () cycle_log_types (false ) end )
473+ make_button (- 170 , h * 3 , " Log P_Random " .. (RNGLog and " ON" or " OFF" ), prandom_log )
474+ make_button (- 170 , h * 4 , " Log Interc. " .. (InterceptLog and " ON" or " OFF" ), intercept_log )
475+ make_button (- 170 , h * 5 , " Show Interc. " .. (InterceptShow and " ON" or " OFF" ),intercept_show )
476+ make_button (- 110 , h * 6 , " Map " .. (ShowMap and " ON" or " OFF" ), map_show )
477+ make_button (- 110 , h * 7 , " Grid " .. (ShowGrid and " ON" or " OFF" ), grid_show )
478+ make_button (- 110 , h * 8 , " Hilite " .. (Hilite and " ON" or " OFF" ), hilite_toggle )
479+ make_button (- 110 , h * 9 , " Follow " .. (Follow and " ON" or " OFF" ), follow_toggle )
480+ make_button (- 110 , h * 10 ," Reset View" , reset_view )
454481
455482 Input = input .get ()
456483
0 commit comments