[Patch] Filter Sign List (by typing a filter string) - v40

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
luk3Z
Traffic Manager
Traffic Manager
Posts: 197
Joined: 25 Dec 2005 17:42
Location: Kielce, Poland (Mars sometimes)

Re: [Patch] Filter Sign List (by typing a filter string)

Post by luk3Z »

What is probability that Filter Sign List will be part of official OTTD ?
I think all good ideas should be implemented and can be moddable via openttd.cfg
Find new graphics easier:
GRFCrawler -> http://grfcrawler.tt-forums.net
BaNaNaS -> https://bananas.openttd.org/
32 bit gfx in OTTD (32bpp) -> https://wiki.openttd.org/en/Community/N ... 20graphics
TTDPatch 2.6 -> viewtopic.php?f=19&t=67694
How to subtract tax from income (workaround) -> viewtopic.php?t=89763&start=20
How to ban distance from income -> Simple Cargo Decay Override
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Terkhen »

Zuu wrote:I'm not really happy with the InitializeFilterTextWidget() function being called both for initializing the text widget and for clearing the text in it. I don't know enough about the string system in OpenTTD to make something really good here, so if someone has better knowledge some help on this matter would be welcome.
I suggest that you check the changes to town_gui.cpp at r17612 . The added feature is similar, it uses the function "void FoundTownWindow::RandomTownName()" both for initializing the text widget and clearing it.
Zuu wrote:Other ideas I have is to leave the sign window as it is and introduce a new window that contains all signs, station names, towns etc. which will have the filtering feature of this patch as well as buttons at the top for enabling/disabling the different sources of strings.
This idea is very interesting. To avoid confusion, each string should include an icon to know its tipe. Otherwise, you can get duplicated entries (a town and a station with the town's name, for example).
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: [Patch] Filter Sign List (by typing a filter string)

Post by petert »

luk3Z wrote:What is probability that Filter Sign List will be part of official OTTD ?
I think all good ideas should be implemented and can be moddable via openttd.cfg
As do I, but there are things that need to happen before a patch can go into trunk. One such being that it is finished.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Zuu »

luk3Z wrote:What is probability that Filter Sign List will be part of official OTTD ?
I think all good ideas should be implemented and can be moddable via openttd.cfg
Why and what should be configured by openttd.cfg in your opinion?
Terkhen wrote:
Zuu wrote:I'm not really happy with the InitializeFilterTextWidget() function being called both for initializing the text widget and for clearing the text in it. I don't know enough about the string system in OpenTTD to make something really good here, so if someone has better knowledge some help on this matter would be welcome.
I suggest that you check the changes to town_gui.cpp at r17612 . The added feature is similar, it uses the function "void FoundTownWindow::RandomTownName()" both for initializing the text widget and clearing it.
Thank you. I'll take a look on that code.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
luk3Z
Traffic Manager
Traffic Manager
Posts: 197
Joined: 25 Dec 2005 17:42
Location: Kielce, Poland (Mars sometimes)

Re: [Patch] Filter Sign List (by typing a filter string)

Post by luk3Z »

Zuu wrote:
luk3Z wrote:What is probability that Filter Sign List will be part of official OTTD ?
I think all good ideas should be implemented and can be moddable via openttd.cfg
Why and what should be configured by openttd.cfg in your opinion?

(...)
Because OTTD lack of some good ideas which are posted on the forum.
I was in shock when I back to this forum after 8 months and I saw all this improvements as "patch" ;)
All good ideas should be available in game and configurable via parameters (also on/off) or maybe "easy update" something like addons in Firefox :)
IMHO OTTD have a lot of addons and too many threads on the forum (+too many binaries), so it is hard to find something. Anyway Grfcrawler is really helpful (also Online Content option in game).
Find new graphics easier:
GRFCrawler -> http://grfcrawler.tt-forums.net
BaNaNaS -> https://bananas.openttd.org/
32 bit gfx in OTTD (32bpp) -> https://wiki.openttd.org/en/Community/N ... 20graphics
TTDPatch 2.6 -> viewtopic.php?f=19&t=67694
How to subtract tax from income (workaround) -> viewtopic.php?t=89763&start=20
How to ban distance from income -> Simple Cargo Decay Override
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Zuu »

