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

Function start

src/OpenLoco/src/Tutorial.cpp:64–133  ·  view source on GitHub ↗

0x0043C590

Source from the content-addressed store, hash-verified

62
63 // 0x0043C590
64 void start(int16_t tutorialNumber)
65 {
66 if (tutorialNumber < 0 || tutorialNumber > 3)
67 {
68 return;
69 }
70
71 // NB: only used by tutorial widget drawing after.
72 _tutorialNumber = tutorialNumber;
73
74 // Figure out what dimensions to use for the tutorial, and whether we can continue using scaling.
75 const auto& config = Config::get();
76 Config::Resolution newResolution = tutorialResolution;
77 if (config.scaleFactor > 1.0)
78 {
79 newResolution *= config.scaleFactor;
80 Config::Resolution desktopResolution = Ui::getDesktopResolution();
81
82 // Don't scale if it means the new window won't fit the desktop.
83 if (newResolution > desktopResolution)
84 {
85 Ui::setWindowScaling(1.0);
86 newResolution = tutorialResolution;
87 }
88 }
89
90 // Ensure that we're in windowed mode, using dimensions 1024x768.
91 auto currentResolution = Ui::getResolution();
92 if (config.display.mode != Config::ScreenMode::window || currentResolution != newResolution)
93 {
94 if (!Ui::setDisplayMode(Config::ScreenMode::window, newResolution))
95 {
96 return;
97 }
98 }
99
100 // Get the environment file for this tutorial.
101 static constexpr Environment::PathId tutorialFileIds[] = {
102 Environment::PathId::tut1024_1,
103 Environment::PathId::tut1024_2,
104 Environment::PathId::tut1024_3,
105 };
106
107 auto fileId = tutorialFileIds[tutorialNumber];
108
109 auto tutPath = Environment::getPath(fileId);
110 _tutorialData = readTutorialFile(tutPath);
111 _tutorialIt = _tutorialData.cbegin();
112
113 // Set the first string to show.
114 static constexpr StringId openingStringIds[] = {
115 StringIds::tutorial_1_string_1,
116 StringIds::tutorial_2_string_1,
117 StringIds::tutorial_3_string_1,
118 };
119
120 _state = State::playing;
121 _tutorialString = openingStringIds[_tutorialNumber];

Callers

nothing calls this directly

Calls 9

getDesktopResolutionFunction · 0.85
setWindowScalingFunction · 0.85
getResolutionFunction · 0.85
setDisplayModeFunction · 0.85
getPathFunction · 0.85
readTutorialFileFunction · 0.85
PrngClass · 0.85
getFunction · 0.70
loadFunction · 0.50

Tested by

no test coverage detected