Exemple #1
0
 /// <summary>Write empty line.</summary>
 public virtual void WriteLine()
 {
     if (ShouldWrite(LogKind.Default))
     {
         WrappedLogger.WriteLine();
     }
 }
Exemple #2
0
 /// <summary>Write the text.</summary>
 /// <param name="logKind">Kind of text.</param>
 /// <param name="text">The text to write.</param>
 public virtual void Write(LogKind logKind, string text)
 {
     if (ShouldWrite(logKind))
     {
         WrappedLogger.Write(logKind, text);
     }
 }
Exemple #3
0
 /// <summary>Write the line.</summary>
 /// <param name="logKind">Kind of text.</param>
 /// <param name="text">The text to write.</param>
 public virtual void WriteLine(LogKind logKind, string text)
 {
     // DONTTOUCH: the order of calls in condition is important.
     if (PreprocessLine(text) || ShouldWrite(logKind))
     {
         WrappedLogger.WriteLine(logKind, text);
     }
 }
 /// <summary>Writes line.</summary>
 /// <param name="logKind">Kind of text.</param>
 /// <param name="text">The text to write.</param>
 public virtual void WriteLine(LogKind logKind, string text)
 {
     // DONTTOUCH: the order of calls in condition is important.
     // Preprocess call can change the _importantScopeCount value.
     if (PreprocessLine(text) || ShouldWrite(logKind))
     {
         WrappedLogger.WriteLine(logKind, text);
     }
 }
Exemple #5
0
        public TtyhClient(string masterUrl, string version, string ticket, HttpClient client, JsonSerializer serializer, ILogger logger)
        {
            _masterUrl = masterUrl;
            _version   = version;
            _ticket    = ticket;

            _client     = client;
            _serializer = serializer;
            _utf8       = new UTF8Encoding(false);
            _log        = new WrappedLogger(logger, "TtyhClient");
        }
        public ProfilesManager(string dataDirectory, JsonParser json, ILogger logger)
        {
            _json = json;
            _hashStringBuilder = new StringBuilder(40);
            _log = new WrappedLogger(logger, "Profiles");
            _log.Info("Initializing...");

            var dataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); // XDG_DATA_HOME

            _profilesPath = Path.Combine(dataPath, dataDirectory, ProfilesDirectory);
            _versionsPath = Path.Combine(dataPath, dataDirectory, VersionsDirectory);

            FindProfiles();
            _log.Info("Initialized!");
        }
Exemple #7
0
        public GameRunner(string dataDirectory, JsonParser json, ILogger logger, string launcherName, string launcherVersion)
        {
            _json      = json;
            _rawLogger = logger;
            _log       = new WrappedLogger(logger, "GameRunner");

            _launcherName    = launcherName;
            _launcherVersion = launcherVersion;

            var dataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); // XDG_DATA_HOME

            _profilesPath  = Path.Combine(dataPath, dataDirectory, ProfilesDirectory);
            _versionsPath  = Path.Combine(dataPath, dataDirectory, VersionsDirectory);
            _librariesPath = Path.Combine(dataPath, dataDirectory, LibrariesDirectory);
            _assetsPath    = Path.Combine(dataPath, dataDirectory, AssetsDirectory);
            _nativesPath   = Path.Combine(dataPath, dataDirectory, NativesDirectory);
        }
Exemple #8
0
        public Launcher(
            SettingsManager settings,
            VersionsManager versions,
            ProfilesManager profiles,
            HttpClient httpClient,
            TtyhClient ttyhClient,
            GameRunner runner,
            ILauncherUi ui,
            ILogger logger,
            string launcherName)
        {
            var translationsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Translations");

            _tr = new Translator(new Catalog("core", translationsPath));

            _settings = settings;
            _versions = versions;
            _profiles = profiles;

            _ttyhClient = ttyhClient;
            _runner     = runner;

            _hashChecker = new HashChecker(logger);
            _downloader  = new Downloader(httpClient, logger);

            _ui = ui;

            _logger        = logger;
            _logger.OnLog += _ui.AppendLog;

            _log = new WrappedLogger(logger, launcherName);

            _ui.OnExit += HandleExit;
            _ui.OnPlayButtonClicked += HandlePlayButtonClicked;
            _ui.OnOfflineModeToggle += HandleOfflineModeToggle;

            _ui.OnUploadSkinClicked += HandleSkinUploadClicked;

            _ui.OnEditProfileClicked   += HandleEditProfile;
            _ui.OnAddProfileClicked    += HandleAddProfile;
            _ui.OnRemoveProfileClicked += HandleRemoveProfile;
        }
Exemple #9
0
        public VersionsManager(string storeUrl, string dataDir, HttpClient client, JsonParser json, ILogger logger)
        {
            _storeUrl = storeUrl;
            _client   = client;
            _json     = json;
            _log      = new WrappedLogger(logger, "Versions");
            _log.Info("Initializing...");

            Prefixes = new CachedPrefixInfo[0];

            var dataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); // XDG_DATA_HOME

            _versionsPath  = Path.Combine(dataPath, dataDir, VersionsDirectory);
            _assetsPath    = Path.Combine(dataPath, dataDir, AssetsDirectory);
            _librariesPath = Path.Combine(dataPath, dataDir, LibrariesDirectory);

            _indexPath = Path.Combine(_versionsPath, IndexName);

            if (!Directory.Exists(_versionsPath))
            {
                Directory.CreateDirectory(_versionsPath);
            }

            if (File.Exists(_indexPath))
            {
                try {
                    _index = _json.ReadFile <PrefixesIndex>(_indexPath);
                }
                catch (JsonSerializationException e) {
                    _log.Error("Can't parse local prefixes index: " + e.Message);
                }
            }

            _index = _index ?? new PrefixesIndex();
            _log.Info($"Initialized with {_index.Prefixes.Count} prefix(es)!");
        }
Exemple #10
0
 public HashChecker(ILogger logger)
 {
     _log = new WrappedLogger(logger, "HashChecker");
 }
Exemple #11
0
 public Downloader(HttpClient client, ILogger logger)
 {
     _log    = new WrappedLogger(logger, "Downloader");
     _client = client;
 }