Compare commits

...

110 Commits

Author SHA1 Message Date
f7ac3c4009 Add support for more Noita builds
All checks were successful
Build and test / Build and test (push) Successful in 2m47s
- Build Aug 12 2024 21:10:13
- Build Aug 12 2024 21:48:01
2024-10-03 21:17:07 +02:00
David Vogel
09d8bcfe09
Merge pull request #31 from WUOTE/12-August-2024-latest
Add support for the latest Beta branch build
2024-09-02 13:59:12 +02:00
b76233caa4 Fix indentation of modifications.lua 2024-09-02 13:57:29 +02:00
b6224e657f Add support for newest dev build 2024-09-02 13:56:22 +02:00
WUOTE
3e5950810a Update modification.lua 2024-09-02 16:44:49 +06:00
d3edf29a80 Add animation capture mode 2024-07-03 00:16:38 +02:00
David Vogel
3fd0d970b7
Merge pull request #30 from Dadido3/dependabot/go_modules/golang.org/x/image-0.18.0
Bump golang.org/x/image from 0.14.0 to 0.18.0
2024-06-26 21:55:23 +02:00
dependabot[bot]
627dc545d4
Bump golang.org/x/image from 0.14.0 to 0.18.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.14.0 to 0.18.0.
- [Commits](https://github.com/golang/image/compare/v0.14.0...v0.18.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-26 19:38:05 +00:00
203a0ea159 Fix predefined area error 2024-05-07 01:12:11 +02:00
0065afe413 Update AREAS.md 2024-04-29 10:03:24 +02:00
9c6e57b340 Merge branch 'master' of https://github.com/Dadido3/noita-mapcap 2024-04-29 09:52:10 +02:00
44ed26952c Replace hardcoded capture areas
We now retrieve the correct biome size and offsets from the game itself.
2024-04-29 09:52:07 +02:00
David Vogel
1aa8b02882
Merge pull request #28 from Dadido3/dependabot/go_modules/golang.org/x/net-0.23.0
Bump golang.org/x/net from 0.19.0 to 0.23.0
2024-04-21 00:44:01 +02:00
dependabot[bot]
e125df80b2
Bump golang.org/x/net from 0.19.0 to 0.23.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.19.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.19.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 12:45:14 +00:00
1936dc100c Add error handling to glReadPixels 2024-04-11 11:39:35 +02:00
1d83b0dfa0 Update README.md 2024-04-10 19:45:57 +02:00
David Vogel
442c8f7f43
Merge pull request #27 from WUOTE/master
Add support for Epilogue 2 Main branch Build Apr  8 2024 18:11:27
2024-04-10 11:05:59 +02:00
dcfe240bfc Add support for Noita "Build Apr 8 2024 18:07:16" 2024-04-10 11:03:06 +02:00
WUOTE
42f3af0655 Add support for Epilogue 2 Main branch Build Apr 8 2024 18:11:27 2024-04-10 05:14:07 +06:00
4e79c08e6a Add support for new Noita beta
- Add support for `Build Apr  6 2024 20:50:04`
- Add support for `Build Apr  6 2024 20:54:23`
2024-04-06 23:28:56 +02:00
aee72fd3c6 Allow reading tiles with transparency 2024-04-06 23:28:15 +02:00
04eeca26e2 Rename parallel world capture areas 2024-03-26 12:11:32 +01:00
ae6bcd9743 Add -1 and +1 parallel world capture area 2024-03-26 12:07:50 +01:00
920288614b Add support for Mar 25 2024 update
- Add support for `Build Mar 25 2024 17:42:49`
- Add support for `Build Mar 25 2024 17:48:04`
2024-03-25 23:02:34 +01:00
c0fd7aab56 Fix capture grid calculation
The capture grid calculation takes now the rendering rectangle into consideration.
With this fix the capture grid will include all cells that overlap with the given capture rectangle.
2024-02-21 17:55:24 +01:00
20d7c330a6 Add new capture area preset
"3 Worlds" does contain the base layout of a "New Game", but 9 times (3x3).
2024-02-20 18:02:21 +01:00
05e6b18745 Add support for Noita build Build Feb 14 2024 07:46:57 2024-02-20 17:43:25 +01:00
David Vogel
f109c66152
Merge pull request #26 from WUOTE/master
Add support for Build Feb 12 2024 19:07:19 (beta branch)
2024-02-16 22:51:50 +01:00
WUOTE
8b2fe81f42 Add support for Build Feb 12 2024 19:07:19 (beta branch) 2024-02-17 02:08:30 +06:00
David Vogel
0758ec7a62
Merge pull request #25 from WUOTE/master
Add compatibility for beta build (Feb 9 2024)
2024-02-11 19:04:02 +01:00
WUOTE
a9141679f4 Add compatibility for beta build (Feb 9 2024) 2024-02-12 00:01:30 +06:00
690a2c55ab Add support for newest main builds of Noita
`Build Jan 18 2024 12:57:44` and `Build Jan 18 2024 13:01:21`.
2024-02-10 12:50:15 +01:00
751877b472 Fix typo in stitcher flag
`wepb-level` --> `webp-level`
2024-02-08 21:07:42 +01:00
b4dca53fc8 Update capture process
- When being in `CaptureDelay` mode, just shake viewport a little bit
- When DoesWorldExistAt still does return false after 600 frames, move viewport to somewhere else, and try again.
2024-02-08 16:27:57 +01:00
9cfb01187c Fix invalid memory access in capture.dll 2024-02-08 16:12:55 +01:00
dddaad938f Fix release archive using wrong path delimiter
This caused the files in the .zip file to appear flattened when opened with 7zip.
2024-02-08 11:48:32 +01:00
41271d5321 Update README.md 2024-02-08 01:22:17 +01:00
b1a10870c1 Several changes
- Add compatibility for newest Noita beta
- Modify STREAMING_CHUNK_TARGET, GRID_MAX_UPDATES_PER_FRAME and GRID_MIN_UPDATES_PER_FRAME magic numbers for a more robust capturing process
- Add LimitGroup to util.go
- Add webp-level command line flag to define the webp compression level
- Rework progress bar to make it work in DZI export mode
- Refactor image exporter functions
- Use LimitGroup to make DZI export multithreaded
- Add BlendMethodFast which doesn't mix tile pixels
- Up Go version to 1.22
- Use Dadido3/go-libwebp for WebP encoding
2024-02-08 00:50:11 +01:00
47d570014d Make addon compatible with newest Noita beta 2024-02-05 22:31:56 +01:00
421f897be7 Let camera shake when it's waiting for a capture
For some reason this improves chunk loading.
2024-02-05 22:31:30 +01:00
9c728e0ae2 Update .gitignore 2024-02-05 22:30:22 +01:00
d9d8c9cd78 Format Capture.pb 2024-02-05 19:10:32 +01:00
15e2b88ed5 Update the Capture.dll
- Increase hardcoded number of workers to 8.
- Export images temporarily, and then move them once they are fully exported. This prevents corrupt images.
2024-02-05 19:00:39 +01:00
9e51538f3f Add setting to delay screen captures
This is useful to let the world populate and let the physics simulation settle down.
2024-02-05 18:10:10 +01:00
24a1615706 Prevent duplicate modification entries in message 2024-02-05 16:14:48 +01:00
45df692b96 Save top left coordinates when exporting DZI 2024-02-05 00:10:10 +01:00
93a1283188 Add more PostFX stuff to disable
- Disable additive_overlay_color
- Disable color_grading

This prevents any color shift that may happen on freezing/snowing weather.
Which only happens in December, January or February.
2024-02-05 00:03:55 +01:00
ace1ab145a More QOL updates
- Give user the option to reapply resolution settings on detected mismatch
- Tell user to apply some modifications manually, if the mod can't do it automatically
- Always set mTrailerMode when DEBUG_PAUSE_GRID_UPDATE is set to prevent chunks from not rendering
2024-01-30 15:01:20 +01:00
4f3f5c594d Some QOL improvements
- Always try to disable `application_rendered_cursor`
- Only disable fullscreen when custom resolution is enabled in mod settings
- Update Message:ShowWrongResolution message
- Update README.md
2024-01-29 16:27:06 +01:00
f22ef05411 Prevent transparent background 2024-01-15 21:31:45 +01:00
d82fda528a Merge remote-tracking branch 'origin/opengl-capture' 2024-01-15 21:29:23 +01:00
860b724bd0 Change DZI to encode tiles to WebP 2024-01-15 21:27:44 +01:00
8057b14d8e Update build.release.yml 2024-01-15 21:20:44 +01:00
0e431c64d3 Update build.release.yml 2024-01-15 21:16:53 +01:00
f2b1aba994 Enable CGO which is needed for cross compilation 2024-01-15 20:30:28 +01:00
1a735c06bd Update Readme.md 2024-01-15 20:30:12 +01:00
69f5d1ccb3 Add WebP encoder 2024-01-15 20:06:49 +01:00
44605b9633 Move coroutine wakeup back into OnWorldPreUpdate 2024-01-05 18:43:10 +01:00
d5cd88a30e Capture directly from OpenGL framebuffer
- Update capture.dll to read via glReadPixels
- Move coroutine wake up into OnWorldPostUpdate
- Update resolution checks for new capturing method
- Remove fullscreen mode check
- Increase screen capture delay
2024-01-04 19:36:36 +01:00
4de83e3dcd Fix typos 2023-12-31 18:22:32 +01:00
d774cf373d Add parameters for DZI output 2023-12-31 17:44:07 +01:00
9da52a3f70 Add compatibility with new beta versions
- `Build Dec 30 2023 19:37:04`
- `Build Dec 30 2023 19:40:49`
2023-12-30 23:21:26 +01:00
e83aa6803a Add support for new Noita versions
- Add support for Build Dec 29 2023 23:36:18
- Add support for Build Dec 29 2023 23:40:18
2023-12-30 14:05:16 +01:00
f7426f3ed5 Don't modify GRID_MAX and MIN magic numbers 2023-12-30 13:58:39 +01:00
478e1284fb Add code that stops grid updates in regular build
This is not exposed to the end user yet, as it is buggy.
2023-12-30 13:34:13 +01:00
8bb8adf1ba Scan world line by line instead of using hilbert curve
This should prevent some glitches due to the way Noita generates the world.
2023-12-28 17:47:36 +01:00
355521b144 Change dziOverlap to 2
With 0, OpenSeadragon has problems drawing the images correctly.
And with 1, we introduce rounding errors when creating the smaller zoom levels.
2023-12-23 12:44:29 +01:00
b76124b2e4 Fix error when there already is an DZI directory 2023-12-23 10:41:05 +01:00
f0ee3e2399 Remove DZI overlap, as it seems unnecessary 2023-12-23 10:40:30 +01:00
b9fc890581 Update stitcher README.md and flag usage string
#7
2023-12-23 01:41:59 +01:00
a96431361f Prevent stdout spam when exporting DZI files 2023-12-23 01:23:53 +01:00
88507af167 Increase default CacheRowHeight 2023-12-23 01:17:40 +01:00
7a6915480b Add first sketch of Deep Zoom Image exporter 2023-12-23 01:17:20 +01:00
915da73845 Add SubStitchedImage 2023-12-23 01:16:25 +01:00
6d028d4064 Fix stitched image cache generation 2023-12-23 01:15:36 +01:00
a0d5c13557 Let StitchedImage invalidate cache based on time 2023-12-23 01:15:05 +01:00
3016919348 Add Bounds method to ImageTiles 2023-12-23 01:11:58 +01:00
cbdd925c30 Correct image.Rectangle downscaling 2023-12-23 01:09:50 +01:00
a0168df91f Change export functions to use image.Image 2023-12-23 01:09:23 +01:00
182373d3cc Refactor export functions
- Pass output path as parameter
- Return and handle errors correctly
2023-12-22 11:03:04 +01:00
0454e29e34 Add JPEG encoder 2023-12-22 10:13:22 +01:00
a70a5a4d1a Prepare stitcher for multiple output formats 2023-12-22 10:07:02 +01:00
f5a3bad396 Update dependencies
- Push minimal go version to 1.21
- tdewolff/canvas compatibility updates
2023-12-21 14:04:50 +01:00
905f629d2c Add support for newer Noita builds
- Add Build Dec 19 2023 18:34:31 support
- Add Build Dec 19 2023 18:38:23 support
- Add Build Dec 21 2023 00:07:29 support
- Add Build Dec 21 2023 00:11:06 support
2023-12-21 13:42:25 +01:00
David Vogel
b11b27d6c3
Merge pull request #23 from Dadido3/dependabot/go_modules/golang.org/x/image-0.10.0
Bump golang.org/x/image from 0.5.0 to 0.10.0
2023-11-02 22:37:41 +01:00
dependabot[bot]
6ef2f7d1d3
Bump golang.org/x/image from 0.5.0 to 0.10.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.5.0 to 0.10.0.
- [Commits](https://github.com/golang/image/compare/v0.5.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-02 21:34:11 +00:00
8f729d3829 Add support for the Jul 26 2023 beta 2023-07-27 10:40:41 +02:00
a6a0cc14e1 Make compatible with Jun 19 2023 builds
Also change how the matching works, as offsets may not change between builds.

fixes #22
2023-06-21 18:43:57 +02:00
2b0f6a25f6 Remove travis build status 2023-04-17 11:21:49 +02:00
d69177cd3b Hide "Disable mod detection" in dev build 2023-04-17 11:19:16 +02:00
f992748443 Add compatibility with Mar 11 2023 build
closes #21
closes #20
2023-04-16 19:13:53 +02:00
22b5c1827d Merge branch 'master' of https://github.com/Dadido3/noita-mapcap 2023-03-15 23:58:57 +01:00
b22b42a8d1 Update message text
- Add possible fix to "resolution changed" message
2023-03-15 23:58:50 +01:00
f1a3010d72 Fix exception with memory modification 2023-03-15 23:57:17 +01:00
David Vogel
ad50faebc9
Merge pull request #19 from Dadido3/dependabot/go_modules/golang.org/x/image-0.5.0
Bump golang.org/x/image from 0.0.0-20220617043117-41969df76e82 to 0.5.0
2023-03-06 23:45:06 +01:00
dependabot[bot]
c72574c55d
Bump golang.org/x/image from 0.0.0-20220617043117-41969df76e82 to 0.5.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.0.0-20220617043117-41969df76e82 to 0.5.0.
- [Release notes](https://github.com/golang/image/releases)
- [Commits](https://github.com/golang/image/commits/v0.5.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-06 22:43:26 +00:00
9494588e7b Add example code for killing/removing creatures 2023-02-25 13:51:17 +01:00
7a85f646cb Merge branch 'master' of https://github.com/Dadido3/noita-mapcap 2023-02-25 13:16:12 +01:00
d8dab5c318 Update README.md 2023-02-25 13:16:09 +01:00
David Vogel
b1971bb4be
Merge pull request #18 from Dadido3/dependabot/go_modules/golang.org/x/text-0.3.8
Bump golang.org/x/text from 0.3.7 to 0.3.8
2023-02-23 11:31:18 +01:00
dependabot[bot]
1652b278cb
Bump golang.org/x/text from 0.3.7 to 0.3.8
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-23 10:24:04 +00:00
486f8e642d Update README.md 2022-09-06 11:33:42 +02:00
f964f5d769 Remove debug print
Getting error when starting new game #16
2022-08-29 16:21:50 +02:00
28a768a130 Fix package.path separators
Getting error when starting new game #16
2022-08-29 16:21:01 +02:00
959b198e46 Fix typos 2022-08-27 14:32:01 +02:00
18682ed441 Fully implement "disable-mod-detection" setting
- Catch exceptions in OnPausedChanged
- Unhide "disable-mod-detection" setting
- Add error message for unsupported modifications
- Change memory modification lookup to contain functions
- Don't (re)enable mod detection automatically
- Add memory.lua library that allows to change the protection of memory regions.
2022-08-27 14:07:37 +02:00
28c07dfd25 Merge branch 'master' of https://github.com/Dadido3/noita-mapcap 2022-08-13 13:58:52 +02:00
fcfd8c88ff Add Voronoi blend method 2022-08-13 13:58:50 +02:00
David Vogel
6761492ea8
Create FUNDING.yml 2022-08-12 23:25:35 +02:00
615faac8e4 Ensure the github action uses at least go 1.19 2022-08-12 14:03:08 +02:00
47 changed files with 2004 additions and 459 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# These are supported funding model platforms
github: Dadido3 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@ -8,18 +8,17 @@ jobs:
build:
name: Build and release
runs-on: ubuntu-latest
runs-on: windows-latest
strategy:
matrix:
goos: [windows]
goarch: ["amd64"]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.18
go-version: ^1.22
- name: Check out code into the Go module directory
uses: actions/checkout@v2
@ -32,6 +31,7 @@ jobs:
env:
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
CGO_ENABLED: 1
- name: Create distribution archive
run: go run -v ./scripts/dist

View File

@ -12,7 +12,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.18
go-version: ^1.22
- name: Check out code into the Go module directory
uses: actions/checkout@v2

6
.gitignore vendored
View File

@ -105,5 +105,9 @@ $RECYCLE.BIN/
/output/
/dist/
/bin/stitch/output.png
/bin/stitch/*.png
/bin/stitch/*.dzi
/bin/stitch/*_files/
/files/magic-numbers/generated.xml
/bin/stitch/captures/*

70
.vscode/settings.json vendored
View File

@ -1,16 +1,22 @@
{
"cSpell.words": [
"aabb",
"acidflow",
"appdata",
"autosetup",
"backbuffer",
"basicfont",
"bytecode",
"cheggaaa",
"Dadido",
"dofile",
"dont",
"Downscales",
"downscaling",
"DPMM",
"executables",
"framebuffer",
"framebuffers",
"Fullscreen",
"goarch",
"gridify",
@ -22,23 +28,43 @@
"Lanczos",
"lann",
"ldflags",
"libwebp",
"linearize",
"longleg",
"lowram",
"luanxml",
"manifoldco",
"mapcap",
"Metamethods",
"metaobject",
"Metatable",
"nfnt",
"Niccoli",
"noita",
"noitamap",
"Nolla",
"NXML",
"openseadragon",
"pixelated",
"polymorphed",
"promptui",
"rasterizer",
"Regen",
"respawn",
"runfast",
"savegames",
"schollz",
"screenshake",
"svenstaro",
"tcnksm",
"tdewolff",
"unmodded",
"unstitchable",
"upscaled",
"Vogel",
"Voronoi",
"webp",
"wepb",
"xmax",
"xmin",
"ymax",
@ -49,5 +75,47 @@
"Lua.format.defaultConfig": {
"max_line_length": "512"
},
"Lua.workspace.ignoreSubmodules": false
"Lua.workspace.ignoreSubmodules": false,
"cSpell.enabledLanguageIds": [
"asciidoc",
"c",
"cpp",
"csharp",
"css",
"elixir",
"erlang",
"git-commit",
"go",
"graphql",
"handlebars",
"haskell",
"html",
"jade",
"java",
"javascript",
"javascriptreact",
"json",
"jsonc",
"jupyter",
"latex",
"less",
"markdown",
"php",
"plaintext",
"python",
"pug",
"restructuredtext",
"rust",
"scala",
"scss",
"scminput",
"swift",
"text",
"typescript",
"typescriptreact",
"vue",
"yaml",
"yml",
"lua"
]
}

View File

@ -1,6 +1,10 @@
# Capture areas
A list of available capture areas.
Other game-modes or mods may use a different biome setup, and therefore the coordinates shown here are not valid for them.
The values shown are for an unmodded `New Game` world.
The noita-mapcap mod will always automatically determine the required coordinates so that it correctly captures the base layout or multiples of it.
Coordinates are in in-game "virtual" or "world" pixels.
`Right` and `Bottom` coordinates are not included in the rectangle.
@ -64,3 +68,16 @@ Bottom = 41984
The end result will have a size of `51200 x 73728 pixels ~= 3775 megapixels`.
![Base layout](images/scale32_extended.png)
## `3 Worlds`
This area consists of `Main world` plus a full left and right parallel world.
``` lua
Left = -53760
Top = -31744
Right = 53760
Bottom = 41984
```
The end result will have a size of `107520 x 73728 pixels ~= 7927 megapixels`.

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019-2022 David Vogel
Copyright (c) 2019-2023 David Vogel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,11 +1,14 @@
# Noita map capture addon [![Build Status](https://travis-ci.com/Dadido3/noita-mapcap.svg?branch=master)](https://travis-ci.com/Dadido3/noita-mapcap)
# Noita map capture addon
A mod for Noita that can capture images of the world and stitch them into one large image.
It works with the regular Noita build and the dev build.
![Title image](images/title.png)
A resulting image with nearly 3.8 gigapixels can be [seen here](https://easyzoom.com/image/223556) (May contain spoilers).
Map captures created with this mod can be viewed on [map.runfast.stream] (may contain spoilers).
If you are interested in creating similar captures, or if you want to contribute your own captures to [map.runfast.stream], you can take a look at [github.com/acidflow-noita/noitamap].
There you'll find detailed step-by-step instructions on how to quickly capture large parts of the Noita world with as little visual glitches and other issues as possible.
## System requirements
@ -53,9 +56,9 @@ To the top left of the window are 3 buttons:
You can always restart a capture, and it will resume where it was stopped.
- ![Output directory button](files/ui-gfx/open-output-16x16.png) Reveals the output directory in your file browser.
This will contain raw screenshots that later can be stitched.
This will contain raw screenshots and other recorded data that later can be stitched.
- ![Stitch button](files/ui-gfx/stitch-16x16.png) Reveals the directory of the stitch tool in your file browser.
- ![Stitch button](files/ui-gfx/stitch-16x16.png) Reveals the stitching tool directory in your file browser.
To stitch the final result, click ![Stitch button](files/ui-gfx/stitch-16x16.png) to open the directory of the stitching tool.
Start `stitch.exe` and proceed with the default values.
@ -78,6 +81,10 @@ After a few minutes the file `output.png` will be created.
- `Spiral`: Will capture the world in a spiral.
The center starting point of the spiral can either be your current viewport, the world center or some custom coordinates.
- `Animation`: Will capture an image sequence.
This will capture whatever you see frame by frame and stores it in the output folder by frame number.
You can't stitch the resulting images, but instead you can use something like ffmpeg to render the sequence into a video file.
### Advanced mod settings
- `World seed`: If non empty, this will set the next new game to this seed.
@ -145,8 +152,9 @@ The sliders are at their default values:
There is not a lot you can do about it:
- You can try to increase the usable address space of your `.../Noita/noita_dev.exe` or `.../Noita/noita.exe` with [Large Address Aware](https://www.techpowerup.com/forums/threads/large-address-aware.112556/) or a similar tool.
This will help with any crashes that are related to out of memory exceptions.
- ~~You can try to increase the usable address space of your `.../Noita/noita_dev.exe` or `.../Noita/noita.exe` with [Large Address Aware] or a similar tool.
This will help with any crashes that are related to out of memory exceptions.~~
`Large Address Aware` is already set in newer Noita builds.
- You can disable the replay recorder.
@ -158,7 +166,7 @@ These can't really be prevented.
All you can do is to click `Ignore always`.
Alternatively you can run the same capture in the regular Noita (non dev build), which has these messages disabled.
With the exception that you can't disable the pixel and rigid body simulations it works as good as in the dev build.
With the exception that you can't disable the pixel and rigid body simulations, the mod works just as well as in the dev build.
### The mod messed up my game
@ -171,6 +179,10 @@ To reset any permanent settings that may have been set by the mod:
2. Start a new game.
3. *Right* click ![Record button](files/ui-gfx/record-16x16.png) and follow instructions.
> ![Hint](files/ui-gfx/hint-16x16.png) If you have changed any resolutions in your game's `config.xml`, you may have to re-apply these changes.
> This also applies if you use any mods that makes Noita work on ultra-wide screens.
> For these mods to work again after a reset, you need to go through their installation steps again.
Alternatively, you can reset **all** game settings by deleting:
- `"%appdata%\..\LocalLow\Nolla_Games_Noita\save_shared\config.xml"` for the regular Noita.
@ -184,17 +196,28 @@ This will cause fast moving objects to completely disappear, and slow moving obj
To disable median blending, use the stitcher with `Blend tile limit` set to 1.
This will cause the stitcher to only use the newest image tile for every resulting pixel.
## Additional information
## Viewing and hosting captures
The resulting stitched images are quite big.
You can read [this comment](https://github.com/Dadido3/noita-mapcap/issues/7#issuecomment-723591552) that addresses how you can view, convert or even self-host your images.
You can use [github.com/Dadido3/noita-mapcap-openseadragon] if you want to host a browser based viewer on your own web space.
If you want to make your captures available to a wider audience, you should check out the [github.com/acidflow-noita/noitamap] project, which aims to make maps of all game modes (including mods) available to the public.
## Acknowledgements
This mod uses the [LuaNXML](https://github.com/zatherz/luanxml) library by [Zatherz](https://github.com/zatherz).
This mod uses the [LuaNXML] library by [Zatherz].
Thanks to [Daniel Niccoli](https://github.com/danielniccoli) for figuring out how to change some in-game options by manipulating process memory.
## License
[MIT](LICENSE)
[github.com/acidflow-noita/noitamap]: https://github.com/acidflow-noita/noitamap
[github.com/Dadido3/noita-mapcap-openseadragon]: https://github.com/Dadido3/noita-mapcap-openseadragon
[Large Address Aware]: https://www.techpowerup.com/forums/threads/large-address-aware.112556/
[LuaNXML]: https://github.com/zatherz/luanxml
[map.runfast.stream]: https://map.runfast.stream
[Zatherz]: https://github.com/zatherz

View File

@ -1,8 +1,10 @@
; Copyright (c) 2019-2022 David Vogel
; Copyright (c) 2019-2024 David Vogel
;
; This software is released under the MIT License.
; https://opensource.org/licenses/MIT
EnableExplicit
UsePNGImageEncoder()
Declare Worker(*Dummy)
@ -15,44 +17,43 @@ Structure QueueElement
sy.i
EndStructure
; Source: https://www.purebasic.fr/english/viewtopic.php?f=13&t=29981&start=15
Procedure EnumWindowsProc(hWnd.l, *lParam.Long)
Protected lpProc.l
GetWindowThreadProcessId_(hWnd, @lpProc)
If *lParam\l = lpProc ; Check if current window's processID matches
*lParam\l = hWnd ; Replace processID in the param With the hwnd As result
ProcedureReturn #False ; Return false to stop iterating
Structure GLViewportDims
x.i
y.i
width.i
height.i
EndStructure
Structure WorkerInfo
workerNumber.i
EndStructure
#Workers = 8
; Returns the size of the main OpenGL rendering output.
ProcedureDLL GetGLViewportSize(*dims.GLViewportDims)
If Not *dims
ProcedureReturn #False
EndIf
glGetIntegerv_(#GL_VIEWPORT, *dims)
ProcedureReturn #True
EndProcedure
; Source: https://www.purebasic.fr/english/viewtopic.php?f=13&t=29981&start=15
; Returns the first window associated with the given process handle
Procedure GetProcHwnd()
Protected pID.l = GetCurrentProcessId_()
Protected tempParam.l = pID
EnumWindows_(@EnumWindowsProc(), @tempParam)
If tempParam = pID ; Check if anything was found
ProcedureReturn #Null
EndIf
ProcedureReturn tempParam ; This is a valid hWnd at this point
EndProcedure
; Get the client rectangle of the "Main" window of this process in screen coordinates
; Returns the size of the main OpenGL rendering output as a windows RECT.
ProcedureDLL GetRect(*rect.RECT)
Protected hWnd.l = GetProcHwnd()
If Not hWnd
ProcedureReturn #False
EndIf
If Not *rect
ProcedureReturn #False
EndIf
GetClientRect_(hWnd, *rect)
Protected dims.GLViewportDims
glGetIntegerv_(#GL_VIEWPORT, dims)
; A RECT consists basically of two POINT structures
ClientToScreen_(hWnd, @*rect\left)
ClientToScreen_(hWnd, @*rect\Right)
*rect\left = dims\x
*rect\top = dims\y
*rect\right = dims\x + dims\width
*rect\bottom = dims\y + dims\height
ProcedureReturn #True
EndProcedure
@ -64,13 +65,16 @@ ProcedureDLL AttachProcess(Instance)
CreateDirectory("mods/noita-mapcap/output/")
For i = 1 To 6
CreateThread(@Worker(), #Null)
Static Dim WorkerInfos.WorkerInfo(#Workers-1)
Protected i
For i = 0 To #Workers-1
WorkerInfos(i)\workerNumber = i
CreateThread(@Worker(), @WorkerInfos(i))
Next
EndProcedure
Procedure Worker(*Dummy)
Protected img, x, y
Procedure Worker(*workerInfo.WorkerInfo)
Protected img, x, y, sx, sy
Repeat
WaitSemaphore(Semaphore)
@ -89,61 +93,60 @@ Procedure Worker(*Dummy)
ResizeImage(img, sx, sy)
EndIf
SaveImage(img, "mods/noita-mapcap/output/" + x + "," + y + ".png", #PB_ImagePlugin_PNG)
;SaveImage(img, "" + x + "," + y + ".png", #PB_ImagePlugin_PNG) ; Test
; Save image temporary, and only move it once it's fully exported.
; This prevents images getting corrupted when the main process crashes.
If SaveImage(img, "mods/noita-mapcap/output/worker_" + *workerInfo\workerNumber + ".tmp", #PB_ImagePlugin_PNG)
RenameFile("mods/noita-mapcap/output/worker_" + *workerInfo\workerNumber + ".tmp", "mods/noita-mapcap/output/" + x + "," + y + ".png")
; We can't really do anything when either SaveImage or RenameFile fails, so just silently fail.
EndIf
FreeImage(img)
ForEver
EndProcedure
; Takes a screenshot of the client area of this process' active window.
; The portion of the client area that is captured is described by capRect, which is in window coordinates and relative to the client area.
; The portion of the client area that is captured is described by capRect, which is in viewport coordinates.
; x and y defines the top left position of the captured rectangle in scaled world coordinates. The scale depends on the window to world pixel ratio.
; sx and sy defines the final dimensions that the screenshot will be resized to. No resize will happen if set to 0.
ProcedureDLL Capture(*capRect.RECT, x.l, y.l, sx.l, sy.l)
Protected hWnd.l = GetProcHwnd()
If Not hWnd
Protected viewportRect.RECT
If Not GetRect(@viewportRect)
ProcedureReturn #False
EndIf
Protected rect.RECT
If Not GetRect(@rect)
ProcedureReturn #False
EndIf
Protected imageID, hDC, *pixelBuffer
; Limit the desired capture area to the actual client area of the window.
; Limit the desired capture area to the actual client area of the viewport.
If *capRect\left < 0 : *capRect\left = 0 : EndIf
If *capRect\right > rect\right-rect\left : *capRect\right = rect\right-rect\left : EndIf
If *capRect\top < 0 : *capRect\top = 0 : EndIf
If *capRect\bottom > rect\bottom-rect\top : *capRect\bottom = rect\bottom-rect\top : EndIf
If *capRect\right < *capRect\left : *capRect\right = *capRect\left : EndIf
If *capRect\bottom < *capRect\top : *capRect\bottom = *capRect\top : EndIf
If *capRect\right > viewportRect\right : *capRect\right = viewportRect\right : EndIf
If *capRect\bottom > viewportRect\bottom : *capRect\bottom = viewportRect\bottom : EndIf
imageID = CreateImage(#PB_Any, *capRect\right-*capRect\left, *capRect\bottom-*capRect\top)
Protected capWidth = *capRect\right - *capRect\left
Protected capHeight = *capRect\bottom - *capRect\top
imageID = CreateImage(#PB_Any, capWidth, capHeight)
If Not imageID
ProcedureReturn #False
EndIf
; Get DC of window.
windowDC = GetDC_(hWnd)
If Not windowDC
FreeImage(imageID)
ProcedureReturn #False
EndIf
hDC = StartDrawing(ImageOutput(imageID))
If Not hDC
ReleaseDC_(hWnd, windowDC)
FreeImage(imageID)
ProcedureReturn #False
EndIf
If Not BitBlt_(hDC, 0, 0, *capRect\right-*capRect\left, *capRect\bottom-*capRect\top, windowDC, *capRect\left, *capRect\top, #SRCCOPY) ; After some time BitBlt will fail, no idea why. Also, that's moments before noita crashes.
StopDrawing()
ReleaseDC_(hWnd, windowDC)
FreeImage(imageID)
ProcedureReturn #False
EndIf
StopDrawing()
ReleaseDC_(hWnd, windowDC)
*pixelBuffer = DrawingBuffer()
glReadPixels_(*capRect\left, *capRect\top, capWidth, capHeight, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, *pixelBuffer)
If glGetError_() <> #GL_NO_ERROR
StopDrawing()
FreeImage(imageID)
ProcedureReturn #False
EndIf
StopDrawing()
LockMutex(Mutex)
; Check if the queue has too many elements, if so, wait. (Emulate go's channels)
@ -173,13 +176,14 @@ EndProcedure
;Capture(123, 123)
;Delay(1000)
; IDE Options = PureBasic 6.00 LTS (Windows - x64)
; IDE Options = PureBasic 6.04 LTS (Windows - x64)
; ExecutableFormat = Shared dll
; CursorPosition = 94
; FirstLine = 39
; Folding = --
; CursorPosition = 99
; FirstLine = 72
; Folding = -
; Optimizer
; EnableThread
; EnableXP
; Executable = capture.dll
; Compiler = PureBasic 6.00 LTS (Windows - x86)
; DisableDebugger
; Compiler = PureBasic 6.04 LTS - C Backend (Windows - x86)

Binary file not shown.

View File

@ -36,13 +36,20 @@ example list of files:
If set to 1, only the newest tile will be used for any resulting pixel.
Use 1 to prevent ghosting and blurry objects.
- `input string`
The source path of the image tiles to be stitched. Defaults to "./..//..//output")
The source path of the image tiles to be stitched. Defaults to "./..//..//output"
- `entities string`
The path to the `entities.json` file. This contains Noita specific entity data. Defaults to "./../../output/entities.json".
- `player-path string`
The path to the player-path.json file. This contains the tracked path of the player. Defaults to "./../../output/player-path.json".
- `output string`
The path and filename of the resulting stitched image. Defaults to "output.png".
Supported formats/file extensions: `.png`, `.webp`, `.jpg`, `.dzi`.
- `dzi-tile-size`
The size of the resulting deep zoom image (DZI) tiles in pixels. Defaults to 512.
- `dzi-tile-overlap`
The number of additional pixels around every deep zoom image (DZI) tile. Defaults to 2.
- `webp-level`
Compression level of WebP files, from 0 (fast) to 9 (slow, best compression). Defaults to 8.
- `xmax int`
Right bound of the output rectangle. This coordinate is not included in the output.
- `xmin int`
@ -58,6 +65,12 @@ To output the 100x100 area that is centered at the origin use:
./stitch -divide 1 -xmin -50 -xmax 50 -ymin -50 -ymax 50
```
To output a [Deep Zoom Image (DZI)](https://en.wikipedia.org/wiki/Deep_Zoom), which can be used with [OpenSeadragon](https://openseadragon.github.io/examples/tilesource-dzi/), use:
``` Shell Session
./stitch -output capture.dzi
```
To start the program interactively:
``` Shell Session

View File

@ -1,4 +1,4 @@
// Copyright (c) 2022 David Vogel
// Copyright (c) 2022-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -8,6 +8,8 @@ package main
import (
"image"
"image/color"
"image/draw"
"math"
"sort"
)
@ -82,3 +84,81 @@ func (b BlendMethodMedian) Draw(tiles []*ImageTile, destImage *image.RGBA) {
}
}
}
// BlendMethodVoronoi maps every pixel to the tile with the closest center point distance.
// The result is basically a Voronoi partitioning.
type BlendMethodVoronoi struct {
BlendTileLimit int // If larger than 0, limits blending to the n newest tiles by file modification time.
}
// Draw implements the StitchedImageBlendMethod interface.
func (b BlendMethodVoronoi) Draw(tiles []*ImageTile, destImage *image.RGBA) {
bounds := destImage.Bounds()
if b.BlendTileLimit > 0 {
// Sort tiles by date.
sort.Slice(tiles, func(i, j int) bool { return tiles[i].modTime.After(tiles[j].modTime) })
}
// List of images corresponding to the "tiles" list.
// Can contain empty/nil entries for images that failed to load.
images := []*image.RGBA{}
for _, tile := range tiles {
images = append(images, tile.GetImage())
}
// Create color variables reused every pixel.
var col color.RGBA
var centerDistSqrMin int
for iy := bounds.Min.Y; iy < bounds.Max.Y; iy++ {
for ix := bounds.Min.X; ix < bounds.Max.X; ix++ {
point := image.Point{ix, iy}
count := 0
centerDistSqrMin = math.MaxInt
// Iterate through all images and create a list of colors.
for _, img := range images {
if img != nil {
if point.In(img.Bounds()) {
center := img.Bounds().Min.Add(img.Bounds().Max).Div(2)
centerDiff := point.Sub(center)
distSqr := centerDiff.X*centerDiff.X + centerDiff.Y*centerDiff.Y
if centerDistSqrMin > distSqr {
centerDistSqrMin = distSqr
col = img.RGBAAt(point.X, point.Y)
}
count++
// Limit number of tiles to blend.
// Will be ignored if the blend tile limit is 0.
if count == b.BlendTileLimit {
break
}
}
}
}
// If there were no images to get data from, ignore the pixel.
if count == 0 {
continue
}
col.A = 255
destImage.SetRGBA(ix, iy, col)
}
}
}
// BlendMethodFast just draws all tiles into the destination image.
// No mixing is done, and this is very fast when there is no or minimal tile overlap.
type BlendMethodFast struct{}
// Draw implements the StitchedImageBlendMethod interface.
func (b BlendMethodFast) Draw(tiles []*ImageTile, destImage *image.RGBA) {
for _, tile := range tiles {
if image := tile.GetImage(); image != nil {
bounds := image.Bounds()
draw.Draw(destImage, bounds, image, bounds.Min, draw.Src)
}
}
}

208
bin/stitch/dzi.go Normal file
View File

@ -0,0 +1,208 @@
// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"encoding/json"
"fmt"
"image"
"log"
"os"
"path/filepath"
"runtime"
"strconv"
"sync"
"sync/atomic"
"time"
"github.com/cheggaaa/pb/v3"
)
type DZI struct {
stitchedImage *StitchedImage
fileExtension string
tileSize int // The (maximum) width and height of a tile in pixels, not including the overlap.
overlap int // The amount of additional pixels on every side of every tile. The real (max) width/height of an image is `2*overlap + tileSize`.
maxZoomLevel int // The maximum zoom level that is needed.
}
// NewDZI creates a new DZI from the given StitchedImages.
//
// dziTileSize and dziOverlap define the size and overlap of the resulting DZI tiles.
func NewDZI(stitchedImage *StitchedImage, dziTileSize, dziOverlap int) DZI {
dzi := DZI{
stitchedImage: stitchedImage,
fileExtension: ".webp",
overlap: dziOverlap,
tileSize: dziTileSize,
}
width, height := stitchedImage.bounds.Dx(), stitchedImage.bounds.Dy()
// Calculate max zoom level and stuff.
neededLength := max(width, height)
var sideLength int = 1
var level int
for sideLength < neededLength {
level += 1
sideLength *= 2
}
dzi.maxZoomLevel = level
//dzi.maxZoomLevelLength = sideLength
return dzi
}
// ExportDZIDescriptor exports the descriptive JSON file at the given path.
func (d DZI) ExportDZIDescriptor(outputPath string) error {
log.Printf("Creating DZI descriptor %q.", outputPath)
f, err := os.Create(outputPath)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
}
defer f.Close()
// Prepare data that describes the layout of the image files.
var dziDescriptor struct {
Image struct {
XMLNS string `json:"xmlns"`
Format string
Overlap string
TileSize string
Size struct {
Width string
Height string
}
TopLeft struct {
X string
Y string
}
}
}
dziDescriptor.Image.XMLNS = "http://schemas.microsoft.com/deepzoom/2008"
dziDescriptor.Image.Format = "webp"
dziDescriptor.Image.Overlap = strconv.Itoa(d.overlap)
dziDescriptor.Image.TileSize = strconv.Itoa(d.tileSize)
dziDescriptor.Image.Size.Width = strconv.Itoa(d.stitchedImage.bounds.Dx())
dziDescriptor.Image.Size.Height = strconv.Itoa(d.stitchedImage.bounds.Dy())
dziDescriptor.Image.TopLeft.X = strconv.Itoa(d.stitchedImage.bounds.Min.X)
dziDescriptor.Image.TopLeft.Y = strconv.Itoa(d.stitchedImage.bounds.Min.Y)
jsonEnc := json.NewEncoder(f)
return jsonEnc.Encode(dziDescriptor)
}
// ExportDZITiles exports the single image tiles for every zoom level.
func (d DZI) ExportDZITiles(outputDir string, bar *pb.ProgressBar, webPLevel int) error {
log.Printf("Creating DZI tiles in %q.", outputDir)
const scaleDivider = 2
var exportedTiles atomic.Int64
// If there is a progress bar, start a goroutine that regularly updates it.
// We will base that on the number of exported tiles.
if bar != nil {
// Count final number of tiles.
bounds := d.stitchedImage.bounds
var finalTiles int64
for zoomLevel := d.maxZoomLevel; zoomLevel >= 0; zoomLevel-- {
for iY := 0; iY <= (bounds.Dy()-1)/d.tileSize; iY++ {
for iX := 0; iX <= (bounds.Dx()-1)/d.tileSize; iX++ {
finalTiles++
}
}
bounds = image.Rect(DivideFloor(bounds.Min.X, scaleDivider), DivideFloor(bounds.Min.Y, scaleDivider), DivideCeil(bounds.Max.X, scaleDivider), DivideCeil(bounds.Max.Y, scaleDivider))
}
bar.SetRefreshRate(250 * time.Millisecond).SetTotal(finalTiles).Start()
done := make(chan struct{})
defer func() {
done <- struct{}{}
bar.SetCurrent(bar.Total()).Finish()
}()
go func() {
ticker := time.NewTicker(250 * time.Millisecond)
for {
select {
case <-done:
return
case <-ticker.C:
bar.SetCurrent(exportedTiles.Load())
}
}
}()
}
// Start with the highest zoom level (Where every world pixel is exactly mapped into one image pixel).
// Generate all tiles for this level, and then stitch another image (scaled down by a factor of 2) based on the previously generated tiles.
// Repeat this process until we have generated level 0.
// The current stitched image we are working with.
stitchedImage := d.stitchedImage
for zoomLevel := d.maxZoomLevel; zoomLevel >= 0; zoomLevel-- {
levelBasePath := filepath.Join(outputDir, fmt.Sprintf("%d", zoomLevel))
if err := os.MkdirAll(levelBasePath, 0755); err != nil {
return fmt.Errorf("failed to create zoom level base directory %q: %w", levelBasePath, err)
}
// Store list of tiles, so that we can reuse them in the next step for the smaller zoom level.
imageTiles := ImageTiles{}
// Export tiles.
lg := NewLimitGroup(runtime.NumCPU())
for iY := 0; iY <= (stitchedImage.bounds.Dy()-1)/d.tileSize; iY++ {
for iX := 0; iX <= (stitchedImage.bounds.Dx()-1)/d.tileSize; iX++ {
rect := image.Rect(iX*d.tileSize, iY*d.tileSize, iX*d.tileSize+d.tileSize, iY*d.tileSize+d.tileSize)
rect = rect.Add(stitchedImage.bounds.Min)
rect = rect.Inset(-d.overlap)
img := stitchedImage.SubStitchedImage(rect)
filePath := filepath.Join(levelBasePath, fmt.Sprintf("%d_%d%s", iX, iY, d.fileExtension))
lg.Add(1)
go func() {
defer lg.Done()
if err := exportWebP(img, filePath, webPLevel); err != nil {
log.Printf("Failed to export WebP: %v", err)
}
exportedTiles.Add(1)
}()
imageTiles = append(imageTiles, ImageTile{
fileName: filePath,
modTime: time.Now(),
scaleDivider: scaleDivider,
image: image.Rect(DivideFloor(img.Bounds().Min.X, scaleDivider), DivideFloor(img.Bounds().Min.Y, scaleDivider), DivideCeil(img.Bounds().Max.X, scaleDivider), DivideCeil(img.Bounds().Max.Y, scaleDivider)),
imageMutex: &sync.RWMutex{},
invalidationChan: make(chan struct{}, 1),
timeoutChan: make(chan struct{}, 1),
})
}
}
lg.Wait()
// Create new stitched image from the previously exported tiles.
// The tiles are already created in a way, that they are scaled down by a factor of 2.
var err error
stitchedImage, err = NewStitchedImage(imageTiles, imageTiles.Bounds(), BlendMethodFast{}, 128, nil)
if err != nil {
return fmt.Errorf("failed to run NewStitchedImage(): %w", err)
}
}
return nil
}

View File

@ -58,6 +58,6 @@ func (e Entities) Draw(destImage *image.RGBA) {
// Theoretically we would need to linearize imgRGBA first, but DefaultColorSpace assumes that the color space is linear already.
r := rasterizer.FromImage(originImage, canvas.DPMM(1.0), canvas.DefaultColorSpace)
c.Render(r)
c.RenderTo(r)
r.Close() // This just transforms the image's luminance curve back from linear into non linear.
}

View File

@ -15,8 +15,8 @@ import (
//var entityDisplayFontFace *canvas.FontFace
var entityDisplayAreaDamageStyle = canvas.Style{
FillColor: color.RGBA{100, 0, 0, 100},
StrokeColor: canvas.Transparent,
Fill: canvas.Paint{Color: color.RGBA{100, 0, 0, 100}},
Stroke: canvas.Paint{},
StrokeWidth: 1.0,
StrokeCapper: canvas.ButtCap,
StrokeJoiner: canvas.MiterJoin,
@ -26,8 +26,8 @@ var entityDisplayAreaDamageStyle = canvas.Style{
}
var entityDisplayMaterialAreaCheckerStyle = canvas.Style{
FillColor: color.RGBA{0, 0, 127, 127},
StrokeColor: canvas.Transparent,
Fill: canvas.Paint{Color: color.RGBA{0, 0, 127, 127}},
Stroke: canvas.Paint{},
StrokeWidth: 1.0,
StrokeCapper: canvas.ButtCap,
StrokeJoiner: canvas.MiterJoin,
@ -37,8 +37,8 @@ var entityDisplayMaterialAreaCheckerStyle = canvas.Style{
}
var entityDisplayTeleportStyle = canvas.Style{
FillColor: color.RGBA{0, 127, 0, 127},
StrokeColor: canvas.Transparent,
Fill: canvas.Paint{Color: color.RGBA{0, 127, 0, 127}},
Stroke: canvas.Paint{},
StrokeWidth: 1.0,
StrokeCapper: canvas.ButtCap,
StrokeJoiner: canvas.MiterJoin,
@ -48,8 +48,8 @@ var entityDisplayTeleportStyle = canvas.Style{
}
var entityDisplayHitBoxStyle = canvas.Style{
FillColor: color.RGBA{64, 64, 0, 64},
StrokeColor: color.RGBA{0, 0, 0, 64},
Fill: canvas.Paint{Color: color.RGBA{64, 64, 0, 64}},
Stroke: canvas.Paint{Color: color.RGBA{0, 0, 0, 64}},
StrokeWidth: 1.0,
StrokeCapper: canvas.ButtCap,
StrokeJoiner: canvas.MiterJoin,
@ -59,8 +59,8 @@ var entityDisplayHitBoxStyle = canvas.Style{
}
var entityDisplayCollisionTriggerStyle = canvas.Style{
FillColor: color.RGBA{0, 64, 64, 64},
StrokeColor: color.RGBA{0, 0, 0, 64},
Fill: canvas.Paint{Color: color.RGBA{0, 64, 64, 64}},
Stroke: canvas.Paint{Color: color.RGBA{0, 0, 0, 64}},
StrokeWidth: 1.0,
StrokeCapper: canvas.ButtCap,
StrokeJoiner: canvas.MiterJoin,

40
bin/stitch/export-dzi.go Normal file
View File

@ -0,0 +1,40 @@
// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/cheggaaa/pb/v3"
)
func exportDZIStitchedImage(stitchedImage *StitchedImage, outputPath string, bar *pb.ProgressBar, dziTileSize, dziOverlap int, webPLevel int) error {
descriptorPath := outputPath
extension := filepath.Ext(outputPath)
outputTilesPath := strings.TrimSuffix(outputPath, extension) + "_files"
dzi := NewDZI(stitchedImage, dziTileSize, dziOverlap)
// Create base directory of all DZI files.
if err := os.MkdirAll(outputTilesPath, 0755); err != nil {
return fmt.Errorf("failed to create output directory: %w", err)
}
// Export DZI descriptor.
if err := dzi.ExportDZIDescriptor(descriptorPath); err != nil {
return fmt.Errorf("failed to export DZI descriptor: %w", err)
}
// Export DZI tiles.
if err := dzi.ExportDZITiles(outputTilesPath, bar, webPLevel); err != nil {
return fmt.Errorf("failed to export DZI tiles: %w", err)
}
return nil
}

67
bin/stitch/export-jpeg.go Normal file
View File

@ -0,0 +1,67 @@
// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"fmt"
"image"
"image/jpeg"
"log"
"os"
"time"
"github.com/cheggaaa/pb/v3"
)
func exportJPEGStitchedImage(stitchedImage *StitchedImage, outputPath string, bar *pb.ProgressBar) error {
log.Printf("Creating output file %q.", outputPath)
// If there is a progress bar, start a goroutine that regularly updates it.
// We will base the progress on the number of pixels read from the stitched image.
if bar != nil {
_, max := stitchedImage.Progress()
bar.SetRefreshRate(250 * time.Millisecond).SetTotal(int64(max)).Start()
done := make(chan struct{})
defer func() {
done <- struct{}{}
bar.SetCurrent(bar.Total()).Finish()
}()
go func() {
ticker := time.NewTicker(250 * time.Millisecond)
for {
select {
case <-done:
return
case <-ticker.C:
value, max := stitchedImage.Progress()
bar.SetCurrent(int64(value)).SetTotal(int64(max))
}
}
}()
}
return exportJPEG(stitchedImage, outputPath)
}
func exportJPEG(img image.Image, outputPath string) error {
f, err := os.Create(outputPath)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
}
defer f.Close()
options := &jpeg.Options{
Quality: 80,
}
if err := jpeg.Encode(f, img, options); err != nil {
return fmt.Errorf("failed to encode image %q: %w", outputPath, err)
}
return nil
}

67
bin/stitch/export-png.go Normal file
View File

@ -0,0 +1,67 @@
// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"fmt"
"image"
"image/png"
"log"
"os"
"time"
"github.com/cheggaaa/pb/v3"
)
func exportPNGStitchedImage(stitchedImage *StitchedImage, outputPath string, bar *pb.ProgressBar) error {
log.Printf("Creating output file %q.", outputPath)
// If there is a progress bar, start a goroutine that regularly updates it.
// We will base the progress on the number of pixels read from the stitched image.
if bar != nil {
_, max := stitchedImage.Progress()
bar.SetRefreshRate(250 * time.Millisecond).SetTotal(int64(max)).Start()
done := make(chan struct{})
defer func() {
done <- struct{}{}
bar.SetCurrent(bar.Total()).Finish()
}()
go func() {
ticker := time.NewTicker(250 * time.Millisecond)
for {
select {
case <-done:
return
case <-ticker.C:
value, max := stitchedImage.Progress()
bar.SetCurrent(int64(value)).SetTotal(int64(max))
}
}
}()
}
return exportPNG(stitchedImage, outputPath)
}
func exportPNG(img image.Image, outputPath string) error {
f, err := os.Create(outputPath)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
}
defer f.Close()
encoder := png.Encoder{
CompressionLevel: png.DefaultCompression,
}
if err := encoder.Encode(f, img); err != nil {
return fmt.Errorf("failed to encode image %q: %w", outputPath, err)
}
return nil
}

73
bin/stitch/export-webp.go Normal file
View File

@ -0,0 +1,73 @@
// Copyright (c) 2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"fmt"
"image"
"log"
"os"
"time"
"github.com/Dadido3/go-libwebp/webp"
"github.com/cheggaaa/pb/v3"
)
func exportWebPStitchedImage(stitchedImage *StitchedImage, outputPath string, bar *pb.ProgressBar, webPLevel int) error {
log.Printf("Creating output file %q.", outputPath)
// If there is a progress bar, start a goroutine that regularly updates it.
// We will base the progress on the number of pixels read from the stitched image.
if bar != nil {
_, max := stitchedImage.Progress()
bar.SetRefreshRate(250 * time.Millisecond).SetTotal(int64(max)).Start()
done := make(chan struct{})
defer func() {
done <- struct{}{}
bar.SetCurrent(bar.Total()).Finish()
}()
go func() {
ticker := time.NewTicker(250 * time.Millisecond)
for {
select {
case <-done:
return
case <-ticker.C:
value, max := stitchedImage.Progress()
bar.SetCurrent(int64(value)).SetTotal(int64(max))
}
}
}()
}
return exportWebP(stitchedImage, outputPath, webPLevel)
}
func exportWebP(img image.Image, outputPath string, webPLevel int) error {
bounds := img.Bounds()
if bounds.Dx() > 16383 || bounds.Dy() > 16383 {
return fmt.Errorf("image size exceeds the maximum allowed size (16383) of a WebP image: %d x %d", bounds.Dx(), bounds.Dy())
}
f, err := os.Create(outputPath)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
}
defer f.Close()
webPConfig, err := webp.ConfigLosslessPreset(webPLevel)
if err != nil {
return fmt.Errorf("failed to create webP config: %v", err)
}
if err = webp.Encode(f, img, webPConfig); err != nil {
return fmt.Errorf("failed to encode image %q: %w", outputPath, err)
}
return nil
}

View File

@ -8,6 +8,7 @@ package main
import (
"fmt"
"image"
"image/draw"
_ "image/png"
"log"
"os"
@ -36,6 +37,7 @@ type ImageTile struct {
}
// NewImageTile returns an image tile object that represents the image at the given path.
// The filename will be used to determine the top left x and y coordinate of the tile.
// This will not load the image into RAM.
func NewImageTile(path string, scaleDivider int) (ImageTile, error) {
if scaleDivider < 1 {
@ -71,7 +73,7 @@ func NewImageTile(path string, scaleDivider int) (ImageTile, error) {
fileName: path,
modTime: modTime,
scaleDivider: scaleDivider,
image: image.Rect(x/scaleDivider, y/scaleDivider, (x+width)/scaleDivider, (y+height)/scaleDivider),
image: image.Rect(DivideFloor(x, scaleDivider), DivideFloor(y, scaleDivider), DivideCeil(x+width, scaleDivider), DivideCeil(y+height, scaleDivider)),
imageMutex: &sync.RWMutex{},
invalidationChan: make(chan struct{}, 1),
timeoutChan: make(chan struct{}, 1),
@ -126,9 +128,16 @@ func (it *ImageTile) GetImage() *image.RGBA {
img = resize.Resize(uint(oldRect.Dx()), uint(oldRect.Dy()), img, resize.NearestNeighbor)
}
imgRGBA, ok := img.(*image.RGBA)
if !ok {
log.Printf("Expected an RGBA image for %q, got %T instead.", it.fileName, img)
var imgRGBA *image.RGBA
switch img := img.(type) {
case *image.RGBA:
imgRGBA = img
case *image.NRGBA:
bounds := img.Bounds()
imgRGBA = image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy()))
draw.Draw(imgRGBA, imgRGBA.Bounds(), img, bounds.Min, draw.Src)
default:
log.Printf("Expected an RGBA or NRGBA image for %q, got %T instead.", it.fileName, img)
return nil
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 David Vogel
// Copyright (c) 2019-2023 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -7,6 +7,7 @@ package main
import (
"fmt"
"image"
"path/filepath"
)
@ -37,6 +38,20 @@ func LoadImageTiles(path string, scaleDivider int) (ImageTiles, error) {
return imageTiles, nil
}
// InvalidateAboveY invalidates all cached images that have no pixel at the given y coordinate or below.
func (it ImageTiles) Bounds() image.Rectangle {
totalBounds := image.Rectangle{}
for i, tile := range it {
if i == 0 {
totalBounds = tile.Bounds()
} else {
totalBounds = totalBounds.Union(tile.Bounds())
}
}
return totalBounds
}
// InvalidateAboveY invalidates all cached images that have no pixel at the given y coordinate or below.
func (it ImageTiles) InvalidateAboveY(y int) {
for i := range it {

View File

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 David Vogel
// Copyright (c) 2019-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -9,11 +9,9 @@ import (
"flag"
"fmt"
"image"
"image/png"
"log"
"os"
"path/filepath"
"sync"
"strings"
"time"
"github.com/1lann/promptui"
@ -23,9 +21,12 @@ import (
var flagInputPath = flag.String("input", filepath.Join(".", "..", "..", "output"), "The source path of the image tiles to be stitched.")
var flagEntitiesInputPath = flag.String("entities", filepath.Join(".", "..", "..", "output", "entities.json"), "The path to the entities.json file.")
var flagPlayerPathInputPath = flag.String("player-path", filepath.Join(".", "..", "..", "output", "player-path.json"), "The path to the player-path.json file.")
var flagOutputPath = flag.String("output", filepath.Join(".", "output.png"), "The path and filename of the resulting stitched image.")
var flagOutputPath = flag.String("output", filepath.Join(".", "output.png"), "The path and filename of the resulting stitched image. Supported formats/file extensions: `.png`, `.webp`, `.jpg`, `.dzi`.")
var flagScaleDivider = flag.Int("divide", 1, "A downscaling factor. 2 will produce an image with half the side lengths.")
var flagBlendTileLimit = flag.Int("blend-tile-limit", 9, "Limits median blending to the n newest tiles by file modification time. If set to 0, all available tiles will be median blended.")
var flagDZITileSize = flag.Int("dzi-tile-size", 512, "The size of the resulting deep zoom image (DZI) tiles in pixels.")
var flagDZIOverlap = flag.Int("dzi-tile-overlap", 2, "The number of additional pixels around every deep zoom image (DZI) tile.")
var flagWebPLevel = flag.Int("webp-level", 8, "Compression level of WebP files, from 0 (fast) to 9 (slow, best compression).")
var flagXMin = flag.Int("xmin", 0, "Left bound of the output rectangle. This coordinate is included in the output.")
var flagYMin = flag.Int("ymin", 0, "Upper bound of the output rectangle. This coordinate is included in the output.")
var flagXMax = flag.Int("xmax", 0, "Right bound of the output rectangle. This coordinate is not included in the output.")
@ -230,65 +231,125 @@ func main() {
*flagOutputPath = result
}
startTime := time.Now()
fileExtension := strings.ToLower(filepath.Ext(*flagOutputPath))
bar := pb.Full.New(0)
var wg sync.WaitGroup
done := make(chan struct{})
// Query the user, if there were no cmd arguments given.
if flag.NFlag() == 0 && fileExtension == ".dzi" {
prompt := promptui.Prompt{
Label: "Enter DZI tile size:",
Default: fmt.Sprint(*flagDZITileSize),
AllowEdit: true,
Validate: func(s string) error {
var num int
_, err := fmt.Sscanf(s, "%d", &num)
if err != nil {
return err
}
if int(num) < 1 {
return fmt.Errorf("number must be at least 1")
}
return nil
},
}
result, err := prompt.Run()
if err != nil {
log.Panicf("Error while getting user input: %v.", err)
}
fmt.Sscanf(result, "%d", flagDZITileSize)
}
// Query the user, if there were no cmd arguments given.
if flag.NFlag() == 0 && fileExtension == ".dzi" {
prompt := promptui.Prompt{
Label: "Enter DZI tile overlap:",
Default: fmt.Sprint(*flagDZIOverlap),
AllowEdit: true,
Validate: func(s string) error {
var num int
_, err := fmt.Sscanf(s, "%d", &num)
if err != nil {
return err
}
if int(num) < 0 {
return fmt.Errorf("number must be at least 0")
}
return nil
},
}
result, err := prompt.Run()
if err != nil {
log.Panicf("Error while getting user input: %v.", err)
}
fmt.Sscanf(result, "%d", flagDZIOverlap)
}
// Query the user, if there were no cmd arguments given.
if flag.NFlag() == 0 && (fileExtension == ".dzi" || fileExtension == ".webp") {
prompt := promptui.Prompt{
Label: "Enter WebP compression level:",
Default: fmt.Sprint(*flagWebPLevel),
AllowEdit: true,
Validate: func(s string) error {
var num int
_, err := fmt.Sscanf(s, "%d", &num)
if err != nil {
return err
}
if int(num) < 0 {
return fmt.Errorf("level must be at least 0")
}
if int(num) > 9 {
return fmt.Errorf("level must not be larger than 9")
}
return nil
},
}
result, err := prompt.Run()
if err != nil {
log.Panicf("Error while getting user input: %v.", err)
}
fmt.Sscanf(result, "%d", flagWebPLevel)
}
blendMethod := BlendMethodMedian{
BlendTileLimit: *flagBlendTileLimit, // Limit median blending to the n newest tiles by file modification time.
}
outputImage, err := NewStitchedImage(tiles, outputRect, blendMethod, 64, overlays)
stitchedImage, err := NewStitchedImage(tiles, outputRect, blendMethod, 128, overlays)
if err != nil {
log.Panicf("NewStitchedImage() failed: %v.", err)
}
_, max := outputImage.Progress()
bar.SetTotal(int64(max)).Start().SetRefreshRate(250 * time.Millisecond)
// Query progress and draw progress bar.
wg.Add(1)
go func() {
defer wg.Done()
bar := pb.Full.New(0)
ticker := time.NewTicker(250 * time.Millisecond)
for {
select {
case <-done:
value, _ := outputImage.Progress()
bar.SetCurrent(int64(value))
bar.Finish()
return
case <-ticker.C:
value, _ := outputImage.Progress()
bar.SetCurrent(int64(value))
switch fileExtension {
case ".png":
if err := exportPNGStitchedImage(stitchedImage, *flagOutputPath, bar); err != nil {
log.Panicf("Export of PNG file failed: %v", err)
}
case ".jpg", ".jpeg":
if err := exportJPEGStitchedImage(stitchedImage, *flagOutputPath, bar); err != nil {
log.Panicf("Export of JPEG file failed: %v", err)
}
}()
log.Printf("Creating output file %q.", *flagOutputPath)
f, err := os.Create(*flagOutputPath)
if err != nil {
log.Panic(err)
case ".webp":
if err := exportWebPStitchedImage(stitchedImage, *flagOutputPath, bar, *flagWebPLevel); err != nil {
log.Panicf("Export of WebP file failed: %v", err)
}
case ".dzi":
if err := exportDZIStitchedImage(stitchedImage, *flagOutputPath, bar, *flagDZITileSize, *flagDZIOverlap, *flagWebPLevel); err != nil {
log.Panicf("Export of DZI file failed: %v", err)
}
default:
log.Panicf("Unknown output format %q.", fileExtension)
}
encoder := png.Encoder{
CompressionLevel: png.DefaultCompression,
}
if err := encoder.Encode(f, outputImage); err != nil {
f.Close()
log.Panic(err)
}
done <- struct{}{}
wg.Wait()
if err := f.Close(); err != nil {
log.Panic(err)
}
log.Printf("Created output file %q in %v.", *flagOutputPath, time.Since(startTime))
log.Printf("Created output in %v.", time.Since(bar.StartTime()))
//fmt.Println("Press the enter key to terminate the console screen!")
//fmt.Scanln()

View File

@ -17,8 +17,8 @@ import (
)
var playerPathDisplayStyle = canvas.Style{
FillColor: canvas.Transparent,
//StrokeColor: color.RGBA{0, 0, 0, 127},
Fill: canvas.Paint{},
//Stroke: canvas.Paint{Color: color.RGBA{0, 0, 0, 127}},
StrokeWidth: 3.0,
StrokeCapper: canvas.ButtCap,
StrokeJoiner: canvas.MiterJoin,
@ -81,13 +81,13 @@ func (p PlayerPath) Draw(destImage *image.RGBA) {
if pathElement.Polymorphed {
// Set stroke color to typically polymorph color.
ctx.Style.StrokeColor = color.RGBA{127, 50, 83, 127}
ctx.Style.Stroke.Color = color.RGBA{127, 50, 83, 127}
} else {
// Set stroke color depending on HP level.
hpFactor := math.Max(math.Min(pathElement.HP/pathElement.MaxHP, 1), 0)
hpFactorInv := 1 - hpFactor
r, g, b, a := uint8((0*hpFactor+1*hpFactorInv)*127), uint8((1*hpFactor+0*hpFactorInv)*127), uint8(0), uint8(127)
ctx.Style.StrokeColor = color.RGBA{r, g, b, a}
ctx.Style.Stroke.Color = color.RGBA{r, g, b, a}
}
ctx.DrawPath(0, 0, path)
@ -96,6 +96,6 @@ func (p PlayerPath) Draw(destImage *image.RGBA) {
// Theoretically we would need to linearize imgRGBA first, but DefaultColorSpace assumes that the color space is linear already.
r := rasterizer.FromImage(originImage, canvas.DPMM(1.0), canvas.DefaultColorSpace)
c.Render(r)
c.RenderTo(r)
r.Close() // This just transforms the image's luminance curve back from linear into non linear.
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2022 David Vogel
// Copyright (c) 2022-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -8,6 +8,7 @@ package main
import (
"image"
"image/color"
"image/draw"
"runtime"
"sync"
)
@ -21,6 +22,8 @@ type StitchedImageCache struct {
rect image.Rectangle // Position and size of the cached area.
image *image.RGBA // Cached RGBA image. The bounds of this image are determined by the filename.
idleCounter byte // Is incremented when this cache object idles, and reset every time the cache is used.
}
func NewStitchedImageCache(stitchedImage *StitchedImage, rect image.Rectangle) StitchedImageCache {
@ -30,6 +33,21 @@ func NewStitchedImageCache(stitchedImage *StitchedImage, rect image.Rectangle) S
}
}
// InvalidateAuto invalidates this cache object when it had idled for too long.
// The cache will be invalidated after `threshold + 1` calls to InvalidateAuto.
func (sic *StitchedImageCache) InvalidateAuto(threshold byte) {
sic.Lock()
defer sic.Unlock()
if sic.image != nil {
if sic.idleCounter >= threshold {
sic.image = nil
return
}
sic.idleCounter++
}
}
// Invalidate clears the cached image.
func (sic *StitchedImageCache) Invalidate() {
sic.Lock()
@ -43,6 +61,8 @@ func (sic *StitchedImageCache) Regenerate() *image.RGBA {
sic.Lock()
defer sic.Unlock()
sic.idleCounter = 0
// Check if there is already a cache image.
if sic.image != nil {
return sic.image
@ -50,7 +70,9 @@ func (sic *StitchedImageCache) Regenerate() *image.RGBA {
si := sic.stitchedImage
// Create new image with default background color.
cacheImage := image.NewRGBA(sic.rect)
draw.Draw(cacheImage, cacheImage.Bounds(), &image.Uniform{colorBackground}, cacheImage.Bounds().Min, draw.Src)
// List of tiles that intersect with the to be generated cache image.
intersectingTiles := []*ImageTile{}
@ -114,6 +136,7 @@ func (sic *StitchedImageCache) RGBAAt(x, y int) color.RGBA {
sic.Lock()
if sic.image != nil {
defer sic.Unlock()
sic.idleCounter = 0
return sic.image.RGBAAt(x, y)
}
sic.Unlock()

View File

@ -1,4 +1,4 @@
// Copyright (c) 2022 David Vogel
// Copyright (c) 2022-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -10,8 +10,13 @@ import (
"image"
"image/color"
"sync/atomic"
"time"
)
// The default background color.
// We use a non transparent black.
var colorBackground = color.RGBA{0, 0, 0, 255}
// StitchedImageCacheGridSize defines the worker chunk size when the cache image is regenerated.
var StitchedImageCacheGridSize = 256
@ -61,9 +66,9 @@ func NewStitchedImage(tiles ImageTiles, bounds image.Rectangle, blendMethod Stit
}
// Generate cache image rows.
rows := bounds.Dy() / cacheRowHeight
maxRow := (bounds.Dy() - 1) / cacheRowHeight
var cacheRows []StitchedImageCache
for i := 0; i < rows; i++ {
for i := 0; i <= maxRow; i++ {
rect := image.Rect(bounds.Min.X, bounds.Min.Y+i*cacheRowHeight, bounds.Max.X, bounds.Min.Y+(i+1)*cacheRowHeight)
cacheRows = append(cacheRows, NewStitchedImageCache(stitchedImage, rect.Intersect(bounds)))
}
@ -71,6 +76,17 @@ func NewStitchedImage(tiles ImageTiles, bounds image.Rectangle, blendMethod Stit
stitchedImage.cacheRowYOffset = -bounds.Min.Y
stitchedImage.cacheRows = cacheRows
// Start ticker to automatically invalidate caches.
// Due to this, the stitchedImage object is not composable, as this goroutine will always have a reference.
go func() {
ticker := time.NewTicker(1 * time.Second)
for range ticker.C {
for rowIndex := range stitchedImage.cacheRows {
stitchedImage.cacheRows[rowIndex].InvalidateAuto(3) // Invalidate cache row after 3 seconds of being idle.
}
}
}()
return stitchedImage, nil
}
@ -104,7 +120,7 @@ func (si *StitchedImage) RGBAAt(x, y int) color.RGBA {
// Determine the cache rowIndex index.
rowIndex := (y + si.cacheRowYOffset) / si.cacheRowHeight
if rowIndex < 0 || rowIndex >= len(si.cacheRows) {
return color.RGBA{}
return colorBackground
}
// Check if we advanced/changed the row index.
@ -116,12 +132,6 @@ func (si *StitchedImage) RGBAAt(x, y int) color.RGBA {
go si.cacheRows[newRowIndex].Regenerate()
}
// Invalidate old cache row.
oldRowIndex := si.oldCacheRowIndex
if oldRowIndex >= 0 && oldRowIndex < len(si.cacheRows) {
si.cacheRows[oldRowIndex].Invalidate()
}
// Invalidate all tiles that are above the next row.
si.tiles.InvalidateAboveY((rowIndex+1)*si.cacheRowHeight - si.cacheRowYOffset)
@ -134,7 +144,7 @@ func (si *StitchedImage) RGBAAt(x, y int) color.RGBA {
// Opaque returns whether the image is fully opaque.
//
// For more speed and smaller file size, StitchedImage will be marked as non-transparent.
// This will speed up image saving by 2x, as there is no need to iterate over the whole image to find a single non opaque pixel.
// This will speed up image saving by 2x, as there is no need to iterate over the whole image just to find a single non opaque pixel.
func (si *StitchedImage) Opaque() bool {
return true
}
@ -145,3 +155,12 @@ func (si *StitchedImage) Progress() (value, max int) {
return int(si.queryCounter.Load()), size.X * size.Y
}
// SubStitchedImage returns an image representing the portion of the image p visible through r.
// The returned image references to the original stitched image, and therefore reuses its cache.
func (si *StitchedImage) SubStitchedImage(r image.Rectangle) SubStitchedImage {
return SubStitchedImage{
StitchedImage: si,
bounds: si.Bounds().Intersect(r),
}
}

View File

@ -0,0 +1,36 @@
// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"image"
"image/color"
)
type SubStitchedImage struct {
*StitchedImage // The original stitched image.
bounds image.Rectangle // The new bounds of the cropped image.
}
// Bounds returns the domain for which At can return non-zero color.
// The bounds do not necessarily contain the point (0, 0).
func (s SubStitchedImage) Bounds() image.Rectangle {
return s.bounds
}
func (s SubStitchedImage) At(x, y int) color.Color {
return s.RGBAAt(x, y)
}
func (s SubStitchedImage) RGBAAt(x, y int) color.RGBA {
point := image.Point{X: x, Y: y}
if !point.In(s.bounds) {
return colorBackground
}
return s.StitchedImage.RGBAAt(x, y)
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 David Vogel
// Copyright (c) 2019-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -9,6 +9,7 @@ import (
"fmt"
"image"
"os"
"sync"
)
// QuickSelect returns the kth smallest element of the given unsorted list.
@ -96,3 +97,44 @@ func DivideCeil(a, b int) int {
return temp
}
// https://gist.github.com/cstockton/d611ced26bb6b4d3f7d4237abb8613c4
type LimitGroup struct {
wg sync.WaitGroup
mu *sync.Mutex
c *sync.Cond
l, n int
}
func NewLimitGroup(n int) *LimitGroup {
mu := new(sync.Mutex)
return &LimitGroup{
mu: mu,
c: sync.NewCond(mu),
l: n,
n: n,
}
}
func (lg *LimitGroup) Add(delta int) {
lg.mu.Lock()
defer lg.mu.Unlock()
if delta > lg.l {
panic(`LimitGroup: delta must not exceed limit`)
}
for lg.n < 1 {
lg.c.Wait()
}
lg.n -= delta
lg.wg.Add(delta)
}
func (lg *LimitGroup) Done() {
lg.mu.Lock()
defer lg.mu.Unlock()
lg.n++
lg.c.Signal()
lg.wg.Done()
}
func (lg *LimitGroup) Wait() { lg.wg.Wait() }

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2019-2022 David Vogel
-- Copyright (c) 2019-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -32,7 +32,7 @@ Capture.PlayerPathCapturingCtx = Capture.PlayerPathCapturingCtx or ProcessRunner
---Returns a capturing rectangle in window coordinates, and also the world coordinates for the same rectangle.
---The rectangle is sized and placed in a way that aligns as pixel perfect as possible with the world coordinates.
---@param pos Vec2|nil -- Position of the viewport center in world coordinates. If set to nil, the viewport center will be queried automatically.
---@param pos Vec2? -- Position of the viewport center in world coordinates. If set to nil, the viewport center will be queried automatically.
---@return Vec2 topLeftCapture
---@return Vec2 bottomRightCapture
---@return Vec2 topLeftWorld
@ -53,19 +53,20 @@ end
---This will block until all chunks in the virtual rectangle are loaded.
---
---Don't set `ensureLoaded` to true when `pos` is nil!
---@param pos Vec2|nil -- Position of the viewport center in world coordinates. If set to nil, the viewport will not be modified.
---@param ensureLoaded boolean|nil -- If true, the function will wait until all chunks in the virtual rectangle are loaded.
---@param dontOverwrite boolean|nil -- If true, the function will abort if there is already a file with the same coordinates.
---@param ctx ProcessRunnerCtx|nil -- The process runner context this runs in.
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPixelScale)
---@param pos Vec2? -- Position of the viewport center in world coordinates. If set to nil, the viewport will not be modified.
---@param ensureLoaded boolean? -- If true, the function will wait until all chunks in the virtual rectangle are loaded.
---@param dontOverwrite boolean? -- If true, the function will abort if there is already a file with the same coordinates.
---@param ctx ProcessRunnerCtx? -- The process runner context this runs in.
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
---@param captureDelay number? -- The number of additional frames to wait before a screen capture.
local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPixelScale, captureDelay)
if outputPixelScale == 0 or outputPixelScale == nil then
outputPixelScale = Coords:PixelScale()
end
local rectTopLeft, rectBottomRight = ScreenCapture.GetRect()
if Coords.WindowResolution ~= rectBottomRight - rectTopLeft then
error(string.format("window size seems to have changed from %s to %s", Coords.WindowResolution, rectBottomRight - rectTopLeft))
if Coords:InternalRectSize() ~= rectBottomRight - rectTopLeft then
error(string.format("internal rectangle size seems to have changed from %s to %s", Coords:InternalRectSize(), rectBottomRight - rectTopLeft))
end
local topLeftCapture, bottomRightCapture, topLeftWorld, bottomRightWorld = calculateCaptureRectangle(pos)
@ -79,10 +80,23 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
return
end
-- Reset the count for the "Waiting for x frames." message in the UI.
if ctx then ctx.state.WaitFrames = 0 end
-- Wait some additional frames.
-- We will shake the screen a little bit so that Noita generates/populates chunks.
if captureDelay and captureDelay > 0 then
for _ = 1, captureDelay do
if pos then CameraAPI.SetPos(pos + Vec2(math.random(-1, 1), math.random(-1, 1))) end
wait(0)
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 1 end
end
end
if pos then CameraAPI.SetPos(pos) end
if ensureLoaded then
local delayFrames = 0
if ctx then ctx.state.WaitFrames = delayFrames end
repeat
-- Prematurely stop capturing if that is requested by the context.
if ctx and ctx:IsStopping() then return end
@ -92,25 +106,43 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
if pos then CameraAPI.SetPos(pos + Vec2(math.random(-10, 10), math.random(-10, 10))) end
wait(0)
delayFrames = delayFrames + 1
if ctx then ctx.state.WaitFrames = delayFrames end
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 1 end
if pos then CameraAPI.SetPos(pos) end
end
if delayFrames > 600 then
-- Shaking wasn't enough, we will just move somewhere else an try again.
if pos then CameraAPI.SetPos(pos + Vec2(math.random(-4000, 4000), math.random(-4000, 4000))) end
wait(50)
delayFrames = delayFrames + 50
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 50 end
if pos then CameraAPI.SetPos(pos) end
wait(10)
delayFrames = delayFrames + 10
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 10 end
end
wait(0)
delayFrames = delayFrames + 1
if ctx then ctx.state.WaitFrames = delayFrames end
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 1 end
local topLeftBounds, bottomRightBounds = CameraAPI:Bounds()
until DoesWorldExistAt(topLeftBounds.x, topLeftBounds.y, bottomRightBounds.x, bottomRightBounds.y)
-- Chunks are loaded and will be drawn on the *next* frame.
end
if ctx then ctx.state.WaitFrames = 0 end
-- Suspend UI drawing for 1 frame.
UI:SuspendDrawing(1)
-- First we wait one frame for the current state to be drawn.
wait(0)
-- Fetch coordinates again, as they may have changed.
-- At this point the needed frame is fully drawn, but the framebuffers are swapped.
-- Recalculate capture position and rectangle if we are not forcing any capture position.
-- We are in the `OnWorldPreUpdate` hook, this means that `CameraAPI.GetPos` return the position of the last frame.
if not pos then
topLeftCapture, bottomRightCapture, topLeftWorld, bottomRightWorld = calculateCaptureRectangle(pos)
if outputPixelScale > 0 then
@ -120,6 +152,10 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
end
end
-- Wait another frame.
-- After this `wait` the framebuffer will be swapped again, and we can grab the correct frame.
wait(0)
-- The top left world position needs to be upscaled by the pixel scale.
-- Otherwise it's not possible to stitch the images correctly.
if not ScreenCapture.Capture(topLeftCapture, bottomRightCapture, outputTopLeft, (bottomRightWorld - topLeftWorld) * outputPixelScale) then
@ -130,6 +166,37 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
MonitorStandby.ResetTimer()
end
---Captures a screenshot of the current viewport.
---This is used to capture animations, therefore the resulting image may not be suitable for stitching.
---@param outputPixelScale number? The resulting image pixel to world pixel ratio.
---@param frameNumber integer The frame number of the animation.
local function captureScreenshotAnimation(outputPixelScale, frameNumber)
if outputPixelScale == 0 or outputPixelScale == nil then
outputPixelScale = Coords:PixelScale()
end
local rectTopLeft, rectBottomRight = ScreenCapture.GetRect()
if not rectTopLeft or not rectBottomRight then
error(string.format("couldn't determine capturing rectangle"))
end
if Coords:InternalRectSize() ~= rectBottomRight - rectTopLeft then
error(string.format("internal rectangle size seems to have changed from %s to %s", Coords:InternalRectSize(), rectBottomRight - rectTopLeft))
end
local topLeftWorld, bottomRightWorld = Coords:ToWorld(rectTopLeft), Coords:ToWorld(rectBottomRight)
---We will use this to get our fame number into the filename.
---@type Vec2
local outputTopLeft = Vec2(frameNumber, 0)
if not ScreenCapture.Capture(rectTopLeft, rectBottomRight, outputTopLeft, (bottomRightWorld - topLeftWorld) * outputPixelScale) then
error(string.format("failed to capture screenshot"))
end
-- Reset monitor and PC standby every screenshot.
MonitorStandby.ResetTimer()
end
---Map capture process runner context error handler callback. Just rolls off the tongue.
---@param err string
---@param scope "init"|"do"|"end"
@ -142,8 +209,9 @@ end
---Use `Capture.MapCapturingCtx` to stop, control or view the progress.
---@param origin Vec2 -- Center of the spiral in world pixels.
---@param captureGridSize number -- The grid size in world pixels.
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
function Capture:StartCapturingSpiral(origin, captureGridSize, outputPixelScale)
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
---@param captureDelay number? -- The number of additional frames to wait before a screen capture.
function Capture:StartCapturingSpiral(origin, captureGridSize, outputPixelScale, captureDelay)
-- Create file that signals that there are files in the output directory.
local file = io.open("mods/noita-mapcap/output/nonempty", "a")
@ -167,23 +235,23 @@ function Capture:StartCapturingSpiral(origin, captureGridSize, outputPixelScale)
repeat
-- +x
for _ = 1, i, 1 do
captureScreenshot(pos, true, true, ctx, outputPixelScale)
captureScreenshot(pos, true, true, ctx, outputPixelScale, captureDelay)
pos:Add(Vec2(captureGridSize, 0))
end
-- +y
for _ = 1, i, 1 do
captureScreenshot(pos, true, true, ctx, outputPixelScale)
captureScreenshot(pos, true, true, ctx, outputPixelScale, captureDelay)
pos:Add(Vec2(0, captureGridSize))
end
i = i + 1
-- -x
for _ = 1, i, 1 do
captureScreenshot(pos, true, true, ctx, outputPixelScale)
captureScreenshot(pos, true, true, ctx, outputPixelScale, captureDelay)
pos:Add(Vec2(-captureGridSize, 0))
end
-- -y
for _ = 1, i, 1 do
captureScreenshot(pos, true, true, ctx, outputPixelScale)
captureScreenshot(pos, true, true, ctx, outputPixelScale, captureDelay)
pos:Add(Vec2(0, -captureGridSize))
end
i = i + 1
@ -200,27 +268,32 @@ function Capture:StartCapturingSpiral(origin, captureGridSize, outputPixelScale)
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
end
---Starts the capturing process of the given area.
---Starts the capturing process of the given area using a hilbert curve.
---Use `Capture.MapCapturingCtx` to stop, control or view the process.
---@param topLeft Vec2 -- Top left of the to be captured rectangle.
---@param bottomRight Vec2 -- Non included bottom left of the to be captured rectangle.
---@param bottomRight Vec2 -- Non inclusive bottom right coordinate of the to be captured rectangle.
---@param captureGridSize number -- The grid size in world pixels.
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
function Capture:StartCapturingArea(topLeft, bottomRight, captureGridSize, outputPixelScale)
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
---@param captureDelay number? -- The number of additional frames to wait before a screen capture.
function Capture:StartCapturingAreaHilbert(topLeft, bottomRight, captureGridSize, outputPixelScale, captureDelay)
-- Create file that signals that there are files in the output directory.
local file = io.open("mods/noita-mapcap/output/nonempty", "a")
if file ~= nil then file:close() end
---The rectangle in grid coordinates.
-- The capture offset which is needed to center the grid cells in the viewport.
local captureOffset = Vec2(captureGridSize / 2, captureGridSize / 2)
-- Get the extended capture rectangle that encloses all grid cells that need to be included in the capture.
-- In this case we only need to extend the capture area by the valid rendering rectangle.
local validTopLeft, validBottomRight = Coords:ValidRenderingRect()
local validTopLeftWorld, validBottomRightWorld = Coords:ToWorld(validTopLeft, topLeft + captureOffset), Coords:ToWorld(validBottomRight, bottomRight + captureOffset)
---The capture rectangle in grid coordinates.
---@type Vec2, Vec2
local gridTopLeft, gridBottomRight = (topLeft / captureGridSize):Rounded("floor"), (bottomRight / captureGridSize):Rounded("floor")
local gridTopLeft, gridBottomRight = (validTopLeftWorld / captureGridSize):Rounded("floor"), ((validBottomRightWorld) / captureGridSize):Rounded("ceil") - Vec2(1, 1)
-- Handle edge cases.
if topLeft.x == bottomRight.x then gridBottomRight.x = gridTopLeft.x end
if topLeft.y == bottomRight.y then gridBottomRight.y = gridTopLeft.y end
---Size of the rectangle in grid coordinates.
---Size of the rectangle in grid cells.
---@type Vec2
local gridSize = gridBottomRight - gridTopLeft
@ -249,8 +322,8 @@ function Capture:StartCapturingArea(topLeft, bottomRight, captureGridSize, outpu
---Position in world coordinates.
---@type Vec2
local pos = (hilbertPos + gridTopLeft) * captureGridSize
pos:Add(Vec2(captureGridSize / 2, captureGridSize / 2)) -- Move to center of grid cell.
captureScreenshot(pos, true, true, ctx, outputPixelScale)
pos:Add(captureOffset) -- Move to center of grid cell.
captureScreenshot(pos, true, true, ctx, outputPixelScale, captureDelay)
ctx.state.Current = ctx.state.Current + 1
end
@ -268,9 +341,73 @@ function Capture:StartCapturingArea(topLeft, bottomRight, captureGridSize, outpu
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
end
---Starts the capturing process of the given area by scanning from left to right, and top to bottom.
---Use `Capture.MapCapturingCtx` to stop, control or view the process.
---@param topLeft Vec2 -- Top left of the to be captured rectangle.
---@param bottomRight Vec2 -- Non inclusive bottom right coordinate of the to be captured rectangle.
---@param captureGridSize number -- The grid size in world pixels.
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
---@param captureDelay number? -- The number of additional frames to wait before a screen capture.
function Capture:StartCapturingAreaScan(topLeft, bottomRight, captureGridSize, outputPixelScale, captureDelay)
-- Create file that signals that there are files in the output directory.
local file = io.open("mods/noita-mapcap/output/nonempty", "a")
if file ~= nil then file:close() end
-- The capture offset which is needed to center the grid cells in the viewport.
local captureOffset = Vec2(captureGridSize / 2, captureGridSize / 2)
-- Get the extended capture rectangle that encloses all grid cells that need to be included in the capture.
-- In this case we only need to extend the capture area by the valid rendering rectangle.
local validTopLeft, validBottomRight = Coords:ValidRenderingRect()
local validTopLeftWorld, validBottomRightWorld = Coords:ToWorld(validTopLeft, topLeft + captureOffset), Coords:ToWorld(validBottomRight, bottomRight + captureOffset)
---The capture rectangle in grid coordinates.
---@type Vec2, Vec2
local gridTopLeft, gridBottomRight = (validTopLeftWorld / captureGridSize):Rounded("floor"), ((validBottomRightWorld) / captureGridSize):Rounded("ceil") - Vec2(1, 1)
---Size of the rectangle in grid cells.
---@type Vec2
local gridSize = gridBottomRight - gridTopLeft
---Process main callback.
---@param ctx ProcessRunnerCtx
local function handleDo(ctx)
Modification.SetCameraFree(true)
ctx.state = { Current = 0, Max = gridSize.x * gridSize.y }
for gridY = gridTopLeft.y, gridBottomRight.y-1, 1 do
for gridX = gridTopLeft.x, gridBottomRight.x-1, 1 do
-- Prematurely stop capturing if that is requested by the context.
if ctx:IsStopping() then return end
---Position in grid coordinates.
---@type Vec2
local gridPos = Vec2(gridX, gridY)
---Position in world coordinates.
---@type Vec2
local pos = gridPos * captureGridSize
pos:Add(captureOffset) -- Move to center of grid cell.
captureScreenshot(pos, true, true, ctx, outputPixelScale, captureDelay)
ctx.state.Current = ctx.state.Current + 1
end
end
end
---Process end callback.
---@param ctx ProcessRunnerCtx
local function handleEnd(ctx)
Modification.SetCameraFree()
end
-- Run process, if there is no other running right now.
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
end
---Starts the live capturing process.
---Use `Capture.MapCapturingCtx` to stop, control or view the process.
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
function Capture:StartCapturingLive(outputPixelScale)
---Queries the mod settings for the live capture parameters.
@ -308,7 +445,7 @@ function Capture:StartCapturingLive(outputPixelScale)
if oldPos then distanceSqr = CameraAPI.GetPos():DistanceSqr(oldPos) else distanceSqr = math.huge end
until ctx:IsStopping() or ((delayFrames >= interval or distanceSqr >= maxDistanceSqr) and distanceSqr >= minDistanceSqr)
captureScreenshot(nil, false, false, ctx, outputPixelScale)
captureScreenshot(nil, false, false, ctx, outputPixelScale, nil)
oldPos = CameraAPI.GetPos()
until ctx:IsStopping()
end
@ -323,8 +460,8 @@ function Capture:StartCapturingLive(outputPixelScale)
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
end
---Gathers all entities on the screen (around x, y within radius), serializes them, appends them into entityFile and modifies those entities.
---@param file file*|nil
---Gathers all entities on the screen (around x, y within radius), serializes them, appends them into entityFile and/or modifies those entities.
---@param file file*?
---@param modify boolean
---@param x number
---@param y number
@ -350,7 +487,7 @@ local function captureModifyEntities(file, modify, x, y, radius)
file:write(",\n\t", JSON.Marshal(rootEntity), "\n", "]")
end
-- Disabling this component will prevent entites from being killed/reset when they go offscreen.
-- Disabling this component will prevent entities from being killed/reset when they go offscreen.
-- If they are reset, all tags will be reset and we may capture these entities multiple times.
-- This has some side effects, like longleg.xml and zombie_weak.xml will respawn every revisit, as their spawner doesn't get deleted. (Or something similar to this)
local components = rootEntity:GetComponents("CameraBoundComponent")
@ -432,6 +569,11 @@ local function captureModifyEntities(file, modify, x, y, radius)
-- Prevent it from being modified again.
rootEntity:AddTag("MapModified")
-- Just a test on how to remove/kill creatures and enemies.
--if (rootEntity:HasTag("enemy") or rootEntity:HasTag("helpless_animal")) and not rootEntity:HasTag("boss") then
-- rootEntity:Kill()
--end
end
end
@ -442,7 +584,7 @@ local function captureModifyEntities(file, modify, x, y, radius)
end
---
---@return file*|nil
---@return file*?
local function createOrOpenEntityCaptureFile()
-- Make sure the file exists.
local file = io.open("mods/noita-mapcap/output/entities.json", "a")
@ -502,7 +644,7 @@ function Capture:StartCapturingEntities(store, modify)
end
---Writes the current player position and other stats onto disk.
---@param file file*|nil
---@param file file*?
---@param pos Vec2
---@param oldPos Vec2
---@param hp number
@ -535,7 +677,7 @@ local function writePlayerPathEntry(file, pos, oldPos, hp, maxHP, polymorphed)
end
---
---@return file*|nil
---@return file*?
local function createOrOpenPlayerPathCaptureFile()
-- Make sure the file exists.
local file = io.open("mods/noita-mapcap/output/player-path.json", "a")
@ -550,8 +692,8 @@ end
---Starts capturing the player path.
---Use `Capture.PlayerPathCapturingCtx` to stop, control or view the progress.
---@param interval integer|nil -- Wait time between captures in frames.
---@param outputPixelScale number|nil -- The resulting image pixel to world pixel ratio.
---@param interval integer? -- Wait time between captures in frames.
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
function Capture:StartCapturingPlayerPath(interval, outputPixelScale)
interval = interval or 20
@ -579,7 +721,7 @@ function Capture:StartCapturingPlayerPath(interval, outputPixelScale)
-- It seems that the entity can still be found by the tag, but its components/values can't be accessed anymore.
-- Solution: Don't do that.
---@type NoitaEntity|nil
---@type NoitaEntity?
local playerEntity
-- Try to find the regular player entity.
@ -639,6 +781,56 @@ function Capture:StartCapturingPlayerPath(interval, outputPixelScale)
self.PlayerPathCapturingCtx:Run(handleInit, handleDo, handleEnd, handleErr)
end
---Starts to capture an animation.
---This stores sequences of images that can't be stitched, but can be rendered into a video instead.
---Use `Capture.MapCapturingCtx` to stop, control or view the process.
---@param outputPixelScale number? -- The resulting image pixel to world pixel ratio.
function Capture:StartCapturingAnimation(outputPixelScale)
---Queries the mod settings for the live capture parameters.
---@return integer interval -- The interval length in frames.
local function querySettings()
local interval = 1--tonumber(ModSettingGet("noita-mapcap.live-interval")) or 30
return interval
end
-- Create file that signals that there are files in the output directory.
local file = io.open("mods/noita-mapcap/output/nonempty", "a")
if file ~= nil then file:close() end
---Process main callback.
---@param ctx ProcessRunnerCtx
local function handleDo(ctx)
Modification.SetCameraFree(false)
local frame = 0
repeat
local interval = querySettings()
-- Wait until we are allowed to take a new screenshot.
local delayFrames = 0
repeat
wait(0)
delayFrames = delayFrames + 1
until ctx:IsStopping() or delayFrames >= interval
captureScreenshotAnimation(outputPixelScale, frame)
frame = frame + 1
until ctx:IsStopping()
end
---Process end callback.
---@param ctx ProcessRunnerCtx
local function handleEnd(ctx)
Modification.SetCameraFree()
end
-- Run process, if there is no other running right now.
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
end
---Starts the capturing process based on user/mod settings.
function Capture:StartCapturing()
Message:CatchException("Capture:StartCapturing", function()
@ -646,21 +838,26 @@ function Capture:StartCapturing()
local mode = ModSettingGet("noita-mapcap.capture-mode")
local outputPixelScale = ModSettingGet("noita-mapcap.pixel-scale")
local captureGridSize = tonumber(ModSettingGet("noita-mapcap.grid-size"))
local captureDelay = tonumber(ModSettingGet("noita-mapcap.capture-delay"))
if mode == "live" then
self:StartCapturingLive(outputPixelScale)
self:StartCapturingPlayerPath(5, outputPixelScale) -- Capture player path with an interval of 5 frames.
elseif mode == "animation" then
self:StartCapturingAnimation(outputPixelScale)
elseif mode == "area" then
local area = ModSettingGet("noita-mapcap.area")
if area == "custom" then
local topLeft = Vec2(ModSettingGet("noita-mapcap.area-top-left"))
local bottomRight = Vec2(ModSettingGet("noita-mapcap.area-bottom-right"))
self:StartCapturingArea(topLeft, bottomRight, captureGridSize, outputPixelScale)
self:StartCapturingAreaScan(topLeft, bottomRight, captureGridSize, outputPixelScale, captureDelay)
else
local predefinedArea = Config.CaptureArea[area]
if predefinedArea then
self:StartCapturingArea(predefinedArea.TopLeft, predefinedArea.BottomRight, captureGridSize, outputPixelScale)
---@type fun():Vec2, Vec2
local predefinedAreaFunction = Config.CaptureArea[area]
if predefinedAreaFunction then
local topLeft, bottomRight = predefinedAreaFunction()
self:StartCapturingAreaScan(topLeft, bottomRight, captureGridSize, outputPixelScale, captureDelay)
else
Message:ShowRuntimeError("PredefinedArea", string.format("Unknown predefined capturing area %q", tostring(area)))
end
@ -669,13 +866,13 @@ function Capture:StartCapturing()
local origin = ModSettingGet("noita-mapcap.capture-mode-spiral-origin")
if origin == "custom" then
local originVec = Vec2(ModSettingGet("noita-mapcap.capture-mode-spiral-origin-vector"))
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale)
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale, captureDelay)
elseif origin == "0" then
local originVec = Vec2(0, 0)
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale)
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale, captureDelay)
elseif origin == "current" then
local originVec = CameraAPI:GetPos()
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale)
self:StartCapturingSpiral(originVec, captureGridSize, outputPixelScale, captureDelay)
else
Message:ShowRuntimeError("SpiralOrigin", string.format("Unknown spiral origin %q", tostring(origin)))
end

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2019-2022 David Vogel
-- Copyright (c) 2019-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -47,14 +47,14 @@ function Check:Regular(interval)
self.Counter = interval
-- Remove some messages, so they will automatically disappear when the problem is solved.
Message:CloseAutoclose()
Message:CloseAutoClose()
-- Compare Noita config and actual window resolution.
local topLeft, bottomRight = ScreenCap.GetRect() -- Actual window client area.
if topLeft and bottomRight then
local actual = bottomRight - topLeft
if actual ~= Coords.WindowResolution then
Message:ShowWrongResolution(Modification.AutoSet, string.format("Old window resolution is %s. Current resolution is %s.", Coords.WindowResolution, actual))
if actual ~= Coords:InternalRectSize() then
Message:ShowWrongResolution(Modification.AutoSet, string.format("Internal rectangle size is %s. Current resolution is %s.", Coords:InternalRectSize(), actual))
end
else
Message:ShowRuntimeError("GetRect", "Couldn't determine window resolution.")
@ -83,7 +83,13 @@ function Check:Regular(interval)
if config["screenshake_intensity"] then
local expected = config.screenshake_intensity
if expected ~= self.StartupConfig.screenshake_intensity then
Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Screenshake intensity is %s, expected %s.", self.StartupConfig.screenshake_intensity, expected))
Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Screen shake intensity is %s, expected %s.", self.StartupConfig.screenshake_intensity, expected))
end
end
if config["application_rendered_cursor"] then
local expected = config.application_rendered_cursor
if expected ~= self.StartupConfig.application_rendered_cursor then
Message:ShowSetNoitaSettings(Modification.AutoSet, string.format("Application rendered cursor is %s, expected %s.", self.StartupConfig.application_rendered_cursor, expected))
end
end
@ -114,7 +120,7 @@ function Check:Regular(interval)
-- This is not perfect, as it doesn't take rounding and cropping into account, so the actual captured area may be a few pixels smaller.
local mode = ModSettingGet("noita-mapcap.capture-mode")
local captureGridSize = tonumber(ModSettingGet("noita-mapcap.grid-size"))
if mode ~= "live" and (Coords.VirtualResolution.x < captureGridSize or Coords.VirtualResolution.y < captureGridSize) then
if (mode ~= "live" and mode ~= "animation") and (Coords.VirtualResolution.x < captureGridSize or Coords.VirtualResolution.y < captureGridSize) then
Message:ShowGeneralSettingsProblem(
"The virtual resolution is smaller than the capture grid size.",
"This means that you will get black areas in your final stitched image.",

View File

@ -1,8 +1,9 @@
-- Copyright (c) 2022 David Vogel
-- Copyright (c) 2022-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
local NXML = require("luanxml.nxml")
local Vec2 = require("noita-api.vec2")
-- List of components that will be disabled on every encountered entity.
@ -27,22 +28,65 @@ Config.ComponentsToDisable = {
--"AudioComponent",
}
local CHUNK_SIZE = 512
---Returns the rectangle of the base area as two vectors.
---@return Vec2 TopLeft Top left corner in world coordinates.
---@return Vec2 BottomRight Bottom right corner in world coordinates. This pixel is not included in the final rectangle.
local function getBaseArea()
local xml = NXML.parse(ModTextFileGetContent("data/biome/_biomes_all.xml"))
local width, height = BiomeMapGetSize()
local offsetX, offsetY = math.floor(width/2), xml.attr.biome_offset_y -- TODO: This may not be right. Check what Noita is really doing when we have a biome map with an odd width.
return Vec2(-offsetX, -offsetY)*CHUNK_SIZE, Vec2(-offsetX+width, -offsetY+height)*CHUNK_SIZE
--return Vec2(-17920, -7168), Vec2(17920, 17408) -- Coordinates for a "New Game" without mods or anything.
end
---A list of capture areas.
---This contains functions that determine the capture area based on the biome size and other parameters.
---The returned vectors are the top left corner, and the bottom right corner of the capture area in world coordinates.
---The bottom right corner pixel is not included in the rectangle.
---@type table<string, fun():Vec2, Vec2>
Config.CaptureArea = {
-- Base layout: Every part outside this is based on a similar layout, but uses different materials/seeds.
["1x1"] = {
TopLeft = Vec2(-17920, -7168), -- in world coordinates.
BottomRight = Vec2(17920, 17408), -- in world coordinates. This pixel is not included in the rectangle.
},
["1x1"] = getBaseArea,
-- Main world: The main world with 3 parts: sky, normal and hell.
["1x3"] = {
TopLeft = Vec2(-17920, -31744), -- in world coordinates.
BottomRight = Vec2(17920, 41984), -- in world coordinates. This pixel is not included in the rectangle.
},
["1x3"] = function()
local width, height = BiomeMapGetSize()
local topLeft, bottomRight = getBaseArea()
return topLeft + Vec2(0, -height)*CHUNK_SIZE, bottomRight + Vec2(0, height)*CHUNK_SIZE
--return Vec2(-17920, -31744), Vec2(17920, 41984) -- Coordinates for a "New Game" without mods or anything.
end,
-- -1 parallel world: The parallel world with 3 parts: sky, normal and hell.
["1x3 -1"] = function()
local width, height = BiomeMapGetSize()
local topLeft, bottomRight = getBaseArea()
return topLeft + Vec2(-width, -height)*CHUNK_SIZE, bottomRight + Vec2(-width, height)*CHUNK_SIZE
--return Vec2(-17920, -31744) + Vec2(-35840, 0), Vec2(17920, 41984) + Vec2(-35840, 0) -- Coordinates for a "New Game" without mods or anything.
end,
-- +1 parallel world: The parallel world with 3 parts: sky, normal and hell.
["1x3 +1"] = function()
local width, height = BiomeMapGetSize()
local topLeft, bottomRight = getBaseArea()
return topLeft + Vec2(width, -height)*CHUNK_SIZE, bottomRight + Vec2(width, height)*CHUNK_SIZE
--return Vec2(-17920, -31744) + Vec2(35840, 0), Vec2(17920, 41984) + Vec2(35840, 0) -- Coordinates for a "New Game" without mods or anything.
end,
-- Extended: Main world + a fraction of the parallel worlds to the left and right.
["1.5x3"] = {
TopLeft = Vec2(-25600, -31744), -- in world coordinates.
BottomRight = Vec2(25600, 41984), -- in world coordinates. This pixel is not included in the rectangle.
},
["1.5x3"] = function()
local width, height = BiomeMapGetSize()
local topLeft, bottomRight = getBaseArea()
return topLeft + Vec2(-math.floor(0.25*width), -height)*CHUNK_SIZE, bottomRight + Vec2(math.floor(0.25*width), height)*CHUNK_SIZE
--return Vec2(-25600, -31744), Vec2(25600, 41984) -- Coordinates for a "New Game" without mods or anything. These coordinates may not exactly be 1.5 of the base width for historic reasons.
end,
-- Extended: Main world + each parallel world to the left and right.
["3x3"] = function()
local width, height = BiomeMapGetSize()
local topLeft, bottomRight = getBaseArea()
return topLeft + Vec2(-width, -height)*CHUNK_SIZE, bottomRight + Vec2(width, height)*CHUNK_SIZE
--return Vec2(-53760, -31744), Vec2(53760, 41984) -- Coordinates for a "New Game" without mods or anything.
end,
}

View File

@ -126,7 +126,7 @@ function Coords:PixelScale()
end
---Converts the given virtual/world coordinates into window/screen coordinates.
---@param world Vec2 -- World coordiante, origin is near the cave entrance.
---@param world Vec2 -- World coordinate, origin is near the cave entrance.
---@param viewportCenter Vec2|nil -- Result of `GameGetCameraPos()`. Will be queried automatically if set to nil.
---@return Vec2 window
function Coords:ToWindow(world, viewportCenter)

View File

@ -0,0 +1,58 @@
-- Copyright (c) 2022 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
local ffi = require("ffi")
local Memory = {}
if ffi.abi'64bit' then
ffi.cdef([[
typedef uint64_t __uint3264;
]])
else
ffi.cdef([[
typedef uint32_t __uint3264;
]])
end
ffi.cdef([[
typedef void VOID;
typedef VOID *LPVOID;
typedef int BOOL;
typedef __uint3264 ULONG_PTR, *PULONG_PTR;
typedef ULONG_PTR SIZE_T, *PSIZE_T;
typedef unsigned long DWORD;
typedef DWORD *PDWORD;
BOOL VirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
]])
Memory.PAGE_NOACCESS = 0x01
Memory.PAGE_READONLY = 0x02
Memory.PAGE_READWRITE = 0x04
Memory.PAGE_WRITECOPY = 0x08
Memory.PAGE_EXECUTE = 0x10
Memory.PAGE_EXECUTE_READ = 0x20
Memory.PAGE_EXECUTE_READWRITE = 0x40
Memory.PAGE_EXECUTE_WRITECOPY = 0x80
Memory.PAGE_GUARD = 0x100
Memory.PAGE_NOCACHE = 0x200
Memory.PAGE_WRITECOMBINE = 0x400
---Changes the protection on a region of committed pages in the virtual address space of the calling process.
---@param addr ffi.cdata*
---@param size integer
---@param newProtect integer
---@return ffi.cdata* oldProtect
function Memory.VirtualProtect(addr, size, newProtect)
local oldProtect = ffi.new('DWORD[1]')
if not ffi.C.VirtualProtect(addr, size, newProtect, oldProtect) then
error(string.format("failed to call VirtualProtect(%s, %s, %s)", addr, size, newProtect))
end
return oldProtect
end
return Memory

View File

@ -18,7 +18,7 @@ local CameraAPI = {}
---
---@param strength number
---@param position Vec2|nil -- Defaults to camera position if not set.
function CameraAPI.Screenshake(strength, position)
function CameraAPI.ScreenShake(strength, position)
if position == nil then
return GameScreenshake(strength)
end

View File

@ -28,7 +28,7 @@ end
-- Package doesn't exist when the Lua API is restricted.
-- Therefore we create it here and apply some default values.
package = package or {}
package.path = package.path or "./?.lua;" -- Allow paths relative to the working directory.
package.path = package.path or "./?.lua" -- Allow paths relative to the working directory.
package.preload = package.preload or {}
package.loaded = package.loaded or {
_G = _G,
@ -64,7 +64,7 @@ local oldRequire = require
local recursionSet = {}
---Emulated require function in case the Lua API is restricted.
---It's probably good enough for most usecases.
---It's probably good enough for most use cases.
---
---We need to override the default require in any case, as only dofile and loadfile can access stuff in the virtual filesystem.
---@param modName string
@ -141,12 +141,13 @@ end
---Set up some stuff so `require` works as expected.
---@param libPath any -- Path to the libraries directory of this mod.
local function setup(libPath)
-- Add the files folder of the given mod as base for any `require` lookups.
package.path = package.path .. "./" .. libPath .. "?.lua;"
package.path = package.path .. "./" .. libPath .. "?/init.lua;"
-- Add the library directory of the mod as base for any `require` lookups.
package.path = package.path:gsub(";$", "") -- Get rid of any trailing semicolon.
package.path = package.path .. ";./" .. libPath .. "?.lua"
package.path = package.path .. ";./" .. libPath .. "?/init.lua"
-- Add the library directory of Noita itself.
package.path = package.path .. "./data/scripts/lib/?.lua;" -- TODO: Get rid of Noita's lib path, create replacement libs for stuff in there
package.path = package.path .. ";./data/scripts/lib/?.lua" -- TODO: Get rid of Noita's lib path, create replacement libs for stuff in there
end
return setup

View File

@ -64,7 +64,7 @@ function NoitaComponent:SetValue(fieldName, ...)
return ComponentSetValue2(self.ID, fieldName, ...) -- TODO: Rework Noita API to handle vectors, and use a vector instead of shitty multi value arguments
end
---Returns one or many values matching the type or subtypes of the requested field in a component subobject.
---Returns one or many values matching the type or subtypes of the requested field in a component sub-object.
---Reports error and returns nil if the field type is not supported or 'object_name' is not a metaobject.
---
---Reporting errors means that it spams the stdout with messages, instead of using the lua error handling. Thanks Nolla.
@ -75,7 +75,7 @@ function NoitaComponent:ObjectGetValue(objectName, fieldName)
return ComponentObjectGetValue2(self.ID, objectName, fieldName) -- TODO: Rework Noita API to handle vectors, and return a vector instead of some shitty multi value result
end
---Sets the value of a field in a component subobject. Value(s) should have a type matching the field type.
---Sets the value of a field in a component sub-object. Value(s) should have a type matching the field type.
---Reports error if the values weren't given in correct type, the field type is not supported or 'object_name' is not a metaobject.
---@param objectName string
---@param fieldName string

View File

@ -48,7 +48,7 @@ end
---Enables the trailer mode and some other things:
---
--- - Disables ingame GUI.
--- - Disables in-game GUI.
--- - Opens fog of war everywhere (Not the same as disabling it completely).
--- - Enables `mTrailerMode`, whatever that does.
---

View File

@ -327,7 +327,7 @@ end
---Creates a component of type 'component_type_name' and adds it to 'entity_id'.
---'table_of_component_values' should be a string-indexed table, where keys are field names and values are field values of correct type.
---The value setting works like ComponentObjectSetValue2(), with the exception that multivalue types are not supported.
---The value setting works like ComponentObjectSetValue2(), with the exception that multi value types are not supported.
---Additional supported values are _tags:comma_separated_string and _enabled:bool, which basically work like the those fields work in entity XML files.
---Returns the created component, if creation succeeded, or nil.
---@param componentTypeName string

View File

@ -3,7 +3,7 @@
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
-- This contains just some utilitites that may be useful to have.
-- This contains just some utilities that may be useful to have.
local DebugAPI = require("noita-api.debug")

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2019-2022 David Vogel
-- Copyright (c) 2019-2023 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -24,6 +24,13 @@ ffi.cdef([[
LONG bottom;
} RECT;
typedef struct {
LONG x;
LONG y;
LONG width;
LONG height;
} GLViewportDims;
bool GetRect(RECT* rect);
bool Capture(RECT* rect, int x, int y, int sx, int sy);
]])

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2019-2022 David Vogel
-- Copyright (c) 2019-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -12,18 +12,19 @@
--------------------------
local Coords = require("coordinates")
local DebugAPI = require("noita-api.debug")
----------
-- Code --
----------
---Removes all messages with the autoclose flag.
---Removes all messages with the AutoClose flag.
---Use this before you recreate all auto closing messages.
function Message:CloseAutoclose()
function Message:CloseAutoClose()
self.List = self.List or {}
for k, message in pairs(self.List) do
if message.Autoclose then
if message.AutoClose then
self.List[k] = nil
end
end
@ -64,7 +65,7 @@ function Message:ShowResetNoitaSettings()
Lines = {
"You requested to reset some game settings like:",
"- Custom resolutions",
"- Screenshake intensity",
"- Screen-shake intensity",
" ",
"Press the following button to reset the settings and close Noita automatically:",
},
@ -94,7 +95,7 @@ function Message:ShowSetNoitaSettings(callback, desc)
Actions = {
{ Name = "Setup and close (May corrupt current save!)", Hint = nil, HintDesc = nil, Callback = callback },
},
Autoclose = true, -- This message will automatically close.
AutoClose = true, -- This message will automatically close.
}
end
@ -111,7 +112,7 @@ function Message:ShowRequestRestart(desc)
" ",
"To resolve this issue, restart the game.",
},
Autoclose = true, -- This message will automatically close.
AutoClose = true, -- This message will automatically close.
}
end
@ -127,12 +128,15 @@ function Message:ShowWrongResolution(callback, desc)
"The resolution changed:",
desc or "",
" ",
"To fix: Restart Noita or revert the change."
"Press the button at the bottom to set up and close Noita automatically.",
" ",
"You can always reset any custom settings by right clicking the `start capture`",
"button at the top left.",
},
Actions = {
{ Name = "Query settings again", Hint = nil, HintDesc = nil, Callback = function() Coords:ReadResolutions() end },
{ Name = "Setup and close (May corrupt current save!)", Hint = nil, HintDesc = nil, Callback = callback },
},
Autoclose = true, -- This message will automatically close.
AutoClose = true, -- This message will automatically close.
}
end
@ -162,7 +166,7 @@ function Message:ShowGeneralSettingsProblem(...)
self.List["GeneralSettingsProblem"] = {
Type = "hint",
Lines = { ... },
Autoclose = true, -- This message will automatically close.
AutoClose = true, -- This message will automatically close.
}
end
@ -176,3 +180,61 @@ function Message:ShowGeneralInstallationProblem(...)
Lines = { ... },
}
end
---Tell the user that some modification couldn't be applied because it is unsupported.
---@param realm "config"|"magicNumbers"|"processMemory"|"filePatches"
---@param name string
---@param value any
function Message:ShowModificationUnsupported(realm, name, value)
self.List = self.List or {}
self.List["ModificationFailed"] = self.List["ModificationFailed"] or {
Type = "warning",
}
-- Create or append to list of modifications.
-- We have to prevent duplicate entries.
self.List["ModificationFailed"].ModificationEntries = self.List["ModificationFailed"].ModificationEntries or {}
local found
for _, modEntry in ipairs(self.List["ModificationFailed"].ModificationEntries) do
if modEntry.realm == realm and modEntry.name == name then
found = true
break
end
end
if not found then
table.insert(self.List["ModificationFailed"].ModificationEntries, {realm = realm, name = name, value = value})
end
-- Build message lines.
self.List["ModificationFailed"].Lines = {"The mod couldn't apply the following changes:"}
table.insert(self.List["ModificationFailed"].Lines, " ")
for _, modEntry in ipairs(self.List["ModificationFailed"].ModificationEntries) do
table.insert(self.List["ModificationFailed"].Lines, string.format("- %q in %q realm", modEntry.name, modEntry.realm))
end
table.insert(self.List["ModificationFailed"].Lines, " ")
table.insert(self.List["ModificationFailed"].Lines, "This simply means that the mod can't automatically apply this change in the Noita version you are using.")
table.insert(self.List["ModificationFailed"].Lines, "If you are running a non-beta version of Noita, feel free to open an issue at https://github.com/Dadido3/noita-mapcap.")
-- Tell the user to change some settings manually, if possible.
local manuallyWithF7 = {}
local possibleManualWithF7 = {mPostFxDisabled = true, mGuiDisabled = true, mGuiHalfSize = true, mFogOfWarOpenEverywhere = true, mTrailerMode = true, mDayTimeRotationPause = true, mPlayerNeverDies = true, mFreezeAI = true}
for _, modEntry in ipairs(self.List["ModificationFailed"].ModificationEntries) do
if modEntry.realm == "processMemory" and possibleManualWithF7[modEntry.name] then
table.insert(manuallyWithF7, modEntry)
end
end
if #manuallyWithF7 > 0 then
table.insert(self.List["ModificationFailed"].Lines, " ")
table.insert(self.List["ModificationFailed"].Lines, "You can apply the setting manually:")
table.insert(self.List["ModificationFailed"].Lines, " ")
table.insert(self.List["ModificationFailed"].Lines, "- Press F7 to open the debug menu.")
for _, modEntry in ipairs(manuallyWithF7) do
table.insert(self.List["ModificationFailed"].Lines, string.format("- Change %q to %q.", modEntry.name, modEntry.value))
end
table.insert(self.List["ModificationFailed"].Lines, "- Press F7 again to close the menu.")
table.insert(self.List["ModificationFailed"].Lines, "- Close this warning when you are done.")
end
end

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2022 David Vogel
-- Copyright (c) 2022-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -19,9 +19,11 @@
local CameraAPI = require("noita-api.camera")
local Coords = require("coordinates")
local ffi = require("ffi")
local Memory = require("memory")
local NXML = require("luanxml.nxml")
local Utils = require("noita-api.utils")
local Vec2 = require("noita-api.vec2")
local DebugAPI = require("noita-api.debug")
----------
-- Code --
@ -92,38 +94,316 @@ end
---@param memory table
function Modification.SetMemoryOptions(memory)
-- Lookup table with the following hierarchy:
-- DevBuild -> OS -> BuildDate -> Option -> Address.
-- DevBuild -> OS -> BuildDate -> Option -> ModFunc.
local lookup = {
[true] = {
Windows = {
[0x00F77B0C] = { _BuildString = "Build Apr 23 2021 18:36:55", -- GOG dev build.
mPostFxDisabled = 0x010E3B6C,
mGuiDisabled = 0x010E3B6D,
mGuiHalfSize = 0x010E3B6E,
mFogOfWarOpenEverywhere = 0x010E3B6F,
mTrailerMode = 0x010E3B70,
mDayTimeRotationPause = 0x010E3B71,
mPlayerNeverDies = 0x010E3B72,
mFreezeAI = 0x010E3B73,
{_Offset = 0x00F77B0C, _BuildString = "Build Apr 23 2021 18:36:55", -- GOG dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010E3B6C)[0] = value end, -- Can be found by using Cheat Engine while toggling options in the F7 menu.
mGuiDisabled = function(value) ffi.cast("char*", 0x010E3B6D)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010E3B6E)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010E3B6F)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010E3B70)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010E3B71)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010E3B72)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010E3B73)[0] = value end,
},
[0x00F80384] = { _BuildString = "Build Apr 23 2021 18:40:40", -- Steam dev build.
mPostFxDisabled = 0x010EDEBC,
mGuiDisabled = 0x010EDEBD,
mGuiHalfSize = 0x010EDEBE,
mFogOfWarOpenEverywhere = 0x010EDEBF,
mTrailerMode = 0x010EDEC0,
mDayTimeRotationPause = 0x010EDEC1,
mPlayerNeverDies = 0x010EDEC2,
mFreezeAI = 0x010EDEC3,
{_Offset = 0x00F80384, _BuildString = "Build Apr 23 2021 18:40:40", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010EDEBC)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x010EDEBD)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010EDEBE)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010EDEBF)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010EDEC0)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010EDEC1)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010EDEC2)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010EDEC3)[0] = value end,
},
{_Offset = 0x00F8A7B4, _BuildString = "Build Mar 11 2023 14:05:19", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010F80EC)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x010F80ED)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010F80EE)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010F80EF)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010F80F0)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010F80F1)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010F80F2)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010F80F3)[0] = value end,
},
{_Offset = 0x00F8A8A4, _BuildString = "Build Jun 19 2023 14:14:52", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010F810C)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x010F810D)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010F810E)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010F810F)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010F8110)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010F8111)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010F8112)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010F8113)[0] = value end,
},
{_Offset = 0x00F82464, _BuildString = "Build Jul 26 2023 23:06:16", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010E9A5C)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x010E9A5D)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010E9A5E)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010E9A5F)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010E9A60)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010E9A61)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010E9A62)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010E9A63)[0] = value end,
},
{_Offset = 0x00FA654C, _BuildString = "Build Dec 19 2023 18:34:31", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x011154BC)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x011154BD)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x011154BE)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x011154BF)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x011154C0)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x011154C1)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x011154C2)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x011154C3)[0] = value end,
},
{_Offset = 0x00F8A9DC, _BuildString = "Build Dec 21 2023 00:07:29", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010F814C)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x010F814D)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010F814E)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010F814F)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010F8150)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010F8151)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010F8152)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010F8153)[0] = value end,
},
{_Offset = 0x00F71DE4, _BuildString = "Build Dec 29 2023 23:36:18", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x0111758C)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x0111758D)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x0111758E)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x0111758F)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x01117590)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x01117591)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x01117592)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x01117593)[0] = value end,
},
{_Offset = 0x00F74FA8, _BuildString = "Build Dec 30 2023 19:37:04", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x0111A5BC)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x0111A5BD)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x0111A5BE)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x0111A5BF)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x0111A5C0)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x0111A5C1)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x0111A5C2)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x0111A5C3)[0] = value end,
},
{_Offset = 0x00F8BA04, _BuildString = "Build Jan 18 2024 12:57:44", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x010F91FC+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x010F91FC+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x010F91FC+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x010F91FC+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x010F91FC+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x010F91FC+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x010F91FC+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x010F91FC+7)[0] = value end,
},
{_Offset = 0x0117091C, _BuildString = "Build Feb 2 2024 14:29:06", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x0130585C)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x0130585D)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x0130585E)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x0130585F)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x01305860)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x01305861)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x01305862)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x01305863)[0] = value end,
},
{_Offset = 0x01173F34, _BuildString = "Build Feb 6 2024 15:54:02", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x0130982C+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x0130982C+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x0130982C+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x0130982C+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x0130982C+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x0130982C+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x0130982C+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x0130982C+7)[0] = value end,
},
{_Offset = 0x01182F70, _BuildString = "Build Mar 25 2024 17:42:49", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x013198AC+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x013198AC+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x013198AC+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x013198AC+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x013198AC+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x013198AC+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x013198AC+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x013198AC+7)[0] = value end,
},
{_Offset = 0x011871FC, _BuildString = "Build Apr 6 2024 20:50:04", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x0131D89C+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x0131D89C+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x0131D89C+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x0131D89C+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x0131D89C+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x0131D89C+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x0131D89C+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x0131D89C+7)[0] = value end,
},
{_Offset = 0x0118718C, _BuildString = "Build Apr 8 2024 18:07:16", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x0131D8DC+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x0131D8DC+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x0131D8DC+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x0131D8DC+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x0131D8DC+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x0131D8DC+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x0131D8DC+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x0131D8DC+7)[0] = value end,
},
{_Offset = 0x0118FD3C, _BuildString = "Build Aug 12 2024 21:10:13", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x01327D3C+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x01327D3C+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x01327D3C+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x01327D3C+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x01327D3C+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x01327D3C+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x01327D3C+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x01327D3C+7)[0] = value end,
},
{_Offset = 0x0118FD3C, _BuildString = "Build Aug 12 2024 21:43:22", -- Steam dev build.
mPostFxDisabled = function(value) ffi.cast("char*", 0x01327D3C+0)[0] = value end,
mGuiDisabled = function(value) ffi.cast("char*", 0x01327D3C+1)[0] = value end,
mGuiHalfSize = function(value) ffi.cast("char*", 0x01327D3C+2)[0] = value end,
mFogOfWarOpenEverywhere = function(value) ffi.cast("char*", 0x01327D3C+3)[0] = value end,
mTrailerMode = function(value) ffi.cast("char*", 0x01327D3C+4)[0] = value end,
mDayTimeRotationPause = function(value) ffi.cast("char*", 0x01327D3C+5)[0] = value end,
mPlayerNeverDies = function(value) ffi.cast("char*", 0x01327D3C+6)[0] = value end,
mFreezeAI = function(value) ffi.cast("char*", 0x01327D3C+7)[0] = value end,
},
},
},
[false] = {
Windows = {
[0x00E1C550] = { _BuildString = "Build Apr 23 2021 18:44:24", -- Steam build.
--enableModDetection = 0x0063D8AD, -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
-- The page this is in is not writable, so this will crash Noita.
-- This modification can be applied manually with some other tool that changes the permission prior to writing, like Cheat Engine.
{_Offset = 0x00E1C550, _BuildString = "Build Apr 23 2021 18:44:24", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x0063D8AD) -- Can be found by searching for the pattern C6 80 20 01 00 00 >01< 8B CF E8 FB 1D. The pointer has to point to the highlighted byte.
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E22E18, _BuildString = "Build Mar 11 2023 14:09:24", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006429ED)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E22E18, _BuildString = "Build Jun 19 2023 14:18:46", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006429ED)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E146D4, _BuildString = "Build Jul 26 2023 23:10:16", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x0064390D)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E333F4, _BuildString = "Build Dec 19 2023 18:38:23", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x00624C5D)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E23EC4, _BuildString = "Build Dec 21 2023 00:11:06", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x0064246D)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E14FA0, _BuildString = "Build Dec 29 2023 23:40:18", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x00625FFD)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E180E8, _BuildString = "Build Dec 30 2023 19:40:49", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x00626EFD)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E24E6C, _BuildString = "Build Jan 18 2024 13:01:21", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x00642A47+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00FECE94, _BuildString = "Build Feb 2 2024 14:33:26", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006AD407)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00FEEFC0, _BuildString = "Build Feb 6 2024 15:58:22", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006AD611+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00FF21D8, _BuildString = "Build Feb 9 2024 15:52:49", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006AE101+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00FF22D4, _BuildString = "Build Feb 12 2024 19:07:19", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006AE161+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00E23E80, _BuildString = "Build Feb 14 2024 07:46:57", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006427A7+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x00FFDB54, _BuildString = "Build Mar 25 2024 17:48:04", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006B1FD8+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x01001DDC, _BuildString = "Build Apr 6 2024 20:54:23", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006B35B5+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x01001DF4, _BuildString = "Build Apr 8 2024 18:11:27", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006B3355+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x01007CA4, _BuildString = "Build Aug 12 2024 21:14:23", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006B3925+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
{_Offset = 0x01007CA4, _BuildString = "Build Aug 12 2024 21:48:01", -- Steam build.
enableModDetection = function(value)
local ptr = ffi.cast("char*", 0x006B3925+6)
Memory.VirtualProtect(ptr, 1, Memory.PAGE_EXECUTE_READWRITE)
ptr[0] = value -- This basically just changes the value that Noita forces to the "mods_have_been_active_during_this_run" member of the WorldStateComponent when any mod is enabled.
end,
},
},
},
@ -131,24 +411,26 @@ function Modification.SetMemoryOptions(memory)
-- Look up the tree and set options accordingly.
local level1 = lookup[DebugGetIsDevBuild()]
if level1 == nil then return end
local level1 = lookup[DebugAPI.IsDevBuild()]
level1 = level1 or {}
local level2 = level1[ffi.os]
if level2 == nil then return end
level2 = level2 or {}
local level3
for k, v in pairs(level2) do
if ffi.string(ffi.cast("char*", k)) == v._BuildString then
local level3 = {}
for _, v in ipairs(level2) do
if ffi.string(ffi.cast("char*", v._Offset)) == v._BuildString then
level3 = v
break
end
end
for k, v in pairs(memory) do
local address = level3[k]
if address ~= nil then
ffi.cast("char*", address)[0] = v
local modFunc = level3[k]
if modFunc ~= nil then
modFunc(v)
else
Message:ShowModificationUnsupported("processMemory", k, v)
end
end
end
@ -166,6 +448,13 @@ function Modification.PatchFiles(patches)
end
ModTextFileSetContent("data/shaders/post_final.frag", postFinal)
end
if patches.PostFinalReplace then
local postFinal = ModTextFileGetContent("data/shaders/post_final.frag")
for k, v in pairs(patches.PostFinalReplace) do
postFinal = postFinal:gsub(k, v)
end
ModTextFileSetContent("data/shaders/post_final.frag", postFinal)
end
end
---Returns tables with user requested game configuration changes.
@ -187,12 +476,16 @@ function Modification.RequiredChanges()
config["internal_size_h"] = tostring(Vec2(ModSettingGet("noita-mapcap.internal-resolution")).y)
config["backbuffer_width"] = config["window_w"]
config["backbuffer_height"] = config["window_h"]
config["fullscreen"] = "0"
magic["VIRTUAL_RESOLUTION_X"] = tostring(Vec2(ModSettingGet("noita-mapcap.virtual-resolution")).x)
magic["VIRTUAL_RESOLUTION_Y"] = tostring(Vec2(ModSettingGet("noita-mapcap.virtual-resolution")).y)
-- Set virtual offset to prevent/reduce not correctly drawn pixels at the window border.
magic["GRID_RENDER_BORDER"] = "3" -- This will widen the right side of the virtual rectangle. It also shifts the world coordinates to the right.
magic["VIRTUAL_RESOLUTION_OFFSET_X"] = "-3"
magic["VIRTUAL_RESOLUTION_OFFSET_Y"] = "0"
magic["STREAMING_CHUNK_TARGET"] = "16" -- Keep more chunks alive.
magic["GRID_MAX_UPDATES_PER_FRAME"] = "1024" -- Allow more pixel physics simulation steps (in 32x32 regions) per frame. With too few, objects can glitch through the terrain/explode.
magic["GRID_MIN_UPDATES_PER_FRAME"] = "0" -- Also allow no updates.
else
-- Reset some values if there is no custom resolution requested.
config["internal_size_w"] = "1280"
@ -204,13 +497,12 @@ function Modification.RequiredChanges()
magic["VIRTUAL_RESOLUTION_OFFSET_Y"] = "-1"
end
-- Always expect a fullscreen mode of 0 (windowed).
-- Capturing will not work in fullscreen.
config["fullscreen"] = "0"
-- Also disable screenshake.
-- Also disable screen shake.
config["screenshake_intensity"] = "0"
-- And disable the cursor being rendered by Noita itself, which would make it appear in screen captures.
config["application_rendered_cursor"] = "0"
magic["DRAW_PARALLAX_BACKGROUND"] = ModSettingGet("noita-mapcap.disable-background") and "0" or "1"
-- These magic numbers seem only to work in the dev build.
@ -218,6 +510,11 @@ function Modification.RequiredChanges()
magic["DEBUG_PAUSE_BOX2D"] = ModSettingGet("noita-mapcap.disable-physics") and "1" or "0"
magic["DEBUG_DISABLE_POSTFX_DITHERING"] = ModSettingGet("noita-mapcap.disable-postfx") and "1" or "0"
-- These magic numbers stop any grid updates (pixel physics), even in the release build.
-- But any Box2D objects glitch, therefore the mod option (disable-physics) is disabled and hidden in the non dev build.
--magic["GRID_MAX_UPDATES_PER_FRAME"] = ModSettingGet("noita-mapcap.disable-physics") and "0" or "128"
--magic["GRID_MIN_UPDATES_PER_FRAME"] = ModSettingGet("noita-mapcap.disable-physics") and "1" or "40"
if ModSettingGet("noita-mapcap.disable-postfx") then
patches.PostFinalConst = {
ENABLE_REFRACTION = false,
@ -231,19 +528,31 @@ function Modification.RequiredChanges()
FOG_FOREGROUND_NIGHT = "vec4(0.0,0.0,0.0,1.0)",
FOG_BACKGROUND_NIGHT = "vec3(0.0,0.0,0.0)",
}
-- Disable color grading, which may make the world look a tad more blue when there is freezing/snowing weather.
-- This is dependent on the seed and the PC's wall clock, and it only snows in December, January or February.
patches.PostFinalReplace = {
["color%.rgb = mix%( color, additive_overlay_color%.rgb, additive_overlay_color%.a %);"] = "",
["color = mix%(color, vec3%(%(color%.r %+ color%.g %+ color%.b%) %* 0%.3333%), color_grading%.a%);"] = "",
["color = color %* color_grading%.rgb;"] = "// Here lies the remains of the tone-mapping/color grading code. 2019-2024. RIP",
}
end
if ModSettingGet("noita-mapcap.disable-shaders-gui-ai") then
if ModSettingGet("noita-mapcap.disable-shaders-gui-ai") and DebugAPI.IsDevBuild() then
memory["mPostFxDisabled"] = 1
memory["mGuiDisabled"] = 1
memory["mFreezeAI"] = 1
memory["mTrailerMode"] = 1 -- Is necessary for chunks to correctly load when DEBUG_PAUSE_GRID_UPDATE is enabled.
end
if ModSettingGet("noita-mapcap.disable-mod-detection") then
if DebugAPI.IsDevBuild() and magic["DEBUG_PAUSE_GRID_UPDATE"] == "1" then
memory["mTrailerMode"] = 1 -- This is necessary for chunks to correctly load when DEBUG_PAUSE_GRID_UPDATE is enabled.
end
if ModSettingGet("noita-mapcap.disable-mod-detection") and not DebugAPI.IsDevBuild() then
memory["enableModDetection"] = 0
else
memory["enableModDetection"] = 1
-- Don't actively (re)enable mod detection.
--memory["enableModDetection"] = 1
end
-- Disables or hides most of the UI.

View File

@ -8,7 +8,7 @@
-----------------------
-- TODO: Wrap Noita utilities and wrap them into a table: https://stackoverflow.com/questions/9540732/loadfile-without-polluting-global-environment
require("utilities") -- Loads Noita's utilities from `data/scripts/lib/utilitites.lua`.
require("utilities") -- Loads Noita's utilities from `data/scripts/lib/utilities.lua`.
--------------------------
-- Load library modules --
@ -146,7 +146,7 @@ function UI:_DrawMessages(messages)
end
GuiLayoutEnd(gui)
if not message.Autoclose then
if not message.AutoClose then
local clicked = GuiImageButton(gui, self:_GenID(), 5, 0, "", "mods/noita-mapcap/files/ui-gfx/dismiss-8x8.png")
--GuiTooltip(gui, "Dismiss message", "")
if clicked then messages[key] = nil end
@ -196,7 +196,7 @@ function UI:Draw()
local gui = self.gui
-- Skip drawing if we are asked to do so.
-- TODO: Find a way to susped UI drawing, but still being able to receive events
-- TODO: Find a way to suspend UI drawing, but still being able to receive events
if self.suspendFrames and self.suspendFrames > 0 then self.suspendFrames = self.suspendFrames - 1 return end
self.suspendFrames = nil

52
go.mod
View File

@ -1,41 +1,43 @@
module github.com/Dadido3/noita-mapcap
go 1.19
go 1.22
require (
github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1
github.com/cheggaaa/pb/v3 v3.1.0
github.com/coreos/go-semver v0.3.0
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329
github.com/Dadido3/go-libwebp v0.3.0
github.com/cheggaaa/pb/v3 v3.1.4
github.com/coreos/go-semver v0.3.1
github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/tdewolff/canvas v0.0.0-20220627195642-6566432f4b20
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75
github.com/tdewolff/canvas v0.0.0-20231218015800-2ad5075e9362
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848
)
require (
github.com/ByteArena/poly2tri-go v0.0.0-20170716161910-d102ad91854f // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/adrg/strutil v0.3.0 // indirect
github.com/adrg/sysfont v0.1.2 // indirect
github.com/adrg/xdg v0.4.0 // indirect
github.com/benoitkugler/textlayout v0.1.3 // indirect
github.com/benoitkugler/textprocessing v0.0.2 // indirect
github.com/benoitkugler/textlayout v0.3.0 // indirect
github.com/benoitkugler/textprocessing v0.0.3 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5 // indirect
github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/gen2brain/shm v0.1.0 // indirect
github.com/go-fonts/latin-modern v0.3.2 // indirect
github.com/go-fonts/liberation v0.3.2 // indirect
github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea // indirect
github.com/go-text/typesetting v0.0.0-20231219150831-cc0073efdbb4 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240 // indirect
github.com/jezek/xgb v1.1.1 // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/tdewolff/minify/v2 v2.11.10 // indirect
github.com/tdewolff/parse/v2 v2.6.0 // indirect
golang.org/x/image v0.0.0-20220617043117-41969df76e82 // indirect
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/tdewolff/minify/v2 v2.20.10 // indirect
github.com/tdewolff/parse/v2 v2.7.7 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.16.0 // indirect
star-tex.org/x/tex v0.4.0 // indirect
)

179
go.sum
View File

@ -1,32 +1,25 @@
git.sr.ht/~sbinet/gg v0.3.1 h1:LNhjNn8DerC8f9DHLz6lS0YYul/b602DUxDgGkd/Aik=
git.sr.ht/~sbinet/gg v0.5.0 h1:6V43j30HM623V329xA9Ntq+WJrMjDxRjuAB1LFWF5m8=
git.sr.ht/~sbinet/gg v0.5.0/go.mod h1:G2C0eRESqlKhS7ErsNey6HHrqU1PwsnCQlekFi9Q2Oo=
github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1 h1:LejjvYg4tCW5HO7q/1nzPrprh47oUD9OUySQ29pDp5c=
github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1/go.mod h1:cnC/60IoLiDM0GhdKYJ6oO7AwpZe1IQfPnSKlAURgHw=
github.com/ByteArena/poly2tri-go v0.0.0-20170716161910-d102ad91854f h1:l7moT9o/v/9acCWA64Yz/HDLqjcRTvc0noQACi4MsJw=
github.com/ByteArena/poly2tri-go v0.0.0-20170716161910-d102ad91854f/go.mod h1:vIOkSdX3NDCPwgu8FIuTat2zDF0FPXXQ0RYFRy+oQic=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/Dadido3/go-libwebp v0.3.0 h1:Qr3Gt8Kn4qgemezDVnjAJffMB9C0QJhxP+9u0U5mC94=
github.com/Dadido3/go-libwebp v0.3.0/go.mod h1:rYiWwlI58XRSMUFMw23nMezErbjX3Z5Xv0Kk3w6Mwwo=
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
github.com/adrg/strutil v0.2.2/go.mod h1:EF2fjOFlGTepljfI+FzgTG13oXthR7ZAil9/aginnNQ=
github.com/adrg/strutil v0.3.0 h1:bi/HB2zQbDihC8lxvATDTDzkT4bG7PATtVnDYp5rvq4=
github.com/adrg/strutil v0.3.0/go.mod h1:Jz0wzBVE6Uiy9wxo62YEqEY1Nwto3QlLl1Il5gkLKWU=
github.com/adrg/sysfont v0.1.2 h1:MSU3KREM4RhsQ+7QgH7wPEPTgAgBIz0Hw6Nd4u7QgjE=
github.com/adrg/sysfont v0.1.2/go.mod h1:6d3l7/BSjX9VaeXWJt9fcrftFaD/t7l11xgSywCPZGk=
github.com/adrg/xdg v0.3.0/go.mod h1:7I2hH/IT30IsupOpKZ5ue7/qNi3CoKzD6tL3HwpaRMQ=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw=
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM=
github.com/benoitkugler/pstokenizer v1.0.0/go.mod h1:l1G2Voirz0q/jj0TQfabNxVsa8HZXh/VMxFSRALWTiE=
github.com/benoitkugler/textlayout v0.0.10/go.mod h1:puH4v13Uz7uIhIH0XMk5jgc8U3MXcn5r3VlV9K8n0D8=
github.com/benoitkugler/textlayout v0.1.3 h1:Jv0E28xDkke3KrWle90yOLtBmZsUqXLBy70lZRfbKN0=
github.com/benoitkugler/textlayout v0.1.3/go.mod h1:o+1hFV+JSHBC9qNLIuwVoLedERU7sBPgEFcuSgfvi/w=
github.com/benoitkugler/textlayout-testdata v0.1.1 h1:AvFxBxpfrQd8v55qH59mZOJOQjtD6K2SFe9/HvnIbJk=
github.com/benoitkugler/textprocessing v0.0.2 h1:PHduXv1+LsLxDIdeR3sG1qvHhWwkbL+ZZcjkOmu38T4=
github.com/benoitkugler/textprocessing v0.0.2/go.mod h1:QwonW08YlX3qeZ3vv91Wyic3JqG+MXBa05N6rHwJaOc=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
github.com/cheggaaa/pb/v3 v3.1.0 h1:3uouEsl32RL7gTiQsuaXD4Bzbfl5tGztXGUvXbs4O04=
github.com/cheggaaa/pb/v3 v3.1.0/go.mod h1:YjrevcBqadFDaGQKRdmZxTY42pXEqda48Ea3lt0K/BE=
github.com/benoitkugler/textlayout v0.3.0 h1:2ehWXEkgb6RUokTjXh1LzdGwG4dRP6X3dqhYYDYhUVk=
github.com/benoitkugler/textlayout v0.3.0/go.mod h1:o+1hFV+JSHBC9qNLIuwVoLedERU7sBPgEFcuSgfvi/w=
github.com/benoitkugler/textlayout-testdata v0.1.1/go.mod h1:i/qZl09BbUOtd7Bu/W1CAubRwTWrEXWq6JwMkw8wYxo=
github.com/benoitkugler/textprocessing v0.0.3 h1:Q2X+Z6vxuW5Bxn1R9RaNt0qcprBfpc2hEUDeTlz90Ng=
github.com/benoitkugler/textprocessing v0.0.3/go.mod h1:/4bLyCf1QYywunMK3Gf89Nhb50YI/9POewqrLxWhxd4=
github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY=
github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8=
github.com/cheggaaa/pb/v3 v3.1.4 h1:DN8j4TVVdKu3WxVwcRKu0sG00IIU6FewoABZzXbRQeo=
github.com/cheggaaa/pb/v3 v3.1.4/go.mod h1:6wVjILNBaXMs8c21qRiaUM8BR82erfgau1DQ4iUXmSA=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
@ -36,119 +29,89 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/djherbis/atime v1.1.0/go.mod h1:28OF6Y8s3NQWwacXc5eZTsEsiMzp7LF8MbXE+XJPdBE=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5 h1:Y5Q2mEwfzjMt5+3u70Gtw93ZOu2UuPeeeTBDntF7FoY=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo=
github.com/go-fonts/dejavu v0.1.0 h1:JSajPXURYqpr+Cu8U9bt8K+XcACIHWqWrvWCKyeFmVQ=
github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g=
github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks=
github.com/go-fonts/liberation v0.2.0 h1:jAkAWJP4S+OsrPLZM4/eC9iW7CtHy+HBXrEwZXWo5VM=
github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY=
github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY=
github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81 h1:6zl3BbBhdnMkpSj2YY30qV3gDcVBGtFgVsV3+/i+mKQ=
github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk=
github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
github.com/go-pdf/fpdf v0.6.0 h1:MlgtGIfsdMEEQJr2le6b/HNr1ZlQwxyWr77r2aj2U/8=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/gen2brain/shm v0.1.0 h1:MwPeg+zJQXN0RM9o+HqaSFypNoNEcNpeoGp0BTSx2YY=
github.com/gen2brain/shm v0.1.0/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA=
github.com/go-fonts/latin-modern v0.3.2 h1:M+Sq24Dp0ZRPf3TctPnG1MZxRblqyWC/cRUL9WmdaFc=
github.com/go-fonts/latin-modern v0.3.2/go.mod h1:9odJt4NbRrbdj4UAMuLVd4zEukf6aAEKnDaQga0whqQ=
github.com/go-fonts/liberation v0.3.2 h1:XuwG0vGHFBPRRI8Qwbi5tIvR3cku9LUfZGq/Ar16wlQ=
github.com/go-fonts/liberation v0.3.2/go.mod h1:N0QsDLVUQPy3UYg9XAc3Uh3UDMp2Z7M1o4+X98dXkmI=
github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea h1:DfZQkvEbdmOe+JK2TMtBM+0I9GSdzE2y/L1/AmD8xKc=
github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea/go.mod h1:Y7Vld91/HRbTBm7JwoI7HejdDB0u+e9AUBO9MB7yuZk=
github.com/go-pdf/fpdf v0.9.0 h1:PPvSaUuo1iMi9KkaAn90NuKi+P4gwMedWPHhj8YlJQw=
github.com/go-pdf/fpdf v0.9.0/go.mod h1:oO8N111TkmKb9D7VvWGLvLJlaZUQVPM+6V42pp3iV4Y=
github.com/go-text/typesetting v0.0.0-20231219150831-cc0073efdbb4 h1:MKnPksPov832ct2c9a40QUB+2lgf2pBo7N92TxAAFA8=
github.com/go-text/typesetting v0.0.0-20231219150831-cc0073efdbb4/go.mod h1:MrLApvxyzSW0MhQqLc484jkUWYX4wsEvEqDosB5Io80=
github.com/go-text/typesetting-utils v0.0.0-20231204162240-fa4dc564ba79 h1:3yBOzx29wog0i7TnUBMcp90EwIb+A5kqmr5vny1UOm8=
github.com/go-text/typesetting-utils v0.0.0-20231204162240-fa4dc564ba79/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240 h1:dy+DS31tGEGCsZzB45HmJJNHjur8GDgtRNX9U7HnSX4=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240/go.mod h1:3P4UH/k22rXyHIJD2w4h2XMqPX4Of/eySEZq9L6wqc4=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329 h1:qq2nCpSrXrmvDGRxW0ruW9BVEV1CN2a9YDOExdt+U0o=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329/go.mod h1:2VPVQDR4wO7KXHwP+DAypEy67rXf+okUx2zjgpCxZw4=
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237 h1:YOp8St+CM/AQ9Vp4XYm4272E77MptJDHkwypQHIRl9Q=
github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237/go.mod h1:e7qQlOY68wOz4b82D7n+DdaptZAi+SHW0+yKiWZzEYE=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY=
github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.3 h1:dAm0YRdRQlWojc3CrCRgPBzG5f941d0zvAKu7qY4e+I=
github.com/tdewolff/canvas v0.0.0-20220627195642-6566432f4b20 h1:n1uiUjN7FaL+7vXRcXi/W5mAggYzfRwcKOV6JP9U1ag=
github.com/tdewolff/canvas v0.0.0-20220627195642-6566432f4b20/go.mod h1:EUhKKb2ofHjd7fnOdhBaqZYlTdF2Mu/gtYg2bwIt6wU=
github.com/tdewolff/minify/v2 v2.11.10 h1:2tk9nuKfc8YOTD8glZ7JF/VtE8W5HOgmepWdjcPtRro=
github.com/tdewolff/minify/v2 v2.11.10/go.mod h1:dHOS3dk+nJ0M3q3uM3VlNzTb70cou+ov0ki7C4PAFgM=
github.com/tdewolff/parse/v2 v2.6.0 h1:f2D7w32JtqjCv6SczWkfwK+m15et42qEtDnZXHoNY70=
github.com/tdewolff/parse/v2 v2.6.0/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.7 h1:8Vs0142DmPFW/bQeHRP3MV19m1gvndjUb1sn8yy74LM=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/tdewolff/canvas v0.0.0-20231218015800-2ad5075e9362 h1:E9HkFtZcjoZQCaSyb2Finw4jhC0NWOJ2DCCoAMYrXLg=
github.com/tdewolff/canvas v0.0.0-20231218015800-2ad5075e9362/go.mod h1:hGxWCl1a3KdYh6pxYy9sa9jLAlmKLMeuCSCjjy39iVE=
github.com/tdewolff/minify/v2 v2.20.10 h1:iz9IkdRqD2pyneib/AvTas23RRG5TnuUFNcNVKmL/jU=
github.com/tdewolff/minify/v2 v2.20.10/go.mod h1:xSJ9fXIfyuEMex88JT4jl8GvXnl/RzWNdqD96AqKlX0=
github.com/tdewolff/parse/v2 v2.7.7 h1:V+50eFDH7Piw4IBwH8D8FtYeYbZp3T4SCtIvmBSIMyc=
github.com/tdewolff/parse/v2 v2.7.7/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.11-0.20231121141655-2d5236e10ae4 h1:CmTImZFElFD07EUPqgMEraDMnJX1E5oJKeibjg0SC2c=
github.com/tdewolff/test v1.0.11-0.20231121141655-2d5236e10ae4/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75 h1:x03zeu7B2B11ySp+daztnwM5oBJ/8wGUSqrwcw9L0RA=
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE=
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20220617043117-41969df76e82 h1:KpZB5pUSBvrHltNEdK/tw0xlPeD13M6M6aGP32gKqiw=
golang.org/x/image v0.0.0-20220617043117-41969df76e82/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gonum.org/v1/plot v0.11.0 h1:z2ZkgNqW34d0oYUzd80RRlc0L9kWtenqK4kflZG1lGc=
gonum.org/v1/plot v0.14.0 h1:+LBDVFYwFe4LHhdP8coW6296MBEY4nQ+Y4vuUpJopcE=
gonum.org/v1/plot v0.14.0/go.mod h1:MLdR9424SJed+5VqC6MsouEpig9pZX2VZ57H9ko2bXU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
star-tex.org/x/tex v0.4.0 h1:AXUwgpnHLCxZUWW3qrmjv6ezNhH3PjUVBuLLejz2cgU=
star-tex.org/x/tex v0.4.0/go.mod h1:w91ycsU/DkkCr7GWr60GPWqp3gn2U+6VX71T0o8k8qE=

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2022 David Vogel
-- Copyright (c) 2022-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -108,7 +108,6 @@ end
---Called *every* time the game is about to start updating the world.
function OnWorldPreUpdate()
Message:CatchException("OnWorldPreUpdate", function()
-- Coroutines aren't run every frame in this lua sandbox, do it manually here.
wake_up_waiting_threads(1)
@ -150,10 +149,13 @@ end
---@param isPaused boolean
---@param isInventoryPause boolean
function OnPausedChanged(isPaused, isInventoryPause)
Message:CatchException("OnPausedChanged", function()
-- Set some stuff based on mod settings.
-- Normally this would be in `OnModSettingsChanged`, but that doesn't seem to be called.
local config, magic, memory, patches = Modification.RequiredChanges()
Modification.SetMemoryOptions(memory)
end)
end
---Will be called when the game is unpaused, if player changed any mod settings while the game was paused.

View File

@ -62,7 +62,7 @@ func addPathToZip(zipWriter *zip.Writer, srcPath, archiveBasePath string, ignore
return err
}
header.Name = archivePath
header.Name = filepath.ToSlash(archivePath)
header.Method = zip.Deflate
writer, err := zipWriter.CreateHeader(header)

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2022 David Vogel
-- Copyright (c) 2022-2024 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -67,15 +67,15 @@ modSettings = {
{
id = "capture-mode",
ui_name = "Mode",
ui_description = "How the mod captures:\n- Live: Capture as you play along.\n- Area: Capture a defined area of the world.\n- Spiral: Capture in a spiral around a starting point indefinitely.",
ui_description = "How the mod captures:\n- Live: Capture as you play along.\n- Area: Capture a defined area of the world.\n- Spiral: Capture in a spiral around a starting point indefinitely.\n- Animation: Capture the screen frame by frame.",
value_default = "live",
values = { { "live", "Live" }, { "area", "Area" }, { "spiral", "Spiral" } },
values = { { "live", "Live" }, { "area", "Area" }, { "spiral", "Spiral" }, { "animation", "Animation"} },
scope = MOD_SETTING_SCOPE_RUNTIME,
},
{
id = "capture-mode-spiral-origin",
ui_name = " Origin",
ui_description = "The starting point or center of the spiral.\n- Current position: Your ingame position.\n- World origin: Near the cave entrance.\n- Custom position: Enter your own coordinates.",
ui_description = "The starting point or center of the spiral.\n- Current position: Your in-game position.\n- World origin: Near the cave entrance.\n- Custom position: Enter your own coordinates.",
value_default = "current",
values = { { "current", "Current position" }, { "0", "World origin" }, { "custom", "Custom position" } },
scope = MOD_SETTING_SCOPE_RUNTIME,
@ -95,7 +95,7 @@ modSettings = {
ui_name = " Rectangle",
ui_description = "The area to be captured.\nSee documentation for more information.",
value_default = "1x1",
values = { { "1x1", "Base layout" }, { "1x3", "Main World" }, { "1.5x3", "Extended" }, { "custom", "Custom" } },
values = { { "1x1", "Base layout" }, { "1x3", "Main World" }, { "1x3 -1", "-1 Parallel World" }, { "1x3 +1", "+1 Parallel World" }, { "1.5x3", "Extended" }, { "3x3", "3 Worlds" }, { "custom", "Custom" } },
scope = MOD_SETTING_SCOPE_RUNTIME,
show_fn = function() return modSettings:GetNextValue("capture-mode") == "area" end,
},
@ -143,7 +143,7 @@ modSettings = {
value_default = "512",
allowed_characters = "0123456789",
scope = MOD_SETTING_SCOPE_RUNTIME,
show_fn = function() return modSettings:GetNextValue("capture-mode") ~= "live" end,
show_fn = function() return modSettings:GetNextValue("capture-mode") == "area" or modSettings:GetNextValue("capture-mode") == "spiral" end,
},
{
id = "pixel-scale",
@ -157,6 +157,18 @@ modSettings = {
scope = MOD_SETTING_SCOPE_RUNTIME,
change_fn = roundChange,
},
{
id = "capture-delay",
ui_name = "Capture delay",
ui_description = "Additional delay before a screen capture is taken.\nThis can help the world to be populated, and the physics simulation to settle down.\nA setting of 0 means that the screenshot is taken as soon as possible.\n \nUse a value of 10 for a good result without slowing the capture process down too much.",
value_default = 0,
value_min = 0,
value_max = 60,
value_display_multiplier = 1,
value_display_formatting = " $0 frames",
scope = MOD_SETTING_SCOPE_RUNTIME,
show_fn = function() return modSettings:GetNextValue("capture-mode") == "area" or modSettings:GetNextValue("capture-mode") == "spiral" end,
},
{
id = "custom-resolution-live",
ui_name = "Use custom resolution",
@ -318,7 +330,7 @@ modSettings = {
id = "disable-mod-detection",
ui_name = " Disable mod detection",
ui_description = "If enabled, Noita will behave as if no mods are enabled.\nTherefore secrets like the cauldron will be generated.",
hidden = true,
hidden = DebugAPI.IsDevBuild(),
value_default = false,
scope = MOD_SETTING_SCOPE_RUNTIME,
},