Exemple #1
0
 void CLaunchThread::uninit()
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    initDb(0);
    initLauncher(0);
    initRequestHandler(0);
 }
void launcherApplication::initialise(const String& commandLine)
{
    File appDataDirectory(File::getSpecialLocation(File::userApplicationDataDirectory));
    
   #if defined(JUCE_LINUX) || defined(JUCE_BSD)
    settingsDirectory = appDataDirectory.getChildFile(".tremulous");
   #elif defined(JUCE_WINDOWS)
    settingsDirectory = appDataDirectory.getChildFile("Tremulous");
   #elif defined(JUCE_MAC)
    settingsDirectory = appDataDirectory.getChildFile("Application Support").getChildFile("Tremulous");
   #endif

    File logFile(settingsDirectory.getChildFile("launcher.log"));
    logger = new FileLogger(logFile, ProjectInfo::projectName, 0);
    Logger::setCurrentLogger(logger);

    // TODO: Parse arguments
    StringArray commandLineArray(getCommandLineParameterArray());
    for (int i = 0; i < commandLineArray.size(); i++) {
      Logger::writeToLog(String("arg") + String(i) + String(": ") + commandLineArray[i]);
    }

    config = new IniFile(settingsDirectory.getChildFile("launcher.ini"));

    File defaultBasepath;
    File defaultHomepath(settingsDirectory);

   #if defined(JUCE_LINUX) || defined(JUCE_BSD)
    defaultBasepath = "/usr/local/games/tremulous";
   #elif defined(JUCE_MAC) || defined(JUCE_WINDOWS)
    defaultBasepath = File::getSpecialLocation(File::globalApplicationsDirectory).getChildFile("Tremulous");
   #endif

    config->setDefault("general", "overpath", defaultBasepath.getFullPathName());
    config->setDefault("general", "basepath", defaultBasepath.getFullPathName());
    config->setDefault("general", "homepath", defaultHomepath.getFullPathName());

    config->setDefault("updater", "downloads", defaultBasepath.getChildFile("updater").getChildFile("downloads").getFullPathName());

  #if defined(JUCE_LINUX)
   #if __x86_64__
    String defaultPlatform("linux64");
   #else
    String defaultPlatform("linux32");
   #endif
  #elif defined(JUCE_BSD) && defined(__FreeBSD__)
   #if __x86_64__
    String defaultPlatform("freebsd64");
   #else
    String defaultPlatform("freebsd32");
   #endif
  #elif defined(JUCE_MAC)
    String defaultPlatform("mac");
  #elif defined(JUCE_WINDOWS)
   #if _WIN64 || __x86_64__
    String defaultPlatform("win64");
   #else
    String defaultPlatform("win32");
   #endif
  #endif

    config->setDefault("updater", "platform", defaultPlatform);
    config->setDefault("updater", "channel", "release");
    config->setDefault("updater", "checkForUpdates", 1);
    config->setDefault("updater", "verifySignature", 1);

    LookAndFeel *laf = &LookAndFeel::getDefaultLookAndFeel();
    laf->setColour(AlertWindow::backgroundColourId, Colour(0xFF111111));
    laf->setColour(AlertWindow::textColourId, Colour(0xFFFFFFFF));
    laf->setColour(AlertWindow::outlineColourId, Colour(0xFF333333));

    laf->setColour(TextButton::buttonColourId, Colour(0xFF333333));
    laf->setColour(TextButton::textColourOffId, Colour(0xFFFFFFFF));

    // Delete old launcher if it exists
    File launcherPath(File::getSpecialLocation(File::SpecialLocationType::currentApplicationFile));
    File oldLauncherPath(launcherPath.getFullPathName() + ".old");
    oldLauncherPath.deleteFile();

    initLauncher();
}