From 98b2313a26f8a5ce6733e014fb8c8d8fd4f290f5 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Mon, 23 Nov 2009 19:47:01 +0000 Subject: [PATCH] Correct ev loop --- main.cpp | 17 ++++++++++++----- menu.cpp | 1 - 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 6952eaf..cc0d14c 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,6 @@ +#include +#include + #include "menu.hh" #include "utils.hh" @@ -29,9 +32,9 @@ static void run(void) SDL_Event ev; while (SDL_PollEvent(&ev)) { if (ev.type == SDL_QUIT) - exit(1); break; + exit(1); - g_menu->pushEvent(&ev); break; + g_menu->pushEvent(&ev); } g_menu->draw(screen, 0, 80, 400, 400); @@ -66,17 +69,21 @@ static void init(void) screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF); panic_if(!screen, "Cannot initialize video: %s\n", SDL_GetError()); - bg_left = IMG_Load("bg_left.png"); - bg_right = IMG_Load("bg_right.png"); - bg_middle = IMG_Load("bg_middle.png"); TTF_Init(); fnt = read_and_alloc_font("font.ttf"); + bg_left = IMG_Load("bg_left.png"); + bg_right = IMG_Load("bg_right.png"); + bg_middle = IMG_Load("bg_middle.png"); + panic_if( !bg_left || !bg_right || !bg_middle, + "bg loading failed\n"); + g_menu = new PrintMenu(fnt); g_menu->setText(main_menu_messages); + g_menu->setSelectedBackground(bg_left, bg_middle, bg_right); } int main(int argc, char *argv[]) diff --git a/menu.cpp b/menu.cpp index 7796f49..52d6a27 100644 --- a/menu.cpp +++ b/menu.cpp @@ -14,7 +14,6 @@ #include "menu.hh" #include "utils.hh" -#include "menutexts.h" #define IS_SUBMENU(p_msg) ( (p_msg)[0] == '^' )