Ejemplo n.º 1
0
        private void Initialize()
        {
            _tesseractApi = new TesseractApi(Context, AssetsDeployment.OncePerVersion);
            setWhitelist  = new CallOnce(() => { _tesseractApi.SetWhitelist("あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめももやゆよらりるれろわゐゑをがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽんアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン"); });
            currentText   = string.Empty;

            SetBackgroundColor(Color.White);
            _path   = new Path();
            _mPaint = new Paint
            {
                Dither      = true,
                Color       = Color.Black,
                StrokeJoin  = Paint.Join.Round,
                StrokeCap   = Paint.Cap.Round,
                StrokeWidth = 15
            };
            _mPaint.SetStyle(Paint.Style.Stroke);
            _tesseractApi.Init("jpn");
        }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        exporting = false;
        for (int i = 0; i < _exportation.Count && !exporting; i++)
        {
            var ex = _exportation[i];
            exporting |= ex.Exporting;
        }

        GUILayout.BeginVertical(GUI.skin.box);
        bool allSelected = true;

        // bool allSelectedAreOpen = true;
        // bool allUnselectedAreClosed = true;
        for (int i = 0; i < _exportFields.arraySize; i++)
        {
            var element  = _exportFields.GetArrayElementAtIndex(i);
            var selected = element.isExpanded;
            allSelected &= selected;
            // var editMode = element.isExpanded;
            // if( selected ) allSelectedAreOpen &= editMode;
            // else allUnselectedAreClosed &= !editMode;
        }
        GUILayout.BeginHorizontal(GUI.skin.box);
        EditorGUI.BeginDisabledGroup(exporting);
        if (GUILayout.Button($"{( allSelected ? "Unselect" : "Select" )} All"))
        {
            for (int i = 0; i < _exportFields.arraySize; i++)
            {
                var element = _exportFields.GetArrayElementAtIndex(i);
                element.isExpanded = !allSelected;
            }
        }
        if (GUILayout.Button($"Invert Selection"))
        {
            for (int i = 0; i < _exportFields.arraySize; i++)
            {
                var element  = _exportFields.GetArrayElementAtIndex(i);
                var selected = element.FindPropertyRelative("_selected");
                selected.boolValue = !selected.boolValue;
            }
        }
        EditorGUI.EndDisabledGroup();
        // if( GUILayout.Button( $"{( allSelectedAreOpen ? "Close" : "Open" )} all selected(s)" ) ) ToggleElements( _exportFields, !allSelectedAreOpen, true );
        // if( GUILayout.Button( $"{( allUnselectedAreClosed ? "Open" : "Close" )} all unselected(s)" ) ) ToggleElements( _exportFields, allUnselectedAreClosed, false );
        GUILayout.EndHorizontal();

        EditorGUI.BeginDisabledGroup(exporting);
        _exportList.DoLayoutList();
        EditorGUI.EndDisabledGroup();
        GUILayout.EndVertical();

        GUILayout.BeginVertical(GUI.skin.box);
        GUILayout.BeginVertical(GUI.skin.box);
        GuiLabelWidthManager.New(25);
        EditorGUI.BeginDisabledGroup(exporting);
        var  authorName    = _author.Get;
        bool authorIsValid = IsValidAuthorName(authorName);

        if (!authorIsValid)
        {
            GuiColorManager.New(K10GuiStyles.RED_TINT_COLOR);
        }
        GUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Author", GUILayout.MaxWidth(40));
        authorName = EditorGUILayout.TextArea(authorName);
        EditorGUILayout.EndHorizontal();
        _author.Set = authorName;
        bool canSend = !exporting && IsValidAuthorName(authorName);

        EditorGUILayout.PropertyField(_urlField);
        EditorGUI.BeginDisabledGroup(!canSend);
        var send = GUILayout.Button("Export", K10GuiStyles.bigbuttonStyle) && canSend;

        EditorGUI.EndDisabledGroup();
        GUILayout.EndVertical();
        if (!authorIsValid)
        {
            GuiColorManager.Revert();
        }
        EditorGUI.EndDisabledGroup();
        GuiLabelWidthManager.Revert();
        GUILayout.BeginVertical(GUI.skin.box);
        if (_exportation.Count > 0)
        {
            for (int i = 0; i < _exportation.Count; i++)
            {
                var color = _exportation[i].GetColor();
                if (color.HasValue)
                {
                    GuiColorManager.New(color.Value);
                }
                GUILayout.BeginHorizontal(GUI.skin.box);
                if (color.HasValue)
                {
                    GuiColorManager.Revert();
                }
                GUILayout.BeginHorizontal(GUI.skin.box);
                GUILayout.Label("\"" + _exportation[i].Name + "\"");
                GUILayout.EndHorizontal();
                if (color.HasValue)
                {
                    GuiColorManager.New(color.Value);
                }
                GUILayout.BeginHorizontal(GUI.skin.box);
                GUILayout.Label(_exportation[i].Message);
                GUILayout.EndHorizontal();
                if (color.HasValue)
                {
                    GuiColorManager.Revert();
                }
                GUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.BeginHorizontal(GUI.skin.box);
            GUILayout.Label("No export data");
            GUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();
        GUILayout.EndVertical();
        GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();

        if (!exporting)
        {
            var exporter = target as JsonExporterData;
            int count    = exporter.FieldsCount;
            while (_exportation.Count < count)
            {
                _exportation.Add(new ExportationElement());
            }
            while (_exportation.Count > count)
            {
                _exportation.RemoveAt(_exportation.Count - 1);
            }
            for (int i = 0; i < count; i++)
            {
                var field = exporter.GetField(i);
                _exportation[i].Set(field);
            }

            if (send)
            {
                if (_exportation.Count > 0)
                {
                    JsonExporterData.OnPreExport?.Invoke();

                    var           url      = _urlField.stringValue;
                    IEventTrigger sendNext = new CallOnce(SetDataDirty);
                    for (int i = _exportation.Count - 1; i >= 0; i--)
                    {
                        var exp = _exportation[i];
                        if (exp.Ignored)
                        {
                            continue;
                        }
                        var f           = exporter.GetField(i);
                        var field       = f.Reference.Definition;
                        var batchSize   = f.BatchSize;
                        var nextTrigger = sendNext;
                        var datas       = new List <string>();
                        if (batchSize == 0)
                        {
                            datas.Add($"{{ \"tableName\": \"{field.FieldName}\", \"data\": {field.GetMemberValueSerialized()} }}");
                        }
                        else
                        {
                            var elementsCount = field.GetCount();
                            for (int e = 0; e < elementsCount; e += batchSize)
                            {
                                datas.Add($"{{ \"tableName\": \"{field.FieldName}\"," +
                                          $" \"ignoreClear\": {( ( e != 0 ) ? "true" : "false" )}," +
                                          $"\"data\": {field.GetMemberValueSerialized( e, batchSize )} }}");
                            }
                        }
                        exp.SetState(EExportStep.Queue);
                        sendNext = new CallOnce(() =>
                        {
                            exp.Trigger(url, datas, nextTrigger, authorName);
                            SetDataDirty();
                        });
                    }

                    sendNext.Trigger();
                }
            }
        }
    }
 static AgentInitializer()
 {
     InitializeAgent = () => CallOnce.TouchMe();
 }