News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

'highlight this' API.

Started by inkelyad, January 02, 2011, 10:10:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

inkelyad

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



prissi

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.

inkelyad

It will not need gui. Each tool can and should fill highlight_color_a, highlight_color_b to do something useful and tool-related.


prissi

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

inkelyad

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.

prissi

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.

inkelyad

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.

prissi

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.

inkelyad

I can replace get_outline_color with static functor object. But I need to test, what way is faster.