Пример #1
0
 private static string UpdateFontName(string s)
 {
     return
         (FontPool.TryGetOrUpdateBundleFontPath(s, out var path, ".fnt", ".tft", ".cft") ?
          FontPool.ExtractFontNameFromPath(path, defaultFontDirectory) :
          "Default");
 }
Пример #2
0
        public FontPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            selector            = editorParams.DropDownListFactory();
            selector.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(selector);
            var propType = editorParams.PropertyInfo.PropertyType;
            var items    = AssetBundle.Current.EnumerateFiles(defaultFontDirectory).
                           Where(i => i.EndsWith(".fnt") || i.EndsWith(".tft") || i.EndsWith(".cft")).
                           Select(i => new DropDownList.Item(FontPool.ExtractFontNameFromPath(i, defaultFontDirectory)));

            foreach (var i in items)
            {
                selector.Items.Add(i);
            }

            var current = CoalescedPropertyValue().GetValue();

            selector.Text     = current.IsDefined ? GetFontName(current.Value) : ManyValuesText;
            selector.Changed += a => {
                SetProperty(new SerializableFont((string)a.Value));
            };
            selector.AddChangeLateWatcher(CoalescedPropertyValue(), i => {
                selector.Text = i.IsDefined ? GetFontName(i.Value): ManyValuesText;
            });
        }