Example #1
0
        public FormMain()
        {
            InitializeComponent();

            m_WorldHandler = new WorldHandler();             // Must be the first
            m_clock        = new DSClock();
            m_AutoSync     = new AutoSync();


            // Alarm
            m_AlarmHandler = new AlarmHandler(this);
            m_AlarmHandler.LoadAlarms();


            // Attack Planer
            m_AttackPlanHandler = new AttackPlanHandler();
            m_AttackPlanHandler.LoadAttackOrders();

            m_FormClockOnTop   = new FormStarter(() => { return(new FormClockOnTop(m_clock, m_AttackPlanHandler)); });
            m_FormAlarm        = new FormStarter(() => { return(new FormAlarm(m_AlarmHandler)); });
            m_FormAttackPlaner = new FormStarter(() => { return(new FormAttackPlaner(m_AttackPlanHandler, m_AlarmHandler, m_WorldHandler)); });
            m_FormSettings     = new FormStarter(() => { return(new FormSettings(m_WorldHandler)); });

            m_timer.Interval = 1;
            m_timer.Start();
            m_timer.Tick += new EventHandler(timer_Tick);
        }
Example #2
0
        internal MappedDataMember(MetaType declaringType, MemberInfo mi, MemberMapping map, int ordinal)
        {
            this.declaringType  = declaringType;
            this.member         = mi;
            this.ordinal        = ordinal;
            this.type           = TypeSystem.GetMemberType(mi);
            this.isNullableType = TypeSystem.IsNullableType(this.type);
            this.memberMap      = map;
            if (this.memberMap != null && this.memberMap.StorageMemberName != null)
            {
                MemberInfo[] mis = mi.DeclaringType.GetMember(this.memberMap.StorageMemberName, BindingFlags.Instance | BindingFlags.NonPublic);
                if (mis == null || mis.Length != 1)
                {
                    throw Error.BadStorageProperty(this.memberMap.StorageMemberName, mi.DeclaringType, mi.Name);
                }
                this.storageMember = mis[0];
            }
            Type storageType = this.storageMember != null?TypeSystem.GetMemberType(this.storageMember) : this.type;

            this.isDeferred = IsDeferredType(storageType);
            ColumnMapping cmap = map as ColumnMapping;

            if (cmap != null && cmap.IsDbGenerated && cmap.IsPrimaryKey)
            {
                // auto-gen identities must be synced on insert
                if ((cmap.AutoSync != AutoSync.Default) && (cmap.AutoSync != AutoSync.OnInsert))
                {
                    throw Error.IncorrectAutoSyncSpecification(mi.Name);
                }
            }
            if (cmap != null)
            {
                this.isPrimaryKey    = cmap.IsPrimaryKey;
                this.isVersion       = cmap.IsVersion;
                this.isDBGenerated   = cmap.IsDbGenerated || !string.IsNullOrEmpty(cmap.Expression) || this.isVersion;
                this.isDiscriminator = cmap.IsDiscriminator;
                this.canBeNull       = cmap.CanBeNull == null ? this.isNullableType || !this.type.IsValueType : (bool)cmap.CanBeNull;
                this.dbType          = cmap.DbType;
                this.expression      = cmap.Expression;
                this.updateCheck     = cmap.UpdateCheck;
                // auto-gen keys are always and only synced on insert
                if (this.IsDbGenerated && this.IsPrimaryKey)
                {
                    this.autoSync = AutoSync.OnInsert;
                }
                else if (cmap.AutoSync != AutoSync.Default)
                {
                    // if the user has explicitly set it, use their value
                    this.autoSync = cmap.AutoSync;
                }
                else if (this.IsDbGenerated)
                {
                    // database generated members default to always
                    this.autoSync = AutoSync.Always;
                }
            }
            this.mappedName = this.memberMap.DbName != null ? this.memberMap.DbName : this.member.Name;
        }
Example #3
0
        public override string Update(IrregularOrder order, Collection <OrderItem> orderItems)
        {
            string errorMessage = AutoSync.GetInstance().CheckServerIsFree();

            if (string.IsNullOrEmpty(errorMessage))
            {
                errorMessage = ServerConnector.GetInstance().UpdateOrderInfoRequest(order, orderItems.ToList());
            }
            errorMessage = HandleRequestResult(errorMessage);

            return(string.IsNullOrEmpty(errorMessage) == false ? errorMessage : base.Update(order, orderItems));
        }
Example #4
0
        public override string Update(IrregularOrder entity)
        {
            string errorMessage = AutoSync.GetInstance().CheckServerIsFree();

            if (string.IsNullOrEmpty(errorMessage))
            {
                errorMessage = ServerConnector.GetInstance().UpdateSingleOrderInfoRequest(entity);
            }
            errorMessage = HandleRequestResult(errorMessage);

            return(base.Update(entity));
        }
