local UI = require("urhox-libs/UI") local Base = require("Game/UI/HomeSkin") local Shared = require("Game/UI/EscortSkin") local Skin = require("Game/UI/FacilitySkin") local Model = require("Game/UI/Management") local W = require("Game/UI/Widgets") local Screen = {} local function label(text,w,h,size,k,props) local widget=text:find("\n",1,true) and Skin.Lines(text,0,0,w,h,size,h/2,k,props) or Skin.Label(text,0,0,w,h,size,k,props) widget:SetStyle({position="relative"}) return widget end local function divider(w,k) return UI.Panel {width=w*k,height=3*k,backgroundColor=false,pointerEvents="none", overflow="visible",children={Shared.Image("divider",0,-2,w,8,k)}} end local function wuguan(a,k) local m=Model.Facility(a,"wuguan") local badge=UI.Panel {width=120*k,height=42*k,backgroundColor=false,pointerEvents="none",children={ Shared.Image("status",0,0,120,42,k,{opacity=m.disabled and 0.65 or 1}), Skin.Label(m.status,5,0,110,42,32,k,{fontColor="#fff0c9",textAlign="center",id="facility-wuguan-status"}), }} local prefix="训练上限 "..a.engine.trainCap(a.state).." " local suffix="→ "..(a.engine.trainCap(a.state)+10) local size=math.min(28,28*286*k/UI.MeasureTextWidth(prefix..suffix,28*k,"home-ink")) local pw=UI.MeasureTextWidth(prefix,size*k,"home-ink")/k local effect=UI.Panel {width=286*k,height=40*k,backgroundColor=false,pointerEvents="none",children={ Skin.Label(prefix,0,0,pw,40,size,k),Skin.Label(suffix,pw,0,286-pw,40,size,k,{fontColor=Skin.Red}), }} local action=Skin.Action(m.actionLabel,0,0,286,56,34,k,function() a:Do("upgradeFacility","wuguan") end, {id="facility-wuguan",disabled=m.disabled}) action:SetStyle({position="relative"}) return UI.Panel(Base.Box(20,97,843,339,k,{id="facility-card-wuguan",backgroundColor=false, flexDirection="row",paddingLeft=45*k,paddingRight=42*k,paddingTop=42*k,paddingBottom=19*k,gap=20*k, children={Skin.Image("scroll",0,0,843,339,k),Skin.Art("wuguan",450,278,k), UI.Panel {width=286*k,height=251*k,gap=14*k,backgroundColor=false,children={ UI.Panel {width=286*k,height=60*k,flexDirection="row",alignItems="center",gap=16*k, children={label(m.title,130,60,48,k),badge}}, label("等级 "..m.level,286,36,29,k,{id="facility-level-wuguan"}),divider(286,k),effect,action, }}}})) end local function facility(a,key,x,y,h,k) local m=Model.Facility(a,key) local card=Shared.Surface(414,h,k,Base.Box(x,y,414,h,k,{id="facility-card-"..key, flexDirection="row",alignItems="center",paddingHorizontal=12*k,paddingVertical=16*k,gap=12*k})) card:AddChild(Skin.Art(key,198,200,k)) local action=Skin.Action(m.actionLabel,0,0,180,56,25,k,function() a:Do("upgradeFacility",key) end, {id="facility-"..key,disabled=m.disabled}) action:SetStyle({position="relative"}) card:AddChild(UI.Panel {width=180*k,height=197*k,gap=6*k,backgroundColor=false,children={ label(m.title,180,34,32,k),label("等级 "..m.level,180,28,24,k,{id="facility-level-"..key}), divider(180,k),label(m.effect,180,52,22,k,{id="facility-effect-"..key}),action, }}) return card end local function business(a,promotion,y,h,k) local m=promotion and Model.Promotion(a) or Model.Chain(a) local card=Shared.Surface(843,h,k,Base.Box(20,y,843,h,k,{id=promotion and "facility-promotion" or "facility-chain", flexDirection="row",alignItems="center",paddingHorizontal=16*k,gap=16*k})) card:AddChild(Skin.Art(m.art,211,115,k)) local title=UI.Panel {width=368*k,height=38*k,flexDirection="row",gap=10*k,backgroundColor=false, children={label(m.title,160,38,32,k)}} local summary=label(m.summary,368,31,24,k,{id=promotion and "facility-bounty-summary" or "facility-chain-summary"}) local content=UI.Panel {width=368*k,height=108*k,gap=6*k,backgroundColor=false,children={title,summary}} if promotion then local status=label(m.status,88,28,21,k,{textAlign="center",fontColor="#fff0c9",id="facility-bounty-status"}) local tag=UI.Panel {width=88*k,height=28*k,borderRadius=0,borderWidth=0,backgroundColor=m.active and "#7b8f58" or "#a9a397", pointerEvents="none",children={status}} title:AddChild(tag) local last=-1 a.facilityStatusUpdate=function() local minutes=math.ceil(a.engine.bountyLeft(a.state)/60000) if minutes==last then return end last=minutes local active=minutes>0 status:SetText(active and "生效中" or "未生效") summary:SetText(active and "剩余 "..minutes.." 分钟 · 新镖单镖银 +15%" or "1小时内新接镖单,镖银 +15%") tag:SetStyle({backgroundColor=active and "#7b8f58" or "#a9a397"}) end a.facilityStatusUpdate() else content:AddChild(label(m.requirement,368,27,20,k,{id="facility-chain-requirement"})) end card:AddChild(content) local button=Skin.Action(m.actionLabel,0,0,200,64,24,k,function() a:Do(promotion and "buyBounty" or "openBranch") end, {id=promotion and "buy-bounty" or "open-branch",disabled=m.disabled}) button:SetStyle({position="relative"}) card:AddChild(button) return card end local function tradeCard(a,row,y,k) local card=Shared.Surface(843,160,k,Base.Box(20,y,843,160,k,{id="facility-trade-"..row.id})) card:AddChild(Skin.Label(row.name,24,12,560,40,32,k)) card:AddChild(Skin.Label("商路控制 "..row.degree.."%",24,58,540,34,26,k)) card:AddChild(Skin.Label("每小时收入 "..W.Number(row.hourly).." 两",24,100,540,34,24,k)) local text=row.max and "已完全掌握" or not row.open and "累计声望 "..W.Number(row.gate).."\n开放" or "投资 · "..W.Number(row.cost).." 两" card:AddChild(Skin.Action(text,607,52,212,64,24,k,function() a:Do("investMonopoly",row.id) end, {id="invest-"..row.id,disabled=not row.open or row.max or a.state.silver