I'm still not convinced. Why should there be an advanced option to turn off the filter function? Do you really think it is in the way, if you don't want to use it? Compared to how much in the way the option would be in the advanced settings window making it even harder to find the existing options in there?
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Terkhen »

luk3Z: There are a lot of discussion threads about converting patches to "add-ons", and why that is not desirable and almost impossible. Search for them: you will find good explanations about this suggestion.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Zuu »

Using Terkhen's advice I've updated the text initializing/clearing code.
Attachments
filter_sign_list28_r18678.patch
(12.04 KiB) Downloaded 94 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
luk3Z
Traffic Manager
Traffic Manager
Posts: 197
Joined: 25 Dec 2005 17:42
Location: Kielce, Poland (Mars sometimes)

Re: [Patch] Filter Sign List (by typing a filter string)

Post by luk3Z »

Zuu wrote:I'm still not convinced. Why should there be an advanced option to turn off the filter function? Do you really think it is in the way, if you don't want to use it? Compared to how much in the way the option would be in the advanced settings window making it even harder to find the existing options in there?
I mean about more advanced ideas to be turn on/off when they radical change (e.g. narrow gauge rails instead of maglev) aspect of the game.
Filter Sign List should be part of OTTD and built-in as improvement.
Find new graphics easier:
GRFCrawler -> http://grfcrawler.tt-forums.net
BaNaNaS -> https://bananas.openttd.org/
32 bit gfx in OTTD (32bpp) -> https://wiki.openttd.org/en/Community/N ... 20graphics
TTDPatch 2.6 -> viewtopic.php?f=19&t=67694
How to subtract tax from income (workaround) -> viewtopic.php?t=89763&start=20
How to ban distance from income -> Simple Cargo Decay Override
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Zuu »

A small update fixing an error in the coding style.
Attachments
filter_sign_list29_r18696.patch
(12.05 KiB) Downloaded 103 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Zuu »

I've now split the patch into two parts. Part one containing all the basic functionality and part two containing the ability to make selections within the filter result with the arrow keys.

These patches can be found at the new FS task: FS#3472.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string)

Post by Zuu »

Version 35

Changes:
  • Changed the widget structure a bit so that at the top level there is a horizontal container and then two vertical containers. This makes the gui more consistent with eg. the town list. See this image:
    SignListPatch35.png
    SignListPatch35.png (17.12 KiB) Viewed 2703 times
  • Changed the storage of the selected item to a pointer to a sign instead of an index in the list. Along with this the behavior has been changed to be more consistent with the content download window.
  • r19523 (though nothing in the patch had to be changed since version 34 to support r19523 compared to the rev that version 34 was made for)
I would be happy if you can test this patch and report if you found any bugs that got introduced by my last changes. I've done some testing myself so there should hopefully not be anything.

I've made the design decision to not scroll to the selected sign if the sign list is rebuilt because of to the window external factors such as a sign got added/removed/changed. This as it could be annoying if you first selected a sign with the keys and then decide to use the scroll bar with the mouse to view some other signs in a multiplayer game. If there is a general opinion (or from the devs) that it should be the other way, I'll happily change it.

Special Keys (as a reminder and for those who have not followed the FS task)
Ctrl + l = bring up the sign list window
f = focus the edit box of the sign list window

When the edit box is selected:
Up/Down = select previous/next sign in the list
Page Up/Down = go up/down a page in the list
Ctrl + Home/End = go to the beginning/end of the list
Enter = Move viewport to selected sign or the first one in the list if none of them are selected
Escape = Clear the filter and unfocus the edit box

The reason for Ctrl + Home/End is that without Ctrl the home/end keys will move the caret of the text edit widget to the beginning/end.

Patch parts (as a reminder or for new users)
part1 = Sign filtering, but no selection within the results.
part2 = Adds selection within the result using up/down/page up/page down/ctrl + home/ctrl + end keys.

The part1and2 edition of the patch includes both parts and is the one recommended for testing. The individual parts are there to keep the two parts separated for a possible future trunk inclusion.

Patch download
Head over to FS#3472 and find the last version at the bottom of the comments

