Exemplo n.º 1
0
std::set<GameSettingsPresetInfo> presetsForMod(const std::string& modDir) {
	std::set<GameSettingsPresetInfo> presets;
	for(Iterator<std::string>::Ref it = FileListIter(".", false, FM_REG, "*.gamesettings"); it->isValid(); it->next())
		presets.insert(settingsInfo("./" + GetBaseFilename(it->get()), true));
	
	for(Iterator<std::string>::Ref it = FileListIter(modDir, false, FM_REG, "*.gamesettings"); it->isValid(); it->next())
		presets.insert(settingsInfo(modDir + "/" + GetBaseFilename(it->get()), false));
	
	return presets;
}
Exemplo n.º 2
0
LevelInfo infoForLevel(const std::string& f, bool absolute) {
	MapLoad* loader = MapLoad::open(absolute ? f : ("levels/" + f), absolute, false);
	if(!loader) return LevelInfo();

	LevelInfo info;
	info.valid = true;
	info.name = loader->header().name;
	info.path = GetBaseFilename(f);
	info.type = loader->format();
	info.typeShort = loader->formatShort();
	
	delete loader;
	
	return info;
}
Exemplo n.º 3
0
Script* ScriptingEngine::LoadScript(const char* path)
{
	auto script = new Script();
	script->Initialize(_impl->engineContext);

	auto file = _impl->lua.load_file(path);

	file();

	std::string baseName = GetBaseFilename(path, ".lua");

	auto something = _impl->lua[baseName]["Update"]();

	return script;
}
Exemplo n.º 4
0
void LoadSounds_Game() {
	sfxGame.smpNinja = LoadSample("data/sounds/throw.wav",4);
	sfxGame.smpPickup = LoadSample("data/sounds/pickup.wav",2);
	sfxGame.smpBump = LoadSample("data/sounds/bump.wav", 2);
	sfxGame.smpDeath[0] = LoadSample("data/sounds/death1.wav", 2);
	sfxGame.smpDeath[1] = LoadSample("data/sounds/death2.wav", 2);
	sfxGame.smpDeath[2] = LoadSample("data/sounds/death3.wav", 2);	
	
	sfxGame.smpTeamScore = LoadSample("data/sounds/teamscore.wav",2);
	if( sfxGame.smpTeamScore.get() == NULL ) {
		notes << "LoadSounds: cannot load teamscore.wav" << endl;
		sfxGame.smpTeamScore = sfxGeneral.smpNotify;
	}
	
	// preload game sounds
	for(Iterator<std::string>::Ref f = FileListIter("data/sounds/game"); f->isValid(); f->next())
		loadGameSound(GetBaseFilename(f->get()));
}
Exemplo n.º 5
0
bool Process::open( const std::string & cmd, std::vector< std::string > params, const std::string& working_dir ) {
	if(params.size() == 0)
		params.push_back(cmd);
	
	std::string realcmd = cmd;
#ifdef WIN32
	std::string interpreter = GetScriptInterpreterCommandForFile(cmd);
	if(interpreter != "") {
		size_t f = interpreter.find(" ");
		if(f != std::string::npos) interpreter.erase(f);
		interpreter = GetBaseFilename(interpreter);
		SysCommand newcmd = GetExecForScriptInterpreter(interpreter);
		realcmd = newcmd.exec;
		params.swap( newcmd.params );
		params.reserve( params.size() + newcmd.params.size() );
		for(std::vector<std::string>::iterator i = newcmd.params.begin(); i != newcmd.params.end(); ++i)
			params.push_back(*i);

		notes << "running \"" << realcmd << "\" for script \"" << cmd << "\"" << endl;
	}
#endif
	
	return data->open( realcmd, params, working_dir );
}
Exemplo n.º 6
0
bool GameSettingsPresetInfo::fromString( const std::string & str) {
	bool global = GetBaseFilename(str) == str || strStartsWith(str, "./");
	*this = settingsInfo(str, global);
	return true;
}
Exemplo n.º 7
0
boolean AddInputFile2Header(FileHeader_t *header,char *filekey, 
                            char *input_filename,char *input_file_ttag,
                            char *version, char *linktime)
/*----------------------------------------------------------------------------->
/ purpose: Change Contents in header struct for RecPointer with Modstring
/
/ coded by: Gerhard L.H. Kruizinga                           08/28/2001
/
/ input:   *header          Pointer to header struct
/          *filekey         Filekey name of inputfile     
/          *input_filename  Input filename
/          *input_file_ttag Input filename time tag
/ output:  *header Pointer to header struct
/
/ return:      1       normal return
/              0       error modifying header
/
<-----------------------------------------------------------------------------*/
{
  long i,RecPointer,ndx;

  char write_format[HEADERMAXCHAR],String[HEADERMAXCHAR+10];
  char Base_Filename[MAXCHAR];

  GetBaseFilename (input_filename, Base_Filename);

  /*>>>> sanity checks <<<<*/

  if ((header->nrecord+2) > NMAXHEADERREC)
  {
    fprintf(stderr,"\nNumber of total Header labels exceeds %d",NMAXHEADERREC);
    fprintf(stderr," in AddInputFile2Header\n\n");
    return False;
  }

  if (header->NinputFileLabel+2 > MAXINPUTFILELABEL)
  {
    fprintf(stderr,"\nNumber of Header input file labels exceeds %d",
                   MAXINPUTFILELABEL);
    fprintf(stderr," in AddInputFile2Header\n\n");
    return False;
  }

  if (header->nrecord < NRHEADERLABELS)
  {
    header->NinputFileLabel = 0;
    loop(i,NRHEADERLABELS) 
         strcpy(&header->HeaderCards[i][0],"NOT DEFINED");
    header->nrecord = NRHEADERLABELS;
  }


  RecPointer = header->nrecord;
  ndx        = header->NinputFileLabel;

  strcpy(header->InputFileLabel[ndx].filekey,filekey);
  strcpy(header->InputFileLabel[ndx].name,Base_Filename);
  strcpy(header->InputFileLabel[ndx].time_tag,input_file_ttag);
  if (version[0]) strcpy(header->InputFileLabel[ndx].software_version,version);
  if (linktime[0]) strcpy(header->InputFileLabel[ndx].linktime,linktime);

  sprintf(write_format,"%%-%ds: %%-%ds",HEADERLABELMAXCHAR,
          HEADERMAXCHAR-HEADERLABELMAXCHAR-2);

  sprintf(String,"%s<-%s",filekey,Base_Filename);
  sprintf(&header->HeaderCards[RecPointer][0],write_format,
          "INPUT FILE NAME               ",String);

  RecPointer++;
  
  sprintf(String,"%s<-%s",filekey,input_file_ttag);
  sprintf(&header->HeaderCards[RecPointer][0],write_format,
          "INPUT FILE TIME TAG (UTC)     ",String);

  header->nrecord += 2;

  if (version[0])
  {
    RecPointer++;
  
    sprintf(String,"%s<-%s",filekey,&version[5]);
    sprintf(&header->HeaderCards[RecPointer][0],write_format,
            "INPUT FILE SOFTWARE VERSION   ",String);
    header->nrecord++;
  }
  if (linktime[0])
  {
    RecPointer++;
  
    sprintf(String,"%s<-%s",filekey,&linktime[5]);
    sprintf(&header->HeaderCards[RecPointer][0],write_format,
            "INPUT FILE LINKTIME TAG       ",String);
    header->nrecord++;
  }

  header->NinputFileLabel++;

  return True;
}