diff --git a/src/ui/stadium.cpp b/src/ui/stadium.cpp index 9813075..26be94d 100644 --- a/src/ui/stadium.cpp +++ b/src/ui/stadium.cpp @@ -858,6 +858,12 @@ void StadiumScreen::render_panorama(Image& out) const { } if (periphery_hover_ < 0) return; const size_t object = size_t(periphery_hover_); + { + // the hit rectangle of the object under the pointer, framed in yellow as on the advertising page + const size_t at = ::bmh::layout::Stadium_PeripheryObjectContains_ExecutableField + object * 8; + const int left = exe_.u16(at), top = exe_.u16(at + 2), right = exe_.u16(at + 4), bottom = exe_.u16(at + 6); + outline(out, left, top, right - left + 1, bottom - top + 1, 0x27); + } copy_crop(out, periphery_overlay_, 8, 7, 26, 32, 180, 27); const bool busy = state_.days[object] != 0; const std::string title = texts_[text_id(::bmh::layout::Stadium_RenderPanorama_TextPointer + unsigned(object) * 4)] + @@ -932,6 +938,7 @@ Image StadiumScreen::render_scene() const { copy_crop(out, panel_, 219, row_y - 19, 220, row_y + 1, 98, 22); } source_border(out, 219, row_y, 318, row_y + 23); + if (pressed_ == Pressed::none && hover_block_ == int(i)) outline(out, 219, row_y, 100, 24, 0x27); const auto& block = state_.blocks[i]; std::string label = texts_[text_id(::bmh::layout::Stadium_Out_TextPointer)]; if (label.size() > 6) label[6] = char('A' + i); @@ -997,7 +1004,8 @@ Image StadiumScreen::render_scene() const { text_at(out, x + (0x35 - label_width) / 2, y + 0x1b, tier, 0x5f); } } - if (pressed_ == Pressed::investment && pressed_index_ == int(choice)) + if ((pressed_ == Pressed::investment && pressed_index_ == int(choice)) || + (pressed_ == Pressed::none && hover_investment_ == int(choice))) outline(out, x, y, 0x35, 0x1d, 0x27); if (future_information_ && row.construction_weeks) { const std::string weeks = format_number(GameState{}, row.construction_weeks, 0x82) + @@ -1454,7 +1462,23 @@ bool StadiumScreen::pointer_down(int x, int y, bool right) { bool StadiumScreen::pointer_move(int x, int y) { if (calculator_source_waiting()) return false; if (pressed_ == Pressed::none) { - if (!panorama_ || pending_ || state_.quoted_object || state_.data) return false; + if (pending_ || state_.quoted_object || state_.data) return false; + if (!panorama_) { + // the same targets a click acts on: an available investment icon or a finished seat block + int investment = -1, block = -1; + if (y >= 153 && y <= 211 && x >= 3 && x <= 217) { + const int choice = ((y - 153) / 30) * 4 + (x - 3) / 54; + if (choice >= 0 && choice < 8 && state_.investments_enabled && state_.investments[size_t(choice)].available) + investment = choice; + } else if (x >= 219 && x <= 319 && y >= 22 && y <= 213) { + const int slot = (y - 22) / 24; + if (slot >= 0 && slot < 8 && state_.blocks[size_t(slot)].construction_weeks == 0) block = slot; + } + const bool changed = investment != hover_investment_ || block != hover_block_; + hover_investment_ = investment; + hover_block_ = block; + return changed; + } const int hover = periphery_object_at(x, y); if (hover == periphery_hover_) return false; periphery_hover_ = hover; @@ -1564,8 +1588,8 @@ StadiumRequest StadiumScreen::release(int x, int y, bool right) { return emit(request(StadiumRequestKind::set_data_ticket_price, index - 8 + 10)); } if (pressed == Pressed::scene_button) { - if (index == 0) { panorama_ = !panorama_; future_information_ = false; periphery_hover_ = -1; return {}; } - if (index == 1) { future_information_ = !future_information_; periphery_hover_ = -1; return {}; } + if (index == 0) { panorama_ = !panorama_; future_information_ = false; periphery_hover_ = -1; hover_investment_ = hover_block_ = -1; return {}; } + if (index == 1) { future_information_ = !future_information_; periphery_hover_ = -1; hover_investment_ = hover_block_ = -1; return {}; } return emit(request(StadiumRequestKind::open_data)); } if (pressed == Pressed::investment) diff --git a/src/ui/stadium.hpp b/src/ui/stadium.hpp index cf31d67..56203ee 100644 --- a/src/ui/stadium.hpp +++ b/src/ui/stadium.hpp @@ -235,6 +235,9 @@ private: int pressed_x_ = -1, pressed_y_ = -1; std::optional tip_dialog_, periphery_dialog_; int periphery_hover_ = -1; + // Yellow frame under the pointer, as on the advertising page: an investment icon or a seat block + // that a click would act on (-1 none). + int hover_investment_ = -1, hover_block_ = -1; int periphery_object_at(int x, int y) const; bool periphery_object_contains(int object, int x, int y) const; void render_panorama(Image&) const; diff --git a/tests/stadium_block_ui_tests.cpp b/tests/stadium_block_ui_tests.cpp index 8280376..cc35bd5 100644 --- a/tests/stadium_block_ui_tests.cpp +++ b/tests/stadium_block_ui_tests.cpp @@ -1121,6 +1121,22 @@ namespace { void source_stadium_data_controls(const std::filesystem::path& data) { const auto exe = load_le(asset_path(data, "BMH.exe")); auto state = overview_state(); + { + // the yellow hover frame of the advertising page: over a seat block and over an investment icon + StadiumScreen scene(data, state); + const auto plain = scene.render().pixels; + if (state.blocks[0].construction_weeks == 0) { + check(scene.pointer_move(250, 30) && scene.render().pixels != plain, "a seat block is framed under the pointer"); + check(scene.pointer_move(100, 100) && scene.render().pixels == plain, "and the frame is gone when the pointer leaves"); + } + for (int choice = 0; choice < 8 && state.investments_enabled; ++choice) { + if (!state.investments[size_t(choice)].available) continue; + check(scene.pointer_move(8 + (choice % 4) * 54, 158 + (choice / 4) * 30) && scene.render().pixels != plain, + "an available investment icon is framed under the pointer"); + check(scene.pointer_move(100, 100) && scene.render().pixels == plain, "and the frame is gone when the pointer leaves"); + break; + } + } StadiumScreen overview(data, state); check(overview.pointer_down(265, 220), "Original stadium data button binds on DOWN"); const auto held_overview=overview.state_json();