Fix save loading at the national desk, calendar colours, pointer size; add -debug
- Loading: a single-manager desk saved with DeskPosition == ManagerCount (the completed loop) is read as the first desk again instead of being refused as "not a savegame". - Calendar: text takes the original's six-row colour gradient (the flat colours were too dark next to the original). - Pointer: sized in window points, so it is not doubled on Retina screens. - Settings: the page names OpenBMH and shows the build version below. - Desk: the opponent's badge is shown whenever the data has one (documented difference); cup-only teams keep the computer portrait. - Live overview tests: Tabelle/Stärken/Spiele handovers, also with the Spiele page opened first. - New command line option -debug: timestamped log, stderr captured in a file, and a savegame after every match day in <saves>/debug. Refs #63, #65, #67, #68, #71, #73. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e7df751a0
commit
38f69fa37b
15 files changed
+234
-13
No files matched your search
+23
-2
@@ -77,9 +77,30 @@ CalendarScreen::CalendarScreen(const std::filesystem::path& data, CalendarState
|
||||
void CalendarScreen::text(Image& out, int x, int baseline, std::string_view bytes, uint8_t color) const {
|
||||
// TextWidth3 refuses text outside the original screen; no UTF-8 enters BMH3.
|
||||
const int top = baseline - font_.baseline;
|
||||
if (x >= 0 && top >= 0 && top + font_.height <= out.height &&
|
||||
x + font_.text_width(bytes) <= out.width)
|
||||
if (!(x >= 0 && top >= 0 && top + font_.height <= out.height &&
|
||||
x + font_.text_width(bytes) <= out.width)) return;
|
||||
// With the gradient on, every set pixel of a glyph takes the colour its row has in the original's
|
||||
// table for this palette token (six rows per token); a token the table does not know stays flat.
|
||||
unsigned slot = 0;
|
||||
while (slot < 32 && exe_.u8(::bmh::layout::Advertising_Text_RuntimeField2 + slot) != color) ++slot;
|
||||
if (!state_.gradient_text || slot == 32) {
|
||||
font_.draw(out, x, top, bytes, color);
|
||||
return;
|
||||
}
|
||||
int pen_x = x;
|
||||
for (unsigned char ch : bytes) {
|
||||
const auto& glyph = font_.glyph(ch);
|
||||
for (int row = 0; row < font_.height; ++row) {
|
||||
const uint8_t row_color = exe_.u8(::bmh::layout::Advertising_Text_RuntimeField + slot * 6 + std::min(row, 5));
|
||||
if (row_color == 0) continue;
|
||||
for (int col = 0; col < glyph.bit_width; ++col) {
|
||||
const int bit = glyph.bit_offset + col;
|
||||
if (!(font_.bitmap[size_t(row) * font_.modulo + bit / 8] & (0x80 >> (bit % 8)))) continue;
|
||||
out.at(pen_x + col, top + row) = row_color;
|
||||
}
|
||||
}
|
||||
pen_x += glyph.advance;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CalendarScreen::information(const CalendarDayProjection& day) const {
|
||||
|
||||
@@ -105,6 +105,10 @@ CalendarState calendar_from_game(const GameState& game, const LeImage& executabl
|
||||
if (current_display >= int(state.days.size()))
|
||||
throw FormatError("calendar: current date is outside the season calendar");
|
||||
state.current_day = current_display;
|
||||
// TextGradientDisabled (a settings switch) clear and the edition's gradient mode 2: the text
|
||||
// takes the original's six-row colour table, as on every other page.
|
||||
state.gradient_text = !game.memory.has(::bmh::layout::TextGradientDisabled) ||
|
||||
(game.memory.u8(::bmh::layout::TextGradientDisabled) == 0 && executable.u8(::bmh::layout::TextGradientMode) == 2);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ struct CalendarState {
|
||||
bool friendly_selection = false;
|
||||
std::vector<RescheduleOption> reschedule_options;
|
||||
std::vector<LeagueMatchRef> moved_matches;
|
||||
bool gradient_text = true; // six-row colour table of the original instead of flat colours
|
||||
};
|
||||
|
||||
// Projects the current saved season without preparing fixtures, advancing the date,
|
||||
|
||||
@@ -621,7 +621,10 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
*d.next_opponent < int(g.club_ids.size())) {
|
||||
const int opponent = *d.next_opponent;
|
||||
d.next_opponent_name = g.club_name(opponent);
|
||||
const bool fallback = original_badge_fallback(opponent,&exe);
|
||||
// OpenBMH deviates from the original: the desk shows the opponent's badge whenever the data has one.
|
||||
// The original draws a computer icon for the clubs between its two gate values (the foreign league
|
||||
// clubs); only the cup-only teams and the empty selector keep the icon.
|
||||
const bool fallback = (opponent & 0xfff) == 0xfff || (opponent >= 168 && opponent < 357);
|
||||
d.next_opponent_badge_fallback = fallback;
|
||||
if (!fallback) {
|
||||
const size_t badge_at = size_t(opponent) * 2;
|
||||
|
||||
@@ -1123,12 +1123,19 @@ int main(int argc, char** argv) {
|
||||
auto special=desk_from_game(special_game,exe,10,&prepared,34);
|
||||
check(special.next_competition_label==desk_texts[(::bmh::layout::DeskState_FormatError_RuntimeField4-::bmh::layout::TextPointerTable)/4],
|
||||
"Source calendar entry 4006 selects the special competition title");
|
||||
MatchGroup fallback_badge_group=cup_fixture;fallback_badge_group.fixtures={12,100};
|
||||
// OpenBMH shows a club badge for every league club; only the cup-only teams keep the computer portrait.
|
||||
MatchGroup fallback_badge_group=cup_fixture;fallback_badge_group.fixtures={12,200};
|
||||
std::vector<MatchGroup> fallback_badge_groups{fallback_badge_group};
|
||||
auto fallback_badge=desk_from_game(match_game,exe,10,&fallback_badge_groups,34);
|
||||
check(fallback_badge.next_opponent==100&&fallback_badge.next_opponent_badge_fallback&&
|
||||
check(fallback_badge.next_opponent==200&&fallback_badge.next_opponent_badge_fallback&&
|
||||
!fallback_badge.next_opponent_badge,
|
||||
"legacy routine special team range uses its computer-portrait fallback");
|
||||
"a cup-only team uses its computer-portrait fallback");
|
||||
fallback_badge_group.fixtures={12,100};
|
||||
fallback_badge_groups={fallback_badge_group};
|
||||
auto foreign_badge=desk_from_game(match_game,exe,10,&fallback_badge_groups,34);
|
||||
check(foreign_badge.next_opponent==100&&!foreign_badge.next_opponent_badge_fallback&&
|
||||
foreign_badge.next_opponent_badge,
|
||||
"a foreign league club shows its badge");
|
||||
prepared.clear();
|
||||
auto other_fixture = league_fixture; other_fixture.fixtures={13,14}; prepared.push_back(other_fixture);
|
||||
auto unmatched = desk_from_game(match_game,exe,10,&prepared,34);
|
||||
|
||||
+12
-1
@@ -51,6 +51,11 @@ std::string number(int value) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::string& product_version() { static std::string version; return version; }
|
||||
}
|
||||
void set_settings_product_version(std::string version) { product_version() = std::move(version); }
|
||||
|
||||
std::array<uint8_t, 180> project_settings_availability(
|
||||
const std::array<uint8_t, 180>& raw_cells, const SettingsAvailabilityInputs& in,
|
||||
const LeImage& exe) {
|
||||
@@ -210,7 +215,13 @@ Image SettingsScreen::render() const {
|
||||
}
|
||||
sprite_font_.draw(out, SpriteFont::centered_title_x(sprite_font_.text_width(state_.title)), 13, state_.title);
|
||||
sprite_font_.draw(out, 5, 235, state_.footer);
|
||||
text(out, 2, 41, utf8_to_original(state_.version), 0x5f, 58);
|
||||
// OpenBMH deviates from the original: the settings page names the product and its build version instead of the original's version text.
|
||||
if (product_version().empty()) {
|
||||
text(out, 2, 41, utf8_to_original(state_.version), 0x5f, 58);
|
||||
} else {
|
||||
text(out, 2, 41, "OpenBMH", 0x5f, 58);
|
||||
text(out, 2, 49, utf8_to_original(product_version()), 0x5f, 58);
|
||||
}
|
||||
for (int col = 0; col < 9; ++col) {
|
||||
const auto label = std::to_string(col + 1);
|
||||
// DrawnFirstBy uses x directly when right=-1 and shadow=0x40.
|
||||
|
||||
@@ -64,6 +64,10 @@ SettingsState settings_from_game(const GameState&, int manager, uint64_t revisio
|
||||
std::optional<uint32_t> settings_source_refusal(const GameState& state,
|
||||
const SettingsWriteRequest& request, uint64_t revision);
|
||||
|
||||
// The product line of the settings page: "OpenBMH" and, below it, this build's version. Set once by the
|
||||
// application (the UI library does not include the generated version); empty keeps the original text.
|
||||
void set_settings_product_version(std::string version);
|
||||
|
||||
class SettingsScreen {
|
||||
public:
|
||||
SettingsScreen(const std::filesystem::path& data, SettingsState state, int origin_item_id = -1);
|
||||
|
||||
Reference in new issue
Block a user