如您所见,代码是找到一个值并将其替换,但是我希望能够从同一文件中找到其他5个类似的模式,这是构建ini文件的方式有点复杂。任何形式的“线索”或帮助都会有所帮助。
到目前为止,我设法更改了最后一个 DeadZone = 0.1和第一个DeadZone = 0.1,但是当我选择输入值时,我希望它同时覆盖所有这6个。
/初学者
这是TAInput.ini
[TAGame.PlayerInput_TA]
MouseSensitivity=10
TapTime=0.5
DoubleTapTime=0.25
GamepadDeadzone=0.1 // <-- Should not be captured either but haven't been so far.
GamepadLookScale=20
KeyboardAxisBlendTime=0
GamepadDeadzones=( Type=IPT_360, Key=XboxTypeS_RightTriggerAxis, DeadZone=0.1 )
GamepadDeadzones=( Type=IPT_360, Key=XboxTypeS_LeftTriggerAxis, DeadZone=0.1 )
GamepadDeadzones=( Type=IPT_PS4, Key=XboxTypeS_RightTriggerAxis, DeadZone=0.1 )
GamepadDeadzones=( Type=IPT_PS4, Key=XboxTypeS_LeftTriggerAxis, DeadZone=0.1 )
GamepadDeadzones=( Type=IPT_XBOX_ONE, Key=XboxTypeS_RightTriggerAxis, DeadZone=0.1 )
GamepadDeadzones=( Type=IPT_XBOX_ONE, Key=XboxTypeS_LeftTriggerAxis, DeadZone=0.1 )
[ProjectX.ControlPreset_X]
这是Form1.cs
try
{
const string FILENAME = "TAInput.ini";
string text = File.ReadAllText(FILENAME);
const string DEADZONE = @"DeadZone=0.(?<Ratio>[\d\.]+)";
Match match = Regex.Match(text, DEADZONE, RegexOptions.Multiline);
if (match.Success)
{
int index = match.Groups["Ratio"].Index;
int length = match.Groups["Ratio"].Length;
text = text.Remove(index, length);
text = text.Insert(index, nudInput.Value.ToString() + "" + "\n");
File.WriteAllText(FILENAME, text);
Process.Start(FILENAME);
}
}
catch
{
MessageBox.Show("No");
}
相关分类