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->ScanDirectoryTop(_T("*.prf"));
  dfe->Lookup(startProfileFile);
  wp->RefreshDisplay();

  if (dfe->GetNumFiles() <= 2) {
    delete wf;
    delete logo;
    return true;
  }

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

  const TCHAR *path = dfe->GetPathFile();
  if (!string_is_empty(path)) {
    _tcscpy(startProfileFile, path);

    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    TCHAR temp[MAX_PATH];
    SetPrimaryDataPath(DirName(path, temp));
  }

  delete wf;
  delete logo;
  return true;
}
Beispiel #2
0
static void
SelectProfile(const TCHAR *path)
{
  if (string_is_empty(path))
    return;

  Profile::SetFiles(path);

  /* When a profile from a secondary data path is used, this path
     becomes the primary data path */
  TCHAR temp[MAX_PATH];
  SetPrimaryDataPath(DirName(path, temp));
}
Beispiel #3
0
static void
SelectProfile(const TCHAR *path)
{
  if (StringIsEmpty(path))
    return;

  Profile::SetFiles(path);

  if (RelativePath(path) == nullptr) {
    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    TCHAR temp[MAX_PATH];
    SetPrimaryDataPath(DirName(path, temp));
  }

  File::Touch(path);
}
Beispiel #4
0
static bool
SelectProfile(Path path)
{
  try {
    if (!CheckProfilePasswordResult(CheckProfileFilePassword(path)))
      return false;
  } catch (const std::runtime_error &e) {
    ShowError(e, _("Password"));
    return false;
  }

  Profile::SetFiles(path);

  if (RelativePath(path) == nullptr)
    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    SetPrimaryDataPath(path.GetParent());

  File::Touch(path);
  return true;
}
Beispiel #5
0
void
CommandLine::Parse(Args &args)
{
  while (!args.IsEmpty()) {
    const char *s = args.GetNext();

    if (*s != '-') {
#ifdef _WIN32
      continue;
#else
      args.UsageError();
#endif
    }

    // Also accept "--" prefix for arguments. Usually used on UNIX for long options
    if (s[1] == '-')
      s++;

    if (strncmp(s, "-profile=", 9) == 0) {
      s += 9;
      PathName convert(s);
      Profile::SetFiles(convert);
    } else if (strncmp(s, "-datapath=", 10) == 0) {
      s += 10;
      PathName convert(s);
      SetPrimaryDataPath(convert);
    }
#ifdef SIMULATOR_AVAILABLE
    else if (strcmp(s, "-simulator") == 0) {
      global_simulator_flag = true;
      sim_set_in_cmd_line_flag = true;
    }
    else if (strcmp(s, "-fly") == 0) {
      global_simulator_flag=false;
      sim_set_in_cmd_line_flag=true;
    }
#endif
#if !defined(_WIN32_WCE)
    else if (isdigit(s[1])) {
      char *p;
      width = strtol(s+1, &p, 10);
      if (*p != 'x' && *p != 'X')
        args.UsageError();
      s = p;
      height = strtol(s+1, &p, 10);
    }
    else if (strcmp(s, "-portrait") == 0) {
      width = 480;
      height = 640;
    }
    else if (strcmp(s, "-square") == 0) {
      width = 480;
      height = 480;
    }
    else if (strcmp(s, "-small") == 0) {
      width = 320;
      height = 240;
    }
#endif
#ifdef HAVE_CMDLINE_FULLSCREEN
    else if (strcmp(s, "-fullscreen") == 0) {
      full_screen = true;
    }
#endif
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__WINE__)
    else if (strcmp(s, "-console") == 0) {
      AllocConsole();
      freopen("CONOUT$", "wb", stdout);
    }
#endif
#if !defined(ANDROID) && !defined(_WIN32_WCE)
    else if (strncmp(s, "-dpi=", 5) == 0) {
      unsigned x_dpi, y_dpi;
      char *p;
      x_dpi = strtol(s+5, &p, 10);
      if (*p == 'x' || *p == 'X') {
        s = p;
        y_dpi = strtol(s+1, &p, 10);
      } else
        y_dpi = x_dpi;

      if (x_dpi < 32 || x_dpi > 512 || y_dpi < 32 || y_dpi > 512)
        args.UsageError();

      Display::SetDPI(x_dpi, y_dpi);
    }
#endif
#ifndef _WIN32
    else
      args.UsageError();
#endif
  }

#if !defined(_WIN32_WCE)
  if (width < 240 || width > 4096 ||
      height < 240 || height > 4096)
    args.UsageError();
#endif
}