{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/78867631","id":78867631,"diff_hunk":"@@ -449,81 +842,124 @@ inventory_entry *inventory_selector::find_entry_by_invlet( long invlet ) const\n     return nullptr;\n }\n \n-void inventory_selector::prepare_columns( bool multiselect )\n+void inventory_selector::rearrange_columns()\n {\n-    for( auto &column : columns ) {\n-        column->set_multiselect( multiselect );\n+    if( !own_gear_column.empty() && is_overflown() ) {\n+        own_gear_column.move_entries_to( own_inv_column );\n     }\n \n-    if( custom_column != nullptr ) {\n-        if( columns.empty() || column_can_fit( *custom_column ) ) {\n-            // Make the column second if possible\n-            const auto position = ( !columns.empty() ) ? std::next( columns.begin() ) : columns.begin();\n+    if( !map_column.empty() && is_overflown() ) {\n+        map_column.move_entries_to( own_inv_column );\n+    }\n+}\n \n-            custom_column->set_multiselect( multiselect );\n-            insert_column( position, custom_column );\n-        } else {\n-            columns.front()->add_entries( *custom_column );\n-            custom_column.release();\n-        }\n+void inventory_selector::prepare_layout()\n+{\n+    if( layout_is_valid ) {\n+        return;\n+    }\n+    // This block adds categories and should go before any width evaluations\n+    for( auto &column : columns ) {","path":"src/inventory_ui.cpp","position":770,"original_position":1047,"commit_id":"aa4449e3ea7cba4addb62ca290c4ee5fae60a7ad","original_commit_id":"51559c50461d8a67f3023845db2cf88a59a50474","user":{"login":"mugling","id":12238606,"avatar_url":"https://avatars.githubusercontent.com/u/12238606?v=3","gravatar_id":"","url":"https://api.github.com/users/mugling","html_url":"https://github.com/mugling","followers_url":"https://api.github.com/users/mugling/followers","following_url":"https://api.github.com/users/mugling/following{/other_user}","gists_url":"https://api.github.com/users/mugling/gists{/gist_id}","starred_url":"https://api.github.com/users/mugling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugling/subscriptions","organizations_url":"https://api.github.com/users/mugling/orgs","repos_url":"https://api.github.com/users/mugling/repos","events_url":"https://api.github.com/users/mugling/events{/privacy}","received_events_url":"https://api.github.com/users/mugling/received_events","type":"User","site_admin":false},"body":"Just use `&e`. There isn't a good reason not to","created_at":"2016-09-15T00:04:50Z","updated_at":"2016-09-15T00:13:20Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17765#discussion_r78867631","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/78867631"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17765#discussion_r78867631"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765","id":78359234,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17765","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17765.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17765.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17765","number":17765,"state":"open","locked":false,"title":"[RDY] Customizable inventory menu (kinda framework) with sub columns, disabled items and item sorting","user":{"login":"codemime","id":11905613,"avatar_url":"https://avatars.githubusercontent.com/u/11905613?v=3","gravatar_id":"","url":"https://api.github.com/users/codemime","html_url":"https://github.com/codemime","followers_url":"https://api.github.com/users/codemime/followers","following_url":"https://api.github.com/users/codemime/following{/other_user}","gists_url":"https://api.github.com/users/codemime/gists{/gist_id}","starred_url":"https://api.github.com/users/codemime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codemime/subscriptions","organizations_url":"https://api.github.com/users/codemime/orgs","repos_url":"https://api.github.com/users/codemime/repos","events_url":"https://api.github.com/users/codemime/events{/privacy}","received_events_url":"https://api.github.com/users/codemime/received_events","type":"User","site_admin":false},"body":"Continues #17572.\r\n~~Closes. #17074 (milestone).~~\r\nCloses #17700 (sort order; no game option yet).\r\n~~Will conflict with #17685 (`OPTIONS` map).~~\r\n\r\nFinally the inventory selector code is clean enough to add really new stuff there.\r\n\r\n### Observable behavior\r\n\r\nEach menu has its own preset with sub columns, filtering and sorting functions. Certain items can be disabled on condition (visible but cannot be selected by players). Various information can be shown in customizable sub columns fairly easy. Menu header was slightly redesigned: width and volume are shown on the right and only when needed (simple inventory, dropping, comparison).  EDIT: Custom presets were removed from this PR.\r\n\r\nIf there are no available choices, the appropriate message shows up:\r\n![no_choices](https://cloud.githubusercontent.com/assets/11905613/17032018/29e493da-4f88-11e6-9d88-b09afbb968a5.png)\r\n\r\nColumns have adaptive layout and look good on both low and high window resolutions:\r\n![big_screen](https://cloud.githubusercontent.com/assets/11905613/17031995/0d41f6fa-4f88-11e6-95a8-0723499c41c1.png)\r\n![big_screen2](https://cloud.githubusercontent.com/assets/11905613/17032357/e1c5471e-4f89-11e6-8924-eb8c080e71bf.png)\r\n\r\nWhen only one column is shown, it gets adjusted to the screen width (either shrinks if its wider than the screen or expands if it occupies more than a half of its width). Long entries can \"steal\" some width from adjacent cells when they don't fit:\r\n![stolen](https://cloud.githubusercontent.com/assets/11905613/17032012/21b84cb0-4f88-11e6-82ee-01f02208941f.png)\r\n\r\n### Implementation details\r\n\r\n- Introduced `inventory_selector_preset` class which customizes the menu via inversion of control. It's fairly easy to use: just inherit form it and override any of its functions\r\n- `inventory_filter_preset` is used for compatibility with silent filters\r\n- Items can be sorted using `get_rank()` function of `inventory_selector_preset` class\r\n- New sub-columns (cells) can be added to presets using `append_cell()` function\r\n- `inventory_multiselector` class was factored out of comparison and dropping selectors\r\n- `selection_column` was moved from the header to the cpp file\r\n- All items are now added via `add_item()` and filtered only once, inventory items via `add_character_items()` (which calls `add_item()`). The latter will be able to deal with NPCs in the future (to make #17603 possible)\r\n- Lazy layout/paging recalculations\r\n- Some sanity checks were added\r\n- Columns are now member variables (not shared pointers). That simplifies things\r\n- Item categories are created from prototypes (and inherit their sort ranks)\r\n- Dialog input was encapsulated into `get_input()` function\r\n- Width adjustment works like this:\r\n    - shrinking: shrink the widest cell by 1 and repeat\r\n    - expanding: expand the narrowest cell by 1 and repeat\r\n- Weight/volume stats can be disabled with `set_display_stats()` (enabled by default)\r\n- Other various code improvements.\r\n\r\nSuggestions are welcome as usual.","created_at":"2016-07-21T17:54:28Z","updated_at":"2016-09-15T00:13:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"071cab1b3f00535229ed2781097b1a9c3854ebef","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765/comments","review_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17765/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/aa4449e3ea7cba4addb62ca290c4ee5fae60a7ad","head":{"label":"codemime:ref_inv_n4","ref":"ref_inv_n4","sha":"aa4449e3ea7cba4addb62ca290c4ee5fae60a7ad","user":{"login":"codemime","id":11905613,"avatar_url":"https://avatars.githubusercontent.com/u/11905613?v=3","gravatar_id":"","url":"https://api.github.com/users/codemime","html_url":"https://github.com/codemime","followers_url":"https://api.github.com/users/codemime/followers","following_url":"https://api.github.com/users/codemime/following{/other_user}","gists_url":"https://api.github.com/users/codemime/gists{/gist_id}","starred_url":"https://api.github.com/users/codemime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codemime/subscriptions","organizations_url":"https://api.github.com/users/codemime/orgs","repos_url":"https://api.github.com/users/codemime/repos","events_url":"https://api.github.com/users/codemime/events{/privacy}","received_events_url":"https://api.github.com/users/codemime/received_events","type":"User","site_admin":false},"repo":{"id":50468318,"name":"Cataclysm-DDA","full_name":"codemime/Cataclysm-DDA","owner":{"login":"codemime","id":11905613,"avatar_url":"https://avatars.githubusercontent.com/u/11905613?v=3","gravatar_id":"","url":"https://api.github.com/users/codemime","html_url":"https://github.com/codemime","followers_url":"https://api.github.com/users/codemime/followers","following_url":"https://api.github.com/users/codemime/following{/other_user}","gists_url":"https://api.github.com/users/codemime/gists{/gist_id}","starred_url":"https://api.github.com/users/codemime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codemime/subscriptions","organizations_url":"https://api.github.com/users/codemime/orgs","repos_url":"https://api.github.com/users/codemime/repos","events_url":"https://api.github.com/users/codemime/events{/privacy}","received_events_url":"https://api.github.com/users/codemime/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/codemime/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":true,"url":"https://api.github.com/repos/codemime/Cataclysm-DDA","forks_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/releases{/id}","deployments_url":"https://api.github.com/repos/codemime/Cataclysm-DDA/deployments","created_at":"2016-01-27T00:03:47Z","updated_at":"2016-01-27T00:03:54Z","pushed_at":"2016-09-14T21:40:32Z","git_url":"git://github.com/codemime/Cataclysm-DDA.git","ssh_url":"git@github.com:codemime/Cataclysm-DDA.git","clone_url":"https://github.com/codemime/Cataclysm-DDA.git","svn_url":"https://github.com/codemime/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":771988,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CleverRaven:master","ref":"master","sha":"c9725b69951192640bb1f00bac9261ecbf3aa72c","user":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"repo":{"id":5973855,"name":"Cataclysm-DDA","full_name":"CleverRaven/Cataclysm-DDA","owner":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":false,"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","forks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/releases{/id}","deployments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/deployments","created_at":"2012-09-26T22:57:43Z","updated_at":"2016-09-14T20:40:01Z","pushed_at":"2016-09-15T00:10:16Z","git_url":"git://github.com/CleverRaven/Cataclysm-DDA.git","ssh_url":"git@github.com:CleverRaven/Cataclysm-DDA.git","clone_url":"https://github.com/CleverRaven/Cataclysm-DDA.git","svn_url":"https://github.com/CleverRaven/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":1047807,"stargazers_count":1070,"watchers_count":1070,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":954,"mirror_url":null,"open_issues_count":1336,"forks":954,"open_issues":1336,"watchers":1070,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17765"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17765"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17765/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765/comments"},"review_comment":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17765/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/aa4449e3ea7cba4addb62ca290c4ee5fae60a7ad"}}}}
{"actor":{"display_login":"mugling"}}