News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

cursor settings for scripted one click tools

Started by THLeaderH, December 08, 2020, 12:39:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

THLeaderH

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?

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

THLeaderH

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.

prissi

Cursors are by defualt now zoomable images, so fixed sizes should work.

THLeaderH

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.


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).

Dwachs

Looks good. One comment: there is already a routine to read coordinates from text files in tabfile_t.
Parsley, sage, rosemary, and maggikraut.

THLeaderH

The routine to read coordinates was replaced with tabfileobj_t::get_koord().

Dwachs

Parsley, sage, rosemary, and maggikraut.