Status
loginDirCreate(std::string &directory, const std::string &username)
{
    // Make sure the accounts directory is in place:
    ABC_CHECK(fileEnsureDir(gContext->accountsDir()));

    // We don't need to do anything if our directory already exists:
    if (!directory.empty())
        return Status();

    // Create our own directory:
    ABC_CHECK(newDirName(directory));
    ABC_CHECK(fileEnsureDir(directory));

    // Write our user name:
    UsernameJson json;
    ABC_CHECK(json.usernameSet(username));
    ABC_CHECK(json.save(directory + ACCOUNT_NAME_FILENAME));

    return Status();
}
Beispiel #2
0
void SettingsDialog::ApplySettings(AppSettings &s /* = settings */)
{
	s.SetShowConsole(showConsoleCheck->IsChecked());
	s.SetAutoCloseConsole(autoCloseConsoleCheck->IsChecked());
	
	s.SetAutoUpdate(autoUpdateCheck->IsChecked());
	
	wxFileName newInstDir = wxFileName::DirName(instDirTextBox->GetValue());
	if (!s.GetInstDir().SameAs(newInstDir))
	{
		wxFileName oldInstDir = s.GetInstDir();
		
		int response = wxMessageBox(
			_T("You've changed your instance directory, would you like to transfer all of your instances?"),
			_T("Instance directory changed."), 
			wxYES | wxNO | wxCANCEL | wxCENTER, this);
		
	RetryTransfer:
		if (response != wxCANCEL)
		{
			s.SetInstDir(newInstDir);
		}
		
		if (response == wxYES)
		{
			wxDir instDir(oldInstDir.GetFullPath());

			wxString oldDirName;
			if (instDir.GetFirst(&oldDirName))
			{
				do 
				{
					oldDirName = Path::Combine(oldInstDir, oldDirName);
					wxFileName newDirName(oldDirName);
					newDirName.MakeRelativeTo(oldInstDir.GetFullPath());
					newDirName.Normalize(wxPATH_NORM_ALL, newInstDir.GetFullPath());
					if (!wxRenameFile(oldDirName, newDirName.GetFullPath(), false))
					{
						wxLogError(_("Failed to move instance folder %s."), oldDirName.c_str());
					}
				} while (instDir.GetNext(&oldDirName));
			}
		}
	}

	s.SetMinMemAlloc(minMemorySpin->GetValue());
	s.SetMaxMemAlloc(maxMemorySpin->GetValue());

	s.SetJavaPath(javaPathTextBox->GetValue());
	s.SetJvmArgs(jvmArgsTextBox->GetValue());
	
	GUIMode newGUIMode;
	if (guiStyleDropDown->GetValue() == guiModeDefault)
		newGUIMode = GUI_Default;
	else if (guiStyleDropDown->GetValue() == guiModeSimple)
		newGUIMode = GUI_Simple;
	
	if (newGUIMode != s.GetGUIMode())
	{
		s.SetGUIMode(newGUIMode);
		wxMessageBox(_("Changing the GUI style requires a restart in order to take effect. Please restart MultiMC."),
			_("Restart Required"));
	}
}