40 lines
2.7 KiB
Python
40 lines
2.7 KiB
Python
"""Execute the actual atlas page preparation; widget operations are doubled."""
|
|
from policy_harness import ROOT, body, run
|
|
p=ROOT/'addons/core/Scripts/Game/ERR/30_Map/ERRM_AtlasPresentation.c'
|
|
prepare=body(p,'void Prepare(').replace('Vector(', 'vector(').replace('Widget mapWidget','Widget* mapWidget').replace('Widget objectives','Widget* objectives')
|
|
for name in ['ERRM_PaperPages','Math','FrameSlot']:prepare=prepare.replace(name+'.',name+'::')
|
|
for name in ['m_Root','objectives']:prepare=prepare.replace(name+'.',name+'->')
|
|
run(r'''
|
|
#include <cassert>
|
|
#include <algorithm>
|
|
#include <string>
|
|
struct vector{float v[3]={0,0,0};vector(){}vector(float x,float y,float z):v{x,y,z}{}float&operator[](int i){return v[i];}};
|
|
struct Widget{float x=0,y=0,w=744,h=1024;int z=0;bool visible=true;Widget*map=nullptr,*overlay=nullptr;Widget*FindAnyWidget(std::string n){return n=="MapWidget"?map:overlay;}void SetVisible(bool b){visible=b;}void SetZOrder(int n){z=n;}};
|
|
struct FrameSlot{static void SetPos(Widget*w,float x,float y){w->x=x;w->y=y;}static void SetSize(Widget*w,float x,float y){w->w=x;w->h=y;}};
|
|
struct Math{static float Min(float a,float b){return std::min(a,b);}static float Max(float a,float b){return std::max(a,b);}};
|
|
struct ERRM_PaperPages{static constexpr int COVER=16777215,OVERVIEW=16777214,REGION=16777216;static bool IsRegion(int page){return page>=REGION;}
|
|
// Page geometry is independently implemented by PaperPages; this test targets
|
|
// marker visibility and alignment, including non-square regional bounds.
|
|
static void RegionBounds(int,int,int,vector,float,vector&lo,vector&hi){lo=vector(.2,0,.3);hi=vector(.7,0,.9);}
|
|
};
|
|
struct Atlas{Widget*m_Root;float m_X=0,m_Y=0,m_Width=0,m_Height=0;
|
|
'''+prepare+r'''
|
|
};
|
|
int main(){
|
|
Widget root,map,overlay;root.map=↦root.overlay=&overlay;Atlas a{&root};
|
|
for(int page:{ERRM_PaperPages::COVER,ERRM_PaperPages::OVERVIEW,ERRM_PaperPages::REGION,ERRM_PaperPages::REGION+4,0,4097}){
|
|
for(vector size:{vector(12800,0,12800),vector(24000,0,12000),vector(8000,0,16000)}){
|
|
a.Prepare(page,size,.5,8,6);
|
|
assert(overlay.visible==(page!=ERRM_PaperPages::COVER));assert(overlay.z>10);
|
|
assert(overlay.x==map.x&&overlay.y==map.y&&overlay.w==map.w&&overlay.h==map.h);
|
|
assert(overlay.x>=0&&overlay.y>=0&&overlay.x+overlay.w<=744&&overlay.y+overlay.h<=1024);
|
|
}
|
|
}
|
|
root.overlay=nullptr;a.Prepare(0,vector(12800,0,12800),.5,8,6);
|
|
}
|
|
''')
|
|
layout=ROOT/'addons/core/UI/layouts/ERRMap/SharedMapRenderTarget.layout'
|
|
assert 'Anchor 0 0 0 0' in body(layout,'Name "ERR_ObjectiveOverlay"')
|
|
assert 'Clipping True' in layout.read_text()
|
|
print('PASS: actual atlas preparation shows disclosed markers on overview, regional and detail sheets; cover hidden; overlay matches map rectangle above print for square/wide/tall terrains')
|