refactor jail_audio: namespace Ja, enum class, tipus sense prefix JA_
This commit is contained in:
+14
-14
@@ -6,7 +6,7 @@
|
||||
#include <sstream> // for basic_stringstream
|
||||
|
||||
#include "core/audio/audio.hpp" // for Audio::get (playSound)
|
||||
#include "core/audio/jail_audio.hpp" // for JA_LoadSound, JA_DeleteSound (propietat local)
|
||||
#include "core/audio/jail_audio.hpp" // for Ja::loadSound, Ja::deleteSound (propietat local)
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, InputAction
|
||||
#include "core/rendering/text.h" // for Text
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
@@ -40,7 +40,7 @@ Menu::Menu(SDL_Renderer *renderer, const std::string &file)
|
||||
center_x_ = 0;
|
||||
center_y_ = 0;
|
||||
widest_item_ = 0;
|
||||
default_action_when_cancel = 0;
|
||||
default_action_when_cancel_ = 0;
|
||||
|
||||
// Selector
|
||||
selector_.origin_y = 0;
|
||||
@@ -73,15 +73,15 @@ Menu::~Menu() {
|
||||
renderer_ = nullptr;
|
||||
|
||||
if (sound_move_ != nullptr) {
|
||||
JA_DeleteSound(sound_move_);
|
||||
Ja::deleteSound(sound_move_);
|
||||
}
|
||||
|
||||
if (sound_accept_ != nullptr) {
|
||||
JA_DeleteSound(sound_accept_);
|
||||
Ja::deleteSound(sound_accept_);
|
||||
}
|
||||
|
||||
if (sound_cancel_ != nullptr) {
|
||||
JA_DeleteSound(sound_cancel_);
|
||||
Ja::deleteSound(sound_cancel_);
|
||||
}
|
||||
|
||||
delete text_;
|
||||
@@ -229,21 +229,21 @@ auto Menu::setVars(const std::string &var, const std::string &value) -> bool {
|
||||
else if (var == "sound_cancel") {
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) {
|
||||
sound_cancel_ = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
sound_cancel_ = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "sound_accept") {
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) {
|
||||
sound_accept_ = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
sound_accept_ = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "sound_move") {
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) {
|
||||
sound_move_ = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
sound_move_ = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ auto Menu::setVars(const std::string &var, const std::string &value) -> bool {
|
||||
}
|
||||
|
||||
else if (var == "defaultActionWhenCancel") {
|
||||
default_action_when_cancel = std::stoi(value);
|
||||
default_action_when_cancel_ = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var.empty()) {
|
||||
@@ -341,15 +341,15 @@ auto Menu::setVars(const std::string &var, const std::string &value) -> bool {
|
||||
void Menu::loadAudioFile(const std::string &file, int sound) {
|
||||
switch (sound) {
|
||||
case SOUND_ACCEPT:
|
||||
sound_accept_ = JA_LoadSound(file.c_str());
|
||||
sound_accept_ = Ja::loadSound(file.c_str());
|
||||
break;
|
||||
|
||||
case SOUND_CANCEL:
|
||||
sound_cancel_ = JA_LoadSound(file.c_str());
|
||||
sound_cancel_ = Ja::loadSound(file.c_str());
|
||||
break;
|
||||
|
||||
case SOUND_MOVE:
|
||||
sound_move_ = JA_LoadSound(file.c_str());
|
||||
sound_move_ = Ja::loadSound(file.c_str());
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -770,7 +770,7 @@ void Menu::setItemCaption(int index, const std::string &text) {
|
||||
|
||||
// Establece el indice del itemm que se usará por defecto al cancelar el menu
|
||||
void Menu::setDefaultActionWhenCancel(int item) {
|
||||
default_action_when_cancel = item;
|
||||
default_action_when_cancel_ = item;
|
||||
}
|
||||
|
||||
// Gestiona la entrada de teclado y mando durante el menu
|
||||
@@ -797,7 +797,7 @@ void Menu::checkInput() {
|
||||
}
|
||||
|
||||
if (Input::get()->checkInput(CANCEL, REPEAT_FALSE)) {
|
||||
item_selected_ = default_action_when_cancel;
|
||||
item_selected_ = default_action_when_cancel_;
|
||||
if (sound_cancel_ != nullptr) {
|
||||
Audio::get()->playSound(sound_cancel_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user