internal void ShowContributors(Role role) { AbstractPersonRepository pRepo = _personRepository; AbstractFilmPersonRepository fpRepo = _filmPersonRepository; List <Guid> ids = fpRepo.ListPersonIdsForilmIdAndRole(CurrentFilm.Id, role); List <string> names = new List <string>(); foreach (Guid id in ids) { Person p = pRepo.GetById(id); names.Add(p.FullName); } if (names.Count > 0) { StringChooser chooser = new StringChooser(names); chooser.Show(); } else { string[] contribkind = { "contributors", "actors", "composers", "directors", "scriptwriters" }; string kind = contribkind[(int)role]; ReportIt("There are (as yet) no " + kind + " defined for this film"); } }
internal void ShowContributors(Role role) { FilmPersonRepository filmPersonRepo = _factory.CreateFilmPersonRepository(); PersonRepository personRepo = _factory.CreatePersonRepository(); List <Guid> ids = filmPersonRepo.ListPersonIdsForFilmIdAndRole(CurrentFilm.Id, role) as List <Guid>; List <string> fullNames = new List <string>(); foreach (Guid g in ids) { Person p = personRepo.GetById(g); fullNames.Add(p.FullName); } StringChooser chooser = new StringChooser(fullNames); chooser.Show(); }
public int ChooseString(List <string> choices) { StringChooser sc = new StringChooser(); sc.SetChoices(choices); sc.ShowDialog(); if (sc.DialogResult == System.Windows.Forms.DialogResult.OK && sc.SelectedIndex >= 0) { return(sc.SelectedIndex); } else { return(-1); } }
private Person ChooseAUniquePerson(List <Person> candidates) { Person result = null; List <string> fullNames = new List <string>(); foreach (Person p in candidates) { fullNames.Add(p.FullName); } StringChooser chooser = new StringChooser(fullNames); chooser.Show(); if (chooser.Accept) { result = _personRepository.GetByFullName(chooser.ChosenString); } return(result); }
internal void SetLocation() { List <string> descriptions = new List <string>(); foreach (Location l in _locationRepository.List()) { descriptions.Add(l.Description); } StringChooser chooser = new StringChooser(descriptions); chooser.ShowDialog(); if (chooser.Accept) { string description = chooser.ChosenString; Location loc = _locationRepository.GetByDescription(description); CurrentFilm.Location = loc; } }
private IPropertyChooser CreateChooserForProperty(PropertyInfo pi, object target) { IPropertyChooser chooser = null; if (pi.PropertyType == typeof(string)) { chooser = new StringChooser(); } else if (pi.PropertyType.IsEnumType()) { chooser = new EnumeratedTypeChooser(pi.PropertyType); } else if (pi.PropertyType.IsIntegerType()) { chooser = new IntegerChooser(pi.PropertyType); } else if (pi.PropertyType == typeof(bool)) { chooser = new BooleanChooser(); } else { chooser = new StringChooser(); } if (chooser != null) { object val = pi.GetValue(target, null); TypeConverter tc = new TypeConverter(); chooser.PropertyName = pi.Name; chooser.PropertyValue = val == null? Translator.Translate("TXT_NA") : tc.ConvertToInvariantString(val); } return(chooser); }
private Person ChooseOnePerson(List <Person> candidates) { Person result = null; List <string> fullNames = new List <string>(); PersonRepository personRepo = _factory.CreatePersonRepository(); foreach (Person p in candidates) { fullNames.Add(p.FullName); } StringChooser chooser = new StringChooser(fullNames); chooser.ShowDialog(); if (chooser.Accepted) { string fullName = chooser.ChosenString; result = personRepo.GetByFullName(fullName); } return(result); }
internal void ShowCountries() { AbstractFilmCountryRepository fcRepo = _filmCountryRepository; AbstractCountryRepository cRepo = _countryRepository; List <Guid> ids = fcRepo.ListCountryIdsForFilmId(CurrentFilm.Id); List <string> names = new List <string>(); foreach (Guid id in ids) { Country c = cRepo.GetById(id); names.Add(c.Name); } if (names.Count > 0) { StringChooser chooser = new StringChooser(names); chooser.Show(); } else { ReportIt("No countries are defined for " + CurrentFilm.Title); } }
internal void ShowCountries() { FilmCountryRepository fcRepo = _factory.CreateFilmCountryRepository(); CountryRepository cRepo = _factory.CreateCountryRepository(); List <Guid> ids = fcRepo.ListCountryIdsForFilmId(CurrentFilm.Id) as List <Guid>; List <string> names = new List <string>(); foreach (Guid g in ids) { Country c = cRepo.GetById(g); names.Add(c.Name); } if (names.Count == 0) { FilmMessageBox box = new FilmMessageBox("There are as yet no countries defined for this film."); box.Show(); } else { StringChooser chooser = new StringChooser(names); chooser.Show(); } }
internal void StoredFilms() { List <string> titles = new List <string>(); AbstractFilmRepository fRepo = _filmRepository; foreach (Film f in fRepo.List()) { if (f.Location.Id.Equals(CurrentLocation.Id)) { titles.Add(f.Title); } } if (titles.Count > 0) { StringChooser chooser = new StringChooser(titles); chooser.ShowDialog(); } else { ReportIt("There are no films stored in this location"); } }
private Person PersonToLookup() { Person result = null; StringiDalog dialog = new StringiDalog(); dialog.WhatText = "A partial Last Name"; dialog.ShowDialog(); if (dialog.Accept) { string lastName = dialog.YourString; PersonRepository personRepo = _factory.CreatePersonRepository(); List <Person> candidates = personRepo.ListByLastName(lastName) as List <Person>; switch (candidates.Count) { case 0: FilmMessageBox box = new FilmMessageBox("No known person has a last name containing " + lastName); box.Show(); break; case 1: result = candidates[0]; break; default: List <string> nameList = NameList(candidates); StringChooser chooser = new StringChooser(nameList); chooser.ShowDialog(); if (chooser.Accepted) { string fullName = chooser.ChosenString; result = personRepo.GetByFullName(fullName); } break; } } return(result); }
internal void ShowContributions(Role role) { AbstractFilmPersonRepository fpRepo = _filmPersonRepository; AbstractFilmRepository fRepo = _filmRepository; List <Guid> ids = fpRepo.ListFilmIdsForPersonIdAndRole(CurrentPerson.Id, role); List <string> titles = new List <string>(); foreach (Guid id in ids) { Film f = fRepo.GetById(id); titles.Add(f.Title); } if (titles.Count > 0) { StringChooser chooser = new StringChooser(titles); chooser.ShowDialog(); } else { string[] actions = { " contributes to", " acts in", " composes for", " directs" }; string action = actions[(int)role]; ReportIt("As yet " + CurrentPerson.FullName + action + " no film"); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var index = 0; var dialogSystem = property.FindPropertyRelative("abstractAbstractDialogInfoAsset").objectReferenceValue as AbstractDialogInfoAsset; #region LeftPart var sp = property.FindPropertyRelative("UnitType"); GUIStyle titleStyle = new GUIStyle() { fontSize = 18, alignment = TextAnchor.UpperLeft }; var leftPart = position.GetLeft(0.15f); // UnitType类型 EditorGUI.LabelField(leftPart.GetUp(0.6f), sp.enumNames[sp.enumValueIndex], titleStyle); // ID EditorGUI.LabelField(leftPart.GetBottom(.5f), "ID: " + property.FindPropertyRelative("id").intValue.ToString()); #endregion position = position.GetRight(.85f); var text = ""; bool error = false; var name = CharacterChooser.GetShowTextFromSerializedProperty(property.FindPropertyRelative("character")); name = name ?? "未设置名字 "; //EditorGUI.ObjectField(position.GetRectAtIndex(index++), property.FindPropertyRelative("character")); switch (EnumUtil.GetEnumValue <UnitType>(sp.enumValueIndex)) { case 10: //Model.UnitType.Word #region Word text = name + ":\"" + property.FindPropertyRelative("words").stringValue + "\""; break; #endregion case 11: //Model.UnitType.Choose #region Choose text = name + ":\"" + property.FindPropertyRelative("title").stringValue + "\""; break; #endregion case 12: //Model.UnitType.Narrator #region Narrator text = $"【{((NarratorType) property.FindPropertyRelative("m_NarratorType").enumValueIndex).ToString()}】"; text += property.FindPropertyRelative("wordToNarrator").stringValue; break; #endregion case 13: //Model.UnitType.ExWord #region ExWord text = name + ":\"" + property.FindPropertyRelative("words").stringValue + "\""; break; #endregion case 20: #region IF var vc1Prop = property.FindPropertyRelative("vc1"); var vc2Prop = property.FindPropertyRelative("vc2"); var ans = dialogSystem.GetValueStrings((ArgType)ValueChooser.GetArgTypeFromSerializedProperty(vc1Prop)); var vc1Type = vc1Prop.FindPropertyRelative("valueType"); var vc2Type = vc2Prop.FindPropertyRelative("valueType"); if ((vc1Type.enumValueIndex == 1 || vc2Type.enumValueIndex == 1) && ans.Count == 0 || (ValueChooser.GetArgTypeFromSerializedProperty(vc1Prop) != ValueChooser.GetArgTypeFromSerializedProperty(vc2Prop))) { error = true; text = "注意!!! 条件设置异常!!!"; // text += ValueChooser.GetArgTypeFromSerializedProperty(vc1Prop); // text += " "; // text += ValueChooser.GetArgTypeFromSerializedProperty(vc2Prop); break; } text += ValueChooser.GetShowTextFromSerializedProperty(vc1Prop); text += compare[property.FindPropertyRelative("compareType").intValue]; text += ValueChooser.GetShowTextFromSerializedProperty(vc2Prop); break; #endregion case 24: //Model.UnitType.Skip text = "SkipNum=" + property.FindPropertyRelative("skipNum").intValue; break; case 60: #region RunSetVarUnit if (dialogSystem.VarAsset.varInfos.Count == 0) { var rect = position.GetRectAtIndex(index++); EditorGUI.HelpBox(rect, "现在 Assets/DialogSystemAssets/GlobalVar.asset 中没有变量", MessageType.Error); break; } var varTypeR = position.GetRectAtIndex(index++); var varInfos = dialogSystem.GetValueInfos(); var keyArray = varInfos.Keys.ToArray(); var varIndexProp = property.FindPropertyRelative("varIndex"); var varToSetProp = property.FindPropertyRelative("varToSet"); text = keyArray[varIndexProp.intValue] + " = " + ArgChooser.GetShowTextFromSerializedProperty(varToSetProp); break; #endregion case 50: //Model.UnitType.Message #region Message var strchooser = property.FindPropertyRelative("workMessageTrigger").FindPropertyRelative("messageToTick"); text = "Tick Message : " + StringChooser.GetShowTextFromSerializedProperty(strchooser); break; #endregion case 31: #region Wait text = "等待 " + property.FindPropertyRelative("waitTime").floatValue + " s"; break; #endregion case 32: //Model.UnitType.FadeIn #region FadeIn text = "画面逐渐正常"; break; #endregion case 33: //Model.UnitType.FadeOut #region FadeOut text = "画面逐渐变色"; break; #endregion case 40: #region Panel var operateType = property.FindPropertyRelative("panelType"); switch (operateType.enumValueIndex) { case 0: //Push text = "Push " + StringChooser.GetShowTextFromSerializedProperty( property.FindPropertyRelative("panelChooser")); break; case 1: //Pop text = "Pop Panel"; break; } break; #endregion case 41: #region Scene if (property.FindPropertyRelative("useSceneMgr").boolValue&& property.FindPropertyRelative("loadBack").boolValue) { text = "LoadBack"; } else { text = "LoadScene: " + StringChooser.GetShowTextFromSerializedProperty( property.FindPropertyRelative("sceneNameChooser")); } break; #endregion case 70: #region Jump var targetAssetProp = property.FindPropertyRelative("targetAsset"); if (targetAssetProp.objectReferenceValue) { text = "跳转:" + (targetAssetProp.objectReferenceValue as AbstractDialogInfoAsset).name; } else { error = true; text = "跳转对象未设置"; } break; #endregion case 90: //Model.UnitType.Progress text += ProgressPointChooser.GetShowTextFromSerializedProperty( property.FindPropertyRelative("progressValueToSet")); break; case 80: //Model.UnitType.VarInfo text = "运行时打印变量信息"; break; case 81: //Model.UnitType.Print text = "Print:" + property.FindPropertyRelative("wordToPrint").stringValue; break; case 82: //Model.UnitType.ProcessInfo text = "运行时打印进度信息"; break; default: break; } if (error) { EditorGUI.HelpBox(position, text, MessageType.Error); } else { EditorGUI.LabelField(position, text); } }