-- The in-game photography panel uses the camera input layer and owns its visual resources. local U=require('ue_observe') local N=require('photo_native') local Face=require('photo_face') local Visuals=require('photo_visuals') local Overlay=require('photo_overlay') local Settings=require('photo_settings') local Studio={} local TABS={'镜头','对焦','灯位','灯色','调色','质感','构图','预设','演员','人物'} local BORDERS={'无','宽银幕','白边','黑边'} local MARKS={'无','斗蛐蛐摄影','留影','影之刃零'} local EYES={'随镜头','正前','左','右','上','下'} local APERTURES={0,1.4,2,2.8,4,5.6,8,11,16} local function lvalue(n)return n<0 and '原画面' or string.format('%.2f',n)end local function channel(mask) local active={} for i=0,2 do if (mask&(1<1 and not fx:expression(role,spec.mesh,chosen.weights) then r.expressions[role]=1 notice(r,'表情未读回',now) end end else r.faces=nil end if not self:subjects(r) then notice(r,'人物显隐未读回',now) end if not r.opticsApplied then r.opticsApplied=true local ok=fx:optics(r.camera,r.settings) log('[Photo] 独立相机参数读回='..tostring(ok)) if not ok then notice(r,'部分镜头参数未读回',now) end if not fx:bars(r.settings.bars,now) then notice(r,'血条隐藏未确认',now) end end end function self:subjects(r) local s=r.settings r.hidden=r.hidden or {} local ok=fx:subject(1,r.player,s.show1) if ok then r.hidden[1]=not s.show1 end local show=r.mode~='duo' or s.show2 local other=fx:subject(2,r.other and r.other.actor,show) if other then r.hidden[2]=not show end return ok and other end function self:releaseSubjects(r) local first=fx:release('actor1') local second=fx:release('actor2') if first and second then r.hidden={} end return first and second end function self:releaseFaces() local player=fx:release('face1') return fx:release('face2') and player end function self:face(r,role,step) local f=r.faces and r.faces[role] if not f or #f.options<=1 or not U.valid(f.mesh) then return false,'该模型没有已适配的表情' end if U.key(N.call(f.mesh,'GetSkeletalMeshAsset'))~=f.asset then return false,'角色外观已变化,请重新打开摄影' end local index=wrap(r.expressions[role]+step,#f.options) local choice=f.options[index] if not fx:expression(role,f.mesh,choice.weights) then r.expressions[role]=1 return false,'表情未读回' end r.expressions[role]=index return true end local function apply(r,id,now,roll) local s=r.settings if id=='bars' then return fx:bars(s.bars,now,true) end if id=='roll' then return roll(s.roll) end if id=='show1' or id=='show2' then return self:subjects(r) end if id:sub(1,2)=='l_' then return fx:light(r) end if id=='grid' or id=='border' or id=='mark' or id=='captureHDR' or id=='lightSlot' or id=='focusMark' or id=='eyes1' or id=='eyes2' or id=='autofocus' then return true end return fx:optics(r.camera,s) end local function applyAll(r,now,roll) local s=r.settings local a=fx:optics(r.camera,s) local b=fx:light(r) local c=fx:bars(s.bars,now,true) local d=self:subjects(r) return roll(s.roll) and a and b and c and d end function self:adjust(r,id,step,now,roll) local s=r.settings if id=='presetSlot' then r.menu.preset=wrap(r.menu.preset+step,5);return true end if id=='save' then local ok=presets.save(r.menu.preset,s) if ok then notice(r,'已保存摄影预设 '..r.menu.preset,now) end return ok,'预设写入未读回' end if id=='load' or id=='reset' then local loaded=id=='reset' and Settings.defaults(60) or presets.load(r.menu.preset) if not loaded then return false,'该槽没有摄影预设' end r.settings=loaded if applyAll(r,now,roll) then notice(r,id=='reset' and '已恢复默认参数' or '已读取摄影预设 '..r.menu.preset,now) return true end r.settings=s applyAll(r,now,roll) return false,'部分参数未读回,已尝试恢复' end local owner,key,old if id=='aperture' then local n=1 for i,v in ipairs(APERTURES)do if v==s.aperture then n=i;break end end owner,key,old=s,id,s.aperture s.aperture=APERTURES[wrap(n+step,#APERTURES)] else owner,key,old=Settings.step(s,id,step) end if not owner then return false,'未知摄影设置' end if owner[key]==old then return true end if apply(r,id,now,roll) then log('[Photo] '..id..'='..tostring(owner[key])..' 读回=true') return true end owner[key]=old apply(r,id,now,roll) return false,'设置未读回,已尝试恢复' end function self:moved(r,now) local s=r.settings if s.autofocus and s.aperture>0 and o.focusFromCamera and now>=(r.focusAt or 0) then r.focusAt=now+.15 local d=o.focusFromCamera(r.position,r.rotation,r.camera) if N.number(d) then d=N.limit(d,50,15000) if math.abs(d-s.focus)>1 and fx:focus(r.camera,s.aperture,d) then s.focus=d end end end if now>=(r.lightAt or 0) then r.lightAt=now+1/30 for _,l in ipairs(s.lights)do if l.power>0 then return fx:light(r) end end end return true end function self:capture(r,now) if not overlay:hide(true) then return false end if overlay.composition and not overlay:composition(r.settings,true,now) then return false end if r.settings.bars and not fx:bars(true,now,true) then return false end return true end local KEYS={'menu','exit','capture','prevTab','nextTab','up','down','less','more','confirm'} local REPEAT={up=true,down=true,less=true,more=true} function self:input(r,input,now) local nav=input and input.nav if not nav then return end local m=r.menu local hit={} for _,k in ipairs(KEYS)do local before=m.keys[k] if nav[k] then if not before or REPEAT[k] and now>=before then hit[k]=true m.keys[k]=now+(before and .12 or .34) end else m.keys[k]=nil end end if not m.armed then -- Keys held while entering photography must be released before a new command. m.armed=true return end if hit.menu then m.visible=not m.visible end if hit.exit then return 'leave',1 end if hit.capture then return 'shot',1 end if not m.visible then return end local tabs=#TABS if hit.prevTab or hit.nextTab then m.tab=wrap(m.tab+(hit.nextTab and 1 or -1),tabs) m.selected=1 return end if not (hit.up or hit.down or hit.less or hit.more or hit.confirm) then return end m.tab=math.min(m.tab,tabs) local rows=rowsFor(r) if not rows[1] then return end if hit.up or hit.down then m.selected=wrap(m.selected+(hit.down and 1 or -1),#rows) end local row=rows[math.min(m.selected,#rows)] if hit.less or hit.more or hit.confirm then return row.id,hit.less and -1 or 1 end end function self:render(r,now) local m=r.menu if overlay.composition and not overlay:composition(r.settings,r.shotQueued~=nil,now) and not m.composeFailed then m.composeFailed=true;notice(r,'构图层未读回',now) end local shown=m.visible and not r.shotQueued if not shown then m.drawAt=nil;return overlay:hide() end if now<(m.drawAt or 0) then return true end m.drawAt=now+1/30 local rows=rowsFor(r) local t=TABS[wrap(m.tab-1,#TABS)]..' ‹ 〔'..TABS[m.tab]..'〕 › '..TABS[wrap(m.tab+1,#TABS)] local hint='鼠标、WASD / Q E 或摇杆移动镜头\n方向键选择和调整 PgUp/PgDn 或 LB/RB 换页\nTab / 菜单键显隐 空格 / X 拍照 Esc / B 退出' if m.noticeUntil>now then hint=m.notice..'\n'..hint end local selected=math.min(m.selected,#rows) local title=m.titleOverride or (r.mode=='duo' and '双人自拍' or '普通拍照') local signature={title,t,hint,selected} for _,row in ipairs(rows)do signature[#signature+1]=row.value;signature[#signature+1]=row.id end return overlay:render({visible=true,title=title,tabs=t,rows=rows, selected=selected,hint=hint,signature=table.concat(signature,'|')},now) end return self end return Studio