The International Simutrans Forum

Development => Extension Requests => Topic started by: inkelyad on January 02, 2011, 10:10:22 PM

Title: 'highlight this' API.
Post by: inkelyad on January 02, 2011, 10:10:22 PM
1) We need global
list<obj_besch_t*> highlight_color_a,
list<obj_besch_t*> highlight_color_b,
2)  Some code to do highlighting in main window (like 'show station coverage' do);
3) tool/key to toggle highlighting.

It will be useful API. With this tools can do something like:
Highlight rails build with current tool with color a, all other rails with color b;
Find depts/attraction/etc (just select appropriate build tool)
Highlight ways with speed limit less then...


Title: Re: 'highlight this' API.
Post by: prissi on January 02, 2011, 10:22:14 PM
simdings.h has still four empty flags. If you define two flags and return the correct color in get_outline_color you could get highlighting quite fast. But a useful gui is probably a nightmare.
Title: Re: 'highlight this' API.
Post by: inkelyad on January 02, 2011, 10:34:45 PM
It will not need gui. Each tool can and should fill highlight_color_a, highlight_color_b to do something useful and tool-related.

Title: Re: 'highlight this' API.
Post by: prissi on January 03, 2011, 09:29:46 AM
Each tool will need to search whole maps for things to highlight. This will take quite some time ... (about 1-10s on a 512*512 map.)
Title: Re: 'highlight this' API.
Post by: inkelyad on January 03, 2011, 11:19:52 AM
Quote from: prissi on January 03, 2011, 09:29:46 AM
Each tool will need to search whole maps for things to highlight.
Why? I don't think 'show station coverage' do that. And map window mode switch works faster then that.
Is this impossible?:
1)Tool fill "list of besch to highlight". Or check on flag inside obj_besch_std_name_t (Ex: all rails)
2)When ding/bench is put on screen, we test it against list from(1) and highlight when need.
I don't understand where full map search is here.
Title: Re: 'highlight this' API.
Post by: prissi on January 03, 2011, 01:23:01 PM
The station highlightning is done completely independent of the actual things on a tile. You cannot compare that.

There are several ways to highlight dings. Adding a case statements to the drawing routine doing several compares sounds to me like a not very good way to do this.

You have four bits left in ding_t::flag, without increasing the memory amout (and thus increasing the cpu demand) of a world by 20%. Alternatively you change get_outline_color() for all objects in question (after all, it is a virtual function). That is probably best way.

And you will need a GUI for "Highlight ways with speed limit less then ..." and for setting color or switching it off.
Title: Re: 'highlight this' API.
Post by: inkelyad on January 03, 2011, 01:44:29 PM
Quote from: prissi on January 03, 2011, 01:23:01 PM
Alternatively you change get_outline_color() for all objects in question (after all, it is a virtual function).
Changing virtual function pointer at runtime looks good. Back to C++ manuals for me.
Title: Re: 'highlight this' API.
Post by: prissi on January 03, 2011, 02:01:36 PM
No, the virtual pointer is not really changable at runtime. But you could provide the checking in this function, as those are usually specific to certain kinds of objects.
Title: Re: 'highlight this' API.
Post by: inkelyad on January 03, 2011, 02:18:00 PM
I can replace get_outline_color with static functor object. But I need to test, what way is faster.