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

Migrate reload ammo selection menu to inventory_selector #70359

Merged
merged 6 commits into from
Jan 18, 2024

Conversation

mqrause
Copy link
Contributor

@mqrause mqrause commented Dec 22, 2023

Summary

Infrastructure "Migrate reload ammo selection menu to inventory_selector"

Purpose of change

Necessary for #69316, also more standardized UI.

Describe the solution

A reconstruction of the old UI within the inventory_selector framework. Changing amount to reload was changed from left/right arrow to the INCREASE_COUNT/DECREASE_COUNT keybinds, which are +/- by default.

Character::select_ammo was made virtual and avatar/npc logic split up accordingly. Avatar now uses the new menu, npc should behave like before.

Reloading attached gunmods required a slightly unoptimal solution, but that should only turn into a problem when the gunmod could be reloaded with the same ammo as the gun itself, because every ammo item can show up in the menu only once currently, preventing you from reloading the gunmod if you could also reload the gun. But I don't think we have a case like that.

Describe alternatives you've considered

Testing

Reloaded a revolver, a magazine and a gun that takes a magazine. Reload an M4 with attached grenade launcher with ammo, magazine and grenades. There are surely some cases I didn't test, but hopefully nothing gamebreaking.

Additional context

Sidenote: #58473 should be very easy to fix with the added helpers from this.

Loading magazine into gun
grafik

Loading ammo into magazine with amount on highlighted ammo reduced
grafik

Loading M4 with grenade launcher
grafik

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Dec 22, 2023
src/game_inventory.cpp Show resolved Hide resolved
src/game_inventory.cpp Outdated Show resolved Hide resolved
src/npcmove.cpp Outdated Show resolved Hide resolved
@mqrause mqrause force-pushed the reload_inv_selector branch from e90232b to 2e00b40 Compare January 5, 2024 17:42
@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [JSON] Changes (can be) made in JSON Monsters Monsters both friendly and unfriendly. Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [Markdown] Markdown issues and PRs labels Jan 5, 2024
@github-actions github-actions bot requested a review from KorGgenT January 5, 2024 17:42
data/json/monsters/zed_dormant.json Outdated Show resolved Hide resolved
data/json/monsters/zed_dormant.json Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the json-styled JSON lint passed, label assigned by github actions label Jan 5, 2024
@mqrause mqrause force-pushed the reload_inv_selector branch from 2e00b40 to aa54f1b Compare January 5, 2024 17:46
@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Jan 5, 2024
@mqrause mqrause force-pushed the reload_inv_selector branch from aa54f1b to 2bfa948 Compare January 9, 2024 23:17
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions Code: Tests Measurement, self-control, statistics, balancing. labels Jan 10, 2024
@mqrause mqrause force-pushed the reload_inv_selector branch 2 times, most recently from 3ea474d to 024d6fc Compare January 13, 2024 13:35
@mqrause mqrause force-pushed the reload_inv_selector branch from 024d6fc to e441c35 Compare January 14, 2024 02:23
@Maleclypse Maleclypse merged commit f2c8c58 into CleverRaven:master Jan 18, 2024
24 of 26 checks passed
@mqrause mqrause deleted the reload_inv_selector branch January 18, 2024 05:06
@SurFlurer
Copy link
Contributor

This change seems to break how speedloader works.

@mqrause
Copy link
Contributor Author

mqrause commented Feb 12, 2024

I dunno, maybe? It should only affect ammo selection and not actual reloading, though.

@osuphobia
Copy link
Contributor

Reloading attached gunmods required a slightly unoptimal solution, but that should only turn into a problem when the gunmod could be reloaded with the same ammo as the gun itself, because every ammo item can show up in the menu only once currently, preventing you from reloading the gunmod if you could also reload the gun. But I don't think we have a case like that.

There are cases that this reconstruction affects. Kel-Tec shotguns have more than one magazine, and the sub-mags are gunmods, now you can only reload this kind of sub-mags after the main magazine is fully reloaded. Same for cases like compound crossbow with rail-mounted crossbow attached, M1897 Trench Gun with modified masterkey shotgun attached, etc.

@osuphobia osuphobia mentioned this pull request May 12, 2024
Procyonae pushed a commit to Procyonae/Cataclysm-DDA that referenced this pull request May 24, 2024
Migrate reload ammo selection menu to inventory_selector
Maleclypse pushed a commit that referenced this pull request May 26, 2024
* Merge pull request #70359 from mqrause/reload_inv_selector

Migrate reload ammo selection menu to inventory_selector

* DEBUG_ONLY flag for more consistency in "seeing this is a bug" (#71065)

* DEBUG_ONLY flag

* apparently a fake item being wood triggers the density tests

---------

Co-authored-by: mqrause <[email protected]>
Co-authored-by: NetSysFire <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.H Backported 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: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Info / User Interface Game - player communication, menus, etc. Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs Monsters Monsters both friendly and unfriendly. NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants