1
0
forked from mirrors/0ad
Commit Graph

38 Commits

Author SHA1 Message Date
Dunedan f43f4ae1b1 Update the pre-commit hooks
With v3.12.0 shfmt changed the behavior of the `--simplify` option to
ignore any EditorConfig when it's provided. Therefore, this option is
now moved to the EditorConfig as suggested by the shfmt author. See
https://github.com/mvdan/sh/issues/1173 for details.
2025-08-22 13:04:38 +02:00
Stan 03f7903fec Make rallypoints moddable.
Allow use of {civ} tags in templates to simplify mod dependencies and inheritance.

Reviewed-On: #8038
Reviewed-By: @phosit
2025-06-15 07:43:08 +02:00
trompetin17 2781d9a6a3 Add Fallback Font support
In previous fontbuilder.py we have the capacity to specified chain fonts
when a glyph is missed from one font.

This commit enable that behavior.
2025-05-28 01:01:03 -05:00
Dunedan 4b3d7f018b Improve find_files implementation
Instead of listing files recursively for each directory manually, this
uses the built-in glob functionality of Python's pathlib.Path. As
part of this the found paths are returned as generator instead of a
list. Together this results in easier to read code and better
performance.
2025-05-27 07:32:51 +02:00
Dunedan 2b54697862 Fix overwriting previous error state
This fixes a problem where the previous error state got overwritten by
the result of validating meshes in checkrefs.py.
2025-05-25 12:23:58 +02:00
Dunedan 71c02cf658 Fix checkrefs.py return code
A typo in the assignment of the error state lead to checkrefs.py
existing with return code 0, while it should've returned 1 in some
cases. This commit fixes that.
2025-05-25 12:23:58 +02:00
Dunedan b4f076effb Don't report errors for empty attribute values
Let checkrefs.py skip reporting errors for empty attribute values.

Fixes #7966
2025-05-25 12:12:45 +02:00
Dunedan 99b9a0cb86 Add support for new font handling for checkrefs.py
As the fonts specified in the GUI templates don't exist as files on disk
anymore after 734386ce9f we can't check if they're specified correctly
the same way as before anymore. Instead, this commit adds validation
of font names to the GUI Relax NG schema and adds a check whether all
fonts referenced in default.cfg exist in the proper location.
2025-05-25 11:21:51 +02:00
scuti 0e1c881fef Check for broken animated meshes in checkrefs.
Added and integrated P293 by @trompetin17 and @Stan
Addresses #6714
2025-05-04 22:25:47 +02:00
ramtzok1 1b797ce0a0 Add specific tips for multiplayer sessions
A multi player loading screen will have possibility of showing single
and multi player tips while multi player tips are in favor.

Tips are now separated by categories. During loading those category
have an occurrence probability, where we are choosing a random category
based on chance and not by complete randomness. From there we just
picking a random tip from that category.
2025-04-12 10:38:57 +02:00
Dunedan 03cb24d400 Move xmlvalidator code to entity directory
The xmlvalidator logic is only used by the checkrefs.py script, so this
moves it to the same directory to have it co-located and avoid having to
modify sys.path to import it.
2025-03-03 17:45:08 +01:00
Vantha 0177b97c69 Complete the GUI XML checks in checkrefs.py
Add checks for sprites, styles, scrollbars, tooltips, and colors.
And too for entire objects referenced by the "use_object" attribute.
(even though that is currently unused)
2025-02-26 16:20:27 +01:00
Dunedan a92a4ff45c Update the pre-commit hooks 2025-01-11 21:44:52 +01:00
Vantha d7dda097e1 Extend the tips page for multiple images per tip
Enable the Tips and Tricks page to show multiple images for each tip.
Add a small GUI panel below the image for switching between them.
Only show it when the current tip has more than one images.

Introduce tipfiles.json to assign images to the text files.
(And stop of relying on file naming)

Add a tip about wonders, and make some slight changes to other texts.
Improve existing tip images and add a bunch of new ones.
2024-12-20 19:46:07 +01:00
Vantha 38b71c1bac Add a Tips and Tricks page containing the loading screen tips
- Small popup page accessible from the main menu via Learn to Play.
- Lets the player read through the tips with 'Previous' and 'Next' buttons.
- Tips continue to be shown on the loading screen.
-> but there without the scrolling ability.

- Added two new hotkeys for quicker tip changing (item.prev and item.next)
-> set to the left and right arrows respectively by default.

- Responsible scripts are placed in gui/reference/tips/.
- The tip text files have been moved to gui/reference/tips/texts/.
- Tip image files have been moved to art/textures/ui/tips/.

- Added a series of new sprites (textures in art/textures/ui/tipdisplay/)
-> comprises a title decoration, a bullet point sprite, and a new button
style.
2024-09-30 06:22:47 +02:00
Dunedan c0232c6b5f Specify the Python target version in ruff.toml
This ensures the same Python target version used for `ruff format`
is used for `ruff check` as well. It also allows ruff, even if it's not
run through pre-commit, to use the correct target Python version.
2024-09-21 20:54:24 +02:00
Dunedan 616f2e134b Fix variable names in checkrefs.py 2024-09-13 11:04:04 +02:00
Dunedan c3b99feb60 Enable ruff rules for code simplification
This enables ruff rules which check for code which can be simplified to
improve readability.