Example #5
0
        public override string Cancel(DBManagement.Ticket ticket, decimal returnFee)
        {
            string errorMessage = AutoSync.GetInstance().CheckServerIsFree();

            if (string.IsNullOrEmpty(errorMessage))
            {
                errorMessage = ServerConnector.GetInstance().CancelTicketRequest(ticket);
            }
            errorMessage = HandleRequestResult(errorMessage);

            return(string.IsNullOrEmpty(errorMessage) == false ? errorMessage : base.Cancel(ticket, returnFee));
        }
Example #6
0
        public override string Delete(Ticket entity)
        {
            string errorMessage = AutoSync.GetInstance().CheckServerIsFree();

            if (string.IsNullOrEmpty(errorMessage))
            {
                errorMessage = ServerConnector.GetInstance().CancelTicketRequest(entity);
            }
            errorMessage = HandleRequestResult(errorMessage);

            return(string.IsNullOrEmpty(errorMessage) == false ? errorMessage : base.Delete(entity));
        }
Example #7
0
 public void SaveConfiguration()
 {
     ConfigurationManager.SetValue(Resources.UILanguageKey, UILanguage);
     ConfigurationManager.SetValue(Resources.RestServiceUrlKey, RestServiceUrl);
     ConfigurationManager.SetValue(Resources.ProxyUserNameKey, Credentials.UserName);
     ConfigurationManager.SetValue(Resources.ProxyPasswordKey, Credentials.Password);
     ConfigurationManager.SetValue(Resources.ProxyDomainKey, Credentials.Domain);
     ConfigurationManager.SetValue(Resources.ProxyUseProxyKey, UseProxyServer.ToString());
     ConfigurationManager.SetValue(Resources.AutoSync, AutoSync.ToString());
     ConfigurationManager.SetValue(Resources.SyncHour, SyncHour);
     ConfigurationManager.SetValue(Resources.SyncInterval, SyncInterval.ToString());
     ConfigurationManager.Save();
 }
Example #8
0
        // Methods
        internal MappedDataMember(MetaType declaringType, MemberInfo mi, MemberMapping map, int ordinal)
        {
            this.declaringType  = declaringType;
            this.member         = mi;
            this.ordinal        = ordinal;
            this.type           = TypeSystem.GetMemberType(mi);
            this.isNullableType = TypeSystem.IsNullableType(this.type);
            this.memberMap      = map;
            if ((this.memberMap != null) && (this.memberMap.StorageMemberName != null))
            {
                MemberInfo[] member = mi.DeclaringType.GetMember(this.memberMap.StorageMemberName, BindingFlags.NonPublic | BindingFlags.Instance);
                if ((member == null) || (member.Length != 1))
                {
                    throw Error.BadStorageProperty(this.memberMap.StorageMemberName, mi.DeclaringType, mi.Name);
                }
                this.storageMember = member[0];
            }
            Type clrType = (this.storageMember != null) ? TypeSystem.GetMemberType(this.storageMember) : this.type;

            this.isDeferred = this.IsDeferredType(clrType);
            ColumnMapping mapping = map as ColumnMapping;

            if ((((mapping != null) && mapping.IsDbGenerated) && (mapping.IsPrimaryKey && (mapping.AutoSync != AutoSync.Default))) && (mapping.AutoSync != AutoSync.OnInsert))
            {
                throw Error.IncorrectAutoSyncSpecification(mi.Name);
            }
            if (mapping != null)
            {
                this.isPrimaryKey    = mapping.IsPrimaryKey;
                this.isVersion       = mapping.IsVersion;
                this.isDBGenerated   = (mapping.IsDbGenerated || !string.IsNullOrEmpty(mapping.Expression)) || this.isVersion;
                this.isDiscriminator = mapping.IsDiscriminator;
                this.canBeNull       = !mapping.CanBeNull.HasValue ? (this.isNullableType || !this.type.IsValueType) : mapping.CanBeNull.Value;
                this.dbType          = mapping.DbType;
                this.expression      = mapping.Expression;
                this.updateCheck     = mapping.UpdateCheck;
                if (this.IsDbGenerated && this.IsPrimaryKey)
                {
                    this.autoSync = AutoSync.OnInsert;
                }
                else if (mapping.AutoSync != AutoSync.Default)
                {
                    this.autoSync = mapping.AutoSync;
                }
                else if (this.IsDbGenerated)
                {
                    this.autoSync = AutoSync.Always;
                }
            }
            this.mappedName = (this.memberMap.DbName != null) ? this.memberMap.DbName : this.member.Name;
        }
