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

Regrouping advanced settings #2322

Closed
DorpsGek opened this issue Sep 28, 2008 · 14 comments
Closed

Regrouping advanced settings #2322

DorpsGek opened this issue Sep 28, 2008 · 14 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

Alberth opened the ticket and wrote:

Patch against revision 14405 (h6ef54dd65a97)

Hereby I submit a patch for some code cleaning and extensions to the 'advanced
setting window'. The new facilities are then used to group several settings
closer together. Last but not least a proposal to change the text of a setting

The following patches should be applied in the order indicated.

First a sequence of code changes.

- 01_doxygen.patch: Code-change, ading doxygen strings and a few comments
- 02_widget_name_use.patch: Code-change, use Widget constants + add them as comment in the widget array
- 03_setting_height.patch: Code-change, introduce a constant for height of a single advanced setting entry
- 04_x_start.patch: Code-change, introduce a constant for the x offset in the option panel
- 05_y_start.patch: Code-change, introduce a constant for the y start offset in the option panel
- 06_vardecl_moves.patch: Code-change, move declarations for vars to their first use
- 07_num_entries.patch: Code-change, rename 'num' field to 'num_entries' field to make clear what it means

Next, 4 patches for new functionality.

- 08_count_numentries.patch: Terminate option name list with NULL, and count the entries at run time
- 09_store_ypos.patch: Instead of a fixed y offset for the n'th entry, store the y offset in the entry itself and use it
- 10_optionpanel_maxheight.patch: Instead of computing the height from the patch number count, use the computed y height introduced by the previous patch
- 11_allow_empty_entries.patch: Allow for empty patch names in the variable name list, and add some extra room then in the panel

Finally, shuffling/grouping of existing advanced settings. The first 2 or 3 change only the indicated page, but after that pages exchange options, so sometimes I temporarily move a setting to a page not yet done.

- 12_economy_ai_tabs.patch: Group settings of the economy and competitors tabs
- 13_interface_tab.patch: Group settings of the interface tab
- 14_construction_tab.patch: Group settings of the construction tab
- 15_stations_tab.patch: Group settings of the stations tab
- 16_vehicles_tab.patch: Group settings of the vehicles tab

Finally, a proposal to change one string.

- 17_lang_english.patch: One proposed change in the strings file

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/2322
@DorpsGek
Copy link
Member Author

Alberth wrote:

Here is a .png file with the new advanced setting pages, so you can look at the picture instead of read about them.
You can clearly see the groups of options which imho makes navigating easier.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4792

@DorpsGek
Copy link
Member Author

Rubidium wrote:

Constants like introduced in 03-05 should be capitalized like all other constants.

Further I'm wondering whether the current 'design' (GUI wise) is the best way to show the configuration settings; it scales fairly badly for small windows (this patch seems to make it even worse). So I guess there needs to be a scrollbar when the settings window is too big for the resolution.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4941

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 2, 2008

Alberth wrote:

Second try, against r14542.

I really liked your suggestion. I was also not entirely happy with my solution, as I wanted to add more 'section-like' headings in the window instead of the small amount of white space, but that would blow up the Vehicles tab even more and I could not find a better way.
Your suggestion triggered me to come up with the solution, merging all tabs into a collapsable treeview and a scrollbar for easy moving around!!

As always, we start simple:
- 01_doxygen.patch: 4 simple doxygen additions
- 02_codechange_settingheight.patch: Introduction of SETTING_HEIGHT constant (moved this outside the window since TreeField struct will need it)
- 03_codechange_replace_xconstant.patch: Replacement of a constant with an x+offset, so the patch text will move if the base x changes
- 04_codechange_left_offset.patch: Introduction of SETTINGTREE_LEFT_OFFSET constant
- 05_codechange_top_offset.patch: Introduction of SETTINGTREE_TOP_OFFSET constant
- 06_codestyle.patch: Moved 'page' variable down to just above where it is needed first, moved declarations to first use.

Next two patches introduce DrawPatch() method. First one creates the function, second one fixes the indentation.
Note that this is not the final place of the method, it will be moved again in patch 10b.
- 07a_codechange_drawpatch.patch
- 07b_codechange_drawpatch.patch

