From 717f10b21efba0b9b3dcd844df219c652a18797a Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 2 May 2005 21:35:13 +0000 Subject: [PATCH] fix file lookup SVN-Revision: 2388 --- src/control/controller.cpp | 5 +---- src/control/joystickkeyboardcontroller.cpp | 2 +- src/gui/menu.cpp | 2 ++ src/resources.cpp | 2 +- src/title.cpp | 32 +++++++++++++++++++++--------- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/control/controller.cpp b/src/control/controller.cpp index b8eb8d5f4..f6f5ecb18 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -38,10 +38,7 @@ const char* Controller::controlNames[] = { Controller::Controller() { - for(int i = 0; i < CONTROLCOUNT; ++i) { - controls[i] = false; - oldControls[i] = false; - } + reset(); } Controller::~Controller() diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 06ffd062e..d314dae77 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -55,7 +55,7 @@ public: JoystickKeyboardController::JoystickKeyboardController() : wait_for_key(-1), wait_for_joybutton(-1) { - memset(last_keys, 0, sizeof(last_keys)); + memset(last_keys, 0, sizeof(last_keys)); // initialize default keyboard map keymap.insert(std::make_pair(SDLK_LEFT, LEFT)); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 03a6a3c0a..361173c06 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -139,6 +139,8 @@ Menu::pop_current() current_->effect.start(500); last_menus.pop_back(); + } else { + current_ = 0; } } diff --git a/src/resources.cpp b/src/resources.cpp index 4119b7ae8..95bf48dfb 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -199,7 +199,7 @@ void unload_shared() std::string get_resource_filename(const std::string& resource) { - std::string filepath = user_dir + resource; + std::string filepath = user_dir + "/" + resource; if(FileSystem::faccessible(filepath)) return filepath; diff --git a/src/title.cpp b/src/title.cpp index 6badcd5a3..7b3b89d41 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -136,7 +136,7 @@ void generate_contrib_menu() delete subset; continue; } - contrib_menu->add_submenu(subset->title, contrib_subset_menu); + contrib_menu->add_submenu(subset->title, contrib_subset_menu, i); contrib_subsets.push_back(subset); ++i; } @@ -244,6 +244,7 @@ void check_contrib_subset_menu() void draw_demo(float elapsed_time) { static float last_tux_x_pos = -1; + static float last_tux_y_pos = -1; Sector* sector = titlesession->get_current_sector(); Player* tux = sector->player; @@ -252,14 +253,21 @@ void draw_demo(float elapsed_time) controller->update(); controller->press(Controller::RIGHT); - if(random_timer.check() || (int) last_tux_x_pos == (int) tux->get_pos().x) { - random_timer.start(float(rand() % 3000 + 3000) / 1000.); - walking = !walking; + if(random_timer.check() || + (walking && (int) last_tux_x_pos == (int) tux->get_pos().x)) { + walking = false; + printf("Walking: %d.\n", walking); } else { - if(!walking) - controller->press(Controller::JUMP); + if(!walking && (int) tux->get_pos().y == (int) last_tux_y_pos) { + random_timer.start(float(rand() % 3000 + 3000) / 1000.); + walking = true; + printf("Walking: %d.\n", walking); + } } + if(!walking) + controller->press(Controller::JUMP); last_tux_x_pos = tux->get_pos().x; + last_tux_y_pos = tux->get_pos().y; // Wrap around at the end of the level back to the beginnig if(sector->solids->get_width() * 32 - 320 < tux->get_pos().x) { @@ -304,7 +312,8 @@ void title() Menu::set_current(main_menu); DrawingContext& context = *titlesession->context; - while (Menu::current()) + bool running = true; + while (running) { // Calculate the movement-factor Uint32 ticks = SDL_GetTicks(); @@ -326,7 +335,6 @@ void title() Menu::current()->event(event); } main_controller->process_event(event); - // FIXME: QUIT signal should be handled more generic, not locally if (event.type == SDL_QUIT) throw std::runtime_error("Received window close"); } @@ -389,7 +397,7 @@ void title() Menu::set_current(main_menu); break; case MNID_QUITMAINMENU: - Menu::set_current(0); + running = false; break; } } @@ -432,6 +440,12 @@ void title() } } + // reopen menu of user closed it (so that the app doesn't close when user + // accidently hit ESC) + if(Menu::current() == 0) { + Menu::set_current(main_menu); + } + mouse_cursor->draw(context); context.do_drawing(); -- 2.11.0