Ejemplo n.º 1
0
    /// <summary>
    /// Saves the selected affix type to disk and updates the entry in the AffixInfo dictionary.
    /// </summary>
    /// <returns>Whether or not there were any problems saving. Also true if there were no changes.</returns>
    public async Task <bool> SaveSelectedType()
    {
        if (selectedType == AffixType.None)
        {
            return(false);
        }

        if (!AffixInfoDisplay.IsValid)
        {
            await DialogBasic.Show("Some inputs are invalid! Make sure no fields are empty.").result;

            return(false);
        }

        if (AffixInfoDisplay.IsChanged)
        {
            var newInfo = AffixInfoDisplay.Info;
            AffixInfo.Deregister(selectedType);
            AffixInfo.Register(newInfo);
            Serializer.SaveAffixInfoToDisk(newInfo);

            // Updates all the changed variables
            AffixInfoDisplay.SetType(newInfo.Type);
        }
        return(true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Loads all affix infos from disk and registers them in the affix info dictionary
    /// </summary>
    /// <param name="folder">The path to the root data folder</param>
    public static void LoadAllAffixInfosFromDisk(string folder)
    {
        var texts = Resources.LoadAll <TextAsset>(folder);

        foreach (var text in texts)
        {
            AffixInfo.Register(DeserializeAffixInfo(text.text));
        }
    }
Ejemplo n.º 3
0
    public async Task RenameSelectedType()
    {
        if (selectedType == AffixType.None)
        {
            return;
        }

        if (!AffixInfoDisplay.IsValid)
        {
            DialogBasic.Show("Renaming requires that all changes are saved first, but there are invalid entries. Please fix all errors before trying again.");
            return;
        }

        if (AffixInfoDisplay.IsChanged)
        {
            if ((await DialogCancellable.Show("Renaming requires that all changes be saved first. Save now?").result).IsCancelled)
            {
                return;
            }

            if (await SaveSelectedType() == false)
            {
                DialogBasic.Show("There was a problem saving. Please recheck the values and try again.");
                return;
            }
        }

        var result = await DialogStringInput.ShowBlocking($"Enter a new name for '{selectedType.Name}'",
                                                          name => !AffixType.Exists(name) && AffixType.IsValidName(name), ShowInvalidNameMessage).result;

        if (result.IsOK)
        {
            string name = result.Value;

            var oldInfo = AffixInfo.GetAffixInfo(selectedType);
            AffixInfo.Deregister(selectedType);
            Serializer.DeleteAffixInfo(oldInfo.Type);

            var newType = AffixType.Replace(selectedType.ID, name);
            var newInfo = new AffixInfo(newType, oldInfo.ValueInfo, oldInfo.Description);
            AffixInfo.Register(newInfo);
            Serializer.SaveAffixInfoToDisk(newInfo);

            var display = displays[selectedType];
            displays.Remove(selectedType);
            displays.Add(newType, display);
            display.SetAffixType(newType);
            SelectType(newType);
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Shows a prompt for the user to enter a new name.
    /// </summary>
    public async Task CreateNew()
    {
        var result = await DialogStringInput.ShowBlocking("Enter a name:", name => !AffixType.Exists(name) && AffixType.IsValidName(name), ShowInvalidNameMessage).result;

        if (result.IsOK)
        {
            string name = result.Value;

            AffixInfo info = new AffixInfo(name, new AffixValueInfo());
            AffixInfo.Register(info);
            AddTypeToLIst(info.Type);
            UpdateHeight();
            SelectType(info.Type);
        }
    }
Ejemplo n.º 5
0
        private void SaveAffixInfoButton_Click(object sender, EventArgs e)
        {
            AffixProgression newProgression = new AffixProgression(localProgressionFunctionName, localProgressionParameters);

            AffixValueInfo newValueInfo = null;

            if (localValueType == AffixValueType.SingleValue)
            {
                newValueInfo = new AffixValueInfo(localBaseValueMinSingle, localBaseValueMaxSingle, newProgression);
            }
            else if (localValueType == AffixValueType.Range)
            {
                newValueInfo = new AffixValueInfo(localBaseValueMinRange, localBaseValueMaxRange, newProgression);
            }

            AffixInfo newInfo = new AffixInfo(localValueType, localName, newValueInfo, localDescription);

            Serializer.SaveAffixInfoToDisk(newInfo);
            AffixInfo.Register(newInfo);
            currentInfo = newInfo;
            UpdateAllLabels();
        }