// Decompiled with JetBrains decompiler
// Type: FiestaLauncher.Services.LangService
// Assembly: FiestaOnline, Version=2019.5.22.0, Culture=neutral, PublicKeyToken=null
// MVID: 2FD5EB61-BC25-469D-997E-88998E849F6A
// Assembly location: C:\Users\marbo\Documents\Gamigo 2020 Client\FiestaOnline.exe

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Xml;

namespace FiestaLauncher.Services
{
  public static class LangService
  {
    private static readonly Dictionary<string, string> Strings = new Dictionary<string, string>();

    internal static void Add(string key, string val)
    {
      if (LangService.Strings.ContainsKey(key))
        LangService.Strings[key] = val;
      else
        LangService.Strings.Add(key, val);
    }

    internal static string Get(string key)
    {
      return !LangService.Strings.ContainsKey(key) ? "?" : LangService.Strings[key];
    }

    internal static void Set(string url)
    {
      try
      {
        string xml = new WebClient()
        {
          Encoding = Encoding.UTF8,
          Proxy = ((IWebProxy) null)
        }.DownloadString(url);
        XmlDocument xmlDocument = new XmlDocument();
        xmlDocument.LoadXml(xml);
        XmlNodeList xmlNodeList1 = xmlDocument.SelectNodes("FiestaLauncher/repatch");
        LangService.Add(xmlNodeList1[0].Name, xmlNodeList1[0].InnerText);
        XmlNodeList xmlNodeList2 = xmlDocument.SelectNodes("FiestaLauncher/up_to_date");
        LangService.Add(xmlNodeList2[0].Name, xmlNodeList2[0].InnerText);
        XmlNodeList xmlNodeList3 = xmlDocument.SelectNodes("FiestaLauncher/update_check");
        LangService.Add(xmlNodeList3[0].Name, xmlNodeList3[0].InnerText);
        XmlNodeList xmlNodeList4 = xmlDocument.SelectNodes("FiestaLauncher/downloading");
        LangService.Add(xmlNodeList4[0].Name, xmlNodeList4[0].InnerText);
        XmlNodeList xmlNodeList5 = xmlDocument.SelectNodes("FiestaLauncher/download_complete");
        LangService.Add(xmlNodeList5[0].Name, xmlNodeList5[0].InnerText);
        XmlNodeList xmlNodeList6 = xmlDocument.SelectNodes("FiestaLauncher/applying");
        LangService.Add(xmlNodeList6[0].Name, xmlNodeList6[0].InnerText);
        XmlNodeList xmlNodeList7 = xmlDocument.SelectNodes("FiestaLauncher/patch_finish");
        LangService.Add(xmlNodeList7[0].Name, xmlNodeList7[0].InnerText);
      }
      catch (Exception ex)
      {
        gFiestaLauncher.onCrash(ex);
      }
    }
  }
}
