Example #1
0
        void ReadConfig()
        {
            if (!File.Exists("./config.ini"))
            {
                return;
            }
            IniReader ini = new IniReader("./config.ini");

            Serializer.DeserializeChk("Options", "removelog", chkRemove);
            Serializer.DeserializeChk("Options", "single_table", chkSingleTable);
            Serializer.DeserializeChk("Options", "one_hit_per_player", chkOneHitPerPlayer);
            Serializer.DeserializeCmb("Options", "sources", cmbSources);
            Serializer.DeserializeChk("Options", "load_on_update", chkLoadOnUpdate);
            Serializer.DeserializeChk("Options", "useblacklist", chkBlacklist);
            Serializer.DeserializeCmb("Options", "blacklistcolour", cmbBlacklistColor);
            Serializer.DeserializeChk("Options", "keeplatestlog", chkLogDeletionKeepLatest);
            Serializer.DeserializeChk("Options", "movelogs", chkMoveLogs);
            Serializer.DeserializeTextBox("Options", "movepath", txtLogMovePath);
            int tablefont = ini.IniReadInt("Options", "tablefont");

            // Filters
            Serializer.DeserializeChk("Filters", "alts", chkAlts);
            Serializer.DeserializeChk("Filters", "alt_based_on_name", chkAltBasedOnName);
            Serializer.DeserializeChk("Filters", "aggressive_ip_matching", chkAggressiveIpMatching);

            // Location filters
            Serializer.DeserializeChk("Filters", "town", chkInTown);
            Serializer.DeserializeChk("Filters", "base", chkInBase);
            Serializer.DeserializeChk("Filters", "tent", chkInTent);
            Serializer.DeserializeChk("Filters", "encounter", chkInEncounter);
            Serializer.DeserializeChk("Filters", "rawfilter", chkRawId);
            Serializer.DeserializeNum("Filters", "rawfilterid", numMapFilter);

            // Condition filters
            Serializer.DeserializeChk("Filters", "netstate", chkFilterNetstate);
            Serializer.DeserializeCmb("Filters", "netstateidx", cmbNetState);
            Serializer.DeserializeChk("Filters", "cond", chkFilterCond);
            Serializer.DeserializeCmb("Filters", "condidx", cmbCond);

            // IP
            Serializer.DeserializeChk("Filters", "ip", chkFilterIp);
            Serializer.DeserializeTextBox("Filters", "ipstring", txtIp);

            // Window
            int x           = ini.IniReadInt("Window", "x");
            int y           = ini.IniReadInt("Window", "y");
            int width       = ini.IniReadInt("Window", "width");
            int height      = ini.IniReadInt("Window", "height");
            int splitterpos = ini.IniReadInt("Window", "splitterpos");

            if (chkSingleTable.Checked)
            {
                splitContainer1.Panel1Collapsed = true;
            }

            if ((x > 0) && (y > 0))
            {
                this.Location = new Point(x, y);
            }
            if ((width > 0) && (height > 0))
            {
                this.Size = new Size(width, height);
            }

            splitContainer1.SplitterDistance = splitterpos;

            chkAggressiveIpMatching.Enabled = chkAlts.Checked;
            chkAltBasedOnName.Enabled       = chkAlts.Checked;

            cmbCond.Enabled     = chkFilterCond.Checked;
            cmbNetState.Enabled = chkFilterNetstate.Checked;

            txtIp.Enabled = chkFilterIp.Checked;

            if (tablefont > -1)
            {
                cmbFont.SelectedIndex = tablefont;
                SetFont(cmbFont.Text);
            }
        }
