Embed supplied high-resolution Classic start artwork (by Codex)
This commit is contained in:
1 parent
0bfa705ec5
commit
9c82cb16b5
20 files changed
+8274
-36
No files matched your search
@@ -449,12 +449,29 @@ target_link_libraries(desk_check PRIVATE bmhcore)
|
|||||||
add_executable(init_check tests/init_check.cpp)
|
add_executable(init_check tests/init_check.cpp)
|
||||||
target_link_libraries(init_check PRIVATE bmhcore)
|
target_link_libraries(init_check PRIVATE bmhcore)
|
||||||
|
|
||||||
|
# The approved compressed title is embedded: no install-time sidecar dependency.
|
||||||
|
set(BMH_START_SCREEN_DATA "${CMAKE_BINARY_DIR}/generated/start_screen_data.cpp")
|
||||||
|
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/generated")
|
||||||
|
add_custom_command(OUTPUT "${BMH_START_SCREEN_DATA}"
|
||||||
|
COMMAND "${CMAKE_COMMAND}" "-DINPUT=${CMAKE_SOURCE_DIR}/assets/start-screen.jpg"
|
||||||
|
"-DOUTPUT=${BMH_START_SCREEN_DATA}" -P "${CMAKE_SOURCE_DIR}/cmake/EmbedStartScreen.cmake"
|
||||||
|
DEPENDS assets/start-screen.jpg cmake/EmbedStartScreen.cmake
|
||||||
|
VERBATIM)
|
||||||
|
add_library(openbmh_start_screen STATIC src/app/start_screen.cpp "${BMH_START_SCREEN_DATA}")
|
||||||
|
target_include_directories(openbmh_start_screen PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||||
|
target_link_libraries(openbmh_start_screen PUBLIC ${BMH_SDL_TARGET})
|
||||||
|
add_executable(start_screen_tests tests/start_screen_tests.cpp)
|
||||||
|
target_include_directories(start_screen_tests PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||||
|
target_link_libraries(start_screen_tests PRIVATE openbmh_start_screen)
|
||||||
|
add_test(NAME start_screen_tests COMMAND start_screen_tests)
|
||||||
|
|
||||||
# The playable program: the shared UI library connected to the engine by src/app.
|
# The playable program: the shared UI library connected to the engine by src/app.
|
||||||
add_executable(openbmh_play
|
add_executable(openbmh_play
|
||||||
src/app/main.cpp
|
src/app/main.cpp
|
||||||
${BMH_APP_CONTROLLER_SOURCE}
|
${BMH_APP_CONTROLLER_SOURCE}
|
||||||
${BMH_APP_SESSION_SDL_SOURCE})
|
${BMH_APP_SESSION_SDL_SOURCE})
|
||||||
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
|
target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio ${BMH_SDL_TARGET})
|
||||||
|
target_link_libraries(openbmh_play PRIVATE openbmh_start_screen)
|
||||||
# a game without a console window on double-click (SDL2main provides WinMain); started from a
|
# 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)
|
# 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)
|
set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH)
|
||||||
|
|||||||
@@ -111,3 +111,5 @@ OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only
|
|||||||
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
Every published binary release identifies its matching source tag and provides a corresponding source archive. Binary releases must accompany or offer the corresponding source and build/relinking materials required by the applicable licenses. The tag identifies application source; it does not replace required materials for linked third-party components.
|
||||||
|
|
||||||
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
Bundled components retain their own licenses, including Nuked OPL3 under LGPL-2.1-or-later. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md).
|
||||||
|
|
||||||
|
The supplied project start artwork is embedded at native resolution; see [start-screen artwork](docs/START_SCREEN.md). It replaces the original title image while the game continues to use your own original data and assets.
|
||||||
@@ -4,6 +4,7 @@ OpenBMH's own code and documentation use GPL-3.0-only. This does not replace the
|
|||||||
|
|
||||||
| Component | Version used by the build | License | Included notice |
|
| Component | Version used by the build | License | Included notice |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
|
| [stb_image](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h) | 2.30, vendored header; JPEG decoder only | MIT or public-domain alternative | [stb_image.txt](docs/licenses/stb_image.txt) |
|
||||||
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
|
| [SDL2](https://github.com/libsdl-org/SDL/tree/release-2.32.10) | 2.32.10, or an explicitly selected system SDL2 | zlib license | [SDL2.txt](docs/licenses/SDL2.txt) |
|
||||||
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
|
| SDL2 HIDAPI code | Included with SDL2 | BSD-3-Clause option; upstream also offers GPL-3.0 and its original license | [license options](docs/licenses/SDL2-HIDAPI-options.txt), [BSD text](docs/licenses/SDL2-HIDAPI-BSD.txt), [original text](docs/licenses/SDL2-HIDAPI-original.txt) |
|
||||||
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
|
| SDL2 yuv2rgb code | Included with SDL2 | BSD-3-Clause | [SDL2-yuv2rgb.txt](docs/licenses/SDL2-yuv2rgb.txt) |
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# OpenBMH Classic start artwork
|
||||||
|
|
||||||
|
The project maintainer supplied this new start-screen artwork for use and
|
||||||
|
repository distribution with this application. It is not extracted game content.
|
||||||
|
The repository license applies to project artwork; original game assets remain
|
||||||
|
external. The unmodified upstream decoder has its separate documented license.
|
||||||
|
|
||||||
|
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||||
|
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||||
|
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||||
|
The application embeds it at build time and decodes it once at startup, so
|
||||||
|
installed applications need no image sidecar or original title-screen VGA.
|
||||||
|
|
||||||
|
The SDL renderer uses the actual image dimensions while showing the title,
|
||||||
|
including high-DPI output and aspect-preserving side bars, then restores the
|
||||||
|
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||||
|
there is no loading-ball animation. Changing the artwork also requires an
|
||||||
|
explicit review/update of its SHA256 in the public-source guard.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 574 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
file(READ "${INPUT}" artwork HEX)
|
||||||
|
string(REGEX REPLACE "(..)" "0x\\1," artwork "${artwork}")
|
||||||
|
file(WRITE "${OUTPUT}" "// Generated from the repository-owned compressed start screen.\n#include \"app/start_screen_data.hpp\"\nnamespace bmh::app {\nconst unsigned char start_screen_jpeg[] = {${artwork}};\nconst std::size_t start_screen_jpeg_size=sizeof(start_screen_jpeg);\n}\n")
|
||||||
+1
-1
@@ -6,7 +6,7 @@ See [Compatibility decisions](COMPATIBILITY.md) for the overall policy. These en
|
|||||||
describe deliberate changes; they are not a list of every known compatibility limit.
|
describe deliberate changes; they are not a list of every known compatibility limit.
|
||||||
|
|
||||||
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
- [src/app/career_session.cpp](../src/app/career_session.cpp): supports designated set-piece record initialization and validation.
|
||||||
- [src/app/main.cpp](../src/app/main.cpp): show only the static title until a complete left or right click, without the DOS loading animation.
|
- [src/app/main.cpp](../src/app/main.cpp): display the repository-owned title at its native resolution until a complete left/right click, without loading balls.
|
||||||
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
- [src/app/quit_confirmation.hpp](../src/app/quit_confirmation.hpp): confirms application exit with a localized native dialog, with cancellation selected by default.
|
||||||
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
- [src/game/career.cpp](../src/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
|
||||||
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
- [src/game/career.hpp](../src/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# OpenBMH Classic start artwork
|
||||||
|
|
||||||
|
The project maintainer supplied this new start-screen artwork for use and
|
||||||
|
repository distribution with this application. It is not extracted game content.
|
||||||
|
The repository license applies to project artwork; original game assets remain
|
||||||
|
external. The unmodified upstream decoder has its separate documented license.
|
||||||
|
|
||||||
|
`start-screen.jpg` retains the supplied image's native **1448 × 1086** pixels.
|
||||||
|
It is an optimized progressive JPEG at quality 92 with 4:4:4 chroma sampling,
|
||||||
|
without EXIF or other input metadata. It occupies 587,410 bytes.
|
||||||
|
The application embeds it at build time and decodes it once at startup, so
|
||||||
|
installed applications need no image sidecar or original title-screen VGA.
|
||||||
|
|
||||||
|
The SDL renderer uses the actual image dimensions while showing the title,
|
||||||
|
including high-DPI output and aspect-preserving side bars, then restores the
|
||||||
|
320 × 240 game/input canvas. A complete left or right mouse click continues;
|
||||||
|
there is no loading-ball animation. Changing the artwork also requires an
|
||||||
|
explicit review/update of its SHA256 in the public-source guard.
|
||||||
@@ -12,3 +12,5 @@ These files preserve upstream license and attribution wording. They are not a gr
|
|||||||
- [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.
|
- [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.
|
||||||
|
|
||||||
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
|
[THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) identifies the upstream versions and distribution requirements. Include this directory, that notice file and the root LICENSE with release packages. Preserve upstream attribution within these verbatim texts.
|
||||||
|
|
||||||
|
- [stb_image](stb_image.txt): complete upstream dual-license text from the vendored 2.30 header. JPEG-only decoding is used for the supplied project start screen.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
This software is available under 2 licenses -- choose whichever you prefer.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
ALTERNATIVE A - MIT License
|
||||||
|
Copyright (c) 2017 Sean Barrett
|
||||||
|
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.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
|
commercial or non-commercial, and by any means.
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
|
software dedicate any and all copyright interest in the software to the public
|
||||||
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
|
this software under copyright law.
|
||||||
|
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 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.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
+33
-34
@@ -1,6 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
#include "formats/badge_policy.hpp"
|
#include "formats/badge_policy.hpp"
|
||||||
#include "formats/executable_layout.hpp"
|
#include "formats/executable_layout.hpp"
|
||||||
|
#include "app/start_screen.hpp"
|
||||||
#include "ui/live_timing.hpp"
|
#include "ui/live_timing.hpp"
|
||||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||||
// career initialised by the engine (app/career_session.hpp) and its desk.
|
// career initialised by the engine (app/career_session.hpp) and its desk.
|
||||||
@@ -208,7 +209,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
|
||||||
const std::string window_title = std::string("OpenBMH ") + bmh::kOpenBmhVersion +
|
const std::string window_title = std::string("OpenBMH ") + bmh::kOpenBmhVersion +
|
||||||
(english_game ? " - Football Limited (experimental)" : "");
|
(english_game ? " - Football Limited (experimental)" : "");
|
||||||
SDL_Window* window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 720, SDL_WINDOW_RESIZABLE);
|
SDL_Window* window = SDL_CreateWindow(window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
if (!window) throw FormatError(SDL_GetError());
|
if (!window) throw FormatError(SDL_GetError());
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||||
if (!renderer) renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
|
if (!renderer) renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
|
||||||
@@ -3619,42 +3620,40 @@ int main(int argc, char** argv) {
|
|||||||
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
|
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// OpenBMH deviates from the original: show only the static title until
|
// OpenBMH deviates from the original: display the repository-owned title
|
||||||
// a complete left or right click, without the DOS loading animation.
|
// at its native resolution until a complete left/right click, without loading balls.
|
||||||
const auto title_path = ui::asset_path(data / "KB", "137.VGA");
|
{
|
||||||
const auto title_palette = load_optional_embedded_palette(title_path);
|
app::StartScreen title_screen(renderer);
|
||||||
const auto title_image = load_vga(title_path);
|
title_screen.present();
|
||||||
present_season(title_image, window_title.c_str(),
|
bool opening_confirmed = false;
|
||||||
title_palette ? &*title_palette : nullptr);
|
std::optional<Uint8> opening_press;
|
||||||
bool opening_confirmed = false;
|
while (running && !opening_confirmed) {
|
||||||
std::optional<Uint8> opening_press;
|
SDL_Event opening_event;
|
||||||
while (running && !opening_confirmed) {
|
while (quit_confirmation.poll(&opening_event)) {
|
||||||
SDL_Event opening_event;
|
if (opening_event.type == SDL_QUIT) running = false;
|
||||||
while (quit_confirmation.poll(&opening_event)) {
|
if (opening_event.type == SDL_KEYDOWN && opening_event.key.keysym.sym == SDLK_ESCAPE &&
|
||||||
if (opening_event.type == SDL_QUIT) running = false;
|
quit_confirmation.confirm()) running = false;
|
||||||
if (opening_event.type == SDL_KEYDOWN && opening_event.key.keysym.sym == SDLK_ESCAPE &&
|
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||||
quit_confirmation.confirm()) running = false;
|
(opening_event.window.event == SDL_WINDOWEVENT_EXPOSED ||
|
||||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
opening_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
|
||||||
(opening_event.window.event == SDL_WINDOWEVENT_EXPOSED ||
|
title_screen.present();
|
||||||
opening_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED))
|
if (opening_event.type == SDL_WINDOWEVENT &&
|
||||||
present_season(title_image, window_title.c_str(),
|
opening_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
title_palette ? &*title_palette : nullptr);
|
opening_press.reset();
|
||||||
if (opening_event.type == SDL_WINDOWEVENT &&
|
if (opening_event.type == SDL_MOUSEBUTTONDOWN &&
|
||||||
opening_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
(opening_event.button.button == SDL_BUTTON_LEFT ||
|
||||||
opening_press.reset();
|
opening_event.button.button == SDL_BUTTON_RIGHT))
|
||||||
if (opening_event.type == SDL_MOUSEBUTTONDOWN &&
|
opening_press = opening_event.button.button;
|
||||||
(opening_event.button.button == SDL_BUTTON_LEFT ||
|
if (opening_event.type == SDL_MOUSEBUTTONUP && opening_press &&
|
||||||
opening_event.button.button == SDL_BUTTON_RIGHT))
|
opening_event.button.button == *opening_press)
|
||||||
opening_press = opening_event.button.button;
|
opening_confirmed = true;
|
||||||
if (opening_event.type == SDL_MOUSEBUTTONUP && opening_press &&
|
}
|
||||||
opening_event.button.button == *opening_press)
|
SDL_Delay(10);
|
||||||
opening_confirmed = true;
|
|
||||||
}
|
}
|
||||||
SDL_Delay(10);
|
} // Restore the indexed game canvas and its logical input mapping.
|
||||||
}
|
|
||||||
// Opening input must not also change an option on the first setup frame.
|
// Opening input must not also change an option on the first setup frame.
|
||||||
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
|
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
|
||||||
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
|
SDL_FlushEvents(SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
|
||||||
season_backdrop.reset();
|
season_backdrop.reset();
|
||||||
dirty = true;
|
dirty = true;
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "app/start_screen.hpp"
|
||||||
|
#include "app/start_screen_data.hpp"
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#define STBI_ONLY_JPEG
|
||||||
|
#define STBI_NO_STDIO
|
||||||
|
#define STBI_NO_HDR
|
||||||
|
#define STBI_NO_LINEAR
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include "app/third_party/stb_image.h"
|
||||||
|
namespace bmh::app {
|
||||||
|
StartScreen::StartScreen(SDL_Renderer* renderer):renderer_(renderer) {
|
||||||
|
if(!renderer_)throw std::runtime_error("Start screen: missing renderer");
|
||||||
|
SDL_RenderGetLogicalSize(renderer_,&previous_width_,&previous_height_);
|
||||||
|
int channels=0;
|
||||||
|
const std::unique_ptr<unsigned char,decltype(&stbi_image_free)> pixels(
|
||||||
|
stbi_load_from_memory(start_screen_jpeg,int(start_screen_jpeg_size),&width_,&height_,&channels,3),stbi_image_free);
|
||||||
|
if(!pixels)throw std::runtime_error("Start screen: embedded artwork could not be decoded");
|
||||||
|
texture_=SDL_CreateTexture(renderer_,SDL_PIXELFORMAT_RGB24,SDL_TEXTUREACCESS_STATIC,width_,height_);
|
||||||
|
if(!texture_)throw std::runtime_error(SDL_GetError());
|
||||||
|
if(SDL_UpdateTexture(texture_,nullptr,pixels.get(),width_*3)!=0||SDL_SetTextureScaleMode(texture_,SDL_ScaleModeLinear)!=0) {
|
||||||
|
const std::string error=SDL_GetError();SDL_DestroyTexture(texture_);texture_=nullptr;throw std::runtime_error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StartScreen::~StartScreen() {
|
||||||
|
SDL_DestroyTexture(texture_);
|
||||||
|
SDL_RenderSetLogicalSize(renderer_,previous_width_,previous_height_);
|
||||||
|
}
|
||||||
|
void StartScreen::present() {
|
||||||
|
if(SDL_RenderSetLogicalSize(renderer_,width_,height_)!=0)throw std::runtime_error(SDL_GetError());
|
||||||
|
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer_,&r,&g,&b,&a);
|
||||||
|
SDL_SetRenderDrawColor(renderer_,0,0,0,255);
|
||||||
|
const int cleared=SDL_RenderClear(renderer_);SDL_SetRenderDrawColor(renderer_,r,g,b,a);
|
||||||
|
if(cleared!=0||SDL_RenderCopy(renderer_,texture_,nullptr,nullptr)!=0)throw std::runtime_error(SDL_GetError());
|
||||||
|
SDL_RenderPresent(renderer_);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
struct SDL_Renderer;
|
||||||
|
struct SDL_Texture;
|
||||||
|
namespace bmh::app {
|
||||||
|
// Owned, embedded artwork, rendered independently of the indexed game canvas.
|
||||||
|
// Destruction restores the caller's logical size and therefore its input mapping.
|
||||||
|
class StartScreen {
|
||||||
|
public:
|
||||||
|
explicit StartScreen(SDL_Renderer*);
|
||||||
|
~StartScreen();
|
||||||
|
StartScreen(const StartScreen&)=delete;
|
||||||
|
StartScreen& operator=(const StartScreen&)=delete;
|
||||||
|
void present();
|
||||||
|
int width()const{return width_;}
|
||||||
|
int height()const{return height_;}
|
||||||
|
private:
|
||||||
|
SDL_Renderer* renderer_;
|
||||||
|
SDL_Texture* texture_=nullptr;
|
||||||
|
int width_=0,height_=0,previous_width_=0,previous_height_=0;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
#include <cstddef>
|
||||||
|
namespace bmh::app {
|
||||||
|
extern const unsigned char start_screen_jpeg[];
|
||||||
|
extern const std::size_t start_screen_jpeg_size;
|
||||||
|
}
|
||||||
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
# stb_image
|
||||||
|
|
||||||
|
Unmodified upstream stb_image 2.30 header, commit `013ac3beddff3dbffafd5177e7972067cd2b5083`.
|
||||||
|
Source: [013ac3beddff3dbffafd5177e7972067cd2b5083](https://github.com/nothings/stb/blob/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h).
|
||||||
|
SHA256: `594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3`.
|
||||||
|
|
||||||
|
Only JPEG decoding is compiled. The complete dual MIT/public-domain license
|
||||||
|
is retained in the header and in `docs/licenses/stb_image.txt`.
|
||||||
Vendored
+7988
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,53 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "app/start_screen.hpp"
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <vector>
|
||||||
|
namespace {
|
||||||
|
void check(bool value,const char* message){if(!value)throw std::runtime_error(message);}
|
||||||
|
void frame(int width,int height,const std::filesystem::path& output) {
|
||||||
|
const std::unique_ptr<SDL_Surface,decltype(&SDL_FreeSurface)> surface(
|
||||||
|
SDL_CreateRGBSurfaceWithFormat(0,width,height,32,SDL_PIXELFORMAT_RGBA32),SDL_FreeSurface);
|
||||||
|
check(bool(surface),SDL_GetError());
|
||||||
|
const std::unique_ptr<SDL_Renderer,decltype(&SDL_DestroyRenderer)> renderer(SDL_CreateSoftwareRenderer(surface.get()),SDL_DestroyRenderer);
|
||||||
|
check(bool(renderer),SDL_GetError());SDL_RenderSetLogicalSize(renderer.get(),320,240);SDL_SetRenderDrawColor(renderer.get(),12,34,56,255);
|
||||||
|
{
|
||||||
|
bmh::app::StartScreen title(renderer.get());
|
||||||
|
check(title.width()==1448&&title.height()==1086,"start artwork was reduced to the game canvas");title.present();
|
||||||
|
int logical_width=0,logical_height=0;SDL_RenderGetLogicalSize(renderer.get(),&logical_width,&logical_height);
|
||||||
|
check(logical_width==1448&&logical_height==1086,"start screen uses the low-resolution logical size");
|
||||||
|
float sx=0,sy=0;SDL_RenderGetScale(renderer.get(),&sx,&sy);
|
||||||
|
check(sx>0&&sy>0&&std::abs(sx-sy)<0.001f,"start artwork aspect ratio was stretched");
|
||||||
|
std::vector<unsigned char> pixels(size_t(width)*height*4);
|
||||||
|
check(SDL_LockSurface(surface.get())==0,SDL_GetError());
|
||||||
|
for(int y=0;y<height;++y)std::memcpy(pixels.data()+size_t(y)*width*4,
|
||||||
|
static_cast<const unsigned char*>(surface->pixels)+size_t(y)*surface->pitch,size_t(width)*4);
|
||||||
|
SDL_UnlockSurface(surface.get());
|
||||||
|
const auto center=(size_t(height/2)*width+width/2)*4;
|
||||||
|
check(pixels[center]+pixels[center+1]+pixels[center+2]>20,"embedded start artwork was not painted");
|
||||||
|
if(width*3>height*4){const auto side=size_t(height/2)*width*4;check(pixels[side]==0&&pixels[side+1]==0&&pixels[side+2]==0,"wide display has no clean side bars");}
|
||||||
|
Uint8 r=0,g=0,b=0,a=0;SDL_GetRenderDrawColor(renderer.get(),&r,&g,&b,&a);
|
||||||
|
check(r==12&&g==34&&b==56&&a==255,"start screen leaked its draw color into the game");
|
||||||
|
if(!output.empty()) {
|
||||||
|
std::filesystem::create_directories(output);std::ofstream file(output/(std::to_string(width)+"x"+std::to_string(height)+".ppm"),std::ios::binary);
|
||||||
|
file<<"P6\n"<<width<<' '<<height<<"\n255\n";for(size_t i=0;i<pixels.size();i+=4)file.write(reinterpret_cast<const char*>(pixels.data()+i),3);
|
||||||
|
}
|
||||||
|
title.present(); // Expose/resize redraw retains the same decoded texture.
|
||||||
|
}
|
||||||
|
int w=0,h=0;SDL_RenderGetLogicalSize(renderer.get(),&w,&h);
|
||||||
|
check(w==320&&h==240,"start screen did not restore the game and input coordinate system");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main(int argc,char** argv)try {
|
||||||
|
SDL_setenv("SDL_VIDEODRIVER","dummy",0);check(SDL_Init(SDL_INIT_VIDEO)==0,SDL_GetError());
|
||||||
|
const std::filesystem::path output=argc>1?argv[1]:"";
|
||||||
|
for(const auto size:std::array<std::array<int,2>,4>{{{1448,1086},{1920,1080},{3840,2160},{3440,1440}}})frame(size[0],size[1],output);
|
||||||
|
SDL_Quit();std::cout<<"Embedded native artwork, 1080p/4K/ultrawide aspect fit, redraw and game/input restoration passed\n";
|
||||||
|
}catch(const std::exception& error){std::cerr<<error.what()<<'\n';SDL_Quit();return 1;}
|
||||||
@@ -14,7 +14,7 @@ def validate(directory, windows):
|
|||||||
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
|
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',
|
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-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', 'stb_image.txt'}
|
||||||
present = set()
|
present = set()
|
||||||
for file in directory.rglob('*'):
|
for file in directory.rglob('*'):
|
||||||
if not file.is_file():
|
if not file.is_file():
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from __future__ import annotations
|
|||||||
import argparse
|
import argparse
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
|
import hashlib
|
||||||
from pathlib import Path, PurePosixPath
|
from pathlib import Path, PurePosixPath
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -28,6 +29,10 @@ ASSET_SUFFIXES = {
|
|||||||
".avi", ".mov", ".mp4", ".png", ".jpg", ".jpeg", ".bmp", ".gif",
|
".avi", ".mov", ".mp4", ".png", ".jpg", ".jpeg", ".bmp", ".gif",
|
||||||
".bin", ".zip", ".7z", ".dmg", ".tar", ".gz", ".pdf",
|
".bin", ".zip", ".7z", ".dmg", ".tar", ".gz", ".pdf",
|
||||||
}
|
}
|
||||||
|
# Newly supplied project artwork and an unchanged MIT/public-domain decoder.
|
||||||
|
# Exact hashes keep this exception from admitting original-game asset dumps.
|
||||||
|
REVIEWED_BINARY_FILES = {"assets/start-screen.jpg": "28df5a72cd7b6951c9eebf30532ea9557007a46f0a73614ba22401c403e379dc"}
|
||||||
|
REVIEWED_UPSTREAM_FILES = {"src/app/third_party/stb_image.h": "594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3"}
|
||||||
PRIVATE_PREFIXES = (
|
PRIVATE_PREFIXES = (
|
||||||
("data", "original"), ("docs", "manuals"), ("docs", "analyses"),
|
("data", "original"), ("docs", "manuals"), ("docs", "analyses"),
|
||||||
("docs", "agents"), ("src", "ui", "validation"),
|
("docs", "agents"), ("src", "ui", "validation"),
|
||||||
@@ -166,6 +171,11 @@ def path_findings(name: str) -> list[Finding]:
|
|||||||
|
|
||||||
|
|
||||||
def scan_blob(name: str, blob: bytes) -> list[Finding]:
|
def scan_blob(name: str, blob: bytes) -> list[Finding]:
|
||||||
|
reviewed = REVIEWED_BINARY_FILES | REVIEWED_UPSTREAM_FILES
|
||||||
|
if name in reviewed:
|
||||||
|
if hashlib.sha256(blob).hexdigest() == reviewed[name]:
|
||||||
|
return []
|
||||||
|
return [Finding(name, 0, "modified-reviewed-project-file")]
|
||||||
result = path_findings(name)
|
result = path_findings(name)
|
||||||
if len(blob) > 2_000_000:
|
if len(blob) > 2_000_000:
|
||||||
result.append(Finding(name, 0, "oversized-source-file"))
|
result.append(Finding(name, 0, "oversized-source-file"))
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import io
|
import io
|
||||||
|
import hashlib
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
@@ -17,6 +18,16 @@ import check_public_tree as guard
|
|||||||
|
|
||||||
|
|
||||||
class BlobChecks(unittest.TestCase):
|
class BlobChecks(unittest.TestCase):
|
||||||
|
def test_only_exact_reviewed_artwork_and_decoder_are_admitted(self):
|
||||||
|
for name, table in (("assets/start-screen.jpg",guard.REVIEWED_BINARY_FILES),
|
||||||
|
("src/app/third_party/stb_image.h",guard.REVIEWED_UPSTREAM_FILES)):
|
||||||
|
content=b"synthetic reviewed input\0"
|
||||||
|
with mock.patch.dict(table,{name:hashlib.sha256(content).hexdigest()}):
|
||||||
|
self.assertEqual(guard.scan_blob(name,content),[])
|
||||||
|
self.assertEqual({finding.rule for finding in guard.scan_blob(name,content+b"changed")},
|
||||||
|
{"modified-reviewed-project-file"})
|
||||||
|
self.assertIn("binary-or-game-asset",{finding.rule for finding in guard.scan_blob("assets/other.jpg",b"synthetic\0")})
|
||||||
|
|
||||||
def rules(self, name, text):
|
def rules(self, name, text):
|
||||||
return {finding.rule for finding in guard.scan_blob(name, text.encode())}
|
return {finding.rule for finding in guard.scan_blob(name, text.encode())}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user