Ejemplo n.º 1
0
void CDistinta::SalvaDistinta(bool saveas)
{
	wxFile ff;
	wxString nome_file;
	int uu;
	RigaDist* rd;
	ListaRighe::Node* nrd;


	if (saveas) {
		fd = new wxFileDialog(NULL, "Save As...",dist_path,nome_dist,"*.dat", wxFD_SAVE);

		 if (fd->ShowModal() == wxID_CANCEL) {
		   delete fd;
			return; // the user changed idea...
		}
		
		nome_dist = fd->GetFilename();
	
		nome_file = dist_path+nome_dist;
	}
	else
		nome_file = ".\\DISTINTA.DAT";

	ff.Open(nome_file,wxFile::write);
	
	//se salvataggio distinta attuale
	//come prima cosa salvo il nome della distinta...
	if(saveas==false) {
		uu=wxStrlen(nome_dist);
		ff.Write(&uu,sizeof(int));
		if (uu>0)
			ff.Write(nome_dist,wxMBConvUTF8());
	}
	//... e poi tutte le righe...
	nrd=lista->GetFirst();

	while (nrd) {
		rd = nrd->GetData();

		for(int ii=0; ii<num_var; ii++) {
			ff.Write(&rd->dati.d[ii],sizeof(double));
			ff.Write(&rd->dati.i[ii],sizeof(int));
		}
		for(int ii=0; ii<num_var; ii++) {
			uu=wxStrlen(rd->dati.s[ii]);
			ff.Write(&uu,sizeof(int));
			if (uu>0)
				ff.Write(rd->dati.s[ii],wxMBConvUTF8());
		} //TODO vedere se passare all'ascii 8 bit

		nrd = nrd->GetNext();
	}

	ff.Close();

	statusbar->SetStatusText(nome_dist,0);


}
Ejemplo n.º 2
0
__fi wxString fromUTF8( const char* src )
{
	// IMPORTANT:  We cannot use wxString::FromUTF8 because it *stupidly* relies on a C++ global instance of
	// wxMBConvUTF8().  C++ initializes and destroys these globals at random, so any object constructor or
	// destructor that attempts to do logging may crash the app (either during startup or during exit) unless
	// we use a LOCAL instance of wxMBConvUTF8(). --air

	// Performance?  No worries.  wxMBConvUTF8() is virtually free.  Initializing a stack copy of the class
	// is just as efficient as passing a pointer to a pre-instanced global. (which makes me wonder wh wxWidgets
	// uses the stupid globals in the first place!)  --air

	return wxString( src, wxMBConvUTF8() );
}
Ejemplo n.º 3
0
void CRefSelDlg::OnListSelect(wxListEvent& event)
{
	_U32 index = (_U32)event.GetItem().GetId();
	
	if(index < (_U32)m_pUUIDList->GetItemCount())
	{
		wxUIntPtr itemdata = m_pUUIDList->GetItemData(index);		

		char uuid[1000];
		AUuidToString(*((A_UUID*)itemdata), uuid);
		m_strSel = wxString(uuid, wxMBConvUTF8());
	}
}
Ejemplo n.º 4
0
// convert a string to IRI: https://en.wikipedia.org/wiki/Internationalized_resource_identifier
static wxString ConvToIRI(const wxString& str)
{
	std::string utf8(str.mb_str(wxMBConvUTF8()));
	wxString escaped;
	for (unsigned i=0; i<utf8.length(); i++) {
		const unsigned char c = utf8[i];
		if ( (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ) {
			escaped.append(wxChar(c));
		} else { /* if (i+1<utf8.length())*/
			escaped.append(wxString::Format(_T("%%%02x"),wxChar(c)));
		}
		//FIXME: this function is incomplete! tested only with german umlauts
	}
	return escaped;
}
Ejemplo n.º 5
0
void CRefSelDlg::AppendItem(wxString& wxRefType, wxString strInput)
{
	Zion::Array<const DDLReflect::STRUCT_INFO*> list;
	Zion::ContentObject::GetTypeList(list);
	Zion::Array<const DDLReflect::STRUCT_INFO*>::iterator i;
	const DDLReflect::STRUCT_INFO* info = NULL;
	for(i=list.begin(); i!=list.end(); i++)
	{
		info = *i;
		while(info)
		{
			if(wxRefType==wxString::FromUTF8(info->name))
			{
				break;
			}

			info = info->parent;
		}

		if(info && wxRefType.c_str()==wxString::FromUTF8(info->name))
		{
			break;
		}
	}

	if(info == NULL) return;

	const A_CONTENT_OBJECT* object = Zion::ContentObject::FindFirst(info, true);
	while(object)
	{
		wxString strNameValue(object->_name._Value, wxMBConvUTF8());
		if(!strInput.empty() && strNameValue.find(strInput) == wxNOT_FOUND)
		{
			continue;
		}

		long item_id = m_pUUIDList->InsertItem(m_pUUIDList->GetItemCount(), wxString::FromUTF8(object->_name._Value));

		char szUUID[128];
		AUuidToString(object->_uuid, szUUID);
		m_pUUIDList->SetItem(item_id, 1, wxString::FromUTF8(szUUID));

		wxUIntPtr itemData = (wxUIntPtr)&object->_uuid;
		m_pUUIDList->SetItemPtrData(item_id, itemData);

		object = Zion::ContentObject::FindNext(info, true, object);
	}
}
Ejemplo n.º 6
0
void CStructEditView::CreateArray(wxPGProperty* id, const wxString& name, const DDLReflect::FIELD_INFO* finfo, void* data)
{
	ZION_ASSERT(finfo->type|DDLReflect::TYPE_ARRAY);

	_U32& count = *((_U32*)data);
	wxString label(finfo->name, wxMBConvUTF8());
	wxArrayProperty* prop = ZION_NEW wxArrayProperty(label+wxString::Format(wxT("[%d]"), finfo->alen), name, finfo, data);//wxPG_LABEL, wxString::Format(wxT("array %d"), count));
	prop->ChangeFlag(wxPG_PROP_COLLAPSED, true);
	wxPGProperty* prog_id = m_pPropGrid->AppendIn(id, prop);
	for(_U32 i=0; i<(_U32)finfo->alen; i++)
	{
		wxPGProperty* item;
		item = CreateProperty(prog_id, wxString::Format(wxT("%s[%d]"), name, i), finfo, (char*)data+finfo->prefix+finfo->elen*i, i);
		prop->m_items.push_back(item);
		if(i>=*((_U32*)data)) item->Hide(true);
	}
}
Ejemplo n.º 7
0
ProMan::RegistryCodes FilePushProfile(wxFileConfig *cfg) {
	wxFileName configFileName;
	wxString tcPath;
	cfg->Read(PRO_CFG_TC_ROOT_FOLDER, &tcPath);

	if ( cfg->Exists(INT_CONFIG_FILE_LOCATION) ) {
		wxString configFileNameString;
		if (cfg->Read(INT_CONFIG_FILE_LOCATION, &configFileNameString)) {
			configFileName.Assign(configFileNameString);
		} else {
			wxLogError(_T("Unable to retrieve Config File location even though config says key exists"));
			return ProMan::UnknownError;
		}
	} else {
		configFileName = GetPlatformDefaultConfigFilePath(tcPath);
	}
	wxASSERT_MSG( configFileName.Normalize(),
		wxString::Format(_T("Unable to normalize PlatformDefaultConfigFilePath (%s)"),
		configFileName.GetFullPath().c_str()));

	if ( !configFileName.FileExists() && configFileName.DirExists() ) {
		// was given a directory name
		configFileName.SetFullName(FSO_CONFIG_FILENAME);
	}

	wxFFileInputStream configFileInputStream(configFileName.GetFullPath());
	wxStringInputStream configBlankInputStream(_T("")); // in case ini file doesn't exist
	wxInputStream* configInputStreamPtr = &configFileInputStream;
	
	if (!configFileInputStream.IsOk()) {
		wxLogDebug(_T("Could not read from ini file %s, writing new file"),
			configFileName.GetFullPath().c_str());
		configInputStreamPtr = &configBlankInputStream;
	}
	wxFileConfig outConfig(*configInputStreamPtr, wxMBConvUTF8());
	bool ret;
	
	// most settings are written to "Default" folder
	outConfig.SetPath(REG_KEY_DEFAULT_FOLDER_CFG);

	// Video
	int width, height, bitdepth;
	cfg->Read(PRO_CFG_VIDEO_RESOLUTION_WIDTH, &width, DEFAULT_VIDEO_RESOLUTION_WIDTH);
	cfg->Read(PRO_CFG_VIDEO_RESOLUTION_HEIGHT, &height, DEFAULT_VIDEO_RESOLUTION_HEIGHT);
	cfg->Read(PRO_CFG_VIDEO_BIT_DEPTH, &bitdepth, DEFAULT_VIDEO_BIT_DEPTH);

	wxString videocardValue = wxString::Format(_T("OGL -(%dx%d)x%d bit"), width, height, bitdepth);

	ret = outConfig.Write(REG_KEY_VIDEO_RESOLUTION_DEPTH, videocardValue);
	ReturnChecker(ret, __LINE__);

	
	wxString filterMethod;
	cfg->Read(PRO_CFG_VIDEO_TEXTURE_FILTER, &filterMethod, DEFAULT_VIDEO_TEXTURE_FILTER);
	int filterMethodValue = ( filterMethod.StartsWith(_T("Bilinear"))) ? 0 : 1;
	
	ret = outConfig.Write(REG_KEY_VIDEO_TEXTURE_FILTER, filterMethodValue);
	ReturnChecker(ret, __LINE__);
	

	int oglAnisotropicFilter;
	cfg->Read(PRO_CFG_VIDEO_ANISOTROPIC, &oglAnisotropicFilter, DEFAULT_VIDEO_ANISOTROPIC);

	// Caution: FSO expects anisotropic values to be a string,
	// but since we're writing to an .ini file, we can write it out as an int
	ret = outConfig.Write(REG_KEY_VIDEO_ANISOTROPIC, oglAnisotropicFilter);
	ReturnChecker(ret, __LINE__);
	

	int oglAntiAliasSample;
	cfg->Read(PRO_CFG_VIDEO_ANTI_ALIAS, &oglAntiAliasSample, DEFAULT_VIDEO_ANTI_ALIAS);

	ret = outConfig.Write(REG_KEY_VIDEO_ANTI_ALIAS, oglAntiAliasSample);
	ReturnChecker(ret, __LINE__);


	// Audio
	wxString soundDevice;
	cfg->Read(PRO_CFG_OPENAL_DEVICE, &soundDevice, DEFAULT_AUDIO_OPENAL_DEVICE);

	ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_DEVICE, soundDevice);
	ReturnChecker(ret, __LINE__);


	// new sound code settings are written to "Sound" folder
	outConfig.SetPath(REG_KEY_AUDIO_FOLDER_CFG);


	wxString playbackDevice;
	cfg->Read(
		PRO_CFG_OPENAL_DEVICE,
		&playbackDevice,
		DEFAULT_AUDIO_OPENAL_PLAYBACK_DEVICE);

	ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_PLAYBACK_DEVICE, playbackDevice);
	ReturnChecker(ret, __LINE__);


	wxString captureDevice;
	bool hasEntry = cfg->Read(
		PRO_CFG_OPENAL_CAPTURE_DEVICE,
		&captureDevice,
		DEFAULT_AUDIO_OPENAL_CAPTURE_DEVICE);

	if (hasEntry) {
		ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_CAPTURE_DEVICE, captureDevice);
		ReturnChecker(ret, __LINE__);
	}


	int enableEFX;
	hasEntry = cfg->Read(PRO_CFG_OPENAL_EFX, &enableEFX, DEFAULT_AUDIO_OPENAL_EFX);

	if (hasEntry) {
		ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_EFX, enableEFX);
		ReturnChecker(ret, __LINE__);
	}


	int sampleRate;
	cfg->Read(
		PRO_CFG_OPENAL_SAMPLE_RATE,
		&sampleRate,
		DEFAULT_AUDIO_OPENAL_SAMPLE_RATE);

	if (sampleRate != DEFAULT_AUDIO_OPENAL_SAMPLE_RATE) {
		ret = outConfig.Write(REG_KEY_AUDIO_OPENAL_SAMPLE_RATE, sampleRate);
		ReturnChecker(ret, __LINE__);
	}


	outConfig.SetPath(REG_KEY_DEFAULT_FOLDER_CFG);


	// Speech
