2020-05-04 09:27:29 +03:00
|
|
|
/*
|
2024-01-02 00:15:26 +03:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2020-05-04 09:27:29 +03:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely.
|
|
|
|
*/
|
2022-11-27 07:43:38 +03:00
|
|
|
#include <SDL3/SDL.h>
|
2022-12-15 07:58:20 +03:00
|
|
|
#include <SDL3/SDL_main.h>
|
2023-03-17 02:25:39 +03:00
|
|
|
#include <SDL3/SDL_test.h>
|
2020-05-04 09:27:29 +03:00
|
|
|
|
|
|
|
static void log_locales(void)
|
|
|
|
{
|
2024-07-27 04:57:18 +03:00
|
|
|
SDL_Locale **locales = SDL_GetPreferredLocales(NULL);
|
2023-11-10 00:29:15 +03:00
|
|
|
if (!locales) {
|
2020-05-04 09:27:29 +03:00
|
|
|
SDL_Log("Couldn't determine locales: %s", SDL_GetError());
|
|
|
|
} else {
|
2024-07-19 08:07:05 +03:00
|
|
|
int i;
|
2020-05-04 09:27:29 +03:00
|
|
|
unsigned int total = 0;
|
|
|
|
SDL_Log("Locales, in order of preference:");
|
2024-07-19 08:07:05 +03:00
|
|
|
for (i = 0; locales[i]; ++i) {
|
|
|
|
const SDL_Locale *l = locales[i];
|
2020-05-04 09:27:29 +03:00
|
|
|
const char *c = l->country;
|
|
|
|
SDL_Log(" - %s%s%s", l->language, c ? "_" : "", c ? c : "");
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
SDL_Log("%u locales seen.", total);
|
2024-07-27 04:57:18 +03:00
|
|
|
SDL_free(locales);
|
2020-05-04 09:27:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2023-03-17 02:25:39 +03:00
|
|
|
int i;
|
|
|
|
int listen = 0;
|
|
|
|
SDLTest_CommonState *state;
|
|
|
|
|
|
|
|
/* Initialize test framework */
|
2023-07-18 23:21:19 +03:00
|
|
|
state = SDLTest_CommonCreateState(argv, 0);
|
2023-11-10 00:29:15 +03:00
|
|
|
if (!state) {
|
2023-03-17 02:25:39 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse commandline */
|
|
|
|
for (i = 1; i < argc;) {
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
consumed = SDLTest_CommonArg(state, i);
|
|
|
|
if (!consumed) {
|
|
|
|
if (SDL_strcmp(argv[1], "--listen") == 0) {
|
|
|
|
listen = 1;
|
|
|
|
consumed = 1;
|
2023-07-19 01:14:38 +03:00
|
|
|
state->flags |= SDL_INIT_VIDEO;
|
2023-03-17 02:25:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consumed <= 0) {
|
|
|
|
static const char *options[] = { "[--listen]", NULL };
|
|
|
|
SDLTest_CommonLogUsage(state, argv[0], options);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
i += consumed;
|
|
|
|
}
|
|
|
|
|
2020-05-04 09:27:29 +03:00
|
|
|
/* Print locales and languages */
|
2024-09-18 17:52:28 +03:00
|
|
|
if (SDLTest_CommonInit(state) == false) {
|
2023-03-17 02:25:39 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_locales();
|
|
|
|
|
|
|
|
if (listen) {
|
|
|
|
int done = 0;
|
|
|
|
while (!done) {
|
|
|
|
SDL_Event e;
|
|
|
|
SDLTest_CommonEvent(state, &e, &done);
|
|
|
|
while (SDL_PollEvent(&e)) {
|
|
|
|
if (e.type == SDL_EVENT_QUIT) {
|
|
|
|
done = 1;
|
|
|
|
} else if (e.type == SDL_EVENT_LOCALE_CHANGED) {
|
|
|
|
SDL_Log("Saw SDL_EVENT_LOCALE_CHANGED event!");
|
|
|
|
log_locales();
|
2020-05-04 09:27:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-17 02:25:39 +03:00
|
|
|
for (i = 0; i < state->num_windows; i++) {
|
|
|
|
SDL_RenderPresent(state->renderers[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Delay(10);
|
|
|
|
}
|
2020-05-04 09:27:29 +03:00
|
|
|
}
|
|
|
|
|
2023-03-17 02:25:39 +03:00
|
|
|
SDLTest_CommonQuit(state);
|
|
|
|
|
2022-11-30 23:51:59 +03:00
|
|
|
return 0;
|
2020-05-04 09:27:29 +03:00
|
|
|
}
|