Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa53c6e2e2 | ||
|
|
a3d1948fcd |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(OpenBMH VERSION 0.1.0 LANGUAGES CXX C)
|
||||
project(OpenBMH VERSION 0.1.1 LANGUAGES CXX C)
|
||||
# the one place of the version: --version of both programs and the window title (src/version.hpp)
|
||||
add_compile_definitions(OPENBMH_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ Version 0.1 establishes the playable engine and development interfaces. Later mi
|
||||
|
||||
## Build from source
|
||||
|
||||
The following recipes target v0.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.
|
||||
The following recipes target v0.1.1. 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:
|
||||
|
||||
@@ -103,6 +103,6 @@ The implementation grew from study of file formats and behaviour of a legally ob
|
||||
|
||||
OpenBMH's own code and documentation are licensed under **GNU GPL version 3 only**, SPDX **GPL-3.0-only**. [LICENSE](LICENSE) contains the unchanged GPLv3 text; the example wording in its appendix does not change this project's version choice. Game content has separate ownership and is not covered by this license.
|
||||
|
||||
Release source is identified by the matching version tag: [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0) for this version. 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.
|
||||
Release source is identified by the matching version tag: [v0.1.1](https://github.com/rezmer/openbmh/tree/v0.1.1) for this version. 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).
|
||||
@@ -34,4 +34,6 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [src/ui/environment.cpp](../src/ui/environment.cpp): omits the two discontinued youth groups from the environment screen.
|
||||
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
|
||||
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): omits DOS drive and delete buttons in the directory-confined save/load view.
|
||||
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): permits cancelling host file dialogs with the right mouse button.
|
||||
@@ -1490,6 +1490,9 @@ declarations change. Game text, resort, image and audio fallbacks belong outside
|
||||
| `Pitch_Render_TextPointer3` | `0xae0f0` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer4` | `0xae0f4` | German-compatible image / runtime field |
|
||||
| `Pitch_Render_TextPointer5` | `0xae0f8` | German-compatible image / runtime field |
|
||||
| `PitchOrderPositionPointers` | `0xa2a37` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneMasks` | `0xa2a4b` | German-compatible image / runtime field |
|
||||
| `PitchOrderZoneTextPointers` | `0xae818` | German-compatible image / runtime field |
|
||||
| `Placements` | `0xbd38c` | German-compatible image / runtime field |
|
||||
| `PlainBackground` | `0xa2569` | German-compatible image / runtime field |
|
||||
| `PlanTicketPrice` | `0xa4856` | German-compatible image / runtime field |
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
# OpenBMH v0.1.0
|
||||
# OpenBMH v0.1.1
|
||||
|
||||
OpenBMH reconstructs the Bundesliga Manager Hattrick engine in C++20. The graphical client uses SDL2; the console provides command batches and local manager-client transports over the same career session. This release needs a supported game installation supplied by the player. No original executable, artwork, music, text database, manual or saved game is included.
|
||||
|
||||
## Changes in 0.1.1
|
||||
|
||||
- Live lineup navigation preserves the saved pitch view and allows repeated switches between the team list and pitch. Right-click can leave the dialog even when the pointer moves between press and release ([#1](https://github.com/rezmer/openbmh/issues/1)).
|
||||
- The instruction panel restores original control symbols, substitute information, red coverage on player hover and pitch-position hints ([#2](https://github.com/rezmer/openbmh/issues/2)).
|
||||
- Right-click cancels load/save dialogs, including settings and desktop-layout files ([#3](https://github.com/rezmer/openbmh/issues/3)).
|
||||
- Save filenames accept typing immediately, replace a selected existing name and support Ctrl+A/Cmd+A. This also applies to desktop layouts saved as MEN files ([#4](https://github.com/rezmer/openbmh/issues/4)).
|
||||
|
||||
These corrections passed targeted UI/controller checks and Linux SDL input replays, including normal and Reality matches, substitutions, file writing and a fresh-process reload. Physical macOS window verification remains human QA. Use the new 0.1.1 packages to test these fixes; older 0.1.0 builds do not include them.
|
||||
|
||||
## Scope
|
||||
|
||||
The engine includes career management, leagues and cups, transfers and contracts, finances, training and camps, stadium management, live match interventions, audio playback and normal saves. Supported actions remain subject to mode, manager and phase restrictions; an unimplemented path reports an explicit error rather than an invented result. The project aims for recognisable behaviour and plausible results, not a promise that every original version produces identical events.
|
||||
@@ -25,7 +34,7 @@ Version 0.1 ships binary packages for Windows x64, macOS on Apple silicon (arm64
|
||||
|
||||
## License
|
||||
|
||||
The matching application source tag is [v0.1.0](https://github.com/rezmer/openbmh/tree/v0.1.0). Source/build and relinking materials for linked components must also accompany or be offered with binary releases under their licenses.
|
||||
The matching application source tag is [v0.1.1](https://github.com/rezmer/openbmh/tree/v0.1.1). Source/build and relinking materials for linked components must also accompany or be offered with binary releases under their licenses.
|
||||
|
||||
OpenBMH-owned code and documentation use GPL-3.0-only. Third-party components retain their licenses; the full texts accompany the package. Read [LICENSE](../../../LICENSE) and [THIRD_PARTY_NOTICES](../../../THIRD_PARTY_NOTICES.md). These licenses do not grant rights to original game content.
|
||||
|
||||
|
||||
+84
-183
@@ -1749,11 +1749,57 @@ int main(int argc, char** argv) {
|
||||
auto live_lineup = ui::lineup_from_game(lineup_state, season_exe, live_revision);
|
||||
live_lineup.in_match = true;
|
||||
live_lineup.entry_prepared = true;
|
||||
ui::LineupScreen screen(data, std::move(live_lineup));
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_lineup");
|
||||
// The live menu owns the same native display word and both pages
|
||||
// as the desk. A separate team-sheet parent can hide a saved
|
||||
// pitch page and strand its navigation request after return.
|
||||
ui::PitchScreen screen(data, std::move(live_lineup),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
const auto live_title = [&] {
|
||||
return (screen.extras().native_display_word & 8)
|
||||
? "OpenBMH - live_pitch" : "OpenBMH - live_lineup";
|
||||
};
|
||||
SDL_SetWindowTitle(window, live_title());
|
||||
bool closed = false;
|
||||
std::optional<SDL_MouseButtonEvent> lineup_down;
|
||||
std::optional<SDL_MouseButtonEvent> lineup_right_down;
|
||||
const auto apply_live_pitch = [&](const ui::PitchRequest& action) {
|
||||
if (action.kind == ui::PitchRequestKind::none) return;
|
||||
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
||||
try {
|
||||
if (action.row < 0 || size_t(action.row) >= screen.state().players.size() ||
|
||||
screen.state().players.at(size_t(action.row)).player_id != action.player_id)
|
||||
throw FormatError("live player information request is stale");
|
||||
auto services = session->live_club_modal_services(live_revision);
|
||||
const ClubPlayerDetailSelection selection{selected_team, action.player_id,
|
||||
action.row, action.row, -1};
|
||||
if (!present_player_detail)
|
||||
throw FormatError("live player information presenter stopped");
|
||||
const auto return_parent = present_player_detail(services, selection, screen.render());
|
||||
if (!return_parent) throw FormatError("live player information presenter stopped");
|
||||
if (*return_parent) closed = true;
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "live player information: %s\n", e.what());
|
||||
}
|
||||
screen.resolve_local_navigation();
|
||||
} else {
|
||||
const auto result = dispatch_pitch(action);
|
||||
if (result.status == app::LiveSubstitutionStatus::applied) {
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
screen.acknowledge(std::move(updated),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
} else if (result.status == app::LiveSubstitutionStatus::source_notice) {
|
||||
show_live_substitution_notice(result, screen.render(), live_title());
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
screen = ui::PitchScreen(data, std::move(updated),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
} else {
|
||||
screen.reject_action(result.error.empty()
|
||||
? "Der Spielerwechsel ist nicht freigegeben." : result.error);
|
||||
}
|
||||
}
|
||||
SDL_SetWindowTitle(window, live_title());
|
||||
};
|
||||
bool left_held = false, left_release_consumed = false, right_held = false;
|
||||
while (running && !closed) {
|
||||
const Image image = screen.render();
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
@@ -1769,188 +1815,35 @@ int main(int argc, char** argv) {
|
||||
if (modal.type == SDL_KEYDOWN && modal.key.keysym.sym == SDLK_ESCAPE) {
|
||||
screen.key("ESC"); closed = true; break;
|
||||
}
|
||||
if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_RIGHT)
|
||||
lineup_right_down = modal.button;
|
||||
else if (modal.type == SDL_MOUSEBUTTONUP && lineup_right_down &&
|
||||
modal.button.button == SDL_BUTTON_RIGHT &&
|
||||
modal.button.x == lineup_right_down->x && modal.button.y == lineup_right_down->y) {
|
||||
lineup_right_down.reset();
|
||||
screen.click(modal.button.x, modal.button.y, true);
|
||||
if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_LEFT) {
|
||||
left_held = true;
|
||||
const auto action = screen.pointer_down(modal.button.x, modal.button.y);
|
||||
left_release_consumed = screen.take_source_down_release_barrier();
|
||||
// Native page/order controls act on DOWN. ACK before
|
||||
// polling another event; their UP cannot toggle twice.
|
||||
apply_live_pitch(action);
|
||||
redrawn = true;
|
||||
} else if (modal.type == SDL_MOUSEBUTTONUP && modal.button.button == SDL_BUTTON_LEFT && left_held) {
|
||||
left_held = false;
|
||||
if (!left_release_consumed)
|
||||
apply_live_pitch(screen.click(modal.button.x, modal.button.y));
|
||||
left_release_consumed = false;
|
||||
redrawn = true;
|
||||
} else if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_RIGHT) {
|
||||
right_held = true;
|
||||
(void)screen.pointer_down(modal.button.x, modal.button.y, true);
|
||||
(void)screen.take_source_down_release_barrier();
|
||||
redrawn = true;
|
||||
} else if (modal.type == SDL_MOUSEBUTTONUP && modal.button.button == SDL_BUTTON_RIGHT && right_held) {
|
||||
right_held = false;
|
||||
// Mouse movement between DOWN and UP must not leave
|
||||
// a closed modal or an accepted request suspended.
|
||||
if (screen.close_requested()) closed = true;
|
||||
redrawn = true;
|
||||
}
|
||||
if (modal.type == SDL_MOUSEBUTTONDOWN && modal.button.button == SDL_BUTTON_LEFT)
|
||||
lineup_down = modal.button;
|
||||
else if (modal.type == SDL_MOUSEBUTTONUP && lineup_down &&
|
||||
modal.button.button == SDL_BUTTON_LEFT &&
|
||||
modal.button.x == lineup_down->x && modal.button.y == lineup_down->y) {
|
||||
lineup_down.reset();
|
||||
const auto request = screen.click(modal.button.x, modal.button.y);
|
||||
if (request.kind == ui::LineupRequestKind::swap_players) {
|
||||
const auto result = dispatch(request);
|
||||
if (result.status == app::LiveSubstitutionStatus::applied) {
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
screen.acknowledge(std::move(updated));
|
||||
redrawn = true;
|
||||
} else if (result.status == app::LiveSubstitutionStatus::source_notice) {
|
||||
show_live_substitution_notice(result, screen.render(),
|
||||
"OpenBMH - live_lineup");
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
screen = ui::LineupScreen(data, std::move(updated));
|
||||
redrawn = true;
|
||||
} else {
|
||||
screen.reject_action(result.error.empty()
|
||||
? "Der Spielerwechsel ist nicht freigegeben."
|
||||
: result.error);
|
||||
redrawn = true;
|
||||
}
|
||||
} else if (request.kind == ui::LineupRequestKind::open_player_info) {
|
||||
const auto& player = screen.state().players.at(size_t(request.first_row));
|
||||
try {
|
||||
if (player.player_id != request.first_player)
|
||||
throw FormatError("live player information request is stale");
|
||||
auto services = session->live_club_modal_services(live_revision);
|
||||
const ClubPlayerDetailSelection selection{selected_team, request.first_player,
|
||||
request.first_row, request.first_row, -1};
|
||||
if (!present_player_detail)
|
||||
throw FormatError("live player information presenter stopped");
|
||||
const auto return_parent = present_player_detail(services, selection, screen.render());
|
||||
if (!return_parent) throw FormatError("live player information presenter stopped");
|
||||
if (*return_parent) closed = true;
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_lineup");
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "live player information: %s\n", e.what());
|
||||
}
|
||||
screen.resolve_local_navigation(request.kind);
|
||||
redrawn = true;
|
||||
} else if (request.kind == ui::LineupRequestKind::open_pitch) {
|
||||
bool returned_to_lineup = false;
|
||||
try {
|
||||
ui::PitchScreen pitch(data, screen.state(),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
auto pitch_entry = pitch.request_page_control(1);
|
||||
app::LiveSubstitutionResult entry_result;
|
||||
if (pitch_entry.kind == ui::PitchRequestKind::none ||
|
||||
(entry_result = dispatch_pitch(pitch_entry)).status !=
|
||||
app::LiveSubstitutionStatus::applied) {
|
||||
if (pitch_entry.kind != ui::PitchRequestKind::none)
|
||||
pitch.reject_action(entry_result.error.empty()
|
||||
? "Source pitch entry was rejected" : entry_result.error);
|
||||
throw FormatError(entry_result.error.empty()
|
||||
? "Source pitch entry could not be acknowledged" : entry_result.error);
|
||||
}
|
||||
auto entered_lineup = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
entered_lineup.in_match = true; entered_lineup.entry_prepared = true;
|
||||
pitch.acknowledge(std::move(entered_lineup),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_pitch");
|
||||
bool pitch_closed = false;
|
||||
std::optional<SDL_MouseButtonEvent> pitch_down;
|
||||
std::optional<SDL_MouseButtonEvent> pitch_right_down;
|
||||
std::optional<ui::PitchRequest> pitch_down_request;
|
||||
Uint32 pitch_down_at = 0;
|
||||
while (running && !pitch_closed) {
|
||||
const Image pitch_image = pitch.render();
|
||||
for (size_t i = 0; i < pixels.size(); ++i)
|
||||
pixels[i] = palette.argb[pitch_image.pixels[i]];
|
||||
SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_Event child;
|
||||
bool pitch_redrawn = false;
|
||||
while (SDL_PollEvent(&child)) {
|
||||
if (child.type == SDL_QUIT) { running = false; pitch_closed = true; break; }
|
||||
if (child.type == SDL_KEYDOWN && child.key.keysym.sym == SDLK_ESCAPE) {
|
||||
pitch.key("ESC"); pitch_closed = true; closed = true; break;
|
||||
}
|
||||
if (child.type == SDL_MOUSEBUTTONDOWN && child.button.button == SDL_BUTTON_LEFT) {
|
||||
pitch_down = child.button; pitch_down_at = SDL_GetTicks();
|
||||
pitch_down_request = pitch.pointer_down(child.button.x, child.button.y);
|
||||
} else if (child.type == SDL_MOUSEBUTTONDOWN && child.button.button == SDL_BUTTON_RIGHT) {
|
||||
pitch_right_down = child.button;
|
||||
(void)pitch.pointer_down(child.button.x, child.button.y, true);
|
||||
} else if (child.type == SDL_MOUSEBUTTONUP && pitch_down &&
|
||||
child.button.button == SDL_BUTTON_LEFT &&
|
||||
child.button.x == pitch_down->x && child.button.y == pitch_down->y) {
|
||||
pitch_down.reset();
|
||||
auto action = pitch_down_request.value_or(ui::PitchRequest{});
|
||||
pitch_down_request.reset();
|
||||
if (SDL_GetTicks() - pitch_down_at > 500)
|
||||
action = pitch.save_formation(child.button.x, child.button.y);
|
||||
else if (action.kind == ui::PitchRequestKind::none)
|
||||
action = pitch.click(child.button.x, child.button.y);
|
||||
if (action.kind == ui::PitchRequestKind::open_player_info) {
|
||||
try {
|
||||
if (action.row < 0 || size_t(action.row) >= pitch.state().players.size() ||
|
||||
pitch.state().players.at(size_t(action.row)).player_id != action.player_id)
|
||||
throw FormatError("live pitch player information request is stale");
|
||||
auto services = session->live_club_modal_services(live_revision);
|
||||
const ClubPlayerDetailSelection selection{selected_team, action.player_id,
|
||||
action.row, action.row, -1};
|
||||
if (!present_player_detail)
|
||||
throw FormatError("live pitch player information presenter stopped");
|
||||
const auto return_parent = present_player_detail(services, selection, pitch.render());
|
||||
if (!return_parent)
|
||||
throw FormatError("live pitch player information presenter stopped");
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_pitch");
|
||||
if (*return_parent) { pitch_closed = true; closed = true; }
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "live pitch player information: %s\n", e.what());
|
||||
}
|
||||
pitch.resolve_local_navigation(); pitch_redrawn = true;
|
||||
} else if (action.kind != ui::PitchRequestKind::none) {
|
||||
const auto result = dispatch_pitch(action);
|
||||
if (result.status == app::LiveSubstitutionStatus::applied) {
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
pitch.acknowledge(std::move(updated),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
if (action.kind == ui::PitchRequestKind::select_pitch_page &&
|
||||
action.page_control == 1) {
|
||||
pitch_closed = true; returned_to_lineup = true;
|
||||
}
|
||||
} else if (result.status == app::LiveSubstitutionStatus::source_notice) {
|
||||
show_live_substitution_notice(result, pitch.render(),
|
||||
"OpenBMH - live_pitch");
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
pitch = ui::PitchScreen(data, std::move(updated),
|
||||
ui::pitch_extras_from_game(state, season_exe, live_revision, selected_opponent));
|
||||
} else {
|
||||
pitch.reject_action(result.error.empty()
|
||||
? "Der Spielerwechsel ist nicht freigegeben."
|
||||
: result.error);
|
||||
}
|
||||
pitch_redrawn = true;
|
||||
} else pitch_redrawn = true;
|
||||
} else if (child.type == SDL_MOUSEBUTTONUP && pitch_right_down &&
|
||||
child.button.button == SDL_BUTTON_RIGHT &&
|
||||
child.button.x == pitch_right_down->x &&
|
||||
child.button.y == pitch_right_down->y) {
|
||||
pitch_right_down.reset();
|
||||
if (pitch.close_requested()) { pitch_closed = true; closed = true; break; }
|
||||
pitch_redrawn = true;
|
||||
} else if (child.type == SDL_MOUSEMOTION)
|
||||
pitch_redrawn |= pitch.move(child.motion.x, child.motion.y);
|
||||
}
|
||||
if (!pitch_redrawn && !pitch_closed && running) SDL_Delay(8);
|
||||
}
|
||||
SDL_SetWindowTitle(window, "OpenBMH - live_lineup");
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "live pitch: %s\n", e.what());
|
||||
}
|
||||
if (returned_to_lineup) {
|
||||
auto updated = ui::lineup_from_game(state, season_exe, live_revision);
|
||||
updated.in_match = true; updated.entry_prepared = true;
|
||||
screen = ui::LineupScreen(data, std::move(updated));
|
||||
} else if (!closed) screen.resolve_local_navigation(request.kind);
|
||||
redrawn = true;
|
||||
} else redrawn = true;
|
||||
} else if (modal.type == SDL_MOUSEMOTION)
|
||||
} else if (modal.type == SDL_MOUSEMOTION) {
|
||||
redrawn |= screen.move(modal.motion.x, modal.motion.y);
|
||||
}
|
||||
if (closed) break;
|
||||
}
|
||||
if (!redrawn && !closed) SDL_Delay(8);
|
||||
}
|
||||
@@ -2747,6 +2640,9 @@ int main(int argc, char** argv) {
|
||||
case SDLK_DOWN: key = "DOWN"; break;
|
||||
case SDLK_LEFT: key = "LEFT"; break;
|
||||
case SDLK_RIGHT: key = "RIGHT"; break;
|
||||
case SDLK_a:
|
||||
if (file_input.key.keysym.mod & (KMOD_CTRL | KMOD_GUI)) key = "SELECT_ALL";
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (!key.empty()) file_changed |= file_screen.key(key);
|
||||
@@ -3866,6 +3762,11 @@ int main(int argc, char** argv) {
|
||||
std::fprintf(stderr, "input: %s\n", err.what());
|
||||
}
|
||||
}
|
||||
if (e.type == SDL_KEYDOWN && flow.screen_name() == "save_load" &&
|
||||
e.key.keysym.sym == SDLK_a && (e.key.keysym.mod & (KMOD_CTRL | KMOD_GUI))) {
|
||||
handle(flow.send_key("SELECT_ALL"));
|
||||
continue;
|
||||
}
|
||||
if (e.type == SDL_KEYDOWN && (e.key.keysym.sym == SDLK_RETURN || e.key.keysym.sym == SDLK_BACKSPACE ||
|
||||
(flow.screen_name() == "save_load" && (e.key.keysym.sym == SDLK_UP ||
|
||||
e.key.keysym.sym == SDLK_DOWN || e.key.keysym.sym == SDLK_PAGEUP || e.key.keysym.sym == SDLK_PAGEDOWN)) ||
|
||||
|
||||
@@ -1471,6 +1471,9 @@ inline constexpr auto Pitch_Render_TextPointer2 = 0xae0ec;
|
||||
inline constexpr auto Pitch_Render_TextPointer3 = 0xae0f0;
|
||||
inline constexpr auto Pitch_Render_TextPointer4 = 0xae0f4;
|
||||
inline constexpr auto Pitch_Render_TextPointer5 = 0xae0f8;
|
||||
inline constexpr auto PitchOrderPositionPointers = 0xa2a37;
|
||||
inline constexpr auto PitchOrderZoneMasks = 0xa2a4b;
|
||||
inline constexpr auto PitchOrderZoneTextPointers = 0xae818;
|
||||
inline constexpr auto Placements = 0xbd38c;
|
||||
inline constexpr auto PlainBackground = 0xa2569;
|
||||
inline constexpr auto PlanTicketPrice = 0xa4856;
|
||||
|
||||
@@ -80,6 +80,10 @@ target_link_libraries(openbmh_ui PRIVATE bmhui ${BMH_SDL_TARGET})
|
||||
add_executable(ui_setup_tests tests.cpp)
|
||||
target_link_libraries(ui_setup_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME ui_setup_tests COMMAND ui_setup_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(ui_save_load_tests save_load_tests.cpp)
|
||||
target_link_libraries(ui_save_load_tests PRIVATE bmhui)
|
||||
bmh_add_data_test(NAME ui_save_load_tests COMMAND ui_save_load_tests "${BMH_DATA}")
|
||||
add_executable(ui_national_friendly_tests ../../tests/national_friendly_ui_tests.cpp)
|
||||
target_link_libraries(ui_national_friendly_tests PRIVATE bmhui)
|
||||
add_test(NAME ui_national_friendly_tests COMMAND ui_national_friendly_tests)
|
||||
|
||||
+64
-15
@@ -195,6 +195,7 @@ PitchScreen::PitchScreen(const std::filesystem::path& data,LineupState state,Pit
|
||||
PitchScreen::PitchScreen(const PitchScreen& other)
|
||||
:PitchScreen(other.data_,other.state_,other.extras_){
|
||||
pending_=other.pending_;selected_=other.selected_;hovered_=other.hovered_;ghost_=other.ghost_;
|
||||
order_hover_grid_=other.order_hover_grid_;
|
||||
scroll_=other.scroll_;close_=other.close_;return_team_=other.return_team_;rejection_=other.rejection_;
|
||||
weights_dirty_=other.weights_dirty_;
|
||||
shooter_editor_open_=other.shooter_editor_open_;shooter_selection_=other.shooter_selection_;
|
||||
@@ -311,14 +312,18 @@ Image PitchScreen::render()const{
|
||||
for(auto[row,baseline]:rows())if(baseline>34&&baseline<107&&(selected_==row||hovered_==row)){
|
||||
copy(out,background_,13,baseline-5,13,baseline-5,51,6);
|
||||
text(out,13,baseline,state_.players.at(row).name,selected_==row?0x27:0x3e);}
|
||||
if(shooter_editor_open_&&zone_cover_open_){
|
||||
// TestsTemporaryDisplayBitCallsBeff tests the temporary 0x80 display bit and calls DerivesRedCoverage
|
||||
// for each healthy active starter. DerivesRedCoverage derives the red coverage
|
||||
// bounds from the native ORDER bytes at player+2..+4 and clips them
|
||||
// to the Source pitch's x=3..192 / y=113..219 area.
|
||||
for(int row=0;row<11;++row){
|
||||
const auto& p=state_.players.at(size_t(row));
|
||||
if(!(p.slot&0x8000)||((p.attributes.w364>>16)&0x1f)!=0)continue;
|
||||
const auto eligible_order_row = [&](std::optional<int> row) {
|
||||
return row && *row >= 0 && *row < 11 &&
|
||||
(state_.players.at(size_t(*row)).slot & 0x8000) &&
|
||||
((state_.players.at(size_t(*row)).attributes.w364 >> 16) & 0x1f) == 0;
|
||||
};
|
||||
std::optional<int> order_row;
|
||||
if(eligible_order_row(hovered_))order_row=hovered_;
|
||||
else if(eligible_order_row(selected_))order_row=selected_;
|
||||
// Both the order page's hovered player and the taker editor's coverage
|
||||
// toggle use the native ORDER geometry and VGA plane-7 mask.
|
||||
const auto draw_coverage = [&](const LineupPlayer& p) {
|
||||
if(!(p.slot&0x8000)||((p.attributes.w364>>16)&0x1f)!=0)return;
|
||||
const int depth=int8_t(p.board[0x41]),lane=int8_t(p.board[0x42]);
|
||||
const int order_x=p.board[2],order_y=p.board[3];
|
||||
const int zone_count=p.board[4]/2;
|
||||
@@ -355,7 +360,11 @@ Image PitchScreen::render()const{
|
||||
source_mask_copy(out,atlas_,0xc4,0x59,draw_x0,lower,draw_x1-draw_x0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if(shooter_editor_open_&&zone_cover_open_){
|
||||
for(int row=0;row<11;++row)draw_coverage(state_.players.at(size_t(row)));
|
||||
}else if(order_panel_open_&&order_row){
|
||||
draw_coverage(state_.players.at(size_t(*order_row)));
|
||||
}
|
||||
for(int row=0;row<11;++row){const auto& p=state_.players.at(row);if(!(p.slot&0x8000))continue;
|
||||
jersey(out,p,int8_t(p.board[0x41]),int8_t(p.board[0x42]),selected_==row||hovered_==row?3:0);}
|
||||
@@ -423,8 +432,40 @@ Image PitchScreen::render()const{
|
||||
text(out,243,baseline+6,details,0x69);
|
||||
}
|
||||
}
|
||||
if(extras_.mode!=1&&order_panel_open_&&selected_&&*selected_<11){
|
||||
const auto& player=state_.players.at(size_t(*selected_));
|
||||
if(extras_.mode!=1&&order_panel_open_){
|
||||
// The original panel includes its eight atlas controls and up to six
|
||||
// marked substitutes above the order bars; none are generated artwork.
|
||||
for(int side=0;side<2;++side)for(int aspect=0;aspect<4;++aspect)
|
||||
copy(out,atlas_,196+aspect*16,56+side*12,243+side*58,179+aspect*12,15,12,0xc0);
|
||||
int bench_row=0;
|
||||
for(const auto& player:state_.players){
|
||||
if(bench_row==6)break;
|
||||
if(player.player_id<0||!(player.slot&0x4000))continue;
|
||||
const int baseline=118+7*bench_row++;
|
||||
text(out,243,baseline,exe_.string_at_pointer(::bmh::layout::PitchOrderPositionPointers+
|
||||
player.attributes.position()*4),0x6b);
|
||||
std::string name=player.name;
|
||||
while(!name.empty()&&font_.text_width(name)>48)name.pop_back();
|
||||
text(out,252,baseline,name,0x6b);
|
||||
text(out,302,baseline,"("+std::to_string(player.attributes.strength())+")",0x6b);
|
||||
}
|
||||
if(order_hover_grid_){
|
||||
const auto [depth,lane]=*order_hover_grid_;
|
||||
const auto mask=exe_.u16(::bmh::layout::PitchOrderZoneMasks+lane*38+std::min(depth,18)*2);
|
||||
std::string position,zone;
|
||||
const auto label=[&](int bit)->const std::string&{
|
||||
return texts_[(::bmh::layout::PitchOrderZoneTextPointers-::bmh::layout::TextPointerTable)/4+bit];
|
||||
};
|
||||
for(int bit=0;bit<6;++bit)if(mask&(1<<bit)){position=label(bit);break;}
|
||||
for(int bit=6;bit<14;++bit)if(mask&(1<<bit))zone+=label(bit);
|
||||
while(!position.empty()&&font_.text_width(position)>78)position.pop_back();
|
||||
while(!zone.empty()&&font_.text_width(zone)>78)zone.pop_back();
|
||||
text(out,241,165,position,0x6b);
|
||||
text(out,241,173,zone,0x69);
|
||||
}
|
||||
}
|
||||
if(extras_.mode!=1&&order_panel_open_&&order_row){
|
||||
const auto& player=state_.players.at(size_t(*order_row));
|
||||
for(int aspect=0;aspect<4;++aspect){
|
||||
const int y=181+12*aspect,value=player.board[size_t(2+aspect)];
|
||||
if(value){copy(out,atlas_,0x103,0x3b,0x103,y,value,9,0xc0);
|
||||
@@ -529,10 +570,15 @@ PitchRequest PitchScreen::order_request(int aspect,int value){
|
||||
}
|
||||
PitchRequest PitchScreen::click(int x,int y,bool right){
|
||||
if(pending_||close_)return {};
|
||||
if(right){if(selected_){selected_.reset();ghost_.reset();}else {close_=true;zone_cover_open_=false;}return {};}
|
||||
const uint16_t display_word=shooter_editor_open_
|
||||
? uint16_t(extras_.native_display_word&0xff0f)
|
||||
: extras_.native_display_word;
|
||||
if(right){
|
||||
if((display_word&0x08)==0){sheet_->click(x,y,true);close_=sheet_->close_requested();}
|
||||
else if(selected_){selected_.reset();ghost_.reset();}
|
||||
else {close_=true;zone_cover_open_=false;}
|
||||
return {};
|
||||
}
|
||||
if((display_word&0x08)==0){
|
||||
// On the full-sheet redraw, PitchScreen presents its original footer
|
||||
// controls at (1,215) and (58,215): data A/B and the pitch/team page.
|
||||
@@ -694,8 +740,11 @@ PitchRequest PitchScreen::save_formation(int x,int y){
|
||||
pending_=r;return r;
|
||||
}
|
||||
bool PitchScreen::move(int x,int y){if(pending_||close_)return false;
|
||||
if((extras_.native_display_word&0x08)==0)return sheet_->move(x,y);
|
||||
const auto old=hovered_;const auto oldghost=ghost_;hovered_=hit_row(x,y);ghost_=selected_?grid(x,y):std::nullopt;
|
||||
return old!=hovered_||oldghost!=ghost_;
|
||||
const auto old_grid=order_hover_grid_;
|
||||
order_hover_grid_=order_panel_open_?grid(x,y):std::nullopt;
|
||||
return old!=hovered_||oldghost!=ghost_||old_grid!=order_hover_grid_;
|
||||
}
|
||||
PitchRequest PitchScreen::key(std::string_view key){
|
||||
// PitchScreen's desktop pages cancel selection/return on mouse event 8.
|
||||
@@ -862,12 +911,12 @@ void PitchScreen::acknowledge(LineupState s,PitchExtras e){
|
||||
if(kind==PitchRequestKind::set_player_marking){marking_target_row_.reset();}
|
||||
state_=std::move(s);extras_=std::move(e);sheet_=std::move(new_sheet);badge_=std::move(new_badge);
|
||||
scroll_=0;
|
||||
if(kind!=PitchRequestKind::set_player_order){selected_.reset();hovered_.reset();ghost_.reset();}
|
||||
if(kind!=PitchRequestKind::set_player_order){selected_.reset();hovered_.reset();ghost_.reset();order_hover_grid_.reset();}
|
||||
pending_.reset();rejection_.clear();
|
||||
}
|
||||
void PitchScreen::reject_action(std::string reason){if(!pending_||reason.empty())throw FormatError("pitch: rejection requires pending action and reason");
|
||||
if(sheet_->pending())sheet_=std::make_unique<LineupScreen>(data_,state_);
|
||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();marking_target_row_.reset();rejection_=std::move(reason);
|
||||
pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();order_hover_grid_.reset();marking_target_row_.reset();rejection_=std::move(reason);
|
||||
}
|
||||
void PitchScreen::resolve_local_navigation(){
|
||||
if(!pending_||pending_->kind!=PitchRequestKind::open_player_info)
|
||||
|
||||
@@ -116,6 +116,7 @@ private:
|
||||
std::optional<PitchRequest> pending_;
|
||||
std::optional<int> selected_, hovered_;
|
||||
std::optional<std::pair<int,int>> ghost_;
|
||||
std::optional<std::pair<int,int>> order_hover_grid_;
|
||||
int scroll_ = 0;
|
||||
bool close_ = false, return_team_ = false;
|
||||
bool weights_dirty_ = false; // original local_30: reapply current AA after a weight change
|
||||
|
||||
+37
-1
@@ -249,12 +249,48 @@ int main(int argc,char**argv){try{
|
||||
hidden_page.click(241,215).kind==PitchRequestKind::none))&&
|
||||
hidden_page.save_formation(250,166).kind==PitchRequestKind::none&&!hidden_page.pending(),
|
||||
"inactive Source AA page ignores hidden formation, weight and held-save coordinates");
|
||||
if(word==0x08||word==0x28)for(int y=110;y<131;++y)for(int x=243;x<278;++x)
|
||||
if(word==0x08)for(int y=110;y<131;++y)for(int x=243;x<278;++x)
|
||||
check(before.pixels[size_t(y)*before.width+x]==0x42,"inactive Source page does not draw the KB2 formation panel");
|
||||
check(hidden_page.extras().formations==aa.formations&&
|
||||
hidden_page.extras().automatic_weights==aa.automatic_weights,
|
||||
"ignored AA input preserves authoritative templates and packed weights");
|
||||
}
|
||||
auto order_lineup=s;auto order_extras=e;order_extras.native_display_word=0x28;
|
||||
order_lineup.players[0].board[2]=12;order_lineup.players[0].board[3]=10;
|
||||
order_lineup.players[0].board[4]=20;order_lineup.players[0].board[5]=8;
|
||||
PitchScreen orders(data,order_lineup,order_extras);
|
||||
auto order_idle=orders.render();
|
||||
auto order_atlas=load_vga(asset_path(data/"KB","2.VGA"));
|
||||
for(int side=0;side<2;++side)for(int aspect=0;aspect<4;++aspect)
|
||||
for(int y=0;y<12;++y)for(int x=0;x<15;++x){
|
||||
const auto value=order_atlas.at(196+aspect*16+x,56+side*12+y);
|
||||
if(value!=0xc0)check(order_idle.at(243+side*58+x,179+aspect*12+y)==value,
|
||||
"Anweis controls use all eight original atlas sprites");
|
||||
}
|
||||
check(orders.move(20,38),"Anweis accepts hover over the first starter");
|
||||
auto order_hover=orders.render();int coverage_changes=0;
|
||||
for(int y=111;y<220;++y)for(int x=3;x<193;++x)
|
||||
if((order_idle.at(x,y)^order_hover.at(x,y))&0x80)++coverage_changes;
|
||||
check(coverage_changes>100&&!orders.pending()&&orders.state().revision==s.revision&&
|
||||
orders.state().players[0].board==order_lineup.players[0].board,
|
||||
"hover previews the red ORDER coverage without selecting or mutating a player");
|
||||
check(orders.move(150,200),"moving over an empty pitch cell updates its position hints");
|
||||
auto hints=orders.render();int hint_pixels=0;
|
||||
for(int y=159;y<=173;++y)for(int x=241;x<319;++x)
|
||||
if(hints.at(x,y)!=order_idle.at(x,y))++hint_pixels;
|
||||
check(hint_pixels>0&&!orders.pending(),"Anweis cell hints come from runtime zone masks and texts");
|
||||
PitchScreen orders_copy=orders;
|
||||
check(orders_copy.render().pixels==hints.pixels,"copying a preview preserves its hovered position hints");
|
||||
orders.move(220,100);
|
||||
check(orders.render().pixels==order_idle.pixels,"leaving Anweis hover restores the idle page");
|
||||
auto cancel_extras=e;cancel_extras.native_display_word=0;
|
||||
PitchScreen team_cancel(data,s,cancel_extras);
|
||||
team_cancel.click(20,38);
|
||||
team_cancel.pointer_down(310,230,true);
|
||||
check(!team_cancel.close_requested()&&!team_cancel.pending(),
|
||||
"a live-compatible full sheet first cancels its selected player on right press");
|
||||
team_cancel.pointer_down(309,229,true);
|
||||
check(team_cancel.close_requested(),"the next right press leaves the full sheet");
|
||||
auto hall_pages=aa;hall_pages.indoor=true;
|
||||
PitchScreen hall_transition(data,s,hall_pages);
|
||||
const auto instructions=hall_transition.click(210,154);
|
||||
|
||||
+19
-9
@@ -101,6 +101,9 @@ SaveLoadScreen::SaveLoadScreen(const std::filesystem::path& data, std::filesyste
|
||||
});
|
||||
} else feedback_ = "VERZEICHNIS NICHT VERFUEGBAR";
|
||||
if (mode_ == SaveLoadMode::save && !entries_.empty()) filename_ = path_to_utf8(entries_.front().path.stem());
|
||||
// OpenBMH deviates from the original: focuses the host save filename on entry and selects an existing name for replacement.
|
||||
filename_focus_ = mode_ == SaveLoadMode::save;
|
||||
filename_selected_ = filename_focus_ && !filename_.empty();
|
||||
}
|
||||
|
||||
Image SaveLoadScreen::render() const {
|
||||
@@ -126,7 +129,7 @@ Image SaveLoadScreen::render() const {
|
||||
text(out, 55, 216, original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer4)), 0x6c, 50, footer_font_, true);
|
||||
const std::string displayed_filename = mode_ == SaveLoadMode::load && selected_ >= 0 &&
|
||||
size_t(selected_) < entries_.size() ? path_to_utf8(entries_[size_t(selected_)].path.stem()) : filename_;
|
||||
text(out, 106, 216, displayed_filename, 0x6c, 140, footer_font_, true);
|
||||
text(out, 106, 216, displayed_filename, filename_selected_ ? 0x27 : 0x6c, 140, footer_font_, true);
|
||||
|
||||
if (entries_.size() > 15) {
|
||||
button(out, 206, 183, 56, original_to_utf8(exe_.cstring(::bmh::layout::SaveLoad_Render_ExecutableField)));
|
||||
@@ -282,7 +285,9 @@ bool SaveLoadScreen::select_row(int y) {
|
||||
if (row < 0 || row >= int(entries_.size())) return false;
|
||||
selected_ = row;
|
||||
if (mode_ == SaveLoadMode::save) filename_ = path_to_utf8(entries_[size_t(row)].path.stem());
|
||||
filename_focus_ = false; overwrite_armed_ = false; feedback_.clear();
|
||||
filename_focus_ = mode_ == SaveLoadMode::save;
|
||||
filename_selected_ = filename_focus_;
|
||||
overwrite_armed_ = false; feedback_.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,7 +317,9 @@ void SaveLoadScreen::request_action() {
|
||||
|
||||
bool SaveLoadScreen::click(int x, int y, bool right) {
|
||||
if (info_) { info_.reset(); return true; }
|
||||
if (pending_ || right) return false;
|
||||
if (pending_) return false;
|
||||
// OpenBMH deviates from the original: permits cancelling host file dialogs with the right mouse button.
|
||||
if (right) { close_requested_ = true; return true; }
|
||||
if (x >= 206 && y >= 60 && y <= 169)
|
||||
return false; // Source drive/delete controls have no host mapping in this slice.
|
||||
if (entries_.size() > 15 && x >= 206 && x <= 262 && y >= 183 && y <= 193) {
|
||||
@@ -329,7 +336,7 @@ bool SaveLoadScreen::click(int x, int y, bool right) {
|
||||
return true;
|
||||
}
|
||||
if (mode_ == SaveLoadMode::save && x >= 52 && x < 262 && y >= 209 && y < 219) {
|
||||
filename_focus_ = true; feedback_.clear(); return true;
|
||||
filename_focus_ = true; filename_selected_ = true; feedback_.clear(); return true;
|
||||
}
|
||||
if (x >= 52 && x < 262 && y >= 196 && y < 206) return false;
|
||||
return false;
|
||||
@@ -350,13 +357,15 @@ bool SaveLoadScreen::key(std::string_view value) {
|
||||
}
|
||||
}
|
||||
if (mode_ == SaveLoadMode::save && filename_focus_) {
|
||||
if (value == "SELECT_ALL") { filename_selected_ = true; return true; }
|
||||
if (value == "BACKSPACE") {
|
||||
if (!filename_.empty()) {
|
||||
if (filename_selected_) filename_.clear();
|
||||
else if (!filename_.empty()) {
|
||||
size_t last = filename_.size() - 1;
|
||||
while (last > 0 && (uint8_t(filename_[last]) & 0xc0) == 0x80) --last;
|
||||
filename_.erase(last);
|
||||
}
|
||||
overwrite_armed_ = false; return true;
|
||||
filename_selected_ = false; overwrite_armed_ = false; return true;
|
||||
}
|
||||
if (value == "ENTER") { request_action(); return true; }
|
||||
}
|
||||
@@ -365,9 +374,10 @@ bool SaveLoadScreen::key(std::string_view value) {
|
||||
}
|
||||
|
||||
bool SaveLoadScreen::text(std::string_view value) {
|
||||
if (info_ || mode_ != SaveLoadMode::save || !filename_focus_ || pending_ || value.empty() ||
|
||||
!valid_filename(filename_ + std::string(value))) return false;
|
||||
filename_ += value;
|
||||
if (info_ || mode_ != SaveLoadMode::save || !filename_focus_ || pending_ || value.empty()) return false;
|
||||
const std::string next = (filename_selected_ ? std::string{} : filename_) + std::string(value);
|
||||
if (!valid_filename(next)) return false;
|
||||
filename_ = next; filename_selected_ = false;
|
||||
overwrite_armed_ = false; feedback_.clear(); return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ private:
|
||||
std::vector<SaveLoadEntry> entries_;
|
||||
int selected_ = 0, scroll_ = 0;
|
||||
std::string filename_, feedback_;
|
||||
bool filename_focus_ = false, overwrite_armed_ = false, close_requested_ = false;
|
||||
bool filename_focus_ = false, filename_selected_ = false;
|
||||
bool overwrite_armed_ = false, close_requested_ = false;
|
||||
int last_clicked_row_ = -1;
|
||||
std::optional<SaveLoadRequest> pending_;
|
||||
struct InfoRow { std::string manager, club, league; };
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "ui/save_load.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
using namespace bmh::ui;
|
||||
|
||||
namespace {
|
||||
void check(bool value, const char* message) {
|
||||
if (!value) throw std::runtime_error(message);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
if (argc != 2) throw std::runtime_error("save/load tests require externally supplied game assets");
|
||||
const auto root = std::filesystem::temp_directory_path() /
|
||||
("openbmh-file-input-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
std::filesystem::create_directories(root);
|
||||
struct Cleanup {
|
||||
std::filesystem::path path;
|
||||
~Cleanup() { std::error_code error; std::filesystem::remove_all(path, error); }
|
||||
} cleanup{root};
|
||||
const Image backdrop(320, 240, 0x42);
|
||||
for (const auto [kind, extension] : {
|
||||
std::pair{SaveLoadFileKind::game, ".FBM"},
|
||||
std::pair{SaveLoadFileKind::settings, ".EIN"},
|
||||
std::pair{SaveLoadFileKind::menu_layout, ".MEN"}}) {
|
||||
std::ofstream(root / (std::string("Existing") + extension)) << "authored filename fixture";
|
||||
SaveLoadScreen load(argv[1], root, SaveLoadMode::load, 0, 7, backdrop, true, kind);
|
||||
check(load.click(0, 0, true) && load.close_requested() && !load.pending(),
|
||||
"right-click closes every file picker without submitting a load");
|
||||
SaveLoadScreen save(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
|
||||
check(save.text("Custom"), "a save picker accepts a new name immediately after opening");
|
||||
check(save.text(" Name"), "subsequent text appends to the edited name");
|
||||
save.key("ENTER");
|
||||
check(save.pending() && save.pending()->path.filename() == std::string("Custom Name") + extension &&
|
||||
!save.pending()->overwrite, "new typing replaces the prefilled filename and keeps its file kind");
|
||||
check(!save.click(0, 0, true) && !save.close_requested(),
|
||||
"a submitted file operation retains ownership until acknowledged or rejected");
|
||||
save.reject("authored refusal");
|
||||
check(save.click(0, 0, true) && save.close_requested(),
|
||||
"a rejected save can be cancelled with the right mouse button");
|
||||
SaveLoadScreen edit(argv[1], root, SaveLoadMode::save, 0, 7, backdrop, true, kind);
|
||||
edit.click(120, 214); edit.key("BACKSPACE");
|
||||
check(edit.text("Long Name") && edit.key("SELECT_ALL") && edit.text("Short"),
|
||||
"clicking and select-all permit replacing a whole filename");
|
||||
check(edit.text("\xc3\x84") && edit.key("BACKSPACE"), "backspace removes a complete UTF-8 character");
|
||||
edit.key("ENTER");
|
||||
check(edit.pending() && edit.pending()->path.filename() == std::string("Short") + extension,
|
||||
"editing and UTF-8 deletion preserve the resulting host filename");
|
||||
}
|
||||
std::cout << "save/load input checks passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user