Author Topic: Setting a Cursor's location  (Read 3820 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

Setting a Cursor's location
« on: January 10, 2020, 11:27:37 AM »
I'm trying to put the cursor in a certain location, but am having some trouble.

I've used the following code:
Code: [Select]
(send gGame:setCursor(gNormalCursor SET_CURSOR_VISIBLE 279 31))This works in as much as it moves the cursor to the numbers specified, but the problem is that while it moves the cursor to that location, when the player moves the mouse, the cursor jumps back to where it was before I set it. So, the setting of the cursor to a location is only cosmetic and not influencing the actual variables involved.

I've looked and cannot find where the cursor variables are held. Can anyone help with this?

Edit: Sorry for the Studio syntax...I'm working on the patch of my old game, so I'm using the old syntax
« Last Edit: January 10, 2020, 04:37:14 PM by Doan Sephim »


Artificial Intelligence Competition

Offline Charles

Re: Setting a Cursor's location
« Reply #1 on: January 11, 2020, 08:41:33 AM »
I don't know much about Studio syntax, but looking at QFG1's code they did:

Code: [Select]
(theGame setCursor: normalCursor TRUE 304 174)

which in turn called the setCursor precedure on the Game object in script 994:
Code: [Select]
(method (setCursor cursorNumber &tmp oldCursor)
;
; Set the cursor form, returning the previous form

(= oldCursor theCursor)
(= theCursor cursorNumber)
(SetCursor cursorNumber &rest)
(return oldCursor)
)

which is calling the kernel command SetCursor http://scicompanion.com/Documentation/Kernels/SetCursor.html?highlight=setcursor

I'm sorry it's not a solution to your problem, but maybe it's a start to help debug it?

[EDIT: Just to confirm, you're seeing this behaviour when running in DosBox?]

Offline Doan Sephim

Re: Setting a Cursor's location
« Reply #2 on: January 12, 2020, 09:38:50 PM »
Yes, I'm running in dosbox.

Since my code does successfully move the visual cursor, all I need is to simultaneously move the variables associated with the cursor. I just am not sure where those are held.

Offline Kawa

Re: Setting a Cursor's location
« Reply #3 on: January 13, 2020, 09:05:30 AM »
I was hoping there'd be something about the part in Larry 5 where when you click during the intro, it offers to show you how to fast forward. Looking there I find that it sets the Fast Forward icon as current and fakes a "pressed Escape" event:
Code: [Select]
(gIconBar curIcon: (gIconBar at: 5) handleEvent: (pEvent type: evKEYBOARD message: KEY_ESC yourself:))Undeterred, I drill down to IconBar::handleEvent:
Code: [Select]
(gGame setCursor:
gCursorNumber
true
(+ (curIcon nsLeft?) (/ (- (curIcon nsRight?) (curIcon nsLeft?)) 2))
(- (curIcon nsBottom?) 3))
)

That basically matches the QFG1 snippet.

Importantly, the "show me" button is roughly dead center on the screen, so that's where the cursor goes. If this were to only change the visuals, moving the cursor should snap it back to where the "show me" button was, right? But it doesn't.

Offline Charles

Re: Setting a Cursor's location
« Reply #4 on: January 13, 2020, 11:05:34 PM »
I don’t have the code snippets in front of me right now, but QFG1VGA and QFG3 also both move the mouse cursor programmatically (when clicking the “other” menu for running/sneaking/magic).  I would expect those to also be similar code to the above.

So as far as I can tell, there aren’t two sets of variables — one for visual one for actual cursor placement.

The thing that’s occurring to me now is that the QFG1EGA code only sets cursor coordinates if it detects no mouse. That uses SCI0, like your Betrayed Alliance, while the other examples use SCI1. It’s possible SCI0 interpreters don’t actually let you position the actual cursor.

I’m racking my brains trying to think of an SCI0 example, but the closest I can get is vaguely recalling being annoyed when QFG2 used to move my mouse back to the corner after cutscenes. And even then, that’s technically SCI1, too.

Offline Doan Sephim

Re: Setting a Cursor's location
« Reply #5 on: January 14, 2020, 09:35:31 AM »
It's very strange. The code I'm using does move the cursor and if I click on where I put the cursor it will trigger for that area, but when I move the mouse it snaps back to where I had the cursor before.

This isn't a big issue, it was just a small quality of life issue that I'm fine not implementing, but it does make me curious as to what's going on in the code. But I'm still very much an amateur in coding, so it's beyond me.

Offline Collector

Re: Setting a Cursor's location
« Reply #6 on: January 14, 2020, 09:44:22 AM »
I don’t have the code snippets in front of me right now, but QFG1VGA and QFG3 also both move the mouse cursor programmatically (when clicking the “other” menu for running/sneaking/magic).

This reminds me of a quirk of the game in DOSBox. If the mouse is not set to be captured the popup menu would disappear the instant the mouse was moved.
KQII Remake Pic


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.035 seconds with 24 queries.