public GameBase(OsuMode mode = OsuMode.Unknown) { startupMode = mode; Instance = this; CrashHandler.Initialize(); //initialise config before everything, because it may be used in Initialize() override. Config = new pConfigManager(Instance.PathConfig + "osum.cfg"); Clock.USER_OFFSET = Config.GetValue("offset", 0); }
static void Main(string[] args) { SetConsoleCtrlHandler(cancelHandler, true); pConfigManager Config = new pConfigManager(@"IRC.cfg", true) { WriteOnChange = true }; Config.LoadConfig(@"IRC.cfg", true); string IRCAddress = Config.GetValue("IRCAddress", "irc.ppy.sh"); string IRCUsername = Config.GetValue("IRCUsername", "lslqtz"); string IRCPassword = Config.GetValue("IRCPassword", ""); int IRCConnectTimeout = Config.GetValue("IRCConnectTimeout", 10000); IRCChannels = Config.GetValue("Channels", "#osu").Split(','); Init(); //Database.ConnectionString = Config.GetValue("ConnectionString", Database.ConnectionString); IrcUserRegistrationInfo IRCUserRegistrationInfo = new IrcUserRegistrationInfo() { NickName = IRCUsername, UserName = IRCUsername, Password = IRCPassword }; IRCClient = new StandardIrcClient(); IRCClient.Registered += OnRegistered; IRCClient.Connected += OnConnected; IRCClient.ProtocolError += OnProtocolError; IRCClient.RawMessageSent += OnSentRawMessage; IRCClient.RawMessageReceived += OnReceivedRawMessage; using (var connectedEvent = new ManualResetEventSlim(false)) { IRCClient.Connected += (s, e) => connectedEvent.Set(); IRCClient.Connect(IRCAddress, false, IRCUserRegistrationInfo); if (!connectedEvent.Wait(IRCConnectTimeout)) { Console.WriteLine("Connection timed out."); Console.ReadKey(true); } while (true) { string str = ""; ConsoleKeyInfo NewKey = Console.ReadKey(true); while (NewKey.Key != ConsoleKey.Enter) { if (NewKey.Key == ConsoleKey.Backspace) { if (str.Length > 0) { str = str.Remove(str.Length - 1); } } else { str += NewKey.KeyChar; } InitTitle(((!string.IsNullOrEmpty(str)) ? string.Format("Current Content: {0}", str) : null)); NewKey = Console.ReadKey(true); } InitTitle(); string[] NewLine = str.Split(':'); if (NewLine.Length > 1) { string target = NewLine[0]; string text = string.Join(" ", NewLine, 1, NewLine.Length - 1); SendMessage(target, text); } str = ""; } } }