Example #1
0
        public Glints(BuildOptions buildOptions, string glintNumber, string __ok = "")
        {
            _buildOptions = buildOptions;
            if(__ok == "")
                _glintsFileName = _buildOptions.dstFolder + "\\glints" + glintNumber + ".xml";
            else
                _glintsFileName = __ok;

            if (!File.Exists(_glintsFileName))
            {
                _glintsXmlDoc = new XmlDocument();
                _glintsRoot = _glintsXmlDoc.CreateElement("glints");
            }
            else
            {
                _glintsXmlDoc = new XmlDocument();
                _glintsXmlDoc.Load(_glintsFileName);

                for (int i = 0; i < _glintsXmlDoc.ChildNodes.Count; i++ )
                {
                    if (_glintsXmlDoc.ChildNodes[i].Name == "glints")
                    {
                        _glintsRoot = (XmlElement)_glintsXmlDoc.ChildNodes[i];
                        break;
                    }
                }
            }
        }
Example #2
0
            public Items(BuilderConfig builderConfig, BuildOptions buildOptions)
            {
                _builderConfig = builderConfig;
                _buildOptions = buildOptions;

                _itemsDocuments = new Dictionary<string, XmlDocument>();

            }
Example #3
0
        public Resources(BuilderConfig builderConfig, BuildOptions buildOptions)
        {
            _builderConfig = builderConfig;
            _buildOptions = buildOptions;
            _backgroundsList = new List<FileName>();
            _resourcesFileName = _buildOptions.dstFolder + "\\resources.xml";

            _resourcesXmlDoc = new XmlDocument();

            _resourcesRoot = _resourcesXmlDoc.CreateElement(_buildOptions.sceneName);

            _texturePackNode = _resourcesXmlDoc.CreateElement("texture_pack");
        }
Example #4
0
        public TexturePack(BuilderConfig builderConfig, BuildOptions buildOptions)
        {
            _builderConfig = builderConfig;
            _buildOptions = buildOptions;

            texturePackDoc = new XmlDocument();

            texturePackRoot = texturePackDoc.CreateElement("texture_packer");
            texturePackRoot.SetAttribute("name", buildOptions.dstFolder + "\\texture_pack\\" + _builderConfig.TexturePackName);
            texturePackRoot.SetAttribute("max_size", "1024 1024");
            texturePackRoot.SetAttribute("extension", "png");
            texturePackRoot.SetAttribute("wide_screen_base", "1024");
        }
Example #5
0
        private void AddGlintButton_Click(object sender, EventArgs e)
        {
            if ((_SelectedFolder != "") && (_SelectedLayers != null))
            {
                BuildOptions _options = new BuildOptions();
                _options.dstFolder = _SelectedFolder;
                Glints _glint = new Glints(_options, "", _SelectedGlint);

                for (int i = 0; i < _SelectedLayers.Count; i++)
                {
                    _glint.AddGlint(_SelectedLayers[i].Text);

                }

                _glint.Save();

                MessageBox.Show("Selected Glints successfully added");
            }
        }
Example #6
0
        public Levels(BuilderConfig builderConfig, BuildOptions buildOptions)
        {
            _builderConfig = builderConfig;
            _buildOptions = buildOptions;

            _xmlFileName = _buildOptions.levelsXmlFileName;

            _sceneXmlDoc = new XmlDocument();

            if (_buildOptions.rebuildLevels)
            {
                if (File.Exists(_xmlFileName))
                {
                    _sceneXmlDoc.Load(_xmlFileName);
                }
            }

            _sceneRoot = (XmlElement)_sceneXmlDoc.DocumentElement;
            _layersNode_SE = (XmlElement)_sceneRoot.FirstChild;
            _layersNode_CE = (XmlElement)_sceneRoot.LastChild;
        }
