protected override float DrawItem(SelectionItemTraits item, Transform transform, float offset) { string key = item.GetKey(); UIElement ui = new UIElement(transform); ui.SetLocation(0, offset, 18.9f, 1); if (key != null) { ui.SetButton(delegate { SelectItem(key); }); } ui.SetBGColor(item.GetColor()); ui.SetText(item.GetDisplay(), Color.black); ui = new UIElement(transform); ui.SetLocation(19, offset, 1, 1); if (key != null) { ui.SetButton(delegate { Play(key); }); } ui.SetBGColor(new Color(0.6f, 0.6f, 1)); ui.SetText("►", Color.black); // this character is strange ui.SetFontSize(Mathf.RoundToInt((float)UIScaler.GetSmallFont() * 0.5f)); return(offset + 1.05f); }
protected override float DrawItem(SelectionItemTraits item, Transform transform, float offset) { string key = item.GetKey(); UIElement ui = new UIElement(transform); ui.SetLocation(0, offset, 18.9f, 1); var audioFilePath = FindAudioPathIfExists(key); ui.SetButton(delegate { SelectItem(key ?? ""); }); ui.SetBGColor(item.GetColor()); ui.SetText(item.GetDisplay(), Color.black); ui = new UIElement(transform); ui.SetLocation(19, offset, 1, 1); ui.SetButton(delegate { Play(key); }); var rightButtonColor = !string.IsNullOrEmpty(audioFilePath) ? AVAILABLE_COLOR : UNAVAILABLE_COLOR; ui.SetBGColor(rightButtonColor); var buttonText = !string.IsNullOrEmpty(audioFilePath) ? "►" : "■"; ui.SetText(buttonText, Color.black); // this character is strange ui.SetFontSize(Mathf.RoundToInt((float)UIScaler.GetSmallFont() * 0.5f)); return(offset + 1.05f); }
private void AddTraitItem(SelectionItemTraits traitItem) { allItems.Add(traitItem); if (traitItem.AlwaysOnTop) { alwaysOnTopTraitItems.Add(traitItem.GetDisplay(), traitItem); return; } string key = traitItem.GetDisplay(); int duplicateIndex = 0; while (alphaTraitItems.ContainsKey(key)) { key = traitItem.GetDisplay() + "_" + duplicateIndex++; } traitItems.Add(traitItems.Count, traitItem); alphaTraitItems.Add(key, traitItem); }
protected virtual float DrawItem(SelectionItemTraits item, Transform transform, float offset) { string key = item.GetKey(); UIElement ui = new UIElement(transform); ui.SetLocation(0, offset, 20, 1); if (key != null) { ui.SetButton(delegate { SelectItem(key); }); } ui.SetBGColor(item.GetColor()); ui.SetText(item.GetDisplay(), Color.black); return(offset + 1.05f); }