Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Town name filtering #6983

Closed
wants to merge 1 commit into from
Closed

Conversation

telk5093
Copy link
Contributor

@telk5093 telk5093 commented Nov 27, 2018

It's my first OpenTTD PR, and please let you know I'm very new to c++ and openttd's codes.
I referenced this code from town_gui.cpp and other's PR and it works, but very strangely.
So please advice your enhanced code, and you can ignore/edit this commit.

This allows filtering town names like below:
image

Copy link
Contributor

@nielsmh nielsmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Overall it looks good, there's a few things you should change, mostly cosmetic.

You also need to change the commit message to follow the scheme used, always starting with a keyword (like Add, Change, Fix), a colon, and then the message. Do this with a commit amend in Git, and force-push your branch. (Amending and force-pushing is often frowned upon, but necessary in this case. Github handles it correctly and updates the PR.)

src/widgets/town_widget.h Outdated Show resolved Hide resolved
src/town_gui.cpp Outdated Show resolved Hide resolved
src/town_gui.cpp Show resolved Hide resolved
src/town_gui.cpp Outdated Show resolved Hide resolved
@telk5093
Copy link
Contributor Author

@nielsmh Thanks for your kind comments. I've corrected, is it okay?

@telk5093 telk5093 changed the title Town name filtering Feature: Town name filtering Nov 28, 2018
@nielsmh
Copy link
Contributor

nielsmh commented Nov 29, 2018

I don't have anything more for now. Will find time to test it later :)

@J0anJosep
Copy link
Contributor

Thanks for the PR.
Each time a new widget is added, run /src/script/api/generate_widget.sh and add the modified lines into your commit.

@telk5093
Copy link
Contributor Author

telk5093 commented Jan 2, 2019

@J0anJosep Thanks for your notice, I committed, is it right?

@LordAro
Copy link
Member

LordAro commented Jan 2, 2019

You'll want to rebase & force-push to merge the commits together, but that's the right idea

@planetmaker
Copy link
Contributor

planetmaker commented Jan 2, 2019

It looks nice. However the sorting doesn't seem to be stable even when I do not change input into the search box (anymore). The resulting list flickers and changes order randomly for me. That doesn't happen with the full list where the entries immediately follow eachother.

I currently can only speculate as to the reasons: I assume a sub-list is generated from the whole list - and display sometimes happens before sorting, but after generation of the sub-list - but most times it happens correctly after sub-list generation and its sorting.

Looks to me you already consider only re-generating the list, when the input field actually changed, though.

Honestly I'm not sure whether this, my observation, is beyond the scope of this patch which just makes use of the existing sort framework. I lean toward "out-of-scope" - yet this makes a bug or race condition visible.

Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per @planetmaker's comments

@telk5093
Copy link
Contributor Author

telk5093 commented Jan 6, 2019

@planetmaker Thanks for your comment, even though I cannot understand 100% what you're meant to because of my lack of english/coding skills.
I'll try to rewrite my code. (of course I think it will take a long time ;p)

@telk5093 telk5093 closed this Jan 6, 2019
@telk5093 telk5093 deleted the master branch January 6, 2019 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants