示例#1
0
        private void buttoneHomeUpdate_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.GamePath))
            {
                if (Properties.Settings.Default.Backup)
                {
                    ModFunctions.generateBackup(Properties.Settings.Default.GamePath);
                }
                switch (selectedMod)
                {
                case "The Other Roles":
                    TheOtherRoles.TheOtherRoles.updateTheOtherRoles(this, Properties.Settings.Default.GamePath);
                    break;
                }
            }
            else
            {
                DialogResult response = MessageBoxFunctions.openMessageBoxWithResponse("No play path was given. Please enter it under the settings. Would you like to be redirected to the settings?", "Error");

                if (response == DialogResult.Yes)
                {
                    settingsButton.PerformClick();
                }
            }
        }
示例#2
0
        public static async void getTheOtherRoles(dynamic mainWindow)
        {
#if DEBUG
            Properties.Settings.Default.ReleaseId = null;
            Properties.Settings.Default.GamePath  = null;
            Properties.Settings.Default.Save();
#endif
            dynamic json = await ModFunctions.getModData(projectApi);

            downloadUrl      = json.assets[0].browser_download_url;
            releaseName      = json.name;
            currentReleaseId = json.assets[0].id.ToString();

            if (string.IsNullOrWhiteSpace(Properties.Settings.Default.ReleaseId))
            {
                mainWindow.buttonHomeInstall.Visible = true;
                mainWindow.buttonHomeStart.Visible   = false;
                mainWindow.buttonHomeUpdate.Visible  = false;
            }
            else if (Properties.Settings.Default.ReleaseId == currentReleaseId)
            {
                mainWindow.buttonHomeInstall.Visible = false;
                mainWindow.buttonHomeStart.Visible   = true;
                mainWindow.buttonHomeUpdate.Visible  = false;
            }
            else
            {
                mainWindow.buttonHomeInstall.Visible = false;
                mainWindow.buttonHomeStart.Visible   = false;
                mainWindow.buttonHomeUpdate.Visible  = true;
            }
        }
        public async static Task <string> checkVersionsUpdate(dynamic mainWindow)
        {
            dynamic json = await ModFunctions.getModData(projectUrl);

            if (Application.ProductVersion != json.tag_name.ToString().Replace("v", ""))
            {
                mainWindow.newVersionButton.Visible = true;
                return(json.assets[0].browser_download_url);
            }
            return(null);
        }
示例#4
0
            private void DrawCleanCollectionButton()
            {
                if (ImGui.Button("Clean Settings"))
                {
                    var changes = ModFunctions.CleanUpCollection(_manager.Collections.CurrentCollection.Settings,
                                                                 _manager.BasePath.EnumerateDirectories());
                    _manager.Collections.CurrentCollection.UpdateSettings(changes);
                }

                ImGuiCustom.HoverTooltip(
                    "Remove all stored settings for mods not currently available and fix invalid settings.\nUse at own risk.");
            }
示例#5
0
        private void buttonHomeStart_Click(object sender, EventArgs e)
        {
            switch (selectedMod)
            {
            case "The Other Roles":
                TheOtherRoles.TheOtherRoles.startTheOtherRoles(this);
                break;

            default:
                ModFunctions.startGame(Properties.Settings.Default.GamePath, true, this);
                break;
            }
        }
示例#6
0
        public static async void updateTheOtherRoles(dynamic mainWindow, string rootPath)
        {
            mainWindow.buttonHomeUpdate.Enabled = false;
            if (deleteOldFiles(rootPath).Result)
            {
                //Create Mod Folder
                Properties.Settings.Default.ReleaseId = currentReleaseId;
                Properties.Settings.Default.Save();
                string gamePath = Properties.Settings.Default.GamePath;
                Directory.CreateDirectory(gamePath);

                await SystemFunctions.copyFolder(rootPath, gamePath);

                mainWindow.downloadProgress.Visible = true;


                //Download Mod
                string zipPath = Properties.Settings.Default.GamePath + "\\" + releaseName + ".zip";
                await ModFunctions.downloadNewVersion(downloadUrl, zipPath, mainWindow);

                ZipFile.ExtractToDirectory(zipPath, Properties.Settings.Default.GamePath);

                if (!Directory.Exists(Properties.Settings.Default.GamePath + "\\BepInex\\config"))
                {
                    Directory.CreateDirectory(Properties.Settings.Default.GamePath + "\\BepInex\\config");
                }
                if (configControll)
                {
                    var _tmpCheck = false;
                    do
                    {
                        if (File.Exists(Properties.Settings.Default.GamePath + "\\me.eisbison.theotherroles.cfg"))
                        {
                            File.Copy(Properties.Settings.Default.GamePath + "\\me.eisbison.theotherroles.cfg", Properties.Settings.Default.GamePath + "\\BepInex\\config\\me.eisbison.theotherroles.cfg", true);
                            _tmpCheck = true;
                            Logger.Log("File copy successed (z329)", null);
                        }
                        else
                        {
                            Logger.Log("Waiting for copy (z333)", null);
                            Thread.Sleep(100);
                        }
                    } while (!_tmpCheck);
                }

                mainWindow.buttonHomeInstall.Visible = false;
                mainWindow.buttonHomeUpdate.Visible  = false;
                mainWindow.buttonHomeStart.Visible   = true;
                mainWindow.downloadProgress.Visible  = false;

                if (File.Exists(rootPath + "\\me.eisbison.theotherroles.cfg"))
                {
                    File.Delete(rootPath + "\\me.eisbison.theotherroles.cfg");
                }
                if (File.Exists(Properties.Settings.Default.GamePath + "\\me.eisbison.theotherroles.cfg"))
                {
                    File.Delete(Properties.Settings.Default.GamePath + "\\me.eisbison.theotherroles.cfg");
                }
                if (File.Exists(Properties.Settings.Default.GamePath + "\\" + releaseName + ".zip"))
                {
                    File.Delete(Properties.Settings.Default.GamePath + "\\" + releaseName + ".zip");
                }

                mainWindow.buttonHomeInstall.Enabled = true;
                mainWindow.buttonHomeUpdate.Enabled  = true;

                DialogResult messageBoxResponse = MessageBoxFunctions.openMessageBoxWithResponse("The mod has been successfully updated. Would you like to start the game now?", "Update finished");

                if (messageBoxResponse == DialogResult.Yes)
                {
                    startTheOtherRoles(mainWindow);
                }
            }
        }
示例#7
0
 public static void startTheOtherRoles(dynamic mainWindow)
 {
     mainWindow.buttonHomeStart.Enabled = false;
     ModFunctions.startGame(Properties.Settings.Default.GamePath, checkInstallation(), mainWindow);
 }
