Exemple #1
0
// Search for level script and then run it
void FindMovieInScript(int LevelIndex)
{
  // Find the pointer to the current script
  CurrScriptPtr = NULL;
  for (vector<LevelScriptHeader>::iterator ScriptIter = LevelScripts.begin();
       ScriptIter < LevelScripts.end(); ScriptIter++)
  {
    if (ScriptIter->Level == LevelIndex) {
      CurrScriptPtr = &(*ScriptIter);                   // Iterator to pointer
      break;
    }
  }
  if (!CurrScriptPtr) {
    return;
  }

  for (unsigned k=0; k<CurrScriptPtr->Commands.size(); k++)
  {
    LevelScriptCommand& Cmd = CurrScriptPtr->Commands[k];

    switch(Cmd.Type)
    {
    case LevelScriptCommand::Movie:
    {
      MovieFileExists = MovieFile.SetNameWithPath(&Cmd.FileSpec[0]);

      // Set the size only if there was a movie file here
      if (MovieFileExists) {
        MovieSize = Cmd.Size;
      }
    }
    break;
    }
  }
}
Exemple #2
0
bool XML_ShaderParser::HandleAttribute(const char *Tag, const char *Value) {
  if(StringsEqual(Tag,"name")) {
    _name = Value;
    return true;
  }
  else if(StringsEqual(Tag,"vert")) {
    _vert.SetNameWithPath(Value);
    return true;
  }
  else if(StringsEqual(Tag,"frag")) {
    _frag.SetNameWithPath(Value);
    return true;
  }
  else if(StringsEqual(Tag,"passes")) {
    return ReadInt16Value(Value,_passes);
  }
  UnrecognizedTag();
  return true;
};
bool OGL_LoadScreen::Start()
{
	// load the image
	FileSpecifier File;
	if (path.size() == 0) return use = false;
	if (!File.SetNameWithPath(path.c_str())) return use = false;
	if (!image.LoadFromFile(File, ImageLoader_Colors, 0)) return use = false;

	if (!blitter.Load(image)) return use = false;

	int screenWidth, screenHeight;
	MainScreenSize(screenWidth, screenHeight);
	bound_screen();
	
	// the true width/height
	int imageWidth = static_cast<int>(image.GetWidth() * image.GetVScale());
	int imageHeight = static_cast<int>(image.GetHeight() * image.GetUScale());

	if (scale)
	{
		if (stretch)
		{
			m_dst.w = screenWidth;
			m_dst.h = screenHeight;
		}
		else if (imageWidth / imageHeight > screenWidth / screenHeight) 
		{
			m_dst.w = screenWidth;
			m_dst.h = imageHeight * screenWidth / imageWidth;
		} 
		else 
		{
			m_dst.w = imageWidth * screenHeight / imageHeight;
			m_dst.h = screenHeight;
		}
	}
	else
	{
		m_dst.w = imageWidth;
		m_dst.h = imageHeight;
	}
	m_dst.x = (screenWidth - m_dst.w) / 2;
	m_dst.y = (screenHeight - m_dst.h) / 2;
	
	x_offset = m_dst.x;
	y_offset = m_dst.y;
	x_scale = m_dst.w / (double) imageWidth;
	y_scale = m_dst.h / (double) imageHeight;
						  
	OGL_ClearScreen();
	
	Progress(0);

	return use = true;
}
Exemple #4
0
static void load_mmls(const Plugin& plugin, XML_Loader_SDL& loader)
{
  ScopedSearchPath ssp(plugin.directory);
  for (std::vector<std::string>::const_iterator it = plugin.mmls.begin();
       it != plugin.mmls.end(); ++it)
  {
    FileSpecifier file;
    file.SetNameWithPath(it->c_str());
    loader.ParseFile(file);
  }
}
Exemple #5
0
static const char *locate_font(const std::string& path)
{
	builtin_fonts_t::iterator j = builtin_fonts.find(path);
	if (j != builtin_fonts.end() || path == "")
	{
		return path.c_str();
	}
	else
	{
		static FileSpecifier file;
		if (file.SetNameWithPath(path.c_str()))
			return file.GetPath();
		else
			return "";
	}
}
bool SoundManager::LoadSound(short sound_index)
{
	if (active)
	{
		SoundDefinition *definition = GetSoundDefinition(sound_index);
		if (!definition) return false;

		// Load all the external-file sounds for each index; fill the slots appropriately.
		int NumSlots= (parameters.flags & _more_sounds_flag) ? definition->permutations : 1;
		for (int k = 0; k < NumSlots; k++)
		{
			SoundOptions *SndOpts = SoundReplacements::instance()->GetSoundOptions(sound_index, k);
			if (!SndOpts) continue;
			FileSpecifier File;
			if (!File.SetNameWithPath(SndOpts->File.c_str())) continue;
			if (!SndOpts->Sound.LoadExternal(File)) continue;
		}

		if (definition->sound_code != NONE &&
		    (parameters.flags & _ambient_sound_flag) || !(definition->flags & _sound_is_ambient))
		{
			if (!definition->LoadedSize())
			{
				definition->Load(*(sound_file.opened_sound_file), parameters.flags & _more_sounds_flag);
				loaded_sounds_size += definition->LoadedSize();
				definition->last_played = machine_tick_count();
				while (loaded_sounds_size > total_buffer_size)
					ReleaseLeastUsefulSound();
			}
			if (definition->LoadedSize())
			{
				definition->permutations_played = 0;
			}
		}
		
		return definition->LoadedSize() ? true : false;
	}	

	return false;
}
Exemple #7
0
// Search for level script and then run it
void GeneralRunScript(int LevelIndex)
{
  // Find the pointer to the current script
  CurrScriptPtr = NULL;
  for (vector<LevelScriptHeader>::iterator ScriptIter = LevelScripts.begin();
       ScriptIter < LevelScripts.end(); ScriptIter++)
  {
    if (ScriptIter->Level == LevelIndex) {
      CurrScriptPtr = &(*ScriptIter);                   // Iterator to pointer
      break;
    }
  }
  if (!CurrScriptPtr) {
    return;
  }

  // Insures that this order is the last order set
  Music::instance()->LevelMusicRandom(CurrScriptPtr->RandomOrder);

  // OpenedResourceFile OFile;
  // FileSpecifier& MapFile = get_map_file();
  // if (!MapFile.Open(OFile)) return;

  for (unsigned k=0; k<CurrScriptPtr->Commands.size(); k++)
  {
    LevelScriptCommand& Cmd = CurrScriptPtr->Commands[k];

    // Data to parse
    char *Data = NULL;
    size_t DataLen = 0;

    // First, try to load a resource (only for scripts)
    LoadedResource ScriptRsrc;
    switch(Cmd.Type)
    {
    case LevelScriptCommand::MML:
#ifdef HAVE_LUA
    case LevelScriptCommand::Lua:
#endif /* HAVE_LUA */
      // if (Cmd.RsrcPresent() && OFile.Get('T','E','X','T',Cmd.RsrcID,ScriptRsrc))
      if (Cmd.RsrcPresent() &&
          get_text_resource_from_scenario(Cmd.RsrcID,ScriptRsrc)) {
        Data = (char *)ScriptRsrc.GetPointer();
        DataLen = ScriptRsrc.GetLength();
      }
    }

    switch(Cmd.Type)
    {
    case LevelScriptCommand::MML:
    {
      // Skip if not loaded
      if (Data == NULL || DataLen <= 0) {
        break;
      }

      // Set to the MML root parser
      char ObjName[256];
      sprintf(ObjName,"[Map Rsrc %hd for Level %d]",Cmd.RsrcID,LevelIndex);
      LSXML_Loader.SourceName = ObjName;
      LSXML_Loader.CurrentElement = &RootParser;
      LSXML_Loader.ParseData(Data,DataLen);
    }
    break;

#ifdef HAVE_LUA

    case LevelScriptCommand::Lua:
    {
      // Skip if not loaded
      if (Data == NULL || DataLen <= 0) {
        break;
      }

      // Load and indicate whether loading was successful
      if (LoadLuaScript(Data, DataLen, _embedded_lua_script)) {
        LuaFound = true;
      }
    }
    break;
#endif /* HAVE_LUA */

    case LevelScriptCommand::Music:
    {
      FileSpecifier MusicFile;
      if (MusicFile.SetNameWithPath(&Cmd.FileSpec[0])) {
        Music::instance()->PushBackLevelMusic(MusicFile);
      }
    }
    break;
#ifdef HAVE_OPENGL
    case LevelScriptCommand::LoadScreen:
    {
      if (Cmd.FileSpec.size() > 0) {
        if (Cmd.L || Cmd.T || Cmd.R || Cmd.B) {
          OGL_LoadScreen::instance()->Set(Cmd.FileSpec, Cmd.Stretch, Cmd.Scale,
                                          Cmd.L, Cmd.T, Cmd.R - Cmd.L,
                                          Cmd.B - Cmd.T);
          OGL_LoadScreen::instance()->Colors()[0] = Cmd.Colors[0];
          OGL_LoadScreen::instance()->Colors()[1] = Cmd.Colors[1];
        }
        else{
          OGL_LoadScreen::instance()->Set(Cmd.FileSpec, Cmd.Stretch, Cmd.Scale);
        }
      }
    }
#endif
      // The movie info is handled separately
    }
  }
}