Handle unframed desktop admission and automation controls (by Codex)
This commit is contained in:
1 parent
bea5478433
commit
f44de65e22
4 files changed
+59
-33
No files matched your search
@@ -5630,11 +5630,11 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
|
||||
if (!price && request.kind != ui::DeskRequestKind::change_option) {
|
||||
error = "unsupported_desk_widget"; return false;
|
||||
}
|
||||
// Keep SDL requests bound to a visible, open and enabled MEN drawer/item.
|
||||
// Keep SDL requests bound to a visible and enabled MEN drawer/item; the frame bit is optional.
|
||||
const auto desk = desktop_projection(revision);
|
||||
const int expected_kind = price ? 55 : 64;
|
||||
const auto item = std::find_if(desk.items.begin(), desk.items.end(), [&](const ui::DeskItem& item) {
|
||||
return item.id == request.item_id && item.kind == expected_kind && item.open && !item.disabled;
|
||||
return item.id == request.item_id && item.kind == expected_kind && !item.disabled;
|
||||
});
|
||||
if (request.menu_kind != expected_kind || item == desk.items.end()) {
|
||||
error = "stale_or_closed_desk_widget"; return false;
|
||||
|
||||
+7
-6
@@ -400,9 +400,9 @@ DeskRequest DesktopScreen::pointer_down(int x, int y, bool right) {
|
||||
}
|
||||
if (right && !state_.drawer_handles) return {};
|
||||
if (right && bin_mode_ && item.kind!=12) return {};
|
||||
if (!right && item.kind==55 && item.open && !state_.national_team &&
|
||||
x-item.x-4>34 && x-item.x-4<87) return {}; // Original ticket-price scale.
|
||||
if (!right && item.kind==64 && item.open) return {}; // Source automation controls remain clicks.
|
||||
if (!right && item.kind==55 && !state_.national_team &&
|
||||
x-item.x-(item.open?4:0)>34 && x-item.x-(item.open?4:0)<87) return {}; // Original ticket-price scale.
|
||||
if (!right && item.kind==64) return {}; // Source automation controls remain clicks.
|
||||
const bool drawer_handle=item.kind>=50&&state_.drawer_handles&&x<=item.x+3&&y<=item.y+3;
|
||||
if (!right) return {}; // LMB closes/activates; RMB alone starts a drag.
|
||||
layout_drag_ = LayoutDrag{item.id, x - item.x, y - item.y, item.x, item.y, -1, false, false, drawer_handle, right};
|
||||
@@ -659,9 +659,10 @@ DeskRequest DesktopScreen::click(int x, int y, bool right) {
|
||||
return close_drawer(item);
|
||||
// The date remains an advance control with or without its optional frame.
|
||||
if (item.kind == 58) return request(DeskRequestKind::advance_turn, item);
|
||||
if (item.kind == 55 && item.open && !state_.national_team && x - item.x - 4 > 34 && x - item.x - 4 < 87)
|
||||
return request(DeskRequestKind::change_ticket_price, item, (x - item.x - 4 - 35) / 3 + 8);
|
||||
if (item.kind == 64 && item.open) return request(DeskRequestKind::change_option, item, std::clamp((x - item.x - 4) / 33, 0, 4));
|
||||
const int content_x = item.x + (item.open ? 4 : 0);
|
||||
if (item.kind == 55 && !state_.national_team && x - content_x > 34 && x - content_x < 87)
|
||||
return request(DeskRequestKind::change_ticket_price, item, (x - content_x - 35) / 3 + 8);
|
||||
if (item.kind == 64) return request(DeskRequestKind::change_option, item, std::clamp((x - content_x) / 33, 0, 4));
|
||||
return {}; // Noninteractive status fields must not invent layout/game changes.
|
||||
}
|
||||
return {};
|
||||
|
||||
@@ -1177,6 +1177,29 @@ int main(int argc, char** argv) {
|
||||
check(date_drag.pointer_up(40,60,true).layout_operation==DeskLayoutOperation::move_item,
|
||||
"unframed date retains right-button movement");
|
||||
check(desk.render().pixels == pixels,"commands cannot mutate the saved game view");
|
||||
for(bool framed : {true,false}) {
|
||||
auto controls=d;
|
||||
controls.items={{1,20,80,98,36,55,0,0,framed,false},
|
||||
{2,20,130,173,38,64,0,0,framed,false}};
|
||||
const int origin=20+(framed?4:0);
|
||||
for(int offset : {34,35,86,87}) {
|
||||
DesktopScreen price_control(data,controls);
|
||||
price_control.pointer_down(origin+offset,90);
|
||||
const auto price_action=price_control.pointer_up(origin+offset,90);
|
||||
check(price_action.kind==((offset==35||offset==86)?
|
||||
DeskRequestKind::change_ticket_price:DeskRequestKind::none),
|
||||
"framed and unframed admission controls use the rendered Source endpoints");
|
||||
if(offset==35||offset==86)
|
||||
check(price_action.value==(offset==35?8:25),"admission endpoint preserves its exact value");
|
||||
}
|
||||
for(int offset : {32,33,65,66,98,99,131,132}) {
|
||||
DesktopScreen automation_control(data,controls);
|
||||
automation_control.pointer_down(origin+offset,140);
|
||||
const auto option_action=automation_control.pointer_up(origin+offset,140);
|
||||
check(option_action.kind==DeskRequestKind::change_option && option_action.value==offset/33,
|
||||
"automation cell boundaries follow the optional frame offset");
|
||||
}
|
||||
}
|
||||
desk.reject_action("unsupported_menu");
|
||||
check(!desk.pending() && desk.render().pixels == pixels,"rejected command preserves state");
|
||||
check(desk.key("A").menu_kind == 3,"original A hotkey opens lineup");
|
||||
|
||||
Reference in new issue
Block a user