The additionally rules getting enabled by this are:

- remove unnecessary nesting of if-statements (SIM102)
- use contextlib.suppress() for no-op exception handling (SIM105)
- use enumerate() for counting in loops (SIM113)
- use context managers for opening files (SIM115)
2024-08-29 07:00:43 +02:00
Dunedan ea647067f0 Enable ruff rules to check for ambiguous code
This enables some ruff rules to check for ambiguous and dead Python
code, which might cause unintended side-effects.

The enabled rules are:

- a bunch of rules related to shadowing of builtin structures (A)
- a bunch of rules checking for unused arguments (ARG)
- a rule checking for useless expressions (B018)
- a rule checking for unbound loop variables (B023)
- a rule checking redefined function parameters (PLR1704)
2024-08-27 19:28:11 +02:00
Dunedan 05e708f987 Refactor check_* functions for better readability 2024-08-25 21:24:00 +02:00
Dunedan 75949e1f5a Replace use of os.path with pathlib 2024-08-25 21:24:00 +02:00
Dunedan 4b77d7bb74 Compile regex pattern once
This should slightly increase the performance as the pattern has to be
only compiled once, instead of so during every loop iteration.
2024-08-25 21:24:00 +02:00
Dunedan 87029f2a91 Replace uses of re.split() with str.split() 2024-08-25 21:23:59 +02:00
Dunedan 24e67746f9 Log a warning when a specified mod can't be found 2024-08-25 21:23:59 +02:00
Dunedan 92d92fac1b Remove unnecessary default value for dict.get() 2024-08-25 21:23:59 +02:00
Dunedan 0dea22285e Fix the exit codes of checkrefs.py 2024-08-25 21:23:59 +02:00
Dunedan 39f2889cf7 Support calling checkrefs.py from other dirs 2024-08-25 21:23:59 +02:00
Dunedan e36c6a31fe Enable additional ruff rules
In the ruff config file added in #6954 explicitly selecting the ruff
rules to check was missed, resulting in ruff only checking a very small
subset of its available rules. That hasn't been desired, so this is the
first of a series of commits enabling more rules. In this PR all rules
whose violations can be either automatically fixed by ruff or are
trivial to fix manually get enabled. For the follow up PRs it's intended
to focus on one area of rules per PR to gradually improve the Python
code quality.
2024-08-25 06:29:39 +02:00
Dunedan c49d4eedd0 Lint and format Python files using ruff
To improve quality und uniformity of the included Python code this
lints and formats the included Python files with ruff.
2024-08-24 10:54:26 +02:00
Stan eeb0f1cce6 Make checkrefs and called scripts return an error 2024-08-23 17:54:56 +02:00
Stan 2a06eea08a Fix checkrefs.py for python 3.12
Fixes #6898
Reported by: @Itms
2024-08-23 15:59:36 +02:00
Freagarach 83b786dcf5 Tokens for required technologies.
Use tokens for required technologies, allowing `-tech` and easier
replacements.
Fixes requiring `replace=""` when replacing techs.
Also a minor fix in the TemplateParser.js for upgrade requirements.
Refs. 9bb9ff8b16.

Differential revision: https://code.wildfiregames.com/D4912
Comments by: @Stan
This was SVN commit r27505.
2023-01-30 08:05:34 +00:00
Freagarach 3e7bdc148e Update checkrefs.py after 9bb9ff8b16.
Reported by: @Langbart
Differential revision: https://code.wildfiregames.com/D4880
Tested by: @Langbart
Fixes #6682

This was SVN commit r27436.
2023-01-13 10:29:51 +00:00
Stan 759aa333a5 Add a function to handle custom phase techs, so they do not show as unused.
Fix autostart files being marked as unused.
Fix an issue with the researcher component. Patch by: @marder
Refs https://code.wildfiregames.com/D4750
Refs #6587
Fixes ca82935dfc

This was SVN commit r27033.
2022-08-06 15:06:03 +00:00
Stan ca82935dfc Add techs and auras to the list of possibly missing files.
Refs: #6544
Accepted by: @Langbart
Differential Revision: https://code.wildfiregames.com/D4725
This was SVN commit r26991.
2022-06-27 14:31:16 +00:00
Stan b9adbbd8be Fix 557fa0312e by adding the js files to the list of dependencies. They were previously found under the gui folder.
Reported by: @Langbart
Fixes #6542

This was SVN commit r26909.
2022-05-28 17:01:42 +00:00
Freagarach b778caf146 Move FormationName and Icon from cmpFormation to cmpIdentity.
Reduces duplication across components.
Allows to provide specific names and history for formations.

Differential revision: https://code.wildfiregames.com/D4476
Comments by: @bb, @Stan
Fixes #6400

This was SVN commit r26476.
2022-02-24 06:51:07 +00:00
Stan 936fb5a172 Replace checkrefs.pl by a python script. This makes it easier to run on Windows for non technical persons.
- Add support for tips
- Fix other scripts not writing to the correct output (they were writing
info messages to stderr)

Based on a patch by: @mammadori	and @cyrille
Differential Revision: https://code.wildfiregames.com/D3213
This was SVN commit r26350.
2022-02-12 15:43:42 +00:00