Example #2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            Utils.InitLog(".\\FOMonitor.log");

            System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection();
            foreach (FontFamily ff in ifc.Families)
            {
                cmbFont.Items.Add(ff.Name);
                if (ff.Name == "Tahoma")
                {
                    cmbFont.SelectedIndex = cmbFont.Items.Count - 1;
                }
            }

            IniReader Fo2238Config = new IniReader(".\\FOnline2238.cfg");

            logPath = Fo2238Config.IniReadValue("2238", "LogfileName");

            if (String.IsNullOrEmpty(logPath))
            {
                logPath = ".\\";
            }
            bool containsTag = containsLogTag(logPath);

            if (containsTag)
            {
                string   validPath = Path.GetPathRoot(logPath);
                string[] parts     = logPath.Split(Path.DirectorySeparatorChar);
                foreach (string part in parts)
                {
                    if (!containsLogTag(part))
                    {
                        validPath += part + Path.DirectorySeparatorChar;
                    }
                    else
                    {
                        break;
                    }
                }
                logExt           = Path.GetExtension(logPath);
                logPath          = validPath;
                lblLogsPath.Text = String.Format("Searching for logs in: {0} (defined in FOnline2238.cfg)", logPath);
            }

            List <string> Colors    = new List <string>(Enum.GetNames(typeof(System.Drawing.KnownColor)));
            Type          colorType = typeof(System.Drawing.Color);

            PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (System.Reflection.PropertyInfo c in propInfoList)
            {
                this.cmbBlacklistColor.Items.Add(c.Name);
            }

            this.Text = "FOMonitor " + version;
            this.cmbMapFilterRaw.SelectedIndex   = 0;
            this.cmbSources.SelectedIndex        = 0;
            this.cmbBlacklistColor.SelectedIndex = 0;
            this.cmbMatchMode.SelectedIndex      = 0;

            this.numMapFilter.Maximum = Int32.MaxValue;
            lblInstructions.Text      = "Use ~gameinfo 1 and press F2, then " + Environment.NewLine + "press update.";
            if (!File.Exists("FOnline.exe"))
            {
                MessageBox.Show("FOnline.exe not found." + Environment.NewLine +
                                "Please move this program to same directory as the fonline client", "FOMonitor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Serializer.Init();
            ReadConfig();
            RestoreTableState();
            if (File.Exists("./whitelist.txt"))
            {
                Whitelist = new Dictionary <int, string>();
                try
                {
                    List <string> lines = new List <string>(File.ReadAllLines("./whitelist.txt"));
                    Whitelist = Utils.ParseWhitelist(lines.ToArray());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to parse whitelist: " + ex.Message);
                }
            }
            else
            {
                File.Create("./whitelist.txt");
            }

            if (File.Exists("./blacklist.txt"))
            {
                Blacklist = new Dictionary <string, string>();
                try
                {
                    List <string> lines = new List <string>(File.ReadAllLines("./blacklist.txt"));
                    Blacklist = Utils.ParseBlacklist(lines.ToArray());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to parse blacklist: " + ex.Message);
                }
            }
            else
            {
                File.Create("./blacklist.txt");
            }
        }
Example #3
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            Utils.InitLog(".\\FOMonitor.log");

            System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection();
            foreach (FontFamily ff in ifc.Families)
            {
                cmbFont.Items.Add(ff.Name);
                if (ff.Name == "Tahoma")
                    cmbFont.SelectedIndex = cmbFont.Items.Count-1;
            }

            IniReader Fo2238Config = new IniReader(".\\FOnline2238.cfg");
            logPath = Fo2238Config.IniReadValue("2238", "LogfileName");

            if(String.IsNullOrEmpty(logPath))
                logPath = ".\\";
            bool containsTag = containsLogTag(logPath);

            if(containsTag)
            {
                string validPath = Path.GetPathRoot(logPath);
                string[] parts = logPath.Split(Path.DirectorySeparatorChar);
                foreach(string part in parts)
                {
                    if (!containsLogTag(part))
                        validPath += part + Path.DirectorySeparatorChar;
                    else
                        break;
                }
                logExt = Path.GetExtension(logPath);
                logPath = validPath;
                lblLogsPath.Text = String.Format("Searching for logs in: {0} (defined in FOnline2238.cfg)", logPath);
            }

            List<string> Colors = new List<string>(Enum.GetNames(typeof(System.Drawing.KnownColor)));
            Type colorType = typeof(System.Drawing.Color);
            PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (System.Reflection.PropertyInfo c in propInfoList)
                this.cmbBlacklistColor.Items.Add(c.Name);

            this.Text = "FOMonitor " + version;
            this.cmbMapFilterRaw.SelectedIndex = 0;
            this.cmbSources.SelectedIndex = 0;
            this.cmbBlacklistColor.SelectedIndex = 0;
            this.cmbMatchMode.SelectedIndex = 0;

            this.numMapFilter.Maximum = Int32.MaxValue;
            lblInstructions.Text = "Use ~gameinfo 1 and press F2, then " + Environment.NewLine + "press update.";
            if (!File.Exists("FOnline.exe"))
            {
                MessageBox.Show("FOnline.exe not found." + Environment.NewLine +
                    "Please move this program to same directory as the fonline client", "FOMonitor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Serializer.Init();
            ReadConfig();
            RestoreTableState();
            if (File.Exists("./whitelist.txt"))
            {
                Whitelist = new Dictionary<int, string>();
                try
                {
                    List<string> lines = new List<string>(File.ReadAllLines("./whitelist.txt"));
                    Whitelist = Utils.ParseWhitelist(lines.ToArray());
                }
                catch(Exception ex)
                {
                    MessageBox.Show("Failed to parse whitelist: " + ex.Message);
                }

            }
            else
                File.Create("./whitelist.txt");

            if (File.Exists("./blacklist.txt"))
            {
                Blacklist = new Dictionary<string, string>();
                try
                {
                    List<string> lines = new List<string>(File.ReadAllLines("./blacklist.txt"));
                    Blacklist = Utils.ParseBlacklist(lines.ToArray());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to parse blacklist: " + ex.Message);
                }

            }
            else
                File.Create("./blacklist.txt");
        }
Example #4
0
        void ReadConfig()
        {
            if (!File.Exists("./config.ini"))
                return;
            IniReader ini = new IniReader("./config.ini");
            Serializer.DeserializeChk("Options", "removelog", chkRemove);
            Serializer.DeserializeChk("Options", "single_table", chkSingleTable);
            Serializer.DeserializeChk("Options", "one_hit_per_player", chkOneHitPerPlayer);
            Serializer.DeserializeCmb("Options", "sources", cmbSources);
            Serializer.DeserializeChk("Options", "load_on_update", chkLoadOnUpdate);
            Serializer.DeserializeChk("Options", "useblacklist", chkBlacklist);
            Serializer.DeserializeCmb("Options", "blacklistcolour", cmbBlacklistColor);
            Serializer.DeserializeChk("Options", "keeplatestlog", chkLogDeletionKeepLatest);
            Serializer.DeserializeChk("Options", "movelogs", chkMoveLogs);
            Serializer.DeserializeTextBox("Options", "movepath", txtLogMovePath);
            int tablefont = ini.IniReadInt("Options", "tablefont");

            // Filters
            Serializer.DeserializeChk("Filters", "alts", chkAlts);
            Serializer.DeserializeChk("Filters", "alt_based_on_name", chkAltBasedOnName);
            Serializer.DeserializeChk("Filters", "aggressive_ip_matching", chkAggressiveIpMatching);

            // Location filters
            Serializer.DeserializeChk("Filters", "town", chkInTown);
            Serializer.DeserializeChk("Filters", "base", chkInBase);
            Serializer.DeserializeChk("Filters", "tent", chkInTent);
            Serializer.DeserializeChk("Filters", "encounter", chkInEncounter);
            Serializer.DeserializeChk("Filters", "rawfilter", chkRawId);
            Serializer.DeserializeNum("Filters", "rawfilterid", numMapFilter);

            // Condition filters
            Serializer.DeserializeChk("Filters", "netstate", chkFilterNetstate);
            Serializer.DeserializeCmb("Filters", "netstateidx", cmbNetState);
            Serializer.DeserializeChk("Filters", "cond", chkFilterCond);
            Serializer.DeserializeCmb("Filters", "condidx", cmbCond);

            // IP
            Serializer.DeserializeChk("Filters", "ip", chkFilterIp);
            Serializer.DeserializeTextBox("Filters", "ipstring", txtIp);

            // Window
            int x = ini.IniReadInt("Window", "x");
            int y = ini.IniReadInt("Window", "y");
            int width = ini.IniReadInt("Window", "width");
            int height = ini.IniReadInt("Window", "height");
            int splitterpos = ini.IniReadInt("Window", "splitterpos");

            if (chkSingleTable.Checked)
                splitContainer1.Panel1Collapsed = true;

            if ((x > 0)&&(y>0))
                this.Location = new Point(x,y);
            if ((width > 0) && (height > 0))
                this.Size = new Size(width, height);

            splitContainer1.SplitterDistance = splitterpos;

            chkAggressiveIpMatching.Enabled = chkAlts.Checked;
            chkAltBasedOnName.Enabled = chkAlts.Checked;

            cmbCond.Enabled = chkFilterCond.Checked;
            cmbNetState.Enabled = chkFilterNetstate.Checked;

            txtIp.Enabled = chkFilterIp.Checked;

            if (tablefont > -1)
            {
                cmbFont.SelectedIndex = tablefont;
                SetFont(cmbFont.Text);
            }
        }
Example #5
0
 public static void Init()
 {
     ini = new IniReader("./config.ini");
     if (!File.Exists("./config.ini"))
         File.CreateText("./config.ini");
 }