Freecam
Freecam copied to clipboard
Generate lang files at build time
- [x] Refactor
:metadata
into a more general:data
project - [x] Introduce a custom gradle task that can "build" lang files
- [x] Move most
VariantTooltip
logic to the gradle task - [x] Move mod description to lang files
- [x] Use the built description in mod metadata
- [ ] Reformat lang files as
.properties
(not planned) - [ ] Split lang files into
main
&config
(low priority?) - [ ] Allow defining per-file key prefix/suffix or json "flattening" (not planned)
- [x] Fabric support (using ModMenu's documented API)
- [ ] Forge support (depends on https://github.com/neoforged/NeoForge/issues/639)
- [ ] Unit tests for
LangTask
- [x] Unit tests for the
LangProcessor
implementations
Fixes #172
This is feature complete and ready for review.
General notes
- First time using Kotlin; seems nice so far. A very expressive language, and excellent null safety.
- Kotlin was used to experiment with what it's like, with a view to potentially porting other parts of the build script in future.
- I would have liked to implement functional tests using Gradle's
TestKit
, however I was running into issues gettingbuildSrc
into the runner's classpath...- I may still add some unit tests though.
-
buildSrc
is an entirely separate "build", with it's own gradle "projects".- Gradle automatically compiles
buildSrc
before running the main build, and makes the result available to the build script. - It is a simple way to have freecam-specific build logic, plugins, & tasks without having to clutter up the actual build script.
- Gradle automatically compiles
- I've verified that
:data
builds everything correctly.
Tooltips
-
VariantTooltip
is now mostly a build step, the only thing handled at runtime is linecount
. - Mod name and description are now handled by
:data
'slangTask
.- If there is a
freecam.name.<variant>
translation, it is appended to the end offreecam.name
. - Same for
description
. - These are also used for the name/description in the mod metadata file.
- These are also assigned to the various
modmenu
-specific translation keys.
- If there is a
Forge
- Forge's Mod Menu doesn't support translating mod info
- I patched in support via two mixins.
- My gut feeling says this is a bad idea, and we should instead open a NeoForge issue/PR.
- I've opened https://github.com/neoforged/NeoForge/issues/639, let's see if there's any interest.
- The forge commit can be dropped from this PR if we'd rather stick to native behavior.
Added some basic unit tests for the LangProcessor
implementations & cleaned up LangTask
a little.
Dropped the forge mixin for now, hopefully we'll get a proper upstream solution.
Neoforge has added support in v2.4.179
, using the following keys:
-
fml.menu.mods.info.displayname.freecam
-
fml.menu.mods.info.description.freecam
I've also been thinking about better ways to approach the transformer funcs and "variant" translations, at risk of making this even more over-engineered.