summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs
blob: 8b883fb6597e1f6d9a21ba1cc73b9d1d11e660b7 (plain)
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
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework.Graphics;
using StardewValley;
using StardewValley.Menus;

namespace StardewModdingAPI.Inheritance.Menus
{
    public class SGameMenu : StardewValley.Menus.GameMenu
    {
        public GameMenu BaseGameMenu { get; private set; }

        public List<ClickableComponent> tabs
        {
            get { return (List<ClickableComponent>)GetBaseFieldInfo("tabs").GetValue(BaseGameMenu); }
            set { GetBaseFieldInfo("tabs").SetValue(BaseGameMenu, value); }
        }

        public List<IClickableMenu> pages
        {
            get { return (List<IClickableMenu>)GetBaseFieldInfo("pages").GetValue(BaseGameMenu); }
            set { GetBaseFieldInfo("pages").SetValue(BaseGameMenu, value); }
        }

        public static SGameMenu ConstructFromBaseClass(GameMenu baseClass)
        {
            SGameMenu s = new SGameMenu();
            s.BaseGameMenu = baseClass;
            return s;
        }

        public override void receiveRightClick(int x, int y, bool playSound = true)
        {
            if (pages[currentTab] is InventoryPage)
            {
                Program.LogInfo("INV SCREEN");
            }
            else
            {
            }
            base.receiveRightClick(x, y, playSound);
        }

        public static FieldInfo[] GetPrivateFields()
        {
            return typeof(GameMenu).GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
        }

        public static FieldInfo GetBaseFieldInfo(string name)
        {
            return typeof(GameMenu).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
        }
    }
}