blob: 35e8e1b3fffec3c8351757782e33d0450429a4ad (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
namespace V3.Widgets
{
/// <summary>
/// A widget factory.
/// </summary>
// ReSharper disable once ClassNeverInstantiated.Global
public sealed class WidgetFactory
{
private IBasicWidgetFactory mFactory;
public WidgetFactory(IBasicWidgetFactory factory)
{
mFactory = factory;
}
/// <summary>
/// Creates a new button with the given text.
/// </summary>
/// <param name="text">the text of the button</param>
/// <returns>the created button</returns>
public Button CreateButton(string text)
{
return CreateTextWidget(mFactory.CreateButton(), text);
}
/// <summary>
/// Creates a new empty widget.
/// </summary>
/// <returns>the created widget</returns>
public EmptyWidget CreateEmptyWidget()
{
return mFactory.CreateEmptyWidget();
}
/// <summary>
/// Creates a new select button with the given text options.
/// </summary>
/// <param name="values">the values of the button</param>
/// <returns>the created button</returns>
public SelectButton CreateSelectButton(string[] values)
{
var widget = CreateTextWidget(mFactory.CreateSelectButton(), "");
foreach (var val in values)
widget.Values.Add(val);
return widget;
}
/// <summary>
/// Creates a new select button without options.
/// </summary>
/// <returns>the created button</returns>
public SelectButton CreateSelectButton()
{
return mFactory.CreateSelectButton();
}
/// <summary>
/// Creates a new label with the given text.
/// </summary>
/// <param name="text">the text of the label</param>
/// <returns>the created label</returns>
public Label CreateLabel(string text)
{
return CreateTextWidget(mFactory.CreateLabel(), text);
}
private T CreateTextWidget<T>(T widget, string text) where T : ITextWidget
{
widget.Text = text;
return widget;
}
public AchievementBox CreateAchievementBox()
{
return mFactory.CreateAchievementBox();
}
}
}
|