@@ -8,5 +8,6 @@ namespace game
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MeasurementSystem measurementSystem{MeasurementSystem::METRIC};
|
MeasurementSystem measurementSystem{MeasurementSystem::METRIC};
|
||||||
|
int volume{100};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,12 @@ namespace game::resource
|
|||||||
return mixer;
|
return mixer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::set_gain(float gain)
|
||||||
|
{
|
||||||
|
auto mixer = mixer_get();
|
||||||
|
MIX_SetMasterGain(mixer, gain);
|
||||||
|
}
|
||||||
|
|
||||||
void Audio::retain()
|
void Audio::retain()
|
||||||
{
|
{
|
||||||
if (refCount) ++(*refCount);
|
if (refCount) ++(*refCount);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace game::resource
|
|||||||
MIX_Audio* internal{nullptr};
|
MIX_Audio* internal{nullptr};
|
||||||
MIX_Track* track{nullptr};
|
MIX_Track* track{nullptr};
|
||||||
int* refCount{nullptr};
|
int* refCount{nullptr};
|
||||||
MIX_Mixer* mixer_get();
|
static MIX_Mixer* mixer_get();
|
||||||
void unload();
|
void unload();
|
||||||
void retain();
|
void retain();
|
||||||
void release();
|
void release();
|
||||||
@@ -27,5 +27,6 @@ namespace game::resource
|
|||||||
void play(bool isLoop = false);
|
void play(bool isLoop = false);
|
||||||
void stop();
|
void stop();
|
||||||
bool is_playing() const;
|
bool is_playing() const;
|
||||||
|
static void set_gain(float vol);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,8 @@ namespace game
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Resources::sound_play(audio::Type type) { audio[type].play(); }
|
void Resources::sound_play(audio::Type type) { audio[type].play(); }
|
||||||
|
|
||||||
|
void Resources::set_audio_gain(float vol) {
|
||||||
|
Audio::set_gain(vol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -124,5 +124,6 @@ namespace game
|
|||||||
|
|
||||||
Resources();
|
Resources();
|
||||||
void sound_play(audio::Type);
|
void sound_play(audio::Type);
|
||||||
|
void set_audio_gain(float vol);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace game::window
|
|||||||
ImVec2 pos)
|
ImVec2 pos)
|
||||||
{
|
{
|
||||||
MeasurementSystem& measurementSystem = gameData.measurementSystem;
|
MeasurementSystem& measurementSystem = gameData.measurementSystem;
|
||||||
|
int& volume = gameData.volume;
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(size);
|
ImGui::SetNextWindowSize(size);
|
||||||
ImGui::SetNextWindowPos(pos);
|
ImGui::SetNextWindowPos(pos);
|
||||||
@@ -48,6 +49,13 @@ namespace game::window
|
|||||||
ImGui::RadioButton("Metric", (int*)&measurementSystem, MeasurementSystem::METRIC);
|
ImGui::RadioButton("Metric", (int*)&measurementSystem, MeasurementSystem::METRIC);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::RadioButton("Imperial", (int*)&measurementSystem, MeasurementSystem::IMPERIAL);
|
ImGui::RadioButton("Imperial", (int*)&measurementSystem, MeasurementSystem::IMPERIAL);
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Sound");
|
||||||
|
if (ImGui::SliderInt("Volume", (int*)&volume, 0, 100))
|
||||||
|
{
|
||||||
|
resources.set_audio_gain((float)volume / 100);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user