| 179 | } |
| 180 | |
| 181 | void 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(); |
nothing calls this directly
no test coverage detected