Example #7
0
        public Scene(BuilderConfig builderConfig, BuildOptions buildOptions, string sceneName)
        {
            _builderConfig = builderConfig;
            _buildOptions = buildOptions;

            _scriptFileName = _buildOptions.sceneName + sceneName + ".lua";

            _xmlFileName = buildOptions.dstFolder + "\\" + buildOptions.sceneName + sceneName + ".xml";

            _sceneXmlDoc = new XmlDocument();

            SceneRootNodeName = buildOptions.sceneName + sceneName;

            if (_buildOptions.rebuildScene)
            {
                if (File.Exists(_xmlFileName))
                {
                    _sceneXmlDoc.Load(_xmlFileName);
                }
            }

            _sceneRoot = (XmlElement)_sceneXmlDoc.DocumentElement;

            if (_sceneRoot == null)
            {
                _sceneRoot = _sceneXmlDoc.CreateElement(SceneRootNodeName);
                _sceneRoot.SetAttribute("include", _builderConfig.IncludesLibFileName);
                _sceneRoot.SetAttribute("edit", "1");
                _sceneXmlDoc.AppendChild(_sceneRoot);
            }

            AddScriptsNodeIfNeeded();

            AddAnimationsNodeIfNeeded();

            AddLayersNodeIfNeeded();

            AddMapsNodeIfNeeded();
        }
Example #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;
        }
Example #9
0
        private void Build(SceneBuildInfo item)
        {
            string srcFolder = Path.Combine(SrcRoot, item.SceneName);
            string dstFolder = Path.Combine(DstRoot, item.SceneName);
            string textsXmlFileName = textBoxTextsXmlLocation.Text;
            string levelsXmlFileName = textBoxLevelsXmlLocation.Text;
            string navigationFilePath = textBoxNavigation.Text;
            string UserName = textBoxName.Text;

            if (Directory.Exists(dstFolder))
            {
                //					Tool.CleanDirectory(dstFolder);

                // 					string msg = "The destination folder " + dstFolder + " is already exists and may contain some USEFUL data. \nDo you really want to overwrite it's content?";
                // 					if (DialogResult.Yes == MessageBox.Show(msg, "Warning", MessageBoxButtons.YesNo,	MessageBoxIcon.Question))
                // 					{
                // 					}
                // 					else
                // 					{
                // 						continue;
                // 					}
            }
            else
            {
                Directory.CreateDirectory(dstFolder);
            }

            Log("Build scene '" + item.SceneName + "' from '" + srcFolder + "'");

            Builder builder = new Builder();

            BuildOptions options = new BuildOptions();

            DirectoryInfo diSrc = new DirectoryInfo(srcFolder);
            options.srcFolder = diSrc.FullName;

            DirectoryInfo diDst = new DirectoryInfo(dstFolder);
            options.dstFolder = diDst.FullName;

            options.textXmlFileName = textsXmlFileName;
            options.levelsXmlFileName = levelsXmlFileName;
            options.navigationFilePath = navigationFilePath;
            options.UserName = UserName;

            options.sceneName = item.SceneName;

            options.rebuildScene = checkBoxRebuildScene.Checked;

            options.rebuildItemsFile = checkBoxRebuildItems.Checked;
            options.rebuildHintsFile = checkBoxRebuildHints.Checked;

            options.rebuildTP = checkBoxRebuildTP.Checked;
            options.buildActiveZonesVisible = checkBoxActiveZonesVisible.Checked;
            options.buildAlphaSelection = checkBoxBuildAlphaSelection.Checked;

            options.rebuildTexts = checkBoxRebuildTexts.Checked;
            options.rebuildLevels = checkBoxRebuildLevels.Checked;
            options.rebuildNavigation = checkBoxNavigation.Checked;

            options.rebuildResourcesFile = checkBoxRebuildResources.Checked;

            options.isSubscreen = item.IsSubscreen;
            options.isMinigame = item.isMinigame;

            options.rebuildGlintsFile = checkBoxGlints.Checked;

            options.ee = checkBoxEE.Checked;
            options.hummingBird = checkBoxHummingBirds.Checked;
            options.someFuncs = checkBoxSomeFuncs.Checked;
            options.fadeAnimation = checkBoxFadeAnimations.Checked;

            options.morfing = checkBoxMorfing.Checked && checkBoxSomeFuncs.Checked;

            builder.Build2(options);
        }