#if IS_WIN32 // speech is currently not supported in OS X or Linux (although Windows doesn't use this code)
	int speechVoice;
	cfg->Read(PRO_CFG_SPEECH_VOICE, &speechVoice, DEFAULT_SPEECH_VOICE);

	ret = outConfig.Write(REG_KEY_SPEECH_VOICE, speechVoice);
	ReturnChecker(ret, __LINE__);


	int speechVolume;
	cfg->Read(PRO_CFG_SPEECH_VOLUME, &speechVolume, DEFAULT_SPEECH_VOLUME);

	ret = outConfig.Write(REG_KEY_SPEECH_VOLUME, speechVolume);
	ReturnChecker(ret, __LINE__);


	int inTechroom, inBriefings, inGame, inMulti;
	cfg->Read(PRO_CFG_SPEECH_IN_TECHROOM, &inTechroom, DEFAULT_SPEECH_IN_TECHROOM);
	cfg->Read(PRO_CFG_SPEECH_IN_BRIEFINGS, &inBriefings, DEFAULT_SPEECH_IN_BRIEFINGS);
	cfg->Read(PRO_CFG_SPEECH_IN_GAME, &inGame, DEFAULT_SPEECH_IN_GAME);
	cfg->Read(PRO_CFG_SPEECH_IN_MULTI, &inMulti, DEFAULT_SPEECH_IN_MULTI);

	ret = outConfig.Write(REG_KEY_SPEECH_IN_TECHROOM, inTechroom);
	ReturnChecker(ret, __LINE__);

	ret = outConfig.Write(REG_KEY_SPEECH_IN_BRIEFINGS, inBriefings);
	ReturnChecker(ret, __LINE__);

	ret = outConfig.Write(REG_KEY_SPEECH_IN_GAME, inGame);
	ReturnChecker(ret, __LINE__);

	ret = outConfig.Write(REG_KEY_SPEECH_IN_MULTI, inMulti);
	ReturnChecker(ret, __LINE__);
