-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathRecipeBrowserClientConfig.cs
50 lines (40 loc) · 1.64 KB
/
RecipeBrowserClientConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Microsoft.Xna.Framework;
using System.ComponentModel;
using System.Reflection;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
namespace RecipeBrowser
{
class RecipeBrowserClientConfig : ModConfig
{
public override ConfigScope Mode => ConfigScope.ClientSide;
[DefaultValue(true)]
public bool ShowRecipeModSource { get; set; }
[DefaultValue(true)]
public bool ShowItemModSource { get; set; }
[DefaultValue(true)]
public bool ShowNPCModSource { get; set; }
[Header("AutomaticSettings")]
// non-player specific stuff:
[DefaultValue(typeof(Vector2), "475, 350")]
[Range(0f, 1920f)]
public Vector2 RecipeBrowserSize { get; set; }
[DefaultValue(typeof(Vector2), "400, 400")]
[Range(0f, 1920f)]
public Vector2 RecipeBrowserPosition { get; set; }
[DefaultValue(typeof(Vector2), "-310, 90")]
[Range(-1920f, 0f)]
public Vector2 FavoritedRecipePanelPosition { get; set; }
[DefaultValue(true)]
public bool OnlyShowFavoritedWhileInInventory { get; set; }
internal static void SaveConfig() {
// in-game ModConfig saving from mod code is not supported yet in tmodloader, and subject to change, so we need to be extra careful.
// This code only supports client configs, and doesn't call onchanged. It also doesn't support ReloadRequired or anything else.
MethodInfo saveMethodInfo = typeof(ConfigManager).GetMethod("Save", BindingFlags.Static | BindingFlags.NonPublic);
if (saveMethodInfo != null)
saveMethodInfo.Invoke(null, new object[] { ModContent.GetInstance< RecipeBrowserClientConfig>() });
else
RecipeBrowser.instance.Logger.Warn("In-game SaveConfig failed, code update required");
}
}
}