int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s NAME\n", argv[0]);
    return 1;
  }

#ifdef _UNICODE
  TCHAR name[1024];
  int length = ::MultiByteToWideChar(CP_ACP, 0, argv[1], -1, name, 1024);
  if (length == 0)
    return 2;
#else
  const char *name = argv[1];
#endif

  InitialiseDataPath();
  Profile::SetFiles(_T(""));
  Profile::Load();
  DeinitialiseDataPath();

  int value;
  if (Profile::Get(name, value)) {
    printf("%d\n", value);
    return 0;
  } else {
    fputs("No such value\n", stderr);
    return 2;
  }
}
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR lpCmdLine2,
        int nCmdShow)
#endif
{
  InitialiseDataPath();
  ScreenGlobalInit screen_init;

  LoadFiles();

  CreateDefaultTask(task_manager, way_points);

  SingleWindow main_window;
  main_window.set(_T("STATIC"), _T("RunTaskEditorDialog"),
                  0, 0, 640, 480);
  main_window.Show();

  Fonts::Initialize();

  dlgTaskOverviewShowModal(main_window);

  Fonts::Deinitialize();
  DeinitialiseDataPath();

  return 0;
}
Exemple #3
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        LPWSTR lpCmdLine,
#else
        LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
  Airspaces airspace_database;
  AirspaceWarningManager airspace_warning(airspace_database);
  airspace_warnings = new ProtectedAirspaceWarningManager(airspace_warning);

  InitialiseDataPath();
  ScreenGlobalInit screen_init;

#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  LoadFiles(airspace_database);

  Fonts::Initialize();

  Airspaces::AirspaceTree::const_iterator it = airspace_database.begin();

  AirspaceInterceptSolution ais;
  for (unsigned i = 0; i < 5 && it != airspace_database.end(); ++i, ++it)
    airspace_warning.GetWarning(*it->get_airspace())
      .UpdateSolution((AirspaceWarning::State)i, ais);

  SingleWindow main_window;
  main_window.set(_T("STATIC"), _T("RunAirspaceWarningDialog"),
                  0, 0, 640, 480);
  main_window.show();

  Layout::Initialize(640, 480);

  Fonts::Initialize();

  DialogLook dialog_look;
  dialog_look.Initialise(Fonts::map_bold, Fonts::map,
                         Fonts::map_bold, Fonts::map_bold);
  SetXMLDialogLook(dialog_look);

  dlgAirspaceWarningsShowModal(main_window, *airspace_warnings);

  Fonts::Deinitialize();
  DeinitialiseDataPath();

  delete airspace_warnings;

  return 0;
}
int main(int argc, char **argv) {
  Args args(argc, argv, "NAME");
  const char *name = args.ExpectNext();
  args.ExpectEnd();

  InitialiseDataPath();
  Profile::SetFiles(nullptr);
  Profile::Load();
  DeinitialiseDataPath();

  const char *value = Profile::Get(name);
  if (value != NULL) {
    puts(value);
    return 0;
  } else {
    fputs("No such value\n", stderr);
    return 2;
  }
}
int main(int argc, char **argv) {
  Args args(argc, argv, "NAME");
  tstring name = args.ExpectNextT();
  args.ExpectEnd();

  InitialiseDataPath();
  Profile::SetFiles(_T(""));
  Profile::Load();
  DeinitialiseDataPath();

  const TCHAR *value = Profile::Get(name.c_str());
  if (value != NULL) {
    _putts(value);
    return 0;
  } else {
    fputs("No such value\n", stderr);
    return 2;
  }
}
Exemple #6
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        gcc_unused LPWSTR lpCmdLine,
#else
        gcc_unused LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  Net::Initialise();

  InitialiseDataPath();
  StartupLogFreeRamAndStorage();

  // Write startup note + version to logfile
  LogStartUp(_T("Starting XCSoar %s"), XCSoar_ProductToken);

  // Read options from the command line
#ifndef WIN32
  CommandLine::Parse(Args(argc, argv, Usage));
#else
  CommandLine::Parse(Args(GetCommandLine(), Usage));
#endif

  ScreenGlobalInit screen_init;

  // Write initialization note to logfile
  LogStartUp(_T("Initialise application instance"));

#ifdef WIN32
  /* try to make the UI most responsive */
  SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif

  // Register window classes
#ifdef USE_GDI
  MainWindow::register_class(hInstance);
#endif

  AllowLanguage();

  InitialiseIOThread();

  // Perform application initialization and run loop
  int ret = EXIT_FAILURE;
  if (XCSoarInterface::Startup())
    ret = CommonInterface::main_window.RunEventLoop();

  CommonInterface::main_window.reset();

  DeinitialiseIOThread();

  DisallowLanguage();

  Fonts::Deinitialize();

  DeinitialiseDataPath();
  Net::Deinitialise();

  assert(!ExistsAnyThread());

  return ret;
}
Exemple #7
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        LPWSTR lpCmdLine,
#else
        LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