Example #9
0
    void FinishedProcessingMulti(AudioClip finishedClip, List <PhonemeMarker> markers)
    {
        //Get Settings File
        string[] guids = AssetDatabase.FindAssets("ProjectSettings t:LipSyncProject");
        string   spath = "";

        if (guids.Length > 0)
        {
            spath = AssetDatabase.GUIDToAssetPath(guids[0]);

            if (guids.Length > 1)
            {
                Debug.LogWarning("LipSync: Multiple LipSyncProject files found. Only one will be used.");
            }
        }

        LipSyncProject settings = (LipSyncProject)AssetDatabase.LoadAssetAtPath(spath, typeof(LipSyncProject));

        // Create File
        string path = AssetDatabase.GetAssetPath(finishedClip);

        path = Path.ChangeExtension(path, xmlMode ? "xml" : "asset");

        try {
            LipSyncClipSetup.SaveFile(settings, path, xmlMode, "", finishedClip.length, markers.ToArray(), new EmotionMarker[0],
                                      new GestureMarker[0], finishedClip);
        } catch {
            Debug.Log(settings);
            Debug.Log(path);
            Debug.Log(xmlMode);
            Debug.Log(finishedClip);
            Debug.Log(markers);
        }

        if (currentClip < clips.Count)
        {
            AutoSync.AutoSyncOptions options = new AutoSync.AutoSyncOptions(languageModelNames[languageModel], attemptAudioConversion, allphone_ciEnabled, backtraceEnabled, beamExponent, pbeamExponent, lwValue, doCleanup, cleanupAggression);
            AutoSync.ProcessAudio(clips[currentClip], FinishedProcessingMulti, OnAutoSyncFailed, (currentClip + 1).ToString() + "/" + clips.Count.ToString(), options);
            currentClip++;
        }
        else
        {
            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();
            setup.ShowNotification(new GUIContent("Batch AutoSync Complete."));
            Close();
        }
    }
Example #10
0
        public override string  Delete(string id)
        {
            IrregularOrder irregularOrder = new IrregularOrder();

            irregularOrder.id = id;

            string errorMessage = AutoSync.GetInstance().CheckServerIsFree();

            if (string.IsNullOrEmpty(errorMessage))
            {
                errorMessage = ServerConnector.GetInstance().DeleteOrderInfoRequest(irregularOrder);
            }
            errorMessage = HandleRequestResult(errorMessage);

            return(string.IsNullOrEmpty(errorMessage) == false ? errorMessage : base.Delete(id));
        }
        /// <summary>
        /// Provides the parameter type for a given data member
        /// </summary>
        /// <param name="objectToUpsert"></param>
        /// <param name="dataMember"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        protected virtual ParameterType GetParameterType(object objectToUpsert, MetaDataMember dataMember, bool update, AutoSync autoSync)
        {
            var memberInfo = dataMember.Member;
            // the deal with columns is:
            // PK only:  criterion for INSERT, criterion for UPDATE
            // PK+GEN:   implicit/criterion for INSERT, criterion for UPDATE
            // GEN only: implicit for both
            // -:        explicit for both
            //
            // explicit is input,
            // implicit is output, 
            // criterion is input PK
            ParameterType type;
            if (dataMember.IsPrimaryKey)
            {
                if (update)
                    type = ParameterType.InputPK;
                else
                {
                    if (dataMember.IsDbGenerated)
                    {
                        if (IsSpecified(objectToUpsert, memberInfo))
                            type = ParameterType.Input;
                        else
                            type = ParameterType.Output;
                    }
                    else
                        type = ParameterType.Input;
                }
            }
            else
            {
                if (dataMember.IsDbGenerated)
                    type = ParameterType.Output;
				else if ((dataMember.AutoSync == AutoSync.Always) || (dataMember.AutoSync == autoSync))
					type = ParameterType.AutoSync;
                else
					type = ParameterType.Input;
            }
            return type;
        }
 /// <summary>
 /// Specifies the AytoSync value for this property. 
 /// AutoSync instructs the runtime how to retrieve the value after an insert or update operation.
 /// </summary>
 /// <param name="autoSync">The autosync value</param>
 /// <returns></returns>
 public IColumnMapping AutoSync(AutoSync autoSync)
 {
     return SetAttribute(Constants.AutoSync, autoSync.ToString());
 }