示例#8
0
        public static void OnChannelMessage(object sender, IrcEventArgs e)
        {
            // Active Flags
            User u = null;

            lock (Users.All)
            {
                u = Users.All.Find(x => x.Name.Equals(e.Data.Nick.ToLower()));
            }
            if (u == null)
            {
                u = CreateUser(e.Data.Nick, false);
            }

            u.LastActive = DateTime.Now;
            u.IncrementVotes();
            LastInteraction = DateTime.Now;

            Log(e.Data.Nick + ": " + e.Data.Message);
            if (!_logform.InputEnabled)
            {
                return;                         // Disable Voting UI Flag
            }
            // Website Filters
            string[] explicit_blacklist = { "dotcom", "(dot)", "░", "█" };
            foreach (string m in explicit_blacklist)
            {
                if (e.Data.Message.ToLower().Contains(m))
                {
                    BanUser(u, false, "filter evasion / Unicode art");
                    return;
                }
            }

            Regex         filter           = new Regex(@"[A-z0-9-]+(?:\.[A-z]{2,3})+", RegexOptions.RightToLeft);
            string        stripped_message = Regex.Replace(e.Data.Message, @"[()]", "");
            bool          is_clean         = true;
            List <string> dirty_matches    = new List <string>();

            foreach (Match m in filter.Matches(stripped_message))
            {
                WebsiteFilter website_filter = WebsiteFilters.Find(x => x.Domain.Equals(m.Value));
                if (website_filter != null)
                {
                    if (website_filter.Type == WebsiteFilter.FilterType.BLACKLIST)
                    {
                        BanUser(u, false, "blacklisted website: '" + m.Value + "'");
                    }
                    return;
                }
                else
                {
                    is_clean = false;
                    dirty_matches.Add(m.Value);
                }
            }
            if (!is_clean)
            {
                BanUser(u, true, "unlisted website(s): " + String.Join(", ", dirty_matches));
                return;
            }

            Nominee keyNominee = null;
            string  command    = e.Data.Message.ToUpper();
            bool    downvote   = false;

            if (command.StartsWith("NO") || command.StartsWith("-"))
            {
                downvote = true;
                if (command.StartsWith("NOT"))
                {
                    command = command.Substring(3);
                }
                else if (command.StartsWith("NO"))
                {
                    command = command.Substring(2);
                }
                else if (command.StartsWith("-"))
                {
                    command = command.Substring(1);
                }
                command.TrimStart(' ');
            }
            if (command.StartsWith("@")) // Function Command
            {
                string[] function_msg = command.Substring(1).Split(' ');
                if (function_msg.Count() == 0)
                {
                    return;
                }
                string   opcode  = function_msg.First();
                string[] payload = function_msg.Skip(1).ToArray();

                Console.WriteLine("Function! Opcode: " + opcode + ", Payload: " + String.Join(" ", payload));

                switch (opcode)
                {
                case "BLAME":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "GOAL": ModFunctions.BlameGoal(u); break;
                    }
                    break;

                case "GET":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "GOAL": ModFunctions.GetGoal(u); break;

                    case "UPTIME": ModFunctions.GetUptime(u); break;
                    }
                    break;

                case "SET":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "GOAL": ModFunctions.SetGoal(u, String.Join(" ", payload.Skip(1))); break;

                    case "QUIETMODE": if (ModFunctions.SetQuietMode(u))
                        {
                            SendIRCNotice("Quiet mode on.");
                        }
                        break;

                    case "R9K": if (ModFunctions.SetAprilFools(u))
                        {
                            SendIRCNotice("r9k mode on.");
                        }
                        break;
                    }
                    break;

                case "CLEAR":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "GOAL": if (!ModFunctions.ClearGoal(u))
                        {
                            Log("Unable to get goal, last get goal was less than 1 minute ago.");
                        }
                        break;

                    case "QUIETMODE": if (ModFunctions.ClearQuietMode(u))
                        {
                            SendIRCNotice("Quiet mode off.");
                        }
                        break;

                    case "R9K": if (ModFunctions.ClearAprilFools(u))
                        {
                            SendIRCNotice("r9k mode off.");
                        }
                        break;
                    }
                    break;

                case "ENABLE":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "INPUT": break;         // TODO
                    }
                    break;

                case "DISABLE":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "INPUT": break;         // TODO
                    }
                    break;

                case "SAVE":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "STATE":
                        if (ModFunctions.SaveState(u))
                        {
                            SendIRCNotice("Saved the twitchplays state.");
                        }
                        break;

                    case "GAME":
                        if (ModFunctions.SaveGame(u))
                        {
                            SendIRCNotice("The game has been saved.");
                        }
                        break;
                    }
                    break;

                case "RELOAD":
                    if (payload.Count() == 0)
                    {
                        return;
                    }
                    switch (payload.First())
                    {
                    case "FILTERS":
                        if (ModFunctions.ReloadFilters(u))
                        {
                            SendIRCNotice("Reloaded filter lists...");
                        }
                        break;

                    case "STATE":
                        if (ModFunctions.LoadState(u))
                        {
                            SendIRCNotice("Reloaded the twitchplays state.");
                        }
                        break;

                    case "GAME":
                        if (ModFunctions.ReloadGame(u))
                        {
                            SendIRCNotice("The game has been reloaded.");
                        }
                        break;
                    }
                    break;

                case "MUTE":     // TODO
                    break;

                default:
                    break;
                }
            }
            else if (command.Equals("ANARCHY"))
            {
                if (IsAprilFools)
                {
                    ShowMessage(e.Data.Nick, (u.GameMode == User.ModeType.DEMOCRACY) ? "*DEMOCRACY" : "DEMOCRACY");
                    u.GameMode = User.ModeType.DEMOCRACY;
                }
                else
                {
                    ShowMessage(e.Data.Nick, (u.GameMode == User.ModeType.ANARCHY) ? "*ANARCHY" : "ANARCHY");
                    u.GameMode = User.ModeType.ANARCHY;
                }
            }
            else if (command.Equals("DEMOCRACY"))
            {
                if (IsAprilFools)
                {
                    ShowMessage(e.Data.Nick, (u.GameMode == User.ModeType.ANARCHY) ? "*ANARCHY" : "ANARCHY");
                    u.GameMode = User.ModeType.ANARCHY;
                }
                else
                {
                    ShowMessage(e.Data.Nick, (u.GameMode == User.ModeType.DEMOCRACY) ? "*DEMOCRACY" : "DEMOCRACY");
                    u.GameMode = User.ModeType.DEMOCRACY;
                }
            }
            else
            {
                if (e.Data.Message.Length > 35)
                {
                    return;                             // don't parse long messages
                }
                // Check to make sure it starts with one of our keys.
                foreach (string key in KeyMap.Keys)
                {
                    if (command.StartsWith(key))
                    {
                        goto _goto_valid_command;
                    }
                }
                return; // not valid command

_goto_valid_command:
                Regex regex = new Regex(@"(?:(?<key>[a-z]+)\s*(?<count>\d?\d?))\s*", RegexOptions.IgnoreCase);

                List <KeyType> keys   = new List <KeyType>();
                List <uint>    counts = new List <uint>();
                foreach (Match match in regex.Matches(command))
                {
                    GroupCollection groups = match.Groups;

                    string _key = groups["key"].Value.ToUpper();
                    if (keyMap.ContainsKey(_key))
                    {
                        uint count = 0;
                        UInt32.TryParse(groups["count"].Value, out count);

                        if (count == 0 || (_key.Equals("START") && count > 1))
                        {
                            count = 1;
                        }

                        keys.Add(keyMap[_key]);
                        counts.Add(count);
                    }
                    else
                    {
                        break;
                    }
                }
                if (keys.Count > 0)
                {
                    keyNominee = new Nominee(keys, counts); // Load if already exists
                    if (keyNominee.CountsSum > 20)          // No more than 20 queued inputs
                    {
                        ShowMessage(e.Data.Nick, "#" + keyNominee.Name);
                        return;
                    }

                    Nominee existing = null;
                    if (null != (existing = nominees.Find(x => x.Name.Equals(keyNominee.Name))))
                    {
                        keyNominee = existing;
                    }
                }
            }

            if (keyNominee != null)
            {
                if (GameMode == User.ModeType.ANARCHY) // Live Mode
                {
                    Nominee n = new Nominee(keyNominee.Keys[0], 1);
                    //Thread vJoyThread = new Thread(() => _logform.vJoySendNominee(n));
                    Thread vjoy_thread = new Thread(() => _logform.vJoySendButton((uint)n.Keys[0], 1));
                    vjoy_thread.Start();

                    u.LastNominee = n;
                    ShowMessage(e.Data.Nick, n.Name);
                    return;
                }
                else if (GameMode == User.ModeType.DEMOCRACY)
                {
                    if (!nominees.Contains(keyNominee))
                    {
                        nominees.Add(keyNominee);
                    }

                    string right_msg = (downvote) ? "-" + keyNominee.Name : keyNominee.Name;

                    if (IsVotingClosed)
                    {
                        right_msg = "#" + right_msg;
                    }
                    else
                    {
                        bool contains = false;
                        if (downvote)
                        {
                            lock (Users.Downvoted)
                            {
                                contains = Users.Downvoted.Contains(u);
                            }
                        }
                        else
                        {
                            lock (Users.Voted)
                            {
                                contains = Users.Voted.Contains(u);
                            }
                        }
                        if (contains)
                        {
                            Nominee lastNominee = (downvote) ? u.LastDownNominee : u.LastNominee;

                            if (lastNominee == keyNominee)
                            {
                                right_msg = "*" + right_msg;
                            }
                            else
                            {
                                if (lastNominee != null)
                                {
                                    if (downvote)
                                    {
                                        lastNominee.Vote();
                                    }
                                    else
                                    {
                                        lastNominee.Unvote();
                                    }
                                }
                                if (downvote)
                                {
                                    keyNominee.Unvote();
                                }
                                else
                                {
                                    keyNominee.Vote();
                                }

                                right_msg = ((downvote) ? "-" + lastNominee.Name : lastNominee.Name) + "=>" + right_msg;
                            }
                        }
                        else
                        {
                            if (downvote)
                            {
                                lock (Users.Downvoted)
                                {
                                    Users.Downvoted.Add(u);
                                }
                                keyNominee.Unvote();
                            }
                            else
                            {
                                lock (Users.Voted)
                                {
                                    Users.Voted.Add(u);
                                }
                                keyNominee.Vote();
                            }
                        }

                        if (downvote)
                        {
                            u.LastDownNominee = keyNominee;
                        }
                        else
                        {
                            u.LastNominee = keyNominee;
                        }
                    }

                    ShowMessage(e.Data.Nick, right_msg);
                }
                else
                {
                    // Unable to find key, wtf?
                }
            }
        }
