mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-13 10:24:39 +00:00
Add a setting. Various tweaks to sound triggering.
This commit is contained in:
parent
434b717ba0
commit
3fd8f3d86d
@ -433,6 +433,7 @@ static ConfigSetting generalSettings[] = {
|
||||
ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion),
|
||||
ConfigSetting("ForceLagSync2", &g_Config.bForceLagSync, false, true, true),
|
||||
ConfigSetting("DiscordPresence", &g_Config.bDiscordPresence, true, true, false), // Or maybe it makes sense to have it per-game? Race conditions abound...
|
||||
ConfigSetting("UISound", &g_Config.bUISound, true, true, false),
|
||||
|
||||
ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers, true, true),
|
||||
ConfigSetting("AutoLoadSaveState", &g_Config.iAutoLoadSaveState, 0, true, true),
|
||||
|
@ -196,6 +196,7 @@ public:
|
||||
int iMaxRecent;
|
||||
int iCurrentStateSlot;
|
||||
int iRewindFlipFrequency;
|
||||
bool bUISound;
|
||||
bool bEnableStateUndo;
|
||||
int iAutoLoadSaveState; // 0 = off, 1 = oldest, 2 = newest, >2 = slot number + 3
|
||||
bool bEnableCheats;
|
||||
|
@ -859,7 +859,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
systemSettings->Add(new CheckBox(&g_Config.bUISound, dev->T("UI Sound")));
|
||||
systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, sy->T("VersionCheck", "Check for new versions of PPSSPP")));
|
||||
const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png";
|
||||
const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg";
|
||||
|
@ -1208,6 +1208,8 @@ void NativeUpdate() {
|
||||
screenManager->update();
|
||||
|
||||
g_Discord.Update();
|
||||
|
||||
UI::SetSoundEnabled(g_Config.bUISound);
|
||||
}
|
||||
|
||||
bool NativeIsAtTopLevel() {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <deque>
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#include "base/timeutil.h"
|
||||
#include "ui/root.h"
|
||||
#include "ui/viewgroup.h"
|
||||
@ -18,6 +19,7 @@ bool focusForced;
|
||||
static std::mutex eventMutex_;
|
||||
|
||||
static std::function<void(UISound)> soundCallback;
|
||||
static bool soundEnabled = true;
|
||||
|
||||
|
||||
struct DispatchQueueItem {
|
||||
@ -141,12 +143,16 @@ void MoveFocus(ViewGroup *root, FocusDirection direction) {
|
||||
}
|
||||
}
|
||||
|
||||
void SetSoundEnabled(bool enabled) {
|
||||
soundEnabled = enabled;
|
||||
}
|
||||
|
||||
void SetSoundCallback(std::function<void(UISound)> func) {
|
||||
soundCallback = func;
|
||||
}
|
||||
|
||||
void PlayUISound(UISound sound) {
|
||||
if (soundCallback) {
|
||||
if (soundEnabled && soundCallback) {
|
||||
soundCallback(sound);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ enum class UISound {
|
||||
COUNT,
|
||||
};
|
||||
|
||||
void SetSoundEnabled(bool enabled);
|
||||
void SetSoundCallback(std::function<void(UISound)> func);
|
||||
|
||||
void PlayUISound(UISound sound);
|
||||
|
@ -157,10 +157,6 @@ bool UIScreen::key(const KeyInput &key) {
|
||||
}
|
||||
|
||||
void UIScreen::TriggerFinish(DialogResult result) {
|
||||
switch (result) {
|
||||
case DialogResult::DR_BACK: UI::PlayUISound(UI::UISound::BACK); break;
|
||||
case DialogResult::DR_OK: UI::PlayUISound(UI::UISound::CONFIRM); break;
|
||||
}
|
||||
screenManager()->finishDialog(this, result);
|
||||
}
|
||||
|
||||
@ -172,6 +168,7 @@ bool UIDialogScreen::key(const KeyInput &key) {
|
||||
} else {
|
||||
finished_ = true;
|
||||
TriggerFinish(DR_BACK);
|
||||
UI::PlayUISound(UI::UISound::BACK);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -217,7 +217,6 @@ void Clickable::Click() {
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
OnClick.Trigger(e);
|
||||
UI::PlayUISound(UI::UISound::CONFIRM);
|
||||
};
|
||||
|
||||
void Clickable::FocusChanged(int focusFlags) {
|
||||
@ -377,6 +376,7 @@ bool StickyChoice::Key(const KeyInput &key) {
|
||||
if (key.flags & KEY_DOWN) {
|
||||
if (IsAcceptKey(key)) {
|
||||
down_ = true;
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_ON);
|
||||
Click();
|
||||
return true;
|
||||
}
|
||||
@ -425,6 +425,11 @@ void ClickableItem::Draw(UIContext &dc) {
|
||||
DrawBG(dc, style);
|
||||
}
|
||||
|
||||
void Choice::Click() {
|
||||
ClickableItem::Click();
|
||||
UI::PlayUISound(UI::UISound::CONFIRM);
|
||||
}
|
||||
|
||||
void Choice::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const {
|
||||
if (atlasImage_.isValid()) {
|
||||
dc.Draw()->GetAtlas()->measureImage(atlasImage_, &w, &h);
|
||||
@ -597,8 +602,10 @@ void PopupHeader::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
void CheckBox::Toggle() {
|
||||
if (toggle_)
|
||||
if (toggle_) {
|
||||
*toggle_ = !(*toggle_);
|
||||
UI::PlayUISound(*toggle_ ? UI::UISound::TOGGLE_ON : UI::UISound::TOGGLE_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckBox::Toggled() const {
|
||||
@ -669,8 +676,14 @@ void CheckBox::GetContentDimensions(const UIContext &dc, float &w, float &h) con
|
||||
}
|
||||
|
||||
void BitCheckBox::Toggle() {
|
||||
if (bitfield_)
|
||||
if (bitfield_) {
|
||||
*bitfield_ = *bitfield_ ^ bit_;
|
||||
if (*bitfield_ & bit_) {
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_ON);
|
||||
} else {
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BitCheckBox::Toggled() const {
|
||||
@ -690,6 +703,11 @@ void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const
|
||||
h += paddingH_;
|
||||
}
|
||||
|
||||
void Button::Click() {
|
||||
Clickable::Click();
|
||||
UI::PlayUISound(UI::UISound::CONFIRM);
|
||||
}
|
||||
|
||||
void Button::Draw(UIContext &dc) {
|
||||
Style style = dc.theme->buttonStyle;
|
||||
|
||||
|
@ -519,6 +519,7 @@ public:
|
||||
Button(const std::string &text, ImageID imageID, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), text_(text), imageID_(imageID) {}
|
||||
|
||||
void Click() override;
|
||||
void Draw(UIContext &dc) override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
const std::string &GetText() const { return text_; }
|
||||
@ -647,6 +648,7 @@ public:
|
||||
Choice(ImageID image, LayoutParams *layoutParams = nullptr)
|
||||
: ClickableItem(layoutParams), atlasImage_(image), iconImage_(ImageID::invalid()), centered_(false), highlighted_(false), selected_(false) {}
|
||||
|
||||
virtual void Click();
|
||||
virtual void HighlightChanged(bool highlighted);
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "math/curves.h"
|
||||
#include "ui/ui_context.h"
|
||||
#include "ui/ui_tween.h"
|
||||
#include "ui/root.h"
|
||||
#include "ui/view.h"
|
||||
#include "ui/viewgroup.h"
|
||||
#include "gfx_es2/draw_buffer.h"
|
||||
@ -1321,11 +1322,17 @@ void ChoiceStrip::HighlightChoice(unsigned int choice){
|
||||
bool ChoiceStrip::Key(const KeyInput &input) {
|
||||
bool ret = false;
|
||||
if (input.flags & KEY_DOWN) {
|
||||
if (IsTabLeftKey(input) && selected_ > 0) {
|
||||
if (IsTabLeftKey(input)) {
|
||||
if (selected_ > 0) {
|
||||
SetSelection(selected_ - 1);
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_OFF); // Maybe make specific sounds for this at some point?
|
||||
}
|
||||
ret = true;
|
||||
} else if (IsTabRightKey(input) && selected_ < (int)views_.size() - 1) {
|
||||
} else if (IsTabRightKey(input)) {
|
||||
if (selected_ < (int)views_.size() - 1) {
|
||||
SetSelection(selected_ + 1);
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_ON);
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user