#endif


	// Joystick
	int currentJoystick;
	cfg->Read(PRO_CFG_JOYSTICK_ID, &currentJoystick, DEFAULT_JOYSTICK_ID);

	ret = outConfig.Write(REG_KEY_JOYSTICK_ID, currentJoystick);
	ReturnChecker(ret, __LINE__);


	int joystickForceFeedback;
	cfg->Read(
		PRO_CFG_JOYSTICK_FORCE_FEEDBACK,
		&joystickForceFeedback,
		DEFAULT_JOYSTICK_FORCE_FEEDBACK);

	ret = outConfig.Write(REG_KEY_JOYSTICK_FORCE_FEEDBACK, joystickForceFeedback);
	ReturnChecker(ret, __LINE__);


	int joystickHit;
	cfg->Read(PRO_CFG_JOYSTICK_DIRECTIONAL, &joystickHit, DEFAULT_JOYSTICK_DIRECTIONAL);

	ret = outConfig.Write(REG_KEY_JOYSTICK_DIRECTIONAL, joystickHit);
	ReturnChecker(ret, __LINE__);


	// Network
	wxString networkConnectionValue;
	cfg->Read(PRO_CFG_NETWORK_TYPE, &networkConnectionValue, DEFAULT_NETWORK_TYPE);

	ret = outConfig.Write(REG_KEY_NETWORK_TYPE, networkConnectionValue);
	ReturnChecker(ret, __LINE__);


	wxString connectionSpeedValue;
	cfg->Read(PRO_CFG_NETWORK_SPEED, &connectionSpeedValue, DEFAULT_NETWORK_SPEED);

	ret = outConfig.Write(REG_KEY_NETWORK_SPEED, connectionSpeedValue);
	ReturnChecker(ret, __LINE__);


	int forcedport;
	cfg->Read(PRO_CFG_NETWORK_PORT, &forcedport, DEFAULT_NETWORK_PORT);

	if (forcedport != DEFAULT_NETWORK_PORT) {
		ret = outConfig.Write(REG_KEY_NETWORK_PORT, forcedport);
		ReturnChecker(ret, __LINE__);
	} else if (outConfig.Exists(REG_KEY_NETWORK_PORT)) {
		ret = outConfig.DeleteEntry(REG_KEY_NETWORK_PORT, false);
		ReturnChecker(ret, __LINE__);
	}


	// custom IP is written to "Network" folder
	outConfig.SetPath(REG_KEY_NETWORK_FOLDER_CFG);

	wxString networkIP;
	cfg->Read(PRO_CFG_NETWORK_IP, &networkIP, DEFAULT_NETWORK_IP);

	if (networkIP != DEFAULT_NETWORK_IP) {
		ret = outConfig.Write(REG_KEY_NETWORK_IP, networkIP);
		ReturnChecker(ret, __LINE__);
	} else if (outConfig.Exists(REG_KEY_NETWORK_IP)) {
		ret = outConfig.DeleteEntry(REG_KEY_NETWORK_IP, false);
		ReturnChecker(ret, __LINE__);
	}

	outConfig.SetPath(REG_KEY_DEFAULT_FOLDER_CFG);


	wxLogDebug(_T("Writing fs2_open.ini to %s"), configFileName.GetFullPath().c_str());
	wxFFileOutputStream outFileStream(configFileName.GetFullPath());

	outConfig.Save(outFileStream);

	return PushCmdlineFSO(cfg);
}
Ejemplo n.º 8
0
ProMan::RegistryCodes FilePullProfile(wxFileConfig *cfg) {
	wxFileName inFileName;
	if ( cfg->Exists(INT_CONFIG_FILE_LOCATION) ) {
		wxString inFileNameString;
		if (cfg->Read(INT_CONFIG_FILE_LOCATION, &inFileNameString)) {
			inFileName.Assign(inFileNameString);
		} else {
			wxLogError(_T("Unable to retrieve Config File location even though config says key exists"));
			return ProMan::UnknownError;
		}
	} else {
		inFileName = GetPlatformDefaultConfigFilePathNew();
		inFileName.SetFullName(FSO_CONFIG_FILENAME);

		if (!inFileName.FileExists())
		{
			inFileName = GetPlatformDefaultConfigFilePathOld();
			inFileName.SetFullName(FSO_CONFIG_FILENAME);
		}
	}
	wxASSERT( inFileName.Normalize() );

	if ( !inFileName.FileExists() && inFileName.DirExists() ) {
		// was given a directory name
		inFileName.SetFullName(FSO_CONFIG_FILENAME);
	}

	if (!inFileName.FileExists()) {
		return ProMan::InputFileDoesNotExist;
	}

	wxFFileInputStream inConfigStream(inFileName.GetFullPath(), _T("rb"));
	wxFileConfig inConfig(inConfigStream, wxMBConvUTF8());

	wxString readString;
	int readNumber;


	// Video
	if ( inConfig.Read(REG_KEY_VIDEO_RESOLUTION_DEPTH, &readString) ) {
		// parses VideocardFS2open into its parts
		wxString videoCard(readString);
		wxString rest, rest1, rest2, rest3;

		long width = 0, height = 0, bitdepth = 0;
		if ( videoCard.StartsWith(_T("OGL -("), &rest) ) {
			int xLocation = rest.Find(_T('x'));
			if ( xLocation != wxNOT_FOUND ) {
				wxString widthStr(rest.Mid(0, xLocation));
				rest1 = rest.Mid(xLocation);
				if ( !widthStr.ToLong(&width, 10) ) {
					width = 0;
				}
				int bLocation = rest1.Find(_T(')'));
				if ( bLocation != wxNOT_FOUND ) {
					wxString heightStr(rest1.Mid(0, bLocation));
					rest2 = rest1.Mid(bLocation+1);
					if ( !heightStr.ToLong(&height, 10) ) {
						height = 0;
					}
					int spaceLoc = rest2.Find(_T(' '));
					if ( spaceLoc != wxNOT_FOUND ) {
						wxString bitStr(rest2.Mid(0, spaceLoc));
						if ( !bitStr.ToLong(&bitdepth, 10) ) {
							bitdepth = 0;
						}
					}
				}
			}
		}
		if ( width > 0 ) {
			cfg->Write(PRO_CFG_VIDEO_RESOLUTION_WIDTH, width);
		} 
		if ( height > 0 ) {
			cfg->Write(PRO_CFG_VIDEO_RESOLUTION_HEIGHT, height);
		}
		if ( bitdepth > 0 ) {
			cfg->Write(PRO_CFG_VIDEO_BIT_DEPTH, bitdepth);
		}
	}

	if ( inConfig.Read(REG_KEY_VIDEO_TEXTURE_FILTER, &readNumber) ) {
		cfg->Write(PRO_CFG_VIDEO_TEXTURE_FILTER, readNumber);
	}

	if ( inConfig.Read(REG_KEY_VIDEO_ANISOTROPIC, &readString) ) {
		long anisotropic;
		// necessary because FSO expects registry value to be a string
		if ( readString.ToLong(&anisotropic) ) {
			cfg->Write(PRO_CFG_VIDEO_ANISOTROPIC, anisotropic);
		}
	}

	if ( inConfig.Read(REG_KEY_VIDEO_ANTI_ALIAS, &readNumber) ) {
		cfg->Write(PRO_CFG_VIDEO_ANTI_ALIAS, readNumber);
	}


	// Audio
	if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_DEVICE, &readString) ) {
		cfg->Write(PRO_CFG_OPENAL_DEVICE, readString);
	}

	if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_PLAYBACK_DEVICE, &readString) &&
			!inConfig.Exists(PRO_CFG_OPENAL_DEVICE)) {
		cfg->Write(PRO_CFG_OPENAL_DEVICE, readString);
	}

	if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_CAPTURE_DEVICE, &readString) ) {
		cfg->Write(PRO_CFG_OPENAL_CAPTURE_DEVICE, readString);
	}

	if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_EFX, &readNumber) ) {
		cfg->Write(PRO_CFG_OPENAL_EFX, readNumber);
	}

	if ( inConfig.Read(REG_KEY_AUDIO_OPENAL_SAMPLE_RATE, &readNumber) ) {
		cfg->Write(PRO_CFG_OPENAL_SAMPLE_RATE, readNumber);
	}


	// Speech
