コード例 #1
0
ParametersConfiguration::ParametersConfiguration(const QString& referenceFileName, const QString& valuesFileName, QObject* parent)
: QObject(parent), parentData_(0), saveFileName_(valuesFileName) {
    empty_ = false;
    if (!parseDataFile(referenceFileName)) {
        empty_ = true;
        qDebug() << "Datafile read error: " << referenceFileName;
    }
    setModified(false);

    resetUserValues(valuesFileName);
}
コード例 #2
0
ファイル: SMFFEConfig.cpp プロジェクト: Sirithang/SMFFE
SMFFEConfig::SMFFEConfig(void)
	:mFilename("data/config.ini")
{
	mViewWidth = 1024;
	mViewHeight = 728;

	// ******* INI READING ****
	if(!fexists(mFilename.c_str()))
	{
		CIniFile::Create(mFilename);
	}

	//----width
	std::string lValue = CIniFile::GetValue("width", "graphics", mFilename);
	if(lValue == "")
	{
		mWinWidth = 1024;
	}
	else
	{
		mWinWidth = atoi(lValue.c_str());
	}

	//-----height
	lValue = CIniFile::GetValue("height", "graphics", mFilename);
	if(lValue == "")
	{
		mWinHeight = 768;
	}
	else
	{
		mWinHeight = atoi(lValue.c_str());
	}

	//-----fullscreen
	lValue = CIniFile::GetValue("fullscreen", "graphics", mFilename);
	if(lValue == "")
	{
		mFullScreen = false;
	}
	else
	{
		mFullScreen = lValue == "true"?true:false;
	}

	//-----sounds

	lValue = CIniFile::GetValue("music", "sounds", mFilename);
	if(lValue == "")
	{
		mMusicOn = true;
	}
	else
	{
		mMusicOn = lValue == "on"?true:false;
	}


	lValue = CIniFile::GetValue("effect", "sounds", mFilename);
	if(lValue == "")
	{
		mEffectRatio = 1.0f;
	}
	else
	{
		mEffectRatio = lValue == "on"?1.0f:0.0f;
	}


	//----------------------READ KEYBOARD/joypad MAPPING
	readKeyboardMapping();
	readJoypadMapping();

	//----------------------READ GLOBAL VARIABLES

	mDatas = parseDataFile("data/variables.conf");

	mPurcentageDamageTakenUltra = stringToFloat(mDatas["ultraReceivePurcentage"]);
	mPurcentageDamageGivenUltra = stringToFloat(mDatas["ultraDegatPurcentage"]);
	mPurcentageDamageTakenUltraFromUltra = stringToFloat(mDatas["ultraReceiveByUltraPurcentage"]);
}
コード例 #3
0
DataFileHelper::DataFileHelper() // Constructor
{
    parseDataFile();
}
コード例 #4
0
ファイル: spline.cpp プロジェクト: scallopedllama/coaster
int spline::parseFile(char *filename, CWSpaceVector &start)
{
	debug("Parsing file %s:\n", filename);
	char pwd[1024];
	pwd[0] = '\0';
	if(strchr(filename, '/') != NULL)
	{
		int endCh = 0;
		//this contains a directory so we need to pull that out
		for(int i=int(strlen(filename)); i>=0; i--)
		{
			if(filename[i] == '/')
			{
				endCh = i;
				break;
			}
		}
		strncpy(pwd, filename, endCh);
		pwd[endCh] = '/';
		pwd[endCh + 1] = '\0';
		debug("\tWorking dir: %s\n", pwd);
	}

	//open the current file
	FILE* data = fopen(filename, "r");

	//if the file can't be opened, the function returns -1.
	//this is so that parts of the rollercoaster can simply be
	//ignored if their respective files couldn't be opened.
	//might look funny in the end, but it's better than just crashing.
	if (data == NULL)
	{
		debug ("can't open file %s\n", filename);
		return -1;
	}

	int pieces;

	// get the number of pieces for this file
	fscanf(data, "%d", &pieces);

	//and the rest
	for (int j = 0; j < pieces; j++)
	{
		// define a variable of a reasonable size for a filename
		char newFilename[1024];
		fscanf(data, "%s", newFilename);

		if(newFilename[0] == '#')
		{
			debug("\tIgnoring comment\n");
			continue;
		}

		char toOpen[1024];
		strcpy(toOpen, pwd);
		strcat(toOpen, newFilename);
		parseDataFile(toOpen, start);
	}
	return 0;
}