Example #10
0
        public Navigation(BuilderConfig builderConfig, BuildOptions buildOptions)
        {
            _builderConfig = builderConfig;
            _buildOptions = buildOptions;

            NavigationsXML = new XmlDocument();
            QuestsXML = new XmlDocument();

            _NavFileName = null;
            _QuestsFileName = null;

            if (_buildOptions.rebuildNavigation)

            if (_buildOptions.sceneName.Contains("ce_"))
            {
                _NavFileName = "\\navigation_ce.xml";

                if (!File.Exists(_buildOptions.navigationFilePath + _NavFileName))
                {
                    _NavFileName = "\\navigation.xml";

                    if (!File.Exists(_buildOptions.navigationFilePath + _NavFileName))
                        _NavFileName = null;
                }

                _QuestsFileName = "\\quest_ce.xml";

                if (!File.Exists(_buildOptions.navigationFilePath + _QuestsFileName))
                {
                    _QuestsFileName = "\\quest.xml";

                    if (!File.Exists(_buildOptions.navigationFilePath + _QuestsFileName))
                        _QuestsFileName = null;
                }

            }
            else
            {
                _NavFileName = "\\navigation_se.xml";

                if (!File.Exists(_buildOptions.navigationFilePath + _NavFileName))
                {
                    _NavFileName = "\\navigation.xml";

                    if (!File.Exists(_buildOptions.navigationFilePath + _NavFileName))
                        _NavFileName = null;
                }

                _QuestsFileName = "\\quest_se.xml";

                if (!File.Exists(_buildOptions.navigationFilePath + _QuestsFileName))
                {
                    _QuestsFileName = "\\quest.xml";

                    if (!File.Exists(_buildOptions.navigationFilePath + _QuestsFileName))
                        _QuestsFileName = null;
                }
            }// end main if

            if (_NavFileName != null)
            {
                NavigationsXML.Load(_buildOptions.navigationFilePath + _NavFileName);

                _navRoot = (XmlElement)NavigationsXML.FirstChild;

                for (int i = 0; i < _navRoot.ChildNodes.Count; i++ )
                {
                    if (!_buildOptions.isHO)
                    {
                        if (_navRoot.ChildNodes[i].Name == _buildOptions.sceneName)
                        {
                            hasChildNodeNav = true;
                            break;
                        }
                    }
                    else
                    {
                        if (_buildOptions.isHo01)
                        {
                            if (_navRoot.ChildNodes[i].Name == _buildOptions.sceneName + "_01")
                            {
                                hasChildNodeNav = true;
                                break;
                            }
                        }

                        if (_buildOptions.isHo02)
                        {
                            if (_navRoot.ChildNodes[i].Name == _buildOptions.sceneName + "_02")
                            {
                                hasChildNodeNav = true;
                                break;
                            }
                        }
                    }

                }

            }// end Navigation file

            if (_QuestsFileName != null)
            {
                QuestsXML.Load(_buildOptions.navigationFilePath + _QuestsFileName);

                _questRoot = (XmlElement)QuestsXML.FirstChild;

                for (int i = 0; i < _questRoot.ChildNodes.Count; i++)
                {
                    if (!_buildOptions.isHO)
                    {
                        if (_questRoot.ChildNodes[i].Name == _buildOptions.sceneName)
                        {
                            hasChildNodeQuest = true;
                            break;
                        }
                    }
                    else
                    {
                        if (_buildOptions.isHo01)
                        {
                            if (_questRoot.ChildNodes[i].Name == _buildOptions.sceneName + "_01" )
                            {
                                hasChildNodeQuest = true;
                                break;
                            }
                        }
                        if (_buildOptions.isHo02)
                        {
                            if (_questRoot.ChildNodes[i].Name == _buildOptions.sceneName + "_02")
                            {
                                hasChildNodeQuest = true;
                                break;
                            }
                        }
                    }

                }

            }// end quests file
        }
