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

Function open

src/OpenLoco/src/Ui/Windows/IndustryWindow.cpp:311–360  ·  view source on GitHub ↗

0x00456D2D

Source from the content-addressed store, hash-verified

309
310 // 0x00456D2D
311 Window* open(IndustryId industryId)
312 {
313 auto window = WindowManager::bringToFront(WindowType::industry, enumValue(industryId));
314 if (window != nullptr)
315 {
316 if (ToolManager::isToolActive(window->type, window->number))
317 {
318 ToolManager::toolCancel();
319 }
320
321 window = WindowManager::bringToFront(WindowType::industry, enumValue(industryId));
322 }
323
324 if (window == nullptr)
325 {
326 // 0x00456DBC start
327 const WindowFlags newFlags = WindowFlags::viewportNoShiftPixels | WindowFlags::resizable;
328 window = WindowManager::createWindow(WindowType::industry, Industry::kWindowSize, newFlags, Industry::getEvents());
329 window->number = enumValue(industryId);
330 window->minWidth = 192;
331 window->minHeight = 137;
332 window->maxWidth = 600;
333 window->maxHeight = 440;
334
335 auto skin = ObjectManager::get<InterfaceSkinObject>();
336 if (skin != nullptr)
337 {
338 window->setColour(WindowColour::primary, skin->windowTitlebarColour);
339 window->setColour(WindowColour::secondary, skin->windowColour);
340 }
341 // 0x00456DBC end
342
343 window->savedView.clear();
344 }
345
346 window->currentTab = Common::widx::tab_industry - Common::widx::tab_industry;
347 window->invalidate();
348
349 window->setWidgets(Industry::widgets);
350 window->holdableWidgets = 0;
351 window->eventHandlers = &Industry::getEvents();
352 window->activatedWidgets = 0;
353
354 Common::setDisabledWidgets(*window);
355
356 window->initScrollWidgets();
357 Industry::initViewport(*window);
358
359 return window;
360 }
361
362 namespace Production
363 {

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected