Пример #1
0
        static void Main(string[] args)
        {
            // Init
            config          = new Configuration(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "config.cfg");
            interaction     = new SpreadsheetInteraction(config.xlsxFile);
            controlCommands = new ControlSpeechCommands("Control.definition");
            Confirmation.Initialize();

            mapper = new HotKeyMapper();
            mapper.AssignToHotkey(Keys.F1, "voice");
            mapper.AssignToHotkey(Keys.F2, "chest");
            mapper.AssignToHotkey(Keys.F3, "help");
            mapper.AssignToHotkey(Keys.F4, "quit");
            mapper.AssignToHotkey(Keys.F8, KeyModifiers.Shift, "wipe");
            bool continueRunning = true;

            //

            Console.WriteLine("Welcome to Metin2 siNDiCATE Drop logger");
            Console.WriteLine("Type 'help' for more info on how to use this program");

            while (continueRunning)
            {
                Console.WriteLine("Commands:" +
                                  "\n-(F1) Voice recognition" +
                                  "\n-(F2) Chests" +
                                  "\n-(F3) Help" +
                                  "\n-(F4) Quit" +
                                  "\n-(Shift + F8) Wipe");

                string command = Console.ReadLine();
                if (currCommand != "")
                {
                    command = currCommand;
                }

                string[] commandBlocks = command.Split(' ');

                //Switch over length
                switch (commandBlocks.Length)
                {
                case 1: {
                    switch (commandBlocks[0])
                    {
                    case "quit":
                    case "exit": {
                        Console.WriteLine("Do you want to quit? y/n");
                        if (Console.ReadKey().Key == ConsoleKey.Y)
                        {
                            continueRunning = false;
                        }
                        break;
                    }

                    case "help": {
                        Console.WriteLine("Existing commands:");
                        Console.WriteLine("quit / exit --> Close the application\n");
                        Console.WriteLine("clear --> Clears the console\n");
                        Console.WriteLine("voice / voice debug --> Enables voice control without/with debug prints\n");
                        Console.WriteLine("chest --> Opens speech recognition for chest drops (Gold/Silver[+-])\n");
                        Console.WriteLine("wipe --> removes the sheet and all custom data !CAUTION ADVISED!");
                        break;
                    }

                    case "voice": {
                        parser         = new DefinitionParser(new System.Text.RegularExpressions.Regex(@"(Mob_)?\w+\.definition"));
                        gameRecognizer = new GameRecognizer();
                        gameRecognizer.helper.AcquireControl();
                        Console.WriteLine("Returned to Main control!");
                        mapper.FreeGameHotkeys();
                        mapper.AssignToHotkey(Keys.F1, "voice");
                        mapper.AssignToHotkey(Keys.F2, "chest");
                        mapper.AssignToHotkey(Keys.F3, "help");
                        mapper.AssignToHotkey(Keys.F4, "quit");
                        mapper.AssignToHotkey(Keys.F8, KeyModifiers.Shift, "wipe");
                        break;
                    }

                    case "chest": {
                        parser = new DefinitionParser(new System.Text.RegularExpressions.Regex(@"\w+\ (C|c)hest[+-]?\.definition"));
                        ChestRecognizer chestRecognizer = new ChestRecognizer();
                        chestRecognizer.helper.AcquireControl();
                        Console.WriteLine("Returned to Main control!");
                        mapper.FreeGameHotkeys();
                        mapper.AssignToHotkey(Keys.F1, "voice");
                        mapper.AssignToHotkey(Keys.F2, "chest");
                        mapper.AssignToHotkey(Keys.F3, "help");
                        mapper.AssignToHotkey(Keys.F4, "quit");
                        mapper.AssignToHotkey(Keys.F8, KeyModifiers.Shift, "wipe");
                        break;
                    }

                    case "clear": {
                        Console.Clear();
                        Console.WriteLine("Welcome to Metin2 siNDiCATE Drop logger");
                        Console.WriteLine("Type 'help' for more info on how to use this program");
                        break;
                    }

                    case "wipe": {
                        Console.WriteLine("Wiping data...");
                        if (File.Exists(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "config.cfg"))
                        {
                            File.Delete(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "config.cfg");
                            Console.WriteLine("config.cfg");
                        }
                        if (File.Exists(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + MobAsociatedDrops.MOB_DROPS_FILE))
                        {
                            File.Delete(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + MobAsociatedDrops.MOB_DROPS_FILE);
                            Console.WriteLine(MobAsociatedDrops.MOB_DROPS_FILE);
                        }
                        if (File.Exists(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + Configuration.FILE_NAME))
                        {
                            File.Delete(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + Configuration.FILE_NAME);
                            Console.WriteLine(Configuration.FILE_NAME);
                        }
                        config      = new Configuration(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "config.cfg");
                        interaction = new SpreadsheetInteraction(config.xlsxFile);
                        break;
                    }

                    default: {
                        Console.WriteLine("Not a valid command, type 'help' for more info");
                        break;
                    }
                    }
                    break;
                }

                case 2: {
                    switch (commandBlocks[0])
                    {
                    case "voice": {
                        if (commandBlocks[1] == "debug")
                        {
                            debug = true;
                            Console.WriteLine("Entering debug mode");
                            parser         = new DefinitionParser(new System.Text.RegularExpressions.Regex(".+"));
                            gameRecognizer = new GameRecognizer();
                            gameRecognizer.helper.AcquireControl();
                            Console.WriteLine("Returned to Main control!");
                        }
                        break;
                    }

                    default: {
                        Console.WriteLine("Not a valid command, type 'help' for more info");
                        break;
                    }
                    }
                    break;
                }
                }
                currCommand = "";
                mapper.FreeGameHotkeys();
            }
        }