#if IS_WIN32 // Linux/OS X don't yet support speech
	if ( inConfig.Read(REG_KEY_SPEECH_VOICE, &readNumber) ) {
		cfg->Write(PRO_CFG_SPEECH_VOICE, readNumber);
	}

	if ( inConfig.Read(REG_KEY_SPEECH_VOLUME, &readNumber) ) {
		cfg->Write(PRO_CFG_SPEECH_VOLUME, readNumber);
	}
	
	if ( inConfig.Read(REG_KEY_SPEECH_IN_TECHROOM, &readNumber) ) {
		cfg->Write(PRO_CFG_SPEECH_IN_TECHROOM, readNumber);
	}

	if ( inConfig.Read(REG_KEY_SPEECH_IN_BRIEFINGS, &readNumber) ) {
		cfg->Write(PRO_CFG_SPEECH_IN_BRIEFINGS, readNumber);
	}

	if ( inConfig.Read(REG_KEY_SPEECH_IN_GAME, &readNumber) ) {
		cfg->Write(PRO_CFG_SPEECH_IN_GAME, readNumber);
	}

	if ( inConfig.Read(REG_KEY_SPEECH_IN_MULTI, &readNumber) ) {
		cfg->Write(PRO_CFG_SPEECH_IN_MULTI, readNumber);
	}
