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

Rewrite and migrate V menu to ImGui #55503

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mqrause
Copy link
Contributor

@mqrause mqrause commented Feb 19, 2022

Summary

Infrastructure "Rewrite and migrate V menu to ImGui"

Purpose of change

Migrate to ImGui and increase maintainability and expandability.

Describe the solution

Completely remake everything using ImGui.
Structurally this is heavily reliant on code I wrote when I started this before ImGui two years ago. It might be a good idea to refactor some of that, but for now I mostly want to get it functional.

Describe alternatives you've considered

There is no alternative (except for implementation details).

Testing

Press V and play around with it.

Additional context

Currently wip. Some basic functionality is implemented, so interested people can check it out and give feedback. The terrain/furniture tab won't be a part of the final version of this PR but is going to be added in another one.

@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Feb 19, 2022
@mqrause mqrause force-pushed the vmenu_rewrite branch 7 times, most recently from b7854a4 to 121194d Compare February 19, 2022 07:57
@NetSysFire NetSysFire added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. labels Feb 19, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 19, 2022
@mqrause mqrause force-pushed the vmenu_rewrite branch 2 times, most recently from 05357ce to 0bf3591 Compare February 20, 2022 10:12
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 20, 2022
@lgtm-com
Copy link

lgtm-com bot commented Feb 20, 2022

This pull request introduces 3 alerts when merging 0bf3591 into f889ed9 - view on LGTM.com

new alerts:

  • 3 for Empty branch of conditional

@lgtm-com
Copy link

lgtm-com bot commented Feb 21, 2022

This pull request introduces 3 alerts when merging cb976c3 into d055515 - view on LGTM.com

new alerts:

  • 2 for Constant return type on member
  • 1 for Empty branch of conditional

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 21, 2022
@mqrause mqrause force-pushed the vmenu_rewrite branch 2 times, most recently from d39553d to 8c02583 Compare February 21, 2022 10:49
@lgtm-com
Copy link

lgtm-com bot commented Feb 21, 2022

This pull request introduces 1 alert when merging 8c02583 into 158205f - view on LGTM.com

new alerts:

  • 1 for Empty branch of conditional

@mqrause mqrause force-pushed the vmenu_rewrite branch 2 times, most recently from 590cff8 to 9e5eeb2 Compare February 25, 2022 15:02
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 25, 2022
@mqrause mqrause force-pushed the vmenu_rewrite branch 2 times, most recently from 4618af9 to a73ed64 Compare February 25, 2022 19:13
@Zireael07
Copy link
Contributor

Do we have a 'salvageable' label for PRs?

@mqrause
Copy link
Contributor Author

mqrause commented Dec 6, 2022

I think I just need to ask a maintainer to reopen it when I continue working on it.

@Night-Pryanik Night-Pryanik reopened this Dec 6, 2022
@github-actions github-actions bot removed the stale Closed for lack of activity, but still valid. label Dec 6, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

@github-actions github-actions bot added the stale Closed for lack of activity, but still valid. label Jan 5, 2023
@Night-Pryanik Night-Pryanik added (P5 - Long-term) Long-term WIP, may stay on the list for a while. and removed stale Closed for lack of activity, but still valid. labels Jan 5, 2023
@mqrause mqrause changed the title [CR] Rewrite and expand the V menu Rewrite and migrate V menu to ImGui Mar 11, 2024
This was referenced May 1, 2024
Copy link
Contributor

@db48x db48x left a comment

Choose a reason for hiding this comment

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

I‌ know that you’re not finished yet, but I like what you’re doing and want to help you get it right. Here are a few comments about things that I‌ noticed as I‌ read the code.

src/surroundings_menu.cpp Outdated Show resolved Hide resolved
const Character &you = get_player_character();
const bool inattentive = you.has_trait( trait_INATTENTIVE );
bool sees = mon->sees( you ) && !inattentive;
cataimgui::draw_colored_text( sees ? "!" : " ", c_yellow );
Copy link
Contributor

Choose a reason for hiding this comment

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

When possible, prefer to just call ImGui::TextColored instead, as it does less work than cataimuig::draw_colored_text.

if( bar_width < bar_max_width ) {
hp_text += "<color_c_white>";
for( int i = bar_max_width - bar_width; i > 0; i-- ) {
hp_text += ".";
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to just call ImGui::TextUnformatted in a loop than to repeatedly append to a string.

src/surroundings_menu.cpp Outdated Show resolved Hide resolved
Comment on lines +1116 to +1045
switch( selected_tab ) {
case surroundings_menu_tab_enum::items:
item_data.selected_entry->select_next();
break;
case surroundings_menu_tab_enum::monsters:
monster_data.selected_entry->select_next();
break;
case surroundings_menu_tab_enum::terfurn:
terfurn_data.selected_entry->select_next();
break;
default:
debugmsg( "invalid tab selected" );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This and every other method here seem very verbose and duplicative. Perhaps something like this would be better:

   tab_data list;
   switch( selected_tab ) {
        case surroundings_menu_tab_enum::items:
            list = item_data;
            break;
        case surroundings_menu_tab_enum::monsters:
            list = monster_data;
            break;
        case surroundings_menu_tab_enum::terfurn:
            list = terfurn_data;
            break;
        default:
            debugmsg( "invalid tab selected" );
    }
    list.selected_entry->select_next();

They could be shortened further by putting the switch into a common method, perhaps called get_currently_selected_list. Then it would just be:

   get_currently_selected_list().selected_entry->select_next();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of that can be simplified, yes. I did so with the filtering for example. But for some others it isn't that easy, because the tabs have different underlying data types (item, Creature, mapdata_common_t).

@mqrause
Copy link
Contributor Author

mqrause commented Sep 6, 2024

Yeah, it's still very WIP, but that's good feedback!

@mqrause mqrause force-pushed the vmenu_rewrite branch 2 times, most recently from 29b141c to ee28e11 Compare October 8, 2024 05:56
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 8, 2024
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 9, 2024
@mqrause mqrause mentioned this pull request Nov 14, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Tooling Tooling that is not part of the main game but is part of the repo. <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions (P5 - Long-term) Long-term WIP, may stay on the list for a while.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants