Пример #1
0
        internal override void OnFiles(List <string> aFiles, POINT aPos)
        {
            var goodFiles = aFiles.Where(x =>
            {
                var ext = Path.GetExtension(x).ToLower();
                return(ext == ".png" || ext == ".dat");
            });

            if (goodFiles.Count() == 0)
            {
                Logger.LogMessage("No files to handle");
                return;
            }

            if (CardHandlerMethods.GetActiveCardHandler(out var cardHandler))
            {
                foreach (var file in goodFiles)
                {
                    var bytes = File.ReadAllBytes(file);

                    if (BoyerMoore.ContainsSequence(bytes, StudioToken))
                    {
                        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                        {
                            cardHandler.Scene_Import(file, aPos);
                        }
                        else
                        {
                            cardHandler.Scene_Load(file, aPos);
                        }
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, FemaleToken))
                    {
                        cardHandler.Character_Load(file, aPos, 1);
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, MaleToken))
                    {
                        cardHandler.Character_Load(file, aPos, 0);
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, FemaleCoordinateToken) || BoyerMoore.ContainsSequence(bytes, MaleCoordinateToken))
                    {
                        cardHandler.Coordinate_Load(file, aPos);
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, PoseToken))
                    {
                        cardHandler.PoseData_Load(file, aPos);
                    }
                    else
                    {
                        Logger.LogMessage("This file does not contain any PlayHome related data");
                    }
                }
            }
            else
            {
                Logger.LogMessage("No handler found for this scene");
            }
        }
Пример #2
0
        internal override void OnFiles(List <string> aFiles, POINT aPos)
        {
            var goodFiles = aFiles.Where(x =>
            {
                var ext = Path.GetExtension(x).ToLower();
                return(ext == ".png" || ext == ".dat");
            });

            if (goodFiles.Count() == 0)
            {
                Logger.LogMessage("No files to handle");
                return;
            }

            if (CardHandlerMethods.GetActiveCardHandler(out var cardHandler))
            {
                foreach (var file in goodFiles)
                {
                    var bytes = File.ReadAllBytes(file);

                    if (BoyerMoore.ContainsSequence(bytes, StudioToken))
                    {
                        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                        {
                            cardHandler.Scene_Import(file, aPos);
                        }
                        else
                        {
                            cardHandler.Scene_Load(file, aPos);
                        }
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, CharaToken, out var index))
                    {
                        var sex = new BoyerMoore(SexToken).Search(bytes, index)
                                  .Select(i => bytes[i + SexToken.Length])
                                  .First(b => b == 0 || b == 1);
                        cardHandler.Character_Load(file, aPos, sex);
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, CoordinateToken))
                    {
                        cardHandler.Coordinate_Load(file, aPos);
                    }
                    else if (BoyerMoore.ContainsSequence(bytes, PoseToken))
                    {
                        cardHandler.PoseData_Load(file, aPos);
                    }
                    else
                    {
                        Logger.LogMessage("This file does not contain any Koikatu related data");
                    }
                }
            }
            else
            {
                Logger.LogMessage("No handler found for this scene");
            }
        }
Пример #3
0
        public static bool ContainsSequence(byte[] haystack, byte[] needle, out int index)
        {
            var l = new BoyerMoore(needle).Search(haystack, 0).ToList();

            if (l.Count > 0)
            {
                index = l[0];
                return(true);
            }
            else
            {
                index = -1;
                return(false);
            }
        }