Esempio n. 1
0
    public void ApplyCurrentState()
    {
        if (CurrentDefinition == null)
            return;

        if(CurrentDefinition.Data == null)
        {
            CurrentDefinition.Data = new Dictionary<string, LangDefParam>();
        }
        else
        {
            CurrentDefinition.Data.Clear();
        }

        foreach (var item in spawned)
        {
            if (item == null)
                continue;

            string key = item.NameInput.text.Trim();
            string description = item.DescriptionInput.text.Trim();
            string[] args = item.ParamsInput.text.Trim().Replace("\n", "").Split(',');
            for (int i = 0; i < args.Length; i++)
            {
                args[i] = args[i].Trim();
            }
            if (CurrentDefinition.ContainsKey(key))
            {
                Debug.LogError("Duplicate key! [" + key + "]");
                continue;
            }
            else
            {
                LangDefParam value = new LangDefParam();
                value.Key = key;
                value.Params = args;
                value.Desription = description;
                value.Locked = item.Lock.isOn;
                CurrentDefinition.Data.Add(key, value);
            }
        }
    }
Esempio n. 2
0
    public void Rename(string oldKey, string newKey)
    {
        if (!ContainsKey(oldKey))
        {
            Debug.LogError("No item for key '" + oldKey + "' was found to rename!");
            return;
        }
        if (ContainsKey(newKey))
        {
            Debug.LogError("There is already an item for key '" + newKey + "' cannot rename!");
            return;
        }

        // Rename process.
        LangDefParam p = Data[oldKey];

        Data.Remove(oldKey);
        p.Key = newKey;
        Data.Add(newKey, p);
    }
Esempio n. 3
0
    private static void GenItems(Dictionary <string, LangDefParam> dic)
    {
        // Auto generate item name and description definitions.
        if (Item.Items == null)
        {
            Item.LoadItems();
        }
        foreach (var item in Item.Items.Values)
        {
            // Descriptions.
            string key = item.Prefab + "_LongDesc";
            if (!dic.ContainsKey(key))
            {
                LangDefParam p = new LangDefParam();
                p.Key        = key;
                p.Desription = "The long description of the '" + item.Prefab + "' item. Please copy from English as accurately as possible.";
                dic.Add(key, p);
            }

            key = item.Prefab + "_ShortDesc";
            if (!dic.ContainsKey(key))
            {
                LangDefParam p = new LangDefParam();
                p.Key        = key;
                p.Desription = "The short description of the '" + item.Prefab + "' item. Please copy from English as accurately as possible.";
                dic.Add(key, p);
            }

            // Names
            key = item.Prefab + "_Name";
            if (!dic.ContainsKey(key))
            {
                LangDefParam p = new LangDefParam();
                p.Key        = key;
                p.Desription = "The display name of the '" + item.Prefab + "' item.";
                dic.Add(key, p);
            }
        }
    }