Beispiel #1
0
bool
dlgStartupShowModal()
{
  LogFormat("Startup dialog");

  logo = new LogoView();

  wf = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(),
                  Layout::landscape ? _T("IDR_XML_STARTUP_L") :
                                      _T("IDR_XML_STARTUP"));
  assert(wf != NULL);

  WndProperty* wp = ((WndProperty *)wf->FindByName(_T("prpProfile")));
  assert(wp != NULL);

  DataFieldFileReader* dfe = (DataFieldFileReader*)wp->GetDataField();
  assert(dfe != NULL);

  dfe->ScanDirectoryTop(_T("*.prf"));

  if (dfe->GetNumFiles() <= 1) {
    SelectProfile(dfe->GetPathFile());

    delete wf;
    delete logo;
    return true;
  }

  unsigned best_index = 0;
  uint64_t best_timestamp = 0;
  unsigned length = dfe->size();

  for (unsigned i = 0; i < length; ++i) {
    const TCHAR *path = dfe->GetItem(i);
    uint64_t timestamp = File::GetLastModification(path);
    if (timestamp > best_timestamp) {
      best_timestamp = timestamp;
      best_index = i;
    }
  }
  dfe->Set(best_index);
  wp->RefreshDisplay();

  if (wf->ShowModal() != mrOK) {
    delete wf;
    delete logo;
    return false;
  }

  SelectProfile(dfe->GetPathFile());

  delete wf;
  delete logo;
  return true;
}
Beispiel #2
0
bool
dlgStartupShowModal()
{
  LogStartUp(_T("Startup dialog"));

  logo = new LogoView();

  wf = LoadDialog(CallBackTable, XCSoarInterface::main_window,
                  Layout::landscape ? _T("IDR_XML_STARTUP_L") :
                                      _T("IDR_XML_STARTUP"));
  assert(wf != NULL);

  WndProperty* wp = ((WndProperty *)wf->FindByName(_T("prpProfile")));
  assert(wp != NULL);

  DataFieldFileReader* dfe = (DataFieldFileReader*)wp->GetDataField();
  assert(dfe != NULL);

  ((WndButton *)wf->FindByName(_T("cmdClose")))
    ->SetOnClickNotify(OnCloseClicked);

  ((WndButton *)wf->FindByName(_T("cmdQuit")))->SetOnClickNotify(OnQuit);

  dfe->SetNotNullable();
  dfe->ScanDirectoryTop(_T("*.prf"));
  dfe->Lookup(Profile::GetPath());
  wp->RefreshDisplay();

  if (dfe->GetNumFiles() <= 1) {
    SelectProfile(dfe->GetPathFile());

    delete wf;
    delete logo;
    return true;
  }

  if (wf->ShowModal() != mrOK) {
    delete wf;
    delete logo;
    return false;
  }

  SelectProfile(dfe->GetPathFile());

  delete wf;
  delete logo;
  return true;
}
Beispiel #3
0
bool SettingsManager::Initialize()
{
    if(wxFile::Exists(SETTINGS_FILENAME))
        if(m_settings.Load(SETTINGS_FILENAME))
            if (m_settings.GetRoot()->GetName() == wxT("iptv"))
            {
                // load program configurations
                if(!LoadConfiguration())
                    return false;

                // load profiles list and cheks if a Latest profile exists
                LoadProfilesList();
                if(!m_latestProfile)
                    return false;

                // load the last profile
                if(!SelectProfile(GetSelectedProfileName()))
                    return false;

                m_initialized = true;
                return true;
            }

    return false;
}
Beispiel #4
0
void SettingsManager::SetProfile(wxString profileName)
{
    if(SelectProfile(profileName))
    {
        m_selectedProfileName = profileName;
    }
}
void CFlashMenuObject::DeleteProfile(const char *profileName)
{
	if(!m_pPlayerProfileManager)
		return;
	const char *userName = m_pPlayerProfileManager->GetCurrentUser();
	IPlayerProfileManager::EProfileOperationResult result;
	m_pPlayerProfileManager->DeleteProfile(userName, profileName, result);
	
	IPlayerProfile *pCurProfile = m_pPlayerProfileManager->GetCurrentProfile(userName);
	if(!pCurProfile)
	{
		IPlayerProfileManager::SProfileDescription profDesc;
		m_pPlayerProfileManager->GetProfileInfo(userName, 0, profDesc);
		SelectProfile(profDesc.name, true);
		ShowMenuMessage("@ui_menu_PROFILEDELETED");
	}

	g_pGame->GetOptions()->InitProfileOptions(true);
	g_pGame->GetOptions()->UpdateFlashOptions();
	UpdateProfiles();
	if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
	{
		m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.Profile.updateProfileList");
	}
}
Beispiel #6
0
static void switchProfile(uint8_t profile)
{
    SelectProfile(profile);
    loadKeyboardSettings();
#ifdef ENABLE_MOUSE
    loadMouseSettings();
#endif
}
Beispiel #7
0
bool
StartupWidget::Save(bool &changed)
{
  const DataFieldFileReader &dff =
    (const DataFieldFileReader &)GetDataField(PROFILE);
  SelectProfile(dff.GetPathFile());
  changed = true;

  return true;
}
Beispiel #8
0
bool
StartupWidget::Save(bool &changed)
{
  const auto &dff = (const FileDataField &)GetDataField(PROFILE);
  if (!SelectProfile(dff.GetPathFile()))
    return false;

  changed = true;

  return true;
}
Beispiel #9
0
bool
dlgStartupShowModal()
{
  LogFormat("Startup dialog");

  /* scan all profile files */
  auto *dff = new FileDataField();
  dff->ScanDirectoryTop(_T("*.prf"));

  if (dff->GetNumFiles() == 1) {
    /* skip this dialog if there is only one */
    const auto path = dff->GetPathFile();
    if (ProfileFileHasPassword(path) == TriState::FALSE &&
        SelectProfile(path)) {
      delete dff;
      return true;
    }
  } else if (dff->GetNumFiles() == 0) {
    /* no profile exists yet: create default profile */
    Profile::SetFiles(nullptr);
    return true;
  }

  /* preselect the most recently used profile */
  unsigned best_index = 0;
  uint64_t best_timestamp = 0;
  unsigned length = dff->size();

  for (unsigned i = 0; i < length; ++i) {
    const auto path = dff->GetItem(i);
    uint64_t timestamp = File::GetLastModification(path);
    if (timestamp > best_timestamp) {
      best_timestamp = timestamp;
      best_index = i;
    }
  }

  dff->Set(best_index);

  /* show the dialog */
  const DialogLook &look = UIGlobals::GetDialogLook();
  WidgetDialog dialog(look);
  TwoWidgets widget(new LogoQuitWidget(look.button, dialog),
                    new StartupWidget(look, dialog, dff));

  dialog.CreateFull(UIGlobals::GetMainWindow(), _T(""), &widget);

  const int result = dialog.ShowModal();
  dialog.StealWidget();

  return result == mrOK;
}
void CFlashMenuObject::AddProfile(const char *profileName)
{
	if(m_pPlayerProfileManager)
	{
		CryFixedStringT<128> sName(profileName);
		sName = sName.Trim();

		// check for invalid chars
		static const char* invalidChars = "\\/:*?\"<>~|";
		if (sName.find_first_of(invalidChars) != CryFixedStringT<128>::npos)
		{
			if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
			{
				ShowMenuMessage("@ui_menu_PROFILEERROR");
			}			
			return;
		}

		const char *userName = m_pPlayerProfileManager->GetCurrentUser();
	
		IPlayerProfileManager::EProfileOperationResult result;
		bool bDone = m_pPlayerProfileManager->CreateProfile(userName,sName.c_str(), false, result);
		if(bDone)
		{
			SelectProfile(sName.c_str(), false, true);
			RestoreDefaults();

			IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
			if(!pProfile)
				return;

			//reset to default (it's a copy of the current one)
			g_pGame->GetOptions()->SaveValueToProfile("Singleplayer.LastSavedGame", "");

			UpdateProfiles();
			if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
			{
				m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.Profile.gotoProfileMenu");
				ShowMenuMessage("@ui_menu_PROFILECREATED");
			}			
		}
		else
		{
			if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
			{
				ShowMenuMessage("@ui_menu_PROFILEERROR");
			}			
		}
	}
}
Beispiel #11
0
bool
dlgStartupShowModal()
{
  LogFormat("Startup dialog");

  /* scan all profile files */
  DataFieldFileReader *dfe = new DataFieldFileReader();
  dfe->ScanDirectoryTop(_T("*.prf"));

  /* skip this dialog if there is only one (or none) */
  if (dfe->GetNumFiles() <= 1) {
    SelectProfile(dfe->GetPathFile());
    delete dfe;
    return true;
  }

  /* preselect the most recently used profile */
  unsigned best_index = 0;
  uint64_t best_timestamp = 0;
  unsigned length = dfe->size();

  for (unsigned i = 0; i < length; ++i) {
    const TCHAR *path = dfe->GetItem(i);
    uint64_t timestamp = File::GetLastModification(path);
    if (timestamp > best_timestamp) {
      best_timestamp = timestamp;
      best_index = i;
    }
  }

  dfe->Set(best_index);

  /* show the dialog */
  const DialogLook &look = UIGlobals::GetDialogLook();
  WidgetDialog dialog(look);
  TwoWidgets widget(new LogoQuitWidget(look.button, dialog),
                    new StartupWidget(look, dialog, dfe));

  dialog.CreateFull(UIGlobals::GetMainWindow(), _T(""), &widget);

  const int result = dialog.ShowModal();
  dialog.StealWidget();

  return result == mrOK;
}