﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace TIASshot {
    internal static class Config {
        static string configFile = "config.xml";
        static XmlDocument doc = new XmlDocument();

        public static void Load() {
            doc.Load(configFile);
        }

        public static float GetFloat(string param) {
            float value = 0.0f;
            XmlNode node = doc.SelectSingleNode($"//Config/{param}");

            if (node != null && float.TryParse(node.InnerText, out float result)) {
                value = result;
            }
            return value;
        }

        public static int GetInt(string param) {
            int value = 0;
            XmlNode node = doc.SelectSingleNode($"//Config/{param}");

            if (node != null && int.TryParse(node.InnerText, out int result)) {
                value = result;
            }
            return value;
        }
    }
}