Example #13
0
    void OnGUI()
    {
        EditorStyles.label.wordWrap = true;

        GUILayout.Space(10);
        tab = GUILayout.Toolbar(tab, new string[] { "AutoSync Settings", "Batch Process" });
        GUILayout.Space(10);

        bool ready = true;

        if (tab == 0)
        {
            ready = currentModules.Count > 0;

            GUILayout.Space(5);
            GUILayout.Box("Presets", EditorStyles.boldLabel);
            GUILayout.Space(5);
            presetScroll = GUILayout.BeginScrollView(presetScroll, GUILayout.MaxHeight(80));
            if (presets.Length == 0)
            {
                GUILayout.Space(10);
                GUILayout.Box("No Presets Found", EditorStyles.centeredGreyMiniLabel);
            }
            else
            {
                EditorGUILayout.BeginVertical();
                for (int i = -1; i < presets.Length; i++)
                {
                    var lineRect = EditorGUILayout.BeginHorizontal();
                    if (i == presetHighlight)
                    {
                        GUI.Box(lineRect, "", (GUIStyle)"SelectionRect");
                    }

                    if (i >= 0)
                    {
                        if (GUILayout.Button(presets[i].displayName, EditorStyles.label))
                        {
                            LoadPreset(i);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("None", EditorStyles.label))
                        {
                            LoadPreset(-1);
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndScrollView();
            GUILayout.Space(5);
            var infoRect = EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUI.Box(infoRect, "", EditorStyles.helpBox);
            GUILayout.Space(5);
            if (presetHighlight == -1)
            {
                GUILayout.Box(new GUIContent("Select a preset for more information.", infoIcon), EditorStyles.label);
            }
            else
            {
                GUILayout.Box(presets[presetHighlight].displayName, EditorStyles.boldLabel);
                EditorGUILayout.LabelField(presets[presetHighlight].description, EditorStyles.label);
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(5);
            EditorGUILayout.EndVertical();
            GUILayout.Space(5);
            Rect toolbarRect = EditorGUILayout.BeginHorizontal();
            toolbarRect.x = 0;
            GUI.Box(toolbarRect, "", EditorStyles.toolbar);
            GUILayout.Box("Current Modules", EditorStyles.miniLabel);
            GUILayout.FlexibleSpace();
            Rect dropDownRect = EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Add", plusIcon, "Add a new module to the list"), EditorStyles.toolbarDropDown, GUILayout.Width(70)))
            {
                GenericMenu addMenu = new GenericMenu();
                for (int i = 0; i < autoSyncModuleTypes.Count; i++)
                {
                    bool isAdded = false;

                    for (int m = 0; m < currentModules.Count; m++)
                    {
                        if (currentModules[m].GetType() == autoSyncModuleTypes[i])
                        {
                            isAdded = true;
                            break;
                        }
                    }

                    if (isAdded)
                    {
                        addMenu.AddDisabledItem(new GUIContent(moduleInfos[autoSyncModuleTypes[i]].displayName));
                    }
                    else
                    {
                        int e = i;
                        addMenu.AddItem(new GUIContent(moduleInfos[autoSyncModuleTypes[i]].displayName), false, () => { AddModule(e); });
                    }
                }
                addMenu.AddSeparator("");
                addMenu.AddItem(new GUIContent("Get More Modules"), false, () => { RDExtensionWindow.ShowWindow("LipSync_Pro"); });
                addMenu.DropDown(dropDownRect);
            }
            if (GUILayout.Button(new GUIContent("New Preset", saveIcon, "Save the current setup as a new preset"), EditorStyles.toolbarButton, GUILayout.Width(90)))
            {
                var savePath = EditorUtility.SaveFilePanelInProject("Save AutoSync Preset", "New AutoSync Preset", "asset", "");
                if (!string.IsNullOrEmpty(savePath))
                {
                    AutoSyncPreset preset = null;

                    if (File.Exists(savePath))
                    {
                        preset = AssetDatabase.LoadAssetAtPath <AutoSyncPreset>(savePath);
                    }
                    else
                    {
                        preset = CreateInstance <AutoSyncPreset>();
                        preset.CreateFromModules(currentModules.ToArray());

                        preset.displayName = Path.GetFileNameWithoutExtension(savePath);
                        preset.description = "Using: ";
                        for (int i = 0; i < currentModules.Count; i++)
                        {
                            preset.description += currentModules[i].GetType().Name;
                            if (i < currentModules.Count - 1)
                            {
                                preset.description += ", ";
                            }
                        }
                    }

                    AssetDatabase.CreateAsset(preset, savePath);
                    AssetDatabase.Refresh();

                    presets         = AutoSyncUtility.GetPresets();
                    presetHighlight = -1;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical();
            settingsScroll = GUILayout.BeginScrollView(settingsScroll, false, false);
            if (currentModules.Count == 0)
            {
                GUILayout.Space(10);
                GUILayout.Box("No Modules Added", EditorStyles.centeredGreyMiniLabel);
            }
            else
            {
                for (int i = 0; i < currentModules.Count; i++)
                {
                    var type = currentModules[i].GetType();
                    var info = moduleInfos[type];
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);
                    GUILayout.Box(new GUIContent(info.displayName, infoIcon, info.description), EditorStyles.label);
                    GUILayout.Space(10);
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(15));
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent(minusIcon, "Remove Module")))
                    {
                        DestroyImmediate(serializedModules[i]);
                        DestroyImmediate(currentModules[i]);
                        serializedModules.RemoveAt(i);
                        currentModules.RemoveAt(i);
                        break;
                    }
                    GUILayout.Space(5);
                    EditorGUI.BeginDisabledGroup(i == 0);
                    if (GUILayout.Button(new GUIContent(upIcon, "Move Up")))
                    {
                        currentModules.Insert(i - 1, currentModules[i]);
                        currentModules.RemoveAt(i + 1);
                        serializedModules.Insert(i - 1, serializedModules[i]);
                        serializedModules.RemoveAt(i + 1);
                        break;
                    }
                    EditorGUI.EndDisabledGroup();
                    EditorGUI.BeginDisabledGroup(i + 2 > currentModules.Count);
                    if (GUILayout.Button(new GUIContent(downIcon, "Move Down")))
                    {
                        currentModules.Insert(i + 2, currentModules[i]);
                        currentModules.RemoveAt(i);
                        serializedModules.Insert(i + 2, serializedModules[i]);
                        serializedModules.RemoveAt(i);
                        break;
                    }
                    EditorGUI.EndDisabledGroup();
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                    var missing = GetMissingClipFeaturesInClipEditor(currentModules, i);
                    if (missing != ClipFeatures.None)
                    {
                        EditorGUILayout.HelpBox(string.Format("This module requires: {0}.\n These features must either be present in the clip already, or be provided by a module above this one.", missing), MessageType.Error);
                    }
                    serializedModules[i].OnInspectorGUI();
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.Space(5);
            GUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(!ready);
            if (GUILayout.Button("Start Single Process", GUILayout.Height(25)))
            {
                if (autoSyncInstance == null)
                {
                    autoSyncInstance = new AutoSync();
                }

                autoSyncInstance.RunSequence(currentModules.ToArray(), FinishedProcessingSingle, (LipSyncData)setup.data);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
        else
        {
            ready = clips.Count > 0 && currentModules.Count > 0;

            GUILayout.Space(5);
            GUILayout.Box("Select AudioClips", EditorStyles.boldLabel);
            GUILayout.Space(5);
            batchScroll = GUILayout.BeginScrollView(batchScroll);
            for (int a = 0; a < clips.Count; a++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                clips[a] = (AudioClip)EditorGUILayout.ObjectField(clips[a], typeof(AudioClip), false);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Remove", GUILayout.MaxWidth(200)))
                {
                    clips.RemoveAt(a);
                    break;
                }
                GUILayout.Space(5);
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(5);
            GUILayout.EndScrollView();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add AudioClip"))
            {
                clips.Add(null);
            }
            if (GUILayout.Button("Add Selected"))
            {
                foreach (AudioClip c in Selection.GetFiltered(typeof(AudioClip), SelectionMode.Assets))
                {
                    if (!clips.Contains(c))
                    {
                        clips.Add(c);
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            EditorGUILayout.HelpBox("Settings from the AutoSync Settings tab will be used. Make sure they are correct.", MessageType.Info);
            xmlMode         = EditorGUILayout.Toggle("Export as XML", xmlMode);
            loadTranscripts = EditorGUILayout.Toggle("Load Transcripts .txt", loadTranscripts);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(!ready);
            if (GUILayout.Button("Start Batch Process", GUILayout.Height(25)))
            {
                currentClip = 0;

                if (clips.Count > 0)
                {
                    if (autoSyncInstance == null)
                    {
                        autoSyncInstance = new AutoSync();
                    }

                    LipSyncData tempData = CreateInstance <LipSyncData>();
                    tempData.clip   = clips[currentClip];
                    tempData.length = tempData.clip.length;

                    if (loadTranscripts)
                    {
                        tempData.transcript = AutoSyncUtility.TryGetTranscript(tempData.clip);
                    }

                    autoSyncInstance.RunSequence(currentModules.ToArray(), FinishedProcessingMulti, tempData);
                }
                else
                {
                    ShowNotification(new GUIContent("No clips added for batch processing!"));
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
    }
 public DapperColumn([CallerMemberName] string columnName = "", bool primaryKey = false, AutoSync sync = AutoSync.Ever)
 {
     ColumnName = columnName;
     PrimaryKey = primaryKey;
     Sync       = sync;
 }
Example #15
0
    void OnGUI()
    {
        GUILayout.Space(10);
        tab = GUILayout.Toolbar(tab, new string[] { "AutoSync Settings", "Batch Process" });
        GUILayout.Space(10);

        if (tab == 0)
        {
            scroll = GUILayout.BeginScrollView(scroll);
            if (languageModelNames.Length > 0)
            {
                languageModel = EditorGUILayout.Popup("Language Model", languageModel, languageModelNames, GUILayout.MaxWidth(400));
                if (clip == null)
                {
                    ready = false;
                }
                else
                {
                    ready = true;
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No language models found. You can download language models from the extensions window or the LipSync website.", MessageType.Error);
                ready = false;
            }
            GUILayout.Space(5);
            EditorGUI.BeginDisabledGroup(!soXDefined);
            attemptAudioConversion = EditorGUILayout.Toggle(new GUIContent("Enable Audio Conversion", "Improves compatibility with a wider range of Audio Formats by creating a temporary copy of your file and converting it to the correct format."), attemptAudioConversion);
            EditorGUI.EndDisabledGroup();
            if (!soXDefined)
            {
                GUILayout.Space(5);
                EditorGUILayout.HelpBox("SoX Audio Converter is not defined. See \"Using SoX with AutoSync.pdf\" for more info.", MessageType.Warning);
            }
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Default Preset"))
            {
                if (languageModelNames == null)
                {
                    return;
                }
                if (languageModelNames.Length == 0)
                {
                    return;
                }

                AutoSync.AutoSyncOptions preset = new AutoSync.AutoSyncOptions(languageModelNames[languageModel], attemptAudioConversion, AutoSync.AutoSyncOptionsPreset.Default);

                doCleanup          = preset.doCleanup;
                cleanupAggression  = preset.cleanupAggression;
                allphone_ciEnabled = preset.allphone_ciEnabled;
                backtraceEnabled   = preset.backtraceEnabled;
                beamExponent       = preset.beamExponent;
                pbeamExponent      = preset.pbeamExponent;
                lwValue            = preset.lwValue;

                cleanupBool.target = doCleanup;
            }
            if (GUILayout.Button("High Quality Preset"))
            {
                if (languageModelNames == null)
                {
                    return;
                }
                if (languageModelNames.Length == 0)
                {
                    return;
                }

                AutoSync.AutoSyncOptions preset = new AutoSync.AutoSyncOptions(languageModelNames[languageModel], attemptAudioConversion, AutoSync.AutoSyncOptionsPreset.HighQuality);

                doCleanup          = preset.doCleanup;
                cleanupAggression  = preset.cleanupAggression;
                allphone_ciEnabled = preset.allphone_ciEnabled;
                backtraceEnabled   = preset.backtraceEnabled;
                beamExponent       = preset.beamExponent;
                pbeamExponent      = preset.pbeamExponent;
                lwValue            = preset.lwValue;

                cleanupBool.target = doCleanup;
            }
            GUILayout.EndHorizontal();
            doCleanup          = EditorGUILayout.Toggle(new GUIContent("Enable Auto Cleanup", "Will attempt to improve quality by removing markers close to other markers"), doCleanup);
            cleanupBool.target = doCleanup;
            if (EditorGUILayout.BeginFadeGroup(cleanupBool.faded))
            {
                cleanupAggression = EditorGUILayout.Slider(new GUIContent("Cleanup Aggression", "How aggressive auto cleanup is. VERY low values recommended."), cleanupAggression, 0, 1);
                if (cleanupAggression > 0.01f)
                {
                    if (cleanupAggression > 0.2f)
                    {
                        if (cleanupAggression > 0.95f)
                        {
                            EditorGUILayout.HelpBox("This will literally remove every marker.", MessageType.Error);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Honestly, LOW values are best.", MessageType.Warning);
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Cleanup Aggression should be a very low value to avoid removing wanted markers.", MessageType.Info);
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();
            GUILayout.Space(10);
            advancedOptions     = EditorGUILayout.Toggle(new GUIContent("Show Advanced Options", "Warning: These options can cause more problems than they solve if set wrong!"), advancedOptions);
            advancedBool.target = advancedOptions;
            if (EditorGUILayout.BeginFadeGroup(advancedBool.faded))
            {
                GUILayout.Label("Advanced", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox("Leave these options alone unless you know what you're doing! Incorrect settings here can seriously reduce AutoSync quality.", MessageType.Warning);
                allphone_ciEnabled = EditorGUILayout.Toggle("Enable Allphone_ci", allphone_ciEnabled);
                backtraceEnabled   = EditorGUILayout.Toggle("Enable Backtrace", backtraceEnabled);
                beamExponent       = EditorGUILayout.IntField("Beam Exponent", beamExponent);
                pbeamExponent      = EditorGUILayout.IntField("Pbeam Exponent", pbeamExponent);
                lwValue            = EditorGUILayout.FloatField("Lw Value", lwValue);
            }
            EditorGUILayout.EndFadeGroup();
            GUILayout.EndScrollView();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(!ready);
            if (GUILayout.Button("Start Single Process", GUILayout.Height(25)))
            {
                AutoSync.AutoSyncOptions options = new AutoSync.AutoSyncOptions(languageModelNames[languageModel], attemptAudioConversion, allphone_ciEnabled, backtraceEnabled, beamExponent, pbeamExponent, lwValue, doCleanup, cleanupAggression);
                AutoSync.ProcessAudio(clip, FinishedProcessingSingle, OnAutoSyncFailed, options);
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
        else
        {
            if (languageModelNames.Length > 0)
            {
                ready = true;
            }
            else
            {
                EditorGUILayout.HelpBox("No language models found. You can download language models from the extensions window or the LipSync website.", MessageType.Warning);
                ready = false;
            }
            GUILayout.Space(5);
            GUILayout.Box("Select AudioClips", EditorStyles.boldLabel);
            GUILayout.Space(10);
            scroll = GUILayout.BeginScrollView(scroll);
            for (int a = 0; a < clips.Count; a++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                clips[a] = (AudioClip)EditorGUILayout.ObjectField(clips[a], typeof(AudioClip), false);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Remove", GUILayout.MaxWidth(200)))
                {
                    clips.RemoveAt(a);
                    break;
                }
                GUILayout.Space(5);
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(5);
            GUILayout.EndScrollView();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add AudioClip"))
            {
                clips.Add(null);
            }
            if (GUILayout.Button("Add Selected"))
            {
                foreach (AudioClip c in Selection.GetFiltered(typeof(AudioClip), SelectionMode.Assets))
                {
                    if (!clips.Contains(c))
                    {
                        clips.Add(c);
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            EditorGUILayout.HelpBox("Settings from the AutoSync Settings tab will be used. Make sure they are correct.", MessageType.Info);
            xmlMode = EditorGUILayout.Toggle("Export as XML", xmlMode);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(!ready);
            if (GUILayout.Button("Start Batch Process", GUILayout.Height(25)))
            {
                if (clips.Count > 0)
                {
                    currentClip = 1;
                    AutoSync.AutoSyncOptions options = new AutoSync.AutoSyncOptions(languageModelNames[languageModel], attemptAudioConversion, allphone_ciEnabled, backtraceEnabled, beamExponent, pbeamExponent, lwValue, doCleanup, cleanupAggression);
                    AutoSync.ProcessAudio(clips[0], FinishedProcessingMulti, OnAutoSyncFailed, "1/" + clips.Count.ToString(), options);
                }
                else
                {
                    ShowNotification(new GUIContent("No clips added for batch processing!"));
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
    }
Example #16
0
    private void FinishedProcessingMulti(LipSyncData outputData, AutoSync.ASProcessDelegateData data)
    {
        if (data.success)
        {
            var settings = LipSyncEditorExtensions.GetProjectFile();

            // Create File
            string outputPath = AssetDatabase.GetAssetPath(outputData.clip);
            outputPath = Path.ChangeExtension(outputPath, xmlMode ? "xml" : "asset");

            try
            {
                LipSyncClipSetup.SaveFile(settings, outputPath, xmlMode, outputData.transcript, outputData.length, outputData.phonemeData, outputData.emotionData,
                                          outputData.gestureData, outputData.clip);
            }
            catch (Exception e)
            {
                Debug.LogError(e.StackTrace);
            }
        }
        else
        {
            batchIncomplete = true;
            string clipName = "Undefined";
            if (outputData.clip)
            {
                clipName = outputData.clip.name;
            }

            Debug.LogErrorFormat("AutoSync: Processing failed on clip '{0}'. Continuing with batch.", clipName);
        }

        if (currentClip < clips.Count)
        {
            currentClip++;

            if (autoSyncInstance == null)
            {
                autoSyncInstance = new AutoSync();
            }

            LipSyncData tempData = CreateInstance <LipSyncData>();
            tempData.clip   = clips[currentClip];
            tempData.length = tempData.clip.length;

            if (loadTranscripts)
            {
                tempData.transcript = AutoSyncUtility.TryGetTranscript(tempData.clip);
            }

            autoSyncInstance.RunSequence(currentModules.ToArray(), FinishedProcessingMulti, tempData);
        }
        else
        {
            AssetDatabase.Refresh();
            EditorUtility.ClearProgressBar();

            if (!batchIncomplete)
            {
                setup.ShowNotification(new GUIContent("Batch AutoSync Completed Successfully"));
            }
            else
            {
                setup.ShowNotification(new GUIContent("Batch AutoSync Completed With Errors"));
            }

            Close();
        }
    }
 /// <summary>
 /// Specifies the AytoSync value for this property.
 /// AutoSync instructs the runtime how to retrieve the value after an insert or update operation.
 /// </summary>
 /// <param name="autoSync">The autosync value</param>
 /// <returns></returns>
 public IColumnMapping AutoSync(AutoSync autoSync)
 {
     return(SetAttribute(Constants.AutoSync, autoSync.ToString()));
 }
		internal MappedDataMember(MetaType declaringType, MemberInfo mi, MemberMapping map, int ordinal)
		{
			this.declaringType = declaringType;
			this.member = mi;
			this.ordinal = ordinal;
			this.type = TypeSystem.GetMemberType(mi);
			this.isNullableType = TypeSystem.IsNullableType(this.type);
			this.memberMap = map;
			if(this.memberMap != null && this.memberMap.StorageMemberName != null)
			{
				MemberInfo[] mis = mi.DeclaringType.GetMember(this.memberMap.StorageMemberName, BindingFlags.Instance | BindingFlags.NonPublic);
				if(mis == null || mis.Length != 1)
				{
					throw Error.BadStorageProperty(this.memberMap.StorageMemberName, mi.DeclaringType, mi.Name);
				}
				this.storageMember = mis[0];
			}
			Type storageType = this.storageMember != null ? TypeSystem.GetMemberType(this.storageMember) : this.type;
			this.isDeferred = IsDeferredType(storageType);
			ColumnMapping cmap = map as ColumnMapping;
			if(cmap != null && cmap.IsDbGenerated && cmap.IsPrimaryKey)
			{
				// auto-gen identities must be synced on insert
				if((cmap.AutoSync != AutoSync.Default) && (cmap.AutoSync != AutoSync.OnInsert))
				{
					throw Error.IncorrectAutoSyncSpecification(mi.Name);
				}
			}
			if(cmap != null)
			{
				this.isPrimaryKey = cmap.IsPrimaryKey;
				this.isVersion = cmap.IsVersion;
				this.isDBGenerated = cmap.IsDbGenerated || !string.IsNullOrEmpty(cmap.Expression) || this.isVersion;
				this.isDiscriminator = cmap.IsDiscriminator;
				this.canBeNull = cmap.CanBeNull == null ? this.isNullableType || !this.type.IsValueType : (bool)cmap.CanBeNull;
				this.dbType = cmap.DbType;
				this.expression = cmap.Expression;
				this.updateCheck = cmap.UpdateCheck;
				// auto-gen keys are always and only synced on insert
				if(this.IsDbGenerated && this.IsPrimaryKey)
				{
					this.autoSync = AutoSync.OnInsert;
				}
				else if(cmap.AutoSync != AutoSync.Default)
				{
					// if the user has explicitly set it, use their value
					this.autoSync = cmap.AutoSync;
				}
				else if(this.IsDbGenerated)
				{
					// database generated members default to always
					this.autoSync = AutoSync.Always;
				}
			}
			this.mappedName = this.memberMap.DbName != null ? this.memberMap.DbName : this.member.Name;
		}
Example #19
0
        /// <summary>
        /// Provides the parameter type for a given data member
        /// </summary>
        /// <param name="objectToUpsert"></param>
        /// <param name="dataMember"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        protected virtual ParameterType GetParameterType(MetaDataMember dataMember, bool update, AutoSync autoSync)
        {
            var memberInfo = dataMember.Member;
            // the deal with columns is:
            // PK only:  criterion for INSERT, criterion for UPDATE
            // PK+GEN:   implicit/criterion for INSERT, criterion for UPDATE
            // GEN only: implicit for both
            // -:        explicit for both
            //
            // explicit is input,
            // implicit is output,
            // criterion is input PK
            ParameterType type;

            if (dataMember.IsPrimaryKey)
            {
                if (update)
                {
                    type = ParameterType.InputPK;
                }
                else
                {
                    if (dataMember.IsDbGenerated)
                    {
                        type = ParameterType.Output;
                    }
                    else
                    {
                        type = ParameterType.Input;
                    }
                }
            }
            else
            {
                if (dataMember.IsDbGenerated)
                {
                    type = ParameterType.Output;
                }
                else if ((dataMember.AutoSync == AutoSync.Always) || (dataMember.AutoSync == autoSync))
                {
                    type = ParameterType.AutoSync;
                }
                else
                {
                    type = ParameterType.Input;
                }
            }
            return(type);
        }