示例#9
0
        public static void ConnectIRC(LogForm _form)
        {
            if (_form != null)
            {
                _logform = _form;
            }

            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "IRC Thread";

                irc.Encoding             = System.Text.Encoding.UTF8;
                irc.SendDelay            = 200;
                irc.ActiveChannelSyncing = true;
                irc.AutoRetry            = true;

                //irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage);
                irc.OnError += new Meebey.SmartIrc4net.ErrorEventHandler(OnError);
                //irc.OnPong += new PongEventHandler(DetermineMode);
                irc.OnJoin  += new JoinEventHandler(OnJoin);
                irc.OnPart  += new PartEventHandler(OnPart);
                irc.OnOp    += new OpEventHandler(OnOp);
                irc.OnDeop  += new DeopEventHandler(OnDeop);
                irc.OnNames += new NamesEventHandler(OnNames);
                //irc.OnRawMessage += new IrcEventHandler(OnRawMessage);
                irc.OnChannelMessage += new IrcEventHandler(OnChannelMessage);
                irc.OnConnected      += new EventHandler(OnConnected);
                irc.OnDisconnected   += new EventHandler(OnDisconnected);

                //if (GameMode == User.ModeType.NONE) GameMode = User.ModeType.ANARCHY;

                // KeyMap
                keyMap.Add("HOLD", KeyType.HOLD);
                keyMap.Add("STAY", KeyType.HOLD);
                keyMap.Add("STOP", KeyType.HOLD);
                keyMap.Add("START", KeyType.START);
                keyMap.Add("SELECT", KeyType.SELECT);
                keyMap.Add("UP", KeyType.UP);
                keyMap.Add("NORTH", KeyType.UP);
                keyMap.Add("DOWN", KeyType.DOWN);
                keyMap.Add("SOUTH", KeyType.DOWN);
                keyMap.Add("LEFT", KeyType.LEFT);
                keyMap.Add("WEST", KeyType.LEFT);
                keyMap.Add("RIGHT", KeyType.RIGHT);
                keyMap.Add("EAST", KeyType.RIGHT);
                keyMap.Add("A", KeyType.A);
                keyMap.Add("B", KeyType.B);

                User u = new User("Command-line Argument");
                u.IsAdmin = true;
                ModFunctions.ReloadFilters(u);
            }

            // Connect
            if (username == null || password == null)
            {
                ExitWithMsg("Username or password has not been set!");
            }

            string[] serverlist;
            serverlist = new string[] { server };

            try
            {
                irc.Connect(serverlist, port);
            }
            catch (Exception e)
            {
                //ExitWithError(e, "Couldn't connect.");
            }
        }