local UI = require("urhox-libs/UI") local W = require("Game/UI/Widgets") local Base = require("Game/UI/HomeSkin") local Escort = require("Game/UI/EscortSkin") local Skin = require("Game/UI/CitySkin") local Screen = {} ---@param a any function Screen.ChooseDestination(a) if #a.state.runs>0 then a:Toast("镖队归来后再安排商路开拓") return end a.cityPicker=true a:SetPage("dispatch") end ---@param a any ---@param w number ---@param availableHeight number ---@param k number ---@return Panel function Screen.Content(a,w,availableHeight,k) local E,s=a.engine,a.state ---@type table local visited={} for _,name in ipairs(s.codex.cities) do visited[name]=true end local header=UI.Panel {width=w,height=702*k,flexShrink=0,backgroundColor=false,children={ Escort.Plaque("天下城池",263.5,2,356,k), Skin.Metric("已到访 "..#s.codex.cities.." 座",141,266,k,"city-visited-count"), Skin.Metric("当前可达 "..#E.citiesOpen(s).." / "..#E.cityList().." 座",430,311,k,"city-open-count"), W.Row({Escort.Image("divider",0,0,74,8,k,{position="relative"}), Base.Label("押镖抵达并交割后记入见闻。",0,0,380,36,26,k,{position="relative"}), Escort.Image("divider",0,0,74,8,k,{position="relative"})}, Base.Box(161.5,128,560,36,k,{gap=16*k,alignItems="center",pointerEvents="none"})), Skin.Map(a,k),Skin.Destination(k,function() Screen.ChooseDestination(a) end), }} -- Preserve data order and all 48 cities. Only the Jiangnan map has dedicated illustrations. ---@type {name:string,cities:any[]}[] local regions={} ---@type table local byName={} for _,c in ipairs(E.cityList()) do local region=byName[c.region] if not region then region={name=c.region,cities={}} byName[c.region]=region regions[#regions+1]=region end region.cities[#region.cities+1]=c end ---@type Widget[] local groups={} for _,region in ipairs(regions) do ---@type Widget[] local entries={} ---@type Widget[] local pair={} ---@type {requirement:number,names:string[]}[] local locked={} ---@type table local thresholds={} for _,c in ipairs(region.cities) do if E.cityUnlocked(s,c) then pair[#pair+1]=Skin.CityCard(a,c,visited[c.name]==true,k) if #pair==2 then entries[#entries+1]=W.Row(pair,{width=852*k,gap=12*k,flexShrink=0}) pair={} end else local bucket=thresholds[c.unlock] if not bucket then bucket={requirement=c.unlock,names={}} thresholds[c.unlock]=bucket locked[#locked+1]=bucket end bucket.names[#bucket.names+1]=c.name end end if #pair>0 then entries[#entries+1]=W.Row(pair,{width=852*k,gap=12*k,flexShrink=0}) end for _,bucket in ipairs(locked) do entries[#entries+1]=Skin.LockedRow(region.name,bucket.names,bucket.requirement,k) end groups[#groups+1]=W.Column({Skin.Region(region.name,k), W.Column(entries,{width=852*k,gap=(#locked==#entries and 4 or 8)*k, alignItems="center",flexShrink=0})}, {width=852*k,gap=4*k,alignItems="center",flexShrink=0}) end return W.Column({header,W.Column(groups,{id="city-regions",width=w,gap=13*k, alignItems="center",flexShrink=0})},{id="city-body",width=w,minHeight=availableHeight, gap=0,paddingBottom=8*k,backgroundColor=false,flexShrink=0}) end return Screen