MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / applicationInit

Method applicationInit

source/client/StarClientApplication.cpp:181–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181void ClientApplication::applicationInit(ApplicationControllerPtr appController) {
182 Application::applicationInit(appController);
183
184 appController->setCursorVisible(true);
185
186 auto configuration = m_root->configuration();
187 bool vsync = configuration->get("vsync").toBool();
188 Vec2U windowedSize = jsonToVec2U(configuration->get("windowedResolution"));
189 Vec2U fullscreenSize = jsonToVec2U(configuration->get("fullscreenResolution"));
190 bool fullscreen = configuration->get("fullscreen").toBool();
191 bool borderless = configuration->get("borderless").toBool();
192 bool maximized = configuration->get("maximized").toBool();
193 m_controllerInput = configuration->get("controllerInput").optBool().value();
194
195 if (fullscreen)
196 appController->setFullscreenWindow(fullscreenSize);
197 else if (borderless)
198 appController->setBorderlessWindow();
199 else if (maximized)
200 appController->setMaximizedWindow();
201 else
202 appController->setNormalWindow(windowedSize);
203
204 float updateRate = 1.0f / GlobalTimestep;
205 if (auto jUpdateRate = configuration->get("updateRate")) {
206 updateRate = jUpdateRate.toFloat();
207 GlobalTimestep = 1.0f / updateRate;
208 }
209
210 if (auto jServerUpdateRate = configuration->get("serverUpdateRate"))
211 ServerGlobalTimestep = 1.0f / jServerUpdateRate.toFloat();
212
213 appController->setTargetUpdateRate(updateRate);
214 appController->setVSyncEnabled(vsync);
215 appController->setCursorHardware(configuration->get("hardwareCursor").optBool().value(true));
216
217 AudioFormat audioFormat = appController->enableAudio();
218 m_mainMixer = make_shared<MainMixer>(audioFormat.sampleRate, audioFormat.channels);
219 m_mainMixer->setVolume(0.5);
220
221 m_worldPainter = make_shared<WorldPainter>();
222 m_guiContext = make_shared<GuiContext>(m_mainMixer->mixer(), appController);
223 m_input = make_shared<Input>();
224 m_voice = make_shared<Voice>(appController);
225
226 auto assets = m_root->assets();
227
228 {
229 auto& io = ImGui::GetIO();
230 m_immediateFont = *assets->bytes("/hobo.ttf");
231 ImFontConfig config{};
232 config.FontDataOwnedByAtlas = false;
233 config.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_ForceAutoHint;
234 io.Fonts->AddFontFromMemoryTTF(m_immediateFont.ptr(), m_immediateFont.size(),
235 16, &config, io.Fonts->GetGlyphRangesDefault());
236 }
237
238 m_minInterfaceScale = assets->json("/interface.config:minInterfaceScale").toInt();

Callers

nothing calls this directly

Calls 15

jsonToVec2UFunction · 0.85
jsonToVec2FFunction · 0.85
setCursorVisibleMethod · 0.80
configurationMethod · 0.80
toBoolMethod · 0.80
optBoolMethod · 0.80
setFullscreenWindowMethod · 0.80
setBorderlessWindowMethod · 0.80
setMaximizedWindowMethod · 0.80
setNormalWindowMethod · 0.80
toFloatMethod · 0.80
setTargetUpdateRateMethod · 0.80

Tested by

no test coverage detected