mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 04:05:09 +02:00
update SDL3 to latest commit
This commit is contained in:
+21
-10
@@ -22,8 +22,8 @@
|
||||
|
||||
static int cal_year;
|
||||
static int cal_month;
|
||||
static SDL_TIME_FORMAT time_format;
|
||||
static SDL_DATE_FORMAT date_format;
|
||||
static SDL_TimeFormat time_format;
|
||||
static SDL_DateFormat date_format;
|
||||
|
||||
static void RenderDateTime(SDL_Renderer *r)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ static void RenderDateTime(SDL_Renderer *r)
|
||||
|
||||
/* Query the current time and print it. */
|
||||
SDL_GetCurrentTime(&ticks);
|
||||
SDL_TimeToDateTime(ticks, &dt, SDL_FALSE);
|
||||
SDL_TimeToDateTime(ticks, &dt, false);
|
||||
|
||||
switch (date_format) {
|
||||
case SDL_DATE_FORMAT_YYYYMMDD:
|
||||
@@ -78,7 +78,19 @@ static void RenderDateTime(SDL_Renderer *r)
|
||||
|
||||
SDLTest_DrawString(r, 10, 15, str);
|
||||
|
||||
SDL_TimeToDateTime(ticks, &dt, SDL_TRUE);
|
||||
SDL_TimeToDateTime(ticks, &dt, true);
|
||||
if (time_format) {
|
||||
if (dt.hour > 12) { /* PM */
|
||||
dt.hour -= 12;
|
||||
postfix = TIMEPOST[2];
|
||||
} else {
|
||||
if (!dt.hour) { /* AM */
|
||||
dt.hour = 12; /* Midnight */
|
||||
}
|
||||
postfix = TIMEPOST[1];
|
||||
}
|
||||
}
|
||||
|
||||
SDL_snprintf(str, sizeof(str), "Local: %s %02d %s %04d (%s) %02d:%02d:%02d.%09d%s %+05d",
|
||||
WDAY[dt.day_of_week], dt.day, MNAME[dt.month - 1], dt.year, short_date,
|
||||
dt.hour, dt.minute, dt.second, dt.nanosecond, postfix,
|
||||
@@ -142,9 +154,6 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
@@ -154,8 +163,7 @@ int main(int argc, char *argv[])
|
||||
goto quit;
|
||||
}
|
||||
|
||||
time_format = SDL_GetNumberProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_SYSTEM_TIME_FORMAT_NUMBER, SDL_TIME_FORMAT_24HR);
|
||||
date_format = SDL_GetNumberProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_SYSTEM_DATE_FORMAT_NUMBER, SDL_DATE_FORMAT_YYYYMMDD);
|
||||
SDL_GetDateTimeLocalePreferences(&date_format, &time_format);
|
||||
|
||||
/* Main render loop */
|
||||
done = 0;
|
||||
@@ -165,7 +173,7 @@ int main(int argc, char *argv[])
|
||||
while (SDL_PollEvent(&event)) {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
switch (event.key.keysym.sym) {
|
||||
switch (event.key.key) {
|
||||
case SDLK_UP:
|
||||
if (++cal_month > 12) {
|
||||
cal_month = 1;
|
||||
@@ -196,6 +204,8 @@ int main(int argc, char *argv[])
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_LOCALE_CHANGED) {
|
||||
SDL_GetDateTimeLocalePreferences(&date_format, &time_format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +218,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
quit:
|
||||
SDLTest_CleanupTextDrawing();
|
||||
SDLTest_CommonQuit(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user