More buttons without a lasting state look pressed while held
Advertising offers and notices, the player card, the training camp booking and notice, the file dialog (page button, overwrite question) and the bank notices and credit fee question now draw the pressed look from the mouse press until the release. Manager notices share source_dialog_button_at for their OK/Ja/Nein. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6bc17a381
commit
551d564efb
14 files changed
+145
-48
No files matched your search
+29
-17
@@ -6,6 +6,7 @@
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/environment.hpp"
|
||||
#include "ui/advertising.hpp"
|
||||
#include "ui/button_frame.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -759,11 +760,11 @@ Image AdvertisingScreen::render() const {
|
||||
|
||||
copy(image, logos_, 32, 217, 138, 174, 11, 14);
|
||||
|
||||
button(image, 89, 191, 66, state_.cancel_label);
|
||||
button(image, 89, 191, 66, state_.cancel_label, pressed_button_ == 0);
|
||||
// The original shows ABBRECHEN only when the selected offer cannot be accepted
|
||||
// (for example while a running sponsor contract is not terminable).
|
||||
if (offer_acceptable())
|
||||
button(image, 164, 191, 66, state_.accept_label);
|
||||
button(image, 164, 191, 66, state_.accept_label, pressed_button_ == 1);
|
||||
}
|
||||
}
|
||||
if (hovered_target_ >= 0) {
|
||||
@@ -779,21 +780,30 @@ Image AdvertisingScreen::render() const {
|
||||
return image;
|
||||
}
|
||||
|
||||
void AdvertisingScreen::button(Image& image, int x, int y, int width, std::string_view label) const {
|
||||
// FormatError3's normal KB/0 bevel. Source promotes any wide button shorter
|
||||
// than ten pixels to a ten-pixel button before tiling its centre.
|
||||
constexpr int height = 10;
|
||||
copy(image, widgets_, 24, 74, x, y, 31, height);
|
||||
int used = 31;
|
||||
while (width - used > 20) {
|
||||
const int count = std::min(8, width - used - 20);
|
||||
copy(image, widgets_, 24, 84, x + used, y, count, height);
|
||||
used += count;
|
||||
}
|
||||
copy(image, widgets_, 45 - (width - used), 94, x + used, y, width - used, height);
|
||||
void AdvertisingScreen::button(Image& image, int x, int y, int width, std::string_view label, bool pressed) const {
|
||||
// FormatError3's KB/0 bevel (button_frame.hpp: raised with shadow, or pressed while the mouse button is held).
|
||||
// Source promotes any wide button shorter than ten pixels to a ten-pixel button before tiling its centre.
|
||||
const int shift = draw_wide_button_frame(image, widgets_, x, y, width, pressed);
|
||||
if (!label.empty())
|
||||
sprite_font_.draw(image, x + width / 2 - sprite_font_.text_width(label) / 2, y + 7,
|
||||
label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField));
|
||||
sprite_font_.draw(image, x + shift + width / 2 - sprite_font_.text_width(label) / 2, y + shift + 7,
|
||||
label, exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(pressed)));
|
||||
}
|
||||
|
||||
// Mouse DOWN on ABBRECHEN or the accept button of the open offer: drawn pressed until the release.
|
||||
bool AdvertisingScreen::press(int x, int y) {
|
||||
int id = -1;
|
||||
// OK of an acknowledging notification (id 2); a warning is timed and has no button
|
||||
if (notification_open() && !close_requested_ && !pending_ && !state_.notification_warning &&
|
||||
source_dialog_button_at(TaxDialogKind::acknowledgement, false, x, y) == GameEndTaxDialog::Button::acknowledge)
|
||||
id = 2;
|
||||
else if (offer_open_ && !close_requested_ && !pending_ && !notification_open() && !spending_calculator_open_ &&
|
||||
y >= 191 && y <= 200) {
|
||||
if (x >= 89 && x <= 154) id = 0;
|
||||
else if (x >= 164 && x <= 229 && offer_acceptable()) id = 1;
|
||||
}
|
||||
const bool changed = id != pressed_button_;
|
||||
pressed_button_ = id;
|
||||
return changed;
|
||||
}
|
||||
|
||||
void AdvertisingScreen::pattern_rect(Image& out, int x, int y, int width, int height) const {
|
||||
@@ -859,7 +869,8 @@ void AdvertisingScreen::draw_notification(Image& out) const {
|
||||
notice.body=utf8_to_original(state_.notification_text);
|
||||
notice.source_manager_flags=state_.notification_warning?0x40:0x80;
|
||||
draw_source_dialog(out,{widgets_,faces_,badge_atlas_?&*badge_atlas_:nullptr,
|
||||
font_,large_font_,exe_,sprite_font_,texts_},notice,state_.font_gradient);
|
||||
font_,large_font_,exe_,sprite_font_,texts_},notice,state_.font_gradient,
|
||||
pressed_button_ == 2 ? std::optional<GameEndTaxDialog::Button>(GameEndTaxDialog::Button::acknowledge) : std::nullopt);
|
||||
}
|
||||
|
||||
bool AdvertisingScreen::dismiss_notification() {
|
||||
@@ -1052,6 +1063,7 @@ bool AdvertisingScreen::move(int x, int y) {
|
||||
}
|
||||
|
||||
bool AdvertisingScreen::click(int x, int y) {
|
||||
pressed_button_ = -1; // the release ends the pressed look
|
||||
pointer_position_ = std::array<int, 2>{x, y};
|
||||
if (close_requested_ || pending_ || x < 0 || y < 0 || x >= 320 || y >= 240) return false;
|
||||
if (notification_open()) return dismiss_notification();
|
||||
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
Image render() const;
|
||||
bool move(int x, int y);
|
||||
bool click(int x, int y);
|
||||
// Mouse DOWN on a button of the open offer: drawn pressed until the release (click()).
|
||||
bool press(int x, int y);
|
||||
bool key(std::string_view key);
|
||||
bool open_offers(int display_slot);
|
||||
bool text(std::string_view input);
|
||||
@@ -175,7 +177,8 @@ private:
|
||||
void draw_notification(Image&) const;
|
||||
void pattern_rect(Image&, int x, int y, int width, int height) const;
|
||||
void source_frame(Image&, int x, int y, int width, int height, bool shadow = true) const;
|
||||
void button(Image&, int x, int y, int width, std::string_view label) const;
|
||||
void button(Image&, int x, int y, int width, std::string_view label, bool pressed = false) const;
|
||||
int pressed_button_ = -1; // offer button held down by the mouse (0 cancel, 1 accept)
|
||||
};
|
||||
|
||||
} // namespace bmh::ui
|
||||
+13
-2
@@ -621,8 +621,10 @@ void BankScreen::draw_manager_dialog(Image& out, std::string_view message, bool
|
||||
notice.body=utf8_to_original(message);
|
||||
notice.source_manager_flags=with_ack_button?0x80:0x40;
|
||||
if(credit_fee_confirmation_open_&&!with_ack_button)notice.kind=TaxDialogKind::question;
|
||||
const auto held=static_cast<GameEndTaxDialog::Button>(pressed_dialog_);
|
||||
draw_source_dialog(out,{widgets_,faces_,badge_atlas_?&*badge_atlas_:nullptr,
|
||||
font_,large_font_,exe_,sprite_font_,texts_},notice,state_.gradient_text);
|
||||
font_,large_font_,exe_,sprite_font_,texts_},notice,state_.gradient_text,
|
||||
held==GameEndTaxDialog::Button::none?std::nullopt:std::optional<GameEndTaxDialog::Button>(held));
|
||||
}
|
||||
void BankScreen::draw_investment_warning(Image& out) const {
|
||||
draw_manager_dialog(out, state_.investment_limit_text, false);
|
||||
@@ -993,6 +995,14 @@ BankRequest BankScreen::submit() {
|
||||
// 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) {
|
||||
// the buttons of the manager notices and of the credit fee question (OK, Ja, Nein)
|
||||
const bool notice = credit_notice_open_ || property_notice_open_;
|
||||
const bool question = credit_fee_confirmation_open_ && !notice;
|
||||
int dialog = int(GameEndTaxDialog::Button::none);
|
||||
if (notice || question)
|
||||
dialog = int(source_dialog_button_at(question ? TaxDialogKind::question : TaxDialogKind::acknowledgement, false, x, y));
|
||||
const bool dialog_changed = dialog != pressed_dialog_;
|
||||
pressed_dialog_ = dialog;
|
||||
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_;
|
||||
@@ -1002,10 +1012,11 @@ bool BankScreen::press(int x, int y) {
|
||||
}
|
||||
const bool changed = id != pressed_button_;
|
||||
pressed_button_ = id;
|
||||
return changed;
|
||||
return changed || dialog_changed;
|
||||
}
|
||||
BankRequest BankScreen::click(int x, int y, bool right) {
|
||||
pressed_button_ = -1; // the release ends the pressed look
|
||||
pressed_dialog_ = int(GameEndTaxDialog::Button::none);
|
||||
if (credit_notice_open_) {
|
||||
if (right || (x >= 95 && x <= 220 && y >= 166 && y <= 176)) {
|
||||
credit_notice_open_ = false;
|
||||
|
||||
@@ -156,6 +156,7 @@ private:
|
||||
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
|
||||
int pressed_dialog_ = 0; // GameEndTaxDialog::Button (0 none) of an open notice/question held down by the mouse
|
||||
bool calculator_stock_count_ = false;
|
||||
bool calculator_property_count_ = false;
|
||||
int selected_stock_ = 11;
|
||||
|
||||
@@ -575,7 +575,8 @@ Image ContractsScreen::render() const {
|
||||
notice.body=utf8_to_original(state_.feedback);
|
||||
notice.source_manager_flags=0x80;
|
||||
draw_source_dialog(out,{widgets_,faces_,&badge_atlas_,font_,large_font_,
|
||||
exe_,sprite_font_,texts_},notice,state_.gradient_text);
|
||||
exe_,sprite_font_,texts_},notice,state_.gradient_text,
|
||||
pressed_button_==3?std::optional<GameEndTaxDialog::Button>(GameEndTaxDialog::Button::acknowledge):std::nullopt);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -589,7 +590,10 @@ Image ContractsScreen::render() const {
|
||||
// release. Returns true when the picture changed.
|
||||
bool ContractsScreen::press(int x, int y) {
|
||||
int id = -1;
|
||||
if (page_ == Page::player_offer || page_ == Page::team_premiums) {
|
||||
if (page_ == Page::result) {
|
||||
// OK of the manager's answer (id 3)
|
||||
if (source_dialog_button_at(TaxDialogKind::acknowledgement, false, x, y) == GameEndTaxDialog::Button::acknowledge) id = 3;
|
||||
} else if (page_ == Page::player_offer || page_ == Page::team_premiums) {
|
||||
const bool team = page_ == Page::team_premiums && team_premium_mode_;
|
||||
const auto selected = std::find_if(state_.players.begin(), state_.players.end(), [&](const auto& p) { return p.row == state_.selected_row; });
|
||||
const int top = team || selected == state_.players.end() || selected->row >= 13 ? 22 : 130;
|
||||
|
||||
@@ -339,6 +339,14 @@ void draw_source_dialog(Image& out,const SourceDialogAssets& assets,const TaxDia
|
||||
button(out,assets.widgets,assets.sprite,assets.exe,175,166,75,no,pressed==Button::no);
|
||||
}
|
||||
}
|
||||
GameEndTaxDialog::Button source_dialog_button_at(TaxDialogKind kind,bool timed_notice,int x,int y){
|
||||
using Button=GameEndTaxDialog::Button;
|
||||
if(y<166||y>176)return Button::none;
|
||||
if(kind==TaxDialogKind::acknowledgement)return !timed_notice&&x>=95&&x<=220?Button::acknowledge:Button::none;
|
||||
if(x>=62&&x<=137)return Button::yes;
|
||||
if(x>=175&&x<=250)return Button::no;
|
||||
return Button::none;
|
||||
}
|
||||
GameEndTaxDialog::Button GameEndTaxDialog::hit_test(int x,int y)const{
|
||||
if(y<166||y>176)return Button::none;
|
||||
if(projection_.kind==TaxDialogKind::acknowledgement)
|
||||
|
||||
@@ -122,6 +122,10 @@ class SpriteFont;
|
||||
// including the existing season-end dialog, share PresentManagerDialog's drawing path.
|
||||
// SourceBadgeFallback classifies the raw club token before reading its badge selector.
|
||||
bool source_badge_fallback(int club_token);
|
||||
// The button of a manager notice (kind acknowledgement: OK, kind question: Ja/Nein) under the pointer, for the pressed look
|
||||
// that every screen showing such a dialog draws while the mouse button is held (draw_source_dialog's `pressed`).
|
||||
// A timed notice has no button.
|
||||
GameEndTaxDialog::Button source_dialog_button_at(TaxDialogKind kind, bool timed_notice, int x, int y);
|
||||
struct SourceDialogAssets {
|
||||
const Image& widgets;
|
||||
const Image& faces;
|
||||
|
||||
+13
-2
@@ -326,7 +326,7 @@ Image PlayerCardScreen::render_card() const {
|
||||
if(i==5){const auto market=player_card_market_value(a,exe_);value=market?cash(*market,1)+exe_.cstring(::bmh::layout::ClubPlayerDetail_Copy_ExecutableField):"?";}
|
||||
text(out,x,base+11,value,0x6a);
|
||||
}
|
||||
button(out,8,211,60,label(::bmh::layout::ClubPlayerDetail_Copy_TextPointer7));button(out,80,211,96,label(::bmh::layout::ClubPlayerDetail_Copy_ExecutableField5),statistics_open_);
|
||||
button(out,8,211,60,label(::bmh::layout::ClubPlayerDetail_Copy_TextPointer7),pressed_button_==0);button(out,80,211,96,label(::bmh::layout::ClubPlayerDetail_Copy_ExecutableField5),statistics_open_||pressed_button_==1);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -365,11 +365,22 @@ Image PlayerCardScreen::render_statistics() const {
|
||||
}
|
||||
button(out,265,142,30,label(::bmh::layout::ClubPlayerDetail_RenderStatistics_ExecutableField),(statistics_flags_&0x40)!=0);
|
||||
button(out,265,153,30,label(::bmh::layout::ClubPlayerDetail_RenderStatistics_ExecutableField2),(statistics_flags_&0x80)!=0);
|
||||
button(out,8,185,140,label(::bmh::layout::ClubPlayerDetail_RenderStatistics_ExecutableField3));
|
||||
button(out,8,185,140,label(::bmh::layout::ClubPlayerDetail_RenderStatistics_ExecutableField3),pressed_button_==2);
|
||||
return out;
|
||||
}
|
||||
|
||||
// Mouse DOWN on a button of the card (Schließen, Statistik, and Zurück of the statistics page): drawn pressed until
|
||||
// the release. Returns true when the picture changed.
|
||||
bool PlayerCardScreen::press(int x,int y) {
|
||||
int id=-1;
|
||||
if(!close_){
|
||||
if(statistics_open_){if(x>=8&&x<=148&&y>=185&&y<=195)id=2;}
|
||||
else if(y>=211&&y<=220){if(x>=8&&x<=68)id=0;else if(x>=80&&x<=176)id=1;}
|
||||
}
|
||||
const bool changed=id!=pressed_button_;pressed_button_=id;return changed;
|
||||
}
|
||||
bool PlayerCardScreen::click(int x,int y,bool right) {
|
||||
pressed_button_=-1; // the release ends the pressed look
|
||||
if(close_)return false;
|
||||
if(statistics_open_){
|
||||
if(right||(x>=8&&x<=148&&y>=185&&y<=195)){
|
||||
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
PlayerCardScreen(const std::filesystem::path& data, PlayerCardState state, std::optional<Image> parent_frame = std::nullopt);
|
||||
Image render() const;
|
||||
bool click(int x, int y, bool right = false);
|
||||
// Mouse DOWN on a card button: drawn pressed until the release (click()).
|
||||
bool press(int x, int y);
|
||||
bool key(std::string_view key);
|
||||
bool close_requested() const { return close_; }
|
||||
bool in_statistics() const { return statistics_open_; }
|
||||
@@ -61,6 +63,7 @@ private:
|
||||
std::array<Image, 2> loan_badges_;
|
||||
bool close_ = false;
|
||||
bool statistics_open_ = false;
|
||||
int pressed_button_ = -1; // 0 Schließen, 1 Statistik, 2 Zurück (statistics page) while the mouse button is held
|
||||
std::optional<Image> statistics_frame_; // previous UI frame for original button redraw edges
|
||||
std::optional<Image> restored_card_frame_; // card loop does not reconstruct its outer frame
|
||||
uint8_t statistics_flags_ = 0;
|
||||
|
||||
@@ -1087,9 +1087,12 @@ FlowResult StartupFlow::process_timer_expired(int pointer_x, int pointer_y) {
|
||||
}
|
||||
|
||||
bool StartupFlow::press_hold(int x,int y) {
|
||||
if (player_card_) return false; // the card covers its parent
|
||||
if (advertising_) return advertising_->press(x, y);
|
||||
if (save_load_) return save_load_->press(x, y);
|
||||
if (player_card_) return player_card_->press(x, y); // the card covers its parent
|
||||
if (pitch_) return pitch_->press(x, y);
|
||||
if (lineup_) return lineup_->press(x, y);
|
||||
if (training_camp_) return training_camp_->press(x, y);
|
||||
if (bank_) return bank_->press(x, y);
|
||||
if (outgoing_transfer_) return outgoing_transfer_->press(x, y);
|
||||
if (manager_ && !desktop_) return manager_->press(x, y);
|
||||
|
||||
+27
-15
@@ -5,6 +5,7 @@
|
||||
#include "formats/native_save_version.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/save_load.hpp"
|
||||
#include "ui/button_frame.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
@@ -141,7 +142,7 @@ Image SaveLoadScreen::render() const {
|
||||
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)));
|
||||
button(out, 206, 183, 56, original_to_utf8(exe_.cstring(::bmh::layout::SaveLoad_Render_ExecutableField)), pressed_more_ != 0);
|
||||
}
|
||||
|
||||
for (int row = 0; row < 15; ++row) {
|
||||
@@ -192,7 +193,9 @@ Image SaveLoadScreen::render() const {
|
||||
// OpenBMH deviates from the original: the host file picker uses the
|
||||
// shared dialog's system identity without a live manager portrait projection.
|
||||
draw_source_dialog(out, {widgets_, widgets_, nullptr, footer_font_, font_, exe_, sprite_font_, texts_},
|
||||
question, gradient_text_);
|
||||
question, gradient_text_,
|
||||
pressed_question_ == 0 ? std::nullopt : std::optional<GameEndTaxDialog::Button>(
|
||||
static_cast<GameEndTaxDialog::Button>(pressed_question_)));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -261,20 +264,12 @@ void SaveLoadScreen::frame(Image& out, int x, int y, int width, int height) cons
|
||||
}
|
||||
}
|
||||
|
||||
void SaveLoadScreen::button(Image& out, int x, int y, int width, std::string_view label) const {
|
||||
// FormatError3 normal button bevel from KB/0.VGA, with Source horizontal tiling.
|
||||
const int sy = 74;
|
||||
copy(out, widgets_, 24, sy, x, y, 31, 10);
|
||||
int used = 31;
|
||||
while (width - used > 20) {
|
||||
const int count = std::min(8, width - used - 20);
|
||||
copy(out, widgets_, 24, sy + 10, x + used, y, count, 10);
|
||||
used += count;
|
||||
}
|
||||
copy(out, widgets_, 45 - (width - used), sy + 20, x + used, y, width - used, 10);
|
||||
void SaveLoadScreen::button(Image& out, int x, int y, int width, std::string_view label, bool pressed) const {
|
||||
// FormatError3 button bevel from KB/0.VGA with Source horizontal tiling (button_frame.hpp: raised or pressed).
|
||||
const int shift = draw_wide_button_frame(out, widgets_, x, y, width, pressed);
|
||||
if (!label.empty())
|
||||
sprite_font_.draw(out, x + width / 2 - sprite_font_.text_width(label) / 2, y + 7, label,
|
||||
exe_.u8(::bmh::layout::Advertising_Button_RuntimeField));
|
||||
sprite_font_.draw(out, x + shift + width / 2 - sprite_font_.text_width(label) / 2, y + shift + 7, label,
|
||||
exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + int(pressed)));
|
||||
}
|
||||
|
||||
void SaveLoadScreen::text(Image& out, int x, int baseline, std::string_view value,
|
||||
@@ -344,7 +339,24 @@ void SaveLoadScreen::request_action() {
|
||||
file_kind_, origin_item_id_};
|
||||
}
|
||||
|
||||
// Mouse DOWN on Ja/Nein of the overwrite question, or on the page button of a long file list: drawn pressed until
|
||||
// the release. Returns true when the picture changed.
|
||||
bool SaveLoadScreen::press(int x, int y) {
|
||||
int question = 0, more = 0;
|
||||
if (!info_ && !pending_) {
|
||||
if (overwrite_confirmation_open_)
|
||||
question = int(source_dialog_button_at(TaxDialogKind::question, false, x, y));
|
||||
else if (entries_.size() > 15 && x >= 206 && x <= 262 && y >= 183 && y <= 193) more = 1;
|
||||
}
|
||||
const bool changed = question != pressed_question_ || more != pressed_more_;
|
||||
pressed_question_ = question;
|
||||
pressed_more_ = more;
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool SaveLoadScreen::click(int x, int y, bool right, bool double_click) {
|
||||
pressed_question_ = 0; // the release ends the pressed look
|
||||
pressed_more_ = 0;
|
||||
if (info_) { info_.reset(); return true; }
|
||||
if (pending_) return false;
|
||||
if (overwrite_confirmation_open_) {
|
||||
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
bool info_press(int x, int y);
|
||||
bool info_open() const { return bool(info_); }
|
||||
bool click(int x, int y, bool right = false, bool double_click = false);
|
||||
// Mouse DOWN on Ja/Nein of the overwrite question or the page button: drawn pressed until the release (click()).
|
||||
bool press(int x, int y);
|
||||
bool key(std::string_view key);
|
||||
bool text(std::string_view value);
|
||||
const std::optional<SaveLoadRequest>& pending() const { return pending_; }
|
||||
@@ -85,7 +87,9 @@ private:
|
||||
void request_action();
|
||||
bool select_row(int y);
|
||||
void frame(Image&, int x, int y, int width, int height) const;
|
||||
void button(Image&, int x, int y, int width, std::string_view label = {}) const;
|
||||
void button(Image&, int x, int y, int width, std::string_view label = {}, bool pressed = false) const;
|
||||
int pressed_question_ = 0; // GameEndTaxDialog::Button (0 none) of the overwrite question held down by the mouse
|
||||
int pressed_more_ = 0; // page button of a long file list held down by the mouse
|
||||
void text(Image&, int x, int baseline, std::string_view value, uint8_t color, int max_width,
|
||||
const Font&, bool gradient = false) const;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Implementation of TrainingCampScreen and training_camp_from_game() (training_camp.hpp): resort rows with hover, price and star display, and booking/focus request construction.
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/training_camp.hpp"
|
||||
#include "ui/button_frame.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
@@ -243,13 +244,11 @@ Image TrainingCampScreen::render() const {
|
||||
sprite_text(out, 104, 235, visit_text, 5);
|
||||
if (chosen_resort_ >= 0 && state_.booking_allowed()) {
|
||||
constexpr int x = 223, y = 214, width = 64, height = 10;
|
||||
rect(out, x + 2, y + height, width, 2, 0x40); rect(out, x + width, y + 2, 2, height, 0x40);
|
||||
copy(out, buttons_, 24, 74, x, y, 31, height);
|
||||
int at = 31, remaining = width - 31;
|
||||
while (remaining > 20) { const int n = std::min(8, remaining - 20); copy(out, buttons_, 24, 84, x + at, y, n, height); at += n; remaining -= n; }
|
||||
copy(out, buttons_, 45 - remaining, 94, x + at, y, remaining, height);
|
||||
(void)height;
|
||||
// the booking button is drawn pressed while the mouse button is held (button_frame.hpp)
|
||||
const int shift = draw_wide_button_frame(out, buttons_, x, y, width, booking_pressed_);
|
||||
const int label_width = small_.text_width(texts_[1267]);
|
||||
text(out, x + width / 2 - label_width / 2, y + 7, texts_[1267], 0);
|
||||
text(out, x + shift + width / 2 - label_width / 2, y + shift + 7, texts_[1267], 0);
|
||||
}
|
||||
if (!rejection_.empty() || state_.feedback != TrainingCampFeedback::none) {
|
||||
std::string message;
|
||||
@@ -268,7 +267,8 @@ Image TrainingCampScreen::render() const {
|
||||
notice.source_manager_flags=state_.feedback==TrainingCampFeedback::booked ||
|
||||
state_.feedback==TrainingCampFeedback::none ? 0x80 : 0x40;
|
||||
draw_source_dialog(out,{buttons_,portraits_,&badge_,small_,large_,exe_,sprite_font_,texts_},
|
||||
notice,state_.gradient_text);
|
||||
notice,state_.gradient_text,
|
||||
notice_pressed_ ? std::optional<GameEndTaxDialog::Button>(GameEndTaxDialog::Button::acknowledge) : std::nullopt);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -284,7 +284,24 @@ TrainingCampRequest TrainingCampScreen::initialize_focus() {
|
||||
return *pending_;
|
||||
}
|
||||
|
||||
// Mouse DOWN on the booking button: drawn pressed until the release. Returns true when the picture changed.
|
||||
bool TrainingCampScreen::press(int x, int y) {
|
||||
const bool on = !pending_ && chosen_resort_ >= 0 && state_.booking_allowed() && rejection_.empty() &&
|
||||
state_.feedback == TrainingCampFeedback::none && x >= 223 && x < 287 && y >= 214 && y < 224;
|
||||
// OK of an acknowledging notice (booked or a plain rejection; the timed warnings have no button)
|
||||
const bool notice_shown = !pending_ && (!rejection_.empty() || state_.feedback != TrainingCampFeedback::none);
|
||||
const bool acknowledging = state_.feedback == TrainingCampFeedback::booked || state_.feedback == TrainingCampFeedback::none;
|
||||
const bool ok = notice_shown && acknowledging &&
|
||||
source_dialog_button_at(TaxDialogKind::acknowledgement, false, x, y) == GameEndTaxDialog::Button::acknowledge;
|
||||
const bool changed = on != booking_pressed_ || ok != notice_pressed_;
|
||||
booking_pressed_ = on;
|
||||
notice_pressed_ = ok;
|
||||
return changed;
|
||||
}
|
||||
|
||||
TrainingCampRequest TrainingCampScreen::click(int x, int y, bool right) {
|
||||
booking_pressed_ = false; // the release ends the pressed look
|
||||
notice_pressed_ = false;
|
||||
if (pending_) return {};
|
||||
if (right && timed_notice_open()) {
|
||||
rejection_.clear(); state_.feedback=TrainingCampFeedback::none; return {};
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
TrainingCampScreen(const std::filesystem::path& data, TrainingCampState state);
|
||||
Image render() const;
|
||||
TrainingCampRequest click(int x, int y, bool right = false);
|
||||
// Mouse DOWN on the booking button: drawn pressed until the release (click()).
|
||||
bool press(int x, int y);
|
||||
TrainingCampRequest key(std::string_view key);
|
||||
bool move(int x, int y);
|
||||
const TrainingCampState& state() const { return state_; }
|
||||
@@ -87,6 +89,8 @@ private:
|
||||
int selected_resort_ = -1;
|
||||
int preview_resort_ = -1; // Text(-1) preserves the last photo while clearing details.
|
||||
int chosen_resort_ = -1;
|
||||
bool booking_pressed_ = false; // booking button held down by the mouse
|
||||
bool notice_pressed_ = false; // OK of the notice held down by the mouse
|
||||
bool close_requested_ = false;
|
||||
std::optional<TrainingCampRequest> pending_;
|
||||
std::string rejection_;
|
||||
|
||||
Reference in new issue
Block a user