Пример #2
0
        /// <summary>
        /// Event fired after a modifier word was said
        /// </summary>
        /// <param name="keyWord">"NEW_TARGET" // "UNDO" // "REMOVE_TARGET" // TARGET_KILLED</param>
        /// <param name="args">Always supply at least string.Empty as args!</param>
        private async void EnemyTargetingModifierRecognized(object sender, ModiferRecognizedEventArgs args)
        {
            if (args.modifier == ModifierWords.NEW_TARGET)
            {
                switch (state)
                {
                case EnemyState.NO_ENEMY: {
                    string enemy = GetEnemy();
                    evnt.Reset();
                    if (enemy == Program.controlCommands.getRemoveTargetCommand)
                    {
                        Console.WriteLine("Targetting calcelled!");
                        return;
                    }
                    string actualEnemyName = DefinitionParser.instance.currentMobGrammarFile.GetMainPronounciation(enemy);
                    state = EnemyState.FIGHTING;
                    Program.interaction.OpenWorksheet(actualEnemyName);
                    currentEnemy = actualEnemyName;
                    Console.WriteLine("Acquired target: " + currentEnemy);
                    stack.Clear();
                    return;
                }

                case EnemyState.FIGHTING: {
                    state = EnemyState.NO_ENEMY;
                    Console.WriteLine("Killed " + currentEnemy + ", the death count increased");
                    Program.interaction.AddNumberTo(new ExcelCellAddress(1, 5), 1);
                    currentEnemy = "";
                    stack.Clear();
                    EnemyTargetingModifierRecognized(this, args);
                    return;
                }
                }
            }
            else if (args.modifier == ModifierWords.TARGET_KILLED)
            {
                Console.WriteLine("Killed " + currentEnemy + ", the death count increased");
                Program.interaction.AddNumberTo(new ExcelCellAddress(1, 5), 1);
                EnemyTargetingModifierRecognized(this, new ModiferRecognizedEventArgs()
                {
                    modifier = ModifierWords.REMOVE_TARGET
                });
            }
            else if (args.modifier == ModifierWords.REMOVE_TARGET)
            {
                Program.interaction.OpenWorksheet(DefinitionParser.instance.currentGrammarFile.ID);
                currentEnemy = "";
                currentItem  = "";
                state        = EnemyState.NO_ENEMY;
                stack.Clear();
                Console.WriteLine("Reset current target to 'None', switching to " + DefinitionParser.instance.currentGrammarFile.ID + " sheet.");
            }
            else if (args.modifier == ModifierWords.UNDO)
            {
                ItemInsertion action = stack.Peek();
                if (action.address == null)
                {
                    Console.WriteLine("Nothing else to undo!");
                    return;
                }
                Console.WriteLine("Would remove " + action.count + " items from " + Program.interaction.currentSheet.Cells[action.address.Row, action.address.Column - 2].Value);

                bool resultUndo = await Confirmation.AskForBooleanConfirmation("'Confirm'/'Refuse'?");

                if (resultUndo)
                {
                    action = stack.Pop();
                    Program.interaction.AddNumberTo(action.address, -action.count);
                    if (Program.interaction.currentSheet.Cells[action.address.Row, action.address.Column].GetValue <int>() == 0 && currentEnemy != "")
                    {
                        string itemName = Program.interaction.currentSheet.Cells[action.address.Row, action.address.Column - 2].Value.ToString();
                        Console.WriteLine("Remove " + currentItem + " from current enemy's (" + currentEnemy + ") item list?");
                        bool resultRemoveFromFile = await Confirmation.AskForBooleanConfirmation("'Confirm'/'Refuse'?");

                        if (resultRemoveFromFile)
                        {
                            currentItem = itemName;
                            mobDrops.RemoveItemEntry(currentEnemy, currentItem, true);
                        }
                        else
                        {
                            Console.WriteLine("Enemy file NOT modified!");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Undo refused!");
                }
            }
        }