The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: THLeaderH on December 08, 2020, 12:39:29 PM

Title: cursor settings for scripted one click tools
Post by: THLeaderH on December 08, 2020, 12:39:29 PM
It must be convenient if you can set the cursor size other than 1x1 tile for a scripted one click tool. tool_t has three public variables related to the cursor size, which are "cursor_area", "cursor_centered", and "cursor_offset". I want to set values to these variables in a script.

To set these values from the script, I think there are two possible ways. The first one is setting these values directory from the script in init() function. The three variables are registered to script vm and the script can handle these as global variables. The second way is using interface function such as "get_cursor_area()" and so on.

I think the first approach is more appropriate since we need two or three interface functions to set these variables with interface functions. How do you think?
Title: Re: cursor settings for scripted one click tools
Post by: Dwachs on December 08, 2020, 12:47:16 PM
You could also read them from the tab-file. This seems to be simpler.

The two approaches you describe need double code for both single-tools and two-click tools. Since on the c++-side these are two different classes (and one is not the child of the other).

Also be careful with transfering coordinates between c++ and squirrel: if you use plain koord type then these are auto-rotated (scripts live in fixed map rotation) on rotated maps.
Title: Re: cursor settings for scripted one click tools
Post by: THLeaderH on December 08, 2020, 12:53:15 PM
Writing cursor size in description.tab makes the cursor size static. Is there any situations where the cursor size needs dynamic? I think this does not need to be dynamic, and that approach makes things much simpler both for the simutrans code and the script code.
Title: Re: cursor settings for scripted one click tools
Post by: prissi on December 08, 2020, 01:07:51 PM
Cursors are by defualt now zoomable images, so fixed sizes should work.
Title: Re: cursor settings for scripted one click tools
Post by: THLeaderH on December 12, 2020, 08:25:38 AM
I wrote a patch to make cursor area and offset configurable. This patch considers the map rotation.
The cursor area and offset is defined in description.tab like the example below.

Code: [Select]
cursor_area=3,4
cursor_offset=1,2

This settings is optional. The default area is (1, 1) and the default offset is (0,0).
Title: Re: cursor settings for scripted one click tools
Post by: Dwachs on December 12, 2020, 09:32:37 AM
Looks good. One comment: there is already a routine to read coordinates from text files in tabfile_t.
Title: Re: cursor settings for scripted one click tools
Post by: THLeaderH on December 17, 2020, 01:08:45 PM
The routine to read coordinates was replaced with tabfileobj_t::get_koord().
Title: Re: cursor settings for scripted one click tools
Post by: Dwachs on December 19, 2020, 10:23:19 AM
thank you, in r9506