#ifdef ENABLE_CMDLINE
#ifdef WIN32
  Args args(GetCommandLine(), USAGE);
#else
  Args args(argc, argv, USAGE);
#endif
  ParseCommandLine(args);
  args.ExpectEnd();
#endif

#if defined(ENABLE_RESOURCE_LOADER) && defined(USE_GDI)
  ResourceLoader::Init(hInstance);
#endif

#ifdef ENABLE_SCREEN
  ScreenGlobalInit screen_init;
  Layout::Initialize(640, 480);
  InitialiseFonts();
#endif

#ifdef ENABLE_DIALOG
  dialog_settings.SetDefaults();
#endif

#ifdef ENABLE_LOOK
  look = new Look();
  look->Initialise(normal_font, bold_font, small_font);

  {
    UISettings ui_settings;
    ui_settings.SetDefaults();
    look->InitialiseConfigured(ui_settings,
                               normal_font, bold_font, small_font,
                               small_font, monospace_font,
                               normal_font, small_font,
#ifndef GNAV
                               small_font,
#endif
                               small_font);
  }

  dialog_look = &look->dialog;
#elif defined(ENABLE_DIALOG_LOOK)
  dialog_look = new DialogLook();
  dialog_look->Initialise(bold_font, normal_font, small_font,
                          bold_font, bold_font, bold_font);
#endif

#ifdef ENABLE_XML_DIALOG
  SetXMLDialogLook(*dialog_look);
#endif

#ifdef ENABLE_DATA_PATH
  InitialiseDataPath();
#endif

#ifdef ENABLE_PROFILE
  Profile::SetFiles(_T(""));
  Profile::Load();
#endif

#ifdef ENABLE_MAIN_WINDOW
  main_window.Create(_T("Test"), {640, 480});
  main_window.Show();
#endif

  Main();

#ifdef ENABLE_MAIN_WINDOW
  main_window.Destroy();
#endif

#ifdef ENABLE_DATA_PATH
  DeinitialiseDataPath();
#endif

#ifdef ENABLE_LOOK
  delete look;
#elif defined(ENABLE_DIALOG_LOOK)
  delete dialog_look;
#endif

#ifdef ENABLE_SCREEN
  DeinitialiseFonts();
#endif

  return 0;
}
Exemple #8
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR lpCmdLine2,
        int nCmdShow)
