// SPDX-License-Identifier: GPL-3.0-only // Implementation of PitchScreen and the pitch_extras_from_save/game projections (pitch.hpp): board geometry, // drag-and-drop, formation and set-piece editors, and request construction. Rendering does not mutate the // authoritative positions; changes only appear after the session acknowledges a new lineup and extras. #include "formats/executable_layout.hpp" #include "ui/pitch.hpp" #include #include #include #include "formats/savestate.hpp" #include "game/messages.hpp" #include "game/state.hpp" #include "ui/manager.hpp" namespace bmh::ui { namespace { Bytes block(const SaveState& save, uint32_t address) { const auto& b=save.block(address); return Bytes(save.stream().begin()+b.offset, save.stream().begin()+b.offset+b.size); } void copy(Image& out,const Image& src,int sx,int sy,int x,int y,int w,int h,int transparent=-1) { if(sx<0||sy<0||sx+w>src.width||sy+h>src.height)throw FormatError("pitch: original atlas bounds"); for(int yy=0;yy=0&&y+yy>=0&&x+xx=src.width||source_y>=src.height|| target_x<0||target_y<0||target_x>=out.width||target_y>=out.height)continue; const auto pixel=src.pixels.at(size_t(source_y)*src.width+source_x); if(transparent>=0&&pixel==transparent)continue; // UsesForTheseSprites/DrawOpaquePlaneMask program VGA bit mask 0x80: only palette plane 7 // is changed, while the low seven destination bits remain untouched. auto& destination=out.at(target_x,target_y); destination=uint8_t((destination&0x7f)|(pixel&0x80)); } } void rect(Image& out,int x,int y,int w,int h,uint8_t color){ for(int yy=std::max(0,y);yy& teams,const LeImage& exe,uint64_t revision) { PitchExtras e;e.manager_slot=memory.u8(::bmh::layout::ActiveManager);e.revision=revision; const int count=memory.u8(::bmh::layout::ManagerCount); if(count<1||count>4||e.manager_slot>=count||teams.size()!=size_t(count))throw FormatError("pitch: invalid active manager"); e.runtime_club=teams.at(e.manager_slot); // The national-team desk has no club of its own (runtime club kNoTeam) and runs on the // national pool; the lineup page accepts it under the same condition (see lineup.cpp). const bool national=e.runtime_club==kNoTeam&&e.manager_slot==0&&count==1&& ((memory.u32(::bmh::layout::CompetitionSelection)&2)!=0|| (memory.has(::bmh::layout::CoachActive)&&memory.u8(::bmh::layout::CoachActive)!=0)); if(e.runtime_club<0||(e.runtime_club>=exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField)&&!national)) throw FormatError("pitch: unsupported club"); const size_t m=size_t(e.manager_slot)*0xb0c,f=size_t(e.manager_slot)*0x160; if(managers.size() teams; const int count=memory.u8(::bmh::layout::ManagerCount); if(count<1||count>4||managers.size()=0){ const auto range=squad_range(opponent_team); if(!range.count||range.first+range.count>game.squad_slots.size()) throw FormatError("pitch: unsupported live opponent squad"); e.opponent_team=opponent_team; e.opponent_name=game.club_name(opponent_team); const size_t own_base=size_t(e.manager_slot)*0x840; for(size_t row=1;row(range.count,11);++row){ const uint16_t slot=game.squad_slots.at(range.first+row); const int id=slot&0x0fff; if(id==0x0fff||!(slot&0x8000)||size_t(id)>=game.players.size()|| size_t(id)>=game.player_name_offsets.size())continue; const auto& player=game.players.at(size_t(id)); if(player.position()==0)continue; const size_t name_at=game.player_name_offsets.at(size_t(id)); if(name_at>=game.player_names.size())throw FormatError("pitch: opponent name outside pool"); const auto end=std::find(game.player_names.begin()+name_at,game.player_names.end(),uint8_t(0)); if(end==game.player_names.end())throw FormatError("pitch: unterminated opponent name"); PitchOpponent opponent;opponent.row=int(row);opponent.player_id=id;opponent.slot=slot; opponent.name=std::string(game.player_names.begin()+name_at,end); opponent.position=player.position(); opponent.detail_text=message_text(game,::bmh::layout::Pitch_FormatError_TextPointer)+exe.cstring(::bmh::layout::CupDraw_FormatError_TextPointer)+ format_number(game,player.strength(true),2)+exe.cstring(::bmh::layout::CupDraw_FormatError_ExecutableField)+message_text(game,::bmh::layout::Pitch_FormatError_TextPointer2)+ format_number(game,int((player.w364>>2)&0x3f),2)+message_text(game,::bmh::layout::Pitch_FormatError_TextPointer3)+ format_number(game,int((player.w368>>18)&0x3f),2)+exe.cstring(::bmh::layout::ClubInfo_Raw_ExecutableField); for(int own=0;own<11;++own){ const size_t assignment=own_base+size_t(own)*0x58+0x44; if(assignment+1>=game.tactics.size())throw FormatError("pitch: truncated own marking rows"); const uint16_t marked=uint16_t(game.tactics[assignment]|uint16_t(game.tactics[assignment+1])<<8); if(marked==id){const size_t own_first=e.runtime_club==kNoTeam?size_t(3072):squad_range(e.runtime_club).first; const int own_id=game.squad_slots.at(own_first+size_t(own))&0x0fff; if(own_id!=0x0fff)opponent.current_marker_player_id=own_id;break;} } e.opponent_players.push_back(std::move(opponent)); } } return e; } std::string pitch_request_json(const PitchRequest& r){std::ostringstream out; out<<"{\"kind\":"<>3)+".VGA")); sheet_=std::make_unique(data_,state_); } PitchScreen::PitchScreen(const PitchScreen& other) :PitchScreen(other.data_,other.state_,other.extras_){ pending_=other.pending_;selected_=other.selected_;hovered_=other.hovered_;ghost_=other.ghost_; order_hover_grid_=other.order_hover_grid_;pointer_grid_=other.pointer_grid_; scroll_=other.scroll_;close_=other.close_;return_team_=other.return_team_;rejection_=other.rejection_; weights_dirty_=other.weights_dirty_; shooter_editor_open_=other.shooter_editor_open_;shooter_selection_=other.shooter_selection_; zone_cover_open_=other.zone_cover_open_; order_panel_open_=other.order_panel_open_;marking_target_row_=other.marking_target_row_; marking_scroll_=other.marking_scroll_;pressed_page_control_=other.pressed_page_control_; sheet_=std::make_unique(*other.sheet_); } PitchScreen& PitchScreen::operator=(const PitchScreen& other){ if(this!=&other){PitchScreen copy(other);*this=std::move(copy);}return *this; } void PitchScreen::validate(const LineupState& s,const PitchExtras& e)const{ if(s.manager_slot<0||s.manager_slot>3||s.runtime_club<0||(s.players.size()!=24&&s.players.size()!=16)|| e.manager_slot!=s.manager_slot||e.runtime_club!=s.runtime_club||e.revision!=s.revision||e.source!=s.source) throw FormatError("pitch: inconsistent authoritative context"); if(!e.indoor)throw FormatError("pitch: transient indoor/outdoor mode is unknown"); // OpenBMH deviates from the original: supports owner-bound designated set-piece selection in the extended manager record. // A loaded career can carry an uninitialized supported rule profile tail until the // authoritative lineup entry initializes it. Read-only preparation must // remain usable before that entry; editor commands validate the tail below. if(e.mode<1||e.mode>3)throw FormatError("pitch: invalid game mode"); if(s.automatic_formation<0||s.automatic_formation>8)throw FormatError("pitch: invalid automatic formation"); for(size_t i=0;iout.width||baseline<5||baseline>=out.height)return; Image mask(std::max(1,width),6);font_.draw(mask,0,0,value,1); int g=0;while(g<32&&exe_.u8(::bmh::layout::Advertising_Text_RuntimeField2+g)!=color)++g; for(int yy=0;yy<6;++yy)for(int xx=0;xx=128)continue;const int g=exe_.u8(::bmh::layout::ClubInfo_Raw_RuntimeField3 + c); if(!g){xx+=2;continue;}const int sx=exe_.u16(::bmh::layout::ClubInfo_Raw_RuntimeField+g*2),w=exe_.u16(::bmh::layout::ClubInfo_Raw_RuntimeField2+g*2)-sx; copy(out,letters_,sx,(font-4)*7,xx,y+1,w,7,0);xx+=w;}} } void PitchScreen::diamond_button(Image& out,int x,int y,std::string_view value,bool selected)const{ // FormatError3: width60, height9 normalized to 10, with pressed frame and // runtime font byte Advertising_Button_RuntimeField+selected. Match the original +2 pressed offset. constexpr int width=60,height=10; int dx=x,dy=y;const int mode=exe_.u8(::bmh::layout::Advertising_Button_RuntimeField + unsigned(selected)); if(selected){const uint8_t bg=out.at(x,y+height);rect(out,x,y,width+1,2,bg);rect(out,x,y,2,height+1,bg);dx+=2;dy+=2;} else{rect(out,x+2,y+height,width,2,0x40);rect(out,x+width,y+2,2,height,0x40);} const int row=selected?44:74;copy(out,widgets_,24,row,dx,dy,31,10,0xc0); int used=31;while(width-used>20){const int amount=std::min(8,width-used-20); copy(out,widgets_,24,row+10,dx+used,dy,amount,10,0xc0);used+=amount;} const int tail=width-used;copy(out,widgets_,45-tail,row+20,dx+used,dy,tail,10,0xc0); if(mode==3){const auto native_value=utf8_to_original(value); text(out,dx+width/2-font_.text_width(native_value)/2,dy+7,native_value,0);} else sprite_.draw(out,dx+width/2-sprite_.text_width(value)/2,dy+7,value,mode); } void PitchScreen::jersey(Image& out,const LineupPlayer& p,int depth,int lane,int color,bool number)const{ if(p.player_id<0||((p.attributes.w364>>16)&31))return; int x=depth*8+4,y=lane*10+119; if(p.board[0x3f]!=0xff)color=3; copy(out,atlas_,208+color*16,0,x,y,16,17,0); if(!number)return; int n=(p.cards&31)+1; if(n>9){copy(out,atlas_,224,27,x+10,y,16,5,0);n-=10;x+=3;} copy(out,atlas_,208+(n%7)*16,27+(n/7)*5,x+10,y,16,5,0); } std::vector> PitchScreen::rows()const{ std::vector> r;int baseline=36; for(size_t i=0;i PitchScreen::formation_save_feedback(bool restored)const{ if(!pending_||pending_->kind!=PitchRequestKind::save_formation)return std::nullopt; auto out=render(); const int x=243+(pending_->formation%2)*38,y=110+(pending_->formation/2)*23; const uint8_t color=restored?0x6b:0; // InclusiveHoverOutlineAtYHitThroughYHit draws an inclusive outline; the players inside are untouched. rect(out,x,y,35,1,color);rect(out,x,y+20,35,1,color); rect(out,x,y,1,21,color);rect(out,x+34,y,1,21,color); return out; } bool PitchScreen::automatic_page()const{ // OpenBMH deviates from the original: supports owner-bound designated set-piece selection in the extended manager record. // PitchScreen draws AutomaticPage and accepts AA weights/formation input only // on native page bit 0x10. The full team sheet and supported rule profile editor own // their respective areas even when that bit is retained underneath. return !shooter_editor_open_&&(extras_.native_display_word&0x18)==0x18; } std::optional> PitchScreen::position_feedback() const { if (!pointer_grid_ || close_ || !(extras_.native_display_word & 8)) return {}; const auto row = selected_ ? selected_ : hovered_; if (!row || size_t(*row) >= state_.players.size()) return {}; const auto& p = state_.players.at(size_t(*row)); if (p.player_id < 0 || !(p.slot & 0xc000) || ((p.attributes.w364 >> 16) & 31)) return {}; const int depth = int(exe_.u8(::bmh::layout::PitchPreferenceDepthBases + p.attributes.position())) - 2 + int((p.attributes.w35c >> 21 & 7) >> 1); const int lane = int((p.attributes.w35c >> 24 & 7) * 800 / 7); const auto band = [&](int x, int y) { return std::min(9, (std::abs(depth - x) * 100 + std::abs(lane - y * 100)) / 200); }; return std::pair{band(int8_t(p.board[0x41]), int8_t(p.board[0x42])), band(pointer_grid_->first, pointer_grid_->second)}; } std::optional> PitchScreen::pointer_cursor(const Palette& palette) const { const auto feedback = position_feedback(); if (!feedback) return {}; const auto band = uint32_t(feedback->second); const uint32_t fill = 0xff000000u | (uint32_t(vga_dac_rgb8(uint8_t(exe_.u8(::bmh::layout::PitchPreferenceRed + band) << 4))) << 16) | (uint32_t(vga_dac_rgb8(uint8_t(exe_.u8(::bmh::layout::PitchPreferenceGreen + band) << 4))) << 8); std::array pixels{}; for (uint32_t i = 0; i < pixels.size(); ++i) { const auto index = exe_.u8(::bmh::layout::OriginalPointerPixels + i); pixels[i] = index == 0 ? 0 : index == 0x11 ? fill : palette.argb[index]; } return pixels; } Image PitchScreen::render()const{ // PitchScreen's page redraw copies the owned offscreen sheet from y=20: all // 190 rows when source bit 0x08 is clear, only the upper 88 rows when it is // set. In the latter case the pitch and its right panel are composed below. const auto list=sheet_->render(); const uint16_t display_word=shooter_editor_open_ ? uint16_t(extras_.native_display_word&0xff0f) : extras_.native_display_word; if((display_word&0x08)==0)return list; Image out=list; copy(out,background_,0,108,0,108,320,120); copy(out,atlas_,0,0,0,108,196,117); rect(out,3,225,191,2,0); rect(out,196,108,124,119,0x42); const bool marking_open=(display_word&0x0040)!=0&&extras_.opponent_team>=0&& !extras_.indoor.value_or(false); if(scroll_)copy(out,list,0,31+scroll_,0,31,320,77); // Names change locally; the full sheets remain the authoritative attributes. for(auto[row,baseline]:rows())if(baseline>34&&baseline<107&&(selected_==row||hovered_==row)){ copy(out,background_,13,baseline-5,13,baseline-5,51,6); text(out,13,baseline,state_.players.at(row).name,selected_==row?0x27:0x3e);} const auto eligible_order_row = [&](std::optional row) { return row && *row >= 0 && *row < 11 && (state_.players.at(size_t(*row)).slot & 0x8000) && ((state_.players.at(size_t(*row)).attributes.w364 >> 16) & 0x1f) == 0; }; std::optional order_row; if(eligible_order_row(hovered_))order_row=hovered_; else if(eligible_order_row(selected_))order_row=selected_; // Both the order page's hovered player and the taker editor's coverage // toggle use the native ORDER geometry and VGA plane-7 mask. const auto draw_coverage = [&](const LineupPlayer& p) { if(!(p.slot&0x8000)||((p.attributes.w364>>16)&0x1f)!=0)return; const int depth=int8_t(p.board[0x41]),lane=int8_t(p.board[0x42]); const int order_x=p.board[2],order_y=p.board[3]; const int zone_count=p.board[4]/2; const int player_x=depth*8+4, player_y=lane*10+0x77; const int radius=order_y/2+order_x+8; const int source_left=(player_x-(order_y/2+0x26-order_x))-8; const int inner=order_y/2+0x26-order_x+8; int backing_left=source_left, backing_half=inner; if(player_x-inner<3){backing_left=3;backing_half=player_x-3;} int right_span=radius; if(player_x+radius+0x15>0xc0)right_span=0xab-player_x; const int backing_right=depth*8+0x19; // CopyCrop -> UsesForTheseSprites uses the current global transparent key // (0 at this Source call site) and VGA write mask 0x80. source_mask_copy(out,atlas_,0x122-radius,0x50,backing_right,player_y,right_span,0x12,0); source_mask_copy(out,atlas_,0xc4,0x50,backing_left,player_y,backing_half+0x15,0x12,0); // The contour uses the unclipped backing geometry: DerivesRedCoverage keeps // local18 for the line start and radius for the right endpoint. int edge_x0=source_left+8; int edge_x1=depth*8+0x19+radius-8; int step=1; for(int n=0;ndraw_x0){ // SourceMaskCopy delegates to opaque DrawOpaquePlaneMask. Its 0xc0 // argument is ignored; 0x80 updates only destination bit 7. source_mask_copy(out,atlas_,0xc4,0x59,draw_x0,upper,draw_x1-draw_x0,1); source_mask_copy(out,atlas_,0xc4,0x59,draw_x0,lower,draw_x1-draw_x0,1); } } }; if(shooter_editor_open_&&zone_cover_open_){ for(int row=0;row<11;++row)draw_coverage(state_.players.at(size_t(row))); }else if(order_panel_open_&&order_row){ draw_coverage(state_.players.at(size_t(*order_row))); } for(int row=0;row<11;++row){const auto& p=state_.players.at(row);if(!(p.slot&0x8000))continue; jersey(out,p,int8_t(p.board[0x41]),int8_t(p.board[0x42]),selected_==row||hovered_==row?3:0);} if(selected_&&ghost_)jersey(out,state_.players.at(*selected_),ghost_->first,ghost_->second,1); // Eight original 35x21 formation panels, AutomaticPage; modal and Anweis // source pages own this right-hand area exclusively. if(automatic_page())for(int f=0;f<8;++f){const int x=243+(f%2)*38,y=110+(f/2)*23; copy(out,atlas_,268,38,x,y,35,21); if(state_.automatic_formation==f+1){rect(out,x,y,35,1,0x27);rect(out,x,y+20,35,1,0x27);rect(out,x,y,1,21,0x27);rect(out,x+34,y,1,21,0x27);} if(extras_.formation_mask&(1<10)--xx;if(depth>17)--xx; const auto color=exe_.u8(::bmh::layout::Pitch_Render_RuntimeField+(depth>7)+(depth>13));rect(out,xx-1,y+2+lane*2,2,1,color);}} 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,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)) button(out,196,162,texts_[(::bmh::layout::Pitch_Render_TextPointer4-::bmh::layout::TextPointerTable)/4],marking_open); button(out,196,175,texts_[(::bmh::layout::Pitch_Render_TextPointer5-::bmh::layout::TextPointerTable)/4],shooter_editor_open_); // SourceBadgeFallback/PaintsFourBorderEdges: raised frame, drawn left/top then bottom/right. rect(out,198,187,1,40,0x46);rect(out,198,187,40,1,0x46); rect(out,198,226,40,1,0x40);rect(out,237,187,1,40,0x40); copy(out,badge_,(extras_.badge%8)*38,0,199,188,38,38); if(shooter_editor_open_){ rect(out,239,110,80,113,0x42); const std::array,3> labels{{{::bmh::layout::FreeKickTakerLabel,114},{::bmh::layout::PenaltyTakerLabel,146},{::bmh::layout::CornerTakerLabel,178}}}; for(size_t i=0;i{0,0,0}); for(size_t i=0;i<3;++i){ const uint16_t encoded=extras_.set_piece_takers[i]; std::string name="AUTO"; if(encoded){const int id=int(encoded)-1;for(const auto& p:state_.players)if(p.player_id==id){name=p.name;break;}} // Text2 passes 0x6b as color to DrawnFirstBy; the preceding // button text restores CareerSession_DispatchLeagueTableControl_RuntimeField2 to FNT3 on return (18234ff). text(out,279-font_.text_width(name)/2,133+int(i)*32,name,0x6b); } } if(marking_open){ // DrawsOpponentHeaderFiveOutfieldRows draws the opponent header and five outfield rows in the // right panel; local_64 toggles the two five-row windows with XOR 5. std::string team_name=extras_.opponent_name; while(!team_name.empty()&&font_.text_width(team_name)>77)team_name.pop_back(); text(out,243,117,team_name,0x6a); for(int visible=0;visible<5;++visible){ const int source_row=1+marking_scroll_+visible; const auto found=std::find_if(extras_.opponent_players.begin(),extras_.opponent_players.end(), [&](const PitchOpponent& p){return p.row==source_row;}); if(found==extras_.opponent_players.end())continue; const int baseline=127+visible*14; const uint8_t color=marking_target_row_&& size_t(*marking_target_row_)position],0x67); std::string shown=found->name; while(!shown.empty()&&font_.text_width(shown)>56)shown.pop_back(); text(out,263,baseline,shown,color); std::string details=found->detail_text; while(!details.empty()&&font_.text_width(details)>77)details.pop_back(); text(out,243,baseline+6,details,0x69); } } if(extras_.mode!=1&&order_panel_open_){ // The original panel includes its eight atlas controls and up to six // marked substitutes above the order bars; none are generated artwork. for(int side=0;side<2;++side)for(int aspect=0;aspect<4;++aspect) copy(out,atlas_,196+aspect*16,56+side*12,243+side*58,179+aspect*12,15,12,0xc0); int bench_row=0; for(const auto& player:state_.players){ if(bench_row==6)break; if(player.player_id<0||!(player.slot&0x4000))continue; const int baseline=118+7*bench_row++; text(out,243,baseline,exe_.string_at_pointer(::bmh::layout::PitchOrderPositionPointers+ player.attributes.position()*4),0x6b); std::string name=player.name; while(!name.empty()&&font_.text_width(name)>48)name.pop_back(); text(out,252,baseline,name,0x6b); text(out,302,baseline,"("+std::to_string(player.attributes.strength())+")",0x6b); } if(order_hover_grid_){ const auto [depth,lane]=*order_hover_grid_; const auto mask=exe_.u16(::bmh::layout::PitchOrderZoneMasks+lane*38+std::min(depth,18)*2); std::string position,zone; const auto label=[&](int bit)->const std::string&{ return texts_[(::bmh::layout::PitchOrderZoneTextPointers-::bmh::layout::TextPointerTable)/4+bit]; }; for(int bit=0;bit<6;++bit)if(mask&(1<78)position.pop_back(); while(!zone.empty()&&font_.text_width(zone)>78)zone.pop_back(); text(out,241,165,position,0x6b); text(out,241,173,zone,0x69); } } if(extras_.mode!=1&&order_panel_open_&&order_row){ const auto& player=state_.players.at(size_t(*order_row)); for(int aspect=0;aspect<4;++aspect){ const int y=181+12*aspect,value=player.board[size_t(2+aspect)]; if(value){copy(out,atlas_,0x103,0x3b,0x103,y,value,9,0xc0); rect(out,0x105,y+9,value,1,0);rect(out,0x103+value,y+2,1,8,0);} } } // Native lower-right swatches compare the current position with the pointer. const auto feedback = position_feedback(); copy(out,atlas_,feedback ? 259 + feedback->first * 5 : 309,68,305,233,5,4,0xc0); copy(out,atlas_,feedback ? 259 + feedback->second * 5 : 309,68,312,230,5,4,0xc0); return out; } std::optional> PitchScreen::grid(int x,int y){ if(x<=3||x>=162||y<=117||y>=209)return {}; return std::pair{(x-4)/8,(y-119)/10}; } std::optional PitchScreen::hit_row(int x,int y)const{ if(x>=0&&x<63&&y>=31&&y<107)for(auto[row,baseline]:rows())if(baseline-7<=y&&y34&&baseline<107)return row; if(const auto pos=grid(x,y))for(int row=0;row<11;++row){const auto&p=state_.players.at(row); if(p.player_id>=0&&(p.slot&0xc000)&&((p.attributes.w364>>16)&31)==0&&int8_t(p.board[0x41])==pos->first&&int8_t(p.board[0x42])==pos->second)return row;} return {}; } std::optional PitchScreen::hit_opponent_row(int x,int y)const{ if(x<239||x>=320||y<122||y>=192)return {}; const int source_row=1+marking_scroll_+(y-122)/14; for(size_t i=0;i=0){const auto&q=state_.players.at(second);r.second_row=second;r.second_player=q.player_id;r.second_slot=q.slot;} pending_=r;rejection_.clear();return r; } PitchRequest PitchScreen::automatic_request(PitchRequestKind kind,int index){ PitchRequest r;r.kind=kind;r.manager_slot=state_.manager_slot;r.runtime_club=state_.runtime_club; r.revision=state_.revision;r.indoor=extras_.indoor.value_or(false);r.expected_mode=uint8_t(extras_.mode);r.old_weights=r.new_weights=extras_.automatic_weights; if(kind==PitchRequestKind::set_automatic_weight){ r.weight_index=index;const int shift=2*index; const int next=(((r.old_weights>>shift)&3)+1)&3; r.new_weights=uint8_t((r.old_weights&~(3<=extras_.opponent_players.size())return {}; const auto& opponent=extras_.opponent_players.at(size_t(opponent_row)); PitchRequest r;r.kind=PitchRequestKind::set_player_marking;r.manager_slot=state_.manager_slot; r.runtime_club=state_.runtime_club;r.revision=state_.revision;r.indoor=extras_.indoor.value_or(false); r.expected_mode=uint8_t(extras_.mode);r.expected_display_word=extras_.native_display_word; r.opponent_team=extras_.opponent_team;r.opponent_row=opponent.row;r.opponent_player=opponent.player_id; r.opponent_slot=opponent.slot; if(own_row>=0){ if(size_t(own_row)>=state_.players.size())return {}; const auto& own=state_.players.at(size_t(own_row)); if(own_row>=11||own.player_id<0||!(own.slot&0x8000)||((own.attributes.w364>>16)&31)!=0)return {}; r.row=own_row;r.player_id=own.player_id;r.slot=own.slot; r.expected_marking_player_id=uint16_t(own.board[0x44]|uint16_t(own.board[0x45])<<8); }else{ r.row=-1;r.player_id=-1;r.expected_marking_player_id=uint16_t(opponent.player_id); } pending_=r;rejection_.clear();return r; } PitchRequest PitchScreen::request_page_control(int control){ if(pending_||close_||control!=1)return {}; return page_request(control); } PitchRequest PitchScreen::order_request(int aspect,int value){ if(!selected_||*selected_>=11)return {}; const auto& p=state_.players.at(size_t(*selected_)); PitchRequest r;r.kind=PitchRequestKind::set_player_order;r.manager_slot=state_.manager_slot; r.runtime_club=state_.runtime_club;r.revision=state_.revision;r.indoor=extras_.indoor.value_or(false);r.expected_mode=uint8_t(extras_.mode); r.row=*selected_;r.player_id=p.player_id;r.slot=p.slot;r.order_aspect=aspect; r.expected_display_word=extras_.native_display_word;r.expected_set_piece_values=extras_.set_piece_takers; r.expected_set_piece_signature=extras_.set_piece_signature; r.expected_order_value=p.board[size_t(2+aspect)];r.new_order_value=value;pending_=r;rejection_.clear();return r; } PitchRequest PitchScreen::click(int x,int y,bool right){ if(pending_||close_)return {}; pointer_grid_=grid(x,y); const uint16_t display_word=shooter_editor_open_ ? uint16_t(extras_.native_display_word&0xff0f) : extras_.native_display_word; if(right){ pointer_grid_.reset(); if((display_word&0x08)==0){sheet_->click(x,y,true);close_=sheet_->close_requested();} else if(selected_){selected_.reset();ghost_.reset();} else {close_=true;zone_cover_open_=false;} return {}; } if((display_word&0x08)==0){ // On the full-sheet redraw, PitchScreen presents its original footer // controls at (1,215) and (58,215): data A/B and the pitch/team page. if(y>=215&&y<=224&&x>=1&&x<=56)return page_request(0); if(y>=215&&y<=224&&x>=58&&x<=113)return page_request(1); // Keep the native team-sheet row actions available while this page is // shown: left-column selection/swap and right-column player info use // the same hitboxes and authoritative row identity as LineupScreen. const auto row_action=sheet_->click(x,y,false); if(row_action.kind==LineupRequestKind::swap_players) return request(PitchRequestKind::swap_players,row_action.first_row,row_action.second_row); if(row_action.kind==LineupRequestKind::open_player_info){ PitchRequest r;r.kind=PitchRequestKind::open_player_info;r.manager_slot=state_.manager_slot; r.runtime_club=state_.runtime_club;r.revision=state_.revision;r.row=row_action.first_row; const auto& player=state_.players.at(size_t(r.row));r.player_id=player.player_id;r.slot=player.slot; pending_=r;rejection_.clear();return r; } return {}; } if(shooter_editor_open_){ if(x>=249&&x<=309&&((y>=114&&y<=123)||(y>=146&&y<=155)||(y>=178&&y<=187))){ const int value=y<=123?2:y<=155?3:4; shooter_selection_=shooter_selection_==value?1:value;return {}; } if(x>=249&&x<=309&&y>=211&&y<=219)return set_piece_request(PitchRequestKind::auto_set_piece_takers); // PageRequest control 5 remains present in the active editor table. Its // repeated click toggles only the private scratch word's coverage bit. if(x>=196&&x<=239&&y>=175&&y<=185){zone_cover_open_=!zone_cover_open_;return {};} if(x>=196&&x<=239&&y>=110&&y<=120)return page_request(0); if(x>=196&&x<=239&&y>=123&&y<=133)return page_request(1); if(x>=196&&x<=239&&y>=136&&y<=146)return page_request(2); if(extras_.mode!=1&&x>=196&&x<=239&&y>=149&&y<=159)return page_request(3); if(extras_.opponent_team>=0&&!extras_.indoor.value_or(false)&& x>=196&&x<=239&&y>=162&&y<=172)return page_request(4); if(shooter_selection_>=2&&shooter_selection_<=4){ if(auto row=hit_row(x,y)){ const auto& p=state_.players.at(size_t(*row)); if((p.slot&0xc000)==0||((p.attributes.w364>>16)&0x1f)!=0){rejection_="Nur ein gesunder, markierter Kaderspieler kann gewählt werden.";return {};} auto r=set_piece_request(PitchRequestKind::set_piece_taker);r.row=*row;r.player_id=p.player_id;r.slot=p.slot; r.set_piece_selector=shooter_selection_;r.expected_set_piece_value=extras_.set_piece_takers[size_t(shooter_selection_-2)]; pending_=r;return r; } if(!selected_)return {}; } // OpenBMH extension: the field stays editable inside the editor. A click picks a taker // only while a taker kind is chosen; otherwise (or with a player already marked for a // move) the placement below works as on the normal page. } if(extras_.mode!=1&&order_panel_open_&&x>=243&&x<=315&&y>=179&&y<=226){ if(!selected_||*selected_>=11){rejection_="Für Anweisungen muss ein Startspieler markiert sein.";return {};} const int aspect=(y-179)/12,xvalue=x; const auto current=int(state_.players.at(size_t(*selected_)).board[size_t(2+aspect)]); int next=current; if(xvalue<258)next=std::max(2,current-1); else if(xvalue>300)next=std::min(40,current+1); else if(xvalue>=259&&xvalue<=299)next=std::clamp(xvalue-259,2,40); if(next==current)return {}; return order_request(aspect,next); } if(x>=196&&x<=239&&y>=110&&y<=120)return page_request(0); if(x>=196&&x<=239&&y>=123&&y<=133)return page_request(1); if(x>=196&&x<=239&&y>=136&&y<=146)return page_request(2); if(x>=196&&x<=239&&y>=175&&y<=185){ auto r=set_piece_request(PitchRequestKind::open_set_piece_editor); if(r.kind==PitchRequestKind::none)return {}; r.new_display_word=uint16_t((extras_.native_display_word&0xff00)|((extras_.native_display_word&0x008f)|0x0080));pending_=r;return r; } if(extras_.mode!=1&&x>=196&&x<=239&&y>=149&&y<=159)return page_request(3); if(extras_.opponent_team>=0&&!extras_.indoor.value_or(false)&& x>=196&&x<=239&&y>=162&&y<=172)return page_request(4); if(x>=196&&x<=239&&y>=149&&y<=172){ rejection_="order and marking controls are read only in this context";return {}; } const bool marking_open=(display_word&0x0040)!=0&&extras_.opponent_team>=0&& !extras_.indoor.value_or(false); if(marking_open&&x>=239&&x<320&&y>=110&&y<=225){ if(const auto target=hit_opponent_row(x,y)){ if(marking_target_row_==target){ const auto r=marking_request(-1,*target); marking_target_row_.reset();selected_.reset();return r; } if(selected_&&*selected_<11){ const auto r=marking_request(*selected_,*target); selected_.reset();marking_target_row_.reset();return r; } marking_target_row_=target;selected_.reset();hovered_.reset();ghost_.reset();return {}; } if(!marking_target_row_&&(y<123||y>190))marking_scroll_^=5; return {}; } if(!state_.entry_prepared){rejection_="lineup entry has not been authoritatively prepared";return {};} // PitchScreen: AA controls are unavailable during a player placement. Weights // act on press; formation choice acts on release, represented by one click. if(automatic_page()&&!state_.in_match&&!selected_&&x>=240&&x<320){ if(y>=208&&y<222){ if(extras_.mode==1){rejection_="automatic weights are unavailable in Modus I";return {};} return automatic_request(PitchRequestKind::set_automatic_weight,(x-240)/27); } if(y>=112&&y<210){ // Original hit grid is 24 high (drawn panels are 23 apart). const int formation=((y-112)/24)*2+(x>279); if(!(extras_.formation_mask&(1<=63&&x<320&&y>=31&&y<110){ const auto all=rows();int current=0; for(size_t i=0;i65?1:0),0,std::max(0,int(all.size())-10)); if(next!=current){scroll_+=all.at(next).second-all.at(current).second;hovered_.reset();} return {}; } if(selected_){const auto&p=state_.players.at(*selected_); if(auto pos=grid(x,y)){if(p.row>=11||((p.attributes.w364>>16)&31))return {}; if(marking_open&&marking_target_row_){const auto r=marking_request(*selected_,*marking_target_row_); selected_.reset();marking_target_row_.reset();ghost_.reset();return r;} if(pos->first==int8_t(p.board[0x41])&&pos->second==int8_t(p.board[0x42])){selected_.reset();ghost_.reset();return {};} return request(PitchRequestKind::move_player,*selected_,-1,pos->first,pos->second);} if(auto row=hit_row(x,y)){if(*row==*selected_){selected_.reset();ghost_.reset();return {};}return request(PitchRequestKind::swap_players,*selected_,*row);} return {}; } if(auto row=hit_row(x,y)){ if(marking_open&&marking_target_row_){const auto r=marking_request(*row,*marking_target_row_); marking_target_row_.reset();return r;} selected_=row;hovered_=row;ghost_.reset();return {};} return {}; } PitchRequest PitchScreen::pointer_down(int x,int y,bool right){ source_down_release_barrier_=false; const uint16_t display_word=shooter_editor_open_ ? uint16_t(extras_.native_display_word&0xff0f) : extras_.native_display_word; const bool sheet_footer=(display_word&0x08)==0&&y>=215&&y<=224&& ((x>=1&&x<=56)||(x>=58&&x<=113)); const bool lower=x>=196&&x<=239&& ((y>=110&&y<=146)||(extras_.mode!=1&&y>=149&&y<=159)|| (extras_.opponent_team>=0&&!extras_.indoor.value_or(false)&&y>=162&&y<=172)||(y>=175&&y<=185)); const bool editor_hit=shooter_editor_open_&& ((x>=249&&x<=309&&((y>=114&&y<=123)||(y>=146&&y<=155)||(y>=178&&y<=187)||(y>=211&&y<=219)))|| (shooter_selection_>=2&&(x<163&&y>=31&&y<209))); const bool order_hit=extras_.mode!=1&&order_panel_open_&&x>=243&&x<=315&&y>=179&&y<=226; if(!right&&!lower&&!editor_hit&&!order_hit&&!sheet_footer)return {}; source_down_release_barrier_=true; return click(x,y,right); } PitchRequest PitchScreen::save_formation(int x,int y){ if(pending_||close_||selected_)return {}; if(state_.in_match){rejection_="formation slots are unavailable during a live intervention";return {};} if(!state_.entry_prepared){rejection_="lineup entry has not been authoritatively prepared";return {};} if(!automatic_page())return {}; if(x<240||x>=320||y<112||y>=210)return {}; const int formation=((y-112)/24)*2+(x>279); if(formation<4){rejection_="long press only supports the four own formation slots";return {};} for(int row=0;row<11;++row)if(state_.players[row].player_id<0||!(state_.players[row].slot&0x8000)){ rejection_="saving a formation requires eleven nominated starters";return {};} auto r=automatic_request(PitchRequestKind::save_formation,formation); for(int row=0;row<11;++row){r.formation_positions[row]=state_.players[row].board[0x41]; r.formation_positions[11+row]=state_.players[row].board[0x42];} pending_=r;return r; } bool PitchScreen::move(int x,int y){if(pending_||close_)return false; const auto old_pointer_grid=pointer_grid_; if((extras_.native_display_word&0x08)==0)return sheet_->move(x,y); pointer_grid_=grid(x,y); const auto old=hovered_;const auto oldghost=ghost_;hovered_=hit_row(x,y);ghost_=selected_?grid(x,y):std::nullopt; const auto old_grid=order_hover_grid_; order_hover_grid_=order_panel_open_?grid(x,y):std::nullopt; return old!=hovered_||oldghost!=ghost_||old_grid!=order_hover_grid_||old_pointer_grid!=pointer_grid_; } PitchRequest PitchScreen::key(std::string_view key){ // PitchScreen's desktop pages cancel selection/return on mouse event 8. // Escape must not synthesize that right click. The separate live caller // retains its existing keyboard return. if(state_.in_match&&(key=="ESC"||key=="ESCAPE"))return click(0,0,true); return {}; } void PitchScreen::acknowledge(LineupState s,PitchExtras e){ if(!pending_)throw FormatError("pitch: no command to acknowledge"); validate(s,e); if(s.revision<=state_.revision||s.manager_slot!=state_.manager_slot||s.runtime_club!=state_.runtime_club||s.source!="engine_projection"||!s.entry_prepared) throw FormatError("pitch: stale or mismatched acknowledgement"); if(e.indoor!=extras_.indoor) throw FormatError("pitch: acknowledgement changed the captured live pitch mode"); if(s.players.size()!=state_.players.size())throw FormatError("pitch: changed squad extent"); if(pending_->kind==PitchRequestKind::move_player){const auto& p=s.players.at(pending_->row); if(p.player_id!=pending_->player_id||p.slot!=pending_->slot||int8_t(p.board[0x41])!=pending_->new_depth||int8_t(p.board[0x42])!=pending_->new_lane) throw FormatError("pitch: acknowledgement does not confirm placement");} if(pending_->kind==PitchRequestKind::swap_players&& (s.players.at(pending_->row).player_id!=pending_->second_player||s.players.at(pending_->second_row).player_id!=pending_->player_id)) throw FormatError("pitch: acknowledgement does not confirm player exchange"); const auto kind=pending_->kind; if(kind==PitchRequestKind::set_automatic_weight||kind==PitchRequestKind::apply_formation||kind==PitchRequestKind::save_formation){ auto formations=extras_.formations;auto mask=extras_.formation_mask; if(kind==PitchRequestKind::save_formation){ std::copy(pending_->formation_positions.begin(),pending_->formation_positions.end(),formations.begin()+pending_->formation*22); mask|=uint8_t(1<formation); } if(e.indoor!=extras_.indoor||e.mode!=extras_.mode||e.badge!=extras_.badge||e.formation_mask!=mask|| e.formations!=formations||e.automatic_weights!=pending_->new_weights) throw FormatError("pitch: acknowledgement changes unrelated AA context or fails to confirm weights"); if((kind==PitchRequestKind::apply_formation||kind==PitchRequestKind::save_formation)&&s.automatic_formation!=pending_->formation+1) throw FormatError("pitch: acknowledgement does not confirm automatic formation"); if(kind==PitchRequestKind::set_automatic_weight){ if(s.automatic_formation!=state_.automatic_formation) throw FormatError("pitch: weight change must not run automatic selection"); for(size_t row=0;rowexpected_set_piece_values!=expected||pending_->expected_display_word!=expected_word|| pending_->expected_set_piece_signature!=extras_.set_piece_signature||pending_->expected_mode!=extras_.mode|| e.set_piece_signature!=0x3253) throw FormatError("pitch: set-piece acknowledgement is stale or has an invalid signature"); if(kind==PitchRequestKind::open_set_piece_editor||kind==PitchRequestKind::close_set_piece_editor){ const uint16_t source_word=kind==PitchRequestKind::open_set_piece_editor ?uint16_t((expected_word&0xff00)|((expected_word&0x008f)|0x0080)) :uint16_t(expected_word&~uint16_t(0x80)); if(pending_->new_display_word!=source_word) throw FormatError("pitch: editor transition does not match Source display-word mask"); auto normalized=expected; if(kind==PitchRequestKind::open_set_piece_editor){ for(auto& value:normalized){ const int id=int(value)-1; const bool member=value&&value<=0x0fff&&std::any_of(state_.players.begin(),state_.players.end(), [&](const LineupPlayer& p){return p.player_id==id;}); if(!member)value=0; } } if(e.set_piece_takers!=normalized||e.native_display_word!=pending_->new_display_word) throw FormatError("pitch: editor-word acknowledgement is inconsistent"); }else if(kind==PitchRequestKind::set_piece_taker){ const size_t idx=size_t(pending_->set_piece_selector-2); if(idx>=3||expected[idx]!=pending_->expected_set_piece_value|| e.native_display_word!=expected_word||e.set_piece_takers[idx]!=uint16_t(pending_->player_id+1)) throw FormatError("pitch: selected set-piece player was not acknowledged"); for(size_t i=0;i<3;++i)if(i!=idx&&e.set_piece_takers[i]!=expected[i]) throw FormatError("pitch: unrelated set-piece taker changed"); }else if(e.set_piece_takers!=std::array{0,0,0}||e.native_display_word!=expected_word) throw FormatError("pitch: AUTO did not clear all designated takers"); } if(kind==PitchRequestKind::select_pitch_page){ uint16_t expected=pending_->expected_display_word; switch(pending_->page_control){ case 0: expected=uint16_t((expected&~uint16_t(0x80))^0x0003);break; case 1: expected=uint16_t(expected^0x000c);break; case 2: expected=uint16_t(((expected&~uint16_t(0x0080))&0x008f)|0x0010);break; case 3: expected=uint16_t(((expected&~uint16_t(0x0080))&0x008f)|0x0020);break; case 4: expected=uint16_t(((expected&~uint16_t(0x0080))&0x008f)|0x0040);break; default: throw FormatError("pitch: invalid Source page control"); } if(pending_->new_display_word!=expected||e.native_display_word!=expected||e.set_piece_takers!=extras_.set_piece_takers|| pending_->expected_mode!=extras_.mode||pending_->expected_set_piece_values!=extras_.set_piece_takers|| pending_->expected_set_piece_signature!=extras_.set_piece_signature|| e.set_piece_signature!=extras_.set_piece_signature) throw FormatError("pitch: Source page ACK changes unrelated set-piece fields or word"); if(pending_->page_control==4&& (pending_->opponent_team<0||pending_->opponent_team!=extras_.opponent_team|| e.opponent_team!=extras_.opponent_team||e.opponent_players!=extras_.opponent_players)) throw FormatError("pitch: man-marking page ACK changed its authenticated live opponent"); } if(kind==PitchRequestKind::set_player_marking){ if(pending_->opponent_team<0||pending_->opponent_team!=extras_.opponent_team|| e.opponent_team!=extras_.opponent_team||e.native_display_word!=extras_.native_display_word|| pending_->expected_display_word!=extras_.native_display_word||pending_->expected_mode!=extras_.mode|| pending_->indoor||pending_->opponent_row<1||pending_->opponent_row>10||pending_->opponent_player<0) throw FormatError("pitch: man-marking ACK is stale or changed its live context"); for(size_t row=0;rowrow&&pending_->row>=0&& (pending_->player_id!=state_.players[row].player_id||pending_->slot!=state_.players[row].slot|| uint16_t(expected[0x44]|uint16_t(expected[0x45])<<8)!=pending_->expected_marking_player_id)) throw FormatError("pitch: own marking row changed before assignment"); if(uint16_t(expected[0x44]|uint16_t(expected[0x45])<<8)==pending_->opponent_player){ expected[0x44]=0xff;expected[0x45]=0x0f; } if(int(row)==pending_->row&&pending_->row>=0){ expected[0x44]=uint8_t(pending_->opponent_player); expected[0x45]=uint8_t(pending_->opponent_player>>8); } } if(s.players[row].board!=expected) throw FormatError("pitch: man-marking ACK changed unrelated board fields"); } const auto opponent=std::find_if(e.opponent_players.begin(),e.opponent_players.end(),[&](const PitchOpponent& p){ return p.row==pending_->opponent_row&&p.player_id==pending_->opponent_player&&p.slot==pending_->opponent_slot;}); if(opponent==e.opponent_players.end())throw FormatError("pitch: opponent identity disappeared during marking"); } if(kind==PitchRequestKind::set_player_order){ if(pending_->row<0||pending_->row>=11||pending_->order_aspect<0||pending_->order_aspect>3|| pending_->expected_mode!=extras_.mode||pending_->expected_display_word!=extras_.native_display_word|| pending_->expected_set_piece_values!=extras_.set_piece_takers||pending_->expected_set_piece_signature!=extras_.set_piece_signature|| e.set_piece_takers!=extras_.set_piece_takers||e.set_piece_signature!=extras_.set_piece_signature|| e.native_display_word!=extras_.native_display_word) throw FormatError("pitch: Anweisungs-ACK changes unrelated owner fields"); for(size_t row=0;rowrow){ if(expected[size_t(2+pending_->order_aspect)]!=pending_->expected_order_value) throw FormatError("pitch: Anweisungsanfrage ist stale"); expected[size_t(2+pending_->order_aspect)]=uint8_t(pending_->new_order_value); } if(s.players[row].player_id!=state_.players[row].player_id||s.players[row].slot!=state_.players[row].slot|| s.players[row].board!=expected) throw FormatError("pitch: Anweisungs-ACK verändert zusätzliche Kaderdaten"); } } if(kind!=PitchRequestKind::select_pitch_page||pending_->page_control!=0)s.view=state_.view; else s.view=state_.view==LineupView::data_a?LineupView::data_b:LineupView::data_a; auto new_sheet=std::make_unique(data_,s); auto new_badge=load_vga(asset_path(data_/"W",std::to_string(e.badge>>3)+".VGA")); if(kind==PitchRequestKind::set_automatic_weight)weights_dirty_=true; else if(kind==PitchRequestKind::apply_formation||kind==PitchRequestKind::save_formation)weights_dirty_=false; if(kind==PitchRequestKind::open_set_piece_editor){shooter_editor_open_=true;shooter_selection_=1;order_panel_open_=false;} if(kind==PitchRequestKind::close_set_piece_editor){shooter_editor_open_=false;shooter_selection_=1;zone_cover_open_=false;} if(kind==PitchRequestKind::set_piece_taker||kind==PitchRequestKind::auto_set_piece_takers)shooter_selection_=1; if(kind==PitchRequestKind::select_pitch_page){ if(pending_->page_control==0){shooter_editor_open_=false;shooter_selection_=1;order_panel_open_=false;zone_cover_open_=false;} else if(pending_->page_control==1){ /* Source Team xor keeps the current editor/page. */ } else if(pending_->page_control==2){shooter_editor_open_=false;shooter_selection_=1;order_panel_open_=false;zone_cover_open_=false;} else if(pending_->page_control==3){shooter_editor_open_=false;shooter_selection_=1;order_panel_open_=true;zone_cover_open_=false;} else if(pending_->page_control==4){shooter_editor_open_=false;shooter_selection_=1;order_panel_open_=false;zone_cover_open_=false;marking_scroll_=0;marking_target_row_.reset();} } if(kind==PitchRequestKind::set_player_marking){marking_target_row_.reset();} state_=std::move(s);extras_=std::move(e);sheet_=std::move(new_sheet);badge_=std::move(new_badge); scroll_=0; if(kind!=PitchRequestKind::set_player_order){selected_.reset();hovered_.reset();ghost_.reset();order_hover_grid_.reset();} pending_.reset();rejection_.clear(); } void PitchScreen::reject_action(std::string reason){if(!pending_||reason.empty())throw FormatError("pitch: rejection requires pending action and reason"); if(sheet_->pending())sheet_=std::make_unique(data_,state_); pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();pointer_grid_.reset();order_hover_grid_.reset();marking_target_row_.reset();rejection_=std::move(reason); } void PitchScreen::resolve_local_navigation(){ if(!pending_||pending_->kind!=PitchRequestKind::open_player_info) throw FormatError("pitch: only player info can resolve locally"); if(sheet_->pending())sheet_->resolve_local_navigation(LineupRequestKind::open_player_info); pending_.reset();selected_.reset();hovered_.reset();ghost_.reset();pointer_grid_.reset();rejection_.clear(); } std::string PitchScreen::state_json()const{std::ostringstream out; out<<"{\"screen\":\"pitch\",\"manager_slot\":"<state_json() <<",\"close_requested\":"<<(close_?"true":"false")<<",\"return_team_requested\":"<<(return_team_?"true":"false") <<",\"shooter_editor_open\":"<<(shooter_editor_open_?"true":"false") <<",\"shooter_selection\":"<=0&&!extras_.indoor.value_or(false))?"true":"false") <<",\"opponent_team\":"<first<<",\"lane\":"<second<<"}";else out<<"null"; out<<",\"pending_action\":";if(pending_)out<