ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


cursor_library

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cursor_library [2017/07/14 21:17]
korshun
cursor_library [2017/07/14 21:40] (current)
korshun
Line 1: Line 1:
 ====== Cursor library ====== ====== Cursor library ======
 The ACSUtils cursor library allows mods to easily add mouse cursor support. The ACSUtils cursor library allows mods to easily add mouse cursor support.
 +
 +It fully supports wide screens and takes into account all mouse settings of the user to provide consistent cursor support regardless of aiming settings.
 +
 +<note important>Do not use the cursor library in serverside scripts. It isn't supported for a number of reasons:
 +  - serverside cursors are very laggy.
 +  - cursor library can't read user's mouse settings to adjust cursor speed and direction.
 +  - cursor library can't read user's aspect ratio to find correct screen boundaries.
 +</note>
  
 ===== Basic usage ===== ===== Basic usage =====
Line 9: Line 17:
     {     {
         UpdateCursor();         UpdateCursor();
 +        
 +        SetHudSize(640, 480, false);
         // Draw cursor at CursorX(), CursorY()         // Draw cursor at CursorX(), CursorY()
         Delay(1);         Delay(1);
Line 15: Line 25:
 </code> </code>
  
-[[functions:UpdateCursor]] reads player input and moves the cursor. [[functions:CursorX]] and [[functions:CursorY]] return the current position of the cursor on the screen in [[HUD coordinate system]].+[[functions:UpdateCursor]] reads player input and moves the cursor. [[functions:CursorX]] and [[functions:CursorY]] return the current position of the cursor on the screen in [[HUD coordinate system]]. The coordinate system is 640x480 by default. 
 + 
 +<note tip>The cursor library does not draw the cursor for you. You can draw it manually using [[zdoom>HudMessage]] or [[HUD Library]], or even keep it invisible.</note> 
 + 
 +===== Advanced features ===== 
 + 
 +==== Getting cursor motion ==== 
 + 
 +[[functions:CursorDeltaX]] and [[functions:CursorDeltaY]] return the difference between the current and the previous cursor positions.  
 + 
 +[[functions:CursorMotionX]] and [[functions:CursorMotionY]] return the difference between the current and the previous cursor positions that would've been there if the cursor was not blocked by screen boundaries. 
 + 
 +==== Setting coordinate system scale ==== 
 + 
 +[[functions:SetCursorArea]] sets the scale of the coordinate system used by the cursor library. You can even set it to ''SetCursorArea(1.0, 1.0)'' and it will work, because the cursor library is fully fixed-point. 
 +  
 +Calling [[functions:SetCursorArea]] also transforms the cursor's coordinates that it stays in the same place on screen. 
 + 
 +==== Moving the cursor ==== 
 + 
 +[[functions:SetCursorPosition]] and [[functions:CenterCursor]] can be used to move the cursor from ACS. 
 + 
 +==== Changing cursor speed ==== 
 + 
 +[[functions:SetCursorSpeed]], [[functions:SetCursorSpeedX]], [[functions:SetCursorSpeedY]] can change the cursor's speed (sensitivity). 
 + 
 +==== Cursor wraparound ==== 
 + 
 +[[functions:EnableCursorWrap]], [[functions:EnableCursorWrapX]], [[functions:EnableCursorWrapY]] can enable or disable cursor wrapping. If cursor wrapping is enabled, then reaching the edge of the screen will move the cursor to the opposite edge. This sudden teleportation will not affect [[functions:CursorDeltaX]] and [[functions:CursorDeltaY]] readings. 
 + 
 + 
 + 
 + 
cursor_library.1500056252.txt.gz · Last modified: 2017/07/14 21:17 by korshun