#include "config.h" #include "jfile.h" #include namespace config { bool musicEnabled = true; int soundMode = SOUND_ALL; uint8_t keys[6] = {SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_SPACE, SDL_SCANCODE_RETURN}; int8_t pad_btns[6] = {0, 1, 2, 3, 4, 5}; void setMusic(const bool value) { musicEnabled = value; file::setConfigValue("music", musicEnabled ? "yes" : "no"); } void toggleMusic() { musicEnabled = !musicEnabled; file::setConfigValue("music", musicEnabled ? "yes" : "no"); } const bool isMusicEnabled() { return musicEnabled; } void setSound(const int value) { soundMode = value; file::setConfigValue("sound", soundMode==SOUND_ALL ? "all" : soundMode==SOUND_BASIC ? "basic" : "none"); } void toggleSound() { soundMode++; if (soundMode>SOUND_NONE) soundMode = SOUND_ALL; file::setConfigValue("sound", soundMode==SOUND_ALL ? "all" : soundMode==SOUND_BASIC ? "basic" : "none"); } const int getSoundMode() { return soundMode; } void defineKey(const int which, const int key) { static const char* nomtecles[6] = {"keyup", "keydown", "keyleft", "keyright", "keyjump", "keypick"}; keys[which] = key; char tmp[5]; file::setConfigValue(nomtecles[which], SDL_itoa(key, tmp, 10)); } const int getKey(const int which) { return keys[which]; } void definePadBtn(const int which, const int btn) { static const char* nomtecles[6] = {"btnup", "btndown", "btnleft", "btnright", "btnjump", "btnpick"}; pad_btns[which] = btn; char tmp[5]; file::setConfigValue(nomtecles[which], SDL_itoa(btn, tmp, 10)); } const int getPadBtn(const int which) { return keys[which]; } }