Exemple #1
0
 public void AddGroup(FileName fn)
 {
     if (_groups.ContainsKey(fn.GroupName))
     {
         _groups[fn.GroupName]++;
     }
     else
     {
         _groups[fn.GroupName] = 1;
         _russianNames[fn.GroupName] = HiddenObjectStudio.Core.Tools.CutDigitsFromTail(fn.RussianName);
     }
 }
 public void ProcessNode(FileName fn)
 {
     if (fn.IsWideTexture)
     {
         AddWideScreenNode(fn, WidePart.LeftPart);
         AddWideScreenNode(fn, WidePart.CenterPart);
         AddWideScreenNode(fn, WidePart.RightPart);
     }
     else
     {
         AddNormalNode(fn);
     }
 }
        private void AddNormalNode(FileName fn)
        {
            try
            {
                XmlElement textureNode = null;

                textureNode = texturePackDoc.CreateElement("texture");

                textureNode.SetAttribute("name", fn.TextureName);
                textureNode.SetAttribute("texture_name", _buildOptions.srcFolder + "\\" + fn.FileNameWithoutExtension);

                if (!fn.DisableAlphaSelection)
                {
                    textureNode.SetAttribute("min_alpha_selection", "150");
                    textureNode.SetAttribute("make_alpha_selection", "1");
                }

                if (fn.IsCollectableItem && !fn.DisableAlphaSelection)
                {
                    textureNode.SetAttribute("alpha_selection_expansion", "4");
                }

                if ((fn.IsActiveZone || fn.IsDropZone))
                {
                    if (_buildOptions.buildActiveZonesVisible)
                    {
                        textureNode.SetAttribute("save_image", "1");
                    }
                    else
                    {
                        textureNode.SetAttribute("save_image", "0");
                    }
                }

                if (_buildOptions.buildAlphaSelection)
                {
                    textureNode.SetAttribute("show_alpha_selection", "1");
                }

                textureNode.SetAttribute("frame_count", "1");

                texturePackRoot.AppendChild(textureNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(fn.FullFileName + ": " + ex.Message, "Error");

                throw;
            }
        }
        public void AddNode(FileName fn)
        {
            BackgroundsList.Add(fn);

            string shaderFullFileName = _buildOptions.dstFolder + "\\" + _builderConfig.ShaderFolderName  + "\\" + fn.GetOnlyFileName();

            XmlElement backgroundNode = _resourcesXmlDoc.CreateElement("shader");

            backgroundNode.SetAttribute("name", fn.TextureName);
            backgroundNode.SetAttribute("texture_name", _builderConfig.ShaderFolderName  + "\\" + fn.FileNameWithoutExtension);
            // 						backgroundNode.SetAttribute("diffuse_file_name", _shaderFolderName + fn.FileNameWithoutExtension + ".jpg");
            // 						backgroundNode.SetAttribute("opacity_file_name", _shaderFolderName + fn.FileNameWithoutExtension + "_alpha.jpg");

            _resourcesRoot.AppendChild(backgroundNode);
        }
Exemple #5
0
            public void AddItem(FileName fn)
            {
                if (fn.IsCollectableItem)
                {
                    XmlDocument itemsXmlDoc = AddItemsDoc(fn);

                    XmlElement itemsNode = (XmlElement)itemsXmlDoc.SelectSingleNode("items");

                    XmlElement itemNode = itemsXmlDoc.CreateElement(fn.TextureName);

                    itemNode.SetAttribute("group", fn.GroupName);
                    itemNode.SetAttribute("full_name", fn.TextureName);

                    itemsNode.AppendChild(itemNode);
                }
            }
Exemple #6
0
        public void AddItem(FileName fn)
        {
            try
            {
                if (fn.IsCollectableItem)
                {
                    if (_buildOptions.rebuildItemsFile)
                    {
                        XmlDocument itemsXmlDoc = AddItemsDoc(fn);

                        XmlElement itemsNode = (XmlElement)itemsXmlDoc.SelectSingleNode("items");

                        XmlElement itemNode = itemsXmlDoc.CreateElement(fn.TextureName);

                        itemNode.SetAttribute("group", fn.GroupName);
                        itemNode.SetAttribute("layer_full_name", fn.TextureName);

                        itemsNode.AppendChild(itemNode);

                    }

                    if (_buildOptions.rebuildHintsFile)
                    {
                        XmlDocument hintsXmlDoc = AddHintsDoc(fn);

                        XmlElement hintsNode = (XmlElement)hintsXmlDoc.SelectSingleNode("hints");

                        XmlElement hintNode = hintsXmlDoc.CreateElement("hint");

                        hintNode.SetAttribute("condition", "_collected-" + _buildOptions.sceneName + "_" + fn.ItemsIndex + "-" + fn.EnglishName + " = ''");

                        hintNode.InnerXml = "<layer name=\"" + fn.EnglishName + "\"/>";

                        hintsNode.AppendChild(hintNode);

                    }

                }
            }
            catch (System.Exception)
            {
                MessageBox.Show(fn.FullFileName, "Error");

                throw new Exception();
            }
        }
Exemple #7
0
            private XmlDocument AddItemsDoc(FileName fn)
            {
                string itemsFileName = "items_" + fn.GetItemsIndex();
                XmlDocument xmlDoc = null;

                try
                {
                    xmlDoc = _itemsDocuments[itemsFileName];
                }
                catch (KeyNotFoundException)
                {
                    xmlDoc = new XmlDocument();
                    _itemsDocuments[itemsFileName] = xmlDoc;
                    xmlDoc.AppendChild(xmlDoc.CreateElement("items"));

                }

                return xmlDoc;
            }
Exemple #8
0
        public bool Build2(BuildOptions options)
        {
            //_config.sceneName = options.sceneName;
            options.isHO = false;
            options.isHo01 = false;
            options.isHo02 = false;
            options.HO01 = new List<string>();
            options.HO02 = new List<string>();
            try
            {
                List<string> textureNames = new List<string>();

                string[] files = Directory.GetFiles(options.srcFolder, "*.png");

                if (files.Length == 0)
                {
                    throw new Exception("Not found *.png in folder.");
                }

                foreach (string fileName in files)
                {
                    if (fileName.Contains("pick_"))
                    {
                        if (fileName.Contains("pick_01"))
                        {
                            if (!options.isHo01)
                                options.isHo01 = true;

                            options.HO01.Add(fileName);
                        }

                        if (fileName.Contains("pick_02"))
                        {
                            if (!options.isHo02)
                                options.isHo02 = true;

                            options.HO02.Add(fileName);
                        }

                        if (!options.isHO)
                        {
                            options.isHO = true;
                        }
                    }

                }

                //////////////////////////////////////////////////////////////////////////
                /// Create texture pack header

                if (options.rebuildTP)
                {
                     _texturePack =  new TexturePack(_config, options);

                    //////////////////////////////////////////////////////////////////////////
                    /// Create resource header
                     if (options.rebuildResourcesFile)
                     {
                         _resources = new Resources(_config, options);
                     }
                }

                //////////////////////////////////////////////////////////////////////////
                /// Create scene header

                if (options.rebuildScene)
                {
                    _scene = new Scene(_config, options, "");
                    _sceneHO1 = new Scene(_config, options, "_01");
                    _sceneHO2 = new Scene(_config, options, "_02");

                }

                if (options.rebuildItemsFile || options.rebuildHintsFile)
                {
                    _items = new Items(_config, options);
                }

                //////////////////////////////////////////////////////////////////////////
                /// Create texts header

                if (options.rebuildTexts)
                {
                    _texts = new Texts(_config, options);
                }

                //////////////////////////////////////////////////////////////////////////
                /// Create navigation header

                if (options.rebuildNavigation)
                {
                    _navigation = new Navigation(_config, options);
                }

                //////////////////////////////////////////////////////////////////////////
                /// Initialize levels

                if (options.rebuildLevels)
                {
                    _levels = new Levels(_config, options);
                }
                //////////////////////////////////////////////////////////////////////////
                /// Create glints xml
                if (options.rebuildGlintsFile)
                {
                    _glints = new Glints( options, "");
                    _glintsHO1 = new Glints( options, "_01");
                    _glintsHO2 = new Glints( options, "_02");

                }
                //////////////////////////////////////////////////////////////////////////

                foreach (string fileName in files)
                {
                    FileName fn = new FileName(fileName);

                    if ((options.rebuildGlintsFile))
                    {
                        if (fileName.LastIndexOf("_g") != -1)
                        {
                            if (options.isHO)
                            {
                                if (options.isHo01)
                                {
                                    if (fileName.Contains("_g1"))
                                    {
                                        _glintsHO1.AddGlint(fn.TextureName);
                                    }

                                }
                                if (options.isHo02)
                                {
                                    if (fileName.Contains("_g2"))
                                        _glintsHO2.AddGlint(fn.TextureName);
                                }
                            }
                            else
                            {
                                if (fileName.Contains("_g0"))
                                    _glints.AddGlint(fn.TextureName);
                            }

                        }
                    }

                    if (fn.IsCollectableItem && _texts != null)
                    {
                        _texts.AddGroup(fn);
                    }

                    if (textureNames.Contains(fn.TextureName))
                    {
                        throw new Exception("Error. Found duplicate the texture name: '" + fn.TextureName + "'\nFile:'" + fn.GetOnlyFileName() + "'");
                    }
                    else
                    {
                        textureNames.Add(fn.TextureName);
                    }
                    //////////////////////////////////////////////////////////////////////////
                    /// Create scene node
                    ///

                    if (!options.isHO)
                    {
                        if (options.rebuildScene)
                        {
                            _scene.ProcessNode(fn);
                        }
                    }
                    else
                    {
                        if (options.rebuildScene)
                        {
                            if (options.isHo01)
                            {
                                _sceneHO1.ProcessNode(fn);
                            }

                            if (options.isHo02)
                            {
                                bool _notfoundHO1item = false;
                                for (int i = 0; i < options.HO01.Count; i++)
                                {
                                    FileName fn2 = new FileName(options.HO01[i]);
                                    if (fn2.TextureName == fn.TextureName)
                                    {
                                        _notfoundHO1item = true;
                                        break;
                                    }
                                }
                                if (!_notfoundHO1item)
                                {
                                    _sceneHO2.ProcessNode(fn);
                                }
                            }
                        }
                    }

                    //////////////////////////////////////////////////////////////////////////
                    /// Create item node

                    if (options.rebuildItemsFile)
                    {
                        _items.AddItem(fn);
                    }
                    //////////////////////////////////////////////////////////////////////////
                    /// Create texture pack node

                    if (options.rebuildTP)
                    {
                        _texturePack.ProcessNode(fn);
                    }

                } // main loop

                if (options.rebuildLevels)
                {
                    _levels.ProcessNormalTextureNode();
                }

                if (options.rebuildNavigation)
                {
                    _navigation.Processing();
                }
                //////////////////////////////////////////////////////////////////////////
                /// Create texts node

                if (options.rebuildTexts)
                {
                    _texts.Save();
                }

                //////////////////////////////////////////////////////////////////////////
                /// Save scene xml

                if (options.rebuildScene)
                {
                    if (!options.isHO)
                    {
                        _scene.Save();
                    }
                    else
                    {
                        if (options.isHo01)
                        {
                            _sceneHO1.Save();
                        }

                        if (options.isHo02)
                        {
                            _sceneHO2.Save();
                        }
                    }
                }

                //////////////////////////////////////////////////////////////////////////
                /// Save navigation xml

                if (options.rebuildNavigation)
                {
                    _navigation.Save();
                }

                //////////////////////////////////////////////////////////////////////////
                /// Save levels xml

                if (options.rebuildLevels)
                {
                    _levels.Save();
                }

                //////////////////////////////////////////////////////////////////////////
                /// Save items xml

                if (options.rebuildItemsFile)
                {
                    if (_items.GetItemsNames().Count != 0)
                    {
                        OptionsHO _optionsHO = new OptionsHO(_items);
                        _optionsHO.ShowDialog();
                        List<string> interactiveItems = _optionsHO.GetInteractiveItems();
                        string defaultColor = _optionsHO.GetDefaultColor();
                        string interactiveColor = _optionsHO.GetInteractiveColor();
                        _items.AddColors(interactiveItems, interactiveColor, defaultColor);
                    }
                    _items.Save();
                }

                //////////////////////////////////////////////////////////////////////////
                /// Save texture pack xml

                if (options.rebuildTP)
                {
                    _texturePack.Save();

                    if (options.rebuildTP)
                    {
                        DirectoryInfo di = new DirectoryInfo(options.dstFolder + "\\texture_pack");
            // 					di.Attributes = FileAttributes.Archive;
            //
            // 					di.Delete(true);

                        Process p = new Process();
                        p.StartInfo.FileName = _config.ElefunToolsPath + "TexturePacker.exe";
                        p.StartInfo.Arguments = options.dstFolder + "\\texture_pack.xml";
                        p.Start();
                        p.WaitForExit();
                    }

                    //////////////////////////////////////////////////////////////////////////
                    /// Save resources xml
                    if (options.rebuildResourcesFile)
                    {
                        _resources.Save();
                    }
                }

                //////////////////////////////////////////////////////////////////////////
                /// Save glints xml
                if (options.rebuildGlintsFile)
                {
                    if (options.isHO)
                    {
                        if (options.isHo01)
                        {
                            _glintsHO1.Save();
                        }
                        if (options.isHo02)
                        {
                            _glintsHO2.Save();
                        }
                    }
                    else
                    {
                        _glints.Save();
                    }
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Error on scene '" + options.sceneName + "': " + ex.Message);
            }

            return true;
        }
Exemple #9
0
        public void UpdateNode(FileName fn)
        {
            XmlElement layerNode = (XmlElement)_layersNode.SelectSingleNode(fn.NodeName);

            if (layerNode != null)
            {
                if (fn.IsCollectableItem)
                {
                    AddCollectAnimationIfNeeded(layerNode);
                }
            }
        }
Exemple #10
0
        public void ProcessWideTextureNode(FileName fn, WidePart widePart)
        {
            try
            {
                XmlElement layerNode = (XmlElement)_layersNode.SelectSingleNode(fn.GetWideNodeName(widePart));

                if (layerNode == null)
                {
                    layerNode = _sceneXmlDoc.CreateElement(fn.GetWideNodeName(widePart));

                    layerNode.SetAttribute("texture_name", fn.GetWideTextureName(widePart));

                    layerNode.SetAttribute("texture_pack", _buildOptions.sceneName + "/" + _builderConfig.TexturePackName);

                    _layersNode.AppendChild(layerNode);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error on " + fn.FullFileName);

                throw ex;
            }
        }
Exemple #11
0
        public void ProcessNormalTextureNode(FileName fn)
        {
            try
            {
                XmlElement layerNode = (XmlElement)_layersNode.SelectSingleNode(fn.NodeName);

                if (layerNode == null)
                {
                    layerNode = _sceneXmlDoc.CreateElement(fn.NodeName);

                    layerNode.SetAttribute("texture_name", fn.TextureName);

                    layerNode.SetAttribute("texture_pack", _buildOptions.sceneName + "/" + _builderConfig.TexturePackName);

                    if (fn.IsDropZone)
                    {
                        layerNode.SetAttribute("accepts_items", fn.AcceptsItemName);
                    }

                    _layersNode.AppendChild(layerNode);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error on " + fn.FullFileName);

                throw ex;
            }
        }
Exemple #12
0
 public void ProcessNode(FileName fn)
 {
     if (fn.IsWideTexture)
     {
         ProcessWideTextureNode(fn, WidePart.LeftPart);
         ProcessWideTextureNode(fn, WidePart.CenterPart);
         ProcessWideTextureNode(fn, WidePart.RightPart);
     }
     else
     {
         ProcessNormalTextureNode(fn);
     }
 }
        private void AddWideScreenNode(FileName fn, WidePart widePart)
        {
            try
            {
                XmlElement textureNode = null;

                textureNode = texturePackDoc.CreateElement("texture");

                textureNode.SetAttribute("name", fn.GetWideTextureName(widePart));
                textureNode.SetAttribute(GetWidePartAttribute(widePart), _buildOptions.srcFolder + "\\" + fn.FileNameWithoutExtension);

                textureNode.SetAttribute("frame_count", "1");

                texturePackRoot.AppendChild(textureNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(fn.FullFileName + ": " + ex.Message, "Error");

                throw;
            }
        }
Exemple #14
0
        private XmlDocument AddItemsDoc(FileName fn)
        {
            string itemsFileName = "items_" + fn.ItemsIndex;
            XmlDocument xmlDoc = null;
            XmlElement root = null;

            if (_itemsDocuments.ContainsKey(itemsFileName))
            {
                xmlDoc = _itemsDocuments[itemsFileName];
                root = (XmlElement)xmlDoc.SelectSingleNode("items");
            }
            else
            {
                xmlDoc = new XmlDocument();
                root = xmlDoc.CreateElement("items");
                xmlDoc.AppendChild(root);

                _itemsDocuments[itemsFileName] = xmlDoc;
            }
            //root.SetAttribute("hints_file", "hints_" + fn.GetItemsIndex() + ".xml");

            return xmlDoc;
        }
Exemple #15
0
        private XmlDocument AddHintsDoc(FileName fn)
        {
            string hintsFileName = "hints_" + fn.ItemsIndex;
            XmlDocument xmlDoc = null;

            if (_hintsDocuments.ContainsKey(hintsFileName))
            {
                xmlDoc = _hintsDocuments[hintsFileName];
            }
            else
            {
                xmlDoc = new XmlDocument();
                _hintsDocuments[hintsFileName] = xmlDoc;
                xmlDoc.AppendChild(xmlDoc.CreateElement("hints"));
                _hintsDocuments[hintsFileName] = xmlDoc;

            }

            return xmlDoc;
        }
Exemple #16
0
        public void AddGroup(FileName fn)
        {
            if (!fn.IsDropZone && !fn.IsActiveZone)
            {
                string ho_scene_name = GetHoSetName(fn.ItemsIndex);

                HoSet ho_text;

                if (_hoSets.ContainsKey(ho_scene_name))
                {
                    ho_text = _hoSets[ho_scene_name];
                }
                else
                {
                    ho_text = new HoSet();
                    _hoSets.Add(ho_scene_name, ho_text);
                }

                ho_text.AddGroup(fn);
            }
        }