Exemplo n.º 1
0
void GameConfig::guiEvent(ofxUIEventArgs &e) {
	string name = e.widget->getName(); 
	int kind = e.widget->getKind(); 
	cout << "got event from: " << name << endl;

	if(name == "INPUT_TEAMS") {
			ofxUITextInput *textinput = (ofxUITextInput *) e.widget; 
			string output = textinput->getTextString(); 
			cout << "TEAMS " << output << endl; 
			iNumTeams = atoi(output.c_str());
	}
	else if(name == "INPUT_PLAYERS")
	{
			ofxUITextInput *textinput = (ofxUITextInput *) e.widget; 
			/*
			if(textinput->getTriggerType() == OFX_UI_TEXTINPUT_ON_ENTER)
			{
					cout << "ON ENTER: "; 
//            ofUnregisterKeyEvents((testApp*)this); 
			}
			else if(textinput->getTriggerType() == OFX_UI_TEXTINPUT_ON_FOCUS)
			{
					cout << "ON FOCUS: "; 
			}
			else if(textinput->getTriggerType() == OFX_UI_TEXTINPUT_ON_UNFOCUS)
			{
					cout << "ON BLUR: "; 
//            ofRegisterKeyEvents(this);             
			} 
			*/       
			string output = textinput->getTextString(); 
			cout << "PLAYERS " << output << endl; 
			iNumPlayers = atoi(output.c_str());
	}
	else if (name == "NEXT >>") 
	{
			ofxUILabelButton *button = (ofxUILabelButton *) e.widget; 
			bool val = button->getValue();
			if( (val == true) && ( (iNumTeams > 0) && (iNumPlayers > 0) ) ) {
				setCurrentPanel( PANEL_PLAYERS );
			}
	}
	else if (name == "SAVE") 
	{
			ofxUILabelButton *button = (ofxUILabelButton *) e.widget; 
			bool val = button->getValue();
			if( (val == true) && ( (iNumTeams > 0) && (iNumPlayers > 0) ) ) {
				saveGameConfig();
			}
	}
} // guiEvent( ofUIEventArgs & )
Exemplo n.º 2
0
void Config::Save() {
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		
		saveGameConfig(gameId_);

		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		// Need to do this somewhere...
		bFirstRun = false;

		for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
			IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
			for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
				if (!bGameSpecific || !setting->perGame_){
					setting->Set(section);
				}
			}
		}

		IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
		recent->Set("MaxRecent", iMaxRecent);

		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "FileName%d", i);
			if (i < (int)recentIsos.size()) {
				recent->Set(keyName, recentIsos[i]);
			} else {
				recent->Delete(keyName); // delete the nonexisting FileName
			}
		}

		IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
		pinnedPaths->Clear();
		for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "Path%d", (int)i);
			pinnedPaths->Set(keyName, vPinnedPaths[i]);
		}

		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Delete("DPadRadius");

		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());

		if (!bGameSpecific) //otherwise we already did this in saveGameConfig()
		{
			IniFile controllerIniFile;
			if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
			}
			KeyMap::SaveToIni(controllerIniFile);
			if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
				return;
			}
			INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
		}
	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
}
Exemplo n.º 3
0
void Config::Save() {
	if (jitForcedOff) {
		// if JIT has been forced off, we don't want to screw up the user's ppsspp.ini
		g_Config.bJit = true;
	}
	if (iniFilename_.size() && g_Config.bSaveSettings) {
		
		saveGameConfig(gameId_);

		CleanRecent();
		IniFile iniFile;
		if (!iniFile.Load(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
		}

		// Need to do this somewhere...
		bFirstRun = false;

		IterateSettings(iniFile, [&](IniFile::Section *section, ConfigSetting *setting) {
			if (!bGameSpecific || !setting->perGame_) {
				setting->Set(section);
			}
		});

		IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
		recent->Set("MaxRecent", iMaxRecent);

		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "FileName%d", i);
			if (i < (int)recentIsos.size()) {
				recent->Set(keyName, recentIsos[i]);
			} else {
				recent->Delete(keyName); // delete the nonexisting FileName
			}
		}

		IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
		pinnedPaths->Clear();
		for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
			char keyName[64];
			snprintf(keyName, sizeof(keyName), "Path%d", (int)i);
			pinnedPaths->Set(keyName, vPinnedPaths[i]);
		}

		IniFile::Section *control = iniFile.GetOrCreateSection("Control");
		control->Delete("DPadRadius");

		if (!iniFile.Save(iniFilename_.c_str())) {
			ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
			return;
		}
		INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());

		if (!bGameSpecific) //otherwise we already did this in saveGameConfig()
		{
			IniFile controllerIniFile;
			if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
			}
			KeyMap::SaveToIni(controllerIniFile);
			if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
				ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
				return;
			}
			INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
		}
	} else {
		INFO_LOG(LOADER, "Not saving config");
	}
	if (jitForcedOff) {
		// force JIT off again just in case Config::Save() is called without exiting PPSSPP
		g_Config.bJit = false;
	}
}