Detecting mousewheel scroll?

Started by stewbasic, May 09, 2014, 10:31:17 AM

Previous topic - Next topic

stewbasic

Is there a command to determine when the player scrolls their mousewheel? I couldn't see anything under mouse commands on the wiki.

I want to disable normal unit interaction and building, but keep map panning and scrolling. So I'm using EnableAlternateControlMode and mimicking the latter. Here's what I have... it's just missing zoom on scroll (not essential if it's not possible).


# This script disables normal controls (selecting units, building etc) but mimics the usual panning and zooming controls.

$toggle:0
$name:"AlternateControl"
$panSpeed:30.0

once
0 ->alt
0 ->panning
OperateWhilePaused(TRUE)
ShowTraceLog
endonce

if(<-toggle)
0 ->toggle
<-alt not ->alt
EnableAlternateControlMode(<-alt)
0 ->panning
@UpdateZoom
endif

if(<-alt)
if(GetCameraZoom <-zoom neq) @UpdateZoom endif
# Pan with right mouse
if(GetMouseButtonUp(1))
0 ->panning
endif
if(<-panning)
GetMouseScreenPixelPosition
<-nscale mul <-dy add
swap <-nscale mul <-dx add swap
SetCameraPosition
SetText(<-nscale)
else
0.0 if(GetKey("W") GetKey("UpArrow") or) <-delta sub endif if(GetKey("S") GetKey("DownArrow") or) <-delta add endif
0.0 if(GetKey("D") GetKey("RightArrow") or) <-delta sub endif if(GetKey("A") GetKey("LeftArrow") or) <-delta add endif
GetCameraPosition ->cy add swap <-cy add SetCameraPosition
endif
if(GetMouseButtonDown(1))
1 ->panning
GetMousePosition ->my ->mx
@ComputePanMap
endif

if(GetKeyDown("Q") GetMouseButtonDown(2) or)
@DeltaZoom(-1)
endif
if(GetKeyDown("Z") GetMouseButtonUp(2) or)
@DeltaZoom(1)
endif

endif

:DeltaZoom
GetCameraZoom add SetCameraZoom
@UpdateZoom

:UpdateZoom
-0.5 GetCameraZoom dup ->zoom asfloat div(8) sub ->nscale
<-nscale mul(<-panSpeed) ->delta
# Recompute mouse to camera map
if(<-panning) @ComputePanMap endif

:ComputePanMap
<-mx ScreenWidth div(2) <-nscale mul sub ->dx
<-my ScreenHeight div(2) <-nscale mul sub ->dy



knucracker

There is a EnableNormalZoomControl(bool) call you can make to turn off zooming.

once
EnableNormalZoomControl(false)
SetCameraZoom(4)
endonce

stewbasic