-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Reorder the renderer setup code so that WebAudio works
Since BJS provides the facilities for both WebGL and WebAudio, the C_WebAudio API relies on it being available when it is loaded. This wasn't the case with the original design, since the UI is loaded asynchronously and only then was the render loop started. Since there's no reason or even benefit to doing so, this should change the render loop to start immediately and allow the WebAudio initialization to create its SoundTracks via BJS' API.
- Loading branch information
1 parent
c2096b7
commit aaabb4a
Showing
4 changed files
with
169 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,45 @@ | ||
var format = require("util").format; | ||
|
||
// Shorthand because I'm lazy (must be set after the localization tables have been read) | ||
let L = {}; | ||
function StartWebClient() { | ||
C_Profiling.startTimer("StartWebClient"); | ||
|
||
C_Settings.loadSettingsCache(); | ||
|
||
// WebAudio Setup: Requires settings to be loaded | ||
// We can do this here as long as the C_Decoding API was loaded first | ||
C_Decoding.addDecoder(new BuiltinAudioDecoder()); | ||
// Ensure stored settings are applied to any new audio source right away | ||
C_WebAudio.setMusicVolume(C_Settings.getValue("musicVolume")); | ||
C_WebAudio.setEffectsVolume(C_Settings.getValue("sfxVolume")); | ||
C_WebAudio.setAmbienceVolume(C_Settings.getValue("ambienceVolume")); | ||
C_WebAudio.setGlobalVolume(C_Settings.getValue("globalVolume")); | ||
|
||
WebClient.initializeLocalizationTables(); | ||
L = C_Locales.getLocalizationTable(C_Settings.getValue("activeLocale")); | ||
WebClient.setWindowTitle(L["Loading..."]); | ||
|
||
C_Macro.restoreMacroCache(); // Needs to be done before addons are loaded, as they may want to interact with the cache? | ||
|
||
WebClient.createUserInterface(); | ||
C_Addons.loadAddonCache(); | ||
C_Addons.loadEnabledAddons(); | ||
|
||
const windowTitle = format("%s (%s)", WebClient.titleString, WebClient.versionString); | ||
WebClient.setWindowTitle(windowTitle); | ||
|
||
C_EventSystem.registerEvent("SCRIPT_EXECUTION_FINISHED", "WebClient", WebClient.onScriptExecutionFinished); | ||
|
||
window.onbeforeunload = function () { | ||
C_EventSystem.triggerEvent("APPLICATION_SHUTDOWN"); | ||
}; | ||
|
||
C_EventSystem.registerEvent("APPLICATION_SHUTDOWN", "WebClient", function () { | ||
DEBUG("Application shutting down; performing cleanup tasks"); | ||
C_Addons.saveAddonCache(); | ||
C_Macro.saveMacroCache(); | ||
C_Settings.saveSettingsCache(); | ||
}); | ||
|
||
WebClient.run(); | ||
|
||
C_Profiling.endTimer("StartWebClient"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.