#endif
{
#if defined(ENABLE_CMDLINE) || defined(ENABLE_MAIN_WINDOW)
#ifdef WIN32
  Args args(GetCommandLine(), USAGE);
#else
  Args args(argc, argv, USAGE);
#endif
#ifdef ENABLE_MAIN_WINDOW
  PixelSize window_size{640, 480};
  const char *a = args.PeekNext();
  if (a != nullptr && a[0] == '-' && IsDigitASCII(a[1])) {
    args.GetNext();
    char *p;
    window_size.cx = ParseUnsigned(a + 1, &p);
    if (*p != 'x' && *p != 'X')
      args.UsageError();
    a = p;
    window_size.cy = ParseUnsigned(a + 1, &p);
    if (*p != '\0')
      args.UsageError();
  }
#endif
#ifdef ENABLE_CMDLINE
  ParseCommandLine(args);
#endif
  args.ExpectEnd();
#endif

#if defined(ENABLE_RESOURCE_LOADER) && defined(USE_GDI)
  ResourceLoader::Init(hInstance);
#endif

#ifdef ENABLE_SCREEN
#ifndef ENABLE_MAIN_WINDOW
  constexpr PixelSize window_size{800, 600};
#endif

  ScreenGlobalInit screen_init;
  Layout::Initialize(window_size);
  InitialiseFonts();
#endif

#ifdef ENABLE_DIALOG
  dialog_settings.SetDefaults();
#endif

#ifdef ENABLE_LOOK
  look = new Look();
  look->Initialise(normal_font);

  {
    UISettings ui_settings;
    ui_settings.SetDefaults();
    look->InitialiseConfigured(ui_settings,
                               normal_font, bold_font,
                               100);
  }

  dialog_look = &look->dialog;
  button_look = &dialog_look->button;
#elif defined(ENABLE_DIALOG_LOOK)
  dialog_look = new DialogLook();
  dialog_look->Initialise();
  button_look = &dialog_look->button;
#elif defined(ENABLE_BUTTON_LOOK)
  button_look = new ButtonLook();
  button_look->Initialise(bold_font);
#endif

#ifdef ENABLE_DATA_PATH
  InitialiseDataPath();
#endif

#ifdef ENABLE_PROFILE
  Profile::SetFiles(_T(""));
  Profile::Load();
#endif

#ifdef ENABLE_MAIN_WINDOW
  main_window.Create(_T("Test"), window_size);
  main_window.Show();
#endif

  Main();

#ifdef ENABLE_MAIN_WINDOW
  main_window.Destroy();
#endif

#ifdef ENABLE_DATA_PATH
  DeinitialiseDataPath();
#endif

#ifdef ENABLE_LOOK
  delete look;
#elif defined(ENABLE_DIALOG_LOOK)
  delete dialog_look;
#elif defined(ENABLE_BUTTON_LOOK)
  delete button_look;
#endif

#ifdef ENABLE_SCREEN
  DeinitialiseFonts();
#endif

  return 0;
}
Exemple #9
0
gcc_visibility_default
JNIEXPORT jboolean JNICALL
Java_org_xcsoar_NativeView_initializeNative(JNIEnv *env, jobject obj,
                                            jobject _context,
                                            jint width, jint height,
                                            jint xdpi, jint ydpi,
                                            jint sdk_version, jstring product)
{
  android_api_level = sdk_version;

  InitThreadDebug();

  InitialiseIOThread();

  Java::Init(env);
  Java::Object::Initialise(env);
  Java::File::Initialise(env);
  Java::InputStream::Initialise(env);
  Java::URL::Initialise(env);
  Java::URLConnection::Initialise(env);

  NativeView::Initialise(env);
  Environment::Initialise(env);
  AndroidBitmap::Initialise(env);
  InternalSensors::Initialise(env);
  NativePortListener::Initialise(env);
  NativeInputListener::Initialise(env);
  PortBridge::Initialise(env);
  BluetoothHelper::Initialise(env);
  NativeLeScanCallback::Initialise(env);
  IOIOHelper::Initialise(env);
  NativeBMP085Listener::Initialise(env);
  BMP085Device::Initialise(env);
  NativeI2CbaroListener::Initialise(env);
  I2CbaroDevice::Initialise(env);
  NativeNunchuckListener::Initialise(env);
  NunchuckDevice::Initialise(env);
  NativeVoltageListener::Initialise(env);
  VoltageDevice::Initialise(env);

  context = new Context(env, _context);

  InitialiseDataPath();

  LogFormat(_T("Starting XCSoar %s"), XCSoar_ProductToken);

  OpenGL::Initialise();
  TextUtil::Initialise(env);

  assert(native_view == nullptr);
  native_view = new NativeView(env, obj, width, height, xdpi, ydpi,
                               product);
#ifdef __arm__
  is_nook = StringIsEqual(native_view->GetProduct(), "NOOK");
#endif

  event_queue = new EventQueue();

  SoundUtil::Initialise(env);
  Vibrator::Initialise(env);
  vibrator = Vibrator::Create(env, *context);

  ioio_helper = new IOIOHelper(env);

#ifdef __arm__
  if (IsNookSimpleTouch()) {
    is_dithered = Nook::EnterFastMode();

    /* enable USB host mode if this is a Nook */
    Nook::InitUsb();
  }
#endif

  ScreenInitialized();
  AllowLanguage();
  InitLanguage();
  return Startup();
}
Exemple #10
0
gcc_visibility_default
JNIEXPORT jboolean JNICALL
Java_org_xcsoar_NativeView_initializeNative(JNIEnv *env, jobject obj,
                                            jobject _context,
                                            jint width, jint height,
                                            jint xdpi, jint ydpi,
                                            jint sdk_version, jstring product)
{
  InitThreadDebug();

  InitialiseIOThread();

  Java::Init(env);
  Java::File::Initialise(env);
  Java::InputStream::Initialise(env);
  Java::URL::Initialise(env);
  Java::URLConnection::Initialise(env);

  Environment::Initialise(env);
  InternalSensors::Initialise(env);
  NativeInputListener::Initialise(env);
  PortBridge::Initialise(env);
  BluetoothHelper::Initialise(env);
#ifdef IOIOLIB
  IOIOHelper::Initialise(env);
  NativeBMP085Listener::Initialise(env);
  BMP085Device::Initialise(env);
  NativeI2CbaroListener::Initialise(env);
  I2CbaroDevice::Initialise(env);
  NativeNunchuckListener::Initialise(env);
  NunchuckDevice::Initialise(env);
  NativeVoltageListener::Initialise(env);
  VoltageDevice::Initialise(env);
#endif

  context = new Context(env, _context);

  InitialiseDataPath();

  LogFormat(_T("Starting XCSoar %s"), XCSoar_ProductToken);

  OpenGL::Initialise();
  TextUtil::Initialise(env);

  assert(native_view == NULL);
  native_view = new NativeView(env, obj, width, height, xdpi, ydpi,
                               sdk_version, product);

  event_queue = new EventQueue();

  SoundUtil::Initialise(env);
  Vibrator::Initialise(env);
  vibrator = Vibrator::Create(env, *context);

#ifdef IOIOLIB
  ioio_helper = new IOIOHelper(env);
#endif

  ScreenInitialized();
  AllowLanguage();
  return Startup();
}
Exemple #11
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        gcc_unused LPWSTR lpCmdLine,
#else
        gcc_unused LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  Net::Initialise();

  InitialiseDataPath();
  StartupLogFreeRamAndStorage();

  // Write startup note + version to logfile
  LogFormat(_T("Starting XCSoar %s"), XCSoar_ProductToken);

  // Read options from the command line
  {
#ifdef WIN32
    Args args(GetCommandLine(), Usage);
#else
    Args args(argc, argv, Usage);
#endif
    CommandLine::Parse(args);
  }

  ScreenGlobalInit screen_init;

