|
1 | | -using Intersect.Client.Framework.Graphics; |
| 1 | +using Intersect.Client.Framework.File_Management; |
| 2 | +using Intersect.Client.Framework.Graphics; |
2 | 3 | using Intersect.Client.Framework.Gwen.ControlInternal; |
| 4 | +using Newtonsoft.Json.Linq; |
3 | 5 |
|
4 | 6 | namespace Intersect.Client.Framework.Gwen.Control; |
5 | 7 |
|
@@ -121,6 +123,7 @@ public IFont? Font |
121 | 123 | foreach (var tab in tabs) |
122 | 124 | { |
123 | 125 | tab.Font = _font; |
| 126 | + tab.FontSize = _fontSize; |
124 | 127 | } |
125 | 128 | } |
126 | 129 | } |
@@ -155,6 +158,7 @@ public TabButton AddPage(string label, string? tabName, Base? page = null) |
155 | 158 | TabButton button = new(_tabStrip) |
156 | 159 | { |
157 | 160 | Font = _font, |
| 161 | + FontSize = _fontSize, |
158 | 162 | IsTabable = false, |
159 | 163 | Page = page, |
160 | 164 | Text = label, |
@@ -211,6 +215,40 @@ public TabButton AddPage(TabButton button) |
211 | 215 | return button; |
212 | 216 | } |
213 | 217 |
|
| 218 | + public override JObject? GetJson(bool isRoot = false, bool onlySerializeIfNotEmpty = false) |
| 219 | + { |
| 220 | + var serializedProperties = base.GetJson(isRoot, onlySerializeIfNotEmpty); |
| 221 | + if (serializedProperties is null) |
| 222 | + { |
| 223 | + return null; |
| 224 | + } |
| 225 | + |
| 226 | + serializedProperties[nameof(Font)] = Font?.Name; |
| 227 | + serializedProperties[nameof(FontSize)] = FontSize; |
| 228 | + |
| 229 | + return serializedProperties; |
| 230 | + } |
| 231 | + |
| 232 | + public override void LoadJson(JToken token, bool isRoot = default) |
| 233 | + { |
| 234 | + base.LoadJson(token, isRoot); |
| 235 | + |
| 236 | + if (token is not JObject obj) |
| 237 | + { |
| 238 | + return; |
| 239 | + } |
| 240 | + |
| 241 | + if (obj.TryGetValue(nameof(Font), out var tokenFont) && tokenFont is { Type: JTokenType.String }) |
| 242 | + { |
| 243 | + Font = GameContentManager.Current.GetFont(tokenFont.Value<string>()); |
| 244 | + } |
| 245 | + |
| 246 | + if (obj.TryGetValue(nameof(FontSize), out var tokenFontSize) && tokenFontSize is { Type: JTokenType.Integer }) |
| 247 | + { |
| 248 | + FontSize = tokenFontSize.Value<int>(); |
| 249 | + } |
| 250 | + } |
| 251 | + |
214 | 252 | /// <summary> |
215 | 253 | /// Handler for tab selection. |
216 | 254 | /// </summary> |
|
0 commit comments