# HG changeset patch # User Emmanuel Gil Peyrot # Date 1387410258 -3600 # Node ID a7dc55ad9380cc53f37047aa2c51268f210658c9 # Parent 64d9117b920940750e5dada2e478e64d0824db87 Display important messages in popups, instead of the terminal. diff --git a/eosd b/eosd --- a/eosd +++ b/eosd @@ -64,7 +64,7 @@ elif args.backend == 'sdl': from pytouhou.ui.sdl.gamerenderer import GameRenderer opengl = False -from pytouhou.lib.sdl import SDL +from pytouhou.lib.sdl import SDL, show_simple_message_box from pytouhou.ui.window import Window from pytouhou.resource.loader import Loader from pytouhou.ui.gamerunner import GameRunner @@ -117,8 +117,8 @@ def main(window, path, data, stage_num, try: resource_loader.scan_archives(data) except IOError: - sys.stderr.write('Some data files were not found, did you forget the -p option?\n') - exit(1) + show_simple_message_box(u'Some data files were not found, did you forget the -p option?') + sys.exit(1) if stage_num is None: story = True @@ -236,7 +236,7 @@ def main(window, path, data, stage_num, break stage_num += 1 except GameOver: - print('Game over') + show_simple_message_box(u'Game over!') break finally: if save_filename: diff --git a/pytouhou/lib/_sdl.pxd b/pytouhou/lib/_sdl.pxd --- a/pytouhou/lib/_sdl.pxd +++ b/pytouhou/lib/_sdl.pxd @@ -193,6 +193,10 @@ cdef extern from "SDL_ttf.h" nogil: SDL_Surface *TTF_RenderUTF8_Blended(TTF_Font *font, const char *text, SDL_Color fg) +cdef extern from "SDL_messagebox.h" nogil: + int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window) + + cdef extern from "SDL_blendmode.h" nogil: ctypedef enum SDL_BlendMode: SDL_BLENDMODE_NONE diff --git a/pytouhou/lib/sdl.pxd b/pytouhou/lib/sdl.pxd --- a/pytouhou/lib/sdl.pxd +++ b/pytouhou/lib/sdl.pxd @@ -122,3 +122,4 @@ cdef Music load_music(const char *filena cdef Chunk load_chunk(file_) cdef Uint32 get_ticks() nogil cdef void delay(Uint32 ms) nogil +cpdef int show_simple_message_box(unicode message) diff --git a/pytouhou/lib/sdl.pyx b/pytouhou/lib/sdl.pyx --- a/pytouhou/lib/sdl.pyx +++ b/pytouhou/lib/sdl.pyx @@ -351,3 +351,8 @@ cdef Uint32 get_ticks() nogil: cdef void delay(Uint32 ms) nogil: SDL_Delay(ms) + + +cpdef int show_simple_message_box(unicode message): + text = message.encode('UTF-8') + return SDL_ShowSimpleMessageBox(1, 'PyTouhou', text, NULL)