Fix unframed desktop date and folder input (by Codex)

This commit is contained in:
Codex committed 2026-11-02 16:14:11 +01:00
1 parent 9c10a2bfeb
commit 8b1dc16233
4 files changed
+191 -67

No files matched your search

+12 -10
View File
@@ -5744,19 +5744,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
error="invalid_desk_folder_child_return"; return false;
}
bool owner_open=false;
bool owner_visible=false;
for(size_t item=1;item<kItems;++item) {
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
// The frame bit does not hide folder contents; require a visible linked owner.
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
int cursor=0;size_t visited=0;
while(++visited<kItems) {
const int next=expected[size_t(cursor)*kStride+5];
if(next==int(item)) { owner_open=true;break; }
if(next==int(item)) { owner_visible=true;break; }
if(next<=0||next>=int(kItems)) break;
cursor=next;
}
if(owner_open) break;
if(owner_visible) break;
}
if(!owner_open) { error="desk_folder_child_owner_closed"; return false; }
if(!owner_visible) { error="desk_folder_child_owner_hidden"; return false; }
const int max_x=std::max(1,319-int(expected[at+3])),max_y=std::max(1,239-int(expected[at+4]));
const int source_x=int(moved_x&0xefff);
const bool snap=g_.memory.has(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)&&g_.memory.u8(::bmh::layout::CareerSession_DispatchDesktopLayout_RuntimeField2)==0;
@@ -5797,19 +5798,20 @@ bool CareerSession::dispatch_desktop_layout(const ui::DeskRequest& request, uint
(expected[at+13]&0x7f)!=folder||expected[at+12]>=50) {
error="invalid_desk_bin_restore";return false;
}
bool owner_open=false;
bool owner_visible=false;
for(size_t item=1;item<kItems;++item) {
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+13]&0x80)==0) continue;
// The frame bit does not hide folder contents; require a visible linked owner.
if(expected[item*kStride+12]!=50+folder||(expected[item*kStride+1]&0x10)!=0) continue;
int cursor=0;size_t visited=0;
while(++visited<kItems) {
const int next=expected[size_t(cursor)*kStride+5];
if(next==int(item)) { owner_open=true;break; }
if(next==int(item)) { owner_visible=true;break; }
if(next<=0||next>=int(kItems)) break;
cursor=next;
}
if(owner_open)break;
if(owner_visible)break;
}
if(!owner_open) { error="desk_bin_restore_folder_closed";return false; }
if(!owner_visible) { error="desk_bin_restore_folder_hidden";return false; }
int tail=0;size_t guard=0;
while(expected[size_t(tail)*kStride+5]!=0) {
if(++guard>=kItems) { error="invalid_desk_layout_chain";return false; }
+8 -3
View File
@@ -309,8 +309,12 @@ std::optional<DeskItem> DesktopScreen::folder_child_at(int x,int y) const {
const int inset = folder.kind >= 50 && !folder.open ? 8 : 0;
if (x < folder.x || y < folder.y || x >= folder.x + folder.width - inset ||
y >= folder.y + folder.height - inset) continue;
if(folder.disabled||folder.kind<50||folder.kind>52||!folder.open) return std::nullopt;
const int folder_id=folder.kind-50,left=folder.x+9,top=folder.y+8,right=folder.x+folder.width-4,bottom=folder.y+folder.height-4;
if(folder.disabled||folder.kind<50||folder.kind>52) return std::nullopt;
// The open bit adds a frame; unframed folders still draw usable tiles.
// Match DeskDrawerRenderer's content origin and wrapping bounds.
const int frame = folder.open ? 4 : 0;
const int folder_id=folder.kind-50,left=folder.x+frame+5,top=folder.y+frame+4;
const int right=folder.x+frame+folder.width-4,bottom=folder.y+frame+folder.height-4;
int child_x=left,child_y=top;
for(uint8_t id:state_.folder_icon_slots[size_t(folder_id)]) {
if(child_x+32>right) child_x=left,child_y+=27;
@@ -653,7 +657,8 @@ DeskRequest DesktopScreen::click(int x, int y, bool right) {
// The corner closes through the same transaction as the quickbar.
if (item.open && state_.drawer_handles && x <= item.x + 3 && y <= item.y + 3)
return close_drawer(item);
if (item.kind == 58 && item.open) return request(DeskRequestKind::advance_turn, 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));
+40
View File
@@ -780,6 +780,31 @@ int main(int argc, char** argv) {
child_return.layout_after[3*16+6]==49,
"RMB drag from the rendered 32×25 folder tile returns it to the visible chain");
check(folder_drag.take_sound_ids().empty(),"folder-child release cannot replay its down-event append");
// Unframed folders render the same tiles four pixels nearer the origin.
auto unframed_child_desk=child_desk;
unframed_child_desk.layout_snap=true;
unframed_child_desk.items.back().open=false;
unframed_child_desk.items.back().width=50;
unframed_child_desk.items.back().height=41;
unframed_child_desk.layout_records[49][13]=0;
unframed_child_desk.layout_records[13]=unframed_child_desk.layout_records[3];
unframed_child_desk.layout_records[13][12]=12;
unframed_child_desk.folder_icon_slots[0]={13};
DesktopScreen unframed_child(data,unframed_child_desk);
check(unframed_child.pointer_down(46,45).kind==DeskRequestKind::none &&
unframed_child.pointer_up(46,45).kind==DeskRequestKind::advance_turn,
"LMB on an unframed folder tile activates its native kickoff action");
DesktopScreen unframed_drag(data,unframed_child_desk);
unframed_drag.pointer_down(46,45,true);
check(unframed_drag.take_sound_ids()==std::vector<uint8_t>({15,12,15}),
"unframed child starts extraction rather than dragging the folder body");
unframed_drag.pointer_move(176,100);
const auto unframed_return=unframed_drag.pointer_up(176,100,true);
check(unframed_return.item_id==13 && unframed_return.menu_kind==12 &&
unframed_return.layout_operation==DeskLayoutOperation::return_folder_child &&
unframed_return.layout_after[13*16]==175 && unframed_return.layout_after[13*16+2]==95 &&
unframed_return.layout_after[49*16+5]==13,
"RMB extraction uses the rendered unframed tile origin and returns the kickoff icon");
DesktopScreen folder_drop(data,child_desk);
folder_drop.pointer_down(50,49,true); folder_drop.take_sound_ids();
folder_drop.pointer_move(55,52);
@@ -1119,6 +1144,21 @@ int main(int argc, char** argv) {
check(desk.click(20,40).kind == DeskRequestKind::none,"no duplicate advance request");
++d.revision; desk.acknowledge(d);
check(desk.click(165,125).kind == DeskRequestKind::advance_turn,"kickoff icon advances");
auto unframed_date=d;
unframed_date.items.front().open=false;
unframed_date.layout_records[1][13]&=0x7f;
DesktopScreen date_click(data,unframed_date);
check(date_click.pointer_down(20,40).kind==DeskRequestKind::none,
"date press waits for its release without entering layout drag");
const auto date_turn=date_click.pointer_up(20,40);
check(date_turn.kind==DeskRequestKind::advance_turn && date_turn.menu_kind==58 &&
date_turn.manager_slot==d.manager_slot && date_turn.revision==d.revision &&
date_click.pointer_up(20,40).kind==DeskRequestKind::none,
"unframed date body emits exactly one authenticated advance action");
DesktopScreen date_drag(data,unframed_date);
date_drag.pointer_down(20,40,true); date_drag.pointer_move(40,60);
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");
desk.reject_action("unsupported_menu");
check(!desk.pending() && desk.render().pixels == pixels,"rejected command preserves state");