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

Function open

src/OpenLoco/src/Ui/Windows/MapWindow.cpp:2408–2464  ·  view source on GitHub ↗

0x0046B490

Source from the content-addressed store, hash-verified

2406
2407 // 0x0046B490
2408 void open()
2409 {
2410 auto window = WindowManager::bringToFront(WindowType::map, 0);
2411 if (window != nullptr)
2412 {
2413 return;
2414 }
2415
2416 auto ptr = malloc(kRenderedMapSize * 2);
2417 if (ptr == nullptr)
2418 {
2419 return;
2420 }
2421
2422 _mapPixels = static_cast<PaletteIndex_t*>(ptr);
2423 _mapAltPixels = &_mapPixels[kRenderedMapSize];
2424
2425 Ui::Size size = { 350, 272 };
2426
2427 if (Ui::getLastMapWindowAttributes().flags != WindowFlags::none)
2428 {
2429 size = { Ui::getLastMapWindowAttributes().size.width, Ui::getLastMapWindowAttributes().size.height };
2430 size.width = std::clamp<uint16_t>(size.width, 350, Ui::width());
2431 size.height = std::clamp<uint16_t>(size.height, 272, Ui::height() - 56);
2432 }
2433
2434 window = WindowManager::createWindow(WindowType::map, size, WindowFlags::none, getEvents());
2435 window->setWidgets(kWidgets);
2436 window->initScrollWidgets();
2437 window->frameNo = 0;
2438
2439 if (Ui::getLastMapWindowAttributes().flags != WindowFlags::none)
2440 {
2441 window->var_88A = Ui::getLastMapWindowAttributes().var88A;
2442 window->var_88C = Ui::getLastMapWindowAttributes().var88C;
2443 window->flags |= (Ui::getLastMapWindowAttributes().flags & WindowFlags::maximised);
2444 }
2445
2446 auto skin = ObjectManager::get<InterfaceSkinObject>();
2447 window->setColour(WindowColour::primary, skin->windowTitlebarColour);
2448 window->setColour(WindowColour::secondary, skin->windowMapColour);
2449
2450 window->var_846 = getCurrentRotation();
2451
2452 clearMap();
2453
2454 centerOnViewPoint();
2455
2456 window->currentTab = 0;
2457 window->showTownNames = true;
2458 window->var_854 = 0;
2459
2460 assignIndustryColours();
2461 assignRouteColours();
2462
2463 mapFrameNumber = 0;
2464 }
2465

Callers

nothing calls this directly

Calls 12

bringToFrontFunction · 0.85
widthFunction · 0.85
heightFunction · 0.85
getCurrentRotationFunction · 0.85
clearMapFunction · 0.85
centerOnViewPointFunction · 0.85
assignIndustryColoursFunction · 0.85
assignRouteColoursFunction · 0.85
setWidgetsMethod · 0.80
initScrollWidgetsMethod · 0.80
createWindowFunction · 0.50
setColourMethod · 0.45

Tested by

no test coverage detected