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

Function createWindow

src/OpenLoco/src/Ui/WindowManager.cpp:563–713  ·  view source on GitHub ↗

* 0x004C9C68 * * @param type @ * @param size.width @ * @param size.height @ * @param flags @ * @param events @ * @return */

Source from the content-addressed store, hash-verified

561 * @return
562 */
563 Window* createWindow(
564 WindowType type,
565 Ui::Size size,
566 Ui::WindowFlags flags,
567 const WindowEventList& events)
568 {
569 Ui::Point position{};
570
571 position.x = 0; // dx
572 position.y = 30; // ax
573 if (windowFitsWithinSpace(position, size))
574 {
575 return createWindowOnScreen(type, position, size, flags, events);
576 }
577
578 position.x = Ui::width() - size.width;
579 position.y = 30;
580 if (windowFitsWithinSpace(position, size))
581 {
582 return createWindowOnScreen(type, position, size, flags, events);
583 }
584
585 position.x = 0;
586 position.y = Ui::height() - size.height - 29;
587 if (windowFitsWithinSpace(position, size))
588 {
589 return createWindowOnScreen(type, position, size, flags, events);
590 }
591
592 position.x = Ui::width() - size.width;
593 position.y = Ui::height() - size.height - 29;
594 if (windowFitsWithinSpace(position, size))
595 {
596 return createWindowOnScreen(type, position, size, flags, events);
597 }
598
599 for (const auto& w : _windows)
600 {
601 if (w.hasFlags(WindowFlags::stickToBack))
602 {
603 continue;
604 }
605
606 position.x = w.x + w.width + 2;
607 position.y = w.y;
608 if (windowFitsWithinSpace(position, size))
609 {
610 return createWindowOnScreen(type, position, size, flags, events);
611 }
612
613 position.x = w.x - size.width - 2;
614 position.y = w.y;
615 if (windowFitsWithinSpace(position, size))
616 {
617 return createWindowOnScreen(type, position, size, flags, events);
618 }
619
620 position.x = w.x;

Callers 15

createWindowOnScreenFunction · 0.70
createWindowCentredFunction · 0.70
openFunction · 0.70
openFunction · 0.50
openFunction · 0.50
openFunction · 0.50
openFunction · 0.50
createErrorWindowFunction · 0.50
openFunction · 0.50
openFunction · 0.50
openFunction · 0.50
openFunction · 0.50

Calls 12

windowFitsWithinSpaceFunction · 0.85
createWindowOnScreenFunction · 0.85
widthFunction · 0.85
heightFunction · 0.85
windowFitsOnScreenFunction · 0.85
countFunction · 0.85
playSoundFunction · 0.85
closeFunction · 0.70
WindowClass · 0.50
hasFlagsMethod · 0.45
beginMethod · 0.45
invalidateMethod · 0.45

Tested by 1

openFunction · 0.40