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

Function open

src/OpenLoco/src/Ui/Windows/TownWindow.cpp:344–391  ·  view source on GitHub ↗

0x00499B7E

Source from the content-addressed store, hash-verified

342
343 // 0x00499B7E
344 Window* open(uint16_t townId)
345 {
346 auto window = WindowManager::bringToFront(WindowType::town, townId);
347 if (window != nullptr)
348 {
349 if (ToolManager::isToolActive(window->type, window->number))
350 {
351 ToolManager::toolCancel();
352 }
353
354 window = WindowManager::bringToFront(WindowType::town, townId);
355 }
356
357 if (window == nullptr)
358 {
359 // 0x00499C0D start
360 const WindowFlags newFlags = WindowFlags::viewportNoShiftPixels | WindowFlags::resizable;
361 window = WindowManager::createWindow(WindowType::town, kWindowSize, newFlags, Town::getEvents());
362 window->number = townId;
363 window->minWidth = 192;
364 window->minHeight = 161;
365 window->maxWidth = 600;
366 window->maxHeight = 440;
367
368 auto skin = ObjectManager::get<InterfaceSkinObject>();
369 if (skin != nullptr)
370 {
371 window->setColour(WindowColour::primary, skin->windowTitlebarColour);
372 window->setColour(WindowColour::secondary, skin->windowColour);
373 }
374 // 0x00499C0D end
375
376 window->savedView.clear();
377 }
378
379 window->currentTab = 0;
380 window->invalidate();
381
382 window->setWidgets(Town::widgets);
383 window->holdableWidgets = 0;
384 window->eventHandlers = &Town::getEvents();
385 window->activatedWidgets = 0;
386 window->disabledWidgets = 0;
387 window->initScrollWidgets();
388 Town::initViewport(*window);
389
390 return window;
391 }
392
393 namespace Population
394 {

Callers

nothing calls this directly

Calls 10

bringToFrontFunction · 0.85
isToolActiveFunction · 0.85
setWidgetsMethod · 0.80
initScrollWidgetsMethod · 0.80
toolCancelFunction · 0.70
initViewportFunction · 0.70
createWindowFunction · 0.50
setColourMethod · 0.45
clearMethod · 0.45
invalidateMethod · 0.45

Tested by

no test coverage detected