Beispiel #1
0
        private static KLContractDefinition BuildPlaceholderContract()
        {
            KLContractDefinition result = new KLContractDefinition();

            // Add all placeholder tags
            foreach (var tag in KLSettings.Instance.placeholderContract.tags)
            {
                result.tags.Add(new KLTagDefinition()
                {
                    name           = tag,
                    sourceContract = KLTagDefinition.SourceContract.Placeholder
                });
            }

            // Add all placeholder variables
            foreach (var variable in KLSettings.Instance.placeholderContract.variables)
            {
                result.variables.Add(
                    new KLVariableDefinition(
                        variable,
                        false,
                        KLVariableDefinition.VariableSource.Ingame,
                        KLVariableDefinition.SourceContract.Placeholder
                        )
                    );
            }

            return(result);
        }
Beispiel #2
0
        private static void UpdateCacheContract(KLContractDefinition contract)
        {
            var cacheContract = KLSettings.Instance.cacheContract;

            foreach (var tag in contract.tags)
            {
                var oldTag = cacheContract.tags.Find(x => x.name.Equals(tag.name));
                if (oldTag != null)
                {
                    cacheContract.tags.Remove(oldTag);
                }

                cacheContract.tags.Add(new KLTagDefinition(tag)
                {
                    sourceContract = KLTagDefinition.SourceContract.Cache
                });
            }

            foreach (var variable in contract.variables)
            {
                if (variable.source != KLVariableDefinition.VariableSource.Ingame)
                {
                    continue;
                }

                var oldVar = cacheContract.variables.Find(x => x.name.Equals(variable.name));
                if (oldVar != null)
                {
                    cacheContract.variables.Remove(oldVar);
                }

                cacheContract.variables.Add(new KLVariableDefinition(variable)
                {
                    sourceContract = KLVariableDefinition.SourceContract.Cache
                });
            }

            // Set cache
            cacheContract.tags.ForEach(x => x.sourceContract      = KLTagDefinition.SourceContract.Cache);
            cacheContract.variables.ForEach(x => x.sourceContract = KLVariableDefinition.SourceContract.Cache);

            EditorUtility.SetDirty(KLSettings.Instance);
        }
        private void Draw(KLContractDefinition contract)
        {
            // ===== BEGIN TAGS =====
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Tags", EditorStyles.boldLabel);
            KLEditorUtils.DrawUILine();

            contract.tags.ForEach(x => Draw(x));

            EditorGUILayout.EndVertical();
            // ===== END TAGS =====

            // ===== BEGIN VARIABLES =====
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Variables", EditorStyles.boldLabel);
            KLEditorUtils.DrawUILine();

            contract.variables.ForEach(x => Draw(x));

            EditorGUILayout.EndVertical();
            // ===== END VARIABLES =====

            // ===== BEGIN SOUNDBANKS =====
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Soundbank files", EditorStyles.boldLabel);
            KLEditorUtils.DrawUILine();

            contract.soundbank_files.ForEach(x => Draw(x));
            EditorGUILayout.EndVertical();
            // ===== END SOUNDBANKS =====

            // ===== BEGIN CHANNELS =====
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Channels", EditorStyles.boldLabel);
            KLEditorUtils.DrawUILine();

            contract.channels.ForEach(x => Draw(x));

            EditorGUILayout.EndVertical();
            // ===== END CHANNELS =====
        }
Beispiel #4
0
        private static void UpdateContract()
        {
            // Read main contract
            var contractPath = KLEditorUtils.KRILLOUD_CONTRACT_PATH;

            if (File.Exists(contractPath))
            {
                m_mainContract = KLStartup.Serialization.Deserialize <KLContractDefinition>(contractPath);
                KLContractUpdate.Instance.GetContractData(Utils.KLUtils.KRILLOUD_PROJECT_PATH);
            }
            else
            {
                m_mainContract = new KLContractDefinition();
                KLStartup.Logger.Log("<b>[KLEditorCore]</b> Contract doesn't exist! " + contractPath);
            }

            m_placeholderContract = BuildPlaceholderContract();
            m_editorContract      = KLContractDefinition.MergeContracts(m_mainContract, m_placeholderContract);
            m_editorContract      = KLContractDefinition.MergeContracts(m_editorContract, KLSettings.Instance.cacheContract);

            UpdateCacheContract(m_mainContract);
            UpdateCacheContract(m_placeholderContract);
        }
 public void ClearCache()
 {
     cacheContract = new KLContractDefinition();
 }