HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] SetCursorVisibility not working?  (Read 2237 times)

Ashtefere

  • General Accounts
  • *
  • Posts: 16
    • View Profile
[Resolved] SetCursorVisibility not working?
« on: Jun 06, 11, 05:55:29 AM »

I have modified the inputcamera script in my learnings of HSL, and am now trying to hide the mouse cursor during camera movement.

I have gotten it to work intermittently, and now it refused to work at all.

Is there some kind of trick to get SetCursorVisibility(false) to work? is there another script overriding this at all?

Thanks

-Jon
« Last Edit: Nov 03, 12, 08:10:54 PM by HE-Cooper »
Logged

Ashtefere

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: SetCursorVisibility not working?
« Reply #1 on: Jun 06, 11, 06:17:40 AM »

For some more info:

Works in the "onmousemove" layer, but none of the others.

At the moment I have the camera lock into mouse-move mode with a toggle, and would like the cursor hidden during that toggle state.

Surely this is doable without requiring the mouse to be constantly moving?

-Jon
Logged

HE-Cooper

  • *****
  • Posts: 2221
    • View Profile
Re: SetCursorVisibility not working?
« Reply #2 on: Jun 06, 11, 08:24:08 PM »

Jonathan,

It's my limited understanding that hiding the mouse cursor "flickers" hidden when you are in game mode within the tool, but that when your players eventually access your world from a player client you'll see it hidden without the flickering you get in the editor.
Logged

Ashtefere

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: SetCursorVisibility not working?
« Reply #3 on: Jun 06, 11, 08:28:16 PM »

OK.

So, if I were to use SetCursor, and set it to a transparent PNG for the "hidden" state, and SetCursor to a normal cursor for "visible" state, that would work?

Thanks

-Jon
Logged

Luke

  • General Accounts
  • *
  • Posts: 2
    • View Profile
Re: SetCursorVisibility not working?
« Reply #4 on: Jun 07, 11, 05:40:39 PM »

In playmode you need to use the $Cursor._setCustomCursorVisibility(false) call in _CursorClassMethods.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: SetCursorVisibility not working?
« Reply #5 on: Jun 07, 11, 06:53:29 PM »

Use of $Cursor._setCustomCursorVisibility() would be if you are using the software cursor.  $Cursor simulates a cursor by moving a gui panel around the screen. Understandably, it can be rather pokey and not real responsive.

So, it is recommended to use hardware cursors, whereby you set it with the external function SetCursor() (supply a path to an image in the repository for the FQN, or use empty string to reset it to normal arrow) and show/hide it with SetCursorVisibility().

Whether you are in play mode or not can affect the hiding of the cursor.  I don't know what modifications you made to the Input_Camera script, but it originally reads,
Code: [Select]
if $PLAYMODE._getPlayModeState() == ON
  $Cursor._setCustomCursorVisibility(false)
else
  SetCursorVisibility(false)
.
SetIgnoreCursor(true)
and later,
Code: [Select]
if $PLAYMODE._getPlayModeState() == ON
  $Cursor._setCustomCursorVisibility(true)
else
  SetCursorVisibility(true)
.
SetIgnoreCursor(false)
So when play mode is ON, it only calls _setCustomCursorVisibility [the software cursor].

We modified the code so that SetCursorVisibility() [the hardware cursor] is always called, regardless of play mode.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: SetCursorVisibility not working?
« Reply #6 on: Jun 07, 11, 06:59:00 PM »

Incidentally, the code I put above was in the onCmdStart and onCmdEnd callbacks, specifically for the DragRotate and DragRotateCamera commands.  If it is only working for you in OnMouseMove, have you confirmed whether the DragRotate command is being called at all?
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Ashtefere

  • General Accounts
  • *
  • Posts: 16
    • View Profile
Re: SetCursorVisibility not working?
« Reply #7 on: Jun 07, 11, 10:09:26 PM »

I have defined my own CMDstates, as the stock untouched code was leaving dragrotate active after camera movement had already been stopped.

Now I have a state called "LockCamera" which works right 100% of the time (toggled on off).

If I want to have hardware cursor running all the time, (edit and play mode) and have it hidden during "LockCamera" state, what should I use?

Additionally, for the CMDStates, can I set a custom string for a state instead of just TRUE/FALSE? That could be quite useful.

I did a test for it and it compiled, but I am not sure if it will work or not.

Thanks

-Jon
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: SetCursorVisibility not working?
« Reply #8 on: Jun 07, 11, 10:22:12 PM »

First, a big thanks to Cooper.  I had tried hardware cursors before, but couldn't figure out why they flickered when moved.  So I disabled it and never thought to try it in the player client.  Sure enough, it is rock-solid in there.

Now that I have tested it in the player client, I see what Jonathan saw.  I set it up to be able to toggle back and forth between the default cursor and our own, and sure enough only the default cursor hides on rotating the camera.  So what I did was when hiding the cursor, set it to default via SetCursor("", 0, 0), then when showing it again, I put in SetCursor("\GUI\our_cursor.png", 0, 0).  That is in addition to still setting visibility.

I also did a check of if not IsHeroBlade() before each of those commands so that we didn't have to deal with the flickering when working in HeroBlade.

That works very nicely, in the player client anyways.

P.S. We found the offset values in SetCursor didn't make a difference, so we did the cursor image so the hotspot was in the center of the image, though I haven't tried to see if they work in the player client.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.