Commit graph

123 commits

Author SHA1 Message Date
Severin Glöckner
dd40711d79 Avoid linebreak in title text of help pages
* doesn't clutter unit help tree when a unit variation is displayed
* when displaying a unit variation in the help, it displays the links
  below the unit image at the same line as when displaying the base unit
patch from #6011
2024-02-04 21:20:52 -06:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
gfgtdf
f8bd32eb15 Deploy and refactor config::optional_child
Previously the config class had an operator bool and
it was a common pattern to use if(const config& = cfg.child(..)).
While this pattern was nice to use. It has severe drawbacks, in
particular it was unclear whether a function that took a config&
parameter allowed "invalid" configs, while most functions
did not, there were some that did. Furtheremore it lead to a few
buggy codes that were unconvered by this change (Not fixed though!),
in particular codes that tested local config objects that were
not references to being invalid, which could never be the case.
This commits replaces those with just `true` in order to not
change behaviour.

Some obvious cases were also removed including for example
things like `assert(config());` There is ony case in the ai code
that i'm not 100% sure of where one implementation of a virtual
function checked for an invalid config and another one that didn't.

With this, all code that check for a config child to be
present now uses config::optional_child which returns an object
that behaves similar to optional<(const) config&>, so it throws
on invalid dereferencing. But it also has operator[string] for
convinience, in particular to make is similary
easy to use the the previous `if (config& = .. child())`.
Also it has a tool DEBUG_CONFIG which tests whether all
optional_config values are checked before they are derefereneced.

Another method manditory_child was
added that throws when the key is not found, which replaces all
occurances of child() that did not check whether the result was
valid. This was neccecary (this= adding a new method instead of
renaming .child) to keep track of converted changes, and be sure
no occurances of child() were accidentally changed to the
throwing version.

We might want to rename one of mandatory_child or optional_child
to just child later. Not sure which one yet. I think it's better
to keep it in the current state (no config::child() ) for a while
though, so that people that currently used child() in their open
prs or other work get an error and not wrongly rely on the previous
behviour of config::child.

The interface of vconfig was not changed in this commit.
2023-04-03 00:39:12 +02:00
Charles Dang
9bb3408ab0 Removed image::get_image wrapper 2023-03-22 01:04:30 -04:00
Steve Cotton
1a7d1e349c Help: don't display trait availability, and refactor code
The `[trait]availability=` attribute acts as a part of the parent tag, not as a
part of the trait itself. For example, `[trait]id=fearless` occurs in both the
`TRAIT_FEARLESS` and `TRAIT_FEARLESS_MUSTHAVE` macros, and the trait is:

* Must-have for units: Ghast, Ghoul, ...
* Available for non-leaders of race: Troll
* Available for non-leaders of types: Dune Paragon, HI, ...

Showing a single "Availability:" in the help is therefor misleading. Adding a
detailed list of where it's available adds a lot of code complexity for little
gain; this commit takes the code cleanup and comments from prototyping that,
but just removes the "Availability:" text from the help.
2023-03-02 14:18:58 +01:00
Steve Cotton
a4e17ac867 Show races with [race]help_taxonomy= as a tree in the help
For example, UtBS' Quenoth Elves now appear as a subfolder of Elves, and a major
reorganisation of animals is being discussed in https://r.wesnoth.org/t56522 .

Multiple levels of nesting are supported. If [race]help_taxonomy= points to a
race that isn't defined, or isn't defined with the current set of add-ons, then
it will fall back to adding the race at the top level. Discovering a unit
belonging to a subgroup will automatically treat the parent group as discovered
too.