The collapsable treeview needs TreeSection and TreeField structs.
- 10a_treeview_code.patch: All TreeSection and TreeField code, except the TreeField::DrawPatch() method.
- 10b_copy_drawpatch.patch: An non-modified copy of the DrawPatch() code to TreeField::DrawPatch(), also shifted 1 indent level (can be done here as it doesn't increase the patch-size)
- 10c_codechange_patch_offset.patch: Replaced patch setting offset numberic constant by TREE_PATCH_TEXT_OFFSET

Next step is a hostile take-over of the current advanced settings window code. Not everything works in-between patches. After 20a and 20b even compilation fails.
- 20a_treeview_global_var.patch: Modify current PatchPages entries to TreeField nodes, resulting a global _treeview var. This one only modifies the declarations, and adds a few TreeSection's (one for each tab, and a root section). Next one does a big change of the contents of all arrays. Code will not compile after applying this patch.
- 20b_treefields_fix.patch: TreeField's need a constructor call. Added around all string constants. After applying this patch, code will not compile, since we have destroyed the PatchPages.
- 20c_display_treeview.patch: To make it compile again, deleting all PatchPage stuff, and add some _treeview calls to get the tree displayed. Removed the DrawPatch() method, and commented click handling and editbox handling out temporarily.

- 21a_clickhandling.patch: Fixing click handling and editbox handling, now using the TreeField's instead of PatchEntry's. Some code is not shifted here, but is done in the next patch.
- 21b_shift_code.patch: Fixing indentation. Note that I didn't shift the code inside the switch-statement.

Everything is quite funcional again, except that the window is not wide enough anymore due to addition of the treeview indenting, and you cannot scroll up and down. This is fixed in the next patch.
- 22_widgets.patch: Change widgets + widget layout so everything fits again and is working properly.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4978

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 2, 2008

Alberth wrote:

The patch shuffling done in the first attempt (patches 12-16) has not been done for the second attempt. I will add them later.
Also, could you please decide about patch 17 of the first attempt?


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4979

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 3, 2008

Alberth wrote:

After a good night sleep, I think patch 20a and further are wrong in the sense that the path taken to introduce the new functionality is too abrupt. I'll try to find another path instead.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4991

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 4, 2008

Alberth wrote:

With the retirement of patches 20+, patches 10[abc] are also obsolete.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4994

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 7, 2008

Alberth wrote:

New path would be by extending PatchPage and PatchEntry.
Before doing that however, first extension of the advanced settings window with a scrollbar, a resize button, and some declarations cleanup.
These changes are after 07b, although they don't directly use that change.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment4997

@DorpsGek
Copy link
Member Author

Alberth wrote:

A rather long sequence of patches to get collapsable nested sub-categories in the advanced setting sindow. Builds on top of 32 above (which bulds on top of 07b of second attempt)

First objective is to construct an interface between the settings-windoW and
the patch-page, so the former doesn't need to know how the latter works.

Moving PatchEntry & PatchPage data struct up in the file without modifications
- 33_moved_datastructs.patch

Name of the patch entry is moved from a seperate array into the PatchEntry
structure. Also, the PatchEntries become statically allocated instead of being
dynamically allocated. This is a patch in 2 parts to make it easier to understand:
- 34a_move_names.patch: Code modifications, except for the constructor call. You need to apply 34b too to make it work again
- 34b_move_names.patch: Adding of explicit TreePatch() call around all element of the (now) PatchEntry arrays.

Moving the initialization of the PatchEntries to a method call. Used this solution rather than in the constructor to prevent dependencies of initialization between load/save part, and PatchEntry arrays initialization at load time (just before main() is called).
- 35_move_init.patch

Code move of window DrawPatch() to PatchEntry::DrawPatch(). Code is not changed otherwise.
- 36_move_drawpatch.patch

PatchEntries should draw themselves
- 37_add_draw.patch

'click' window variable replaced by a pointer + some bits inside the
PatchEntry. Reason is that row numbers in a window will not mean anything any
more with collapsable sub-pages.
- 38_move_depressed.patch

'entry' variable replaced too for the same reason.
- 39_modify_entry.patch

Patch page should draw itself
- 40_move_pagedraw.patch

With recursive collapsable sub-page, an index in the main-page is meaningless. Instead we search for the right entry. It is a bit overkill now, but at 46_subpages patch, we must do this recursively for the correct result.
- 41_abstract_entries.patch

Query the page for its length
- 42_add_length.patch

Create a patch-entry kind field, and move the data of the currently existing kind into d.entry struct
- 43_entrykind.patch

Count rows before and while drawing rows
- 44_draw_row_counting.patch

Count rows to find an entry
- 45_find_entry_counting.patch

Count rows when computing length
- 46_length_counting.patch

Add 2nd kind to PatchEntry (namely a collapsable sub-page), and extend all functions with a 2nd case. Also, handle folding and unfolding in the OnClick() window code
This patch has a 'Signals' sub-page in the Construction page.
- 47_subpages.patch

At this point, everything is working, except
a) unfolded sub-pages are not drawn at a deeper nesting level, so it may be tricky to understand for the user,
b) A lot more sub-pages should be introduced, and current settings should be shuffled a bit (like in the first attempt)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment5023

