bool ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundSettings s, SoundDevice[] devices) { var i = 0; var options = devices.ToDictionary(d => (i++).ToString(), d => d); Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => soundDevice == options[o], () => soundDevice = options[o]); item.Get<LabelWidget>("LABEL").GetText = () => options[o].Label; return item; }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); return true; }
bool ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundDevice[] devices) { var i = 0; var options = devices.ToDictionary(d => (i++).ToString(), d => d); Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => soundDevice == options[o], () => soundDevice = options[o]); var deviceLabel = item.Get<LabelWidget>("LABEL"); var font = Game.Renderer.Fonts[deviceLabel.Font]; var label = WidgetUtils.TruncateText(options[o].Label, deviceLabel.Bounds.Width, font); deviceLabel.GetText = () => label; return item; }; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); return true; }