@@ -90,6 +90,7 @@ local InertTypes
9090
9191-- gui.defaultPixelFont("fceux")
9292gui .use_surface (" client" )
93+ client .SetClientExtraPadding (240 , 0 , 0 , 0 )
9394
9495-- TYPE CONVERTERS
9596
@@ -298,7 +299,7 @@ local function maybe_swap(smaller, bigger)
298299 if smaller > bigger then
299300 return bigger , smaller
300301 end
301- return smaller , bigger
302+ return smaller - 100 , bigger + 100
302303end
303304
304305local function get_line_count (str )
@@ -497,6 +498,7 @@ local function iterate()
497498
498499 if selected_sector then
499500 for _ , line in ipairs (selected_sector .lines ) do
501+ -- cached_line_coords gives some length error?
500502 local x1 , y1 , x2 , y2 = game_to_screen (line :coords ())
501503 gui .drawLine (x1 , y1 , x2 , y2 , 0xff00ffff )
502504 end
@@ -525,13 +527,25 @@ local function iterate()
525527 local health = mobj.health
526528 local sprite = SpriteNumber[mobj.sprite]
527529 --]] --
528- if text_color then
529- -- type = MobjType[type]
530- text (pos .x , pos .y , string.format (" %d" , index ), text_color )
530+
531+ if in_range (mousePos .x , pos .x - radius , pos .x + radius )
532+ and in_range (mousePos .y , pos .y - radius , pos .y + radius )
533+ then
534+ radius_color = " white"
535+ text_color = " white"
531536 end
537+
532538 if radius_color then
533539 box (pos .x - radius , pos .y - radius , pos .x + radius , pos .y + radius , radius_color )
534540 end
541+
542+ if text_color then
543+ -- type = MobjType[type]
544+ text (
545+ pos .x - radius + 1 ,
546+ pos .y - radius ,
547+ string.format (" %d" , index ), text_color )
548+ end
535549 end
536550 end
537551 end
@@ -557,6 +571,8 @@ local function get_player1_xy()
557571end
558572
559573local function update_zoom ()
574+ local screenwidth = client .screenwidth ()
575+ local screenheight = client .screenheight ()
560576 local mousePos = client .transformPoint (Mouse .X , Mouse .Y )
561577 local mouseWheel = math.floor (Mouse .Wheel / 120 )
562578 local deltaX = mousePos .x - LastMouse .x
@@ -578,8 +594,8 @@ local function update_zoom()
578594 if Follow and Globals .gamestate == 0 then
579595 local playerPos = get_player1_xy ()
580596 local screenCenter = screen_to_game ({
581- x = client . screenwidth () / 2 ,
582- y = client . screenheight () / 2
597+ x = screenwidth / 2 ,
598+ y = screenheight / 2
583599 })
584600
585601 screenCenter .x = screenCenter .x - playerPos .x
@@ -589,8 +605,8 @@ local function update_zoom()
589605 end
590606
591607 if not Init
592- and LastScreenSize .w == client . screenwidth ()
593- and LastScreenSize .h == client . screenheight ()
608+ and LastScreenSize .w == screenwidth
609+ and LastScreenSize .h == screenheight
594610 then return end
595611
596612 if OB .top ~= math.maxinteger
@@ -601,14 +617,18 @@ local function update_zoom()
601617 then
602618 OB .left , OB .right = maybe_swap (OB .left , OB .right )
603619 OB .top , OB .bottom = maybe_swap (OB .top , OB .bottom )
604- local span = { x = OB .right - OB .left + 200 , y = OB .bottom - OB .top + 200 }
605- local scale = { x = client .screenwidth ()/ span .x , y = client .screenheight ()/ span .y }
606- local spanCenter = { x = OB .left + span .x / 2 , y = OB .top + span .y / 2 }
607- Zoom = math.min (scale .x , scale .y )
608- local sreenCenter = { x = client .screenwidth ()/ Zoom / 2 , y = client .screenheight ()/ Zoom / 2 }
609- Pan .x = - math.floor (spanCenter .x - sreenCenter .x )
610- Pan .y = - math.floor (spanCenter .y - sreenCenter .y )
611- Init = false
620+ local span = { x = OB .right - OB .left , y = OB .bottom - OB .top }
621+ local scale = { x = screenwidth / span .x , y = screenheight / span .y }
622+ Zoom = math.min (scale .x , scale .y )
623+ local spanCenter = { x = OB .left + span .x / 2 , y = OB .top + span .y / 2 }
624+ local sreenCenter = { x = screenwidth / Zoom / 2 , y = screenheight / Zoom / 2 }
625+
626+ if not Follow then
627+ Pan .x = - math.floor (spanCenter .x - sreenCenter .x )
628+ Pan .y = - math.floor (spanCenter .y - sreenCenter .y )
629+ end
630+
631+ Init = false
612632 end
613633end
614634
@@ -646,11 +666,18 @@ local function make_button(x, y, name, func)
646666
647667 if in_range (mousePos .x , x , x + boxWidth )
648668 and in_range (mousePos .y , y - boxHeight , y ) then
649- if Mouse .Left then
650- suppress_click_input ()
651- colorIndex = 3
652- func ()
653- else colorIndex = 2 end
669+ if not (Follow
670+ and (func == pan_left
671+ or func == pan_up
672+ or func == pan_down
673+ or func == pan_right ))
674+ then
675+ if Mouse .Left then
676+ suppress_click_input ()
677+ colorIndex = 3
678+ func ()
679+ else colorIndex = 2 end
680+ end
654681 end
655682
656683 box (x , y , x + boxWidth , y - boxHeight , 0xaaffffff , colors [colorIndex ])
@@ -664,9 +691,9 @@ local function make_buttons()
664691 make_button ( 64 , client .screenheight ()- 40 , " ^" , pan_up )
665692 make_button ( 64 , client .screenheight ()- 10 , " v" , pan_down )
666693 make_button ( 88 , client .screenheight ()- 24 , " >" , pan_right )
667- make_button (300 , client .screenheight ()- 10 , " Reset\n View " , reset_view )
694+ make_button (118 , client .screenheight ()- 40 , " Reset View " , reset_view )
668695 make_button (118 , client .screenheight ()- 10 ,
669- string.format (" Follow\n %s" , Follow and " ON" or " OFF" ), follow_toggle )
696+ string.format (" Follow %s" , Follow and " ON " or " OFF" ), follow_toggle )
670697end
671698
672699-- Additional types that are not identifiable by flags alone
756783while true do
757784 local framecount = emu .framecount ()
758785 local paused = client .ispaused ()
759- Mouse = input .getmouse ()
786+ Mouse = input .getmouse ()
760787
761788 local episode , map = Globals .gameepisode , Globals .gamemap
762789 if episode ~= LastEpisode or map ~= LastMap then
0 commit comments