I may have missed a trick in writing this nicely, the code uses several different
traversal patterns over the tree that it's constructing.
2023-01-18 15:34:22 +01:00
Severin Glöckner
5155a55723 Add missing space / dot. 2022-08-22 12:17:26 +02:00
Tommy
a02709e0ff Remove \n from log lines with it as suffix on the final string 2022-07-20 15:20:57 +12:00
Tommy
6ace55e063 Remove << "\n"; from log lines 2022-07-20 15:20:57 +12:00
Tommy
6a1cda1f28 Remove newline from PLAIN_LOG entries, or use STREAMING_LOG 2022-07-20 15:20:57 +12:00
Pentarctagon
3874fe5f0d Remove <iostream> from a lot of places. 2022-07-06 20:11:11 -05:00
Pentarctagon
c8e948a62b std::cerr -> PLAIN_LOG, to stop bypassing the logging system 2022-07-06 20:11:11 -05:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
c4c292fa3b Replace all remaining usages if MAKE_ENUM. 2022-03-03 21:23:02 -06:00
Wedge009
57cfcf87d7 Switch to hard-coded colours instead of relying on pango names (resolves #4348).
* Pango changed its definition of 'green' in version 1.32.2 to align with CSS specifications (see #4348 for details).
* This change focuses only on instances of '<span color="green">', leaving instances of named colours that don't use 'green'.
* Problem: Cannot use this approach with '<format>' (at least not that I'm currently aware) so it breaks time-of-day bonus colour consistency.
2021-09-20 11:43:19 +10:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Celtic Minstrel
e555e0681d Fix a bunch of compiler warnings
- Some implicit conversions
- Loop variable is always copied
- Missing prototypes
- Unused lambda captures
- Comma operators
2021-07-01 01:33:28 -04:00
Iris Morelle
f33c087770 help: Readjust heading font measurement and line spacing
Fixes tiny help topic body subheadings and tiny line spacing.
2021-03-19 12:38:36 -03:00
Iris Morelle
055eb13e67 Move font::is_cjk_char() to help browser implementation 2021-03-13 13:51:47 -03:00
Iris Morelle
0024cfa7e4 gui1: Use font::pango_line_width() in more places
The SDL_ttf version is still in use in the SDL_ttf API itself.
2021-03-13 13:51:47 -03:00
Iris Morelle
a7015a9c95 help: Use Pango word wrap implementation instead of SDL_ttf 2021-03-13 13:51:47 -03:00
Iris Morelle
041e56e63b help: Use color_t::from_hex_string() instead of from_argb_bytes()
Colours obtained from help markup until now have been generated using
from_argb_bytes(), even though the caller ensures they are 7 characters
long and thus in #RRGGBB hex notation. When porting the help text render
code to pango_text, this resulted in text with colour set by markup
being rendered invisible with an alpha value of 0.

Unless we decide at a later point to support alpha values in help
markup, we want alpha to always be 255.
2021-02-17 17:29:43 -03:00
Charles Dang
040a52ce25 Cleaned up some SDL includes 2021-01-17 18:01:38 +11:00
Charles Dang
f323deb23e Don't use optional::value since MacOS < 10.14 doesn't like it 2021-01-17 12:25:10 +11:00
Charles Dang
4d54b2a7fd Used std::optional directly since we support C++17 now 2021-01-17 11:48:14 +11:00
Charles Dang
a4b749524b Cleaned up ridiculously excessive passing around of terrain data cache
Keep in mind ter_data_cache is simply a shared_ptr, and in all call locations it was grabbed from game_config_manager::terrain_types().

1. campaign_controller took and kept a member, which was passed to either...
2. playsingle_controller or playmp_controller, which passed it to their parent class...
3. play_controller, which kept a member to initialize...
4. game_state, which passed it on to...
5. game_board, which passed it on to...
6. gamemap, where it was *finally* actually needed.

This entire chain has been replaced with a single call to game_config_manager::terrain_types() in the game_board constructor.
gamemap retains its ctor parameter since editor_map passes in its own object.

The ter_data_cache alias has also been removed. It was just confusing.
2021-01-02 17:03:15 +11:00
Pentarctagon
4c2b725ec0 Change all doxygen comments to the same format. 2020-12-31 23:59:28 -06:00
Charles Dang
cb537f781b
Converted uses of boost::optional to utils::optional (#5329) 2020-12-02 08:16:05 +11:00
Steve Cotton
f3f1407ace
Show [race]help_taxonomy= as "This is a group of units, all of whom are $help_taxonomy" (#5143)
The code comments talk about both Dunefolk and Quenoth Elves - of these two, only the
Dunefolk's data is changed in this commit. All Quenoth unit are race=elf at the moment,
I intend to add [race]id=quenoth in a separate PR.

Draft documentation for the Wiki:

* '''help_taxonomy''': {{DevFeature1.15|?}} in the help browser, show this
race as a group of units from another race; the value of this attribute should
be the other race's '''id''' attribute. This only affects the help browser, for
all other purposes (such as WML filters) the two races are completely separate.

How this is visualised in the help browser is a GUI design decision, this attribute
merely tells the engine that the relationship exists.
2020-09-13 15:20:48 +02:00
Steve Cotton
e9603e6e01
Show the "loyal" trait in help (#5123)
Fixes #1935 for normal users, expanding on aac0941's fix which only showed
these abiities when Wesnoth was in debug mode.

The removed enum member "NON_REVEALING_DESCRIPTION" was unused, and all
existing callers effectively used description_type() as a boolean.

This does mean that the "aged" trait will be shown to all users, even if
they haven't played HttT, however that seems reasonable.
2020-09-11 06:18:08 +02:00
Steve Cotton
7b1d5bc19b
Help browser: fix behavior of clicking on icons of terrain sections (#5110)
This commit uses the UI's calculated indent for the UI's event handling, and
removes section::level. The code generating the help sections still has its own
"level", which is used to detect excessive recursion.

This fixes a UI quirk that I only noticed while working out what section::level
was for, while considering the subtopics needed for implementing a taxonomy
system. The help browser calculates indentation for its tree-view based on the
data tree given to it. However, the logic for deciding whether a mouse-click
was on the icon or the text used section::level, rather than any value
calculated in the UI classes. While section::level was often the correct
number, it was wrong for the terrain types' sections.
2020-08-30 17:19:21 +02:00
gfgtdf
93aa2ca409 deploy new game_config_view object
the game_config_view object offers const
access to the game_config object, furthermore
it allows the game_config config object to be
replaced by a vector of config objects which
is what we will do later.
2020-06-29 15:16:05 +02:00
Steve Cotton
c2ce47f6a3 Simplify help's logic for terrain_types that should be hidden in help
Even when a terrain has hide_help=yes, its help should still be shown if the
player right-clicks on a hex of that type and selects "Terrain description".

This commit changes lines that have inconsistent logic, and the main reason for
doing it was to work out whether that inconsistency was something that needed
to be kept when refactoring the terrain code.

The inconsistency was a bug, help would fail to open the topic.  However, the
bug is so obscure that I only found it when considering the edge case that the
commit is removing, and there's no terrain in core that would trigger it.  The
edge case requires a terrain to be:

* defined by a [terrain_type] tag, so is_combined()==false
* hide_help=yes
* hidden=no (or is the default value)

To replicate the bug, try changing the definition of Gg to have hide_help=yes.
2020-01-17 11:14:12 +01:00
Wedge009
0bba03dd02 Leave help_impl.cpp in wesnoth text domain
[ci skip]
2019-11-06 10:35:27 +11:00
Wedge009
da609b933a Use fixed-width alignment for time-of-day icons 2019-11-06 10:35:27 +11:00
Wedge009
771b1720db Add time-of-day alignment icons to Help 2019-11-06 10:35:27 +11:00
Wedge009
f749608e79 Help Time of Day Bonuses: Add text-domain and colouring 2019-11-06 10:35:27 +11:00
Wedge009
ab40d88a05 Add Time of Day Bonuses to Help
Also mark 'Time of Day Schedule' and bonus strings for translation, to synchronise with what 1.14 branch has.

Resolves #3064
2019-11-06 10:35:27 +11:00
Steve Cotton
3b36ada41e
Improve the terrain code's encapsulation (#4411)
Change terrain_type_data's documentation and some methods to avoid exposing
implementation details, for example renaming try_merge_terrains to is_known.

Move the code to load all the [terrain_types] in to the terrain_type_data
class's own .cpp file, and out of terrain.cpp.

Add documentation about "underlying", and why worst(best(a,b),c,d) terrains don't work
The commented-out code for merging pluses and minuses in the middle of an alias
was commented out in 1.5's d2edbe118a, but the
concept of pluses and minuses in the middle of an alias seems broken anyway
(see comments added to merge_alias_lists in this commit).

Descriptions are t_strings, avoid converting them to std::string and back.
2019-10-03 14:30:04 +02:00
josteph
13e40841fe help: Show topic id in debug log
Fixes #4353
2019-09-16 18:12:17 +00:00
Martin Hrubý (hrubymar10)
6f468a3757
Migrate links to https if available
Closes #3343
2019-09-08 07:53:28 +02:00
Steve Cotton
06f0776134 Refresh help_impl.cpp using ranged-for loops and avoiding raw pointers
The old copy-assignment code would have appended the topics and sections
without clearing those lists, while the new code does clear them. However, the
copy-assignment is only called after calling clear(), so this doesn't affect
the behavior.
2019-08-06 16:29:59 +02:00
Charles Dang
2470984af3 Prepend 'SDL2/' to all SDL includes
This was needed to get the build working with vcpkg's version of SDL, where all the SDL files are
in their own SDL folder. However, our cmake config also has a note saying it was a deliberate choice
to move our SDL files *out* of their SDL2 folder due to certain distros (FreeBSD is mentioned) not
putting the files in said folder in the first place.
2019-07-22 15:35:55 +11:00
Steve Cotton
469fcc9c52 Convert help_impl's ref-counting to std::shared_ptr
This is part of #4166, as topic_text wasn't consistent with
the Rule of Three.
2019-07-15 16:51:12 +02:00
Jyrki Vesterinen
6b0ef7e3ce Replace strcmp() with string comparison operator
This isn't C.
2019-05-11 15:11:38 +03:00
josteph
d25463e445 Help: In debug mode, show unit type id's in their help topics.
Useful when multiple unit types have the same name.
2019-05-11 10:19:14 +00:00
josteph
4b99886433 Help: Support optional image in push_tab_pair 2019-03-20 14:51:47 +00:00
josteph
d9d445c23f Help: Use a typedef instead of hardcoding the concrete type 2019-03-20 14:51:46 +00:00