Ejemplo n.º 1
0
void check_contrib_menu()
{
  int index = contrib_menu->check();
  if (index == -1)
    return;

  if (index < (int)contrib_subsets.size())
    {
      // FIXME: This shouln't be busy looping
      LevelSubset& subset = * (contrib_subsets[index]);

      current_contrib_subset = subset.name;
 
      contrib_subset_menu->clear();
 
      contrib_subset_menu->additem(MN_LABEL, subset.title, 0,0);
      contrib_subset_menu->additem(MN_HL,"",0,0);

      for (int i = 0; i < subset.levels; ++i)
        {
        /** get level's title */
        Level level;
        level.load(subset.name, i+1);
        contrib_subset_menu->additem(MN_ACTION, level.name, 0,0,i+1);
        }

      contrib_subset_menu->additem(MN_HL,"",0,0);      
      contrib_subset_menu->additem(MN_BACK, "Back", 0, 0);
      }
    else if(index < worldmap_list.num_items + (int)contrib_subsets.size())
      {
      // Loading fade
      fadeout();

      emscripten_pause_main_loop();

      delete worldmap;
      worldmap = new WorldMapNS::WorldMap();
      worldmap->loadmap(worldmap_list.item[index - contrib_subsets.size()]);
//      worldmap.set_levels_as_solved();
      static std::string savegame = worldmap_list.item[index - contrib_subsets.size()];
      // remove .stwm...
      savegame = savegame.substr(0, savegame.size()-5);
      savegame = std::string(st_save_dir) + "/" + savegame + ".stsg";
      std::cout << "SaveGameName: " << savegame << "\n";
      worldmap->loadgame(savegame.c_str());

      worldmap->display();

      emscripten_set_main_loop(worldmap_loop, 100);

      emscripten_resume_main_loop();

      //Menu::set_current(main_menu);
      }
}
Ejemplo n.º 2
0
bool process_load_game_menu()
{
  int slot = load_game_menu->check();

  if(slot != -1 && load_game_menu->get_item_by_id(slot).kind == MN_ACTION)
    {
      char slotfile[1024];
      snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot);

      emscripten_pause_main_loop();

      if (access(slotfile, F_OK) != 0)
        {
          //draw_intro();
        }

      fadeout();

      if (!worldmap)
	{
	  worldmap = new WorldMapNS::WorldMap();
	  //TODO: Define the circumstances under which BonusIsland is chosen
	  //printf("pxx: %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__);
	  worldmap->set_map_file("world1.stwm");
	  //printf("pxx: %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__);
	  worldmap->load_map();
	  //printf("pxx: %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__);
	}
      
      // Load the game or at least set the savegame_file variable
      worldmap->loadgame(slotfile);
      //printf("pxx: %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__);

      worldmap->display();

      //printf("pxx: %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__);
      emscripten_set_main_loop(worldmap_loop, 100);
      //printf("pxx: %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__);
      
      emscripten_resume_main_loop();
      //Menu::set_current(main_menu);

      //st_pause_ticks_stop();
      return true;
    }
  else
    {
      return false;
    }
}
Ejemplo n.º 3
0
void five(void *arg) {
  assert((int)arg == 55);
  fived = true;
  emscripten_resume_main_loop();
}