The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on October 07, 2018, 07:05:54 PM

Title: Lock the screen position
Post by: Yona-TYT on October 07, 2018, 07:05:54 PM

I was thinking about a function to keep the screen in a section of the map, with this I can make the player stay in a marked region until he completes the assigned task.

Example: As seen in the image, the player must connect the track of the train to be able to advance to the next step, then at that moment he does not need to move the screen, then this is where blocking the screen makes a lot of sense, thus avoiding that the player gets lost beyond the area marked with (X).
(https://www.mediafire.com/convkey/1ecc/fsp3x7bvez8h1316g.jpg)
  Is the same principle used when trying to go beyond the edges of the map... is it possible to implement that?.
Edit.
It would also be great to show a dark transparent layer (like the station cover) to visually indicate that the rest of the map is inaccessible temporarily and restrict the use of any tool beyond the limits, you should return a message if you use a tool .
It would be great to have this in the tutorial scenario, it would make things easier for me.
Regards !!.
Title: Re: Lock the screen position
Post by: ACarlotti on October 07, 2018, 11:07:38 PM
If this is implemented, then it should be in the form of a bounding box (or polygon of some sort) that the player can scroll to see the entirety of, but not scroll any further. Any system of bounding the centre of the view will probably fail when the window size is smaller than expected.
Title: Re: Lock the screen position
Post by: Yona-TYT on October 07, 2018, 11:48:07 PM

@ACarlotti
Do you mean to keep the course in the delimited or fenced region?
In any case, a minimum value can be set for the coordinate delimitations.
Title: Re: Lock the screen position
Post by: ACarlotti on October 08, 2018, 12:03:07 AM
Quote from: Yona-TYT on October 07, 2018, 11:48:07 PMDo you mean to keep the course in the delimited or fenced region?
I don't know what you mean here.
Title: Re: Lock the screen position
Post by: Yona-TYT on October 14, 2018, 12:22:10 PM
Quote from: ACarlotti on October 07, 2018, 11:07:38 PMIf this is implemented, then it should be in the form of a bounding box (or polygon of some sort) that the player can scroll to see the entirety of, but not scroll any further. Any system of bounding the centre of the view will probably fail when the window size is smaller than expected.

Sorry, I was the one who did not understand your message in the first place.

Quote from: ACarlotti on October 08, 2018, 12:03:07 AMI don't know what you mean here.
I was referring to the course that marks the tiles, that can not leave the delimited region.
Title: Re: Lock the screen position
Post by: An_dz on October 15, 2018, 12:41:23 AM
What ACarlotti is saying is that if the API is to set only a center coordinate it will fail if you build the scenario in a 1920x1080 fullscreen but the player is playing in a 800x600 window. You'll see much more area than the user.

So to prevent this happening one would set the area the user can see, with two sets of coordinates to set a rectangle.

Anyway, I don't think there should have an API to prevent the user from going around the map, instead there should have an API that draws a rectagle on the screen to let the user know that the objective will only validate inside that area.
Title: Re: Lock the screen position
Post by: Yona-TYT on October 15, 2018, 03:01:55 AM
I would like the rest of the map to be darkened with a dark transparent cover, as seen in the transparent station coverts.  ;)
Title: Re: Lock the screen position
Post by: Yona-TYT on October 25, 2018, 05:23:59 PM
I was trying to create a function that would shadow the map around a rectangle, but this is very difficult for me.

I know this creates the transparent cover I'm looking for, but I do not know how to make this cover the map completely:

simplan.cc (line 577)==============================================================
for(int halt_count = 0; halt_count < halt_list_count; halt_count++) {
    const FLAGGED_PIXVAL transparent = PLAYER_FLAG | OUTLINE_FLAG | color_idx_to_rgb(halt_list[halt_count]->get_owner()->get_player_color1() + 4);
    display_img_blend( img, xpos, ypos, transparent | TRANSPARENT25_FLAG, 0, 0);
}
Title: Re: Lock the screen position
Post by: An_dz on October 30, 2018, 03:51:41 PM
Shadowing the rest of the map would be too expensive, I think it makes more sense to just draw a thick border.
Title: Re: Lock the screen position
Post by: Yona-TYT on October 30, 2018, 05:30:11 PM
And how can I get that?... ???
Title: Re: Lock the screen position
Post by: An_dz on November 03, 2018, 03:16:19 PM
Hard to tell now without looking the code, but you probably can use the graphics for the cursor border. Take a look in one of the pakset sources and you'll find what graphic I'm telling, it's a bunch of lines in multiple directions.