コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: SettingsLogic.cs プロジェクト: CH4Code/OpenRA
        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;
        }