The International Simutrans Forum

 

Author Topic: Lock the screen position  (Read 562 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1136
    • Simutrans-BLOG
  • Languages: ES
Lock the screen position
« 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).

  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 !!.
« Last Edit: October 07, 2018, 07:38:58 PM by Yona-TYT »

Offline ACarlotti

  • *
  • Posts: 240
Re: Lock the screen position
« Reply #1 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1136
    • Simutrans-BLOG
  • Languages: ES
Re: Lock the screen position
« Reply #2 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.

Offline ACarlotti

  • *
  • Posts: 240
Re: Lock the screen position
« Reply #3 on: October 08, 2018, 12:03:07 AM »
Do you mean to keep the course in the delimited or fenced region?
I don't know what you mean here.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1136
    • Simutrans-BLOG
  • Languages: ES
Re: Lock the screen position
« Reply #4 on: October 14, 2018, 12:22:10 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.

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

I don't know what you mean here.
I was referring to the course that marks the tiles, that can not leave the delimited region.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Lock the screen position
« Reply #5 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1136
    • Simutrans-BLOG
  • Languages: ES
Re: Lock the screen position
« Reply #6 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.  ;)

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1136
    • Simutrans-BLOG
  • Languages: ES
Re: Lock the screen position
« Reply #7 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:
Code: [Select]
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);
}

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Lock the screen position
« Reply #8 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1136
    • Simutrans-BLOG
  • Languages: ES
Re: Lock the screen position
« Reply #9 on: October 30, 2018, 05:30:11 PM »
And how can I get that?... ???

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Lock the screen position
« Reply #10 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.