Skip to content

Commit fc40ac8

Browse files
committed
- Added Restore Defaults button to the racial settings menu.
1 parent 7896e31 commit fc40ac8

File tree

1 file changed

+42
-3
lines changed
  • xivModdingFramework/General

1 file changed

+42
-3
lines changed

xivModdingFramework/General/CMP.cs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Dynamic;
44
using System.IO;
5+
using System.Linq;
56
using System.Text;
67
using System.Text.RegularExpressions;
78
using System.Threading.Tasks;
@@ -44,6 +45,31 @@ internal static async Task ApplyRgspFile(string filePath, IndexFile index = null
4445
await SetScalingParameter(rgsp, index, modlist);
4546
}
4647

48+
/// <summary>
49+
/// Disables the .rgsp file for this race, if it exists, and restores the .cmp file for the race back to default.
50+
/// </summary>
51+
/// <param name="race"></param>
52+
/// <param name="gender"></param>
53+
/// <returns></returns>
54+
public static async Task DisableRgspMod(XivSubRace race, XivGender gender)
55+
{
56+
var path = GetRgspPath(race, gender);
57+
var _modding = new Modding(XivCache.GameInfo.GameDirectory);
58+
59+
60+
var modlist = await _modding.GetModListAsync();
61+
var mod = modlist.Mods.FirstOrDefault(x => x.fullPath == path);
62+
if (mod != null && mod.enabled)
63+
{
64+
await _modding.ToggleModStatus(path, false);
65+
} else
66+
{
67+
var def = await GetScalingParameter(race, gender, true);
68+
await SetScalingParameter(def);
69+
}
70+
71+
}
72+
4773
internal static async Task RestoreDefaultScaling(string rgspPath, IndexFile index = null, ModList modlist = null)
4874
{
4975
var match = RgspPathExtractFormat.Match(rgspPath);
@@ -55,6 +81,14 @@ internal static async Task RestoreDefaultScaling(string rgspPath, IndexFile inde
5581
await RestoreDefaultScaling(race, gender, index, modlist);
5682
}
5783

84+
public static string GetRgspPath(XivSubRace race, XivGender gender)
85+
{
86+
var subraceId = (int)race;
87+
var genderId = (int)gender;
88+
var rgspFilePath = String.Format(RgspPathFormat, subraceId, genderId);
89+
return rgspFilePath;
90+
}
91+
5892
/// <summary>
5993
/// Restores the default settings back into the CMP file.
6094
/// Does NOT delete .rgsp entry.
@@ -78,11 +112,9 @@ internal static async Task RestoreDefaultScaling(XivSubRace race, XivGender gend
78112
/// <returns></returns>
79113
public static async Task SaveScalingParameter(RacialGenderScalingParameter rgsp, string sourceApplication, IndexFile index = null, ModList modlist = null)
80114
{
81-
var subraceId = (int) rgsp.Race;
82-
var genderId = (int)rgsp.Gender;
83115

84116
// Write the .rgsp file and let the DAT functions handle applying it.
85-
var rgspFilePath = String.Format(RgspPathFormat, subraceId, genderId);
117+
var rgspFilePath = GetRgspPath(rgsp.Race, rgsp.Gender);
86118

87119
var bytes = rgsp.GetBytes();
88120

@@ -104,6 +136,13 @@ public static async Task<RacialGenderScalingParameter> GetScalingParameter(XivS
104136
return cmp.GetScalingParameter(race, gender);
105137
}
106138

139+
/// <summary>
140+
/// Performs the base level alteration to the CMP file, without going through .rgsp files.
141+
/// </summary>
142+
/// <param name="data"></param>
143+
/// <param name="index"></param>
144+
/// <param name="modlist"></param>
145+
/// <returns></returns>
107146
private static async Task SetScalingParameter(RacialGenderScalingParameter data, IndexFile index = null, ModList modlist = null)
108147
{
109148
var cmp = await GetCharaMakeParameterSet(false, index, modlist);

0 commit comments

Comments
 (0)