@DorpsGek
Copy link
Member Author

Alberth wrote:

Two patches to fix the drawing problem mentioned above:

Adding a 'level' byte and 'last_field' bit + initialization
- 48_leveldata.patch

Drawing + handling of indented section levels is a bit more involved.
- Drawing is somewhat complicated by the need to know of all parent levels whether more fields follow at that level (stored in the parent_last integer).
- Click handling has to take the indentation into account
- Window has to be widened by 2 indent levels (2*15 = 30 pixels)
- 49_draw_indented.patch

And as a dessert, a screen-shot of the construction page with an unfolded 'Signals' sub-page.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment5032

@DorpsGek
Copy link
Member Author

Alberth wrote:

Length calculation changed in 47_subpages.patch was not correct, folded sub-pages got always counted as unfolded (causing the window to think there were more rows than in reality). Fix is a two-line patch attached below.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment5033

@DorpsGek
Copy link
Member Author

Alberth wrote:

First step, removing all tabs, and merging them all in a single page (ie an
additional top-level sub-list). The patch is split in 3 parts. The code
compiles and runs between every patch, except that the code looks unfinished.

Remove the buttons, the top-panel where the buttons are displayed in, and their 'case' in the OnClick() method.
- 51a_remove_tabs.patch

Create new sub-list titles, add PatchPage for each tab, add some comments
between the PatchEntry/PatchPage variables for easier navigating, Construct a
new _patches_main main list, and replace the old list of tabs with just the new
one.
The OnClick() code for the PATCHSEL_OPTIONSPANEL is now the only case left, so
the switch is replaced by an if. All code is dedented one TAB (and not further
modified), except for the cases of the inner switch statement which are not
moved (thus fixing the code style of this switch/case).
Obviously, the 'break' and a curly-bracket at the end is also removed.
Finally, the window needs an extra 15 pixels (TREE_WIDTH iirc) for the additional sub-list level.
- 51b_remove_tabs.patch

A list of tabs with 1 entry is not particular useful. Also the 'page' variable in the Window is not needed any more.
- 51c_remove_tabs.patch

The two PatchEntry sub-structures are moved to top-level
- 52_extract_substructs.patch

The 'Signals' sub-page was not according to name style + position of the sub-pages to come.
- 53_move_rename_signals.patch

Second step:
A sequence of option shuffling, and sub-pages creation.
- 54_displayopts_autorenew_servicing.patch
- 55_interaction_airport_town_ai.patch
- 56_cargo_industries.patch
- 57_routing_gamesettings.patch
- 58_trains_moves.patch
- 59_orders_timetables.patch

Afterwards, I checked over the entire patch-sequence (51a-59) that I didn't lose a PatchEntry with a setting in it (I didn't).

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment5061

@DorpsGek
Copy link
Member Author

Alberth wrote:

A composed overview of all pages and sub-pages unfolded.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment5062

@DorpsGek
Copy link
Member Author

DorpsGek commented Jan 3, 2009

Rubidium wrote:

Is there some git/hg repository so I don't need to manually download each of the patches and apply that?


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322#comment5180

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Implemented

Around r14975. Nice job Albert


This comment was imported from FlySpray: https://bugs.openttd.org/task/2322

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant