Minor fix to love.localechanged callback.

Wrong callback placement.
This commit is contained in:
Miku AuahDark
2022-03-18 10:30:31 +08:00
parent 5603c8915b
commit 730cb08acf
2 changed files with 31 additions and 27 deletions
+7 -3
View File
@@ -35,6 +35,8 @@
#include <cmath> #include <cmath>
#include <SDL_version.h>
namespace love namespace love
{ {
namespace event namespace event
@@ -433,6 +435,11 @@ Message *Event::convert(const SDL_Event &e)
case SDL_APP_LOWMEMORY: case SDL_APP_LOWMEMORY:
msg = new Message("lowmemory"); msg = new Message("lowmemory");
break; break;
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_LOCALECHANGED:
msg = new Message("localechanged");
break;
#endif
default: default:
break; break;
} }
@@ -551,9 +558,6 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
msg = new Message("joystickremoved", vargs); msg = new Message("joystickremoved", vargs);
} }
break; break;
case SDL_LOCALECHANGED:
msg = new Message("localechanged");
break;
default: default:
break; break;
} }
+24 -24
View File
@@ -90,30 +90,30 @@ love::system::System::PowerState System::getPowerInfo(int &seconds, int &percent
powerStates.find(sdlstate, state); powerStates.find(sdlstate, state);
return state; return state;
} }
std::vector<std::string> System::getPreferredLocales() const std::vector<std::string> System::getPreferredLocales() const
{ {
std::vector<std::string> result; std::vector<std::string> result;
#if SDL_VERSION_ATLEAST(2, 0, 14) #if SDL_VERSION_ATLEAST(2, 0, 14)
SDL_Locale *locales = SDL_GetPreferredLocales(); SDL_Locale *locales = SDL_GetPreferredLocales();
if (locales) if (locales)
{ {
for (SDL_Locale* locale = locales; locale->language != nullptr; locale++) for (SDL_Locale* locale = locales; locale->language != nullptr; locale++)
{ {
if (locale->country) if (locale->country)
result.push_back(std::string(locale->language) + "_" + std::string(locale->country)); result.push_back(std::string(locale->language) + "_" + std::string(locale->country));
else else
result.push_back(locale->language); result.push_back(locale->language);
} }
SDL_free(locales); SDL_free(locales);
} }
#endif #endif
return result; return result;
} }
EnumMap<System::PowerState, SDL_PowerState, System::POWER_MAX_ENUM>::Entry System::powerEntries[] = EnumMap<System::PowerState, SDL_PowerState, System::POWER_MAX_ENUM>::Entry System::powerEntries[] =