Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2a6300aad | ||
|
|
12e3e52537 | ||
|
|
6d97b60ebc | ||
|
|
e3e2262e37 | ||
|
|
184a421512 | ||
|
|
998b037d3d |
No files matched your search
@@ -21,7 +21,7 @@ jobs:
|
||||
platform: linux-x64
|
||||
- runner: windows-2022
|
||||
platform: windows-x64
|
||||
- runner: macos-14
|
||||
- runner: macos-15
|
||||
platform: macos-arm64
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 90
|
||||
|
||||
+21
-1
@@ -1,6 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 1.0.0 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 1.0.2 LANGUAGES CXX C)
|
||||
if(APPLE)
|
||||
# Enable native languages before dependencies/subdirectories inherit rules.
|
||||
enable_language(OBJC OBJCXX)
|
||||
endif()
|
||||
set(OPENBMH_PRERELEASE "" CACHE STRING "Prerelease identifier; empty for final release")
|
||||
set(OPENBMH_PRODUCT_VERSION "${PROJECT_VERSION}")
|
||||
if(OPENBMH_PRERELEASE)
|
||||
@@ -1132,3 +1136,19 @@ add_test(NAME lineup_foreign_limit_tests COMMAND lineup_foreign_limit_tests)
|
||||
add_executable(calendar_epoch_tests tests/calendar_epoch_tests.cpp)
|
||||
target_link_libraries(calendar_epoch_tests PRIVATE bmhui)
|
||||
add_test(NAME calendar_epoch_tests COMMAND calendar_epoch_tests)
|
||||
|
||||
add_executable(video_session_tests tests/video_session_tests.cpp)
|
||||
target_include_directories(video_session_tests PRIVATE src)
|
||||
target_link_libraries(video_session_tests PRIVATE ${BMH_SDL_TARGET})
|
||||
add_test(NAME video_session_tests COMMAND video_session_tests)
|
||||
if(APPLE)
|
||||
add_executable(mac_video_picker_tests tests/mac_video_picker_tests.mm)
|
||||
set_target_properties(mac_video_picker_tests PROPERTIES OBJCXX_STANDARD 20 OBJCXX_STANDARD_REQUIRED YES)
|
||||
target_include_directories(mac_video_picker_tests PRIVATE src)
|
||||
target_link_libraries(mac_video_picker_tests PRIVATE ${BMH_SDL_TARGET} nfd::nfd "-framework Cocoa")
|
||||
add_test(NAME mac_video_picker_tests COMMAND mac_video_picker_tests)
|
||||
endif()
|
||||
|
||||
add_executable(desktop_feedback_tests tests/desktop_feedback_tests.cpp)
|
||||
target_link_libraries(desktop_feedback_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME desktop_feedback_tests COMMAND desktop_feedback_tests "${BMH_DATA}")
|
||||
@@ -14,13 +14,15 @@ Check the [releases page](https://github.com/Weyoune/openbmh/releases) for avail
|
||||
2. Extract the OpenBMH package into a separate directory, or alongside the game files.
|
||||
3. Start `OpenBMH` (`OpenBMH.exe` on Windows). Select the game directory or executable when prompted. A ZIP or 7z containing one game installation can also be selected.
|
||||
|
||||
From a terminal:
|
||||
From a terminal in the extracted package on Linux or macOS:
|
||||
|
||||
```sh
|
||||
OpenBMH --data "path/to/game" --save-directory "path/to/saves"
|
||||
openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
./OpenBMH --data "path/to/game" --save-directory "path/to/saves"
|
||||
./openbmh_cli --console --data "path/to/game" --saves "path/to/saves"
|
||||
```
|
||||
|
||||
In Windows PowerShell, use `.\OpenBMH.exe` and `.\openbmh_cli.exe` instead.
|
||||
|
||||
Use a writable save directory and keep backups of existing games. German editions are the primary compatibility target. **Football Limited / English data support is experimental**; original V2.20 save import and some edition-specific behaviour remain limited. See the [release notes](docs/release/1.0/RELEASE_NOTES.md).
|
||||
|
||||
## Features and direction
|
||||
@@ -31,7 +33,7 @@ OpenBMH focuses on original-game compatibility, stability and community contribu
|
||||
|
||||
## Build from source
|
||||
|
||||
The following recipes target OpenBMH 1.0 release candidates. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
The following recipes build OpenBMH 1.0. They require Git, CMake 3.24 or newer and a C++20 compiler. The first configure fetches pinned open-source dependencies. Native build and package results are documented for each release; these instructions do not claim an untested platform result.
|
||||
|
||||
Clone the public repository, then run the commands for your system:
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
# OpenBMH 1.0.2
|
||||
|
||||
A left click on an open desktop widget's upper-left close button now hides that widget through the normal validated layout transaction. The close button no longer starts a drag or shows the moving outline. Moving an element with the right mouse button remains available.
|
||||
|
||||
The close action consumes its matching mouse release even if the engine has already removed the widget, preventing an accidental click on an icon underneath. The automation and macOS keyboard fixes from 1.0.1 remain unchanged.
|
||||
|
||||
---
|
||||
|
||||
# OpenBMH 1.0.1
|
||||
|
||||
The automatic-lineup monitor now draws the selected formation from the actual manager formation table. Outdoor, indoor and custom formation slots retain their original coordinates and palette. Dragging a desktop element shows the original yellow outline, which disappears when the drag ends.
|
||||
|
||||
SDL video initialization now precedes the initial native file picker. On macOS this lets SDL establish the Cocoa application and keyboard activation policy before the picker creates or modifies NSApp. It addresses keyboard input missing throughout the game, including entering the manager name. A native macOS regression checks the activation policy after the picker initialization/shutdown lifecycle.
|
||||
|
||||
Native interactive Mac keyboard acceptance remains human QA; automated checks do not represent physical typing on a user's Mac.
|
||||
|
||||
---
|
||||
|
||||
# OpenBMH 1.0.0
|
||||
|
||||
Classic direct-installation runtime restored from v0.1.2. The game executable is OpenBMH / OpenBMH.exe; openbmh_cli remains available.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Classic 1.0 candidate validation
|
||||
# OpenBMH 1.0 validation
|
||||
|
||||
Scope: recorded automated/original-data checks. Exact final source revision and native platform build records accompany the published release.
|
||||
|
||||
- Linux x64 Release build: all targets compiled.
|
||||
- CTest: 35 passed, 157 skipped, zero failures (192 registered tests). Skips require separately configured original-data or save fixtures; they are not acceptance passes.
|
||||
- Local Linux CTest: 35 passed, 157 skipped, zero failures (192 registered tests). Skips require separately configured original-data or save fixtures; they are not acceptance passes.
|
||||
- Synthetic tests cover unchanged executable image loading, nine original strength ranges, atomic rejection of malformed ranges, unsupported environment guards, and legacy/extended/truncated crest gates.
|
||||
- Public source scan: zero findings; generated differences catalogue matches source markers.
|
||||
- Version output: both GUI and console identify 1.0.0-rc.1.
|
||||
@@ -33,3 +33,13 @@ After the final lineup, qualification and once-per-player season-reset correctio
|
||||
The duplicate-player defect was reproduced and captured before correction: a temporary offer referenced a player already owned by a club, then the extended market-retirement pass regenerated that player a second time. Frozen private before/after saves and a cached-reference regression support the correction. Save-envelope diagnostics use a separate RNG and do not consume either gameplay stream.
|
||||
|
||||
Calendar epoch regression covers the original CD and Diamond parameters, engine weekdays, desktop dates, save-header dates, year rollover and atomic rejection of invalid/unknown setup instructions. The original and checked Diamond date routines differ only in their weekday/year operands. After installing the original CD calendar parameters, the 600-turn run with contract and advertising policies completed eleven season-end desks without invariant failures.
|
||||
|
||||
## 1.0.1 desktop and macOS regressions
|
||||
|
||||
The desktop feedback test checks selected saved formations against their original table, compares changed miniature pixels, and checks the original yellow outline during a drag and its removal afterward. Private CD and Diamond render captures use the original assets. The SDL lifetime test checks initialization before the picker scope, normal destruction and failed initialization cleanup.
|
||||
|
||||
A macOS-only native Cocoa test initializes SDL before the native picker lifecycle, checks regular activation, creates a keyboard-focused window and verifies that a Cocoa key event produces both SDL key and text events. This automated native event test supplements human keyboard QA; it is not a claim of physical typing on the user's machine.
|
||||
|
||||
## 1.0.2 close-button regression
|
||||
|
||||
The desktop feedback test checks that the left corner requests removal instead of entering drag mode, that the remaining layout chain is intact, and that the release after acknowledgement does not activate an underlying icon. A subsequent independent click remains usable. Right-button movement and its temporary yellow outline remain covered. The user confirmed the 1.0.1 automation and Mac keyboard corrections.
|
||||
+4
-3
@@ -31,6 +31,7 @@
|
||||
#include "launch/file_dialog.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
#include "version.hpp"
|
||||
#include "app/video_session.hpp"
|
||||
#include "app/live_matchday_events.hpp"
|
||||
#include "audio/playback.hpp"
|
||||
#include "app/audio.hpp"
|
||||
@@ -151,6 +152,9 @@ int main(int argc, char** argv) {
|
||||
data = launch::path_from_utf8(args[i]);
|
||||
}
|
||||
}
|
||||
std::optional<app::VideoSession> video;
|
||||
try { video.emplace(); }
|
||||
catch (const std::exception& error) { show_start_error(error.what()); return 1; }
|
||||
// the game: as given (directory, EXE or archive); else the directory OpenBMH itself lies in,
|
||||
// when it holds a playable game (the simplest install: openbmh next to BMH.EXE); else
|
||||
// chosen in the file dialog
|
||||
@@ -194,7 +198,6 @@ int main(int argc, char** argv) {
|
||||
ui::StartupFlow flow(data, save_directory);
|
||||
std::unique_ptr<app::CareerSession> session;
|
||||
uint64_t revision = 0;
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) throw FormatError(SDL_GetError());
|
||||
openbmh::audio::Playback playback;
|
||||
std::string audio_error;
|
||||
playback.initialize(audio_error); // Audio is optional; the game continues without a device.
|
||||
@@ -3903,11 +3906,9 @@ int main(int argc, char** argv) {
|
||||
SDL_DestroyWindow(window);
|
||||
mouse_sound.detach(); // Remove event producers before closing the audio device.
|
||||
playback.shutdown();
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "error: %s\n", e.what());
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include <SDL.h>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
namespace bmh::app {
|
||||
// Establish SDL's native application before any file picker can create NSApp.
|
||||
// Cocoa otherwise retains the picker's non-keyboard activation policy.
|
||||
class VideoSession {
|
||||
public:
|
||||
VideoSession() {
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
const std::string error = SDL_GetError();
|
||||
SDL_Quit();
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
}
|
||||
~VideoSession() { SDL_Quit(); }
|
||||
VideoSession(const VideoSession&) = delete;
|
||||
VideoSession& operator=(const VideoSession&) = delete;
|
||||
};
|
||||
}
|
||||
@@ -488,6 +488,18 @@ DeskDate desk_date(uint32_t counter, const LeImage& exe) {
|
||||
return d;
|
||||
}
|
||||
|
||||
namespace {
|
||||
void project_automation_formation(DeskState& desk, const Bytes& formations, bool indoor) {
|
||||
const int selected = desk.automation[0];
|
||||
if (selected == 0) return;
|
||||
if (selected > 8) throw FormatError("desktop: invalid automatic formation");
|
||||
const size_t offset = size_t(desk.manager_slot) * 0x160 + size_t(indoor) * 0xb0 + size_t(selected - 1) * 22;
|
||||
if (offset + 22 > formations.size()) throw FormatError("desktop: missing automatic formation");
|
||||
desk.automation_formation.emplace();
|
||||
std::copy_n(formations.begin() + offset, 22, desk.automation_formation->begin());
|
||||
}
|
||||
}
|
||||
|
||||
DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revision) {
|
||||
StaticMemory memory(s);
|
||||
auto manager = block_copy(s, ::bmh::layout::ManagerRecords), tactics = block_copy(s, ::bmh::layout::TacticsBoards), options = block_copy(s, ::bmh::layout::ManagerAutomation);
|
||||
@@ -510,6 +522,7 @@ DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revisi
|
||||
project_table_position(d, table_source);
|
||||
project_drawer_rows(d, exe, manager, s.pool(0), offsets, position_history,
|
||||
results_by_opponent, rounds, std::nullopt);
|
||||
project_automation_formation(d, block_copy(s, layout::Formations), false);
|
||||
d.source = "original_save_read_only"; return d;
|
||||
}
|
||||
|
||||
@@ -520,6 +533,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
auto d = project(g.memory, {g.manager_records, g.tactics, g.manager_options, g.stocks, g.club_heap_78, g.club_names,
|
||||
g.club_ids, g.squad_slots, g.players, g.team_morale, g.manager_teams, g.league_rounds},
|
||||
exe, g.level, g.date, g.season_day(), g.season, revision);
|
||||
project_automation_formation(d, g.formations, g.indoor);
|
||||
// DeskDate only auto-opens for an ordinary club manager; the national
|
||||
// runtime (0x165) suppresses this consumer while manual mailbox access remains valid.
|
||||
if (d.runtime_club != kNoTeam && d.manager_slot >= 0 && d.manager_slot < 32 && g.memory.has(::bmh::layout::MailboxRecipientMask))
|
||||
|
||||
@@ -107,6 +107,7 @@ struct DeskState {
|
||||
bool mailbox_notification_pending = false; // MailboxRecipientMask active-manager bit; transient, non-FBM
|
||||
std::optional<DeskItem> menu_layout_shortcut; // final bar cell returns native record 53/kind 72, then dispatches MEN
|
||||
std::array<uint8_t, 5> automation{};
|
||||
std::optional<std::array<uint8_t, 22>> automation_formation;
|
||||
std::array<std::optional<bool>, 10> warnings{};
|
||||
std::vector<DeskItem> items; // Original linked-list drawing / hit-test order.
|
||||
std::string source;
|
||||
|
||||
+61
-10
@@ -218,7 +218,14 @@ void DesktopScreen::draw_item(Image& out, const DeskItem& item) const {
|
||||
copy(out, icons_, 97, 111, x + 3 + i * 33, y + 2, 32, 30);
|
||||
const auto value = state_.automation[i];
|
||||
if ((i == 4 ? value & 1 : value) != 0) copy(out, icons_, 129 + i * 16, 111, x + i * 33 + 10, y + 4, 17, 11);
|
||||
// Individual automatic-formation dots need a separately verified renderer.
|
||||
if (i == 0 && value != 0 && state_.automation_formation) {
|
||||
const auto& formation = *state_.automation_formation;
|
||||
// The original miniature excludes the keeper and unused positions.
|
||||
for (int row = 1; row < 11; ++row)
|
||||
if (formation[size_t(row)] != 0)
|
||||
rect(out, x + 10 + formation[size_t(row)] * 15 / 18,
|
||||
y + 5 + formation[size_t(row + 11)], 1, 1, 0x27);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
@@ -275,6 +282,20 @@ Image DesktopScreen::render() const {
|
||||
if (shortcut_hover_record_ >= 0)
|
||||
text(out, 0, 235, texts_[text_id(::bmh::layout::Desktop_Render_TextPointer + uint32_t(shortcut_hover_record_) * 4)], 0x5f, 319);
|
||||
}
|
||||
if (layout_drag_ && layout_preview_) {
|
||||
const auto selected = std::find_if(visible.items.begin(), visible.items.end(),
|
||||
[&](const DeskItem& item) { return item.id == layout_drag_->item; });
|
||||
if (selected != visible.items.end()) {
|
||||
draw_item(out, *selected);
|
||||
const auto& item = *selected;
|
||||
const int w = item.width - (item.kind >= 50 && !item.open ? 8 : 0);
|
||||
const int h = item.height - (item.kind >= 50 && !item.open ? 8 : 0);
|
||||
rect(out, item.x, item.y, w, 1, 0x27);
|
||||
rect(out, item.x, item.y + h - 1, w, 1, 0x27);
|
||||
rect(out, item.x, item.y, 1, h, 0x27);
|
||||
rect(out, item.x + w - 1, item.y, 1, h, 0x27);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -306,8 +327,30 @@ std::optional<DeskItem> DesktopScreen::folder_child_at(int x,int y) const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
DeskRequest DesktopScreen::close_drawer(const DeskItem& item) {
|
||||
if (item.id < 1 || item.id >= 54 || item.kind < 50 || item.kind > 71 || !item.open) return {};
|
||||
const auto& record = state_.layout_records[size_t(item.id)];
|
||||
const int previous = record[6], next = record[5];
|
||||
if (previous >= 54 || next >= 54 || record[12] != item.kind ||
|
||||
state_.layout_records[size_t(previous)][5] != item.id ||
|
||||
(next != 0 && state_.layout_records[size_t(next)][6] != item.id)) return {};
|
||||
auto action = request(DeskRequestKind::change_layout, item, 2);
|
||||
action.layout_operation = DeskLayoutOperation::toggle_quickbar_drawer;
|
||||
action.layout_target_item = item.id;
|
||||
for (size_t i = 0; i < 54; ++i)
|
||||
std::copy(state_.layout_records[i].begin(), state_.layout_records[i].end(), action.layout_before.begin() + i * 16);
|
||||
action.layout_after = action.layout_before;
|
||||
action.layout_after[size_t(previous) * 16 + 5] = uint8_t(next);
|
||||
if (next != 0) action.layout_after[size_t(next) * 16 + 6] = uint8_t(previous);
|
||||
action.layout_after[size_t(item.id) * 16 + 5] = 0xff;
|
||||
action.layout_after[size_t(item.id) * 16 + 6] = 0xff;
|
||||
sound_ids_.push_back(12);
|
||||
pending_ = action;
|
||||
return action;
|
||||
}
|
||||
|
||||
DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
if (pending_) return {};
|
||||
if (pending_ || drawer_close_release_pending_) return {};
|
||||
if (socket_release_pending_) return {}; // DeskDate waits here for the first RMB release.
|
||||
sample_shortcut_pointer(x, y);
|
||||
shortcut_hover_record_ = -1; // DeskDate clears its tooltip on event2/event8 before dispatch.
|
||||
@@ -345,19 +388,22 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
const int inset = item.kind >= 50 && !item.open ? 8 : 0;
|
||||
if (item.disabled || x < item.x || y < item.y || x >= item.x + item.width - inset ||
|
||||
y >= item.y + item.height - inset) continue;
|
||||
if (!right && item.kind >= 50 && item.open && state_.drawer_handles &&
|
||||
x <= item.x + 3 && y <= item.y + 3) {
|
||||
auto action = close_drawer(item);
|
||||
drawer_close_release_pending_ = action.kind != DeskRequestKind::none;
|
||||
return action;
|
||||
}
|
||||
if (right && !state_.drawer_handles) return {};
|
||||
if (right && bin_mode_ && item.kind!=12) return {};
|
||||
if (!right && item.kind==55 && item.open && !state_.national_team &&
|
||||
x-item.x-4>34 && x-item.x-4<87) return {}; // Original ticket-price scale.
|
||||
if (!right && item.kind==64 && item.open) return {}; // Source automation controls remain clicks.
|
||||
const bool drawer_handle=item.kind>=50&&state_.drawer_handles&&x<=item.x+3&&y<=item.y+3;
|
||||
if(item.kind>=50&&!drawer_handle&&!right) return {};
|
||||
if(!right&&!drawer_handle) return {}; // Source LMB activates; RMB starts a drag.
|
||||
if (!right) return {}; // LMB closes/activates; RMB alone starts a drag.
|
||||
layout_drag_ = LayoutDrag{item.id, x - item.x, y - item.y, item.x, item.y, -1, false, false, drawer_handle, right};
|
||||
layout_preview_ = state_;
|
||||
// RemovesBinModeIcon/RestoresChildBinMode run at RMB press, even if no motion follows.
|
||||
// The existing LMB handle drag differs from that Source path; do not
|
||||
// invent its sound mapping here.
|
||||
if (right) sound_ids_.insert(sound_ids_.end(), {12, 15});
|
||||
return {};
|
||||
}
|
||||
@@ -365,7 +411,7 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
}
|
||||
|
||||
bool DesktopScreen::pointer_move(int x, int y) {
|
||||
if (pending_ || socket_release_pending_) return false;
|
||||
if (pending_ || socket_release_pending_ || drawer_close_release_pending_) return false;
|
||||
if (!layout_drag_ || !layout_preview_) return sample_shortcut_pointer(x, y);
|
||||
auto& drag = *layout_drag_;
|
||||
auto found = std::find_if(layout_preview_->items.begin(), layout_preview_->items.end(),
|
||||
@@ -383,6 +429,10 @@ bool DesktopScreen::pointer_move(int x, int y) {
|
||||
}
|
||||
|
||||
DeskRequest DesktopScreen::pointer_up(int x, int y, bool right) {
|
||||
if (drawer_close_release_pending_) {
|
||||
if (!right) drawer_close_release_pending_ = false;
|
||||
return {}; // The close owns its release even after the widget was removed by ACK.
|
||||
}
|
||||
if (socket_release_pending_) {
|
||||
if (right) socket_release_pending_ = false;
|
||||
return {}; // First socket RMB release is only the Source wait barrier.
|
||||
@@ -600,9 +650,9 @@ DeskRequest DesktopScreen::click(int x, int y, bool right) {
|
||||
}
|
||||
if (item.disabled || right) return {};
|
||||
if (item.kind < 50) return request(item.kind == 12 ? DeskRequestKind::advance_turn : DeskRequestKind::open_menu, item);
|
||||
// DeskDate only handles Ticket/Calendar/Automation body clicks;
|
||||
// drawer open/close is exclusively the compact quickbar operation.
|
||||
if (item.open && state_.drawer_handles && x <= item.x + 3 && y <= item.y + 3) return {};
|
||||
// The corner closes through the same transaction as the quickbar.
|
||||
if (item.open && state_.drawer_handles && x <= item.x + 3 && y <= item.y + 3)
|
||||
return close_drawer(item);
|
||||
if (item.kind == 58 && item.open) return request(DeskRequestKind::advance_turn, item);
|
||||
if (item.kind == 55 && item.open && !state_.national_team && x - item.x - 4 > 34 && x - item.x - 4 < 87)
|
||||
return request(DeskRequestKind::change_ticket_price, item, (x - item.x - 4 - 35) / 3 + 8);
|
||||
@@ -722,6 +772,7 @@ std::string DesktopScreen::state_json() const {
|
||||
",\"shortcut_hover_record\":" + std::to_string(shortcut_hover_record_) +
|
||||
",\"socket_confirmation_armed\":" + std::string(socket_confirmation_armed_ ? "true" : "false") +
|
||||
",\"bin_mode\":" + std::string(bin_mode_ ? "true" : "false") +
|
||||
",\"dragging_item\":" + (layout_drag_ ? std::to_string(layout_drag_->item) : "null") +
|
||||
",\"pending_action\":" + (pending_ ? desk_request_json(*pending_) : "null") +
|
||||
",\"last_rejection\":" + (last_rejection_.empty() ? "null" : json_quote(last_rejection_)) + "}";
|
||||
return out;
|
||||
|
||||
@@ -71,6 +71,8 @@ private:
|
||||
mutable std::vector<uint8_t> sound_ids_;
|
||||
struct LayoutDrag { int item=-1, grab_x=0, grab_y=0, start_x=0, start_y=0, folder=-1; bool moved=false, folder_child=false, drawer_handle=false, right_button=false; };
|
||||
std::optional<LayoutDrag> layout_drag_;
|
||||
bool drawer_close_release_pending_ = false;
|
||||
DeskRequest close_drawer(const DeskItem& item);
|
||||
std::optional<DeskState> layout_preview_;
|
||||
void text(Image&, int x, int baseline, std::string_view, uint8_t color, int right = -1) const;
|
||||
void sprite_text(Image&, int x, int baseline, std::string_view, int font) const;
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/desktop.hpp"
|
||||
#include "formats/palette.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/fbm.hpp"
|
||||
#include "formats/savestate.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include <filesystem>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
using namespace bmh;
|
||||
using namespace bmh::ui;
|
||||
void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);}
|
||||
void capture(const std::filesystem::path& dir,const char* name,const Image& image,const Palette& palette){
|
||||
if(dir.empty())return;
|
||||
std::filesystem::create_directories(dir);
|
||||
std::ofstream out(dir/name,std::ios::binary);out<<"P6\n"<<image.width<<' '<<image.height<<"\n255\n";
|
||||
for(auto pixel:image.pixels){const auto c=palette.argb[pixel];for(int shift:{16,8,0})out.put(char(c>>shift));}
|
||||
}
|
||||
int main(int argc,char**argv)try{
|
||||
if(argc<2||!*argv[1])return 77;
|
||||
const std::filesystem::path data=argv[1],output=argc>2?argv[2]:"";
|
||||
const auto palette=load_palette(data/"M3PC.COL");
|
||||
if (argc > 3) {
|
||||
const auto file = load_savegame(argv[3]);
|
||||
check(file.checksum_ok,"reference save checksum invalid");
|
||||
const auto exe = load_le(data/"BMH.exe");
|
||||
const SaveState original(file.stream);
|
||||
const auto option_offset = original.block(layout::ManagerAutomation).offset;
|
||||
for (int selected=0; selected<=4; ++selected) {
|
||||
auto stream = file.stream;
|
||||
stream.at(option_offset)=uint8_t(selected);
|
||||
const SaveState saved(stream);
|
||||
auto projected = desk_from_save(saved,exe,1);
|
||||
check(projected.automation_formation.has_value()==(selected!=0),"formation visibility did not follow saved automation option");
|
||||
if(selected)for(size_t i=0;i<22;++i)
|
||||
check(projected.automation_formation->at(i)==saved.data(layout::Formations)[size_t(selected-1)*22+i],
|
||||
"miniature did not use the selected saved formation");
|
||||
projected.items={{1,20,20,173,40,64,0,0,true,false}};
|
||||
const auto rendered = DesktopScreen(data,projected).render();
|
||||
const std::string name="saved-formation-"+std::to_string(selected)+".ppm";
|
||||
capture(output,name.c_str(),rendered,palette);
|
||||
}
|
||||
}
|
||||
DeskState state;state.options.managers=1;state.options.duration=5;state.options.mode=3;state.options.difficulty=2;
|
||||
state.options.league=true;state.options.world=true;
|
||||
state.manager_slot=0;state.runtime_club=0;state.manager_teams={0};state.manager_name="QA";state.club_name="QA";
|
||||
DeskManagerIdentity manager;manager.runtime_club=0;manager.club_identity_key=0;manager.name="QA";manager.league=0;manager.portrait=0;manager.badge=0;
|
||||
state.managers={manager};state.league=0;state.portrait=0;state.badge=0;
|
||||
state.items={{1,20,20,173,40,64,0,0,true,false}};
|
||||
state.automation[0]=1;state.automation_formation.emplace();state.automation_formation->fill(0);
|
||||
(*state.automation_formation)[1]=18;(*state.automation_formation)[12]=3;
|
||||
const auto first=DesktopScreen(data,state).render();
|
||||
check(first.pixels[size_t(32)*320+49]==0x27,"formation player not rendered at the original miniature coordinate");
|
||||
state.automation[0]=2;(*state.automation_formation)[1]=6;(*state.automation_formation)[12]=2;
|
||||
const auto second=DesktopScreen(data,state).render();
|
||||
check(first.pixels!=second.pixels,"changing selected formation left the monitor unchanged");
|
||||
capture(output,"formation-1.ppm",first,palette);capture(output,"formation-2.ppm",second,palette);
|
||||
state.drawer_handles=true;
|
||||
state.items={{2,20,20,32,25,0,0,0,false,false},{1,20,20,173,40,64,0,0,true,false}};
|
||||
state.layout_records[0][5]=2;
|
||||
state.layout_records[2][5]=1; state.layout_records[2][6]=0;
|
||||
state.layout_records[1][5]=0; state.layout_records[1][6]=2;
|
||||
state.layout_records[1][12]=64; state.layout_records[1][13]=0x80;
|
||||
DesktopScreen widget_drag(data,state);
|
||||
widget_drag.pointer_down(21,21,true);
|
||||
widget_drag.pointer_move(61,61);
|
||||
const auto widget_move=widget_drag.pointer_up(61,61,true);
|
||||
check(widget_move.kind==DeskRequestKind::change_layout && widget_move.layout_operation==DeskLayoutOperation::move_item,
|
||||
"right-button widget movement was replaced by closing");
|
||||
DesktopScreen close(data,state);
|
||||
capture(output,"close-before.ppm",close.render(),palette);
|
||||
const auto removal=close.pointer_down(21,21,false);
|
||||
check(removal.kind==DeskRequestKind::change_layout &&
|
||||
removal.layout_operation==DeskLayoutOperation::toggle_quickbar_drawer &&
|
||||
removal.layout_target_item==1,"left corner did not request widget removal");
|
||||
check(removal.layout_after[2*16+5]==0 && removal.layout_after[16+5]==0xff &&
|
||||
removal.layout_after[16+6]==0xff,"corner removal corrupted the remaining layout chain");
|
||||
check(close.state_json().find("\"dragging_item\":null")!=std::string::npos,
|
||||
"close corner incorrectly entered drag mode");
|
||||
check(!close.pointer_move(100,100),"close press turned into movement");
|
||||
auto removed=state; removed.revision=state.revision+1; removed.items.erase(removed.items.begin()+1);
|
||||
for(size_t i=0;i<54;++i)std::copy_n(removal.layout_after.begin()+i*16,16,removed.layout_records[i].begin());
|
||||
close.acknowledge(removed);
|
||||
check(close.pointer_up(21,21,false).kind==DeskRequestKind::none,
|
||||
"close release activated the icon underneath the removed widget");
|
||||
capture(output,"close-after.ppm",close.render(),palette);
|
||||
check(close.pointer_up(21,21,false).kind==DeskRequestKind::open_menu,
|
||||
"close release barrier consumed a subsequent independent click");
|
||||
state.layout_records={}; state.layout_records[0][5]=1;
|
||||
state.items={{1,20,20,32,25,0,0,0,false,false}};state.drawer_handles=true;
|
||||
DesktopScreen drag(data,state);const auto normal=drag.render();
|
||||
const auto idle=drag.state_json();
|
||||
drag.pointer_down(25,25,true);
|
||||
check(drag.state_json()!=idle,"drag press did not invalidate the rendered desktop");
|
||||
drag.pointer_move(65,65);
|
||||
const auto moving=drag.render();
|
||||
check(moving.pixels[size_t(60)*320+60]==0x27 && moving.pixels[size_t(84)*320+91]==0x27,"moving icon lacks inclusive yellow outline");
|
||||
const auto request=drag.pointer_up(65,65,true);
|
||||
check(request.kind==DeskRequestKind::change_layout,"drag did not retain its layout transaction");
|
||||
check(drag.render().pixels==normal.pixels,"yellow preview survived release without acknowledgement");
|
||||
capture(output,"drag-normal.ppm",normal,palette);capture(output,"drag-active.ppm",moving,palette);
|
||||
std::cout<<"Automation formation changes and transient yellow drag border passed\n";return 0;
|
||||
}catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "app/video_session.hpp"
|
||||
#include <SDL_syswm.h>
|
||||
#include <cstring>
|
||||
#include <nfd.h>
|
||||
#include <iostream>
|
||||
int main() { @autoreleasepool {
|
||||
SDL_setenv("SDL_VIDEODRIVER", "cocoa", 1);
|
||||
try {
|
||||
bmh::app::VideoSession video;
|
||||
if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) return 1;
|
||||
if (NFD_Init() != NFD_OKAY) return 2;
|
||||
NFD_Quit();
|
||||
if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) return 3;
|
||||
SDL_Window* window=SDL_CreateWindow("Keyboard startup QA",0,0,320,240,0);
|
||||
if(!window)return 4;
|
||||
SDL_SysWMinfo info{}; SDL_VERSION(&info.version);
|
||||
if(!SDL_GetWindowWMInfo(window,&info))return 5;
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
[info.info.cocoa.window makeKeyAndOrderFront:nil];
|
||||
for(int i=0;i<100 && SDL_GetKeyboardFocus()!=window;++i){SDL_PumpEvents();SDL_Delay(10);}
|
||||
if(SDL_GetKeyboardFocus()!=window){std::cerr<<"Cocoa window did not acquire keyboard focus\n";return 6;}
|
||||
SDL_StartTextInput();
|
||||
SDL_Event input;while(SDL_PollEvent(&input)){}
|
||||
NSEvent* key=[NSEvent keyEventWithType:NSEventTypeKeyDown location:NSZeroPoint
|
||||
modifierFlags:0 timestamp:[[NSProcessInfo processInfo] systemUptime] windowNumber:[info.info.cocoa.window windowNumber]
|
||||
context:nil characters:@"q" charactersIgnoringModifiers:@"q" isARepeat:NO keyCode:12];
|
||||
[NSApp postEvent:key atStart:NO];
|
||||
bool key_received=false,text_received=false;
|
||||
for(int i=0;i<100 && !(key_received&&text_received);++i){
|
||||
while(SDL_PollEvent(&input)){
|
||||
key_received|=input.type==SDL_KEYDOWN;
|
||||
text_received|=input.type==SDL_TEXTINPUT && std::strcmp(input.text.text,"q")==0;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_DestroyWindow(window);
|
||||
if(!key_received||!text_received){std::cerr<<"Native key="<<key_received<<" text="<<text_received<<'\n';return 7;}
|
||||
std::cout<<"Native Cocoa key and text reach SDL after initial picker lifecycle\n";
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 6;}
|
||||
return 0;
|
||||
} }
|
||||
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/video_session.hpp"
|
||||
#include <iostream>
|
||||
int main(int, char**)try {
|
||||
SDL_setenv("SDL_VIDEODRIVER","dummy",1);
|
||||
{ bmh::app::VideoSession video;
|
||||
if (!(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)) return 1;
|
||||
// The initial chooser executes inside this scope, not before it.
|
||||
}
|
||||
if (SDL_WasInit(SDL_INIT_VIDEO)) return 1;
|
||||
SDL_setenv("SDL_VIDEODRIVER","unavailable-openbmh-test-driver",1);
|
||||
bool rejected=false;
|
||||
try { bmh::app::VideoSession failed; } catch(const std::exception&) { rejected=true; }
|
||||
if(!rejected || SDL_WasInit(SDL_INIT_VIDEO))return 1;
|
||||
std::cout<<"Video lifetime initializes before picker and releases on early return\n";
|
||||
return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
Reference in new issue
Block a user