namespace V3.Widgets { /// /// A widget factory. /// // ReSharper disable once ClassNeverInstantiated.Global public sealed class WidgetFactory { private IBasicWidgetFactory mFactory; public WidgetFactory(IBasicWidgetFactory factory) { mFactory = factory; } /// /// Creates a new button with the given text. /// /// the text of the button /// the created button public Button CreateButton(string text) { return CreateTextWidget(mFactory.CreateButton(), text); } /// /// Creates a new empty widget. /// /// the created widget public EmptyWidget CreateEmptyWidget() { return mFactory.CreateEmptyWidget(); } /// /// Creates a new select button with the given text options. /// /// the values of the button /// the created button public SelectButton CreateSelectButton(string[] values) { var widget = CreateTextWidget(mFactory.CreateSelectButton(), ""); foreach (var val in values) widget.Values.Add(val); return widget; } /// /// Creates a new select button without options. /// /// the created button public SelectButton CreateSelectButton() { return mFactory.CreateSelectButton(); } /// /// Creates a new label with the given text. /// /// the text of the label /// the created label public Label CreateLabel(string text) { return CreateTextWidget(mFactory.CreateLabel(), text); } private T CreateTextWidget(T widget, string text) where T : ITextWidget { widget.Text = text; return widget; } public AchievementBox CreateAchievementBox() { return mFactory.CreateAchievementBox(); } } }