示例#1
0
        /// <summary>
        /// upon clicking the save button, store data of the current opened grid.
        /// Some tabs may have another TabControl in which that Control contains a Grid control.
        /// </summary>
        private void BtnSave_Click(object sender, EventArgs ev) {
            var main = TabControlMain.SelectedTab;

            switch (((MouseEventArgs)ev).Button) {
                case MouseButtons.Left: {
                    if (loadAll || ModifierKeys == Keys.Shift) {
                        ForEachPage(TabControlMain,
                            (page, text) => BinaryDataUtil.ExportBinary(page, text));
                    } else {
                        BinaryDataUtil.ExportBinary(main, main.Text);
                    }

                    if (!loadAll) MessageBox.Show(Resources.CompleteSaveBIN);
                    break;
                }
                case MouseButtons.Right: {
                    if (ModifierKeys == Keys.Shift) {
                        ForEachPage(TabControlMain, (page, text) => BinaryDataUtil.ExportPictures(page, text));
                    } else {
                        BinaryDataUtil.ExportPictures(main, main.Text);
                    }

                    if (!loadAll) MessageBox.Show(Resources.CompleteSaveImages);
                    break;
                }
            }
        }
示例#2
0
文件: Elias.cs 项目: Quackster/Elias
        private bool ContainsSmallFurni()
        {
            var xmlData = BinaryDataUtil.SolveFile(this, this.OUTPUT_PATH, "assets");

            if (xmlData == null)
            {
                return(false);
            }

            var assets = xmlData.SelectSingleNode("//assets");

            for (int i = 0; i < assets.ChildNodes.Count; i++)
            {
                var node = assets.ChildNodes.Item(i);

                if (node == null)
                {
                    continue;
                }

                if (node.OuterXml.Contains("_32_"))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        private void ShowBinaryWindow(string name, ProtectedBinary binary)
        {
#if DEBUG
            var modifiedData = BinaryDataUtil.Open(name, binary, null);
#else
            ProtectedBinary modifiedData = null;

            // BinaryDataUtil was introduced with KeePass 2.25, so use it if it's available
            var binaryDataUtil = typeof(BinaryDataClassifier).Assembly.GetType("KeePass.Util.BinaryDataUtil");
            if (binaryDataUtil != null)
            {
                modifiedData = (ProtectedBinary)binaryDataUtil.GetMethod("Open", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { name, binary, null });
            }
            else
            {
                // Not available, use the legacy code
                modifiedData = OpenBinaryDataLegacy(name, binary);
            }
#endif

            if (modifiedData != null)
            {
                Entry.CreateBackup(Database);

                Entry.Binaries.Set(name, modifiedData);

                RefreshObjectsFromEntry();
                OnEntryModified(EventArgs.Empty);
            }
        }
示例#4
0
        private void OnTabControlChanged()
        {
            ClearAllPages(TabControlMain);

            var main = TabControlMain.SelectedTab;
            var sub  = (main.Controls[0] is TabControl tc ? tc.SelectedTab : main);

            BinaryDataUtil.ImportGrid($"{main.Text}/{sub.Text}.bin", (DataViewer)sub.Controls[0], AddGridRow);
        }
示例#5
0
文件: Elias.cs 项目: Quackster/Elias
        private void GenerateAliases(bool isDownscaled = false)
        {
            this.IsDownscaled = isDownscaled;
            var xmlData = BinaryDataUtil.SolveFile(this, this.OUTPUT_PATH, "assets");

            if (xmlData == null)
            {
                return;
            }

            var assets = xmlData.SelectSingleNode("//assets");

            for (int i = 0; i < assets.ChildNodes.Count; i++)
            {
                var node = assets.ChildNodes.Item(i);

                if (node == null)
                {
                    continue;
                }

                if (IsSmallFurni && node.OuterXml.Contains("_64_"))
                {
                    continue;
                }

                if (!IsSmallFurni && node.OuterXml.Contains("_32_"))
                {
                    continue;
                }

                var eliasAlias = new EliasAsset(this, node);
                eliasAlias.Parse();

                if (eliasAlias.ShockwaveAssetName == null && !eliasAlias.IsIcon && !eliasAlias.IsShadow)
                {
                    continue;
                }

                Assets.Add(eliasAlias);
            }

            foreach (var eliasAlias in Assets)
            {
                if (eliasAlias.IsIcon)
                {
                    continue;
                }

                eliasAlias.WriteAssets();
                eliasAlias.WriteFlippedAssets();
                eliasAlias.WriteImageNames();
                eliasAlias.WriteRegPointData();
            }

            this.SantiyCheckFrames();
        }
示例#6
0
        /// <summary>
        /// upon clicking the save button, store data of the current opened grid.
        /// Some tabs may have another TabControl in which that Control contains a Grid control.
        /// </summary>
        private void BtnSave_Click(object sender, EventArgs ev)
        {
            var main = TabControlMain.SelectedTab;

            switch (((MouseEventArgs)ev).Button)
            {
            case MouseButtons.Left: {
                if (main.Controls[0] is TabControl tc)
                {
                    foreach (TabPage page in tc.TabPages)
                    {
                        BinaryDataUtil.ExportBinary(page, main.Text);
                    }
                }
                else
                {
                    BinaryDataUtil.ExportBinary(main, main.Text);
                }

                if (!loadAll)
                {
                    MessageBox.Show(Resources.CompleteSaveBIN);
                }
                break;
            }

            case MouseButtons.Right: {
                if (main.Controls[0] is TabControl tc)
                {
                    foreach (TabPage page in tc.TabPages)
                    {
                        BinaryDataUtil.ExportPictures(page, main.Text);
                    }
                }
                else
                {
                    BinaryDataUtil.ExportPictures(main, main.Text);
                }

                if (!loadAll)
                {
                    MessageBox.Show(Resources.CompleteSaveImages);
                }
                break;
            }
            }
        }
示例#7
0
        private void OnTabControlChanged() {
            ClearAllPages(TabControlMain);

            var main = TabControlMain.SelectedTab;
            var dv = GetCurrentDataViewport();
            BinaryDataUtil.ImportGrid($"{main.Text}/{dv.Parent.Text}.bin", dv, AddGridRow);

            // if (main.Controls[0] is TabControl tc) {
            //     foreach (TabPage page in tc.TabPages) {
            //         BinaryDataUtil.ImportGrid($"{main.Text}/{page.Name}.bin", (DataViewport)page.Controls[0], 
            //             tc.SelectedTab == page ? AddGridRow : null);
            //     }
            //
            //     return;
            // } 

            // BinaryDataUtil.ImportGrid($"{main.Text}/{main.Text}.bin", (DataViewport)main.Controls[0], AddGridRow);
        }
示例#8
0
文件: Elias.cs 项目: Quackster/Elias
        private void TryRemoveGraphicsTag()
        {
            if (!this.HasGraphicsTag)
            {
                return;
            }

            string convertedDirectory = Path.Combine(this.FileDirectory, "converted");

            if (!Directory.Exists(convertedDirectory))
            {
                Directory.CreateDirectory(convertedDirectory);
            }

            string copiedSwfPath = Path.Combine(convertedDirectory, this.Sprite + ".swf");

            if (File.Exists(copiedSwfPath))
            {
                File.Delete(copiedSwfPath);
            }

            File.Copy(FullFileName, copiedSwfPath);
            var xmlData = BinaryDataUtil.SolveFilePath(this, this.OUTPUT_PATH, "visualization");

            var p = new Process();

            p.StartInfo.FileName       = FFDEC_PATH;
            p.StartInfo.Arguments      = string.Format("-replace \"{0}\" \"{1}\" \"{2}\" \"{3}\"", copiedSwfPath, copiedSwfPath, Path.GetFileName(xmlData).Split('_')[0], xmlData);
            p.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
            p.WaitForExit();


            //xmlData.SelectSingleNode
            //document.Load(@"C:\Path\To\xmldoc.xml");
        }
示例#9
0
文件: Elias.cs 项目: Quackster/Elias
        private void GenerateAnimations()
        {
            char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToLower().ToCharArray();
            var    xmlData  = BinaryDataUtil.SolveFile(this, this.OUTPUT_PATH, "visualization");

            var animations = 0;
            var sections   = new SortedDictionary <string, EliasAnimation>();

            if (xmlData == null)
            {
                return;
            }

            XmlNodeList frames = null;

            if (!IsDownscaled)
            {
                frames = xmlData.SelectNodes("//visualizationData/visualization[@size='" + (IsSmallFurni ? "32" : "64") + "']/animations/animation/animationLayer/frameSequence/frame");
            }
            else
            {
                frames = xmlData.SelectNodes("//visualizationData/visualization[@size='64']/animations/animation/animationLayer/frameSequence/frame");
            }

            int highestAnimationLayer = 0;

            for (int i = 0; i < frames.Count; i++)
            {
                var frame = frames.Item(i);

                var animationLayer = frame.ParentNode.ParentNode;
                int letterPosition = int.Parse(animationLayer.Attributes.GetNamedItem("id").InnerText);

                if (letterPosition < 0 || letterPosition > alphabet.Length)
                {
                    continue;
                }

                var animationLetter = Convert.ToString(alphabet[int.Parse(animationLayer.Attributes.GetNamedItem("id").InnerText)]);

                highestAnimationLayer = int.Parse(animationLayer.Attributes.GetNamedItem("id").InnerText) + 1;

                var animation   = frame.ParentNode.ParentNode.ParentNode;
                var animationId = int.Parse(animation.Attributes.GetNamedItem("id").InnerText);

                var castAnimationId = animationId + 1;

                if (castAnimationId > animations)
                {
                    animations = castAnimationId;
                }

                if (!sections.ContainsKey(animationLetter))
                {
                    sections.Add(animationLetter, new EliasAnimation());//new Dictionary<int, List<string>>());
                }

                if (!sections[animationLetter].States.ContainsKey(animationId))
                {
                    var frameClass = new EliasFrame();
                    sections[animationLetter].States.Add(animationId, frameClass);

                    if (animationLayer.Attributes.GetNamedItem("loopCount") != null)
                    {
                        frameClass.Loop = int.Parse(animationLayer.Attributes.GetNamedItem("loopCount").InnerText);
                    }

                    if (animationLayer.Attributes.GetNamedItem("frameRepeat") != null)
                    {
                        frameClass.FramesPerSecond = int.Parse(animationLayer.Attributes.GetNamedItem("frameRepeat").InnerText);
                    }
                }

                sections[animationLetter].States[animationId].Frames.Add(frame.Attributes.GetNamedItem("id").InnerText);
            }

            for (int i = 0; i < highestAnimationLayer; i++)
            {
                string letter = Convert.ToString(alphabet[i]);

                if (!sections.ContainsKey(letter))
                {
                    var animation = new EliasAnimation();
                    sections.Add(letter, animation);

                    for (int j = 0; j < animations; j++)
                    {
                        if (!animation.States.ContainsKey(j))
                        {
                            var frame = new EliasFrame();
                            frame.Frames.Add("0");

                            animation.States.Add(j, frame);
                        }
                    }
                }
            }

            var states = "";

            for (int i = 0; i < animations; i++)
            {
                states += (i + 1) + ",";
            }

            StringBuilder stringBuilder = new StringBuilder();

            if (animations > 0)
            {
                stringBuilder.Append("[\r");
                stringBuilder.Append("states:[" + states.TrimEnd(",".ToCharArray()) + "],\r");
                stringBuilder.Append("layers:[\r");

                int e = 0;
                foreach (var animation in sections)
                {
                    while (animation.Value.States.Count != animations)
                    {
                        int nextKey = 0;

                        if (animation.Value.States.ContainsKey(nextKey))
                        {
                            while (animation.Value.States.ContainsKey(nextKey))
                            {
                                nextKey++;
                            }
                        }

                        animation.Value.States.Add(nextKey, new EliasFrame());
                        animation.Value.States[nextKey].Frames.Add("0");
                    }

                    stringBuilder.Append(animation.Key + ": [ ");

                    int i = 0;
                    foreach (var f in animation.Value.States)
                    {
                        // loop: 0, delay: 4,
                        stringBuilder.Append("[ ");

                        if (f.Value.Loop != -1)
                        {
                            stringBuilder.Append("loop: " + f.Value.Loop + ", ");
                        }

                        if (f.Value.FramesPerSecond != -1)
                        {
                            stringBuilder.Append("delay: " + f.Value.FramesPerSecond + ", ");
                        }

                        stringBuilder.Append("frames:[ ");
                        stringBuilder.Append(string.Join(",", f.Value.Frames));

                        if (animation.Value.States.Count - 1 > i)
                        {
                            stringBuilder.Append(" ] ], ");
                        }
                        else
                        {
                            stringBuilder.Append(" ] ] ");
                        }

                        i++;
                    }

                    if (sections.Count - 1 > e)
                    {
                        stringBuilder.Append("],\r");
                    }
                    else
                    {
                        stringBuilder.Append("]\r");
                    }

                    e++;
                }

                stringBuilder.Append("]\r");
                stringBuilder.Append("]\r");
            }

            File.WriteAllText(Path.Combine(CAST_PATH, ((this.IsSmallFurni ? "s_" : "") + this.Sprite) + ".data"), stringBuilder.ToString());
        }
示例#10
0
文件: Elias.cs 项目: Quackster/Elias
        public string[] Parse()
        {
            List <string> filesWritten = new List <string>();

            this.IsSmallFurni = false;

            this.TryCleanup();
            this.ExtractAssets();
            this.RunSwfmill();

            this.ReadSymbolClass();
            this.GenerateAliases();
            this.TryWriteIcon();
            this.GenerateShadows();
            this.CreateMemberalias();
            this.GenerateProps();
            this.GenerateAssetIndex();
            this.GenerateAnimations();
            GenerateMissingImages();
            TryRemoveGraphicsTag();
            this.RunEliasDirector();

            filesWritten.Add("hh_furni_xx_" + Sprite + ".cct");

            if (!GenerateSmallFurni)
            {
                return(filesWritten.ToArray());
            }

            this.IsSmallFurni = true;

            if (!this.ContainsSmallFurni())
            {
                this.Assets.Clear();
                this.Symbols.Clear();

                if (!GenerateSmallModernFurni)
                {
                    return(filesWritten.ToArray());
                }

                this.Assets.Clear();
                this.Symbols.Clear();

                BinaryDataUtil.ReplaceFiles(this.OUTPUT_PATH, "_64_", "_32_");
                BinaryDataUtil.DownscaleImages(this.OUTPUT_PATH);

                TryCleanup(true);
                ReadSymbolClass();
                GenerateAliases(true);

                if (IsDownscaled)
                {
                    Logging.Log(ConsoleColor.Red, "WARNING: Downscaling small version for: " + Sprite);
                }

                TryWriteIcon();
                GenerateShadows();
                CreateMemberalias();
                GenerateProps();
                GenerateAssetIndex();
                GenerateAnimations();
                GenerateMissingImages();
                //TryRemoveGraphicsTag();
                RunEliasDirector();
            }
            else
            {
                this.Assets.Clear();
                this.Symbols.Clear();

                TryCleanup(true);
                ReadSymbolClass();
                GenerateAliases();
                TryWriteIcon();
                GenerateShadows();
                CreateMemberalias();
                GenerateProps();
                GenerateAssetIndex();
                GenerateAnimations();
                GenerateMissingImages();
                //TryRemoveGraphicsTag();
                RunEliasDirector();

                filesWritten.Add("hh_furni_xx_s_" + Sprite + ".cct");
            }
            return(filesWritten.ToArray());
        }
示例#11
0
文件: Elias.cs 项目: Quackster/Elias
        private void GenerateProps()
        {
            char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToLower().ToCharArray();
            var    xmlData  = BinaryDataUtil.SolveFile(this, this.OUTPUT_PATH, "visualization");

            Dictionary <int, int> shiftValues = new Dictionary <int, int>();

            if (xmlData == null)
            {
                return;
            }

            XmlNodeList layers = null;
            string      prefix = "";

            if (!IsDownscaled)
            {
                prefix = "//visualizationData/visualization[@size='" + (IsSmallFurni ? "32" : "64") + "']";
                layers = xmlData.SelectNodes(prefix + "/layers/layer");
            }
            else
            {
                prefix = "//visualizationData/visualization[@size='64']";
                layers = xmlData.SelectNodes(prefix + "/layers/layer");
            }

            Dictionary <string, string> layerData = new Dictionary <string, string>();

            for (int i = 0; i < layers.Count; i++)
            {
                var node = layers.Item(i);

                if (node == null)
                {
                    continue;
                }

                if (node.Name != "layer")
                {
                    continue;
                }

                if (node.Attributes.GetNamedItem("z") == null && node.Attributes.GetNamedItem("alpha") == null && node.Attributes.GetNamedItem("ink") == null)
                {
                    continue;
                }

                char letter = alphabet[int.Parse(node.Attributes.GetNamedItem("id").InnerText)];
                //string firstSection = "\"" + letter + "\": [{0}]";
                string secondSection = "";

                if (node.Attributes.GetNamedItem("z") != null)
                {
                    int z = int.Parse(node.Attributes.GetNamedItem("z").InnerText);

                    if (!shiftValues.ContainsKey(z))
                    {
                        shiftValues.Add(z, z);
                    }
                    else
                    {
                        shiftValues[z] = shiftValues[z] - 1;
                    }

                    if (xmlData.SelectNodes(prefix + "/directions/direction/layer[@id='" + node.Attributes.GetNamedItem("id").InnerText + "']").Count == 0)
                    {
                        secondSection += "#zshift: [" + shiftValues[z] + "], ";
                    }
                }

                if (node.Attributes.GetNamedItem("alpha") != null && node.Attributes.GetNamedItem("ink") == null)//if (node.Attributes.GetNamedItem("alpha") != null)
                {
                    double alphaValue = double.Parse(node.Attributes.GetNamedItem("alpha").InnerText);
                    double newValue   = (double)((alphaValue / 255) * 100);
                    secondSection += "#blend: " + (int)newValue + ", ";
                }

                if (node.Attributes.GetNamedItem("ink") != null)//if (node.Attributes.GetNamedItem("alpha") != null)
                {
                    if (node.Attributes.GetNamedItem("ink").InnerText == "ADD" || node.Attributes.GetNamedItem("ink").InnerText == "33")
                    {
                        secondSection += "#ink: 33, ";
                    }
                }

                if ((node.Attributes.GetNamedItem("ignoreMouse") != null && node.Attributes.GetNamedItem("ignoreMouse").InnerText == "1")) //if (node.Attributes.GetNamedItem("alpha") != null)
                {
                    secondSection += "#transparent: 1, ";                                                                                  // Don't allow click
                }

                if (layerData.ContainsKey(Convert.ToString(letter)))
                {
                    layerData.Remove(Convert.ToString(letter));
                }

                layerData.Add(Convert.ToString(letter), secondSection);
                //sections.Add(string.Format(firstSection, secondSection));
            }

            var directions      = new Dictionary <string, EliasDirection>();
            var directionLayers = xmlData.SelectNodes("//visualizationData/visualization[@size='" + (IsSmallFurni ? "32" : "64") + "']/directions/direction/layer");

            for (int i = 0; i < directionLayers.Count; i++)
            {
                var node = directionLayers.Item(i);

                if (node == null)
                {
                    continue;
                }

                if (node.Name != "layer")
                {
                    continue;
                }

                var layerNode     = node;
                var directionNode = layerNode.ParentNode;

                if (layerNode.Attributes.GetNamedItem("id") == null ||
                    layerNode.Attributes.GetNamedItem("z") == null ||
                    directionNode.Attributes.GetNamedItem("id") == null)
                {
                    continue;
                }

                string letter    = Convert.ToString(alphabet[int.Parse(layerNode.Attributes.GetNamedItem("id").InnerText)]);
                int    z         = int.Parse(layerNode.Attributes.GetNamedItem("z").InnerText);
                int    direction = int.Parse(directionNode.Attributes.GetNamedItem("id").InnerText);

                if (!directions.ContainsKey(letter))
                {
                    directions.Add(letter, new EliasDirection());
                }

                directions[letter].Coords[direction]     = z;
                directions[letter].Coords[direction + 1] = z;
            }

            var j = 0;

            foreach (var zData in directions)
            {
                string letter = zData.Key;

                if (!layerData.ContainsKey(letter))
                {
                    layerData.Add(letter, "");
                }

                layerData[letter] += "#zshift: [" + zData.Value.Props + "], ";
                //sections.Add("\"" + zData.Key + "\": [#zshift: [" + zData.Value.Props + "]]" + ((j + 1 < directions.Count) ? ", " : ""));
                j++;
            }

            StringBuilder output = new StringBuilder();

            if (layerData.Count > 0)
            {
                output.Append("[");

                int k = 0;
                foreach (var layer in layerData)
                {
                    output.Append("\"" + layer.Key + "\": ");
                    output.Append("[" + (layer.Value.Length >= 2 ? layer.Value.Substring(0, layer.Value.Length - 2) : ":") + "]");

                    if (layerData.Count - 1 > k)
                    {
                        output.Append(", ");
                    }

                    k++;
                }

                output.Append("]");
            }

            File.WriteAllText(Path.Combine(CAST_PATH, ((this.IsSmallFurni ? "s_" : "") + this.Sprite) + ".props"), output.ToString());
            //File.WriteAllText(Path.Combine(CAST_PATH, ((this.IsSmallFurni ? "s_" : "") + this.Sprite) + ".props"), sections.Count > 0 ? "[" + string.Join(", ", sections) + "]" : "");
        }