#ifdef WIN32
  /* try to make the UI most responsive */
  SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif

  AllowLanguage();

  InitialiseIOThread();

  // Perform application initialization and run loop
  int ret = EXIT_FAILURE;
  if (Startup())
    ret = CommonInterface::main_window->RunEventLoop();

  if (CommonInterface::main_window != nullptr) {
    CommonInterface::main_window->Destroy();
    delete CommonInterface::main_window;
  }

  DeinitialiseIOThread();

  DisallowLanguage();

  Fonts::Deinitialize();

  DeinitialiseDataPath();
  Net::Deinitialise();

  assert(!ExistsAnyThread());

  return ret;
}
Exemple #12
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        LPWSTR lpCmdLine,
#else
        LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
  InitialiseDataPath();
  Profile::SetFiles(_T(""));
  Profile::Load();

  ComputerSettings settings_computer;
  settings_computer.SetDefaults();
  Profile::Load(settings_computer);

  MapSettings settings_map;
  settings_map.SetDefaults();
  Profile::Load(settings_map);

  LoadFiles(settings_computer.poi, settings_computer.team_code);

  ScreenGlobalInit screen_init;

#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  MapLook *map_look = new MapLook();
  map_look->Initialise(settings_map, Fonts::map, Fonts::map_bold);

  TrafficLook *traffic_look = new TrafficLook();
  traffic_look->Initialise();

  TestWindow window(*map_look, *traffic_look);
  window.Create({640, 480});

  GenerateBlackboard(window.map, settings_computer, settings_map);
  Fonts::Initialize();
#ifdef ENABLE_OPENGL
  DrawThread::UpdateAll(window.map);
#else
  DrawThread::Draw(window.map);
  window.initialised = true;
#endif
  window.Show();

  window.RunEventLoop();
  window.Destroy();

  Fonts::Deinitialize();

  delete terrain;
  delete topography;
  delete traffic_look;
  delete map_look;

  DeinitialiseDataPath();

  return 0;
}
Exemple #13
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        LPWSTR lpCmdLine,
#else
        LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
#ifdef WIN32
  Args args(GetCommandLine(), "DRIVER FILE");
#else
  Args args(argc, argv, "DRIVER FILE");
#endif
  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == NULL)
    return EXIT_FAILURE;

  args.ExpectEnd();

  InitialiseDataPath();
  Profile::SetFiles(_T(""));
  Profile::Load();

  const Waypoints way_points;

  InterfaceBlackboard blackboard;
  blackboard.SetComputerSettings().SetDefaults();

  GlideComputerTaskEvents task_events;
  TaskManager task_manager(way_points);
  task_manager.SetTaskEvents(task_events);

  Airspaces airspace_database;
  AirspaceWarningManager airspace_warning(airspace_database);

  ProtectedTaskManager protected_task_manager(task_manager,
                                              blackboard.GetComputerSettings().task);

  LoadFiles(airspace_database);

  GlideComputer glide_computer(way_points, airspace_database,
                               protected_task_manager,
                               task_events);
  glide_computer.SetTerrain(terrain);
  glide_computer.Initialise();
  glide_computer.ReadComputerSettings(blackboard.GetComputerSettings());

  ScreenGlobalInit screen_init;

  LoadReplay(replay, glide_computer, blackboard);
  delete replay;

#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  Layout::Initialize(640, 480);

  SingleWindow main_window;
  main_window.set(_T("STATIC"), _T("RunAnalysis"),
                  PixelRect{0, 0, 640, 480});

  Fonts::Initialize();

  dialog_settings.SetDefaults();

  Look *look = new Look();
  look->Initialise();
  look->InitialiseConfigured(blackboard.GetUISettings());

  SetXMLDialogLook(look->dialog);

  dialog_look = &look->dialog;

  main_window.show();

  dlgAnalysisShowModal(main_window, *look, blackboard, glide_computer,
                       &protected_task_manager,
                       &airspace_database,
                       terrain);

  delete look;
  Fonts::Deinitialize();

  delete terrain;

  DeinitialiseDataPath();

  return 0;
}