Example #11
0
        public Texts(BuilderConfig builderConfig, BuildOptions buildOptions)
        {
            _builderConfig = builderConfig;
            _buildOptions = buildOptions;

            _textsXmlDoc = new XmlDocument();
            _TextsCENode = new XmlDocument();
            _TextsSENode = new XmlDocument();
            _TextsFHNode = new XmlDocument();

            _hoSets = new Dictionary<string, HoSet>();

            if (File.Exists(_buildOptions.textXmlFileName + "\\texts_config.xml"))
            {
                _textsXmlDoc.Load(_buildOptions.textXmlFileName + "\\texts_config.xml");
                //_hoItemsNode  = (XmlElement)_textsXmlDoc.DocumentElement.SelectSingleNode(HO_ITEMS_PATH);

                    if (_textsXmlDoc.ChildNodes[0] != null)
                    {
                        for (int i = 0; i < _textsXmlDoc.ChildNodes[0].ChildNodes.Count; i++)
                        {
                            switch (_textsXmlDoc.ChildNodes[0].ChildNodes[i].Attributes["file_name"].Value)
                            {
                                case "texts_first_hour.xml":
                                    _TextsFH = "\\texts_first_hour.xml";
                                    _TextsFHNode.Load(_buildOptions.textXmlFileName + _TextsFH);
                                    break;
                                case "texts_se.xml":
                                    _TextsSE = "\\texts_se.xml";
                                    _TextsSENode.Load(_buildOptions.textXmlFileName + _TextsSE);
                                    break;
                                case "texts_ce.xml":
                                    _TextsCE = "\\texts_ce.xml";
                                    _TextsCENode.Load(_buildOptions.textXmlFileName + _TextsCE);
                                    break;
                            }

                        }
                    }

                if (_buildOptions.sceneName.Contains("ce_"))
                {
                    if (_TextsCENode != null)
                    {
                        t_Document = _TextsCENode;
                        _pDocName = _TextsCE;
                    }
                }
                else
                {
                    if (_TextsFHNode != null)
                    {
                        t_Document = _TextsFHNode;
                        _pDocName = _TextsFH;
                    }
                }

                if (t_Document != null)
                {
                    String t_Desc = null;
                    String t_Desc2 = null;
                    if (_buildOptions.isMinigame)
                    {
                        t_Desc = MINIGAME_DESC_PATH;
                        t_Desc2 = "mini_games_descriptions";
                    }
                    else
                    {
                        t_Desc = HO_ITEMS_PATH;
                        t_Desc2 = "ho_items";
                    }

                    _hoItemsNode = (XmlElement)t_Document.DocumentElement.SelectSingleNode(t_Desc);
                    XmlElement _t_NodeGameplay = (XmlElement)t_Document.DocumentElement.SelectSingleNode("gameplay");

                    if (_hoItemsNode == null)
                    {
                        XmlElement t_hoItem = t_Document.CreateElement(t_Desc2);
                        _t_NodeGameplay.AppendChild(t_hoItem);
                        _hoItemsNode = t_hoItem;
                    }
                }
            }
            else if (File.Exists(_buildOptions.textXmlFileName + "\\texts.xml"))
            {
                _textsXmlDoc.Load(_buildOptions.textXmlFileName + "\\texts.xml");
                _pDocName = "texts.xml";

                String t_Desc = null;
                String t_Desc2 = null;
                if (_buildOptions.isMinigame)
                {
                    t_Desc = MINIGAME_DESC_PATH;
                    t_Desc2 = "mini_games_descriptions";
                }
                else
                {
                    t_Desc = HO_ITEMS_PATH;
                    t_Desc2 = "ho_items";
                }

                _hoItemsNode = (XmlElement)_textsXmlDoc.DocumentElement.SelectSingleNode(t_Desc);
                XmlElement _t_NodeGameplay = (XmlElement)_textsXmlDoc.DocumentElement.SelectSingleNode("gameplay");

                if (_hoItemsNode == null)
                {
                    XmlElement t_hoItem = _textsXmlDoc.CreateElement(t_Desc2);
                    _t_NodeGameplay.AppendChild(t_hoItem);
                    _hoItemsNode = t_hoItem;
                }

                t_Document = _textsXmlDoc;
            }
            else
            {
                throw new Exception("Texts file not found '" + _buildOptions.textXmlFileName +_pDocName + "'");
            }
        }