1using System.Reflection;
35 public const string fName =
"SettingsManager";
49 public static bool UseVr {
get;
set; }
74 value = Math.Clamp(value, 0f, 1f);
89#pragma warning disable CS0649
91#pragma warning restore CS0649
99 value =
new Point2(width, height);
136 for (
int i = array.Length - 1; i >= 0; i--) {
137 if (array[i] >= minValue && array[i] <= maxValue)
209 loader.WindowModeChanged(value);
277 public static string UserId {
get;
set; }
344 [Obsolete(
"该变量目前尚未使用,有待后续API版本完善。后续完善后模组可能用到,为了向未来兼容别删")]
368 List<string> result = [];
370 if (versions.Count == 0) {
373 result.Add(packageName);
374 result.Add(versions.Count.ToString());
375 foreach (
string version
in versions) {
379 return string.Join(
";", result);
382 if (
string.IsNullOrEmpty(value)) {
385 string[] array = value.Split(
';');
386 Dictionary<string, HashSet<string>> result = [];
388 while (i < array.Length) {
389 string packageName = array[i++];
390 if (
int.TryParse(array[i++], out
int count)) {
391 HashSet<string> versions =
new(count);
394 versions.Add(array[i++]);
396 result.Add(packageName, versions);
417 List<string> results = [];
419 results.Add(info.ToString());
421 return string.Join(
"||", results);
424 if (
string.IsNullOrEmpty(value)) {
427 string[] array1 = value.Split(
"||", StringSplitOptions.RemoveEmptyEntries);
428 foreach (
string str
in array1) {
453 StringBuilder sb =
new();
455 if (substitutes.Count == 0) {
458 sb.Append($
"{guid},");
460 sb.Append($
"{substitute.PackageName},{substitute.ClassName},");
475 if (
string.IsNullOrEmpty(value)) {
478 string[] array1 = value.Split(
';');
479 foreach (
string str
in array1) {
480 string[] array2 = str.Split(
',');
481 if (array2.Length < 5) {
484 string guid = array2[0];
486 for (
int i = 1; i < array2.Length; i += 2) {
497 StringBuilder sb =
new();
499 sb.Append($
"{guid},{substitute.PackageName},{substitute.ClassName};");
502 return sb.ToString();
507 if (
string.IsNullOrEmpty(value)) {
510 string[] array = value.Split(
';');
511 foreach (
string str
in array) {
512 string[] array2 = str.Split(
',');
513 if (array2.Length == 3) {
550#if ANDROID || BROWSER
569 MotdUpdateUrl = $
"{CommunityServerManager.CurrentChineseInfo.ApiUrl}/com/motd?v={0}&l={1}";
570 MotdUpdateCheckUrl = $
"{CommunityServerManager.CurrentChineseInfo.ApiUrl}com/motd?v={0}&cmd=version_check&platform={1}&apiv={2}&l={3}";
684 if (item.TryGetValue(keyName, out
object result2)) {
688 return throwIfNotFound ?
throw new ArgumentException(
string.Format(
LanguageControl.
Get(
fName,
"1"), keyName)) :
null;
696 if (item.TryGetValue(keyName, out
object result2)) {
700 return throwIfNotFound ?
throw new ArgumentException(
string.Format(
LanguageControl.
Get(
fName,
"1"), keyName)) :
null;
705 return Convert.ToInt32(result);
708 if (item.TryGetValue(keyName, out
object result2)) {
709 return Convert.ToInt32(result2);
712 return throwIfNotFound ?
throw new ArgumentException(
string.Format(
LanguageControl.
Get(
fName,
"2"), keyName)) : -1;
727 item[keyName] = value;
746 item[keyName] = value;
765 item[keyName] = value;
782 if (xElement.Elements(
"Configs").Any())
789 foreach (
string name
in valuesDictionary.Keys) {
791 PropertyInfo propertyInfo = (from pi in typeof(
SettingsManager).GetRuntimeProperties()
792 where pi.Name == name && pi.GetMethod.IsStatic && pi.GetMethod.IsPublic && pi.SetMethod.IsPublic
793 select pi).FirstOrDefault();
794 if (propertyInfo is not
null) {
795 object value = valuesDictionary.GetValue<
object>(name);
802 propertyInfo.SetValue(
null, value,
null);
806 catch (Exception ex) {
808 str =
"Setting \"{0}\" could not be loaded. Reason: {1}";
816 info =
"Loaded settings.";
823 catch (Exception e) {
825 str =
"Loading settings failed.";
846 XElement xElement =
new(
"Settings");
847 foreach (PropertyInfo item
in from pi
in typeof(
SettingsManager).GetRuntimeProperties()
848 where pi.GetMethod.IsStatic && pi.GetMethod.IsPublic && pi.SetMethod.IsPublic
851 object value = item.GetValue(
null,
null);
852 settingsValuesDictionary.SetValue(item.Name, value);
854 catch (Exception ex) {
856 str =
"Setting \"{0}\" could not be saved. Reason: {1}";
858 Log.
Warning(
string.Format(str, item.Name, ex));
861 settingsValuesDictionary.
Save(xElement);
870 info =
"Saved settings.";
874 catch (Exception e) {
876 str =
"Saving settings failed.";
static int MaxTextureSize
static void Information(object message)
static void Warning(object message)
static int Clamp(int x, int min, int max)
static float Saturate(float x)
static void CreateDirectory(string path)
static bool DirectoryExists(string path)
static Stream OpenFile(string path, OpenFileMode openFileMode)
static bool FileExists(string path)
static Action Deactivated
static WindowMode WindowMode
static void ReportExceptionToUser(string additionalMessage, Exception e)
static bool TryGet(out string result, params string[] keys)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static void SaveModSettings()
static Dictionary< string, ValuesDictionary > ModGamepadMapSettings
储存每个模组的手柄键位映射设置,键:模组包名,值:模组的键位映射设置
static Dictionary< string, ValuesDictionary > ModCameraManageSettings
储存每个模组的相机设置,键:模组包名,值:模组的相机设置
static Dictionary< string, ValuesDictionary > ModKeyboardMapSettings
储存每个模组的键盘鼠标键位映射设置,键:模组包名,值:模组的键位映射设置
static WindowMode m_windowMode
static int GetCameraManageSetting(string keyName, bool throwIfNotFound=true)
static int AnimatedTextureRefreshLimit
static int m_screenshotSizeCustomAspectRatioIndex
static CommunityContentMode CommunityContentMode
static ResolutionMode m_resolutionMode
static Action< string > SettingChanged
static string[] ScreenshotSizeCustomAspectRatiosNames
static double MotdUpdatePeriodHours
static float LowFPSToTimeDeceleration
static bool UseAPISleepTimeAcceleration
static string DatabaseSelectedClassSubstitutes
static string ScpboxUserInfo
static void SetCameraManageSetting(string keyName, int value)
仅用于修改现有相机配置,添加相机配置请使用ModLoader.GetCameraList
static float MinimumDragDistance
static float MinimumHoldDuration
static Point2 m_screenshotSizeCustom
static float MoveWidgetSize
static string DropboxAccessToken
static string BlocksTextureFileName
static string CommunityServerUserInfos
static object GetKeyboardMapping(string keyName, bool throwIfNotFound=true)
static bool DragHalfInSplit
static bool UpsideDownLayout
static bool ShowGuiInScreenshots
static Point2 ScreenshotSizeCustom
static float CreativeReach
static int GetLastIndexOfAnyInRange(this int[] array, int minValue, int maxValue)
static MoveControlMode MoveControlMode
static Point2 m_resizableWindowPosition
static string MotdUpdateUrl
static float SoundsVolume
static string LastSelectedChineseCommunityInfo
static LookControlMode LookControlMode
static bool ShortInventoryLooping
static ScreenLayout ScreenLayout2
static int NewYearCelebrationLastYear
static bool HideCrosshair
static string LastLaunchedVersion
static bool ObjectsShadowsEnabled
static float MoveWidgetMarginX
static string MotdUpdateCheckUrl
static ValuesDictionary GamepadMappingSettings
static int m_screenshotSizeCustomWidthIndex
static bool CreativeDragMaxStacking
static bool UsePrimaryMemoryBank
static ValuesDictionary CameraManageSettings
static float GamepadCursorSpeed
static Point2 m_resizableWindowSize
static float m_musicVolume
static void InitializeCameraManageSettings()
static float m_brightness
static float GamepadTriggerThreshold
手柄扳机触发阈值,范围0~1,默认0.5。扳机的按压幅度只有超过这个数时才会被视为“按下”状态,越小则越容易触发。
static int[] ScreenshotSizeCustomWidths
static int ScreenshotSizeCustomWidthIndex
static float MoveWidgetMarginY
static readonly Lock m_saveLock
static bool FlipVerticalAxis
static float CreativeDigTime
static int VisibilityRange
static float m_soundsVolume
static string BulletinTime
static ScreenshotSize ScreenshotSize
static float[] ScreenshotSizeCustomAspectRatios
static bool HorizontalCreativeFlight
static bool HideMoveLookPads
static bool TerrainMipmapsEnabled
static int IsolatedStorageMigrationCounter
static bool DeleteWorldNeedToText
static string ScpboxAccessToken
static void SetKeyboardMapping(string keyName, object value)
仅用于修改现有键盘鼠标键位,添加键位请使用ModLoader.GetKeyboardMappings
static string DatabaseClassSubstitutes
static bool FileAssociationEnabled
static string LastSelectedOriginalCommunityInfo
static ScreenLayout ScreenLayout4
static ScreenLayout ScreenLayout3
static float GamepadDeadZone
static bool LeftHandedLayout
static object GetGamepadMapping(string keyName, bool throwIfNotFound=true)
static float MoveSensitivity
static int PresentationInterval
static bool MotdUseBackupUrl
static CommunityContentMode OriginalCommunityContentMode
static ResolutionMode ResolutionMode
static WindowMode WindowMode
static void InitializeGamepadMappingSettings()
static ScreenLayout ScreenLayout1
static void SaveSettings()
static DateTime MotdLastUpdateTime
static bool FullScreenMode
static SkyRenderingMode SkyRenderingMode
static string DisabledMods
static bool ShowLogoInScreenshots
static bool DisplayFpsRibbon
static void InitializeKeyboardMappingSettings()
static bool AdaptEdgeToEdgeDisplay
static bool DisplayFpsCounter
static string MotdLastDownloadedData
static string m_databaseClassSubstitutes
static float LookSensitivity
static int ScreenshotSizeCustomAspectRatioIndex
static bool MultithreadedTerrainUpdate
static bool AllowInitialIntro
static ValuesDictionary KeyboardMappingSettings
static void SetGamepadMapping(string keyName, object value)
仅用于修改现有手柄键位,添加键位请使用ModLoader.GetGamepadMappings
static bool LoadSettings()
文件存在则读取并返回真否则返回假
static bool ShowCandidatesWindow
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Dictionary< string, List< ClassSubstitute > > ClassSubstitutes
static string SettingPath
static Dictionary< string, ClassSubstitute > SelectedClassSubstitutes
static Dictionary< string, List< ClassSubstitute > > OldClassSubstitutes
static void LoadConfigs()
static Dictionary< string, HashSet< string > > DisabledMods
static void LoadConfigsFromXml(XElement xElement)
static void SaveConfigs()
bool ContainsKey(string key)
void ApplyOverrides(ValuesDictionary overridesValuesDictionary)
static XElement LoadXmlFromStream(Stream stream, Encoding encoding, bool throwOnError)
static void SaveXmlToStream(XElement node, Stream stream, Encoding encoding, bool throwOnError)
static readonly Point2 Zero