예제 #1
0
                /// <summary>
                /// Sets 'Other and event logging' to specified value in this config, 
                /// requires that no wurm clients are running, else will abort
                /// </summary>
                /// <param name="newValue"></param>
                /// <returns></returns>
                public bool SetCommonLoggingMode(EnumLoggingType newValue)
                {
                    try
                    {
                        if (State.WurmClientRunning == State.EnumWurmClientStatus.Running) return false;
                        if (newValue == EnumLoggingType.Unknown) return false;
                        //string replacementIRC = "irc_log_rotation=";  //irc is not used for anything and users may not like irc logging forced on them
                        string replacementOTHER = "other_log_rotation=";
                        string replacementEVENT = "event_log_rotation=";
                        if (newValue == EnumLoggingType.Never)
                        {
                            //replacementIRC += "0";
                            replacementOTHER += "0";
                            replacementEVENT += "0";
                        }
                        if (newValue == EnumLoggingType.OneFile)
                        {
                            //replacementIRC += "1";
                            replacementOTHER += "1";
                            replacementEVENT += "1";
                        }
                        if (newValue == EnumLoggingType.Monthly)
                        {
                            //replacementIRC += "2";
                            replacementOTHER += "2";
                            replacementEVENT += "2";
                        }
                        if (newValue == EnumLoggingType.Daily)
                        {
                            //replacementIRC += "3";
                            replacementOTHER += "3";
                            replacementEVENT += "3";
                        }
                        bool result = true;

                        //if (RewriteFile(@"irc_log_rotation=\d", replacementIRC))
                        //    _IrcLoggingType = newValue;
                        //else result = false;
                        if (RewriteFile(@"other_log_rotation=\d", replacementOTHER))
                            _OtherLoggingType = newValue;
                        else result = false;
                        if (RewriteFile(@"event_log_rotation=\d", replacementEVENT))
                            _EventLoggingType = newValue;
                        else result = false;

                        return result;
                    }
                    catch (Exception _e)
                    {
                        Logger.LogError("Error while modifying settings in wurm config file", this, _e);
                        return false;
                    }
                }
예제 #2
0
                void ProcessLine(string line)
                {
                    if (line.Contains("custim_timer_source"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _CustomTimerSource = EnumFileSource.ProfileFolder;
                        else if (val == 1) _CustomTimerSource = EnumFileSource.PlayerFolder;
                    }
                    else if (line.Contains("exec_source"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _ExecSource = EnumFileSource.ProfileFolder;
                        else if (val == 1) _ExecSource = EnumFileSource.PlayerFolder;
                    }
                    else if (line.Contains("key_bindings_source"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _KeyBindSource = EnumFileSource.ProfileFolder;
                        else if (val == 1) _KeyBindSource = EnumFileSource.PlayerFolder;
                    }
                    else if (line.Contains("auto_run_source"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _AutoRunSource = EnumFileSource.ProfileFolder;
                        else if (val == 1) _AutoRunSource = EnumFileSource.PlayerFolder;
                    }

                    else if (line.Contains("irc_log_rotation"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _IrcLoggingType = EnumLoggingType.Never;
                        else if (val == 1) _IrcLoggingType = EnumLoggingType.OneFile;
                        else if (val == 2) _IrcLoggingType = EnumLoggingType.Monthly;
                        else if (val == 3) _IrcLoggingType = EnumLoggingType.Daily;
                    }
                    else if (line.Contains("other_log_rotation"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _OtherLoggingType = EnumLoggingType.Never;
                        else if (val == 1) _OtherLoggingType = EnumLoggingType.OneFile;
                        else if (val == 2) _OtherLoggingType = EnumLoggingType.Monthly;
                        else if (val == 3) _OtherLoggingType = EnumLoggingType.Daily;
                    }
                    else if (line.Contains("event_log_rotation"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _EventLoggingType = EnumLoggingType.Never;
                        else if (val == 1) _EventLoggingType = EnumLoggingType.OneFile;
                        else if (val == 2) _EventLoggingType = EnumLoggingType.Monthly;
                        else if (val == 3) _EventLoggingType = EnumLoggingType.Daily;
                    }
                    else if (line.Contains("skillgain_minimum"))
                    {
                        int? val = ExtractSettingNumericValue(line);
                        if (val == 0) _SkillGainRate = EnumSkillGainRate.Never;
                        else if (val == 1) _SkillGainRate = EnumSkillGainRate.PerInteger;
                        else if (val == 2) _SkillGainRate = EnumSkillGainRate.Per0_1;
                        else if (val == 3) _SkillGainRate = EnumSkillGainRate.Per0_01;
                        else if (val == 4) _SkillGainRate = EnumSkillGainRate.per0_001;
                        else if (val == 5) _SkillGainRate = EnumSkillGainRate.Always;
                    }

                    else if (line.Contains("skillgain_no_alignment"))
                    {
                        bool? val = ExtractBoolValue(line);
                        if (val == true) _NoSkillMessageOnAlignmentChange = true;
                        else if (val == false) _NoSkillMessageOnAlignmentChange = false;
                    }
                    else if (line.Contains("skillgain_no_favor"))
                    {
                        bool? val = ExtractBoolValue(line);
                        if (val == true) _NoSkillMessageOnFavorChange = true;
                        else if (val == false) _NoSkillMessageOnFavorChange = false;
                    }
                    else if (line.Contains("save_skills_on_quit"))
                    {
                        bool? val = ExtractBoolValue(line);
                        if (val == true) _SaveSkillsOnQuit = true;
                        else if (val == false) _SaveSkillsOnQuit = false;
                    }
                    else if (line.Contains("setting_timestamps"))
                    {
                        bool? val = ExtractBoolValue(line);
                        if (val == true) _TimestampMessages = true;
                        else if (val == false) _TimestampMessages = false;
                    }
                }
예제 #3
0
 /// <summary>
 /// returns true if all 3 logging mode options are equal to the same value 
 /// and the value is present in argument array
 /// </summary>
 /// <param name="loggingModes"></param>
 /// <returns></returns>
 public bool EventAndOtherLoggingModesAreEqual(EnumLoggingType[] loggingModes)
 {
     if (EventLoggingType == OtherLoggingType) //&& OtherLoggingType == IrcLoggingType) // irc is not used for anything
     {
         if (loggingModes.Contains(EventLoggingType))
             return true;
     }
     return false;
 }