Binary
A binary of r19523 with this patch applied is here attached. The "M" has intentionally been removed so that you can test this on the current #openttdcoop game that uses this revision.
r19523-filter_sign_list35-win32.zip
(3.77 MiB) Downloaded 106 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string) - v35

Post by Zuu »

I've been working on and off on this patch since last code review. See the comments at flyspray #3472 for more details. I would say the patch is ready for further review.


Expected behaviour: (with part 1 only applied)
  • Global hotkey: Ctrl + l - opens sign list
  • In the sign list window there are three new controls
    • Filter edit box - type a filter here
    • Match case button - toggle if filter should be case sensitive (the state of this button is remembered as a static var, but is not saved to config)
    • Clear filter button - erases the filter
  • Local hotkey (only when sign window is open): f - focus filter edit box
All signs that contains the filter text will be included in the sign list. Eg. if the filter text is "blue", then both "blue car" and "my blue car" will be included but not "blu".

When you have the filter box focused:
  • Enter = Jump to first displayed sign
  • Escape = clear filter
If part 2 is also applied
(only different behaviour is listed here)

When filter edit box is focused:
  • Arrow Up/Down = Select previous/next sign in the sign list. (selected sign is shown in blue. by default there is no selection until a movement key is pressed)
  • Page Up/Down = Move selection up/down a whole page
  • Ctrl + Home/End = Move selection to begin/end of list
  • Enter = Jump to selected sign or the first one in the list in case there is no selected sign.
When you have a selected sign and new signs are added (that are accepted by the filter), that changes the list of signs. To make sure the selected sign do not move out of the view, it will be scrolled to in OnInvalidate.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: [Patch] Filter Sign List (by typing a filter string) - v37

Post by Ammler »

patch update to r20146 (hotkeys)
Attachments
FilterSignList.diff
(14.86 KiB) Downloaded 100 times
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string) - v37

Post by Zuu »

Thanks Ammler. I started on a update, but put it on hold as I was not sure if Yexo's commit series related to the hotkey feature was done or not. That said, it looks now like he is done and I can finish up my update and diff it against yours to see if I or you has missed anything. Anyway I will need to provide both parts of the patch to not lose that division again.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: [Patch] Filter Sign List (by typing a filter string) - v37

Post by Ammler »

my patch was not mean to be a kind of official (that is why I didn't post to FS), I just liked to contribute my update to this nice patch, since we use MQ, I could split our patch too.

A little Feature Request ;-)
With Hotkey ctrl-l, it opens the signlist, it would be nice, if the filter text field would get focus then, imo.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string) - v37

Post by Zuu »

You can already use the 'f' key after ctrl + l to focus the edit box. I generally don't think that windows that has many purposes should auto-focus the edit box as that blocks other hotkeys from being used.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string) - v39

Post by Zuu »

I have now updated the patch so that it works with current trunk.

Version 38
Updated to r20394

Since some time ago, the sign list window has a configurable hotkey hook in trunk. (no hotkey is assigned by default) Therefore, I have removed the Ctrl+L hotkey altogether from this patch, as you can set that yourself in your hotkeys.cfg files. If there is a popular demand then perhaps a default hotkey can be set later.

Version 39
The F-hotkey that is used to focus the edit box has been made configurable.

Tip: You can set "GLOBAL+CTRL+L" as hotkey in your hotkeys.cfg file, and then that hotkey will open the sign list window and then focus the filter edit box.

Download
The patch files are found in the FS task: http://bugs.openttd.org/task/3472
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string) - v40

Post by Zuu »

Update - version 40

Version 40 has now been posted to the FS task. There you also find the complete change log. It is mostly changes in response to a review by Terkhen. When signs are clicked they will now get selected and when you clear the filter, the selection will stay.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Filter Sign List (by typing a filter string) - v40

Post by Zuu »

Some great news today: the first part of this patch was committed to trunk by Terkhen. (r20516 and r20517) :-D The second part has some issues that has to be solved (see comment by Terkhen at the FS task).

With the first part it is possible to filter the sign list and (when the edit box is selected) hit Enter/Return to jump to the first sign in the list. The second part of the patch that has NOT been committed adds the possibility to select signs within the result with the arrow keys so that you can jump to any sign within the results using the keyboard only.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 15 guests