#endif


	// Joystick
	if ( inConfig.Read(REG_KEY_JOYSTICK_ID, &readNumber) ) {
		cfg->Write(PRO_CFG_JOYSTICK_ID, readNumber);
	}
	
	if ( inConfig.Read(REG_KEY_JOYSTICK_FORCE_FEEDBACK, &readNumber) ) {
		cfg->Write(PRO_CFG_JOYSTICK_FORCE_FEEDBACK, readNumber);
	}
	
	if ( inConfig.Read(REG_KEY_JOYSTICK_DIRECTIONAL, &readNumber) ) {
		cfg->Write(PRO_CFG_JOYSTICK_DIRECTIONAL, readNumber);
	}


	//  Network
	if ( inConfig.Read(REG_KEY_NETWORK_TYPE, &readString) ) {
		cfg->Write(PRO_CFG_NETWORK_TYPE, readString);
	}

	if ( inConfig.Read(REG_KEY_NETWORK_SPEED, &readString) ) {
		cfg->Write(PRO_CFG_NETWORK_SPEED, readString);
	}

	if ( inConfig.Read(REG_KEY_NETWORK_PORT, &readNumber) ) {
		cfg->Write(PRO_CFG_NETWORK_PORT, readNumber);
	}

	if ( inConfig.Read(REG_KEY_NETWORK_IP, &readString) ) {
		cfg->Write(PRO_CFG_NETWORK_IP, readString);
	}


	return ProMan::NoError;
}
Ejemplo n.º 9
0
MyTagLib::String OOPCharsetConv::utf8ToWide(const char *utf8, size_t numBytes) {
    size_t len = numBytes;
    wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len, NULL));

    return buf ? (const wchar_t *) buf : MyTagLib::EmptyString;
}
Ejemplo n.º 10
0
wxPGProperty* CStructEditView::CreateProperty(wxPGProperty* id, const wxString& name, const DDLReflect::FIELD_INFO* finfo, void* data, _U32 index)
{
	wxString strLabel;
	wxPGProperty* prop = NULL;

	if(finfo->type&DDLReflect::TYPE_ARRAY)
	{
		strLabel.Printf(wxT("[%d]"), index);
	}
	else
	{
		strLabel = wxString::FromUTF8(finfo->name);
	}

	wxPGProperty* prog_id = 0;
	bool has_subitem = false;
	switch(finfo->type&DDLReflect::TYPE_MASK)
	{
	case DDLReflect::TYPE_U8:
		prop = ZION_NEW CPropertyEx<_U8, wxUIntProperty>(strLabel, name, finfo, data, *((const _U8*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_U16:
		prop = ZION_NEW CPropertyEx<_U16, wxUIntProperty>(strLabel, name, finfo, data, *((const _U16*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_U32:
		prop = ZION_NEW CPropertyEx<_U32, wxUIntProperty>(strLabel, name, finfo, data, *((const _U32*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_U64:
		prop = ZION_NEW CPropertyEx<_U64, wxUIntProperty>(strLabel, name, finfo, data, *((const _U64*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_S8:
		prop = ZION_NEW CPropertyEx<_S8, wxIntProperty>(strLabel, name, finfo, data, *((const _S8*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_S16:
		prop = ZION_NEW CPropertyEx<_S16, wxIntProperty>(strLabel, name, finfo, data, *((const _S16*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_S32:
		prop = ZION_NEW CPropertyEx<_S32, wxIntProperty>(strLabel, name, finfo, data, *((const _S32*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_S64:
		prop = ZION_NEW CPropertyEx<_S64, wxIntProperty>(strLabel, name, finfo, data, *((const _S64*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_F32:
		prop = ZION_NEW CPropertyEx<_F32, wxFloatProperty>(strLabel, name, finfo, data, *((const _F32*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_F64:
		prop = ZION_NEW CPropertyEx<_F64, wxFloatProperty>(strLabel, name, finfo, data, *((const _F64*)data));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_STRING:
		prop = ZION_NEW CPropertyEx<wxString, wxStringProperty>(strLabel, name, finfo, data, wxString((const char*)data, wxMBConvUTF8()));
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	case DDLReflect::TYPE_UUID:
		{
			char value[100];
			AUuidToString(*((A_UUID*)data), value);
			prop = ZION_NEW CPropertyEx<wxString, wxStringProperty>(strLabel, name, finfo, data, wxString(value, wxMBConvUTF8()));
			prog_id = m_pPropGrid->AppendIn(id, prop);
		}
		break;
	case DDLReflect::TYPE_STRUCT:
		if(strcmp(finfo->sinfo->name, "A_CONFUSED_U32")==0)
		{
			prop = ZION_NEW CPropertyEx<_U32, wxUIntProperty>(strLabel, name, finfo, data, Zion::CNUM_GET(*((const A_CONFUSED_U32*)data)));
			prog_id = m_pPropGrid->AppendIn(id, prop);
			break;
		}
		if(strcmp(finfo->sinfo->name, "A_CONFUSED_S32")==0)
		{
			prop = ZION_NEW CPropertyEx<_S32, wxIntProperty>(strLabel, name, finfo, data, Zion::CNUM_GET(*((const A_CONFUSED_S32*)data)));
			prog_id = m_pPropGrid->AppendIn(id, prop);
			break;
		}
		if(strcmp(finfo->sinfo->name, "A_CONFUSED_F32")==0)
		{
			prop = ZION_NEW CPropertyEx<_F32, wxFloatProperty>(strLabel, name, finfo, data, Zion::CNUM_GET(*((const A_CONFUSED_F32*)data)));
			prog_id = m_pPropGrid->AppendIn(id, prop);
			break;
		}
		{
			wxString value(wxT("struct "));
			value += wxString(finfo->sinfo->name, wxMBConvUTF8());
			prop = ZION_NEW CPropertyEx<wxString, wxStringProperty>(strLabel, name, finfo, data, value);
			prop->ChangeFlag(wxPG_PROP_READONLY, true);
			prop->ChangeFlag(wxPG_PROP_COLLAPSED, true);
			prog_id = m_pPropGrid->AppendIn(id, prop);
			has_subitem = true;
		}
		break;
	case DDLReflect::TYPE_UUID_REF:
		prop = ZION_NEW wxObjectRefProperty(strLabel, name, finfo, data);
		prog_id = m_pPropGrid->AppendIn(id, prop);
		break;
	default:
		ZION_ASSERT(0);
		return NULL;
	}

	if((finfo->flags&DDLReflect::FLAG_READONLY)!=0)
	{
		prop->ChangeFlag(wxPG_PROP_READONLY, true);
	}
	
	if(has_subitem)
	{
		CreateStruct(prog_id, name, finfo->sinfo, data);
	}

	return prop;
}
Ejemplo n.º 11
0
	bool MigrateOldConfig()
	{
		if (!(FlagListManager::GetFlagListManager()->GetBuildCaps() & FlagListManager::BUILD_CAPS_SDL))
		{
			// Nothing to do, we have an old build
			return true;
		}

		wxFileName newName = GetPlatformDefaultConfigFilePathNew();
		newName.SetFullName(FSO_CONFIG_FILENAME);

		if (wxFile::Exists(newName.GetFullPath())) {
			// New file already exists, nothing to do here
			return true;
		}

		wxLogStatus(_T("Migrating old configuration..."));
#if IS_WIN32
		// On Windows this is implemented by iterating through the registry and copying the values to the config file
		wxString keyName;
		HKEY useKey = GetRegistryKeyname(keyName);

		LONG ret = ERROR_SUCCESS;
		HKEY regHandle = 0;
		ret = RegOpenKeyExW(useKey,
			keyName.wc_str(),
			0,
			KEY_READ,
			&regHandle
			);
		if (ret != ERROR_SUCCESS) {
			// Key does not exists or some other error, assume it doesn't exist
			return true; // No old config, nothing to do here
		}

		wxStringInputStream configBlankInputStream(_T(""));

		wxFileConfig outConfig(configBlankInputStream, wxMBConvUTF8());

		copyValuesIntoConfig(regHandle, outConfig, REG_KEY_DEFAULT_FOLDER_CFG);

		for (DWORD i = 0;; ++i) {
			WCHAR subkey[255];
			DWORD subkeyLen = 255;

			LONG res = RegEnumKeyExW(regHandle, i, subkey, &subkeyLen, NULL, NULL, NULL, NULL);
			if (res != ERROR_SUCCESS)
				break;

			HKEY handle;
			res = RegOpenKeyExW(regHandle, subkey, 0, KEY_READ, &handle);
			if (res != ERROR_SUCCESS) {
				continue;
			}
			wxString sectionName(subkey, subkeyLen);

			sectionName = wxString::FromAscii("/") + sectionName;

			copyValuesIntoConfig(handle, outConfig, sectionName);
			RegCloseKey(handle);
		}

		RegCloseKey(regHandle);

		wxLogStatus(_T("Writing fs2_open.ini to %s"), newName.GetFullPath().c_str());
		wxFFileOutputStream outFileStream(newName.GetFullPath());

		outConfig.Save(outFileStream, wxMBConvUTF8());
#else
		wxFileName oldName = GetPlatformDefaultConfigFilePathOld();
		oldName.SetFullName(FSO_CONFIG_FILENAME);

		if (!wxFile::Exists(oldName.GetFullPath())) {
			// Old file does not exist, probably first run.
			return true;
		}

		if (!wxCopyFile(oldName.GetFullPath(), newName.GetFullPath())) {
			wxLogError(_T("Failed to copy old configuration file to new location!"));
			return false;
		}
#endif

		wxLogStatus(_T("Migration finished."));
		return true;
	}
Ejemplo n.º 12
0
// TODO:  Do we want to include the null char in the stream?  If so then
// just add +1 to m_len in the ctor 
wxStringInputStream::wxStringInputStream(const wxString& s) 
#if wxUSE_UNICODE
    : m_str(s), m_buf(wxMBConvUTF8().cWX2MB(s).release()), m_len(strlen(m_buf))
#else
    : m_str(s), m_buf((char*)s.c_str()), m_len(s.length())