|
1 |
| -using Intersect.Client.Core; |
2 | 1 | using Intersect.Client.Framework.Gwen.Control;
|
3 | 2 |
|
4 | 3 | namespace Intersect.Client.Interface.Game.DescriptionWindows.Components;
|
5 | 4 |
|
6 |
| -public partial class ComponentBase : IDisposable |
| 5 | +public partial class ComponentBase(Base parent, string name = "") : ImagePanel(parent, name) |
7 | 6 | {
|
8 |
| - protected Base mParent; |
9 |
| - |
10 |
| - protected string mName; |
11 |
| - |
12 |
| - protected ImagePanel mContainer; |
13 |
| - |
14 |
| - public ComponentBase(Base parent, string name = "") |
15 |
| - { |
16 |
| - mParent = parent; |
17 |
| - mName = name; |
18 |
| - } |
19 |
| - |
20 |
| - protected virtual void GenerateComponents() |
21 |
| - { |
22 |
| - mContainer = new ImagePanel(mParent, mName); |
23 |
| - } |
24 |
| - |
25 |
| - /// <summary> |
26 |
| - /// The name of this control. |
27 |
| - /// </summary> |
28 |
| - public string Name { get { return mName; } } |
29 |
| - |
30 |
| - /// <summary> |
31 |
| - /// The base container of this control. |
32 |
| - /// </summary> |
33 |
| - public ImagePanel Container => mContainer; |
34 |
| - |
35 | 7 | /// <summary>
|
36 |
| - /// Is this component current visible? |
37 |
| - /// </summary> |
38 |
| - public bool IsVisible => mContainer.IsVisibleInTree; |
39 |
| - |
40 |
| - /// <summary> |
41 |
| - /// The current X location of the control. |
42 |
| - /// </summary> |
43 |
| - public int X => mContainer.X; |
44 |
| - |
45 |
| - /// <summary> |
46 |
| - /// The current Y location of the control. |
47 |
| - /// </summary> |
48 |
| - public int Y => mContainer.Y; |
49 |
| - |
50 |
| - /// <summary> |
51 |
| - /// The current width of the control. |
52 |
| - /// </summary> |
53 |
| - public int Width => mContainer.Width; |
54 |
| - |
55 |
| - /// <summary> |
56 |
| - /// The current Height of the control. |
57 |
| - /// </summary> |
58 |
| - public int Height => mContainer.Height; |
59 |
| - |
60 |
| - /// <summary> |
61 |
| - /// Hide the control. |
62 |
| - /// </summary> |
63 |
| - public void Hide() => mContainer.Hide(); |
64 |
| - |
65 |
| - /// <summary> |
66 |
| - /// Show the control. |
67 |
| - /// </summary> |
68 |
| - public void Show() => mContainer.Show(); |
69 |
| - |
70 |
| - /// <summary> |
71 |
| - /// Sets the control position. |
72 |
| - /// </summary> |
73 |
| - /// <param name="x">The X position to move the control to.</param> |
74 |
| - /// <param name="y">The Y position to move the control to.</param> |
75 |
| - /// <param name="itemDecriptionContainer">The container for the item description.</param> |
76 |
| - public virtual void SetPosition(int x, int y, ImagePanel? itemDecriptionContainer = null) => mContainer.SetPosition(x, y); |
77 |
| - |
78 |
| - /// <summary> |
79 |
| - /// Sets the control position based on ImagePanel. |
80 |
| - /// </summary> |
81 |
| - public virtual void SetPosition(Base _icon, SpellDescriptionWindow _descriptionWindow) => mContainer.SetPosition(_icon); |
82 |
| - |
83 |
| - /// <summary> |
84 |
| - /// Resizes the control to fit its children. |
85 |
| - /// </summary> |
86 |
| - /// <param name="width">Allow the control to resize its width.</param> |
87 |
| - /// <param name="height">Allow the control to resize its height.</param> |
88 |
| - public void SizeToChildren(bool width = true, bool height = true) => mContainer.SizeToChildren(width, height); |
89 |
| - |
90 |
| - /// <summary> |
91 |
| - /// Dispose of the object. |
| 8 | + /// Corrects the width of the component compared to the parent size. |
92 | 9 | /// </summary>
|
93 |
| - public virtual void Dispose() |
| 10 | + public virtual void CorrectWidth() |
94 | 11 | {
|
95 |
| - if(!mParent.Children.Contains(mContainer)) |
| 12 | + if (Parent == default) |
96 | 13 | {
|
97 | 14 | return;
|
98 | 15 | }
|
99 | 16 |
|
100 |
| - mParent.RemoveChild(mContainer, true); |
101 |
| - } |
102 |
| - |
103 |
| - /// <summary> |
104 |
| - /// Load the Json layout of the current component. |
105 |
| - /// </summary> |
106 |
| - public void LoadLayout() => mContainer.LoadJsonUi(Framework.File_Management.GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); |
107 |
| - |
108 |
| - /// <summary> |
109 |
| - /// Corrects the width of the component compared to the parent size. |
110 |
| - /// </summary> |
111 |
| - public virtual void CorrectWidth() |
112 |
| - { |
113 |
| - mContainer.SetSize(mParent.InnerWidth, mContainer.InnerHeight); |
| 17 | + SetSize(Parent.InnerWidth, InnerHeight); |
114 | 18 | }
|
115 | 19 | }
|
0 commit comments