diff --git a/src/app/main.cpp b/src/app/main.cpp index 3e17bf2..052a67c 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -4180,6 +4180,19 @@ int main(int argc, char** argv) { // Remember where the right press began, to detect releases without a matching press. if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_RIGHT) right_press_screen = flow.screen_name(); + // Buttons without a lasting state look pressed while the mouse button is held (bank, offer editor, + // lineup, pitch). The pitch runs its action at the press itself, so the pressed look is held briefly. + if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_LEFT && + flow.press_hold(e.button.x, e.button.y)) { + const auto image = process_timer_image(flow.render()); + for (size_t i = 0; i < pixels.size(); ++i) pixels[i] = palette.argb[image.pixels[i]]; + SDL_UpdateTexture(texture, nullptr, pixels.data(), 320 * 4); + SDL_RenderClear(renderer); + SDL_RenderCopy(renderer, texture, nullptr, nullptr); + SDL_RenderPresent(renderer); + dirty = false; + if (flow.in_pitch()) SDL_Delay(90); + } // Screens that react to the press itself get pointer_down() now. if(!selector_consumed&&e.type==SDL_MOUSEBUTTONDOWN&&(flow.desktop()||flow.in_balance()||flow.in_desk_records()||flow.in_achievements()||flow.in_indoor_standings()||flow.in_reschedule_calendar()||flow.in_league_pairings()||flow.in_family_table()||flow.in_toto_calculator()||flow.in_stadium()||flow.in_environment()||flow.in_strengths()||flow.in_top_scorers()||flow.in_opportunities()||flow.in_statistics_menu()||flow.in_statistics_page()||flow.in_analytics()||flow.in_other_games()||flow.in_pitch()||flow.in_settings())&& (e.button.button==SDL_BUTTON_LEFT||e.button.button==SDL_BUTTON_RIGHT)) { diff --git a/src/ui/bank.cpp b/src/ui/bank.cpp index 88cd49b..eab2067 100644 --- a/src/ui/bank.cpp +++ b/src/ui/bank.cpp @@ -5,6 +5,7 @@ // accepts a request. #include "formats/executable_layout.hpp" #include "ui/bank.hpp" +#include "ui/button_frame.hpp" #include "ui/game_end.hpp" #include @@ -782,16 +783,13 @@ Image BankScreen::render() const { } const auto draw_button = [&](int x, uint32_t text_address) { constexpr int y = 174, button_width = 64; - rect(out, x + 2, y + 10, button_width, 2, 0x40); rect(out, x + button_width, y + 2, 2, 10, 0x40); - copy_region(out, widgets_, 24, 74, x, y, 31, 10); - int at = 31, remaining = button_width - 31; - while (remaining > 20) { const int n = std::min(8, remaining - 20); copy_region(out, widgets_, 24, 84, x + at, y, n, 10); at += n; remaining -= n; } - if (remaining > 0) copy_region(out, widgets_, 45 - remaining, 94, x + at, y, remaining, 10); + const bool down = pressed_button_ == (x < 100 ? 0 : 1); + const int shift = draw_wide_button_frame(out, widgets_, x, y, button_width, down); const size_t id = text_id(text_address); if (id < texts_.strings.size()) { const std::string label = original_to_utf8(texts_[id]); - sprite_font_.draw(out, x + (button_width - sprite_font_.text_width(label)) / 2, y + 7, - label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)); + sprite_font_.draw(out, x + shift + (button_width - sprite_font_.text_width(label)) / 2, y + shift + 7, + label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(down))); } }; draw_button(60, ::bmh::layout::Bank_FormatError_RuntimeField18 + 4 * 4); @@ -831,18 +829,10 @@ Image BankScreen::render() const { draw_property_card(out, selected_fund_, 124, false); const auto source_button = [&](int x, std::string_view label) { constexpr int width = 64, y = 174; - rect(out, x + 2, y + 10, width, 2, 0x40); - rect(out, x + width, y + 2, 2, 10, 0x40); - copy_region(out, widgets_, 24, 74, x, y, 31, 10); - int at = 31, remaining = width - 31; - while (remaining > 20) { - const int n = std::min(8, remaining - 20); - copy_region(out, widgets_, 24, 84, x + at, y, n, 10); - at += n; remaining -= n; - } - if (remaining > 0) copy_region(out, widgets_, 45 - remaining, 94, x + at, y, remaining, 10); - sprite_font_.draw(out, x + (width - sprite_font_.text_width(label)) / 2, y + 7, - label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)); + const bool down = pressed_button_ == (x < 100 ? 0 : 1); + const int shift = draw_wide_button_frame(out, widgets_, x, y, width, down); + sprite_font_.draw(out, x + shift + (width - sprite_font_.text_width(label)) / 2, y + shift + 7, + label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(down))); }; source_button(60, original_to_utf8(texts_[191])); source_button(185, original_to_utf8(texts_[192])); @@ -924,13 +914,10 @@ Image BankScreen::render() const { if (visible_tip_) body_baseline(out, 200, 167, db(::bmh::layout::Bank_FormatError_RuntimeField19 + uint32_t(*visible_tip_) * 4), 0xf7); auto source_button = [&](int x, std::string_view label) { constexpr int width = 64, y = 174; - rect(out, x + 2, y + 10, width, 2, 0x40); rect(out, x + width, y + 2, 2, 10, 0x40); - copy_region(out, widgets_, 24, 74, x, y, 31, 10); - int at = 31, remain = width - 31; - while (remain > 20) { const int n = std::min(8, remain - 20); copy_region(out, widgets_, 24, 84, x + at, y, n, 10); at += n; remain -= n; } - if (remain > 0) copy_region(out, widgets_, 45 - remain, 94, x + at, y, remain, 10); - sprite_font_.draw(out, x + (width - sprite_font_.text_width(label)) / 2, y + 7, - label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)); + const bool down = pressed_button_ == (x < 100 ? 0 : 1); + const int shift = draw_wide_button_frame(out, widgets_, x, y, width, down); + sprite_font_.draw(out, x + shift + (width - sprite_font_.text_width(label)) / 2, y + shift + 7, + label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(down))); }; source_button(60, original_to_utf8(texts_[191])); source_button(185, original_to_utf8(texts_[192])); @@ -948,18 +935,10 @@ Image BankScreen::render() const { body_baseline(out, 195, 82, state_.deposit_text.empty() ? money(state_.deposit) : state_.deposit_text, 0x00); auto source_button = [&](int x, std::string_view label) { const int width = 64, y = 174; - rect(out, x + 2, y + 10, width, 2, 0x40); - rect(out, x + width, y + 2, 2, 10, 0x40); - copy_region(out, widgets_, 24, 74, x, y, 31, 10); - int at = 31, remaining = width - 31; - while (remaining > 20) { - const int n = std::min(8, remaining - 20); - copy_region(out, widgets_, 24, 84, x + at, y, n, 10); - at += n; remaining -= n; - } - if (remaining > 0) copy_region(out, widgets_, 45 - remaining, 94, x + at, y, remaining, 10); - sprite_font_.draw(out, x + (width - sprite_font_.text_width(label)) / 2, y + 7, label, - exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)); + const bool down = pressed_button_ == (x < 100 ? 0 : 1); + const int shift = draw_wide_button_frame(out, widgets_, x, y, width, down); + sprite_font_.draw(out, x + shift + (width - sprite_font_.text_width(label)) / 2, y + shift + 7, label, + exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(down))); }; source_button(60, original_to_utf8(texts_[193])); source_button(185, original_to_utf8(texts_[194])); @@ -1011,7 +990,22 @@ BankRequest BankScreen::submit() { state_.revision, withdrawing_ ? -int32_t(value) : int32_t(value)}; pending_ = request; feedback_.clear(); return request; } +// Mouse DOWN on one of the two bottom buttons (Kaufen/Verkaufen, Einzahlen/Abheben, OK/Abbruch of a credit): the button +// is drawn pressed until the release. Returns true when the picture changed. +bool BankScreen::press(int x, int y) { + int id = -1; + const bool has_buttons = (exchange_open_ || property_open_ || deposit_open_ || credit_open_) && !calculator_open_ && + !credit_notice_open_ && !credit_fee_confirmation_open_ && !property_notice_open_ && !investment_warning_open_ && !pending_; + if (has_buttons && y >= 174 && y <= 184) { + if (x >= 60 && x <= 124) id = 0; + else if (x >= 185 && x <= 249) id = 1; + } + const bool changed = id != pressed_button_; + pressed_button_ = id; + return changed; +} BankRequest BankScreen::click(int x, int y, bool right) { + pressed_button_ = -1; // the release ends the pressed look if (credit_notice_open_) { if (right || (x >= 95 && x <= 220 && y >= 166 && y <= 176)) { credit_notice_open_ = false; diff --git a/src/ui/bank.hpp b/src/ui/bank.hpp index 69a0beb..e8f6884 100644 --- a/src/ui/bank.hpp +++ b/src/ui/bank.hpp @@ -112,6 +112,8 @@ public: BankScreen(const std::filesystem::path&, BankState); Image render() const; BankRequest click(int x, int y, bool right = false); + // Mouse DOWN: draws the bottom button under the pointer pressed until the release (click()). + bool press(int x, int y); BankRequest key(std::string_view); bool text(std::string_view); bool close_requested() const { return close_requested_; } @@ -153,6 +155,7 @@ private: bool credit_fee_confirmation_open_ = false, credit_notice_open_ = false; bool credit_fees_accepted_ = false; bool selling_shares_ = false; + int pressed_button_ = -1; // 0 left, 1 right bottom button while the mouse button is held bool calculator_stock_count_ = false; bool calculator_property_count_ = false; int selected_stock_ = 11; diff --git a/src/ui/bank_tests.cpp b/src/ui/bank_tests.cpp index 7c7f06b..b340f8b 100644 --- a/src/ui/bank_tests.cpp +++ b/src/ui/bank_tests.cpp @@ -27,6 +27,16 @@ int main(int argc, char** argv) { check(screen.render().width == 320, "original bank room canvas"); check(screen.click(270, 90).kind == BankRequestKind::none && screen.state_json().find("\"deposit_open\":true") != std::string::npos, "Kasse opens the deposit view locally"); + { // a bottom button looks pressed while the mouse button is held and normal again after the release + const auto raised = screen.render(); + check(!screen.press(10, 10), "no pressed look outside the buttons"); + check(screen.press(90, 180) && screen.render().pixels != raised.pixels, "Einzahlen shows the pressed look"); + check(!screen.press(90, 180), "an unchanged press does not redraw"); + screen.click(90, 180); + screen.click(0, 0, true); // back to the Sparbuch page (the calculator was opened by the click) + screen.click(270, 90); + check(screen.render().pixels == raised.pixels, "the release ends the pressed look"); + } screen.click(90, 180); check(screen.calculator_open(), "Einzahlen button opens the original calculator"); check(!screen.text("-500"), "rejects non-digit input"); diff --git a/src/ui/button_frame.hpp b/src/ui/button_frame.hpp new file mode 100644 index 0000000..95614a7 --- /dev/null +++ b/src/ui/button_frame.hpp @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-3.0-only +// The frame of a wide push button (width > 31) as every dialog of the game draws it, in both looks: +// raised - drop shadow at the right and bottom, bevel art at y=74 of the widget image; +// pressed - no shadow, the button moved two pixels down and right, bevel art at y=44. +// A button without a lasting state (Kaufen, Verkaufen, Angebot, Abbruch, ...) is shown pressed while the mouse button is +// held down; the screens keep the held button in `pressed_*` members and draw it with this helper. +#pragma once + +#include +#include + +#include "formats/vga.hpp" + +namespace bmh::ui { + +// Draws the frame of a button of the given width (10 pixels high) with its top left corner at (x,y). +// Returns the offset (0 raised, 2 pressed) that the label must be moved by; the label colour mode of the +// pressed look is the one after the raised one in the executable (Advertising_Button_RuntimeField + 1). +inline int draw_wide_button_frame(Image& out, const Image& art, int x, int y, int width, bool pressed) { + constexpr int height = 10; + const auto put = [&](int sx, int sy, int dx, int dy, int w, int h) { + for (int yy = 0; yy < h; ++yy) for (int xx = 0; xx < w; ++xx) { + const int tx = dx + xx, ty = dy + yy, px = sx + xx, py = sy + yy; + if (tx < 0 || ty < 0 || tx >= out.width || ty >= out.height || px < 0 || py < 0 || + px >= art.width || py >= art.height) continue; + out.at(tx, ty) = art.pixels[size_t(py) * size_t(art.width) + size_t(px)]; + } + }; + const auto fill = [&](int fx, int fy, int w, int h, uint8_t color) { + for (int yy = std::max(0, fy); yy < std::min(out.height, fy + h); ++yy) + for (int xx = std::max(0, fx); xx < std::min(out.width, fx + w); ++xx) out.at(xx, yy) = color; + }; + if (pressed) { + // the place of the shadow shows the background again + const uint8_t background = out.at(std::min(x, out.width - 1), std::min(y + height, out.height - 1)); + fill(x, y, width + 1, 2, background); + fill(x, y, 2, height + 1, background); + x += 2; + y += 2; + } else { + fill(x + 2, y + height, width, 2, 0x40); + fill(x + width, y + 2, 2, height, 0x40); + } + const int top = pressed ? 44 : 74; + put(24, top, x, y, 31, height); + int at = 31, left = width - 31; + while (left > 20) { + const int n = std::min(8, left - 20); + put(24, top + 10, x + at, y, n, height); + at += n; + left -= n; + } + put(45 - left, top + 20, x + at, y, left, height); + return pressed ? 2 : 0; +} + +} // namespace bmh::ui diff --git a/src/ui/flow.hpp b/src/ui/flow.hpp index f44f6ab..13c6731 100644 --- a/src/ui/flow.hpp +++ b/src/ui/flow.hpp @@ -110,6 +110,9 @@ public: FlowResult click(int x, int y, bool right = false, bool double_click = false); // Mouse button press (DOWN) entry point; click() handles the matching release. FlowResult pointer_down(int x,int y,bool right=false); + // Left press on a screen whose buttons have no lasting state (bank, offer editor, ...): the button under the pointer is + // drawn pressed until the release. Returns true when the screen must be presented at once. + bool press_hold(int x,int y); // Timer expiry event together with the current pointer position. FlowResult process_timer_expired(int pointer_x = 0, int pointer_y = 0); bool timed_notice_open() const; diff --git a/src/ui/lineup.cpp b/src/ui/lineup.cpp index 42a3ee3..e2d323c 100644 --- a/src/ui/lineup.cpp +++ b/src/ui/lineup.cpp @@ -4,6 +4,7 @@ // Swapping or preparing is done by the session, not here. #include "formats/executable_layout.hpp" #include "ui/lineup.hpp" +#include "ui/button_frame.hpp" #include #include @@ -168,17 +169,16 @@ void LineupScreen::sprite_text(Image& out,int x,int baseline,std::string_view va copy(out,letters_,sx,(font-4)*7,x,baseline-6,width,7,0);x+=width; } } -void LineupScreen::button(Image& out,int x,int y,std::string_view value) const { - constexpr int width=55,height=10; - rect(out,x+2,y+height,width,2,0x40);rect(out,x+width,y+2,2,height,0x40); - copy(out,widgets_,24,74,x,y,31,10); - int at=31,remaining=width-31; - while(remaining>20){const int n=std::min(8,remaining-20);copy(out,widgets_,24,84,x+at,y,n,10);at+=n;remaining-=n;} - copy(out,widgets_,45-remaining,94,x+at,y,remaining,10); - if(exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)==3)text(out,x,y+7,value,0,x+width); +void LineupScreen::button(Image& out,int x,int y,std::string_view value,bool pressed) const { + constexpr int width=55; + // a button held down by the mouse is drawn pressed (button_frame.hpp): moved by two pixels, other label mode + const int shift=draw_wide_button_frame(out,widgets_,x,y,width,pressed); + const int mode=exe_.u8(::bmh::layout::Advertising_Button_RuntimeField+int(pressed)); + x+=shift;y+=shift; + if(mode==3)text(out,x,y+7,value,0,x+width); else { int length=0;for(unsigned char c:value){const int g=exe_.u8(::bmh::layout::ClubInfo_Raw_RuntimeField3 + c);length+=g?exe_.u16(::bmh::layout::ClubInfo_Raw_RuntimeField2+g*2)-exe_.u16(::bmh::layout::ClubInfo_Raw_RuntimeField+g*2):2;} - sprite_text(out,x+width/2-length/2,y+7,value,exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)); + sprite_text(out,x+width/2-length/2,y+7,value,mode); } } std::vector> LineupScreen::rows() const { @@ -237,8 +237,8 @@ Image LineupScreen::render() const { number((p.statistics ? p.statistics->goals : le16(Bytes(p.board.begin(),p.board.end()),0x4a)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField2)+number((p.statistics ? p.statistics->assists : le16(Bytes(p.board.begin(),p.board.end()),0x4c)),3)+exe_.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField),0x6c); } } - button(out,1,215,texts_[(::bmh::layout::Lineup_Render_TextPointer-::bmh::layout::TextPointerTable)/4+(state_.view==LineupView::data_a?1:0)]); - button(out,58,215,texts_[(::bmh::layout::Lineup_Render_TextPointer2-::bmh::layout::TextPointerTable)/4]); + button(out,1,215,texts_[(::bmh::layout::Lineup_Render_TextPointer-::bmh::layout::TextPointerTable)/4+(state_.view==LineupView::data_a?1:0)],pressed_button_==0); + button(out,58,215,texts_[(::bmh::layout::Lineup_Render_TextPointer2-::bmh::layout::TextPointerTable)/4],pressed_button_==1); return out; } LineupRequest LineupScreen::request(LineupRequestKind kind,int first,int second) { @@ -252,7 +252,14 @@ LineupRequest LineupScreen::initialize() { if(pending_||close_||state_.entry_prepared)return {}; return request(LineupRequestKind::prepare_lineup); } +// Mouse DOWN on a bottom button (Daten A/B, Spielfeld): drawn pressed until the release. +bool LineupScreen::press(int x,int y) { + int id=-1; + if(!pending_&&!close_&&y>=215&&y<=224){if(x>=1&&x<=56)id=0;else if(x>=58&&x<=113)id=1;} + const bool changed=id!=pressed_button_;pressed_button_=id;return changed; +} LineupRequest LineupScreen::click(int x,int y,bool right) { + pressed_button_=-1; // the release ends the pressed look if(pending_||close_)return {}; if(right){if(selected_)selected_.reset();else close_=true;return {};} if(y>=215&&y<=224){ diff --git a/src/ui/lineup.hpp b/src/ui/lineup.hpp index 58e5dc7..21b5d85 100644 --- a/src/ui/lineup.hpp +++ b/src/ui/lineup.hpp @@ -64,6 +64,8 @@ public: LineupRequest initialize(); Image render() const; LineupRequest click(int x, int y, bool right = false); + // Mouse DOWN on a bottom button: drawn pressed until the release (click()). + bool press(int x, int y); bool move(int x, int y); // local original name-column hover LineupRequest key(std::string_view key); bool close_requested() const { return close_; } @@ -88,7 +90,8 @@ private: std::vector> rows() const; // (squad row, baseline) 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 = 5) const; - void button(Image&, int x, int y, std::string_view value) const; + void button(Image&, int x, int y, std::string_view value, bool pressed = false) const; + int pressed_button_ = -1; // bottom button held down by the mouse LineupRequest request(LineupRequestKind, int first = -1, int second = -1); }; diff --git a/src/ui/outgoing_transfer.cpp b/src/ui/outgoing_transfer.cpp index 46827d4..d16a34a 100644 --- a/src/ui/outgoing_transfer.cpp +++ b/src/ui/outgoing_transfer.cpp @@ -5,6 +5,7 @@ // never recomputed here. #include "formats/executable_layout.hpp" #include "ui/outgoing_transfer.hpp" +#include "ui/button_frame.hpp" #include #include @@ -448,28 +449,17 @@ void OutgoingTransferScreen::draw_footer(Image& out) const { // OpenTransferEditor registers four FormatError3 controls from a216c/a216e/a2170. // The address stride in OutgoingTransfer_DrawFooter_TextPointer is exactly one TEXTD pointer (four bytes): // IDs 230..233 are Team-Info, Spieler-Info, Angebot and Abbruch. - constexpr int drawn_height = 10; // FormatError3 raises requested h=9 for width>31. for (size_t i = 0; i < kFooterButtonX.size(); ++i) { const int x = kFooterButtonX[i]; - // FormatError3 first calls ColorBottomRightBevel for the raised control's shadow. - fill_rect(out, x + 2, kFooterButtonY + drawn_height, kFooterButtonWidth, 2, 0x40); - fill_rect(out, x + kFooterButtonWidth, kFooterButtonY + 2, 2, drawn_height, 0x40); - // FormatError3's standard KB0 frame; its requested nine-pixel height - // is raised to ten for widths over 31, then the sprite is tiled. - copy_region(out, button_art_, 24, 74, x, kFooterButtonY, 31, drawn_height); - int used = 31; - while (kFooterButtonWidth - used > 20) { - const int count = std::min(8, kFooterButtonWidth - used - 20); - copy_region(out, button_art_, 24, 84, x + used, kFooterButtonY, count, drawn_height); - used += count; - } - const int remaining = kFooterButtonWidth - used; - copy_region(out, button_art_, 45 - remaining, 94, x + used, kFooterButtonY, - remaining, drawn_height); + // FormatError3: shadow, KB0 frame (height raised to ten for widths over 31) and tiled middle; a button held + // down by the mouse is drawn in the pressed look (button_frame.hpp). + const bool down = pressed_button_ == int(i); + const int shift = draw_wide_button_frame(out, button_art_, x, kFooterButtonY, kFooterButtonWidth, down); const auto label = original_to_utf8(text_at(texts_, ::bmh::layout::OutgoingTransfer_DrawFooter_TextPointer + uint32_t(i) * 4)); const int text_width = sprite_font_.text_width(label); - sprite_font_.draw(out, x + kFooterButtonWidth / 2 - text_width / 2, - kFooterButtonY + 7, label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField)); + sprite_font_.draw(out, x + shift + kFooterButtonWidth / 2 - text_width / 2, + kFooterButtonY + shift + 7, label, + exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(down))); } } @@ -492,7 +482,20 @@ OutgoingTransferRequest OutgoingTransferScreen::process_timer_expired() { // presets edit the value and right click cancels it; otherwise right click cancels the screen, footer buttons send // team info, player info, submit (only when editable) or cancel; clicks on the fee, salary or (mode 3) contract/bonus // areas open the calculator. Opening the calculator is local state and sends no request. +// Mouse DOWN on a footer button: it is drawn pressed until the release. Returns true when the picture changed. +bool OutgoingTransferScreen::press(int x, int y) { + int id = -1; + if (!closed_ && !pending_ && !calculator_open_) + for (size_t i = 0; i < kFooterButtonX.size(); ++i) + if (x >= kFooterButtonX[i] && x <= kFooterButtonX[i] + kFooterButtonWidth && y >= kFooterButtonY && + y <= kFooterButtonY + kFooterButtonHeight) id = int(i); + const bool changed = id != pressed_button_; + pressed_button_ = id; + return changed; +} + OutgoingTransferRequest OutgoingTransferScreen::click(int x, int y, bool right, bool double_click) { + pressed_button_ = -1; // the release ends the pressed look if (closed_ || pending_) return {}; if (double_click && !right && !calculator_open_ && y > 0x12 && y < 0x21) { state_.quote_loan = !state_.quote_loan; diff --git a/src/ui/outgoing_transfer.hpp b/src/ui/outgoing_transfer.hpp index 38362ec..a22970e 100644 --- a/src/ui/outgoing_transfer.hpp +++ b/src/ui/outgoing_transfer.hpp @@ -97,6 +97,8 @@ public: OutgoingTransferEditorState state); Image render() const; OutgoingTransferRequest click(int x, int y, bool right = false, bool double_click = false); + // Mouse DOWN: the footer button under the pointer is drawn pressed until the release (click()). + bool press(int x, int y); // Source event8 returns calculator cancellation before closing its editor. OutgoingTransferRequest process_timer_expired(); OutgoingTransferRequest key(std::string_view key); @@ -125,6 +127,7 @@ private: std::string numeric_text_, feedback_; bool calculator_open_ = false; bool closed_ = false; + int pressed_button_ = -1; // footer button held down by the mouse std::optional pending_; OutgoingTransferIdentity identity() const; diff --git a/src/ui/pitch.cpp b/src/ui/pitch.cpp index 3fa2b41..7f2ee5e 100644 --- a/src/ui/pitch.cpp +++ b/src/ui/pitch.cpp @@ -422,8 +422,8 @@ Image PitchScreen::render()const{ if(automatic_page()&&extras_.mode!=1)for(int f=0;f<3;++f){ const int x=241+f*27;copy(out,atlas_,196+f*24,38,x,205,24,18); copy(out,atlas_,256+((extras_.automatic_weights>>(2*f))&3)*16,32,x+19,211,4,5);} - button(out,196,110,texts_[(::bmh::layout::Lineup_Render_TextPointer-::bmh::layout::TextPointerTable)/4+(state_.view==LineupView::data_a?1:0)]); - button(out,196,123,texts_[(::bmh::layout::Pitch_Render_TextPointer-::bmh::layout::TextPointerTable)/4]); + button(out,196,110,texts_[(::bmh::layout::Lineup_Render_TextPointer-::bmh::layout::TextPointerTable)/4+(state_.view==LineupView::data_a?1:0)],pressed_lower_button_==0); + button(out,196,123,texts_[(::bmh::layout::Pitch_Render_TextPointer-::bmh::layout::TextPointerTable)/4],pressed_lower_button_==1); button(out,196,136,texts_[(::bmh::layout::Pitch_Render_TextPointer2-::bmh::layout::TextPointerTable)/4],(extras_.native_display_word&0x0010)!=0); if(extras_.mode!=1)button(out,196,149,texts_[(::bmh::layout::Pitch_Render_TextPointer3-::bmh::layout::TextPointerTable)/4],order_panel_open_); if(extras_.opponent_team>=0&&!extras_.indoor.value_or(false)) @@ -757,7 +757,16 @@ PitchRequest PitchScreen::click(int x,int y,bool right){ selected_=row;hovered_=row;ghost_.reset();return {};} return {}; } +// Mouse DOWN on one of the two momentary buttons of the desktop page (Daten A/B at y=110, Spielfeld/Kurz at y=123): drawn +// pressed; pointer_down() runs the action and ends the pressed look. The toggles below them keep their lasting state. +bool PitchScreen::press(int x,int y){ + int id=-1; + if(!pending_&&!close_&&(extras_.native_display_word&0x08)!=0&&x>=196&&x<=239){ + if(y>=110&&y<=120)id=0;else if(y>=123&&y<=133)id=1;} + const bool changed=id!=pressed_lower_button_;pressed_lower_button_=id;return changed; +} PitchRequest PitchScreen::pointer_down(int x,int y,bool right){ + pressed_lower_button_=-1; source_down_release_barrier_=false; const uint16_t display_word=shooter_editor_open_ ? uint16_t(extras_.native_display_word&0xff0f) diff --git a/src/ui/pitch.hpp b/src/ui/pitch.hpp index 1397521..1198aaa 100644 --- a/src/ui/pitch.hpp +++ b/src/ui/pitch.hpp @@ -98,6 +98,8 @@ public: // dispatches and acknowledges the returned native page-word request. PitchRequest request_page_control(int control); PitchRequest pointer_down(int x,int y,bool right=false); + // Mouse DOWN on a momentary button: drawn pressed; pointer_down() then runs its action and ends the look. + bool press(int x,int y); bool take_source_down_release_barrier(){const bool value=source_down_release_barrier_;source_down_release_barrier_=false;return value;} PitchRequest save_formation(int x, int y); // completed long press, own slots 4..7 bool move(int x, int y); @@ -146,6 +148,7 @@ private: std::vector> rows() const; void text(Image&, int x, int baseline, std::string_view, uint8_t color) const; void button(Image&, int x, int y, std::string_view, bool selected = false) const; + int pressed_lower_button_ = -1; // momentary button held down by the mouse (0 Daten, 1 Spielfeld/Kurz) void jersey(Image&, const LineupPlayer&, int depth, int lane, int color, bool number = true) const; PitchRequest request(PitchRequestKind, int row, int second = -1, int depth = -1, int lane = -1); PitchRequest automatic_request(PitchRequestKind, int index); diff --git a/src/ui/preparation_flow.cpp b/src/ui/preparation_flow.cpp index 0225b51..1ac3104 100644 --- a/src/ui/preparation_flow.cpp +++ b/src/ui/preparation_flow.cpp @@ -1086,6 +1086,15 @@ FlowResult StartupFlow::process_timer_expired(int pointer_x, int pointer_y) { return {}; // other modal callers retain their own input owner } +bool StartupFlow::press_hold(int x,int y) { + if (player_card_) return false; // the card covers its parent + if (pitch_) return pitch_->press(x, y); + if (lineup_) return lineup_->press(x, y); + if (bank_) return bank_->press(x, y); + if (outgoing_transfer_) return outgoing_transfer_->press(x, y); + return false; +} + // Routes a mouse press to the active child page (checked in a fixed order); the submenu pages then forward their pending action through finish_*_input. FlowResult StartupFlow::pointer_down(int x,int y,bool right) { if(pitch_hold_release_barrier_&&!right)return {};