MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / initViewport

Function initViewport

src/OpenLoco/src/ViewportManager.cpp:63–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62
63 static Viewport* initViewport(Ui::Point origin, Ui::Size size, ZoomLevel zoom)
64 {
65 // Viewports with 0 width are invalid.
66 if (size.width == 0)
67 {
68 assert(size.width != 0);
69 return nullptr;
70 }
71
72 auto* vp = allocate();
73 if (vp == nullptr)
74 {
75 return nullptr;
76 }
77
78 vp->x = origin.x;
79 vp->y = origin.y;
80 vp->width = size.width;
81 vp->height = size.height;
82
83 vp->viewWidth = size.width << static_cast<uint8_t>(zoom);
84 vp->viewHeight = size.height << static_cast<uint8_t>(zoom);
85 vp->zoom = static_cast<uint8_t>(zoom);
86 vp->flags = ViewportFlags::none;
87
88 if (Config::get().gridlinesOnLandscape)
89 {
90 vp->flags |= ViewportFlags::gridlines_on_landscape;
91 }
92
93 return vp;
94 }
95
96 static void focusViewportOn(Window* w, int index, EntityId dx)
97 {

Callers 1

createFunction · 0.70

Calls 2

allocateFunction · 0.85
getFunction · 0.70

Tested by

no test coverage detected