Beispiel #1
0
        public int Convert()
        {
            var labelNodes = m_Object.nodes.Where(n => n.InputsCount > 1);
            int written    = 0;

            foreach (var varKey in m_Object.variables.Keys)
            {
                m_Manager.ProcessVariable(varKey, m_Object.variables[varKey]);
            }

            using (m_Writer = new StatStreamWriter(m_OutputFile))
            {
                written += WriteHeader();

                m_CurrentLabelNode = m_Object.StartNode;
                written           += m_Writer.WriteLine($"label {m_Object.StartNode.StartName}:");
                written           += ProcessNode(m_Object.StartNode);
                written           += m_Writer.WriteLine("    return");

                foreach (var node in labelNodes)
                {
                    m_CurrentLabelNode = node;
                    written           += m_Writer.WriteLine(string.Empty);
                    written           += m_Writer.WriteLine($"label {node.LabelName}:");
                    written           += WriteSetNvlMode(false, 1);

                    DDNode nextNode = null;
                    written += ProcessSingleNode(node, ref nextNode);
                    written += ProcessNode(nextNode);
                    written += m_Writer.WriteLine("    return");
                }
            }

            return(written);
        }
Beispiel #2
0
        private void WriteVariables(string bornPath)
        {
            if ((m_ProcessedVariables.Keys.Count < 1) || (false == m_IsVariablesChanged))
            {
                return;
            }

            m_IsVariablesChanged = false;

            string path = m_RootPath + Path.DirectorySeparatorChar + "all-game-variables.rpy";

            m_Log.AppendLogLine($"Writing all variables to {Path.GetFileName(path)}");

            using (var writer = new StatStreamWriter(path))
            {
                var names = new List <string>(m_ProcessedVariables.Keys);

                names.Sort();
                writer.WriteLine("init python:");

                foreach (var varName in names)
                {
                    var varValue = m_ProcessedVariables[varName];

                    writer.Write($"    {varName} = ");

                    switch (varValue.type)
                    {
                    case DDVarType.String: writer.WriteLine($"\"{varValue.value}\""); break;

                    case DDVarType.Integer: writer.WriteLine($"{varValue.value}"); break;

                    case DDVarType.Boolean: writer.WriteLine(string.Format("{0}", varValue.Equals("true") ? "True" : "False")); break;
                    }
                }

                m_Log.AppendLogLine($"Variables finished. Size: {writer.TotalWritten}");
            }
        }
Beispiel #3
0
        private int WritePassIfNeed(int written, int level)
        {
            if (0 >= written)
            {
                written = m_Writer.WriteLine($"{GetPadding(level)}pass");
            }

            return(written);
        }