--- hatari/src/gui-sdl/sdlgui.c 2019/04/01 07:13:52 1.1.1.5 +++ hatari/src/gui-sdl/sdlgui.c 2019/04/09 08:47:28 1.1.1.8 @@ -6,7 +6,7 @@ A tiny graphical user interface for Hatari. */ -const char SDLGui_rcsid[] = "Hatari $Id: sdlgui.c,v 1.1.1.5 2019/04/01 07:13:52 root Exp $"; +const char SDLGui_fileid[] = "Hatari sdlgui.c : " __DATE__ " " __TIME__; #include #include @@ -79,6 +79,12 @@ int SDLGui_Init(void) { SDL_Color blackWhiteColors[2] = {{255, 255, 255, 0}, {0, 0, 0, 0}}; + if (pSmallFontGfx && pBigFontGfx) + { + /* already initialized */ + return 0; + } + /* Initialize the font graphics: */ pSmallFontGfx = SDLGui_LoadXBM(font5x8_width, font5x8_height, font5x8_bits); pBigFontGfx = SDLGui_LoadXBM(font10x16_width, font10x16_height, font10x16_bits); @@ -154,6 +160,15 @@ int SDLGui_SetScreen(SDL_Surface *pScrn) return 0; } +/*-----------------------------------------------------------------------*/ +/* + Return character size for current font in given arguments. +*/ +void SDLGui_GetFontSize(int *width, int *height) +{ + *width = fontwidth; + *height = fontheight; +} /*-----------------------------------------------------------------------*/ /* @@ -172,7 +187,7 @@ void SDLGui_CenterDlg(SGOBJ *dlg) /* Draw a text string. */ -static void SDLGui_Text(int x, int y, const char *txt) +void SDLGui_Text(int x, int y, const char *txt) { int i; char c; @@ -403,7 +418,7 @@ static void SDLGui_EditField(SGOBJ *dlg, { size_t cursorPos; /* Position of the cursor in the edit field */ int blinkState = 0; /* Used for cursor blinking */ - int bStopEditing = FALSE; /* TRUE if user wants to exit the edit field */ + int bStopEditing = false; /* true if user wants to exit the edit field */ char *txt; /* Shortcut for dlg[objnum].txt */ SDL_Rect rect; Uint32 grey, cursorCol; @@ -411,7 +426,7 @@ static void SDLGui_EditField(SGOBJ *dlg, int nOldUnicodeMode; /* Enable unicode translation to get proper characters with SDL_PollEvent */ - nOldUnicodeMode = SDL_EnableUNICODE(TRUE); + nOldUnicodeMode = SDL_EnableUNICODE(true); grey = SDL_MapRGB(pSdlGuiScrn->format, 192, 192, 192); cursorCol = SDL_MapRGB(pSdlGuiScrn->format, 128, 128, 128); @@ -441,18 +456,18 @@ static void SDLGui_EditField(SGOBJ *dlg, switch (event.type) { case SDL_QUIT: /* User wants to quit */ - bQuitProgram = TRUE; - bStopEditing = TRUE; + bQuitProgram = true; + bStopEditing = true; break; case SDL_MOUSEBUTTONDOWN: /* Mouse pressed -> stop editing */ - bStopEditing = TRUE; + bStopEditing = true; break; case SDL_KEYDOWN: /* Key pressed */ switch (event.key.keysym.sym) { case SDLK_RETURN: case SDLK_KP_ENTER: - bStopEditing = TRUE; + bStopEditing = true; break; case SDLK_LEFT: if (cursorPos > 0) @@ -796,6 +811,9 @@ int SDLGui_DoDialog(SGOBJ *dlg, SDL_Even } break; + case SDL_JOYAXISMOTION: + case SDL_JOYBALLMOTION: + case SDL_JOYHATMOTION: case SDL_MOUSEMOTION: break; @@ -834,7 +852,7 @@ int SDLGui_DoDialog(SGOBJ *dlg, SDL_Even memcpy(pEventOut, &sdlEvent, sizeof(SDL_Event)); if (retbutton == SDLGUI_QUIT) - bQuitProgram = TRUE; + bQuitProgram = true; return retbutton; }