Fix up and add options menu slider

This commit is contained in:
Kae 2024-01-03 20:08:57 +11:00
parent 91cf2d8251
commit ddc64fb14c
9 changed files with 37 additions and 28 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1017 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2,13 +2,13 @@
"paneLayout" : { "paneLayout" : {
"voiceLabel" : { "voiceLabel" : {
"type" : "label", "type" : "label",
"position" : [119, 186], "position" : [119, 202],
"hAnchor" : "mid", "hAnchor" : "mid",
"value" : "VOICE" "value" : "VOICE"
}, },
"showVoiceSettings" : { "showVoiceSettings" : {
"type" : "button", "type" : "button",
"position" : [30, 169], "position" : [30, 185],
"caption" : "Settings", "caption" : "Settings",
"base" : "/interface/optionsmenu/duocontrolsbutton.png", "base" : "/interface/optionsmenu/duocontrolsbutton.png",
"hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png" "hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png"
@ -16,7 +16,7 @@
"showVoicePlayers" : { "showVoicePlayers" : {
"type" : "button", "type" : "button",
"disabled" : true, "disabled" : true,
"position" : [133, 169], "position" : [133, 185],
"caption" : "^#a0a000,font=iosevka-semiboldoblique;TODO^#aa7;:^reset; Players", "caption" : "^#a0a000,font=iosevka-semiboldoblique;TODO^#aa7;:^reset; Players",
"base" : "/interface/optionsmenu/duocontrolsbutton.png", "base" : "/interface/optionsmenu/duocontrolsbutton.png",
"hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png" "hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png"
@ -42,7 +42,15 @@
"base" : "/interface/optionsmenu/tricontrolsbutton.png", "base" : "/interface/optionsmenu/tricontrolsbutton.png",
"hover" : "/interface/optionsmenu/tricontrolsbuttonhover.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" }
} }
} }

View File

@ -54,14 +54,9 @@ void MainMixer::update(float dt, bool muteSfx, bool muteMusic) {
currentWorld = m_universeClient->worldClient(); currentWorld = m_universeClient->worldClient();
if (currentWorld) { if (currentWorld) {
for (auto audioInstance : currentWorld->pullPendingAudio()) { for (auto audioInstance : currentWorld->pullPendingAudio())
audioInstance->setMixerGroup(MixerGroup::Effects);
m_mixer->play(audioInstance); m_mixer->play(audioInstance);
}
for (auto audioInstance : currentWorld->pullPendingInstrumentAudio()) {
audioInstance->setMixerGroup(MixerGroup::Instruments);
m_mixer->play(audioInstance);
}
for (auto audioInstance : currentWorld->pullPendingMusic()) { for (auto audioInstance : currentWorld->pullPendingMusic()) {
audioInstance->setMixerGroup(MixerGroup::Music); audioInstance->setMixerGroup(MixerGroup::Music);
m_mixer->play(audioInstance); m_mixer->play(audioInstance);

View File

@ -20,6 +20,9 @@ OptionsMenu::OptionsMenu(PaneManager* manager)
GuiReader reader; GuiReader reader;
reader.registerCallback("instrumentSlider", [=](Widget*) {
updateInstrumentVol();
});
reader.registerCallback("sfxSlider", [=](Widget*) { reader.registerCallback("sfxSlider", [=](Widget*) {
updateSFXVol(); updateSFXVol();
}); });
@ -67,6 +70,7 @@ OptionsMenu::OptionsMenu(PaneManager* manager)
reader.construct(config.get("paneLayout"), this); reader.construct(config.get("paneLayout"), this);
m_instrumentSlider = fetchChild<SliderBarWidget>("instrumentSlider");
m_sfxSlider = fetchChild<SliderBarWidget>("sfxSlider"); m_sfxSlider = fetchChild<SliderBarWidget>("sfxSlider");
m_musicSlider = fetchChild<SliderBarWidget>("musicSlider"); m_musicSlider = fetchChild<SliderBarWidget>("musicSlider");
m_tutorialMessagesButton = fetchChild<ButtonWidget>("tutorialMessagesCheckbox"); m_tutorialMessagesButton = fetchChild<ButtonWidget>("tutorialMessagesCheckbox");
@ -74,10 +78,12 @@ OptionsMenu::OptionsMenu(PaneManager* manager)
m_clientP2PJoinableButton = fetchChild<ButtonWidget>("clientP2PJoinableCheckbox"); m_clientP2PJoinableButton = fetchChild<ButtonWidget>("clientP2PJoinableCheckbox");
m_allowAssetsMismatchButton = fetchChild<ButtonWidget>("allowAssetsMismatchCheckbox"); m_allowAssetsMismatchButton = fetchChild<ButtonWidget>("allowAssetsMismatchCheckbox");
m_instrumentLabel = fetchChild<LabelWidget>("instrumentValueLabel");
m_sfxLabel = fetchChild<LabelWidget>("sfxValueLabel"); m_sfxLabel = fetchChild<LabelWidget>("sfxValueLabel");
m_musicLabel = fetchChild<LabelWidget>("musicValueLabel"); m_musicLabel = fetchChild<LabelWidget>("musicValueLabel");
m_p2pJoinableLabel = fetchChild<LabelWidget>("clientP2PJoinableLabel"); m_p2pJoinableLabel = fetchChild<LabelWidget>("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_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()); m_musicSlider->setRange(m_musicRange, assets->json("/interface/optionsmenu/optionsmenu.config:musicDelta").toInt());
@ -103,6 +109,7 @@ void OptionsMenu::toggleFullscreen() {
} }
StringList const OptionsMenu::ConfigKeys = { StringList const OptionsMenu::ConfigKeys = {
"instrumentVol",
"sfxVol", "sfxVol",
"musicVol", "musicVol",
"tutorialMessages", "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() { void OptionsMenu::updateSFXVol() {
m_localChanges.set("sfxVol", m_sfxSlider->val()); m_localChanges.set("sfxVol", m_sfxSlider->val());
Root::singleton().configuration()->set("sfxVol", m_sfxSlider->val()); Root::singleton().configuration()->set("sfxVol", m_sfxSlider->val());
@ -154,6 +167,9 @@ void OptionsMenu::updateAllowAssetsMismatch() {
} }
void OptionsMenu::syncGuiToConf() { 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_sfxSlider->setVal(m_localChanges.get("sfxVol").toInt(), false);
m_sfxLabel->setText(toString(m_sfxSlider->val())); m_sfxLabel->setText(toString(m_sfxSlider->val()));

View File

@ -29,6 +29,7 @@ private:
void initConfig(); void initConfig();
void updateInstrumentVol();
void updateSFXVol(); void updateSFXVol();
void updateMusicVol(); void updateMusicVol();
void updateTutorialMessages(); void updateTutorialMessages();
@ -43,6 +44,7 @@ private:
void displayModBindings(); void displayModBindings();
void displayGraphics(); void displayGraphics();
SliderBarWidgetPtr m_instrumentSlider;
SliderBarWidgetPtr m_sfxSlider; SliderBarWidgetPtr m_sfxSlider;
SliderBarWidgetPtr m_musicSlider; SliderBarWidgetPtr m_musicSlider;
ButtonWidgetPtr m_tutorialMessagesButton; ButtonWidgetPtr m_tutorialMessagesButton;
@ -51,10 +53,12 @@ private:
ButtonWidgetPtr m_clientP2PJoinableButton; ButtonWidgetPtr m_clientP2PJoinableButton;
ButtonWidgetPtr m_allowAssetsMismatchButton; ButtonWidgetPtr m_allowAssetsMismatchButton;
LabelWidgetPtr m_instrumentLabel;
LabelWidgetPtr m_sfxLabel; LabelWidgetPtr m_sfxLabel;
LabelWidgetPtr m_musicLabel; LabelWidgetPtr m_musicLabel;
LabelWidgetPtr m_p2pJoinableLabel; LabelWidgetPtr m_p2pJoinableLabel;
//TODO: add instrument range (or just use one range for all 3, it's kinda silly.)
Vec2I m_sfxRange; Vec2I m_sfxRange;
Vec2I m_musicRange; Vec2I m_musicRange;

View File

@ -22,7 +22,6 @@ public:
virtual void addDrawable(Drawable drawable, EntityRenderLayer renderLayer) = 0; virtual void addDrawable(Drawable drawable, EntityRenderLayer renderLayer) = 0;
virtual void addLightSource(LightSource lightSource) = 0; virtual void addLightSource(LightSource lightSource) = 0;
virtual void addParticle(Particle particle) = 0; virtual void addParticle(Particle particle) = 0;
virtual void addInstrumentAudio(AudioInstancePtr audio) = 0;
virtual void addAudio(AudioInstancePtr audio) = 0; virtual void addAudio(AudioInstancePtr audio) = 0;
virtual void addTilePreview(PreviewTile preview) = 0; virtual void addTilePreview(PreviewTile preview) = 0;
virtual void addOverheadBar(OverheadBar bar) = 0; virtual void addOverheadBar(OverheadBar bar) = 0;
@ -32,7 +31,6 @@ public:
void addDrawables(List<Drawable> drawables, EntityRenderLayer renderLayer, Vec2F translate = Vec2F()); void addDrawables(List<Drawable> drawables, EntityRenderLayer renderLayer, Vec2F translate = Vec2F());
void addLightSources(List<LightSource> lightSources, Vec2F translate = Vec2F()); void addLightSources(List<LightSource> lightSources, Vec2F translate = Vec2F());
void addParticles(List<Particle> particles, Vec2F translate = Vec2F()); void addParticles(List<Particle> particles, Vec2F translate = Vec2F());
void addInstrumentAudios(List<AudioInstancePtr> audios, Vec2F translate = Vec2F());
void addAudios(List<AudioInstancePtr> audios, Vec2F translate = Vec2F()); void addAudios(List<AudioInstancePtr> audios, Vec2F translate = Vec2F());
void addTilePreviews(List<PreviewTile> previews); void addTilePreviews(List<PreviewTile> previews);
void addOverheadBars(List<OverheadBar> bars, Vec2F translate = Vec2F()); void addOverheadBars(List<OverheadBar> bars, Vec2F translate = Vec2F());

View File

@ -138,6 +138,7 @@ void Songbook::playback() {
} }
AudioInstancePtr audioInstance = make_shared<AudioInstance>(*m_uncompressedSamples[note.file]); AudioInstancePtr audioInstance = make_shared<AudioInstance>(*m_uncompressedSamples[note.file]);
audioInstance->setMixerGroup(MixerGroup::Instruments);
audioInstance->setPitchMultiplier(note.velocity); audioInstance->setPitchMultiplier(note.velocity);
auto start = m_timeSourceInstance->epoch + (int64_t)(note.timecode * 1000.0); auto start = m_timeSourceInstance->epoch + (int64_t)(note.timecode * 1000.0);
@ -153,7 +154,7 @@ void Songbook::playback() {
void Songbook::render(RenderCallback* renderCallback) { void Songbook::render(RenderCallback* renderCallback) {
for (auto& a : m_pendingAudio) for (auto& a : m_pendingAudio)
renderCallback->addInstrumentAudio(a); renderCallback->addAudio(a);
m_pendingAudio.clear(); m_pendingAudio.clear();
} }

View File

@ -165,7 +165,6 @@ void WorldClient::removeEntity(EntityId entityId, bool andDie) {
m_particles->addParticles(move(renderCallback.particles)); m_particles->addParticles(move(renderCallback.particles));
m_samples.appendAll(move(renderCallback.audios)); m_samples.appendAll(move(renderCallback.audios));
m_instrumentSamples.appendAll(move(renderCallback.instrumentAudios));
} }
if (auto version = m_masterEntitiesNetVersion.maybeTake(entity->entityId())) { 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_particles->addParticles(move(renderCallback.particles));
m_samples.appendAll(move(renderCallback.audios)); m_samples.appendAll(move(renderCallback.audios));
m_instrumentSamples.appendAll(move(renderCallback.instrumentAudios));
previewTiles.appendAll(move(renderCallback.previewTiles)); previewTiles.appendAll(move(renderCallback.previewTiles));
renderData.overheadBars.appendAll(move(renderCallback.overheadBars)); renderData.overheadBars.appendAll(move(renderCallback.overheadBars));
@ -687,9 +685,6 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
List<AudioInstancePtr> WorldClient::pullPendingAudio() { List<AudioInstancePtr> WorldClient::pullPendingAudio() {
return take(m_samples); return take(m_samples);
} }
List<AudioInstancePtr> WorldClient::pullPendingInstrumentAudio() {
return take(m_instrumentSamples);
}
List<AudioInstancePtr> WorldClient::pullPendingMusic() { List<AudioInstancePtr> WorldClient::pullPendingMusic() {
return take(m_music); return take(m_music);
@ -2142,10 +2137,6 @@ void WorldClient::ClientRenderCallback::addAudio(AudioInstancePtr audio) {
audios.append(move(audio)); audios.append(move(audio));
} }
void WorldClient::ClientRenderCallback::addInstrumentAudio(AudioInstancePtr audio) {
instrumentAudios.append(move(audio));
}
void WorldClient::ClientRenderCallback::addTilePreview(PreviewTile preview) { void WorldClient::ClientRenderCallback::addTilePreview(PreviewTile preview) {
previewTiles.append(move(preview)); previewTiles.append(move(preview));
} }

View File

@ -149,7 +149,6 @@ public:
// calculations. It is not necessary on the light array. // calculations. It is not necessary on the light array.
void render(WorldRenderData& renderData, unsigned borderTiles); void render(WorldRenderData& renderData, unsigned borderTiles);
List<AudioInstancePtr> pullPendingAudio(); List<AudioInstancePtr> pullPendingAudio();
List<AudioInstancePtr> pullPendingInstrumentAudio();
List<AudioInstancePtr> pullPendingMusic(); List<AudioInstancePtr> pullPendingMusic();
bool playerCanReachEntity(EntityId entityId, bool preferInteractive = true) const; bool playerCanReachEntity(EntityId entityId, bool preferInteractive = true) const;
@ -183,7 +182,6 @@ private:
void addLightSource(LightSource lightSource) override; void addLightSource(LightSource lightSource) override;
void addParticle(Particle particle) override; void addParticle(Particle particle) override;
void addAudio(AudioInstancePtr audio) override; void addAudio(AudioInstancePtr audio) override;
void addInstrumentAudio(AudioInstancePtr audio) override;
void addTilePreview(PreviewTile preview) override; void addTilePreview(PreviewTile preview) override;
void addOverheadBar(OverheadBar bar) override; void addOverheadBar(OverheadBar bar) override;
@ -191,7 +189,6 @@ private:
List<LightSource> lightSources; List<LightSource> lightSources;
List<Particle> particles; List<Particle> particles;
List<AudioInstancePtr> audios; List<AudioInstancePtr> audios;
List<AudioInstancePtr> instrumentAudios;
List<PreviewTile> previewTiles; List<PreviewTile> previewTiles;
List<OverheadBar> overheadBars; List<OverheadBar> overheadBars;
}; };
@ -311,7 +308,6 @@ private:
ParticleManagerPtr m_particles; ParticleManagerPtr m_particles;
List<AudioInstancePtr> m_samples; List<AudioInstancePtr> m_samples;
List<AudioInstancePtr> m_instrumentSamples;
List<AudioInstancePtr> m_music; List<AudioInstancePtr> m_music;
HashMap<EntityId, uint64_t> m_masterEntitiesNetVersion; HashMap<EntityId, uint64_t> m_masterEntitiesNetVersion;