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

Implement a better way to wrap text containing color tags #76513

Merged
merged 3 commits into from
Nov 9, 2024

Conversation

db48x
Copy link
Contributor

@db48x db48x commented Sep 18, 2024

Summary

Interface "Improved text wrapping in spellbook and spellcasting menus"

Purpose of change

Long strings that need to wrap onto multiple lines and also contain color codes are hard to wrap correctly. This gets us most of the way to a correct solution.

It also lets us draw text with fewer allocations, allowing us to gradually get away from creating strings with color tags only to throw them away.

Fixes #77297
Also Fixes #76298
Also fixes #75901

Testing

Best place to test it is in the spellcasting window, using psi abilities. These frequently include color.

Additional context

This isn’t a perfect solution. It relies on ImGui’s built‐in text wrapping in several significant ways, and this comes at the cost of some remaining imperfections. Luckily these imperfections are less intrusive than the existing problems, and we can fix them as we have time and inclination.

@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` labels Sep 18, 2024
@github-actions github-actions bot requested a review from KorGgenT September 18, 2024 09:00
@github-actions github-actions bot added the <Bugfix> This is a fix for a bug (or closes open issue) label Sep 18, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

[JSON & C++ formatters](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/DEVELOPER_TOOLING.md)

[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::cyan( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::magenta( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::brown( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::light_red( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::light_green( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::light_blue( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::light_cyan( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::pink( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::yellow( std::string_view str ) {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::spaced() {


[JSON & C++ formatters] reported by reviewdog 🐶

Paragraph *Paragraph::separated() {


[JSON & C++ formatters] reported by reviewdog 🐶

static void TextEx( const std::string_view str, float wrap_width, uint32_t color ) {


[JSON & C++ formatters] reported by reviewdog 🐶

float widthRemaining = ImGui::CalcWrapWidthForPos(ImGui::GetCursorScreenPos(), wrap_width);


[JSON & C++ formatters] reported by reviewdog 🐶

static void TextSegmentEx( const Segment &seg, float wrap_width, bool styled) {


[JSON & C++ formatters] reported by reviewdog 🐶

void TextColoredParagraph( nc_color default_color, const std::string_view str, std::optional<Segment> value, float wrap_width ) {


[JSON & C++ formatters] reported by reviewdog 🐶


[JSON & C++ formatters] reported by reviewdog 🐶

void TextColoredParagraph( nc_color color, std::string_view str, std::optional<Segment> value = std::nullopt, float wrap_width = 0.0f );


[JSON & C++ formatters] reported by reviewdog 🐶

info_size.y -= (3.0*ImGui::GetTextLineHeightWithSpacing()) - ImGui::GetFrameHeightWithSpacing();

@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Sep 18, 2024
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Sep 18, 2024
src/main_menu.cpp Outdated Show resolved Hide resolved
src/main_menu.cpp Outdated Show resolved Hide resolved
src/text.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds astyled astyled PR, label is assigned by github actions and removed astyled astyled PR, label is assigned by github actions labels Sep 19, 2024
src/main_menu.cpp Outdated Show resolved Hide resolved
src/main_menu.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 19, 2024
@db48x
Copy link
Contributor Author

db48x commented Sep 19, 2024

Oops. Dumb mistake; I probably should have just left it until the morning when I could think more clearly.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 19, 2024
@Night-Pryanik
Copy link

Should this also fix #75901?

@db48x
Copy link
Contributor Author

db48x commented Sep 21, 2024

It does; good catch. Weirdly I've never actually seen that bug report. I wonder how many more there are that I haven’t noticed because they don’t use the correct keywords.

@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 21, 2024
@db48x
Copy link
Contributor Author

db48x commented Sep 21, 2024

Looks like a spurious build failure to me.

@CLIDragon
Copy link
Contributor

I would appreciate documenting that BeginRightAlign requires calling EndRightAlign if it succeeds.

You mention that this leaves remaining imperfections - what are they?

@db48x
Copy link
Contributor Author

db48x commented Sep 23, 2024

Perhaps the most obvious flaw is that at certain wrap widths the first word of a segment will not be word–wrapped but instead will be split across two lines. This is due to a design decision to allow text rendering to make progress even if ImGui is asked to render it in a space too narrow for a whole word.

Screenshot from 2024-09-22 20-21-36

Fixing this is doable but not a high priority at the moment. The fix involves duplicating the ImGui methods that we currently call and tweaking their implementation. We could of course just modify ImGui directly, but that makes upgrading more difficult. Because we don't currently allow the user to resize any ImGui windows it’ll probably never actually come up.

There is also a really funny–looking problem that happens when a paragraph contains embedded newlines. Getting the correct rendering in that case merely requires the caller to split their strings if they contain any newlines. This is no great hardship, but I would prefer the API to handle it more gracefully. Fixing this is again doable, and again it’ll need to be done by duplicating and tweaking some of the ImGui methods that we call.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 28, 2024
@db48x
Copy link
Contributor Author

db48x commented Oct 12, 2024

@kevingranade, is there anything else that needs to be done before this can be merged?

@sparr
Copy link
Member

sparr commented Oct 19, 2024

attempting to build this PR on Linux with clang 18.1.8 produces

... many earlier lines of compile ...
CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_ctime,include_file_mtime ccache clang++  -o cataclysm-tiles obj/tiles/debug.o obj/tiles/translations.o obj/tiles/string_formatter.o obj/tiles/output.o obj/tiles/character.o obj/tiles/item.o obj/tiles/map.o obj/tiles/point.o obj/tiles/rng.o obj/tiles/game.o obj/tiles/cata_utility.o obj/tiles/calendar.o obj/tiles/json.o obj/tiles/avatar.o obj/tiles/units.o obj/tiles/color.o obj/tiles/options.o obj/tiles/messages.o obj/tiles/itype.o obj/tiles/npc.o obj/tiles/generic_factory.o obj/tiles/vehicle.o obj/tiles/ui_manager.o obj/tiles/line.o obj/tiles/ui.o obj/tiles/creature.o obj/tiles/monster.o obj/tiles/mapdata.o obj/tiles/flag.o obj/tiles/mtype.o obj/tiles/input_context.o obj/tiles/catacharset.o obj/tiles/creature_tracker.o obj/tiles/overmapbuffer.o obj/tiles/coordinates.o obj/tiles/bodypart.o obj/tiles/flexbuffer_json.o obj/tiles/veh_type.o obj/tiles/sounds.o obj/tiles/inventory.o obj/tiles/cached_options.o obj/tiles/mutation.o obj/tiles/item_location.o obj/tiles/weather.o obj/tiles/input.o obj/tiles/field_type.o obj/tiles/string_input_popup.o obj/tiles/event.o obj/tiles/skill.o obj/tiles/player_activity.o obj/tiles/event_bus.o obj/tiles/path_info.o obj/tiles/effect.o obj/tiles/trap.o obj/tiles/text_snippets.o obj/tiles/overmap.o obj/tiles/character_id.o obj/tiles/damage.o obj/tiles/units_utility.o obj/tiles/mission.o obj/tiles/filesystem.o obj/tiles/requirements.o obj/tiles/bionics.o obj/tiles/activity_type.o obj/tiles/magic.o obj/tiles/localized_comparator.o obj/tiles/init.o obj/tiles/effect_on_condition.o obj/tiles/translation.o obj/tiles/faction.o obj/tiles/clzones.o obj/tiles/assign.o obj/tiles/item_pocket.o obj/tiles/item_group.o obj/tiles/recipe.o obj/tiles/game_inventory.o obj/tiles/mongroup.o obj/tiles/condition.o obj/tiles/action.o obj/tiles/item_factory.o obj/tiles/field.o obj/tiles/coordinate_conversions.o obj/tiles/recipe_dictionary.o obj/tiles/popup.o obj/tiles/explosion.o obj/tiles/character_martial_arts.o obj/tiles/magic_enchantment.o obj/tiles/iuse.o obj/tiles/martialarts.o obj/tiles/character_attire.o obj/tiles/cata_imgui.o obj/tiles/sdltiles.o obj/tiles/projectile.o obj/tiles/item_stack.o obj/tiles/city.o obj/tiles/weather_type.o obj/tiles/visitable.o obj/tiles/vehicle_selector.o obj/tiles/proficiency.o obj/tiles/iuse_actor.o obj/tiles/item_category.o obj/tiles/submap.o obj/tiles/stomach.o obj/tiles/map_selector.o obj/tiles/display.o obj/tiles/activity_handlers.o obj/tiles/tileray.o obj/tiles/material.o obj/tiles/json_loader.o obj/tiles/basecamp.o obj/tiles/worldfactory.o obj/tiles/vitamin.o obj/tiles/timed_event.o obj/tiles/iexamine.o obj/tiles/wcwidth.o obj/tiles/mod_manager.o obj/tiles/item_contents.o obj/tiles/profession.o obj/tiles/fault.o obj/tiles/construction.o obj/tiles/achievement.o obj/tiles/scent_map.o obj/tiles/mapbuffer.o obj/tiles/kill_tracker.o obj/tiles/harvest.o obj/tiles/auto_pickup.o obj/tiles/ammo.o obj/tiles/try_parse_integer.o obj/tiles/sdl_wrappers.o obj/tiles/ranged.o obj/tiles/mapgen_functions.o obj/tiles/map_extras.o obj/tiles/handle_liquid.o obj/tiles/fungal_effects.o obj/tiles/cata_variant.o obj/tiles/avatar_action.o obj/tiles/stats_tracker.o obj/tiles/relic.o obj/tiles/move_mode.o obj/tiles/memorial_logger.o obj/tiles/inventory_ui.o obj/tiles/weather_gen.o obj/tiles/weakpoint.o obj/tiles/teleport.o obj/tiles/regional_settings.o obj/tiles/pathfinding.o obj/tiles/panels.o obj/tiles/overmap_ui.o obj/tiles/npctrade.o obj/tiles/npctalk.o obj/tiles/monstergenerator.o obj/tiles/gates.o obj/tiles/game_ui.o obj/tiles/effect_source.o obj/tiles/dialogue_chatbin.o obj/tiles/debug_menu.o obj/tiles/cursesport.o obj/tiles/cata_tiles.o obj/tiles/addiction.o obj/tiles/scenario.o obj/tiles/mapgen.o obj/tiles/level_cache.o obj/tiles/help.o obj/tiles/dispersion.o obj/tiles/craft_command.o obj/tiles/computer.o obj/tiles/bodygraph.o obj/tiles/veh_interact.o obj/tiles/subbodypart.o obj/tiles/string_id.o obj/tiles/sdl_utils.o obj/tiles/music.o obj/tiles/mapsharing.o obj/tiles/iteminfo_query.o obj/tiles/behavior.o obj/tiles/vehicle_group.o obj/tiles/recipe_groups.o obj/tiles/past_games_info.o obj/tiles/morale_types.o obj/tiles/map_memory.o obj/tiles/mapgendata.o obj/tiles/lightmap.o obj/tiles/item_search.o obj/tiles/item_components.o obj/tiles/event_statistics.o obj/tiles/dialogue_helpers.o obj/tiles/crafting_gui.o obj/tiles/construction_group.o obj/tiles/ballistics.o obj/tiles/veh_utils.o obj/tiles/veh_appliance.o obj/tiles/trait_group.o obj/tiles/system_locale.o obj/tiles/start_location.o obj/tiles/shadowcasting.o obj/tiles/sdlsound.o obj/tiles/safe_reference.o obj/tiles/safemode_ui.o obj/tiles/pickup.o obj/tiles/past_achievements_info.o obj/tiles/overmap_location.o obj/tiles/npctrade_utils.o obj/tiles/npc_class.o obj/tiles/morale.o obj/tiles/monfaction.o obj/tiles/mission_companion.o obj/tiles/mattack_actors.o obj/tiles/item_tname.o obj/tiles/gamemode.o obj/tiles/font_loader.o obj/tiles/faction_camp.o obj/tiles/diary.o obj/tiles/crafting.o obj/tiles/contents_change_handler.o obj/tiles/auto_note.o obj/tiles/ascii_art.o obj/tiles/anatomy.o obj/tiles/ammo_effect.o obj/tiles/active_item_cache.o obj/tiles/widget.o obj/tiles/unicode.o obj/tiles/ui_iteminfo.o obj/tiles/speech.o obj/tiles/sleep.o obj/tiles/overmap_connection.o obj/tiles/overlay_ordering.o obj/tiles/mondefense.o obj/tiles/mondeath.o obj/tiles/math_parser.o obj/tiles/magic_teleporter_list.o obj/tiles/loading_ui.o obj/tiles/do_turn.o obj/tiles/dependency_tree.o obj/tiles/clothing_mod.o obj/tiles/character_modifier.o obj/tiles/butchery_requirements.o obj/tiles/advanced_inv.o obj/tiles/activity_actor.o obj/tiles/translation_gendered.o obj/tiles/trade_ui.o obj/tiles/temp_crafting_inventory.o obj/tiles/talker_npc.o obj/tiles/talker_avatar.o obj/tiles/skill_ui.o obj/tiles/skill_boost.o obj/tiles/simplexnoise.o obj/tiles/simple_pathfinding.o obj/tiles/sdl_font.o obj/tiles/scores_ui.o obj/tiles/rotatable_symbols.o obj/tiles/profession_group.o obj/tiles/mood_face.o obj/tiles/monster_oracle.o obj/tiles/monattack.o obj/tiles/mod_tileset.o obj/tiles/melee.o obj/tiles/math_parser_jmath.o obj/tiles/math_parser_diag_value.o obj/tiles/mapgenformat.o obj/tiles/main_menu.o obj/tiles/end_screen.o obj/tiles/emit.o obj/tiles/drawing_primitives.o obj/tiles/distraction_manager.o obj/tiles/disease.o obj/tiles/construction_category.o obj/tiles/climbing.o obj/tiles/char_validity_check.o obj/tiles/calendar_ui.o obj/tiles/behavior_strategy.o obj/tiles/advanced_inv_pagination.o obj/tiles/activity_tracker.o obj/tiles/veh_shape.o obj/tiles/ui_extended_description.o obj/tiles/translation_plural_evaluator.o obj/tiles/translation_manager_impl.o obj/tiles/tgz_archiver.o obj/tiles/test_data.o obj/tiles/talker_topic.o obj/tiles/talker_monster.o obj/tiles/talker_item.o obj/tiles/talker_furniture.o obj/tiles/talker_character.o obj/tiles/string_editor_window.o obj/tiles/speed_description.o obj/tiles/smart_controller_ui.o obj/tiles/shearing.o obj/tiles/sdl_geometry.o obj/tiles/sdl_gamepad.o obj/tiles/scent_block.o obj/tiles/player_difficulty.o obj/tiles/pixel_minimap_projectors.o obj/tiles/pixel_minimap.o obj/tiles/pinyin.o obj/tiles/overmap_noise.o obj/tiles/ordered_static_globals.o obj/tiles/npctalk_rules.o obj/tiles/npc_attack.o obj/tiles/monexamine.o obj/tiles/mmap_file.o obj/tiles/math_parser_func.o obj/tiles/math_parser_diag.o obj/tiles/map_item_stack.o obj/tiles/live_view.o obj/tiles/iuse_software_sokoban.o obj/tiles/iuse_software_snake.o obj/tiles/iuse_software_minesweeper.o obj/tiles/iuse_software_lightson.o obj/tiles/iuse_software_kitten.o obj/tiles/iuse_software.o obj/tiles/item_action.o obj/tiles/iexamine_actors.o obj/tiles/gamemode_tutorial.o obj/tiles/flexbuffer_cache.o obj/tiles/event_field_transformations.o obj/tiles/editmap.o obj/tiles/distribution.o obj/tiles/demangle.o obj/tiles/crash.o obj/tiles/computer_session.o obj/tiles/compatibility.o obj/tiles/character_oracle.o obj/tiles/cellular_automata.o obj/tiles/behavior_oracle.o obj/tiles/animation.o obj/tiles/advanced_inv_pane.o obj/tiles/advanced_inv_listitem.o obj/tiles/advanced_inv_area.o obj/tiles/version.o obj/tiles/translation_document.o obj/tiles/third-party/imgui/imgui.o obj/tiles/text.o obj/tiles/shop_cons_rate.o obj/tiles/map_field.o obj/tiles/lang_stats.o obj/tiles/dialogue_win.o obj/tiles/cata_bitset.o obj/tiles/bonuses.o obj/tiles/activity_item_handling.o obj/tiles/armor_layers.o obj/tiles/bionics_ui.o obj/tiles/character_ammo.o obj/tiles/character_armor.o obj/tiles/character_body.o obj/tiles/character_crafting.o obj/tiles/character_escape.o obj/tiles/character_guns.o obj/tiles/character_inventory.o obj/tiles/character_morale.o obj/tiles/character_proficiency.o obj/tiles/consumption.o obj/tiles/diary_ui.o obj/tiles/emscripten_exception.o obj/tiles/filesystem_impl.o obj/tiles/grab.o obj/tiles/handle_action.o obj/tiles/magic_spell_effect.o obj/tiles/magic_ter_fur_transform.o obj/tiles/main.o obj/tiles/medical_ui.o obj/tiles/missiondef.o obj/tiles/mission_place.o obj/tiles/mission_start.o obj/tiles/mission_ui.o obj/tiles/mission_util.o obj/tiles/mod_manager_ui.o obj/tiles/monmove.o obj/tiles/mutation_data.o obj/tiles/mutation_type.o obj/tiles/mutation_ui.o obj/tiles/ncurses_def.o obj/tiles/newcharacter.o obj/tiles/npcmove.o obj/tiles/npctalk_funcs.o obj/tiles/player_display.o obj/tiles/player_hardcoded_effects.o obj/tiles/proficiency_ui.o obj/tiles/savegame.o obj/tiles/savegame_json.o obj/tiles/savegame_legacy.o obj/tiles/string_id_null_ids.o obj/tiles/suffer.o obj/tiles/text_style_check_reader.o obj/tiles/translation_manager.o obj/tiles/trapfunc.o obj/tiles/turret.o obj/tiles/vehicle_autodrive.o obj/tiles/vehicle_display.o obj/tiles/vehicle_move.o obj/tiles/vehicle_part.o obj/tiles/vehicle_use.o obj/tiles/wincurse.o obj/tiles/wish.o obj/tiles/third-party/flatbuffers/idl_parser.o obj/tiles/third-party/flatbuffers/util.o obj/tiles/third-party/imgui/imgui.o obj/tiles/third-party/imgui/imgui_demo.o obj/tiles/third-party/imgui/imgui_draw.o obj/tiles/third-party/imgui/imgui_tables.o obj/tiles/third-party/imgui/imgui_widgets.o obj/tiles/third-party/imgui/imgui_impl_sdl2.o obj/tiles/third-party/imgui/imgui_impl_sdlrenderer2.o -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer -lSDL2 -lpthread -lz
/usr/bin/ld: obj/tiles/third-party/imgui/imgui.o: in function `ImVector<ImGuiStorage::ImGuiStoragePair>::operator[](int)':
/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:1118: multiple definition of `ImGuiStyle::ImGuiStyle()'; obj/tiles/third-party/imgui/imgui.o:/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:1118: first defined here
... dozens more multiple definition errors ...
/usr/bin/ld: obj/tiles/third-party/imgui/imgui.o: in function `ImGuiWindow::~ImGuiWindow()':
/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:3720: multiple definition of `ImGuiWindow::~ImGuiWindow()'; obj/tiles/third-party/imgui/imgui.o:/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:3720: first defined here
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:1046: cataclysm-tiles] Error 1

I got this with a non-clean make after recent builds of newer master branch, and the same results with make clean && make. My make parameters are RELEASE=0 LTO=0 TILES=1 SOUND=1 LOCALIZE=0 CLANG=1 CCACHE=1 BACKTRACE=0 ASTYLE=0 LINTJSON=0 TESTS=0 RUNTESTS=0 HEADERPOPULARITY=1

@db48x
Copy link
Contributor Author

db48x commented Oct 24, 2024

That’s weird. You can see that it is running the linker to build the executable, and that obj/tiles/third-party/imgui/imgui.o is listed twice.

@db48x
Copy link
Contributor Author

db48x commented Oct 24, 2024

I cannot reproduce the problem, even with the same parameters.

Yea, you would think that would be easy.

Then use it on the debug item spawn window.
@github-actions github-actions bot added Items: Containers Things that hold other things and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Oct 28, 2024
@db48x
Copy link
Contributor Author

db48x commented Oct 28, 2024

The failures are all unrelated to this particular patch.

src/cata_imgui.cpp Outdated Show resolved Hide resolved
src/third-party/imgui/imgui.h Show resolved Hide resolved
@katemonster33
Copy link
Contributor

So I rebased this branch against master and compared it to current master. The wrapping works now on the spell list but what happened to the keybinding instructions on the spell list?
before: spell_list_before
after: spell_list_after

@db48x
Copy link
Contributor Author

db48x commented Nov 1, 2024

Nice. They’re supposed to still be there, but beneath the spell info. It worked before; perhaps I broke it when I rebased it last.

@db48x
Copy link
Contributor Author

db48x commented Nov 1, 2024

Screenshot from 2024-11-01 15-07-04

I’ve tried again to make the spell info take up the full available width of the column, but I think I am ready to give up on that. Again.

and rename RightAlign to BeginRightAlign to address review comments.
@katemonster33
Copy link
Contributor

Hmmmmm. Let me have a look.

This fixed the sizing error for me.
@katemonster33
Copy link
Contributor

Whoops, I was trying to suggest that change, not commit it outright. Feel free to revert it if I broke stuff.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Nov 2, 2024
@db48x
Copy link
Contributor Author

db48x commented Nov 2, 2024

Yea, I guess we might as well do that.

@Maleclypse Maleclypse merged commit 9764ff0 into CleverRaven:master Nov 9, 2024
19 of 26 checks passed
@Procyonae
Copy link
Contributor

Procyonae commented Nov 9, 2024

attempting to build this PR on Linux with clang 18.1.8 produces

... many earlier lines of compile ...
CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_ctime,include_file_mtime ccache clang++  -o cataclysm-tiles obj/tiles/debug.o obj/tiles/translations.o obj/tiles/string_formatter.o obj/tiles/output.o obj/tiles/character.o obj/tiles/item.o obj/tiles/map.o obj/tiles/point.o obj/tiles/rng.o obj/tiles/game.o obj/tiles/cata_utility.o obj/tiles/calendar.o obj/tiles/json.o obj/tiles/avatar.o obj/tiles/units.o obj/tiles/color.o obj/tiles/options.o obj/tiles/messages.o obj/tiles/itype.o obj/tiles/npc.o obj/tiles/generic_factory.o obj/tiles/vehicle.o obj/tiles/ui_manager.o obj/tiles/line.o obj/tiles/ui.o obj/tiles/creature.o obj/tiles/monster.o obj/tiles/mapdata.o obj/tiles/flag.o obj/tiles/mtype.o obj/tiles/input_context.o obj/tiles/catacharset.o obj/tiles/creature_tracker.o obj/tiles/overmapbuffer.o obj/tiles/coordinates.o obj/tiles/bodypart.o obj/tiles/flexbuffer_json.o obj/tiles/veh_type.o obj/tiles/sounds.o obj/tiles/inventory.o obj/tiles/cached_options.o obj/tiles/mutation.o obj/tiles/item_location.o obj/tiles/weather.o obj/tiles/input.o obj/tiles/field_type.o obj/tiles/string_input_popup.o obj/tiles/event.o obj/tiles/skill.o obj/tiles/player_activity.o obj/tiles/event_bus.o obj/tiles/path_info.o obj/tiles/effect.o obj/tiles/trap.o obj/tiles/text_snippets.o obj/tiles/overmap.o obj/tiles/character_id.o obj/tiles/damage.o obj/tiles/units_utility.o obj/tiles/mission.o obj/tiles/filesystem.o obj/tiles/requirements.o obj/tiles/bionics.o obj/tiles/activity_type.o obj/tiles/magic.o obj/tiles/localized_comparator.o obj/tiles/init.o obj/tiles/effect_on_condition.o obj/tiles/translation.o obj/tiles/faction.o obj/tiles/clzones.o obj/tiles/assign.o obj/tiles/item_pocket.o obj/tiles/item_group.o obj/tiles/recipe.o obj/tiles/game_inventory.o obj/tiles/mongroup.o obj/tiles/condition.o obj/tiles/action.o obj/tiles/item_factory.o obj/tiles/field.o obj/tiles/coordinate_conversions.o obj/tiles/recipe_dictionary.o obj/tiles/popup.o obj/tiles/explosion.o obj/tiles/character_martial_arts.o obj/tiles/magic_enchantment.o obj/tiles/iuse.o obj/tiles/martialarts.o obj/tiles/character_attire.o obj/tiles/cata_imgui.o obj/tiles/sdltiles.o obj/tiles/projectile.o obj/tiles/item_stack.o obj/tiles/city.o obj/tiles/weather_type.o obj/tiles/visitable.o obj/tiles/vehicle_selector.o obj/tiles/proficiency.o obj/tiles/iuse_actor.o obj/tiles/item_category.o obj/tiles/submap.o obj/tiles/stomach.o obj/tiles/map_selector.o obj/tiles/display.o obj/tiles/activity_handlers.o obj/tiles/tileray.o obj/tiles/material.o obj/tiles/json_loader.o obj/tiles/basecamp.o obj/tiles/worldfactory.o obj/tiles/vitamin.o obj/tiles/timed_event.o obj/tiles/iexamine.o obj/tiles/wcwidth.o obj/tiles/mod_manager.o obj/tiles/item_contents.o obj/tiles/profession.o obj/tiles/fault.o obj/tiles/construction.o obj/tiles/achievement.o obj/tiles/scent_map.o obj/tiles/mapbuffer.o obj/tiles/kill_tracker.o obj/tiles/harvest.o obj/tiles/auto_pickup.o obj/tiles/ammo.o obj/tiles/try_parse_integer.o obj/tiles/sdl_wrappers.o obj/tiles/ranged.o obj/tiles/mapgen_functions.o obj/tiles/map_extras.o obj/tiles/handle_liquid.o obj/tiles/fungal_effects.o obj/tiles/cata_variant.o obj/tiles/avatar_action.o obj/tiles/stats_tracker.o obj/tiles/relic.o obj/tiles/move_mode.o obj/tiles/memorial_logger.o obj/tiles/inventory_ui.o obj/tiles/weather_gen.o obj/tiles/weakpoint.o obj/tiles/teleport.o obj/tiles/regional_settings.o obj/tiles/pathfinding.o obj/tiles/panels.o obj/tiles/overmap_ui.o obj/tiles/npctrade.o obj/tiles/npctalk.o obj/tiles/monstergenerator.o obj/tiles/gates.o obj/tiles/game_ui.o obj/tiles/effect_source.o obj/tiles/dialogue_chatbin.o obj/tiles/debug_menu.o obj/tiles/cursesport.o obj/tiles/cata_tiles.o obj/tiles/addiction.o obj/tiles/scenario.o obj/tiles/mapgen.o obj/tiles/level_cache.o obj/tiles/help.o obj/tiles/dispersion.o obj/tiles/craft_command.o obj/tiles/computer.o obj/tiles/bodygraph.o obj/tiles/veh_interact.o obj/tiles/subbodypart.o obj/tiles/string_id.o obj/tiles/sdl_utils.o obj/tiles/music.o obj/tiles/mapsharing.o obj/tiles/iteminfo_query.o obj/tiles/behavior.o obj/tiles/vehicle_group.o obj/tiles/recipe_groups.o obj/tiles/past_games_info.o obj/tiles/morale_types.o obj/tiles/map_memory.o obj/tiles/mapgendata.o obj/tiles/lightmap.o obj/tiles/item_search.o obj/tiles/item_components.o obj/tiles/event_statistics.o obj/tiles/dialogue_helpers.o obj/tiles/crafting_gui.o obj/tiles/construction_group.o obj/tiles/ballistics.o obj/tiles/veh_utils.o obj/tiles/veh_appliance.o obj/tiles/trait_group.o obj/tiles/system_locale.o obj/tiles/start_location.o obj/tiles/shadowcasting.o obj/tiles/sdlsound.o obj/tiles/safe_reference.o obj/tiles/safemode_ui.o obj/tiles/pickup.o obj/tiles/past_achievements_info.o obj/tiles/overmap_location.o obj/tiles/npctrade_utils.o obj/tiles/npc_class.o obj/tiles/morale.o obj/tiles/monfaction.o obj/tiles/mission_companion.o obj/tiles/mattack_actors.o obj/tiles/item_tname.o obj/tiles/gamemode.o obj/tiles/font_loader.o obj/tiles/faction_camp.o obj/tiles/diary.o obj/tiles/crafting.o obj/tiles/contents_change_handler.o obj/tiles/auto_note.o obj/tiles/ascii_art.o obj/tiles/anatomy.o obj/tiles/ammo_effect.o obj/tiles/active_item_cache.o obj/tiles/widget.o obj/tiles/unicode.o obj/tiles/ui_iteminfo.o obj/tiles/speech.o obj/tiles/sleep.o obj/tiles/overmap_connection.o obj/tiles/overlay_ordering.o obj/tiles/mondefense.o obj/tiles/mondeath.o obj/tiles/math_parser.o obj/tiles/magic_teleporter_list.o obj/tiles/loading_ui.o obj/tiles/do_turn.o obj/tiles/dependency_tree.o obj/tiles/clothing_mod.o obj/tiles/character_modifier.o obj/tiles/butchery_requirements.o obj/tiles/advanced_inv.o obj/tiles/activity_actor.o obj/tiles/translation_gendered.o obj/tiles/trade_ui.o obj/tiles/temp_crafting_inventory.o obj/tiles/talker_npc.o obj/tiles/talker_avatar.o obj/tiles/skill_ui.o obj/tiles/skill_boost.o obj/tiles/simplexnoise.o obj/tiles/simple_pathfinding.o obj/tiles/sdl_font.o obj/tiles/scores_ui.o obj/tiles/rotatable_symbols.o obj/tiles/profession_group.o obj/tiles/mood_face.o obj/tiles/monster_oracle.o obj/tiles/monattack.o obj/tiles/mod_tileset.o obj/tiles/melee.o obj/tiles/math_parser_jmath.o obj/tiles/math_parser_diag_value.o obj/tiles/mapgenformat.o obj/tiles/main_menu.o obj/tiles/end_screen.o obj/tiles/emit.o obj/tiles/drawing_primitives.o obj/tiles/distraction_manager.o obj/tiles/disease.o obj/tiles/construction_category.o obj/tiles/climbing.o obj/tiles/char_validity_check.o obj/tiles/calendar_ui.o obj/tiles/behavior_strategy.o obj/tiles/advanced_inv_pagination.o obj/tiles/activity_tracker.o obj/tiles/veh_shape.o obj/tiles/ui_extended_description.o obj/tiles/translation_plural_evaluator.o obj/tiles/translation_manager_impl.o obj/tiles/tgz_archiver.o obj/tiles/test_data.o obj/tiles/talker_topic.o obj/tiles/talker_monster.o obj/tiles/talker_item.o obj/tiles/talker_furniture.o obj/tiles/talker_character.o obj/tiles/string_editor_window.o obj/tiles/speed_description.o obj/tiles/smart_controller_ui.o obj/tiles/shearing.o obj/tiles/sdl_geometry.o obj/tiles/sdl_gamepad.o obj/tiles/scent_block.o obj/tiles/player_difficulty.o obj/tiles/pixel_minimap_projectors.o obj/tiles/pixel_minimap.o obj/tiles/pinyin.o obj/tiles/overmap_noise.o obj/tiles/ordered_static_globals.o obj/tiles/npctalk_rules.o obj/tiles/npc_attack.o obj/tiles/monexamine.o obj/tiles/mmap_file.o obj/tiles/math_parser_func.o obj/tiles/math_parser_diag.o obj/tiles/map_item_stack.o obj/tiles/live_view.o obj/tiles/iuse_software_sokoban.o obj/tiles/iuse_software_snake.o obj/tiles/iuse_software_minesweeper.o obj/tiles/iuse_software_lightson.o obj/tiles/iuse_software_kitten.o obj/tiles/iuse_software.o obj/tiles/item_action.o obj/tiles/iexamine_actors.o obj/tiles/gamemode_tutorial.o obj/tiles/flexbuffer_cache.o obj/tiles/event_field_transformations.o obj/tiles/editmap.o obj/tiles/distribution.o obj/tiles/demangle.o obj/tiles/crash.o obj/tiles/computer_session.o obj/tiles/compatibility.o obj/tiles/character_oracle.o obj/tiles/cellular_automata.o obj/tiles/behavior_oracle.o obj/tiles/animation.o obj/tiles/advanced_inv_pane.o obj/tiles/advanced_inv_listitem.o obj/tiles/advanced_inv_area.o obj/tiles/version.o obj/tiles/translation_document.o obj/tiles/third-party/imgui/imgui.o obj/tiles/text.o obj/tiles/shop_cons_rate.o obj/tiles/map_field.o obj/tiles/lang_stats.o obj/tiles/dialogue_win.o obj/tiles/cata_bitset.o obj/tiles/bonuses.o obj/tiles/activity_item_handling.o obj/tiles/armor_layers.o obj/tiles/bionics_ui.o obj/tiles/character_ammo.o obj/tiles/character_armor.o obj/tiles/character_body.o obj/tiles/character_crafting.o obj/tiles/character_escape.o obj/tiles/character_guns.o obj/tiles/character_inventory.o obj/tiles/character_morale.o obj/tiles/character_proficiency.o obj/tiles/consumption.o obj/tiles/diary_ui.o obj/tiles/emscripten_exception.o obj/tiles/filesystem_impl.o obj/tiles/grab.o obj/tiles/handle_action.o obj/tiles/magic_spell_effect.o obj/tiles/magic_ter_fur_transform.o obj/tiles/main.o obj/tiles/medical_ui.o obj/tiles/missiondef.o obj/tiles/mission_place.o obj/tiles/mission_start.o obj/tiles/mission_ui.o obj/tiles/mission_util.o obj/tiles/mod_manager_ui.o obj/tiles/monmove.o obj/tiles/mutation_data.o obj/tiles/mutation_type.o obj/tiles/mutation_ui.o obj/tiles/ncurses_def.o obj/tiles/newcharacter.o obj/tiles/npcmove.o obj/tiles/npctalk_funcs.o obj/tiles/player_display.o obj/tiles/player_hardcoded_effects.o obj/tiles/proficiency_ui.o obj/tiles/savegame.o obj/tiles/savegame_json.o obj/tiles/savegame_legacy.o obj/tiles/string_id_null_ids.o obj/tiles/suffer.o obj/tiles/text_style_check_reader.o obj/tiles/translation_manager.o obj/tiles/trapfunc.o obj/tiles/turret.o obj/tiles/vehicle_autodrive.o obj/tiles/vehicle_display.o obj/tiles/vehicle_move.o obj/tiles/vehicle_part.o obj/tiles/vehicle_use.o obj/tiles/wincurse.o obj/tiles/wish.o obj/tiles/third-party/flatbuffers/idl_parser.o obj/tiles/third-party/flatbuffers/util.o obj/tiles/third-party/imgui/imgui.o obj/tiles/third-party/imgui/imgui_demo.o obj/tiles/third-party/imgui/imgui_draw.o obj/tiles/third-party/imgui/imgui_tables.o obj/tiles/third-party/imgui/imgui_widgets.o obj/tiles/third-party/imgui/imgui_impl_sdl2.o obj/tiles/third-party/imgui/imgui_impl_sdlrenderer2.o -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer -lSDL2 -lpthread -lz
/usr/bin/ld: obj/tiles/third-party/imgui/imgui.o: in function `ImVector<ImGuiStorage::ImGuiStoragePair>::operator[](int)':
/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:1118: multiple definition of `ImGuiStyle::ImGuiStyle()'; obj/tiles/third-party/imgui/imgui.o:/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:1118: first defined here
... dozens more multiple definition errors ...
/usr/bin/ld: obj/tiles/third-party/imgui/imgui.o: in function `ImGuiWindow::~ImGuiWindow()':
/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:3720: multiple definition of `ImGuiWindow::~ImGuiWindow()'; obj/tiles/third-party/imgui/imgui.o:/home/sparr/src/Cataclysm-DDA/src/third-party/imgui/imgui.cpp:3720: first defined here
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:1046: cataclysm-tiles] Error 1

I got this with a non-clean make after recent builds of newer master branch, and the same results with make clean && make. My make parameters are RELEASE=0 LTO=0 TILES=1 SOUND=1 LOCALIZE=0 CLANG=1 CCACHE=1 BACKTRACE=0 ASTYLE=0 LINTJSON=0 TESTS=0 RUNTESTS=0 HEADERPOPULARITY=1

I'm also having this problem on master now this is merged with make -j$((`nproc`+0)) CCACHE=1 RELEASE=1 MSYS2=1 DYNAMIC_LINKING=1 SDL=1 TILES=1 SOUND=1 LOCALIZE=0 LANGUAGES=all LINTJSON=0 ASTYLE=0 TESTS=0 RUNTESTS=0 HEADERPOPULARITY=1, removing HEADERPOPULARITY=1 makes it compile again

@db48x
Copy link
Contributor Author

db48x commented Nov 9, 2024

If using HEADERPOPULARITY=1 makes it fail to build, then you should file a bug about that. I notice that imgui.o is included twice in that build. Not sure why that would be, but it explains the error message.

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 <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds Info / User Interface Game - player communication, menus, etc. Items: Containers Things that hold other things json-styled JSON lint passed, label assigned by github actions
Projects
None yet
10 participants