From ddc64fb14caded7e49c0886cfa58b1ca82900262 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:08:57 +1100 Subject: [PATCH] Fix up and add options menu slider --- .../interface/optionsmenu/body_blank.png | Bin 1017 -> 1088 bytes .../optionsmenu/optionsmenu.config.patch | 18 +++++++++++++----- source/frontend/StarMainMixer.cpp | 9 ++------- source/frontend/StarOptionsMenu.cpp | 16 ++++++++++++++++ source/frontend/StarOptionsMenu.hpp | 4 ++++ source/game/StarEntityRendering.hpp | 2 -- source/game/StarSongbook.cpp | 3 ++- source/game/StarWorldClient.cpp | 9 --------- source/game/StarWorldClient.hpp | 4 ---- 9 files changed, 37 insertions(+), 28 deletions(-) diff --git a/assets/opensb/interface/optionsmenu/body_blank.png b/assets/opensb/interface/optionsmenu/body_blank.png index 7d5b0f1b36716d0682417c0ee9c487dc8286a2ed..dcb6112b7521903e06712c9b6cb5de4362e23db7 100644 GIT binary patch literal 1088 zcmeAS@N?(olHy`uVBq!ia0vp^Z-96g2OE%F%d+qvkYX$ja(7}_cTVOdki(Mh=;N{Dg zU;O#==i94Sua@j#5&8V{Pu|^Q{hz*Uz5n`cc;z4U$DcS@1aw#gG0@A>f~1WRccxEY zk+CyoUY^|Y%P-G<<_>rHagqSmy_T5RO&{<`6SqY!F9Wg11iPHaC~b%W2xDzMpe zdEc7$*1JAdjtI}qQB|9@`G{;JzqjtS!+dihfQlm?D8OxjILkzG&DRZwlWcR?)#k1^ zxFp#9+TlZaYI9+p-&@xf`+t62&^)H2yLzqXCoXh^1PU72_P=^tEaR15LU#7;;%)yI zLW2%X6@Ko!wanGe?pa;XIOrsRjHZ_|`KV1kz3KP4tgX8=cGpZiFULQe^W^sE%5JVKS)jUv^D);N5kU*|^p~n>6`ulQbb3)F|G3~9kuRmL@Nnoxqas3>6dRN8An~xI<7CElJ9-FuQlbGlgD>)R8 z@P4ei`?O3uKhSaQPLc+$DlcYiT)y$g%I}l-c;DpgcPI}Jyw7GEp*Owx z^y$;TXV0F!`IAt9&+^Odq0;uJF6ZtKzrFs`5C68Of*cAF97-7I((41AH*>y4#4TF% zv!-reolO7na((@Pt0_j7rUgt=Di|6tjX)E*blU&O8sFu?*{=^+uUX67E2P6Bhy%SW z%~*8x^#k42*BuwLa61CgEW7r*YeM|i^@q)@udDkPS@!>QfyJM=GV7P0WwzZ+I9g@% zPwcJLjiX70q4Ua&qPMwjlPN+P^PG{>3{^}=3s$$Nxv+_+!Q0zcL9+MBw;;#nEyglHd zo@H=prSj**hqZ22FlSfUw#U}`+iUwbCS5(&TpW=x0ZB8$po9NyZ=Yevs^yx$|FCxR z|Am1~tqP=~Yu6fWH*e!J@!BBZf`pFb&ShA9@x`t;`!+`CtUIL_|77#=!?|%%+KH{VRI^m6_D^H0rR z3%UOHad8V)olGfurDbSxqBi2jX1n)?xy%l@FV5JP6(zpjuG)rYPR50AdrqGXySJz* z>bNtK^ISG4ZhIb^w+-Twyw?Zj$-b$La2DooUf9`w^nweD-G~5#Imjdbpq;JlRNI93 znnNfNj2zz+?$w!oeDvtizi;2Jou6}v50R>X39E|x+mk0t-Z1`tBrMj%fgL6Bu+=j> YJ#*MM_LAl%V0LBjboFyt=akR{0B3HORR910 diff --git a/assets/opensb/interface/optionsmenu/optionsmenu.config.patch b/assets/opensb/interface/optionsmenu/optionsmenu.config.patch index cc8568b..b428f37 100644 --- a/assets/opensb/interface/optionsmenu/optionsmenu.config.patch +++ b/assets/opensb/interface/optionsmenu/optionsmenu.config.patch @@ -2,13 +2,13 @@ "paneLayout" : { "voiceLabel" : { "type" : "label", - "position" : [119, 186], + "position" : [119, 202], "hAnchor" : "mid", "value" : "VOICE" }, "showVoiceSettings" : { "type" : "button", - "position" : [30, 169], + "position" : [30, 185], "caption" : "Settings", "base" : "/interface/optionsmenu/duocontrolsbutton.png", "hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png" @@ -16,7 +16,7 @@ "showVoicePlayers" : { "type" : "button", "disabled" : true, - "position" : [133, 169], + "position" : [133, 185], "caption" : "^#a0a000,font=iosevka-semiboldoblique;TODO^#aa7;:^reset; Players", "base" : "/interface/optionsmenu/duocontrolsbutton.png", "hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png" @@ -42,7 +42,15 @@ "base" : "/interface/optionsmenu/tricontrolsbutton.png", "hover" : "/interface/optionsmenu/tricontrolsbuttonhover.png" }, - "sfxValueLabel" : { "position" : [192, 142] }, // this is 2px too low in vanilla lol - "musicSlider" : { "position" : [62, 126] } + + "volumeLabel" : { "position" : [119, 173] }, + "musicSlider" : { "position" : [62, 126] }, + + "sfxLabel" : { "position" : [32, 142], "value" : "Sound" }, + "sfxValueLabel" : { "position" : [192, 142] }, + + "instrumentSlider" : { "type" : "slider", "position" : [62, 158], "gridImage" : "/interface/optionsmenu/largeselection.png" }, + "instrumentLabel" : { "type" : "label", "position" : [32, 158], "value" : "Tunes" }, + "instrumentValueLabel" : { "type" : "label", "position" : [192, 158], "hAnchor" : "mid", "value" : "Replace Me" } } } \ No newline at end of file diff --git a/source/frontend/StarMainMixer.cpp b/source/frontend/StarMainMixer.cpp index 16fb736..a0f5e2b 100644 --- a/source/frontend/StarMainMixer.cpp +++ b/source/frontend/StarMainMixer.cpp @@ -54,14 +54,9 @@ void MainMixer::update(float dt, bool muteSfx, bool muteMusic) { currentWorld = m_universeClient->worldClient(); if (currentWorld) { - for (auto audioInstance : currentWorld->pullPendingAudio()) { - audioInstance->setMixerGroup(MixerGroup::Effects); + for (auto audioInstance : currentWorld->pullPendingAudio()) m_mixer->play(audioInstance); - } - for (auto audioInstance : currentWorld->pullPendingInstrumentAudio()) { - audioInstance->setMixerGroup(MixerGroup::Instruments); - m_mixer->play(audioInstance); - } + for (auto audioInstance : currentWorld->pullPendingMusic()) { audioInstance->setMixerGroup(MixerGroup::Music); m_mixer->play(audioInstance); diff --git a/source/frontend/StarOptionsMenu.cpp b/source/frontend/StarOptionsMenu.cpp index caa1b21..0ea1fa1 100644 --- a/source/frontend/StarOptionsMenu.cpp +++ b/source/frontend/StarOptionsMenu.cpp @@ -20,6 +20,9 @@ OptionsMenu::OptionsMenu(PaneManager* manager) GuiReader reader; + reader.registerCallback("instrumentSlider", [=](Widget*) { + updateInstrumentVol(); + }); reader.registerCallback("sfxSlider", [=](Widget*) { updateSFXVol(); }); @@ -67,6 +70,7 @@ OptionsMenu::OptionsMenu(PaneManager* manager) reader.construct(config.get("paneLayout"), this); + m_instrumentSlider = fetchChild("instrumentSlider"); m_sfxSlider = fetchChild("sfxSlider"); m_musicSlider = fetchChild("musicSlider"); m_tutorialMessagesButton = fetchChild("tutorialMessagesCheckbox"); @@ -74,10 +78,12 @@ OptionsMenu::OptionsMenu(PaneManager* manager) m_clientP2PJoinableButton = fetchChild("clientP2PJoinableCheckbox"); m_allowAssetsMismatchButton = fetchChild("allowAssetsMismatchCheckbox"); + m_instrumentLabel = fetchChild("instrumentValueLabel"); m_sfxLabel = fetchChild("sfxValueLabel"); m_musicLabel = fetchChild("musicValueLabel"); m_p2pJoinableLabel = fetchChild("clientP2PJoinableLabel"); + m_instrumentSlider->setRange(m_sfxRange, assets->json("/interface/optionsmenu/optionsmenu.config:sfxDelta").toInt()); m_sfxSlider->setRange(m_sfxRange, assets->json("/interface/optionsmenu/optionsmenu.config:sfxDelta").toInt()); m_musicSlider->setRange(m_musicRange, assets->json("/interface/optionsmenu/optionsmenu.config:musicDelta").toInt()); @@ -103,6 +109,7 @@ void OptionsMenu::toggleFullscreen() { } StringList const OptionsMenu::ConfigKeys = { + "instrumentVol", "sfxVol", "musicVol", "tutorialMessages", @@ -120,6 +127,12 @@ void OptionsMenu::initConfig() { } } +void OptionsMenu::updateInstrumentVol() { + m_localChanges.set("instrumentVol", m_instrumentSlider->val()); + Root::singleton().configuration()->set("instrumentVol", m_instrumentSlider->val()); + m_instrumentLabel->setText(toString(m_instrumentSlider->val())); +} + void OptionsMenu::updateSFXVol() { m_localChanges.set("sfxVol", m_sfxSlider->val()); Root::singleton().configuration()->set("sfxVol", m_sfxSlider->val()); @@ -154,6 +167,9 @@ void OptionsMenu::updateAllowAssetsMismatch() { } void OptionsMenu::syncGuiToConf() { + m_instrumentSlider->setVal(m_localChanges.get("instrumentVol").toInt(), false); + m_instrumentLabel->setText(toString(m_instrumentSlider->val())); + m_sfxSlider->setVal(m_localChanges.get("sfxVol").toInt(), false); m_sfxLabel->setText(toString(m_sfxSlider->val())); diff --git a/source/frontend/StarOptionsMenu.hpp b/source/frontend/StarOptionsMenu.hpp index b984f02..d98fb20 100644 --- a/source/frontend/StarOptionsMenu.hpp +++ b/source/frontend/StarOptionsMenu.hpp @@ -29,6 +29,7 @@ private: void initConfig(); + void updateInstrumentVol(); void updateSFXVol(); void updateMusicVol(); void updateTutorialMessages(); @@ -43,6 +44,7 @@ private: void displayModBindings(); void displayGraphics(); + SliderBarWidgetPtr m_instrumentSlider; SliderBarWidgetPtr m_sfxSlider; SliderBarWidgetPtr m_musicSlider; ButtonWidgetPtr m_tutorialMessagesButton; @@ -51,10 +53,12 @@ private: ButtonWidgetPtr m_clientP2PJoinableButton; ButtonWidgetPtr m_allowAssetsMismatchButton; + LabelWidgetPtr m_instrumentLabel; LabelWidgetPtr m_sfxLabel; LabelWidgetPtr m_musicLabel; LabelWidgetPtr m_p2pJoinableLabel; + //TODO: add instrument range (or just use one range for all 3, it's kinda silly.) Vec2I m_sfxRange; Vec2I m_musicRange; diff --git a/source/game/StarEntityRendering.hpp b/source/game/StarEntityRendering.hpp index cc78748..c131a81 100644 --- a/source/game/StarEntityRendering.hpp +++ b/source/game/StarEntityRendering.hpp @@ -22,7 +22,6 @@ public: virtual void addDrawable(Drawable drawable, EntityRenderLayer renderLayer) = 0; virtual void addLightSource(LightSource lightSource) = 0; virtual void addParticle(Particle particle) = 0; - virtual void addInstrumentAudio(AudioInstancePtr audio) = 0; virtual void addAudio(AudioInstancePtr audio) = 0; virtual void addTilePreview(PreviewTile preview) = 0; virtual void addOverheadBar(OverheadBar bar) = 0; @@ -32,7 +31,6 @@ public: void addDrawables(List drawables, EntityRenderLayer renderLayer, Vec2F translate = Vec2F()); void addLightSources(List lightSources, Vec2F translate = Vec2F()); void addParticles(List particles, Vec2F translate = Vec2F()); - void addInstrumentAudios(List audios, Vec2F translate = Vec2F()); void addAudios(List audios, Vec2F translate = Vec2F()); void addTilePreviews(List previews); void addOverheadBars(List bars, Vec2F translate = Vec2F()); diff --git a/source/game/StarSongbook.cpp b/source/game/StarSongbook.cpp index cba60f3..68db655 100644 --- a/source/game/StarSongbook.cpp +++ b/source/game/StarSongbook.cpp @@ -138,6 +138,7 @@ void Songbook::playback() { } AudioInstancePtr audioInstance = make_shared(*m_uncompressedSamples[note.file]); + audioInstance->setMixerGroup(MixerGroup::Instruments); audioInstance->setPitchMultiplier(note.velocity); auto start = m_timeSourceInstance->epoch + (int64_t)(note.timecode * 1000.0); @@ -153,7 +154,7 @@ void Songbook::playback() { void Songbook::render(RenderCallback* renderCallback) { for (auto& a : m_pendingAudio) - renderCallback->addInstrumentAudio(a); + renderCallback->addAudio(a); m_pendingAudio.clear(); } diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index 3c83d4d..b2a79fb 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -165,7 +165,6 @@ void WorldClient::removeEntity(EntityId entityId, bool andDie) { m_particles->addParticles(move(renderCallback.particles)); m_samples.appendAll(move(renderCallback.audios)); - m_instrumentSamples.appendAll(move(renderCallback.instrumentAudios)); } if (auto version = m_masterEntitiesNetVersion.maybeTake(entity->entityId())) { @@ -546,7 +545,6 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) { m_particles->addParticles(move(renderCallback.particles)); m_samples.appendAll(move(renderCallback.audios)); - m_instrumentSamples.appendAll(move(renderCallback.instrumentAudios)); previewTiles.appendAll(move(renderCallback.previewTiles)); renderData.overheadBars.appendAll(move(renderCallback.overheadBars)); @@ -687,9 +685,6 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) { List WorldClient::pullPendingAudio() { return take(m_samples); } -List WorldClient::pullPendingInstrumentAudio() { - return take(m_instrumentSamples); -} List WorldClient::pullPendingMusic() { return take(m_music); @@ -2142,10 +2137,6 @@ void WorldClient::ClientRenderCallback::addAudio(AudioInstancePtr audio) { audios.append(move(audio)); } -void WorldClient::ClientRenderCallback::addInstrumentAudio(AudioInstancePtr audio) { - instrumentAudios.append(move(audio)); -} - void WorldClient::ClientRenderCallback::addTilePreview(PreviewTile preview) { previewTiles.append(move(preview)); } diff --git a/source/game/StarWorldClient.hpp b/source/game/StarWorldClient.hpp index bb8facb..3e9d15e 100644 --- a/source/game/StarWorldClient.hpp +++ b/source/game/StarWorldClient.hpp @@ -149,7 +149,6 @@ public: // calculations. It is not necessary on the light array. void render(WorldRenderData& renderData, unsigned borderTiles); List pullPendingAudio(); - List pullPendingInstrumentAudio(); List pullPendingMusic(); bool playerCanReachEntity(EntityId entityId, bool preferInteractive = true) const; @@ -183,7 +182,6 @@ private: void addLightSource(LightSource lightSource) override; void addParticle(Particle particle) override; void addAudio(AudioInstancePtr audio) override; - void addInstrumentAudio(AudioInstancePtr audio) override; void addTilePreview(PreviewTile preview) override; void addOverheadBar(OverheadBar bar) override; @@ -191,7 +189,6 @@ private: List lightSources; List particles; List audios; - List instrumentAudios; List previewTiles; List overheadBars; }; @@ -311,7 +308,6 @@ private: ParticleManagerPtr m_particles; List m_samples; - List m_instrumentSamples; List m_music; HashMap m_masterEntitiesNetVersion;