local UI = require("urhox-libs/UI") local W = require("Game/UI/Widgets") local FacilityScreen = require("Game/UI/FacilityScreen") local Dialogs = require("Game/UI/Dialogs") local Home = require("Game/UI/Home") local Skin = require("Game/UI/HomeSkin") local HomeScreen = require("Game/UI/HomeScreen") local EscortScreen = require("Game/UI/EscortScreen") local EscortSkin = require("Game/UI/EscortSkin") local CodexScreen = require("Game/UI/CodexScreen") local CityScreen = require("Game/UI/CityScreen") local RankScreen = require("Game/UI/RankScreen") local View = {} local pages={{"dispatch","接镖"},{"escort","镖师"},{"facility","设施"},{"codex","图鉴"},{"city","城池"},{"rank","排行"}} ---@param a any function View.Render(a) local scrollX,scrollY=0,0 if a.content then scrollX,scrollY=a.content:GetScroll() end local modalX,modalY=0,0 if a.dialogContent then modalX,modalY=a.dialogContent:GetScroll() end a.progressWidgets={} a.facilityStatusUpdate=nil local s=a.state local w,h,k=Skin.Metrics() local home=a.page=="dispatch" local escort=a.page=="escort" local facility=a.page=="facility" local codex=a.page=="codex" local city=a.page=="city" local rank=a.page=="rank" local availableHeight=math.max(0,h-292*k) local gameBody if not s then gameBody=W.Card({W.Title("长风镖局"),W.Label("已有进度暂未读取,请先恢复存档。")}) elseif home then gameBody=HomeScreen.Content(a,w,availableHeight,k) elseif escort then gameBody=EscortScreen.Content(a,w,availableHeight,k) elseif facility then gameBody=FacilityScreen.Content(a,w,availableHeight,k) elseif codex then gameBody=CodexScreen.Content(a,w,availableHeight,k) elseif city then gameBody=CityScreen.Content(a,w,availableHeight,k) else gameBody=RankScreen.Content(a,w,availableHeight,k) end local body=(home or escort or facility or codex or city or rank) and s and gameBody or W.Column({gameBody},{padding=14}) a.content=UI.ScrollView {id="page-scroll",width="100%",flexGrow=1,flexShrink=1,flexBasis=0, showScrollbar=false,children={body}} ---@type Widget[] local contents={} if home then contents[#contents+1]=Skin.Courtyard(w,h,k) end if escort or codex or city or rank then contents[#contents+1]=EscortSkin.Background(w,h,k) end if facility then contents[#contents+1]=EscortSkin.Background(w,h,k,{id="facility-background"}) end contents[#contents+1]=Home.Header(a) contents[#contents+1]=a.content contents[#contents+1]=Home.Navigation(a,pages) local shell=W.Column(contents,{id="home-shell",width=w,height="100%",gap=0, overflow="hidden",backgroundColor="#debf8e"}) local safe=UI.SafeAreaView {id="safe-area",width="100%",height="100%",alignItems="center",children={shell}} local root=UI.Panel {id="game-root",width="100%",height="100%",backgroundColor="#382c22", backgroundImage=Skin.Root.."images/courtyard.jpg",backgroundFit="cover",backgroundImageOpacity=0.4, pointerEvents="box-none",children={safe}} a.toastLabel=W.Label(a.message or "",{fontSize=13,fontColor="#fff8e7",textAlign="center"}) a.toastPanel=W.Card({a.toastLabel},{id="toast",position="absolute",bottom=184*k,left="5%",width="90%",maxWidth=w, backgroundColor="#263f3df2",borderWidth=0,padding=10,visible=a.message~=nil and a.message~="",pointerEvents="none"}) root:AddChild(a.toastPanel) local dialog=a:CurrentDialog() a.dialogContent=nil if dialog then local title,children=Dialogs.Content(a,dialog) if not dialog.blocking and dialog.kind~="receipt" then children[#children+1]=W.Secondary("返回",function() a:CloseDialog() end,{id="dialog-close"}) end a.dialogContent=UI.ScrollView {id="dialog-scroll",width="100%",flexGrow=1,flexBasis=0,flexShrink=1, padding=14,children={W.Column(children,{gap=12})}} root:AddChild(UI.Panel {id="dialog-overlay",position="absolute",left=0,top=0,width="100%",height="100%", backgroundColor="#182823b8",alignItems="center",justifyContent="center",children={ W.Column({W.Label(title,{fontSize=13,fontWeight="bold",fontColor=W.colors.pine,margin=14}),a.dialogContent}, {width="92%",height="88%",maxWidth=540,backgroundColor=W.colors.sheet,borderRadius=8, borderWidth=1,borderColor=W.colors.line,overflow="hidden"})}}) end UI.SetRoot(root,true) a.root=root a.pendingScroll={x=scrollX or 0,y=scrollY or 0,modalX=modalX or 0,modalY=modalY or 0} end return View