Add RmlUI night-stadium launcher and shared theme (by Codex)
This commit is contained in:
1 parent
00f522c1f3
commit
8aa849e9fa
32 files changed
+1841
-917
No files matched your search
+8
-1
@@ -453,6 +453,11 @@ target_link_libraries(openbmh_play PRIVATE bmhui bmh_launcher bmhlaunch_dialog o
|
||||
# a game without a console window on double-click (SDL2main provides WinMain); started from a
|
||||
# console it attaches to that one for --version, --help and start errors (src/app/main.cpp)
|
||||
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH)
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
add_custom_command(TARGET openbmh_play POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/assets/launcher"
|
||||
"$<TARGET_FILE_DIR:openbmh_play>/assets/launcher")
|
||||
endif()
|
||||
if(MSVC)
|
||||
target_compile_options(openbmh_play PRIVATE /utf-8)
|
||||
# App sources also compile in headless tests/helpers without target /utf-8.
|
||||
@@ -1107,8 +1112,10 @@ bmh_add_data_test(NAME english_fixture_table_data_tests DATA_DIR "${BMH_ENGLISH_
|
||||
COMMAND fixture_table_tests "${BMH_ENGLISH_DATA}")
|
||||
|
||||
# Private build paths are inputs to the source-package tool, never shipped in its manifest.
|
||||
FetchContent_GetProperties(rmlui)
|
||||
FetchContent_GetProperties(freetype)
|
||||
set(package_dependencies "{}")
|
||||
foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd)
|
||||
foreach(dependency IN ITEMS SDL2 miniz lzma_sdk nfd rmlui freetype)
|
||||
string(REPLACE "\\" "/" dependency_path "${${dependency}_SOURCE_DIR}")
|
||||
if(dependency STREQUAL "SDL2" AND sdl2_SOURCE_DIR)
|
||||
set(dependency_path "${sdl2_SOURCE_DIR}")
|
||||
|
||||
@@ -15,7 +15,7 @@ Check the [releases page](https://github.com/Weyoune/openbmh/releases) for avail
|
||||
These instructions describe the **0.2 development branch**, not the published 0.1.2 package.
|
||||
|
||||
1. Extract OpenBMH into a writable directory.
|
||||
2. Start `OpenBMH.exe` on Windows, or `OpenBMH` on Linux/macOS. Its native launcher initially has an empty **Name | Art** list.
|
||||
2. Start `OpenBMH.exe` on Windows, or `OpenBMH` on Linux/macOS. Its RmlUI launcher initially has an empty **Name | Art** list. The night-stadium design uses a small version label in the lower-right corner.
|
||||
3. Choose **Add**, select your own BMH or Football Limited installation, and enter a unique mod name and starting display year. The default names are `BMH-classic` and `FTDL-classic` (the English format identifier is `FLTD-classic`).
|
||||
4. Optionally transfer saved games and settings from the installation or another folder. The import reports files it could not migrate.
|
||||
5. Select the resulting Classic mod and choose **Start**. After import, its original installation is no longer needed for play.
|
||||
@@ -31,7 +31,7 @@ For direct startup or the console:
|
||||
|
||||
Both frontends use native content and saves. Use **Add** to migrate older files rather than passing an original executable or `.FBM` to the running game. The starting year changes the Classic year display; original weekday and scheduling rules are preserved. Modern worlds are reserved for a later version.
|
||||
|
||||
See the [0.2 migration contract](docs/formats/obw/runtime-0.2.md) for compatibility and validation limits. Native Windows and macOS behaviour must be checked on their target platforms before a 0.2 release.
|
||||
The launcher uses SDL2, RmlUI and OpenGL 3.3 (macOS: OpenGL 4.1); keep its `assets` directory next to the executable. Folder selection uses the operating system's dialog. See the [0.2 migration contract](docs/formats/obw/runtime-0.2.md) for compatibility and validation limits. Interactive Windows and macOS behaviour must be checked on their target platforms before a 0.2 release.
|
||||
|
||||
## Features and direction
|
||||
|
||||
|
||||
@@ -10,9 +10,14 @@ OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the
|
||||
| [miniz](https://github.com/richgel999/miniz/releases/tag/3.0.2) | 3.0.2 amalgamation | MIT; embedded public-domain notices remain in its source | [miniz.txt](docs/licenses/miniz.txt), [source notices](docs/licenses/miniz-source-notices.txt) |
|
||||
| [LZMA SDK decoder files](https://github.com/ip7z/7zip/tree/24.09/C) | Selected C files from 7-Zip 24.09 | Public domain, as marked in the selected files | [LZMA-SDK.txt](docs/licenses/LZMA-SDK.txt) |
|
||||
| [nativefiledialog-extended](https://github.com/btzy/nativefiledialog-extended/tree/v1.2.1) | 1.2.1 | zlib license | [nativefiledialog-extended.txt](docs/licenses/nativefiledialog-extended.txt) |
|
||||
| [RmlUi](https://github.com/mikke89/RmlUi/tree/6.3) | 6.3, Core and SDL2/OpenGL backend | MIT | [RmlUi.txt](docs/licenses/RmlUi.txt), [containers](docs/licenses/RmlUi-containers.txt), [Khronos notice](docs/licenses/RmlUi-Khronos.txt) |
|
||||
| [FreeType](https://github.com/freetype/freetype/tree/VER-2-13-3) | 2.13.3 | FreeType License (FTL) | [license choices](docs/licenses/FreeType.txt), [FTL](docs/licenses/FreeType-FTL.txt), [BDF](docs/licenses/FreeType-BDF.txt), [PCF](docs/licenses/FreeType-PCF.txt), [internal gzip/zlib](docs/licenses/FreeType-zlib.txt) |
|
||||
| LatoLatin Regular and Bold | Unmodified fonts included with RmlUi 6.3 | SIL Open Font License 1.1 | [font notices](docs/licenses/RmlUi-fonts.txt) |
|
||||
| [Nuked OPL3](https://github.com/nukeykt/Nuked-OPL3/tree/765ec962e473aeb767e4cba74ffdc8f588ffbfe8) | Commit `765ec962e473aeb767e4cba74ffdc8f588ffbfe8` | LGPL-2.1-or-later | [LGPL-2.1.txt](docs/licenses/LGPL-2.1.txt), [copyright and source notice](docs/licenses/Nuked-OPL3-notices.txt) |
|
||||
|
||||
The miniz implementation provides a zlib-compatible API; it is not the zlib library. OpenBMH does not directly link a separate zlib dependency. SDL2 and nativefiledialog-extended use the **zlib license**, which is distinct from using zlib code. A system-library build or distributor's package can have additional runtime dependencies; its notices must match the libraries actually included.
|
||||
The miniz implementation provides a zlib-compatible API; it is not the zlib library. FreeType's internal gzip module includes its bundled zlib code; an external zlib library is not linked by the pinned build. SDL2 and nativefiledialog-extended use the **zlib license**, which is distinct from using zlib code. A system-library build or distributor's package can have additional runtime dependencies; its notices must match the libraries actually included.
|
||||
|
||||
Portions of this software are copyright © the FreeType Project (www.freetype.org). All rights reserved. The pinned build uses the FreeType License option, with the included module notices retained. RmlUi and FreeType are linked statically; their corresponding pinned source is included in the source package.
|
||||
|
||||
Only the public-domain C decoding subset is taken from the 7-Zip source package. This statement does not describe all of 7-Zip: other parts of that upstream project have different licenses and are not included here.
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
<rml>
|
||||
<head>
|
||||
<title>OpenBMH</title>
|
||||
<link type="text/rcss" href="theme.rcss"/>
|
||||
</head>
|
||||
<body>
|
||||
<img id="stadium" src="stadium.tga"/>
|
||||
<div class="shade"/>
|
||||
<div class="brand">
|
||||
<div class="pitch"><div class="halfway"/><div class="circle"/><div class="goal left"/><div class="goal right"/></div>
|
||||
<div class="wordmark">Open<span>BMH</span></div>
|
||||
</div>
|
||||
<div class="workspace">
|
||||
<div class="library panel">
|
||||
<h1>Deine Spiele</h1>
|
||||
<div class="subtitle">Bundesliga Manager Hattrick · Football Limited</div>
|
||||
<div class="table">
|
||||
<div class="column-head"><span class="name">Name</span><span class="type">Art</span></div>
|
||||
<div id="mod-list" tabindex="0"/>
|
||||
</div>
|
||||
<div id="mod-count" class="count">0 Mods</div>
|
||||
</div>
|
||||
<div class="actions panel">
|
||||
<button id="start" class="action primary" data-action="start" disabled="disabled"><span class="icon play"/><span>Start</span></button>
|
||||
<button id="add" class="action" data-action="add"><span class="icon plus"><span/></span><span>Add</span></button>
|
||||
<button id="delete" class="action" data-action="delete" disabled="disabled"><span class="icon bin"><span/></span><span>Delete</span></button>
|
||||
<button id="rename" class="action" data-action="rename" disabled="disabled"><span class="icon pencil"/><span>Rename</span></button>
|
||||
<button id="end" class="action" data-action="end"><span class="icon exit"><span/></span><span>End</span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="version" class="version"/>
|
||||
<div id="overlay">
|
||||
<div id="modal" class="panel">
|
||||
<h2 id="modal-title"/>
|
||||
<div id="modal-body"/>
|
||||
<div id="modal-error"/>
|
||||
<div class="modal-buttons">
|
||||
<button id="cancel" data-action="cancel">Abbrechen</button>
|
||||
<button id="accept" class="primary" data-action="accept">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</rml>
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"asset": "stadium.tga",
|
||||
"sha256": "08f82783a357d5b0722f3737de54844150bc14d98036845f1aaee3211608e1c8",
|
||||
"origin": "Independently generated night-stadium artwork for OpenBMH. No original game assets.",
|
||||
"method": "Built-in image_gen; exported as uncompressed 24-bit TGA without changing pixels.",
|
||||
"distribution": "Project-supplied launcher artwork, distributed with OpenBMH under GPL-3.0-only.",
|
||||
"prompt": "Use case: precise-object-edit / background extraction. The provided image is an AI-generated original football stadium at dusk, covered by a launcher UI. Produce the CLEAN BACKGROUND ART ONLY for that launcher. Completely remove ALL interface graphics, all panels, all buttons, text, logos, the pitch-symbol brand, table, selected row, outlines, version number, and any lettering on advertising boards. Seamlessly reconstruct the stadium scene in all removed regions. Preserve the overall identical camera viewpoint, sweeping stadium structure, dark navy dusk sky with warm twilight just at horizon, powerful white floodlights at upper corners, subtle crowd lights, blue-black grandstands, green football pitch at lower center with white field markings, and near black foreground rail. Keep the center and middle lower grandstands appropriately dark and subdued so future UI overlay remains readable. The result must be a single beautiful photorealistic stadium environment landscape background, approximately 16:10, without any lettering, logos, overlays or watermark anywhere. This is a clean background asset for the approved night-stadium OpenBMH design, not a revised UI mockup."
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.5 MiB |
@@ -0,0 +1,74 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
body { margin: 0; width: 100%; height: 100%; overflow: hidden; font-family: LatoLatin; font-size: 18dp; color: #eef3fa; background: #07121e; }
|
||||
div, h1, h2, label { display: block; box-sizing: border-box; }
|
||||
h1, h2 { margin: 0; font-weight: bold; }
|
||||
span { display: inline-block; }
|
||||
#stadium { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
|
||||
.shade { position: absolute; width: 100%; height: 100%; background-color: #06152525; }
|
||||
.brand { position: absolute; left: 5.3%; top: 19%; display: flex; align-items: center; }
|
||||
.wordmark { font-size: 44dp; font-weight: bold; margin-left: 18dp; }
|
||||
.wordmark span { color: #76efc1; }
|
||||
.pitch { width: 80dp; height: 57dp; border: 2dp #79efc2; border-radius: 3dp; position: relative; }
|
||||
.halfway { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2dp #79efc2; }
|
||||
.circle { position: absolute; left: 30dp; top: 18dp; width: 18dp; height: 18dp; border: 2dp #79efc2; border-radius: 9dp; }
|
||||
.goal { position: absolute; top: 17dp; width: 10dp; height: 22dp; border: 2dp #79efc2; }
|
||||
.goal.left { left: -2dp; } .goal.right { right: -2dp; }
|
||||
.workspace { position: absolute; left: 4.5%; right: 4.5%; top: 31%; bottom: 15.5%; display: flex; }
|
||||
.panel { background: #081522ee; border: 1dp #34495e; border-radius: 10dp; }
|
||||
.library { flex: 1; min-width: 0; padding: 21dp 23dp 14dp; display: flex; flex-direction: column; }
|
||||
h1 { font-size: 31dp; }
|
||||
.subtitle { color: #a9bfd7; font-size: 16dp; margin: 4dp 0 16dp; }
|
||||
.table { flex: 1; min-height: 50dp; border: 1dp #2d4358; border-radius: 6dp; overflow: hidden; display: flex; flex-direction: column; }
|
||||
.column-head { display: flex; padding: 11dp 21dp; color: #a8bbd2; font-size: 17dp; background: #10203388; }
|
||||
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.type { width: 150dp; margin-left: 12dp; }
|
||||
#mod-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
|
||||
.mod-row { display: flex; align-items: center; width: 100%; padding: 12dp 21dp; font-size: 18dp; color: #e8eff9; border-bottom: 1dp #20364c; border-left: 6dp transparent; background: transparent; text-align: left; }
|
||||
.mod-row:hover { background: #203a4999; }
|
||||
.mod-row.selected { background: #183b40bb; border-left-color: #78f0c2; }
|
||||
.mod-row.invalid { color: #efc68c; }
|
||||
.mod-row:focus { border-bottom-color: #78f0c2; }
|
||||
.empty { padding: 24dp 15dp; color: #b8c8d9; font-size: 17dp; text-align: center; }
|
||||
.empty-detail { color: #91a8c1; margin-top: 12dp; font-size: 15dp; }
|
||||
.count { font-size: 14dp; color: #a8bdd5; margin-top: 12dp; }
|
||||
.actions { margin-left: 10dp; width: 257dp; padding: 20dp 18dp 17dp; display: flex; flex-direction: column; justify-content: space-between; }
|
||||
button { box-sizing: border-box; font-family: LatoLatin; font-size: 18dp; color: #f4f7fc; background: #091723bb; border: 1dp #6d86a3; border-radius: 7dp; padding: 10dp 17dp; cursor: pointer; tab-index: auto; }
|
||||
button:hover { background: #203a4aee; border-color: #a7c3da; }
|
||||
button:focus { border-color: #a0f7d6; }
|
||||
button:active { background: #2b4b57; }
|
||||
button:disabled { opacity: 0.40; cursor: default; }
|
||||
.action { width: 100%; height: 55dp; display: flex; align-items: center; justify-content: center; font-weight: bold; }
|
||||
.primary { background: #76edbe; color: #041712; border-color: #8df7cf; font-weight: bold; }
|
||||
.primary:hover { background: #a1ffda; border-color: #c3ffe6; }
|
||||
.primary:active { background: #58cfa2; }
|
||||
.danger { border-color: #dc817f; color: #ffb6ad; background: #55262b; }
|
||||
.icon { display: inline-block; width: 21dp; height: 21dp; margin-right: 21dp; position: relative; box-sizing: border-box; }
|
||||
.play { width: 0; height: 0; border-left: 17dp #061911; border-top: 11dp transparent; border-bottom: 11dp transparent; }
|
||||
.plus { border-top: 2dp #b1c6df; width: 21dp; height: 1dp; }
|
||||
.plus span { position: absolute; height: 21dp; left: 9dp; top: -12dp; border-left: 2dp #b1c6df; }
|
||||
.bin { width: 16dp; height: 20dp; border: 2dp #b1c6df; border-radius: 2dp; }
|
||||
.bin span { position: absolute; left: -5dp; top: -6dp; width: 22dp; border-top: 2dp #b1c6df; }
|
||||
.pencil { height: 22dp; width: 7dp; border: 2dp #b1c6df; transform: rotate(40deg); }
|
||||
.exit { width: 14dp; border: 2dp #b1c6df; border-right-width: 0; }
|
||||
.exit span { position: absolute; left: 6dp; top: 7dp; width: 15dp; border-top: 2dp #b1c6df; }
|
||||
.version { position: absolute; right: 20dp; bottom: 14dp; font-size: 11dp; color: #8fa8c1; }
|
||||
#overlay { display: none; position: absolute; width: 100%; height: 100%; background: #020810bb; }
|
||||
#modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 580dp; padding: 25dp; }
|
||||
h2 { font-size: 25dp; margin-bottom: 19dp; }
|
||||
#modal-body { font-size: 17dp; line-height: 1.45; max-height: 360dp; overflow: auto; }
|
||||
label { color: #afc5dd; font-size: 15dp; margin: 12dp 0 6dp; }
|
||||
input { box-sizing: border-box; display: block; width: 100%; height: 39dp; padding: 8dp 10dp; color: #eff6ff; background: #06111eee; border: 1dp #567088; border-radius: 4dp; font-size: 18dp; caret-color: #86f3cb; tab-index: auto; }
|
||||
input:focus { border-color: #85f3ca; }
|
||||
.fields { display: flex; } .fields .year { width: 160dp; }
|
||||
.check-row { display: flex; align-items: center; margin: 18dp 0 7dp; }
|
||||
input.checkbox { width: 20dp; height: 20dp; padding: 0; margin-right: 12dp; }
|
||||
input.checkbox:checked { background: #78edbf; border-color: #78edbf; }
|
||||
.check-row label { margin: 0; color: #e9f2fb; }
|
||||
.browse-row { display: flex; } .browse-row input { flex: 1; min-width: 0; }
|
||||
.browse-row button { margin-left: 9dp; font-size: 15dp; }
|
||||
.modal-buttons { display: flex; justify-content: flex-end; margin-top: 23dp; }
|
||||
.modal-buttons button { margin-left: 10dp; min-width: 110dp; }
|
||||
#modal-error { color: #ffb7a5; font-size: 15dp; margin-top: 12dp; }
|
||||
scrollbarvertical { width: 10dp; } scrollbarvertical sliderbar { background: #476077; border-radius: 4dp; }
|
||||
|
||||
selection { color: #051711; background-color: #76edbe; }
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# Building OpenBMH
|
||||
|
||||
Requirements: a C++20 compiler, CMake 3.24 or newer, Git and a supported build tool such as Ninja. The CMake project fetches pinned SDL2, miniz, 7-Zip C decoder and nativefiledialog-extended sources. Network access is needed on the first configure unless these dependencies are supplied locally. Nuked OPL3 is included in the source tree.
|
||||
Requirements: a C++20 compiler, CMake 3.24 or newer, Git and a supported build tool such as Ninja. The CMake project fetches pinned SDL2, miniz, 7-Zip C decoder, nativefiledialog-extended, RmlUi and FreeType sources. Network access is needed on the first configure unless these dependencies are supplied locally. Nuked OPL3 is included in the source tree.
|
||||
|
||||
```sh
|
||||
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
@@ -26,7 +26,7 @@ With a Visual Studio generator, choose one actually provided by your installed C
|
||||
|
||||
## Linux
|
||||
|
||||
Install a C++20 compiler, Git, CMake, Ninja, pkg-config and the development packages required by SDL2 and the dialog backend. The native Linux launcher uses GTK3. For example, Debian-family development packages include `build-essential`, `cmake`, `ninja-build`, `git`, `pkg-config` and `libgtk-3-dev`; SDL2's selected video/audio backends may need additional development libraries.
|
||||
Install a C++20 compiler, Git, CMake, Ninja, pkg-config and the development packages required by SDL2 and the folder-dialog backend. The RmlUI launcher uses SDL2/OpenGL; its native folder picker uses GTK3 on Linux. For example, Debian-family development packages include `build-essential`, `cmake`, `ninja-build`, `git`, `pkg-config`, `libgl1-mesa-dev` and `libgtk-3-dev`; SDL2's selected video/audio backends may need additional development libraries. RmlUI and FreeType are built from pinned sources without installing them separately. Keep the generated `assets/launcher` directory alongside OpenBMH when copying a development build.
|
||||
|
||||
The common commands above build the bundled SDL2. To use an installed SDL2 CMake package instead, configure with `-DBMH_USE_SYSTEM_SDL2=ON`. Its version and backend configuration then come from the installed package.
|
||||
|
||||
|
||||
+12
-2
@@ -12,7 +12,7 @@ OpenBMH is a C++20 engine with graphical and console frontends. The implementati
|
||||
| `src/ui` | View projections, rendering and input interpretation for game screens |
|
||||
| `src/cli` | Command language, structured protocol, console windows and multi-client seat routing |
|
||||
| `src/audio` | Bank decoding, synthesis, playback and cues, without authority to change gameplay |
|
||||
| `src/launch` | Native launcher, portable mod library, child processes and legacy installation discovery |
|
||||
| `src/launch` | RmlUI launcher, portable mod library, child processes and legacy installation discovery |
|
||||
| `src/content` | Sealed OBW content, native career containers and personal preferences |
|
||||
| `src/import` | Legacy installation and save-layout conversion; original readers are used here |
|
||||
|
||||
@@ -50,6 +50,16 @@ The only mutable mount setting is the presentation year of the selected career.
|
||||
streams, Reality residues and the manager-desk driver. No host object, pointer or callback
|
||||
is dumped. The session reconstructs content pointers and callbacks when loading.
|
||||
|
||||
The native launcher remains the parent process. Each game starts in a fresh child process
|
||||
The RmlUI launcher remains the parent process. Each game starts in a fresh child process
|
||||
of `OpenBMH`, keeping edition-specific process globals isolated. Portable mod content and
|
||||
personal files have independent lifetimes. See [runtime-0.2](formats/obw/runtime-0.2.md).
|
||||
|
||||
The launcher layout and theme live in `assets/launcher/launcher.rml` and `theme.rcss`.
|
||||
They share the same RmlUI core, FreeType font engine and upstream SDL2/OpenGL renderer
|
||||
on all desktop platforms. The C++ view translates events into the existing launcher
|
||||
interface; it does not own conversion rules or mod storage. This presentation layer
|
||||
can be reused by future modern screens. Classic game screens retain their current UI.
|
||||
The operating system supplies the folder picker through nativefiledialog-extended.
|
||||
Release packages contain the complete launcher asset directory and unmodified Lato
|
||||
fonts from the pinned RmlUI source. Background artwork is independently generated;
|
||||
its provenance and approved digest are recorded with the project assets.
|
||||
@@ -6,12 +6,13 @@ This contract is for the 0.2 development branch. It is not a release validation
|
||||
## Portable layout and lifecycle
|
||||
|
||||
`OpenBMH.exe` (Windows) / `OpenBMH` (Linux and macOS) starts the operating system's
|
||||
native launcher: one selected row, **Name | Art**, and **Start, Add, Delete, Rename, End**.
|
||||
RmlUI launcher: one selected row, **Name | Art**, and **Start, Add, Delete, Rename, End**.
|
||||
No installation is auto-selected on first launch. Add converts an externally owned
|
||||
installation; original assets never belong in a distribution.
|
||||
|
||||
```
|
||||
OpenBMH[.exe]
|
||||
assets/launcher/*
|
||||
mods/<name>/content.obw
|
||||
userdata/<content-id>/*.obs
|
||||
userdata/<content-id>/*.obsettings
|
||||
@@ -34,6 +35,12 @@ The launcher starts a child process of the same binary, with `--run-mod` and a s
|
||||
save directory, and remains available after the child exits. `--mod <content.obw>` bypasses
|
||||
the launcher. A normal GUI/console invocation cannot fall back to original game files.
|
||||
|
||||
RML/RCSS define the launcher and its import, rename, delete and progress dialogs.
|
||||
Only folder selection uses an OS dialog. The SDL2/OpenGL view keeps UI resources
|
||||
relative to the executable, supports resizing and HiDPI input, and sleeps between
|
||||
input or scheduled UI updates. The running child's match engine does not depend on
|
||||
RmlUI. OpenGL 3.3 is required for the launcher (4.1 on macOS).
|
||||
|
||||
## Integrity and content access
|
||||
|
||||
The existing `classic-installation-v1` payload is complemented by
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
FreeType font driver for BDF fonts
|
||||
|
||||
Francesco Zappa Nardelli
|
||||
<francesco.zappa.nardelli@ens.fr>
|
||||
|
||||
|
||||
Introduction
|
||||
************
|
||||
|
||||
BDF (Bitmap Distribution Format) is a bitmap font format defined by Adobe,
|
||||
which is intended to be easily understood by both humans and computers.
|
||||
This code implements a BDF driver for the FreeType library, following the
|
||||
Adobe Specification V 2.2. The specification of the BDF font format is
|
||||
available from Adobe's web site:
|
||||
|
||||
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5005.BDF_Spec.pdf
|
||||
|
||||
Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org).
|
||||
They do not define vertical metrics, because the X Consortium BDF
|
||||
specification has removed them.
|
||||
|
||||
|
||||
Encodings
|
||||
*********
|
||||
|
||||
[This section is out of date, retained for historical reasons. BDF
|
||||
properties can be retrieved with `FT_Get_BDF_Property`, character set ID
|
||||
values with `FT_Get_BDF_Charset_ID`.]
|
||||
|
||||
The variety of encodings that accompanies bdf fonts appears to encompass the
|
||||
small set defined in freetype.h. On the other hand, two properties that
|
||||
specify encoding and registry are usually defined in bdf fonts.
|
||||
|
||||
I decided to make these two properties directly accessible, leaving to the
|
||||
client application the work of interpreting them. For instance:
|
||||
|
||||
|
||||
#include FT_INTERNAL_BDF_TYPES_H
|
||||
|
||||
FT_Face face;
|
||||
BDF_Public_Face bdfface;
|
||||
|
||||
|
||||
FT_New_Face( library, ..., &face );
|
||||
|
||||
bdfface = (BDF_Public_Face)face;
|
||||
|
||||
if ( ( bdfface->charset_registry == "ISO10646" ) &&
|
||||
( bdfface->charset_encoding == "1" ) )
|
||||
[..]
|
||||
|
||||
|
||||
Thus the driver always exports `ft_encoding_none' as face->charmap.encoding.
|
||||
FT_Get_Char_Index's behavior is unmodified, that is, it converts the ULong
|
||||
value given as argument into the corresponding glyph number.
|
||||
|
||||
If the two properties are not available, Adobe Standard Encoding should be
|
||||
assumed.
|
||||
|
||||
|
||||
Anti-Aliased Bitmaps
|
||||
********************
|
||||
|
||||
The driver supports an extension to the BDF format as used in Mark Leisher's
|
||||
xmbdfed bitmap font editor. Microsoft's SBIT tool expects bitmap fonts in
|
||||
that format for adding anti-aliased them to TrueType fonts. It introduces a
|
||||
fourth field to the `SIZE' keyword which gives the bpp value (bits per
|
||||
pixel) of the glyph data in the font. Possible values are 1 (the default),
|
||||
2 (four gray levels), 4 (16 gray levels), and 8 (256 gray levels). The
|
||||
driver returns either a bitmap with 1 bit per pixel or a pixmap with 8bits
|
||||
per pixel (using 4, 16, and 256 gray levels, respectively).
|
||||
|
||||
|
||||
Known problems
|
||||
**************
|
||||
|
||||
- A font is entirely loaded into memory. Obviously, this is not the Right
|
||||
Thing(TM). If you have big fonts I suggest you convert them into PCF
|
||||
format (using the bdftopcf utility): the PCF font drive of FreeType can
|
||||
perform incremental glyph loading.
|
||||
|
||||
When I have some time, I will implement on-demand glyph parsing.
|
||||
|
||||
- Except for encodings properties, client applications have no visibility of
|
||||
the PCF_Face object. This means that applications cannot directly access
|
||||
font tables and must trust FreeType.
|
||||
|
||||
- Currently, glyph names are ignored.
|
||||
|
||||
I plan to give full visibility of the BDF_Face object in an upcoming
|
||||
revision of the driver, thus implementing also glyph names.
|
||||
|
||||
- As I have never seen a BDF font that defines vertical metrics, vertical
|
||||
metrics are (parsed and) discarded. If you own a BDF font that defines
|
||||
vertical metrics, please let me know (I will implement them in 5-10
|
||||
minutes).
|
||||
|
||||
|
||||
License
|
||||
*******
|
||||
|
||||
Copyright (C) 2001-2002 by Francesco Zappa Nardelli
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*** Portions of the driver (that is, bdflib.c and bdf.h):
|
||||
|
||||
Copyright 2000 Computing Research Labs, New Mexico State University
|
||||
Copyright 2001-2002, 2011 Francesco Zappa Nardelli
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
||||
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
Credits
|
||||
*******
|
||||
|
||||
This driver is based on excellent Mark Leisher's bdf library. If you
|
||||
find something good in this driver you should probably thank him, not
|
||||
me.
|
||||
@@ -0,0 +1,169 @@
|
||||
The FreeType Project LICENSE
|
||||
----------------------------
|
||||
|
||||
2006-Jan-27
|
||||
|
||||
Copyright 1996-2002, 2006 by
|
||||
David Turner, Robert Wilhelm, and Werner Lemberg
|
||||
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
The FreeType Project is distributed in several archive packages;
|
||||
some of them may contain, in addition to the FreeType font engine,
|
||||
various tools and contributions which rely on, or relate to, the
|
||||
FreeType Project.
|
||||
|
||||
This license applies to all files found in such packages, and
|
||||
which do not fall under their own explicit license. The license
|
||||
affects thus the FreeType font engine, the test programs,
|
||||
documentation and makefiles, at the very least.
|
||||
|
||||
This license was inspired by the BSD, Artistic, and IJG
|
||||
(Independent JPEG Group) licenses, which all encourage inclusion
|
||||
and use of free software in commercial and freeware products
|
||||
alike. As a consequence, its main points are that:
|
||||
|
||||
o We don't promise that this software works. However, we will be
|
||||
interested in any kind of bug reports. (`as is' distribution)
|
||||
|
||||
o You can use this software for whatever you want, in parts or
|
||||
full form, without having to pay us. (`royalty-free' usage)
|
||||
|
||||
o You may not pretend that you wrote this software. If you use
|
||||
it, or only parts of it, in a program, you must acknowledge
|
||||
somewhere in your documentation that you have used the
|
||||
FreeType code. (`credits')
|
||||
|
||||
We specifically permit and encourage the inclusion of this
|
||||
software, with or without modifications, in commercial products.
|
||||
We disclaim all warranties covering The FreeType Project and
|
||||
assume no liability related to The FreeType Project.
|
||||
|
||||
|
||||
Finally, many people asked us for a preferred form for a
|
||||
credit/disclaimer to use in compliance with this license. We thus
|
||||
encourage you to use the following text:
|
||||
|
||||
"""
|
||||
Portions of this software are copyright © <year> The FreeType
|
||||
Project (www.freetype.org). All rights reserved.
|
||||
"""
|
||||
|
||||
Please replace <year> with the value from the FreeType version you
|
||||
actually use.
|
||||
|
||||
|
||||
Legal Terms
|
||||
===========
|
||||
|
||||
0. Definitions
|
||||
--------------
|
||||
|
||||
Throughout this license, the terms `package', `FreeType Project',
|
||||
and `FreeType archive' refer to the set of files originally
|
||||
distributed by the authors (David Turner, Robert Wilhelm, and
|
||||
Werner Lemberg) as the `FreeType Project', be they named as alpha,
|
||||
beta or final release.
|
||||
|
||||
`You' refers to the licensee, or person using the project, where
|
||||
`using' is a generic term including compiling the project's source
|
||||
code as well as linking it to form a `program' or `executable'.
|
||||
This program is referred to as `a program using the FreeType
|
||||
engine'.
|
||||
|
||||
This license applies to all files distributed in the original
|
||||
FreeType Project, including all source code, binaries and
|
||||
documentation, unless otherwise stated in the file in its
|
||||
original, unmodified form as distributed in the original archive.
|
||||
If you are unsure whether or not a particular file is covered by
|
||||
this license, you must contact us to verify this.
|
||||
|
||||
The FreeType Project is copyright (C) 1996-2000 by David Turner,
|
||||
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
|
||||
specified below.
|
||||
|
||||
1. No Warranty
|
||||
--------------
|
||||
|
||||
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
|
||||
USE, OF THE FREETYPE PROJECT.
|
||||
|
||||
2. Redistribution
|
||||
-----------------
|
||||
|
||||
This license grants a worldwide, royalty-free, perpetual and
|
||||
irrevocable right and license to use, execute, perform, compile,
|
||||
display, copy, create derivative works of, distribute and
|
||||
sublicense the FreeType Project (in both source and object code
|
||||
forms) and derivative works thereof for any purpose; and to
|
||||
authorize others to exercise some or all of the rights granted
|
||||
herein, subject to the following conditions:
|
||||
|
||||
o Redistribution of source code must retain this license file
|
||||
(`FTL.TXT') unaltered; any additions, deletions or changes to
|
||||
the original files must be clearly indicated in accompanying
|
||||
documentation. The copyright notices of the unaltered,
|
||||
original files must be preserved in all copies of source
|
||||
files.
|
||||
|
||||
o Redistribution in binary form must provide a disclaimer that
|
||||
states that the software is based in part of the work of the
|
||||
FreeType Team, in the distribution documentation. We also
|
||||
encourage you to put an URL to the FreeType web page in your
|
||||
documentation, though this isn't mandatory.
|
||||
|
||||
These conditions apply to any software derived from or based on
|
||||
the FreeType Project, not just the unmodified files. If you use
|
||||
our work, you must acknowledge us. However, no fee need be paid
|
||||
to us.
|
||||
|
||||
3. Advertising
|
||||
--------------
|
||||
|
||||
Neither the FreeType authors and contributors nor you shall use
|
||||
the name of the other for commercial, advertising, or promotional
|
||||
purposes without specific prior written permission.
|
||||
|
||||
We suggest, but do not require, that you use one or more of the
|
||||
following phrases to refer to this software in your documentation
|
||||
or advertising materials: `FreeType Project', `FreeType Engine',
|
||||
`FreeType library', or `FreeType Distribution'.
|
||||
|
||||
As you have not signed this license, you are not required to
|
||||
accept it. However, as the FreeType Project is copyrighted
|
||||
material, only this license, or another one contracted with the
|
||||
authors, grants you the right to use, distribute, and modify it.
|
||||
Therefore, by using, distributing, or modifying the FreeType
|
||||
Project, you indicate that you understand and accept all the terms
|
||||
of this license.
|
||||
|
||||
4. Contacts
|
||||
-----------
|
||||
|
||||
There are two mailing lists related to FreeType:
|
||||
|
||||
o freetype@nongnu.org
|
||||
|
||||
Discusses general use and applications of FreeType, as well as
|
||||
future and wanted additions to the library and distribution.
|
||||
If you are looking for support, start in this list if you
|
||||
haven't found anything to help you in the documentation.
|
||||
|
||||
o freetype-devel@nongnu.org
|
||||
|
||||
Discusses bugs, as well as engine internals, design issues,
|
||||
specific licenses, porting, etc.
|
||||
|
||||
Our home page can be found at
|
||||
|
||||
https://www.freetype.org
|
||||
|
||||
|
||||
--- end of FTL.TXT ---
|
||||
@@ -0,0 +1,96 @@
|
||||
FreeType font driver for PCF fonts
|
||||
|
||||
Francesco Zappa Nardelli
|
||||
<francesco.zappa.nardelli@ens.fr>
|
||||
|
||||
|
||||
Introduction
|
||||
************
|
||||
|
||||
PCF (Portable Compiled Format) is a binary bitmap font format, largely used
|
||||
in X world. This code implements a PCF driver for the FreeType library.
|
||||
Glyph images are loaded into memory only on demand, thus leading to a small
|
||||
memory footprint.
|
||||
|
||||
Information on the PCF font format can only be worked out from
|
||||
`pcfread.c', and `pcfwrite.c', to be found, for instance, in the XFree86
|
||||
(www.xfree86.org) source tree (xc/lib/font/bitmap/).
|
||||
|
||||
Many good bitmap fonts in bdf format come with XFree86: they can be
|
||||
compiled into the pcf format using the `bdftopcf' utility.
|
||||
|
||||
|
||||
Supported hardware
|
||||
******************
|
||||
|
||||
The driver has been tested on linux/x86 and sunos5.5/sparc. In both
|
||||
cases the compiler was gcc. When back in Paris, I will test it also
|
||||
on linux/alpha.
|
||||
|
||||
|
||||
Encodings
|
||||
*********
|
||||
|
||||
Use `FT_Get_BDF_Charset_ID' to access the encoding and registry.
|
||||
|
||||
The driver always exports `ft_encoding_none' as face->charmap.encoding.
|
||||
FT_Get_Char_Index() behavior is unmodified, that is, it converts the ULong
|
||||
value given as argument into the corresponding glyph number.
|
||||
|
||||
|
||||
Known problems
|
||||
**************
|
||||
|
||||
- dealing explicitly with encodings breaks the uniformity of FreeType 2
|
||||
API.
|
||||
|
||||
- except for encodings properties, client applications have no
|
||||
visibility of the PCF_Face object. This means that applications
|
||||
cannot directly access font tables and are obliged to trust
|
||||
FreeType.
|
||||
|
||||
- currently, glyph names and ink_metrics are ignored.
|
||||
|
||||
I plan to give full visibility of the PCF_Face object in the next
|
||||
release of the driver, thus implementing also glyph names and
|
||||
ink_metrics.
|
||||
|
||||
- height is defined as (ascent - descent). Is this correct?
|
||||
|
||||
- if unable to read size information from the font, PCF_Init_Face
|
||||
sets available_size->width and available_size->height to 12.
|
||||
|
||||
- too many english grammar errors in the readme file :-(
|
||||
|
||||
|
||||
License
|
||||
*******
|
||||
|
||||
Copyright (C) 2000 by Francesco Zappa Nardelli
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
Credits
|
||||
*******
|
||||
|
||||
Keith Packard wrote the pcf driver found in XFree86. His work is at
|
||||
the same time the specification and the sample implementation of the
|
||||
PCF format. Undoubtedly, this driver is inspired from his work.
|
||||
@@ -0,0 +1,29 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.3, August 18th, 2023
|
||||
|
||||
Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
|
||||
The data format used by the zlib library is described by RFCs (Request for
|
||||
Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
|
||||
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
|
||||
*/
|
||||
@@ -0,0 +1,46 @@
|
||||
FREETYPE LICENSES
|
||||
-----------------
|
||||
|
||||
The FreeType 2 font engine is copyrighted work and cannot be used
|
||||
legally without a software license. In order to make this project
|
||||
usable to a vast majority of developers, we distribute it under two
|
||||
mutually exclusive open-source licenses.
|
||||
|
||||
This means that *you* must choose *one* of the two licenses described
|
||||
below, then obey all its terms and conditions when using FreeType 2 in
|
||||
any of your projects or products.
|
||||
|
||||
- The FreeType License, found in the file `docs/FTL.TXT`, which is
|
||||
similar to the original BSD license *with* an advertising clause
|
||||
that forces you to explicitly cite the FreeType project in your
|
||||
product's documentation. All details are in the license file.
|
||||
This license is suited to products which don't use the GNU General
|
||||
Public License.
|
||||
|
||||
Note that this license is compatible to the GNU General Public
|
||||
License version 3, but not version 2.
|
||||
|
||||
- The GNU General Public License version 2, found in
|
||||
`docs/GPLv2.TXT` (any later version can be used also), for
|
||||
programs which already use the GPL. Note that the FTL is
|
||||
incompatible with GPLv2 due to its advertisement clause.
|
||||
|
||||
The contributed BDF and PCF drivers come with a license similar to
|
||||
that of the X Window System. It is compatible to the above two
|
||||
licenses (see files `src/bdf/README` and `src/pcf/README`). The same
|
||||
holds for the source code files `src/base/fthash.c` and
|
||||
`include/freetype/internal/fthash.h`; they were part of the BDF driver
|
||||
in earlier FreeType versions.
|
||||
|
||||
The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
|
||||
too is compatible to the above two licenses.
|
||||
|
||||
The files `src/autofit/ft-hb.c` and `src/autofit/ft-hb.h` contain code
|
||||
taken almost verbatim from the HarfBuzz file `hb-ft.cc`, which uses
|
||||
the 'Old MIT' license, compatible to the above two licenses.
|
||||
|
||||
The MD5 checksum support (only used for debugging in development
|
||||
builds) is in the public domain.
|
||||
|
||||
|
||||
--- end of LICENSE.TXT ---
|
||||
@@ -8,6 +8,9 @@ These files preserve upstream license and attribution wording. They are not a gr
|
||||
- [miniz](miniz.txt): the MIT license shipped with the 3.0.2 amalgamation. [Additional verbatim source notices](miniz-source-notices.txt), including the additional copyright attribution and public-domain dedication, are also retained.
|
||||
- [LZMA SDK](LZMA-SDK.txt): the public-domain declaration from the 7-Zip 24.09 documentation. Only individually marked public-domain decoder files are used.
|
||||
- [nativefiledialog-extended](nativefiledialog-extended.txt): version 1.2.1 zlib license.
|
||||
- [RmlUi](RmlUi.txt): 6.3 MIT license, including the separate [container notices](RmlUi-containers.txt) and [Khronos backend notice](RmlUi-Khronos.txt).
|
||||
- [FreeType](FreeType.txt): 2.13.3 license choices, with the [FTL](FreeType-FTL.txt) selected for this build and [BDF](FreeType-BDF.txt), [PCF](FreeType-PCF.txt) and [gzip/zlib](FreeType-zlib.txt) notices preserved.
|
||||
- [Lato font notices](RmlUi-fonts.txt): unmodified Regular and Bold Latin fonts from RmlUi 6.3, under SIL OFL 1.1. The upstream sample-font notice is retained verbatim.
|
||||
- [Nuked OPL3 copyright and license notice](Nuked-OPL3-notices.txt): unchanged leading notice from its vendored implementation.
|
||||
- [LGPL version 2.1](LGPL-2.1.txt): full license supplied with Nuked OPL3. Its source notices permit version 2.1 or any later version.
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
@@ -0,0 +1,58 @@
|
||||
RmlUi Core contains thirdparty libraries. They are listed below along with
|
||||
their full licenses - all MIT licensed.
|
||||
|
||||
---
|
||||
|
||||
robin_hood unordered map & set
|
||||
https://github.com/martinus/robin-hood-hashing
|
||||
|
||||
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
||||
SPDX-License-Identifier: MIT
|
||||
Copyright (c) 2018-2020 Martin Ankerl <http://martin.ankerl.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
itlib
|
||||
https://github.com/iboB/itlib
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright(c) 2016-2019 Chobolabs Inc.
|
||||
Copyright(c) 2020-2023 Borislav Stanimirov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files(the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and / or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,316 @@
|
||||
The RmlUi samples include fonts that are separately licensed. They are listed
|
||||
below along with their licenses.
|
||||
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
--- Lato ---
|
||||
--- http://www.latofonts.com/ ---
|
||||
--- ---
|
||||
--- LatoLatin-Bold.ttf ---
|
||||
--- LatoLatin-BoldItalic.ttf ---
|
||||
--- LatoLatin-Italic.ttf ---
|
||||
--- LatoLatin-Regular.ttf ---
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com),
|
||||
with Reserved Font Name Lato.
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
--- Noto Emoji ---
|
||||
--- https://www.google.com/get/noto/ ---
|
||||
--- ---
|
||||
--- NotoEmoji-Regular.ttf ---
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License,
|
||||
Version 1.1.
|
||||
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font
|
||||
creation efforts of academic and linguistic communities, and to
|
||||
provide a free and open framework in which fonts may be shared and
|
||||
improved in partnership with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply to
|
||||
any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software
|
||||
components as distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to,
|
||||
deleting, or substituting -- in part or in whole -- any of the
|
||||
components of the Original Version, by changing formats or by porting
|
||||
the Font Software to a new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed,
|
||||
modify, redistribute, and sell modified and unmodified copies of the
|
||||
Font Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components, in
|
||||
Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the
|
||||
corresponding Copyright Holder. This restriction only applies to the
|
||||
primary font name as presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created using
|
||||
the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
--- RobotoMono ---
|
||||
--- https://fonts.google.com/ ---
|
||||
--- ---
|
||||
--- RobotoMono-Bold.ttf ---
|
||||
--- RobotoMono-BoldItalic.ttf ---
|
||||
--- RobotoMono-Italic.ttf ---
|
||||
--- RobotoMono-Regular.ttf ---
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2008-2014 CodePoint Ltd, Shift Technology Ltd, and contributors
|
||||
Copyright (c) 2019-2026 The RmlUi Team, and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -30,20 +30,12 @@ target_link_libraries(bmh_content PUBLIC bmh_obw PRIVATE bmh_miniz)
|
||||
add_library(bmh_launcher STATIC ../launch/mods.cpp ../launch/process.cpp ../launch/launcher.cpp)
|
||||
target_include_directories(bmh_launcher PUBLIC ..)
|
||||
target_link_libraries(bmh_launcher PUBLIC bmh_content)
|
||||
if(WIN32)
|
||||
target_sources(bmh_launcher PRIVATE ../launch/launcher_win32.cpp)
|
||||
target_link_libraries(bmh_launcher PRIVATE comctl32 ole32 shell32 uuid)
|
||||
elseif(APPLE)
|
||||
set_property(TARGET bmh_launcher PROPERTY OBJCXX_STANDARD 20)
|
||||
target_sources(bmh_launcher PRIVATE ../launch/launcher_cocoa.mm)
|
||||
set_source_files_properties(../launch/launcher_cocoa.mm PROPERTIES COMPILE_OPTIONS "-fobjc-arc")
|
||||
target_link_libraries(bmh_launcher PRIVATE "-framework AppKit")
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(BMH_GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
target_sources(bmh_launcher PRIVATE ../launch/launcher_gtk.cpp)
|
||||
target_link_libraries(bmh_launcher PRIVATE PkgConfig::BMH_GTK)
|
||||
endif()
|
||||
include(../launch/rmlui.cmake)
|
||||
target_sources(bmh_launcher PRIVATE ../launch/launcher_rmlui.cpp)
|
||||
target_link_libraries(bmh_launcher PRIVATE bmh_rmlui nfd)
|
||||
add_executable(launcher_document_tests ../../tests/launcher_document_tests.cpp)
|
||||
target_link_libraries(launcher_document_tests PRIVATE RmlUi::Core)
|
||||
add_test(NAME launcher_document_tests COMMAND launcher_document_tests "${launcher_assets}")
|
||||
add_executable(native_content_tests ../../tests/native_content_tests.cpp)
|
||||
target_link_libraries(native_content_tests PRIVATE bmh_launcher)
|
||||
add_test(NAME native_content_tests COMMAND native_content_tests)
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#import <AppKit/AppKit.h>
|
||||
#include "launch/launcher_ui.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include <functional>
|
||||
|
||||
@interface OBMLauncherBridge : NSObject <NSTableViewDataSource, NSTableViewDelegate, NSWindowDelegate> {
|
||||
@public
|
||||
std::function<void(NSInteger)> action;
|
||||
std::function<void()> selection;
|
||||
}
|
||||
@property(strong) NSArray<NSDictionary *> *rows;
|
||||
- (void)activate:(id)sender;
|
||||
@end
|
||||
@implementation OBMLauncherBridge
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)table {
|
||||
(void)table;
|
||||
return self.rows.count;
|
||||
}
|
||||
- (id)tableView:(NSTableView *)table objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row {
|
||||
(void)table;
|
||||
return self.rows[row][column.identifier];
|
||||
}
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)note {
|
||||
(void)note;
|
||||
if (selection)
|
||||
selection();
|
||||
}
|
||||
- (void)activate:(id)sender {
|
||||
if (action)
|
||||
action([sender tag]);
|
||||
}
|
||||
- (BOOL)windowShouldClose:(NSWindow *)window {
|
||||
(void)window;
|
||||
if (action)
|
||||
action(0);
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
|
||||
namespace bmh::launch {
|
||||
namespace {
|
||||
NSString *string(const std::string &s) {
|
||||
auto value = [[NSString alloc] initWithBytes:s.data() length:s.size() encoding:NSUTF8StringEncoding];
|
||||
if (!value)
|
||||
throw std::runtime_error("Invalid UTF-8 launcher text");
|
||||
return value;
|
||||
}
|
||||
std::string utf8(NSString *s) { return std::string(s.UTF8String ?: ""); }
|
||||
NSTextField *label(NSString *text, NSRect frame) {
|
||||
auto *field = [NSTextField labelWithString:text];
|
||||
field.frame = frame;
|
||||
return field;
|
||||
}
|
||||
NSTextField *input(NSString *text, NSRect frame) {
|
||||
auto *field = [[NSTextField alloc] initWithFrame:frame];
|
||||
field.stringValue = text;
|
||||
return field;
|
||||
}
|
||||
class CocoaLauncher final : public LauncherUI {
|
||||
NSWindow *window_;
|
||||
NSTableView *table_;
|
||||
OBMLauncherBridge *bridge_;
|
||||
NSMutableArray<NSButton *> *buttons_;
|
||||
NSWindow *progress_ = nil;
|
||||
NSTextField *progress_label_ = nil;
|
||||
OBMLauncherBridge *progress_bridge_ = nil;
|
||||
bool cancelled_ = false;
|
||||
|
||||
public:
|
||||
CocoaLauncher() {
|
||||
[NSApplication sharedApplication];
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[NSApp finishLaunching];
|
||||
window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 660, 340)
|
||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
||||
NSWindowStyleMaskMiniaturizable
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
window_.title = @"OpenBMH";
|
||||
[window_ center];
|
||||
window_.releasedWhenClosed = NO;
|
||||
bridge_ = [OBMLauncherBridge new];
|
||||
bridge_.rows = @[];
|
||||
window_.delegate = bridge_;
|
||||
auto *scroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(16, 16, 490, 308)];
|
||||
scroll.hasVerticalScroller = YES;
|
||||
scroll.borderType = NSBezelBorder;
|
||||
table_ = [[NSTableView alloc] initWithFrame:scroll.bounds];
|
||||
table_.allowsMultipleSelection = NO;
|
||||
table_.dataSource = bridge_;
|
||||
table_.delegate = bridge_;
|
||||
for (NSString *identifier in @[ @"Name", @"Art" ]) {
|
||||
auto *column = [[NSTableColumn alloc] initWithIdentifier:identifier];
|
||||
column.title = identifier;
|
||||
column.width = [identifier isEqualToString:@"Name"] ? 350 : 110;
|
||||
[table_ addTableColumn:column];
|
||||
}
|
||||
table_.target = bridge_;
|
||||
table_.doubleAction = @selector(activate:);
|
||||
table_.tag = 1;
|
||||
scroll.documentView = table_;
|
||||
[window_.contentView addSubview:scroll];
|
||||
buttons_ = [NSMutableArray new];
|
||||
NSArray *titles = @[ @"Start", @"Add", @"Delete", @"Rename", @"End" ];
|
||||
for (NSInteger i = 0; i < 5; ++i) {
|
||||
auto *button = [NSButton buttonWithTitle:titles[i] target:bridge_ action:@selector(activate:)];
|
||||
button.tag = i + 1;
|
||||
button.frame = NSMakeRect(522, 282 - i * 50, 120, 34);
|
||||
[window_.contentView addSubview:button];
|
||||
[buttons_ addObject:button];
|
||||
}
|
||||
bridge_->action = [this](NSInteger code) {
|
||||
if ((code == 1 || code == 3 || code == 4) && table_.selectedRow < 0)
|
||||
return;
|
||||
[NSApp stopModalWithCode:code];
|
||||
};
|
||||
bridge_->selection = [this] {
|
||||
for (NSInteger i : {0, 2, 3})
|
||||
buttons_[i].enabled = table_.selectedRow >= 0;
|
||||
};
|
||||
bridge_->selection();
|
||||
[window_ makeKeyAndOrderFront:nil];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
~CocoaLauncher() override {
|
||||
finish_progress();
|
||||
bridge_->action = {};
|
||||
bridge_->selection = {};
|
||||
window_.delegate = nil;
|
||||
[window_ orderOut:nil];
|
||||
[window_ close];
|
||||
}
|
||||
LauncherChoice next(const std::vector<ModEntry> &mods) override {
|
||||
const NSInteger old = table_.selectedRow;
|
||||
auto *rows = [NSMutableArray new];
|
||||
for (const auto &mod : mods)
|
||||
[rows addObject:@{
|
||||
@"Name" : string(mod.name + (mod.error.empty() ? "" : " ⚠")),
|
||||
@"Art" : string(mod.type)
|
||||
}];
|
||||
bridge_.rows = rows;
|
||||
[table_ reloadData];
|
||||
if (old >= 0 && size_t(old) < mods.size())
|
||||
[table_ selectRowIndexes:[NSIndexSet indexSetWithIndex:old] byExtendingSelection:NO];
|
||||
bridge_->selection();
|
||||
[window_ makeKeyAndOrderFront:nil];
|
||||
const NSInteger response = [NSApp runModalForWindow:window_];
|
||||
return {response == 1 ? LauncherAction::start
|
||||
: response == 2 ? LauncherAction::add
|
||||
: response == 3 ? LauncherAction::remove
|
||||
: response == 4 ? LauncherAction::rename
|
||||
: LauncherAction::end,
|
||||
int(table_.selectedRow)};
|
||||
}
|
||||
std::optional<std::filesystem::path> choose_folder(const std::string &title,
|
||||
const std::filesystem::path &initial) override {
|
||||
auto *panel = [NSOpenPanel openPanel];
|
||||
panel.title = string(title);
|
||||
panel.canChooseFiles = NO;
|
||||
panel.canChooseDirectories = YES;
|
||||
panel.allowsMultipleSelection = NO;
|
||||
if (!initial.empty())
|
||||
panel.directoryURL = [NSURL fileURLWithPath:string(path_to_utf8(initial)) isDirectory:YES];
|
||||
if ([panel runModal] != NSModalResponseOK)
|
||||
return {};
|
||||
return path_from_utf8(utf8(panel.URL.path));
|
||||
}
|
||||
std::optional<AddMod> configure_add(AddMod initial) override {
|
||||
auto *alert = [NSAlert new];
|
||||
alert.messageText = @"Classic-Mod hinzufügen";
|
||||
[alert addButtonWithTitle:@"Importieren"];
|
||||
[alert addButtonWithTitle:@"Abbrechen"];
|
||||
auto *view = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 540, 180)];
|
||||
[view addSubview:label(@"Bezeichnung", NSMakeRect(0, 146, 160, 24))];
|
||||
auto *name = input(string(initial.name), NSMakeRect(170, 146, 370, 24));
|
||||
[view addSubview:name];
|
||||
[view addSubview:label(@"Startjahr (nur Anzeige)", NSMakeRect(0, 106, 165, 24))];
|
||||
auto *year = input(string(std::to_string(initial.start_year)), NSMakeRect(170, 106, 110, 24));
|
||||
[view addSubview:year];
|
||||
auto *migrate = [NSButton checkboxWithTitle:@"Spielstände/Einstellungen übernehmen"
|
||||
target:nil
|
||||
action:nil];
|
||||
migrate.frame = NSMakeRect(0, 68, 540, 24);
|
||||
migrate.state = initial.migrate ? NSControlStateValueOn : NSControlStateValueOff;
|
||||
[view addSubview:migrate];
|
||||
[view addSubview:label(@"Spielstandsordner", NSMakeRect(0, 25, 160, 24))];
|
||||
auto *saves = input(string(path_to_utf8(initial.saves)), NSMakeRect(170, 25, 245, 24));
|
||||
[view addSubview:saves];
|
||||
auto *browse_bridge = [OBMLauncherBridge new];
|
||||
browse_bridge->action = [this, saves](NSInteger) {
|
||||
if (auto p = choose_folder("Spielstandsordner wählen", path_from_utf8(utf8(saves.stringValue))))
|
||||
saves.stringValue = string(path_to_utf8(*p));
|
||||
};
|
||||
auto *browse = [NSButton buttonWithTitle:@"Auswählen …"
|
||||
target:browse_bridge
|
||||
action:@selector(activate:)];
|
||||
browse.frame = NSMakeRect(420, 22, 120, 30);
|
||||
[view addSubview:browse];
|
||||
alert.accessoryView = view;
|
||||
while ([alert runModal] == NSAlertFirstButtonReturn)
|
||||
try {
|
||||
initial.name = utf8(name.stringValue);
|
||||
ModLibrary::validate_name(initial.name);
|
||||
const auto value = utf8(year.stringValue);
|
||||
size_t end = 0;
|
||||
initial.start_year = std::stoi(value, &end);
|
||||
if (end != value.size() || initial.start_year < 1900 || initial.start_year > 9998)
|
||||
throw std::runtime_error("Startjahr muss zwischen 1900 und 9998 liegen");
|
||||
initial.saves = path_from_utf8(utf8(saves.stringValue));
|
||||
initial.migrate = migrate.state == NSControlStateValueOn;
|
||||
return initial;
|
||||
} catch (const std::exception &e) {
|
||||
message(e.what(), true);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
std::optional<std::string> rename(const std::string &old) override {
|
||||
auto *alert = [NSAlert new];
|
||||
alert.messageText = @"Mod umbenennen";
|
||||
[alert addButtonWithTitle:@"Umbenennen"];
|
||||
[alert addButtonWithTitle:@"Abbrechen"];
|
||||
auto *field = input(string(old), NSMakeRect(0, 0, 380, 26));
|
||||
alert.accessoryView = field;
|
||||
if ([alert runModal] != NSAlertFirstButtonReturn)
|
||||
return {};
|
||||
return utf8(field.stringValue);
|
||||
}
|
||||
bool confirm_delete(const std::string &name) override {
|
||||
auto *alert = [NSAlert new];
|
||||
alert.messageText = string("Mod „" + name + "“ löschen?");
|
||||
alert.informativeText = @"Spielstände und persönliche Einstellungen bleiben erhalten.";
|
||||
[alert addButtonWithTitle:@"Abbrechen"];
|
||||
[alert addButtonWithTitle:@"Löschen"];
|
||||
return [alert runModal] == NSAlertSecondButtonReturn;
|
||||
}
|
||||
void message(const std::string &value, bool error) override {
|
||||
auto *alert = [NSAlert new];
|
||||
alert.messageText = @"OpenBMH";
|
||||
alert.informativeText = string(value);
|
||||
alert.alertStyle = error ? NSAlertStyleWarning : NSAlertStyleInformational;
|
||||
[alert runModal];
|
||||
}
|
||||
void progress(const std::string &value, bool cancellable) override {
|
||||
if (!progress_) {
|
||||
cancelled_ = false;
|
||||
for (NSButton *b in buttons_)
|
||||
b.enabled = NO;
|
||||
progress_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 580, 125)
|
||||
styleMask:NSWindowStyleMaskTitled
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
progress_.title = @"OpenBMH";
|
||||
progress_.releasedWhenClosed = NO;
|
||||
progress_label_ = label(string(value), NSMakeRect(16, 65, 548, 40));
|
||||
[progress_.contentView addSubview:progress_label_];
|
||||
progress_bridge_ = [OBMLauncherBridge new];
|
||||
progress_bridge_->action = [this](NSInteger) { cancelled_ = true; };
|
||||
progress_.delegate = progress_bridge_;
|
||||
if (cancellable) {
|
||||
auto *button = [NSButton buttonWithTitle:@"Abbrechen"
|
||||
target:progress_bridge_
|
||||
action:@selector(activate:)];
|
||||
button.frame = NSMakeRect(440, 15, 120, 30);
|
||||
[progress_.contentView addSubview:button];
|
||||
}
|
||||
[window_ beginSheet:progress_ completionHandler:nil];
|
||||
}
|
||||
progress_label_.stringValue = string(value);
|
||||
}
|
||||
bool pump() override {
|
||||
@autoreleasepool {
|
||||
NSEvent *event;
|
||||
while ((event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||
untilDate:[NSDate distantPast]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES]))
|
||||
[NSApp sendEvent:event];
|
||||
[NSApp updateWindows];
|
||||
}
|
||||
return cancelled_;
|
||||
}
|
||||
void finish_progress() override {
|
||||
if (progress_) {
|
||||
progress_bridge_->action = {};
|
||||
[window_ endSheet:progress_];
|
||||
[progress_ orderOut:nil];
|
||||
[progress_ close];
|
||||
progress_ = nil;
|
||||
progress_label_ = nil;
|
||||
progress_bridge_ = nil;
|
||||
for (NSButton *b in buttons_)
|
||||
b.enabled = YES;
|
||||
bridge_->selection();
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
std::unique_ptr<LauncherUI> make_launcher_ui() { return std::make_unique<CocoaLauncher>(); }
|
||||
} // namespace bmh::launch
|
||||
@@ -1,269 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "launch/launcher_ui.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include <gtk/gtk.h>
|
||||
#include <array>
|
||||
namespace bmh::launch {
|
||||
namespace {
|
||||
class GtkLauncher final : public LauncherUI {
|
||||
GtkWidget *window_ = nullptr, *tree_ = nullptr, *progress_ = nullptr, *progress_label_ = nullptr;
|
||||
GtkListStore *model_ = nullptr;
|
||||
std::array<GtkWidget *, 5> buttons_{};
|
||||
bool cancelled_ = false;
|
||||
std::string selection_;
|
||||
enum { Start = 1, Add, Delete, Rename, End };
|
||||
static void selection_changed(GtkTreeSelection *selection, gpointer data) {
|
||||
auto &self = *static_cast<GtkLauncher *>(data);
|
||||
GtkTreeIter it;
|
||||
GtkTreeModel *model;
|
||||
const bool selected = gtk_tree_selection_get_selected(selection, &model, &it);
|
||||
for (int id : {Start, Delete, Rename})
|
||||
gtk_widget_set_sensitive(self.buttons_[size_t(id - 1)], selected);
|
||||
}
|
||||
GtkWidget *entry(GtkWidget *grid, int row, const char *label, const std::string &initial) {
|
||||
auto *title = gtk_label_new(label);
|
||||
gtk_widget_set_halign(title, GTK_ALIGN_START);
|
||||
gtk_grid_attach(GTK_GRID(grid), title, 0, row, 1, 1);
|
||||
auto *input = gtk_entry_new();
|
||||
gtk_entry_set_text(GTK_ENTRY(input), initial.c_str());
|
||||
gtk_widget_set_hexpand(input, TRUE);
|
||||
gtk_grid_attach(GTK_GRID(grid), input, 1, row, 1, 1);
|
||||
return input;
|
||||
}
|
||||
|
||||
public:
|
||||
GtkLauncher() {
|
||||
if (!gtk_init_check(nullptr, nullptr))
|
||||
throw std::runtime_error("Kein Desktop für den nativen Launcher verfügbar");
|
||||
window_ = gtk_dialog_new();
|
||||
gtk_window_set_title(GTK_WINDOW(window_), "OpenBMH");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window_), 620, 340);
|
||||
auto *body = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(body), 16);
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window_))), body, TRUE, TRUE, 0);
|
||||
model_ = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
tree_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model_));
|
||||
auto *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_));
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
||||
g_signal_connect(selection, "changed", G_CALLBACK(selection_changed), this);
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
auto *renderer = gtk_cell_renderer_text_new();
|
||||
auto *column =
|
||||
gtk_tree_view_column_new_with_attributes(i ? "Art" : "Name", renderer, "text", i, nullptr);
|
||||
gtk_tree_view_column_set_expand(column, i == 0);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_), column);
|
||||
}
|
||||
gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(tree_), 2);
|
||||
auto *scroller = gtk_scrolled_window_new(nullptr, nullptr);
|
||||
gtk_widget_set_hexpand(scroller, TRUE);
|
||||
gtk_widget_set_vexpand(scroller, TRUE);
|
||||
gtk_container_add(GTK_CONTAINER(scroller), tree_);
|
||||
gtk_box_pack_start(GTK_BOX(body), scroller, TRUE, TRUE, 0);
|
||||
auto *buttons = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_pack_start(GTK_BOX(body), buttons, FALSE, FALSE, 0);
|
||||
const char *labels[] = {"Start", "Add", "Delete", "Rename", "End"};
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
auto *button = gtk_button_new_with_label(labels[i]);
|
||||
buttons_[size_t(i)] = button;
|
||||
gtk_box_pack_start(GTK_BOX(buttons), button, FALSE, FALSE, 0);
|
||||
g_object_set_data(G_OBJECT(button), "response-id", GINT_TO_POINTER(i + 1));
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(+[](GtkButton *button, gpointer self) {
|
||||
auto *window = static_cast<GtkLauncher *>(self)->window_;
|
||||
gtk_dialog_response(
|
||||
GTK_DIALOG(window),
|
||||
GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "response-id")));
|
||||
}),
|
||||
this);
|
||||
}
|
||||
g_signal_connect(tree_, "row-activated",
|
||||
G_CALLBACK(+[](GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, gpointer data) {
|
||||
gtk_dialog_response(GTK_DIALOG(static_cast<GtkLauncher *>(data)->window_),
|
||||
Start);
|
||||
}),
|
||||
this);
|
||||
gtk_widget_show_all(window_);
|
||||
}
|
||||
~GtkLauncher() override {
|
||||
finish_progress();
|
||||
gtk_widget_destroy(window_);
|
||||
g_object_unref(model_);
|
||||
}
|
||||
LauncherChoice next(const std::vector<ModEntry> &mods) override {
|
||||
gtk_list_store_clear(model_);
|
||||
int selected = -1;
|
||||
for (size_t i = 0; i < mods.size(); ++i) {
|
||||
GtkTreeIter it;
|
||||
gtk_list_store_append(model_, &it);
|
||||
const auto &mod = mods[i];
|
||||
const auto shown = mod.error.empty() ? mod.name : mod.name + " ⚠";
|
||||
gtk_list_store_set(model_, &it, 0, shown.c_str(), 1, mod.type.c_str(), 2, mod.error.c_str(), -1);
|
||||
if (mod.name == selection_) {
|
||||
auto *path = gtk_tree_path_new_from_indices(int(i), -1);
|
||||
gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_), path, nullptr, FALSE);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
}
|
||||
selection_changed(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_)), this);
|
||||
const int response = gtk_dialog_run(GTK_DIALOG(window_));
|
||||
GtkTreeIter it;
|
||||
GtkTreeModel *model;
|
||||
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_)), &model, &it)) {
|
||||
auto *path = gtk_tree_model_get_path(model, &it);
|
||||
selected = gtk_tree_path_get_indices(path)[0];
|
||||
gtk_tree_path_free(path);
|
||||
if (selected >= 0 && size_t(selected) < mods.size())
|
||||
selection_ = mods[size_t(selected)].name;
|
||||
}
|
||||
return {response == Start ? LauncherAction::start
|
||||
: response == Add ? LauncherAction::add
|
||||
: response == Delete ? LauncherAction::remove
|
||||
: response == Rename ? LauncherAction::rename
|
||||
: LauncherAction::end,
|
||||
selected};
|
||||
}
|
||||
std::optional<std::filesystem::path> choose_folder(const std::string &title,
|
||||
const std::filesystem::path &initial) override {
|
||||
auto *dialog = gtk_file_chooser_dialog_new(
|
||||
title.c_str(), GTK_WINDOW(window_), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "Abbrechen",
|
||||
GTK_RESPONSE_CANCEL, "Auswählen", GTK_RESPONSE_ACCEPT, nullptr);
|
||||
const auto folder=initial.empty()?path_from_utf8(g_get_home_dir()):initial;
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),path_to_utf8(folder).c_str());
|
||||
std::optional<std::filesystem::path> result;
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
if (file) {
|
||||
result = path_from_utf8(file);
|
||||
g_free(file);
|
||||
}
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
return result;
|
||||
}
|
||||
std::optional<AddMod> configure_add(AddMod initial) override {
|
||||
auto *dialog = gtk_dialog_new_with_buttons("Classic-Mod hinzufügen", GTK_WINDOW(window_),
|
||||
GTK_DIALOG_MODAL, "Abbrechen", GTK_RESPONSE_CANCEL,
|
||||
"Importieren", GTK_RESPONSE_ACCEPT, nullptr);
|
||||
gtk_window_set_default_size(GTK_WINDOW(dialog), 540, -1);
|
||||
auto *grid = gtk_grid_new();
|
||||
gtk_grid_set_row_spacing(GTK_GRID(grid), 12);
|
||||
gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(grid), 16);
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), grid, TRUE, TRUE, 0);
|
||||
auto *name = entry(grid, 0, "Bezeichnung", initial.name);
|
||||
auto *year = entry(grid, 1, "Startjahr (nur Anzeige)", std::to_string(initial.start_year));
|
||||
auto *migrate = gtk_check_button_new_with_label("Spielstände/Einstellungen übernehmen");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(migrate), initial.migrate);
|
||||
gtk_grid_attach(GTK_GRID(grid), migrate, 0, 2, 3, 1);
|
||||
auto *saves = entry(grid, 3, "Spielstandsordner", path_to_utf8(initial.saves));
|
||||
auto *browse = gtk_button_new_with_label("Auswählen …");
|
||||
gtk_grid_attach(GTK_GRID(grid), browse, 2, 3, 1, 1);
|
||||
struct Browse {
|
||||
GtkLauncher *self;
|
||||
GtkWidget *input;
|
||||
};
|
||||
Browse context{this, saves};
|
||||
g_signal_connect(
|
||||
browse, "clicked", G_CALLBACK(+[](GtkButton *, gpointer p) {
|
||||
auto &c = *static_cast<Browse *>(p);
|
||||
if (auto path = c.self->choose_folder("Spielstandsordner wählen",
|
||||
path_from_utf8(gtk_entry_get_text(GTK_ENTRY(c.input)))))
|
||||
gtk_entry_set_text(GTK_ENTRY(c.input), path_to_utf8(*path).c_str());
|
||||
}),
|
||||
&context);
|
||||
gtk_widget_show_all(dialog);
|
||||
std::optional<AddMod> result;
|
||||
while (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
try {
|
||||
initial.name = gtk_entry_get_text(GTK_ENTRY(name));
|
||||
ModLibrary::validate_name(initial.name);
|
||||
std::string value = gtk_entry_get_text(GTK_ENTRY(year));
|
||||
size_t end = 0;
|
||||
initial.start_year = std::stoi(value, &end);
|
||||
if (end != value.size() || initial.start_year < 1900 || initial.start_year > 9998)
|
||||
throw std::runtime_error("Startjahr muss zwischen 1900 und 9998 liegen");
|
||||
initial.saves = path_from_utf8(gtk_entry_get_text(GTK_ENTRY(saves)));
|
||||
initial.migrate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(migrate));
|
||||
result = initial;
|
||||
break;
|
||||
} catch (const std::exception &e) {
|
||||
message(e.what(), true);
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
return result;
|
||||
}
|
||||
std::optional<std::string> rename(const std::string &old) override {
|
||||
auto *dialog =
|
||||
gtk_dialog_new_with_buttons("Mod umbenennen", GTK_WINDOW(window_), GTK_DIALOG_MODAL, "Abbrechen",
|
||||
GTK_RESPONSE_CANCEL, "Umbenennen", GTK_RESPONSE_ACCEPT, nullptr);
|
||||
auto *input = gtk_entry_new();
|
||||
gtk_entry_set_text(GTK_ENTRY(input), old.c_str());
|
||||
gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), 16);
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), input, TRUE, TRUE, 0);
|
||||
gtk_widget_show_all(dialog);
|
||||
std::optional<std::string> result;
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
result = gtk_entry_get_text(GTK_ENTRY(input));
|
||||
gtk_widget_destroy(dialog);
|
||||
return result;
|
||||
}
|
||||
bool confirm_delete(const std::string &name) override {
|
||||
auto *dialog = gtk_message_dialog_new(GTK_WINDOW(window_), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_YES_NO, "Mod „%s“ löschen?", name.c_str());
|
||||
gtk_message_dialog_format_secondary_text(
|
||||
GTK_MESSAGE_DIALOG(dialog), "Spielstände und persönliche Einstellungen bleiben erhalten.");
|
||||
const bool yes = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES;
|
||||
gtk_widget_destroy(dialog);
|
||||
return yes;
|
||||
}
|
||||
void message(const std::string &text, bool error) override {
|
||||
auto *dialog = gtk_message_dialog_new(GTK_WINDOW(window_), GTK_DIALOG_MODAL,
|
||||
error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
|
||||
"%s", text.c_str());
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
void progress(const std::string &text, bool cancellable) override {
|
||||
if (!progress_) {
|
||||
cancelled_ = false;
|
||||
progress_ = gtk_dialog_new();
|
||||
gtk_window_set_title(GTK_WINDOW(progress_), "OpenBMH");
|
||||
gtk_window_set_transient_for(GTK_WINDOW(progress_), GTK_WINDOW(window_));
|
||||
gtk_window_set_modal(GTK_WINDOW(progress_), TRUE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(progress_), 20);
|
||||
progress_label_ = gtk_label_new(text.c_str());
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(progress_))), progress_label_,
|
||||
TRUE, TRUE, 0);
|
||||
if (cancellable)
|
||||
gtk_dialog_add_button(GTK_DIALOG(progress_), "Abbrechen", GTK_RESPONSE_CANCEL);
|
||||
g_signal_connect(progress_, "response", G_CALLBACK(+[](GtkDialog *, int, gpointer data) {
|
||||
static_cast<GtkLauncher *>(data)->cancelled_ = true;
|
||||
}),
|
||||
this);
|
||||
g_signal_connect(progress_, "delete-event",
|
||||
G_CALLBACK(+[](GtkWidget *, GdkEvent *, gpointer data) -> gboolean {
|
||||
static_cast<GtkLauncher *>(data)->cancelled_ = true;
|
||||
return TRUE;
|
||||
}),
|
||||
this);
|
||||
gtk_widget_set_sensitive(window_, FALSE);
|
||||
gtk_widget_show_all(progress_);
|
||||
}
|
||||
gtk_label_set_text(GTK_LABEL(progress_label_), text.c_str());
|
||||
}
|
||||
bool pump() override {
|
||||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
return cancelled_;
|
||||
}
|
||||
void finish_progress() override {
|
||||
if (progress_) {
|
||||
gtk_widget_destroy(progress_);
|
||||
progress_ = progress_label_ = nullptr;
|
||||
gtk_widget_set_sensitive(window_, TRUE);
|
||||
gtk_window_present(GTK_WINDOW(window_));
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
std::unique_ptr<LauncherUI> make_launcher_ui() { return std::make_unique<GtkLauncher>(); }
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,557 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "launch/launcher_ui.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/process.hpp"
|
||||
#include "version.hpp"
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControl.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlInput.h>
|
||||
#include <RmlUi_Platform_SDL.h>
|
||||
#include <RmlUi_Renderer_GL3.h>
|
||||
#include <nfd.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace bmh::launch {
|
||||
namespace {
|
||||
std::string escape(std::string_view value) {
|
||||
std::string result;
|
||||
for (char c : value)
|
||||
switch (c) {
|
||||
case '&':
|
||||
result += "&";
|
||||
break;
|
||||
case '<':
|
||||
result += "<";
|
||||
break;
|
||||
case '>':
|
||||
result += ">";
|
||||
break;
|
||||
case '"':
|
||||
result += """;
|
||||
break;
|
||||
case '\n':
|
||||
result += "<br/>";
|
||||
break;
|
||||
default:
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
[[noreturn]] void sdl_error(const char *operation) {
|
||||
throw std::runtime_error(std::string(operation) + ": " + SDL_GetError());
|
||||
}
|
||||
int modifiers(Uint16 state) {
|
||||
int result = 0;
|
||||
if (state & KMOD_CTRL)
|
||||
result |= Rml::Input::KM_CTRL;
|
||||
if (state & KMOD_SHIFT)
|
||||
result |= Rml::Input::KM_SHIFT;
|
||||
if (state & KMOD_ALT)
|
||||
result |= Rml::Input::KM_ALT;
|
||||
if (state & KMOD_GUI)
|
||||
result |= Rml::Input::KM_META;
|
||||
#ifdef __APPLE__
|
||||
// RmlUI text widgets use the Ctrl flag for editing shortcuts.
|
||||
if (state & KMOD_GUI)
|
||||
result |= Rml::Input::KM_CTRL;
|
||||
#endif
|
||||
if (state & KMOD_CAPS)
|
||||
result |= Rml::Input::KM_CAPSLOCK;
|
||||
if (state & KMOD_NUM)
|
||||
result |= Rml::Input::KM_NUMLOCK;
|
||||
return result;
|
||||
}
|
||||
struct Video {
|
||||
SDL_Window *window = nullptr;
|
||||
SDL_GLContext gl = nullptr;
|
||||
bool loader = false;
|
||||
Video() {
|
||||
try {
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
|
||||
sdl_error("Launcher video initialization");
|
||||
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
#ifdef __APPLE__
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
#else
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||
#endif
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
window = SDL_CreateWindow("OpenBMH", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1100, 688,
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI |
|
||||
SDL_WINDOW_HIDDEN);
|
||||
if (!window)
|
||||
sdl_error("Launcher window");
|
||||
SDL_SetWindowMinimumSize(window, 800, 540);
|
||||
gl = SDL_GL_CreateContext(window);
|
||||
if (!gl)
|
||||
sdl_error("Launcher requires OpenGL 3.3 (macOS: 4.1)");
|
||||
SDL_GL_MakeCurrent(window, gl);
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
std::string error;
|
||||
if (!RmlGL3::Initialize(&error))
|
||||
throw std::runtime_error("Launcher graphics initialization: " + error);
|
||||
loader = true;
|
||||
SDL_StopTextInput();
|
||||
} catch (...) {
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
void close() {
|
||||
if (loader)
|
||||
RmlGL3::Shutdown();
|
||||
if (gl)
|
||||
SDL_GL_DeleteContext(gl);
|
||||
if (window)
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER);
|
||||
}
|
||||
~Video() { close(); }
|
||||
};
|
||||
class RmlLauncher final : public LauncherUI, public Rml::EventListener {
|
||||
Video video_;
|
||||
SystemInterface_SDL system_{video_.window};
|
||||
RenderInterface_GL3 renderer_;
|
||||
TextInputMethodEditor_SDL ime_;
|
||||
Rml::Context *context_ = nullptr;
|
||||
Rml::ElementDocument *document_ = nullptr;
|
||||
bool initialized_ = false, closed_ = false, dirty_ = true;
|
||||
bool answered_ = false, accepted_ = false, busy_ = false, cancelled_ = false;
|
||||
bool cancellable_ = false, modal_visible_ = false;
|
||||
int selected_ = -1;
|
||||
std::string selected_name_;
|
||||
std::vector<ModEntry> mods_;
|
||||
std::optional<LauncherAction> action_;
|
||||
|
||||
Rml::Element *element(const char *id) const {
|
||||
auto *value = document_->GetElementById(id);
|
||||
if (!value)
|
||||
throw std::runtime_error(std::string("Launcher element missing: ") + id);
|
||||
return value;
|
||||
}
|
||||
void text(const char *id, const std::string &value) {
|
||||
element(id)->SetInnerRML(escape(value));
|
||||
dirty_ = true;
|
||||
}
|
||||
void display(const char *id, bool shown, const char *style = "block") {
|
||||
element(id)->SetProperty("display", shown ? style : "none");
|
||||
dirty_ = true;
|
||||
}
|
||||
void enabled(const char *id, bool active) {
|
||||
auto *button = element(id);
|
||||
if (active)
|
||||
button->RemoveAttribute("disabled");
|
||||
else
|
||||
button->SetAttribute("disabled", "disabled");
|
||||
button->SetPseudoClass("disabled", !active);
|
||||
button->SetProperty("focus", active ? "auto" : "none");
|
||||
dirty_ = true;
|
||||
}
|
||||
std::string value(const char *id) const {
|
||||
auto *input = dynamic_cast<Rml::ElementFormControl *>(element(id));
|
||||
if (!input)
|
||||
throw std::runtime_error("Launcher input has the wrong type");
|
||||
return input->GetValue();
|
||||
}
|
||||
void resize() {
|
||||
int w = 0, h = 0, pixels_w = 0, pixels_h = 0;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
SDL_GL_GetDrawableSize(video_.window, &pixels_w, &pixels_h);
|
||||
if (w <= 0 || h <= 0 || pixels_w <= 0 || pixels_h <= 0)
|
||||
return;
|
||||
renderer_.SetViewport(pixels_w, pixels_h);
|
||||
context_->SetDimensions({pixels_w, pixels_h});
|
||||
const float scale = std::clamp(std::min(w / 1100.f, h / 688.f), .72f, 2.5f);
|
||||
context_->SetDensityIndependentPixelRatio(float(pixels_w) / w * scale);
|
||||
dirty_ = true;
|
||||
}
|
||||
void select(int index, bool focus = false) {
|
||||
if (index < 0 || size_t(index) >= mods_.size())
|
||||
index = -1;
|
||||
selected_ = index;
|
||||
selected_name_ = index >= 0 ? mods_[size_t(index)].name : std::string{};
|
||||
for (size_t i = 0; i < mods_.size(); ++i) {
|
||||
auto *row = document_->GetElementById("mod-" + std::to_string(i));
|
||||
row->SetClass("selected", int(i) == selected_);
|
||||
row->SetAttribute("aria-selected", int(i) == selected_ ? "true" : "false");
|
||||
if (focus && int(i) == selected_) {
|
||||
row->Focus(true);
|
||||
row->ScrollIntoView();
|
||||
}
|
||||
}
|
||||
enabled("start", selected_ >= 0);
|
||||
enabled("delete", selected_ >= 0);
|
||||
enabled("rename", selected_ >= 0);
|
||||
}
|
||||
bool modal_open() const { return modal_visible_; }
|
||||
void close_modal() {
|
||||
modal_visible_ = false;
|
||||
display("overlay", false);
|
||||
answered_ = false;
|
||||
busy_ = false;
|
||||
SDL_StopTextInput();
|
||||
if (selected_ >= 0)
|
||||
select(selected_, true);
|
||||
else
|
||||
element("add")->Focus(true);
|
||||
}
|
||||
void modal(const std::string &title, const std::string &body, const std::string &accept,
|
||||
bool cancel = true, bool danger = false) {
|
||||
text("modal-title", title);
|
||||
element("modal-body")->SetInnerRML(body);
|
||||
text("modal-error", "");
|
||||
text("accept", accept);
|
||||
element("accept")->SetClass("danger", danger);
|
||||
element("accept")->SetClass("primary", !danger);
|
||||
display("accept", !accept.empty(), "inline-block");
|
||||
display("cancel", cancel, "inline-block");
|
||||
answered_ = accepted_ = false;
|
||||
display("overlay", true);
|
||||
modal_visible_ = true;
|
||||
if (auto *input = document_->GetElementById("mod-name"))
|
||||
input->Focus(true);
|
||||
else
|
||||
element(cancel ? "cancel" : "accept")->Focus(true);
|
||||
context_->Update();
|
||||
dirty_ = true;
|
||||
}
|
||||
void dispatch(const std::string &command) {
|
||||
if (command == "cancel") {
|
||||
if (busy_) {
|
||||
if (cancellable_)
|
||||
cancelled_ = true;
|
||||
} else {
|
||||
answered_ = true;
|
||||
accepted_ = false;
|
||||
}
|
||||
} else if (command == "accept" && !busy_) {
|
||||
answered_ = accepted_ = true;
|
||||
} else if (command == "browse" && !busy_) {
|
||||
try {
|
||||
if (auto path =
|
||||
choose_folder("Spielstandsordner wählen", path_from_utf8(value("save-folder")))) {
|
||||
auto *input = dynamic_cast<Rml::ElementFormControl *>(element("save-folder"));
|
||||
input->SetValue(path_to_utf8(*path));
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
text("modal-error", e.what());
|
||||
}
|
||||
} else if (!modal_open()) {
|
||||
if (command == "add")
|
||||
action_ = LauncherAction::add;
|
||||
else if (command == "end")
|
||||
action_ = LauncherAction::end;
|
||||
else if (selected_ >= 0) {
|
||||
if (command == "start")
|
||||
action_ = LauncherAction::start;
|
||||
else if (command == "rename")
|
||||
action_ = LauncherAction::rename;
|
||||
else if (command == "delete")
|
||||
action_ = LauncherAction::remove;
|
||||
}
|
||||
}
|
||||
dirty_ = true;
|
||||
}
|
||||
void ProcessEvent(Rml::Event &event) override {
|
||||
const bool double_click = event.GetType() == "dblclick";
|
||||
if (event.GetType() != "click" && !double_click)
|
||||
return;
|
||||
for (auto *target = event.GetTargetElement(); target && target != document_;
|
||||
target = target->GetParentNode()) {
|
||||
if (target->HasAttribute("data-row") && !modal_open()) {
|
||||
select(target->GetAttribute<int>("data-row", -1));
|
||||
if (double_click)
|
||||
dispatch("start");
|
||||
return;
|
||||
}
|
||||
if (target->HasAttribute("data-action")) {
|
||||
if (double_click)
|
||||
return;
|
||||
if (!target->HasAttribute("disabled"))
|
||||
dispatch(target->GetAttribute<Rml::String>("data-action", ""));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void step(bool wait) {
|
||||
// Modal visibility and refreshed rows must be laid out before queued
|
||||
// pointer events are hit-tested against the new document state.
|
||||
if (dirty_) context_->Update();
|
||||
SDL_Event event;
|
||||
const int timeout = dirty_ ? 0 : int(std::clamp(context_->GetNextUpdateDelay(), 0.0, .2) * 1000);
|
||||
bool got = wait ? SDL_WaitEventTimeout(&event, timeout) != 0 : SDL_PollEvent(&event) != 0;
|
||||
bool redraw = dirty_ || got || context_->GetNextUpdateDelay() <= 0;
|
||||
while (got) {
|
||||
if (event.type == SDL_QUIT ||
|
||||
(event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE)) {
|
||||
closed_ = answered_ = true;
|
||||
accepted_ = false;
|
||||
cancelled_ = true;
|
||||
action_ = LauncherAction::end;
|
||||
} else if (event.type == SDL_KEYDOWN && !event.key.repeat &&
|
||||
event.key.keysym.sym == SDLK_ESCAPE) {
|
||||
if (modal_open())
|
||||
dispatch("cancel");
|
||||
else
|
||||
action_ = LauncherAction::end;
|
||||
} else if (event.type == SDL_KEYDOWN && modal_open() && event.key.keysym.sym == SDLK_TAB) {
|
||||
Rml::ElementList controls;
|
||||
element("modal")->QuerySelectorAll(controls, "input, button");
|
||||
std::erase_if(controls, [](auto *control) {
|
||||
return !control->IsVisible() || control->HasAttribute("disabled");
|
||||
});
|
||||
if (!controls.empty()) {
|
||||
const auto at = std::find(controls.begin(), controls.end(), context_->GetFocusElement());
|
||||
const int current = at == controls.end() ? -1 : int(at - controls.begin());
|
||||
const int step = event.key.keysym.mod & KMOD_SHIFT ? -1 : 1;
|
||||
const int next = (current + step + int(controls.size())) % int(controls.size());
|
||||
controls[size_t(next)]->Focus(true);
|
||||
}
|
||||
} else if (event.type == SDL_KEYDOWN && !modal_open() && !event.key.repeat &&
|
||||
(event.key.keysym.sym == SDLK_UP || event.key.keysym.sym == SDLK_DOWN)) {
|
||||
const int direction = event.key.keysym.sym == SDLK_UP ? -1 : 1;
|
||||
if (!mods_.empty())
|
||||
select(std::clamp(selected_ < 0 ? 0 : selected_ + direction, 0, int(mods_.size()) - 1),
|
||||
true);
|
||||
} else if (event.type == SDL_KEYDOWN && !event.key.repeat &&
|
||||
(event.key.keysym.sym == SDLK_RETURN || event.key.keysym.sym == SDLK_SPACE) &&
|
||||
context_->GetFocusElement() &&
|
||||
context_->GetFocusElement()->HasAttribute("data-action")) {
|
||||
auto *focused = context_->GetFocusElement();
|
||||
if (!focused->HasAttribute("disabled"))
|
||||
dispatch(focused->GetAttribute<Rml::String>("data-action", ""));
|
||||
} else if (event.type == SDL_KEYDOWN && !event.key.repeat &&
|
||||
event.key.keysym.sym == SDLK_RETURN) {
|
||||
if (modal_open() && !busy_)
|
||||
dispatch("accept");
|
||||
else if (!modal_open() && selected_ >= 0)
|
||||
dispatch("start");
|
||||
} else if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) {
|
||||
// Use the modifiers captured with this event, not SDL's final
|
||||
// state after pumping a batch containing the key releases.
|
||||
const auto key = RmlSDL::ConvertKey(event.key.keysym.sym);
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
context_->ProcessKeyDown(key, modifiers(event.key.keysym.mod));
|
||||
else
|
||||
context_->ProcessKeyUp(key, modifiers(event.key.keysym.mod));
|
||||
} else {
|
||||
if (event.type == SDL_TEXTEDITING)
|
||||
ime_.HandleEdit(event.edit);
|
||||
// SDL2 reports mouse coordinates in window units on Retina/HiDPI.
|
||||
int w = 0, h = 0, pw = 0, ph = 0;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
SDL_GL_GetDrawableSize(video_.window, &pw, &ph);
|
||||
if (w > 0 && h > 0) {
|
||||
if (event.type == SDL_MOUSEMOTION) {
|
||||
event.motion.x = int(double(event.motion.x) * pw / w);
|
||||
event.motion.y = int(double(event.motion.y) * ph / h);
|
||||
}
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
|
||||
event.button.x = int(double(event.button.x) * pw / w);
|
||||
event.button.y = int(double(event.button.y) * ph / h);
|
||||
// Repeated clicks need a fresh hover target even when
|
||||
// the pointer has not moved since a modal was closed.
|
||||
context_->ProcessMouseMove(event.button.x, event.button.y,
|
||||
RmlSDL::GetKeyModifierState());
|
||||
}
|
||||
}
|
||||
RmlSDL::InputEventHandler(context_, video_.window, event);
|
||||
}
|
||||
if (event.type == SDL_WINDOWEVENT)
|
||||
resize();
|
||||
got = SDL_PollEvent(&event) != 0;
|
||||
}
|
||||
if (redraw) {
|
||||
context_->Update();
|
||||
renderer_.BeginFrame();
|
||||
renderer_.Clear();
|
||||
context_->Render();
|
||||
renderer_.EndFrame();
|
||||
SDL_GL_SwapWindow(video_.window);
|
||||
dirty_ = false;
|
||||
}
|
||||
}
|
||||
bool wait_modal() {
|
||||
while (!answered_ && !closed_)
|
||||
step(true);
|
||||
answered_ = false;
|
||||
return accepted_ && !closed_;
|
||||
}
|
||||
|
||||
public:
|
||||
RmlLauncher() {
|
||||
if (!renderer_)
|
||||
throw std::runtime_error("RmlUI could not create the OpenGL renderer");
|
||||
try {
|
||||
Rml::SetSystemInterface(&system_);
|
||||
Rml::SetRenderInterface(&renderer_);
|
||||
Rml::SetTextInputHandler(&ime_);
|
||||
initialized_ = Rml::Initialise();
|
||||
if (!initialized_)
|
||||
throw std::runtime_error("RmlUI initialization failed");
|
||||
const auto assets = executable_path({}).parent_path() / "assets" / "launcher";
|
||||
for (const char *weight : {"Regular", "Bold"})
|
||||
if (!Rml::LoadFontFace(path_to_utf8(assets / (std::string("LatoLatin-") + weight + ".ttf"))))
|
||||
throw std::runtime_error("Launcher font missing; extract the complete OpenBMH package");
|
||||
context_ = Rml::CreateContext("launcher", {1100, 688});
|
||||
if (!context_)
|
||||
throw std::runtime_error("RmlUI launcher context failed");
|
||||
document_ = context_->LoadDocument(path_to_utf8(assets / "launcher.rml"));
|
||||
if (!document_)
|
||||
throw std::runtime_error("Launcher layout missing; extract the complete OpenBMH package");
|
||||
document_->AddEventListener("click", this);
|
||||
document_->AddEventListener("dblclick", this);
|
||||
text("version", std::string("v") + bmh::kOpenBmhVersion);
|
||||
resize();
|
||||
document_->Show();
|
||||
SDL_ShowWindow(video_.window);
|
||||
element("add")->Focus(true);
|
||||
} catch (...) {
|
||||
if (initialized_)
|
||||
Rml::Shutdown();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
~RmlLauncher() override {
|
||||
if (initialized_)
|
||||
Rml::Shutdown();
|
||||
}
|
||||
LauncherChoice next(const std::vector<ModEntry> &mods) override {
|
||||
if (closed_)
|
||||
return {LauncherAction::end, -1};
|
||||
mods_ = mods;
|
||||
std::string rows;
|
||||
int selection = -1;
|
||||
for (size_t i = 0; i < mods.size(); ++i) {
|
||||
const auto &mod = mods[i];
|
||||
if (mod.name == selected_name_)
|
||||
selection = int(i);
|
||||
rows += "<button id=\"mod-" + std::to_string(i) + "\" class=\"mod-row" +
|
||||
(mod.error.empty() ? "" : " invalid") + "\" data-row=\"" + std::to_string(i) +
|
||||
"\" title=\"" + escape(mod.error) + "\"><span class=\"name\">" + escape(mod.name) +
|
||||
"</span><span class=\"type\">" + escape(mod.type) + "</span></button>";
|
||||
}
|
||||
if (mods.empty())
|
||||
rows = "<div class=\"empty\">Keine Mods vorhanden.<div class=\"empty-detail\">Über Add eine "
|
||||
"Installation hinzufügen.</div></div>";
|
||||
element("mod-list")->SetInnerRML(rows);
|
||||
text("mod-count", std::to_string(mods.size()) + (mods.size() == 1 ? " Mod" : " Mods"));
|
||||
select(selection);
|
||||
action_.reset();
|
||||
while (!action_ && !closed_)
|
||||
step(true);
|
||||
return {action_.value_or(LauncherAction::end), selected_};
|
||||
}
|
||||
std::optional<std::filesystem::path> choose_folder(const std::string &title,
|
||||
const std::filesystem::path &initial = {}) override {
|
||||
(void)title;
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePathU8 result;
|
||||
const auto directory = path_to_utf8(initial.empty() ? executable_path({}).parent_path() : initial);
|
||||
const auto status = NFD::PickFolder(result, directory.c_str());
|
||||
SDL_RaiseWindow(video_.window);
|
||||
dirty_ = true;
|
||||
if (status == NFD_CANCEL)
|
||||
return {};
|
||||
if (status != NFD_OKAY)
|
||||
throw std::runtime_error(std::string("Ordnerauswahl: ") + NFD::GetError());
|
||||
return path_from_utf8(result.get());
|
||||
}
|
||||
std::optional<AddMod> configure_add(AddMod initial) override {
|
||||
modal("Classic-Mod hinzufügen",
|
||||
"<label>Bezeichnung</label><input id=\"mod-name\" type=\"text\" maxlength=\"100\" value=\"" +
|
||||
escape(initial.name) +
|
||||
"\"/><div class=\"fields\"><div class=\"year\"><label>Startjahr (nur "
|
||||
"Anzeige)</label><input id=\"start-year\" type=\"text\" maxlength=\"4\" value=\"" +
|
||||
std::to_string(initial.start_year) +
|
||||
"\"/></div></div><div class=\"check-row\"><input id=\"migrate\" class=\"checkbox\" "
|
||||
"type=\"checkbox\" " +
|
||||
(initial.migrate ? "checked=\"checked\"" : "") +
|
||||
"/><label for=\"migrate\">Spielstände/Einstellungen "
|
||||
"übernehmen</label></div><label>Spielstandsordner</label><div class=\"browse-row\"><input "
|
||||
"id=\"save-folder\" type=\"text\" value=\"" +
|
||||
escape(path_to_utf8(initial.saves)) +
|
||||
"\"/><button data-action=\"browse\">Auswählen …</button></div>",
|
||||
"Importieren");
|
||||
while (wait_modal()) {
|
||||
try {
|
||||
initial.name = value("mod-name");
|
||||
ModLibrary::validate_name(initial.name);
|
||||
const auto year = value("start-year");
|
||||
size_t end = 0;
|
||||
initial.start_year = std::stoi(year, &end);
|
||||
if (end != year.size() || initial.start_year < 1900 || initial.start_year > 9998)
|
||||
throw std::runtime_error("Startjahr muss zwischen 1900 und 9998 liegen.");
|
||||
initial.migrate = element("migrate")->HasAttribute("checked");
|
||||
initial.saves = path_from_utf8(value("save-folder"));
|
||||
close_modal();
|
||||
return initial;
|
||||
} catch (const std::exception &e) {
|
||||
text("modal-error", e.what());
|
||||
}
|
||||
}
|
||||
close_modal();
|
||||
return {};
|
||||
}
|
||||
std::optional<std::string> rename(const std::string &old) override {
|
||||
modal("Mod umbenennen",
|
||||
"<label>Bezeichnung</label><input id=\"mod-name\" type=\"text\" maxlength=\"100\" value=\"" +
|
||||
escape(old) + "\"/>",
|
||||
"Umbenennen");
|
||||
std::optional<std::string> result;
|
||||
while (wait_modal()) {
|
||||
try {
|
||||
auto name = value("mod-name");
|
||||
ModLibrary::validate_name(name);
|
||||
result = name;
|
||||
break;
|
||||
} catch (const std::exception &e) {
|
||||
text("modal-error", e.what());
|
||||
}
|
||||
}
|
||||
close_modal();
|
||||
return result;
|
||||
}
|
||||
bool confirm_delete(const std::string &name) override {
|
||||
modal("Mod löschen?",
|
||||
"„" + escape(name) + "“<br/><br/>Spielstände und persönliche Einstellungen bleiben erhalten.",
|
||||
"Löschen", true, true);
|
||||
const bool result = wait_modal();
|
||||
close_modal();
|
||||
return result;
|
||||
}
|
||||
void message(const std::string &value, bool error) override {
|
||||
if (closed_)
|
||||
return;
|
||||
modal(error ? "OpenBMH · Hinweis" : "OpenBMH", escape(value), "OK", false);
|
||||
wait_modal();
|
||||
close_modal();
|
||||
}
|
||||
void progress(const std::string &value, bool cancellable) override {
|
||||
if (!busy_) {
|
||||
modal(cancellable ? "Mod importieren" : "Spiel läuft", escape(value), "", cancellable);
|
||||
busy_ = true;
|
||||
cancelled_ = false;
|
||||
cancellable_ = cancellable;
|
||||
} else
|
||||
text("modal-body", value);
|
||||
}
|
||||
bool pump() override {
|
||||
step(false);
|
||||
return cancelled_ || closed_;
|
||||
}
|
||||
void finish_progress() override {
|
||||
if (busy_)
|
||||
close_modal();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
std::unique_ptr<LauncherUI> make_launcher_ui() { return std::make_unique<RmlLauncher>(); }
|
||||
} // namespace bmh::launch
|
||||
@@ -1,320 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#ifndef UNICODE
|
||||
#define UNICODE
|
||||
#endif
|
||||
#ifndef _UNICODE
|
||||
#define _UNICODE
|
||||
#endif
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <shobjidl.h>
|
||||
#include "launch/launcher_ui.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include <functional>
|
||||
namespace bmh::launch {
|
||||
namespace {
|
||||
std::wstring wide(const std::string &s) { return path_from_utf8(s).wstring(); }
|
||||
std::string text(HWND window) {
|
||||
int n = GetWindowTextLengthW(window);
|
||||
std::wstring s(size_t(n) + 1, L'\0');
|
||||
GetWindowTextW(window, s.data(), n + 1);
|
||||
s.resize(size_t(n));
|
||||
return path_to_utf8(std::filesystem::path(s));
|
||||
}
|
||||
struct Form {
|
||||
HWND window = nullptr;
|
||||
bool done = false;
|
||||
int response = 0;
|
||||
bool prevent_close = false;
|
||||
std::function<void(int)> command;
|
||||
static LRESULT CALLBACK procedure(HWND h, UINT msg, WPARAM w, LPARAM l) {
|
||||
auto *form = reinterpret_cast<Form *>(GetWindowLongPtrW(h, GWLP_USERDATA));
|
||||
if (msg == WM_NCCREATE) {
|
||||
form = static_cast<Form *>(reinterpret_cast<CREATESTRUCTW *>(l)->lpCreateParams);
|
||||
SetWindowLongPtrW(h, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(form));
|
||||
form->window = h;
|
||||
}
|
||||
if (form) {
|
||||
if (msg == WM_COMMAND && form->command) {
|
||||
try {
|
||||
form->command(LOWORD(w));
|
||||
} catch (const std::exception &e) {
|
||||
MessageBoxW(h, wide(e.what()).c_str(), L"OpenBMH", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (msg == WM_NOTIFY && reinterpret_cast<NMHDR *>(l)->code == LVN_ITEMCHANGED) {
|
||||
const bool selected =
|
||||
ListView_GetNextItem(reinterpret_cast<NMHDR *>(l)->hwndFrom, -1, LVNI_SELECTED) >= 0;
|
||||
for (int id : {1, 3, 4})
|
||||
EnableWindow(GetDlgItem(h, id), selected);
|
||||
return 0;
|
||||
}
|
||||
if (msg == WM_CLOSE) {
|
||||
form->response = 0;
|
||||
form->done = true;
|
||||
if (!form->prevent_close)
|
||||
ShowWindow(h, SW_HIDE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return DefWindowProcW(h, msg, w, l);
|
||||
}
|
||||
Form(const wchar_t *title, int width, int height, HWND owner = nullptr) {
|
||||
static const bool registered = [] {
|
||||
WNDCLASSW c{};
|
||||
c.lpfnWndProc = procedure;
|
||||
c.hInstance = GetModuleHandleW(nullptr);
|
||||
c.lpszClassName = L"OpenBMHLauncher";
|
||||
c.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||
c.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1);
|
||||
return RegisterClassW(&c) != 0;
|
||||
}();
|
||||
if (!registered)
|
||||
throw std::runtime_error("Cannot register native launcher window");
|
||||
window =
|
||||
CreateWindowExW(WS_EX_DLGMODALFRAME, L"OpenBMHLauncher", title,
|
||||
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, width, height, owner, nullptr, GetModuleHandleW(nullptr), this);
|
||||
if (!window)
|
||||
throw std::runtime_error("Cannot create native launcher window");
|
||||
command = [this](int id) {
|
||||
// Edit controls also emit WM_COMMAND while the user types.
|
||||
if (id != IDOK && id != IDCANCEL)
|
||||
return;
|
||||
response = id;
|
||||
done = true;
|
||||
};
|
||||
}
|
||||
~Form() {
|
||||
if (window)
|
||||
DestroyWindow(window);
|
||||
}
|
||||
HWND control(const wchar_t *cls, const std::wstring &label, int x, int y, int w, int h, int id,
|
||||
DWORD style = 0) {
|
||||
auto window =
|
||||
CreateWindowExW(cls == std::wstring(L"EDIT") ? WS_EX_CLIENTEDGE : 0, cls, label.c_str(),
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | style, x, y, w, h, this->window,
|
||||
reinterpret_cast<HMENU>(INT_PTR(id)), GetModuleHandleW(nullptr), nullptr);
|
||||
SendMessageW(window, WM_SETFONT, reinterpret_cast<WPARAM>(GetStockObject(DEFAULT_GUI_FONT)), TRUE);
|
||||
return window;
|
||||
}
|
||||
int run() {
|
||||
done = false;
|
||||
response = 0;
|
||||
ShowWindow(window, SW_SHOW);
|
||||
SetForegroundWindow(window);
|
||||
MSG msg;
|
||||
while (!done && GetMessageW(&msg, nullptr, 0, 0) > 0)
|
||||
if (!IsDialogMessageW(window, &msg)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
};
|
||||
class WinLauncher final : public LauncherUI {
|
||||
Form main_{L"OpenBMH", 660, 370};
|
||||
HWND list_ = nullptr;
|
||||
std::unique_ptr<Form> progress_;
|
||||
HWND progress_label_ = nullptr;
|
||||
bool com_ = false;
|
||||
|
||||
public:
|
||||
WinLauncher() {
|
||||
const auto result = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
com_ = SUCCEEDED(result);
|
||||
if (FAILED(result) && result != RPC_E_CHANGED_MODE)
|
||||
throw std::runtime_error("Cannot initialize native folder dialog");
|
||||
INITCOMMONCONTROLSEX controls{sizeof(controls), ICC_LISTVIEW_CLASSES};
|
||||
InitCommonControlsEx(&controls);
|
||||
list_ = main_.control(WC_LISTVIEWW, L"", 16, 16, 480, 290, 100,
|
||||
LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER);
|
||||
ListView_SetExtendedListViewStyle(list_, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
LVCOLUMNW c{};
|
||||
c.mask = LVCF_TEXT | LVCF_WIDTH;
|
||||
c.cx = i ? 110 : 340;
|
||||
c.pszText = const_cast<wchar_t *>(i ? L"Art" : L"Name");
|
||||
ListView_InsertColumn(list_, i, &c);
|
||||
}
|
||||
const wchar_t *labels[] = {L"Start", L"Add", L"Delete", L"Rename", L"End"};
|
||||
for (int i = 0; i < 5; ++i)
|
||||
main_.control(L"BUTTON", labels[i], 514, 16 + i * 48, 110, 34, i + 1, BS_PUSHBUTTON);
|
||||
main_.command = [this](int id) {
|
||||
if (id < 1 || id > 5)
|
||||
return;
|
||||
const int selected = ListView_GetNextItem(list_, -1, LVNI_SELECTED);
|
||||
if (id != 2 && id != 5 && selected < 0)
|
||||
return;
|
||||
main_.response = id;
|
||||
main_.done = true;
|
||||
};
|
||||
}
|
||||
~WinLauncher() override {
|
||||
if (com_)
|
||||
CoUninitialize();
|
||||
}
|
||||
LauncherChoice next(const std::vector<ModEntry> &mods) override {
|
||||
const int old = ListView_GetNextItem(list_, -1, LVNI_SELECTED);
|
||||
ListView_DeleteAllItems(list_);
|
||||
for (size_t i = 0; i < mods.size(); ++i) {
|
||||
auto name = wide(mods[i].name + (mods[i].error.empty() ? "" : " [!]"));
|
||||
LVITEMW row{};
|
||||
row.mask = LVIF_TEXT;
|
||||
row.iItem = int(i);
|
||||
row.pszText = name.data();
|
||||
ListView_InsertItem(list_, &row);
|
||||
auto type = wide(mods[i].type);
|
||||
ListView_SetItemText(list_, int(i), 1, type.data());
|
||||
}
|
||||
if (old >= 0 && size_t(old) < mods.size())
|
||||
ListView_SetItemState(list_, old, LVIS_SELECTED, LVIS_SELECTED);
|
||||
const bool selected = ListView_GetNextItem(list_, -1, LVNI_SELECTED) >= 0;
|
||||
for (int id : {1, 3, 4})
|
||||
EnableWindow(GetDlgItem(main_.window, id), selected);
|
||||
const int response = main_.run();
|
||||
return {response == 1 ? LauncherAction::start
|
||||
: response == 2 ? LauncherAction::add
|
||||
: response == 3 ? LauncherAction::remove
|
||||
: response == 4 ? LauncherAction::rename
|
||||
: LauncherAction::end,
|
||||
ListView_GetNextItem(list_, -1, LVNI_SELECTED)};
|
||||
}
|
||||
std::optional<std::filesystem::path> choose_folder(const std::string &title,
|
||||
const std::filesystem::path &initial) override {
|
||||
IFileOpenDialog *dialog = nullptr;
|
||||
if (FAILED(
|
||||
CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&dialog))))
|
||||
throw std::runtime_error("Cannot create folder dialog");
|
||||
struct Release {
|
||||
IFileOpenDialog *p;
|
||||
~Release() { p->Release(); }
|
||||
} release{dialog};
|
||||
DWORD options = 0;
|
||||
dialog->GetOptions(&options);
|
||||
dialog->SetOptions(options | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM);
|
||||
dialog->SetTitle(wide(title).c_str());
|
||||
if (!initial.empty()) {
|
||||
IShellItem *folder = nullptr;
|
||||
if (SUCCEEDED(SHCreateItemFromParsingName(initial.c_str(), nullptr, IID_PPV_ARGS(&folder)))) {
|
||||
dialog->SetFolder(folder);
|
||||
folder->Release();
|
||||
}
|
||||
}
|
||||
const auto status = dialog->Show(main_.window);
|
||||
if (status == HRESULT_FROM_WIN32(ERROR_CANCELLED))
|
||||
return {};
|
||||
if (FAILED(status))
|
||||
throw std::runtime_error("Folder dialog failed");
|
||||
IShellItem *item = nullptr;
|
||||
if (FAILED(dialog->GetResult(&item)))
|
||||
throw std::runtime_error("No folder selected");
|
||||
PWSTR name = nullptr;
|
||||
const auto result = item->GetDisplayName(SIGDN_FILESYSPATH, &name);
|
||||
item->Release();
|
||||
if (FAILED(result))
|
||||
throw std::runtime_error("Invalid folder selection");
|
||||
std::filesystem::path path(name);
|
||||
CoTaskMemFree(name);
|
||||
return path;
|
||||
}
|
||||
std::optional<AddMod> configure_add(AddMod initial) override {
|
||||
Form form(L"Classic-Mod hinzufügen", 650, 295, main_.window);
|
||||
form.control(L"STATIC", L"Bezeichnung", 16, 20, 160, 22, 100);
|
||||
auto name = form.control(L"EDIT", wide(initial.name), 182, 16, 425, 26, 101, ES_AUTOHSCROLL);
|
||||
form.control(L"STATIC", L"Startjahr (nur Anzeige)", 16, 62, 164, 22, 102);
|
||||
auto year =
|
||||
form.control(L"EDIT", wide(std::to_string(initial.start_year)), 182, 58, 110, 26, 103, ES_NUMBER);
|
||||
auto migrate = form.control(L"BUTTON", L"Spielstände/Einstellungen übernehmen", 16, 100, 550, 26, 104,
|
||||
BS_AUTOCHECKBOX);
|
||||
SendMessageW(migrate, BM_SETCHECK, initial.migrate ? BST_CHECKED : BST_UNCHECKED, 0);
|
||||
form.control(L"STATIC", L"Spielstandsordner", 16, 146, 160, 22, 105);
|
||||
auto saves = form.control(L"EDIT", initial.saves.wstring(), 182, 140, 310, 26, 106, ES_AUTOHSCROLL);
|
||||
form.control(L"BUTTON", L"Auswählen …", 502, 140, 106, 26, 107);
|
||||
form.control(L"BUTTON", L"Importieren", 365, 204, 116, 32, 1);
|
||||
form.control(L"BUTTON", L"Abbrechen", 493, 204, 116, 32, 2);
|
||||
form.command = [&](int id) {
|
||||
if (id == 107) {
|
||||
if (auto path = choose_folder("Spielstandsordner wählen", path_from_utf8(text(saves))))
|
||||
SetWindowTextW(saves, path->c_str());
|
||||
} else if (id == 1 || id == 2) {
|
||||
form.response = id;
|
||||
form.done = true;
|
||||
}
|
||||
};
|
||||
EnableWindow(main_.window, FALSE);
|
||||
std::optional<AddMod> out;
|
||||
while (form.run() == 1)
|
||||
try {
|
||||
initial.name = text(name);
|
||||
ModLibrary::validate_name(initial.name);
|
||||
auto value = text(year);
|
||||
size_t end = 0;
|
||||
initial.start_year = std::stoi(value, &end);
|
||||
if (end != value.size() || initial.start_year < 1900 || initial.start_year > 9998)
|
||||
throw std::runtime_error("Startjahr muss zwischen 1900 und 9998 liegen");
|
||||
initial.saves = path_from_utf8(text(saves));
|
||||
initial.migrate = SendMessageW(migrate, BM_GETCHECK, 0, 0) == BST_CHECKED;
|
||||
out = initial;
|
||||
break;
|
||||
} catch (const std::exception &e) {
|
||||
message(e.what(), true);
|
||||
}
|
||||
EnableWindow(main_.window, TRUE);
|
||||
return out;
|
||||
}
|
||||
std::optional<std::string> rename(const std::string &old) override {
|
||||
Form form(L"Mod umbenennen", 480, 165, main_.window);
|
||||
auto input = form.control(L"EDIT", wide(old), 16, 16, 430, 26, 100, ES_AUTOHSCROLL);
|
||||
form.control(L"BUTTON", L"Umbenennen", 190, 65, 120, 32, 1);
|
||||
form.control(L"BUTTON", L"Abbrechen", 322, 65, 124, 32, 2);
|
||||
EnableWindow(main_.window, FALSE);
|
||||
const auto response = form.run();
|
||||
EnableWindow(main_.window, TRUE);
|
||||
return response == 1 ? std::optional<std::string>(text(input)) : std::nullopt;
|
||||
}
|
||||
bool confirm_delete(const std::string &name) override {
|
||||
return MessageBoxW(main_.window,
|
||||
wide("Mod „" + name +
|
||||
"“ löschen?\nSpielstände und persönliche Einstellungen bleiben erhalten.")
|
||||
.c_str(),
|
||||
L"OpenBMH", MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES;
|
||||
}
|
||||
void message(const std::string &value, bool error) override {
|
||||
MessageBoxW(main_.window, wide(value).c_str(), L"OpenBMH",
|
||||
MB_OK | (error ? MB_ICONERROR : MB_ICONINFORMATION));
|
||||
}
|
||||
void progress(const std::string &value, bool cancellable) override {
|
||||
if (!progress_) {
|
||||
EnableWindow(main_.window, FALSE);
|
||||
progress_ = std::make_unique<Form>(L"OpenBMH", 600, 150, main_.window);
|
||||
progress_->prevent_close = true;
|
||||
progress_label_ = progress_->control(L"STATIC", L"", 16, 18, 550, 40, 100);
|
||||
if (cancellable)
|
||||
progress_->control(L"BUTTON", L"Abbrechen", 440, 65, 115, 28, 1);
|
||||
ShowWindow(progress_->window, SW_SHOW);
|
||||
}
|
||||
SetWindowTextW(progress_label_, wide(value).c_str());
|
||||
}
|
||||
bool pump() override {
|
||||
MSG msg;
|
||||
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
return progress_ && progress_->done;
|
||||
}
|
||||
void finish_progress() override {
|
||||
if (progress_) {
|
||||
progress_.reset();
|
||||
EnableWindow(main_.window, TRUE);
|
||||
SetForegroundWindow(main_.window);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
std::unique_ptr<LauncherUI> make_launcher_ui() { return std::make_unique<WinLauncher>(); }
|
||||
} // namespace bmh::launch
|
||||
@@ -0,0 +1,41 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
# A shared visual layer for the launcher and future modern screens.
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build dependencies statically" FORCE)
|
||||
foreach(feature IN ITEMS ZLIB BZIP2 PNG HARFBUZZ BROTLI)
|
||||
set(FT_DISABLE_${feature} ON CACHE BOOL "Keep the bundled font engine minimal" FORCE)
|
||||
endforeach()
|
||||
set(SKIP_INSTALL_ALL ON)
|
||||
FetchContent_Declare(freetype
|
||||
GIT_REPOSITORY https://github.com/freetype/freetype.git
|
||||
GIT_TAG VER-2-13-3 GIT_SHALLOW TRUE GIT_SUBMODULES "")
|
||||
FetchContent_MakeAvailable(freetype)
|
||||
if(NOT TARGET Freetype::Freetype)
|
||||
add_library(Freetype::Freetype ALIAS freetype)
|
||||
endif()
|
||||
set(RMLUI_SAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(RMLUI_LUA_BINDINGS OFF CACHE BOOL "" FORCE)
|
||||
set(RMLUI_SVG_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(RMLUI_LOTTIE_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(rmlui
|
||||
GIT_REPOSITORY https://github.com/mikke89/RmlUi.git
|
||||
GIT_TAG 6.3 GIT_SHALLOW TRUE)
|
||||
FetchContent_MakeAvailable(rmlui)
|
||||
add_library(bmh_rmlui STATIC
|
||||
${rmlui_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp
|
||||
${rmlui_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp)
|
||||
target_include_directories(bmh_rmlui PUBLIC ${rmlui_SOURCE_DIR}/Backends)
|
||||
target_compile_definitions(bmh_rmlui PUBLIC RMLUI_SDL_VERSION_MAJOR=2 RMLUI_NUM_MSAA_SAMPLES=0)
|
||||
target_link_libraries(bmh_rmlui PUBLIC RmlUi::Core ${BMH_SDL_TARGET} PRIVATE ${CMAKE_DL_LIBS})
|
||||
|
||||
# The background is project artwork, and the unmodified fonts come from the
|
||||
# pinned dependency. All assets are located relative to the executable at runtime.
|
||||
set(launcher_assets "${CMAKE_BINARY_DIR}/assets/launcher")
|
||||
file(MAKE_DIRECTORY "${launcher_assets}")
|
||||
foreach(asset IN ITEMS launcher.rml theme.rcss stadium.tga)
|
||||
configure_file("${CMAKE_SOURCE_DIR}/assets/launcher/${asset}" "${launcher_assets}/${asset}" COPYONLY)
|
||||
endforeach()
|
||||
foreach(weight IN ITEMS Regular Bold)
|
||||
configure_file("${rmlui_SOURCE_DIR}/Samples/assets/LatoLatin-${weight}.ttf"
|
||||
"${launcher_assets}/LatoLatin-${weight}.ttf" COPYONLY)
|
||||
endforeach()
|
||||
install(DIRECTORY "${launcher_assets}/" DESTINATION assets/launcher COMPONENT Runtime)
|
||||
@@ -0,0 +1,88 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include <RmlUi/Core.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
struct System : Rml::SystemInterface {
|
||||
std::string errors;
|
||||
bool LogMessage(Rml::Log::Type type, const Rml::String &text) override {
|
||||
if (type <= Rml::Log::LT_WARNING)
|
||||
errors += text + "\n";
|
||||
return true;
|
||||
}
|
||||
};
|
||||
struct Renderer : Rml::RenderInterface {
|
||||
size_t rendered_vertices = 0;
|
||||
Rml::CompiledGeometryHandle CompileGeometry(Rml::Span<const Rml::Vertex> vertices,
|
||||
Rml::Span<const int>) override {
|
||||
return Rml::CompiledGeometryHandle(vertices.size());
|
||||
}
|
||||
void ReleaseGeometry(Rml::CompiledGeometryHandle) override {}
|
||||
void RenderGeometry(Rml::CompiledGeometryHandle geometry, Rml::Vector2f, Rml::TextureHandle) override {
|
||||
rendered_vertices += size_t(geometry);
|
||||
}
|
||||
void EnableScissorRegion(bool) override {}
|
||||
void SetScissorRegion(Rml::Rectanglei) override {}
|
||||
Rml::TextureHandle LoadTexture(Rml::Vector2i &dimensions, const Rml::String &name) override {
|
||||
std::ifstream input(name, std::ios::binary);
|
||||
unsigned char header[18]{};
|
||||
input.read(reinterpret_cast<char *>(header), sizeof(header));
|
||||
if (!input || header[2] != 2 || header[16] != 24)
|
||||
throw std::runtime_error("Stadium asset unavailable");
|
||||
dimensions = {header[12] + 256 * header[13], header[14] + 256 * header[15]};
|
||||
return 1;
|
||||
}
|
||||
Rml::TextureHandle GenerateTexture(Rml::Span<const Rml::byte>, Rml::Vector2i) override { return 2; }
|
||||
void ReleaseTexture(Rml::TextureHandle) override {}
|
||||
};
|
||||
void require(bool value, const std::string &error) {
|
||||
if (!value)
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
} // namespace
|
||||
int main(int argc, char **argv) try {
|
||||
require(argc == 2, "launcher asset directory required");
|
||||
System system;
|
||||
Renderer renderer;
|
||||
Rml::SetSystemInterface(&system);
|
||||
Rml::SetRenderInterface(&renderer);
|
||||
require(Rml::Initialise(), "RmlUI initialization");
|
||||
struct Shutdown {
|
||||
~Shutdown() { Rml::Shutdown(); }
|
||||
} shutdown;
|
||||
const std::filesystem::path assets(argv[1]);
|
||||
for (const auto *weight : {"Regular", "Bold"})
|
||||
require(Rml::LoadFontFace((assets / (std::string("LatoLatin-") + weight + ".ttf")).string()),
|
||||
"font load");
|
||||
auto *context = Rml::CreateContext("test", {1100, 688});
|
||||
auto *document = context->LoadDocument((assets / "launcher.rml").string());
|
||||
require(document != nullptr, "launcher document load");
|
||||
document->Show();
|
||||
for (const auto size : {Rml::Vector2i(1100, 688), Rml::Vector2i(800, 540), Rml::Vector2i(2200, 1376)}) {
|
||||
context->SetDimensions(size);
|
||||
context->SetDensityIndependentPixelRatio(float(size.x) / 1100);
|
||||
context->Update();
|
||||
context->Render();
|
||||
for (const auto *id : {"start", "add", "delete", "rename", "end"}) {
|
||||
auto *button = document->GetElementById(id);
|
||||
require(button != nullptr, "missing launcher action");
|
||||
const auto origin = button->GetAbsoluteOffset(Rml::BoxArea::Border);
|
||||
const auto dimensions = button->GetBox().GetSize(Rml::BoxArea::Border);
|
||||
require(origin.x >= 0 && origin.y >= 0 && origin.x + dimensions.x <= size.x + 1 &&
|
||||
origin.y + dimensions.y <= size.y + 1 && dimensions.y >= 30,
|
||||
"action outside viewport or too small");
|
||||
require(button->GetNumChildren() >= 2, "action lost its visible text label");
|
||||
}
|
||||
require(!document->GetElementById("overlay")->IsVisible(), "modal unexpectedly visible");
|
||||
}
|
||||
require(renderer.rendered_vertices > 100, "launcher did not render");
|
||||
require(system.errors.empty(), system.errors);
|
||||
std::cout << "Launcher RML/RCSS, fonts, background, visible labels and responsive layout passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception &error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
@@ -28,6 +28,10 @@ class PackageAllowlistTests(unittest.TestCase):
|
||||
notes = root / 'docs/release/0.1/RELEASE_NOTES.md'
|
||||
notes.parent.mkdir(parents=True)
|
||||
notes.write_text('synthetic release notes')
|
||||
for name in ['launcher.rml', 'theme.rcss', 'stadium.tga', 'LatoLatin-Regular.ttf', 'LatoLatin-Bold.ttf']:
|
||||
asset = root / 'assets' / 'launcher' / name
|
||||
asset.parent.mkdir(parents=True, exist_ok=True)
|
||||
asset.write_text('synthetic packaged UI asset')
|
||||
licenses = Path(__file__).resolve().parents[1] / 'docs' / 'licenses'
|
||||
for source in licenses.iterdir():
|
||||
if source.is_file():
|
||||
@@ -35,6 +39,11 @@ class PackageAllowlistTests(unittest.TestCase):
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text('synthetic license placeholder')
|
||||
package.validate(root, False)
|
||||
missing = root / 'assets/launcher/LatoLatin-Bold.ttf'
|
||||
missing.unlink()
|
||||
with self.assertRaises(RuntimeError):
|
||||
package.validate(root, False)
|
||||
missing.write_text('synthetic font')
|
||||
schema = root / 'docs/formats/obw/schema/1.0/manifest.json'
|
||||
schema.parent.mkdir(parents=True)
|
||||
schema.write_text('{"type":"object"}')
|
||||
@@ -55,6 +64,15 @@ class PackageAllowlistTests(unittest.TestCase):
|
||||
|
||||
|
||||
class SourceInventoryTests(unittest.TestCase):
|
||||
def test_only_pinned_unused_freetype_logging_submodule_is_omitted(self):
|
||||
record = b'160000 72dfcc858c040c54a6a0b88fcb7e70ee186d3167 0\tsubprojects/dlg\0'
|
||||
self.assertEqual(source_package.unbuilt_submodules('freetype', record),
|
||||
{'subprojects/dlg': '72dfcc858c040c54a6a0b88fcb7e70ee186d3167'})
|
||||
for component, entry in [('SDL2', record), ('freetype', record.replace(b'subprojects/dlg', b'other')),
|
||||
('freetype', record.replace(b'72df', b'0000'))]:
|
||||
with self.assertRaises(RuntimeError):
|
||||
source_package.unbuilt_submodules(component, entry)
|
||||
|
||||
def setUp(self):
|
||||
self.temporary = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temporary.cleanup)
|
||||
|
||||
@@ -14,7 +14,11 @@ def validate(directory, windows):
|
||||
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
|
||||
licenses = {'README.md', 'LGPL-2.1.txt', 'Nuked-OPL3-notices.txt', 'LZMA-SDK.txt', 'SDL2-HIDAPI-BSD.txt',
|
||||
'SDL2-HIDAPI-options.txt', 'SDL2-HIDAPI-original.txt', 'SDL2-yuv2rgb.txt',
|
||||
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt'}
|
||||
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt',
|
||||
'RmlUi.txt', 'RmlUi-containers.txt', 'RmlUi-fonts.txt', 'RmlUi-Khronos.txt',
|
||||
'FreeType.txt', 'FreeType-FTL.txt', 'FreeType-BDF.txt', 'FreeType-PCF.txt', 'FreeType-zlib.txt'}
|
||||
launcher_assets = {'assets/launcher/' + name for name in
|
||||
('launcher.rml', 'theme.rcss', 'stadium.tga', 'LatoLatin-Regular.ttf', 'LatoLatin-Bold.ttf')}
|
||||
present = set()
|
||||
for file in directory.rglob('*'):
|
||||
if not file.is_file():
|
||||
@@ -22,6 +26,7 @@ def validate(directory, windows):
|
||||
relative = file.relative_to(directory)
|
||||
present.add(relative.as_posix())
|
||||
allowed = (len(relative.parts) == 1 and file.name in products | documents)
|
||||
allowed |= relative.as_posix() in launcher_assets
|
||||
allowed |= len(relative.parts) == 3 and relative.parts[:2] == ('docs', 'licenses') and file.name in licenses
|
||||
allowed |= (len(relative.parts) >= 2 and relative.parts[0] == 'docs' and
|
||||
'licenses' not in relative.parts and file.suffix in {'.md', '.txt', '.csv'} and
|
||||
@@ -35,7 +40,7 @@ def validate(directory, windows):
|
||||
r'concrt\d+|ucrtbase|api-ms-win-(?:crt|core)-[a-z0-9-]+)\.dll', file.name, re.I)))
|
||||
if not allowed:
|
||||
raise RuntimeError('Unexpected package entry: ' + relative.as_posix())
|
||||
required = products | documents | {'docs/licenses/' + name for name in licenses}
|
||||
required = products | documents | launcher_assets | {'docs/licenses/' + name for name in licenses}
|
||||
required.add('docs/release/0.1/RELEASE_NOTES.md')
|
||||
if required - present:
|
||||
raise RuntimeError('Missing package entries: ' + ', '.join(sorted(required - present)))
|
||||
|
||||
@@ -16,6 +16,8 @@ COMPONENTS = {
|
||||
'miniz': ('3.0.2', 'https://github.com/richgel999/miniz', ['miniz.c', 'miniz.h', 'LICENSE']),
|
||||
'lzma_sdk': ('24.09', 'https://github.com/ip7z/7zip', ['C/7zDec.c', 'C/7z.h', 'DOC/License.txt']),
|
||||
'nfd': ('v1.2.1', 'https://github.com/btzy/nativefiledialog-extended', ['CMakeLists.txt', 'src/nfd_cocoa.m', 'LICENSE']),
|
||||
'rmlui': ('6.3', 'https://github.com/mikke89/RmlUi', ['CMakeLists.txt', 'Include/RmlUi/Core.h', 'LICENSE.txt']),
|
||||
'freetype': ('VER-2-13-3', 'https://github.com/freetype/freetype', ['CMakeLists.txt', 'include/ft2build.h', 'LICENSE.TXT']),
|
||||
}
|
||||
# Verified against the archive SHA256 pinned in CMakeLists.txt. These are free
|
||||
# dependency source files, not game data. Refuse modified archive-cache inputs.
|
||||
@@ -32,6 +34,26 @@ def git(directory, *arguments):
|
||||
return subprocess.check_output(['git', '-C', str(directory), *arguments])
|
||||
|
||||
|
||||
def unbuilt_submodules(component, staged):
|
||||
"""Only FreeType's unused make/autotools logging dependency is omitted.
|
||||
|
||||
The pinned CMake font-engine target does not compile dlg. Every other
|
||||
submodule, or a changed revision, still needs explicit source packaging.
|
||||
"""
|
||||
excluded = {}
|
||||
for record in staged.split(b'\0'):
|
||||
if not record.startswith(b'160000 '):
|
||||
continue
|
||||
metadata, path = record.split(b'\t', 1)
|
||||
commit = metadata.split()[1].decode()
|
||||
name = path.decode()
|
||||
if (component != 'freetype' or name != 'subprojects/dlg' or
|
||||
commit != '72dfcc858c040c54a6a0b88fcb7e70ee186d3167'):
|
||||
raise RuntimeError('Dependency submodules require explicit packaging: ' + component)
|
||||
excluded[name] = commit
|
||||
return excluded
|
||||
|
||||
|
||||
def copy_files(source, destination, files, required=False, materialized_links=None):
|
||||
"""Copy only the explicit source inventory, materializing internal links.
|
||||
|
||||
@@ -164,15 +186,16 @@ def main():
|
||||
if not dependencies.get(name) or not all((directory / marker).is_file() for marker in markers):
|
||||
raise RuntimeError('Actual dependency source unavailable: ' + name)
|
||||
commit = None
|
||||
excluded = {}
|
||||
if (directory / '.git').exists():
|
||||
commit = git(directory, 'rev-parse', 'HEAD').decode().strip()
|
||||
tag = git(directory, 'rev-parse', reference + '^{commit}').decode().strip()
|
||||
if commit != tag or git(directory, 'status', '--porcelain', '--untracked-files=no').strip():
|
||||
raise RuntimeError('Dependency differs from its pinned source: ' + name)
|
||||
if git(directory, 'ls-files', '--stage').find(b'160000 ') != -1:
|
||||
raise RuntimeError('Dependency submodules require explicit packaging: ' + name)
|
||||
excluded = unbuilt_submodules(name, git(directory, 'ls-files', '--stage', '-z'))
|
||||
if commit:
|
||||
files = [Path(p.decode('utf-8')) for p in git(directory, 'ls-files', '-z').split(b'\0') if p]
|
||||
files = [p for p in files if p.as_posix() not in excluded]
|
||||
if name == 'lzma_sdk':
|
||||
files = [p for p in files if p.parts[0] == 'C' or p == Path('DOC/License.txt')]
|
||||
else:
|
||||
@@ -188,6 +211,7 @@ def main():
|
||||
materialized_links=dependency_links)
|
||||
manifest['dependencies'][name] = {'upstream': url, 'reference': reference,
|
||||
'commit': commit, 'files': hashes,
|
||||
'unbuilt_submodules': excluded,
|
||||
'materialized_links': dependency_links}
|
||||
initial_cache.append('set(FETCHCONTENT_SOURCE_DIR_' + name.upper() +
|
||||
' "${CMAKE_CURRENT_LIST_DIR}/dependencies/' + name + '" CACHE PATH "" FORCE)')
|
||||
|
||||
@@ -7,6 +7,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import dataclasses
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path, PurePosixPath
|
||||
import re
|
||||
@@ -40,6 +41,11 @@ PRIVATE_DOCUMENTS = {
|
||||
}
|
||||
SOURCE_SUFFIXES = {".cpp", ".hpp", ".h", ".c", ".inc"}
|
||||
SKIP_DIRECTORIES = {".git", "__pycache__", ".cache", "_deps", "node_modules"}
|
||||
# Exact independently generated launcher artwork, not imported game material.
|
||||
# Keep prior reviewed hashes if an asset is intentionally revised in history.
|
||||
PROJECT_ARTWORK = {
|
||||
"assets/launcher/stadium.tga": {"08f82783a357d5b0722f3737de54844150bc14d98036845f1aaee3211608e1c8"},
|
||||
}
|
||||
|
||||
LEGACY_SYMBOLS = re.compile(
|
||||
r"(?<![A-Za-z0-9])(?:" + "FUN" + r"_?[0-9a-f]{4,8}|" + "DAT" +
|
||||
@@ -156,7 +162,7 @@ def path_findings(name: str) -> list[Finding]:
|
||||
result = []
|
||||
if path.is_absolute() or ".." in parts:
|
||||
result.append(Finding(name, 0, "unsafe-path"))
|
||||
if path.suffix.lower() in ASSET_SUFFIXES:
|
||||
if path.suffix.lower() in ASSET_SUFFIXES and name not in PROJECT_ARTWORK:
|
||||
result.append(Finding(name, 0, "binary-or-game-asset"))
|
||||
if path.name in PRIVATE_DOCUMENTS or any(parts[:len(p)] == p for p in PRIVATE_PREFIXES):
|
||||
result.append(Finding(name, 0, "private-material-path"))
|
||||
@@ -167,6 +173,10 @@ def path_findings(name: str) -> list[Finding]:
|
||||
|
||||
def scan_blob(name: str, blob: bytes) -> list[Finding]:
|
||||
result = path_findings(name)
|
||||
if name in PROJECT_ARTWORK:
|
||||
if hashlib.sha256(blob).hexdigest() not in PROJECT_ARTWORK[name]:
|
||||
result.append(Finding(name, 0, "unreviewed-project-artwork"))
|
||||
return result
|
||||
if len(blob) > 2_000_000:
|
||||
result.append(Finding(name, 0, "oversized-source-file"))
|
||||
if b"\0" in blob:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"""Synthetic checks for the source-distribution guard; no game input is used."""
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -17,6 +18,14 @@ import check_public_tree as guard
|
||||
|
||||
|
||||
class BlobChecks(unittest.TestCase):
|
||||
def test_only_exact_reviewed_project_artwork_is_accepted(self):
|
||||
name = "assets/launcher/synthetic.tga"
|
||||
payload = b"synthetic\0pixels"
|
||||
with mock.patch.dict(guard.PROJECT_ARTWORK, {name: {hashlib.sha256(payload).hexdigest()}}):
|
||||
self.assertEqual(guard.scan_blob(name, payload), [])
|
||||
self.assertIn("unreviewed-project-artwork", {f.rule for f in guard.scan_blob(name, payload+b"changed")})
|
||||
self.assertIn("binary-content", {f.rule for f in guard.scan_blob(name, payload)})
|
||||
|
||||
def rules(self, name, text):
|
||||
return {finding.rule for finding in guard.scan_blob(name, text.encode())}
|
||||
|
||||
|
||||
Reference in new issue
Block a user