private void UndoSystem_ListOfActionsChanged(object sender, EventArgs e) { if (!Destroyed) { //!!!!is not too much updates? EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime() + 3.1); EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime() + 0.5); EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime()); } }
public static void Update() { EngineToolTip.UpdateAllInstances(); var control = GetControlOverCursor(); if (currentControl != control) { //end old currentControl = null; currentControlForm?.Close(); currentControlForm = null; //start new if (control != null) { (EngineToolTip toolTip, string text)tuple = EngineToolTip.GetToolTipByControl(control); if (tuple.toolTip != null && !string.IsNullOrEmpty(tuple.text)) { currentControl = control; currentControlText = tuple.text; currentControlStartTime = EngineApp.GetSystemTime(); currentCursorPosition = Control.MousePosition; } } } //show form if (currentControl != null && currentControlForm == null) { //reset counter when mouse moved if (currentCursorPosition != Control.MousePosition) { currentCursorPosition = Control.MousePosition; currentControlStartTime = EngineApp.GetSystemTime(); } //show form if (EngineApp.GetSystemTime() > currentControlStartTime + initialDelay) { currentControlForm = new EngineToolTipForm(currentControlText); currentControlForm.StartPosition = FormStartPosition.Manual; var mouse = Control.MousePosition; currentControlForm.Location = new Point(mouse.X, mouse.Y + (int)(16.0f * EditorAPI.DPIScale)); currentControlForm.Show(); } } }
private void timer1_Tick(object sender, EventArgs e) { if (!IsHandleCreated || WinFormsUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication) { return; } if (!WinFormsUtility.IsControlVisibleInHierarchy(this)) { return; } double updateTime = 0.05; { var count = EditorForm.Instance.GetObjectsInFocus().Objects.Length; if (count > 2000) { updateTime = 2.0; } else if (count > 500) { updateTime = 1.0; } else if (count > 250) { updateTime = 0.5; } else if (count > 100) { updateTime = 0.1; } else { updateTime = 0.05; } } if (EngineApp.GetSystemTime() - lastUpdateTime < updateTime) { return; } UpdateSelectedPanel(); lastUpdateTime = EngineApp.GetSystemTime(); }
protected override void OnTick(Viewport viewport, double delta) { if (pathTest) { found = false; path = null; error = null; if (GetPositionByCursor(viewport, out endPosition)) { var startTime = EngineApp.GetSystemTime(); //if( stepSize < .1f ) // stepSize = .1f; //if( polygonPickExtents < .001f ) // polygonPickExtents = .001f; //MathFunctions.Clamp( ref maxPolygonPath, 1, 65536 ); //MathFunctions.Clamp( ref maxSmoothPath, 1, 65536 ); //MathFunctions.Clamp( ref maxSteerPoints, 1, 256 ); var context = new Component_Pathfinding.FindPathContext(); context.Start = startPosition; context.End = endPosition; owner.FindPath(context); found = context.Path != null; path = context.Path; error = context.Error; //found = owner.FindPath( startPosition, endPosition, // stepSize, new Vec3( polygonPickExtents, polygonPickExtents, polygonPickExtents ), // maxPolygonPath, maxSmoothPath, maxSteerPoints, out path ); var endTime = EngineApp.GetSystemTime(); if ((EngineApp.GetSystemTime() - timeLastUpdateTime) > 0.25) { timeLastUpdateTime = EngineApp.GetSystemTime(); time = endTime - startTime; } } } }
public bool IsTimeToUpdate() { double time = EngineApp.GetSystemTime(); double step = time - lastRenderTime; float invFPS = 0; if (automaticUpdateFPS != 0) { invFPS = 1.0f / automaticUpdateFPS; } if (step >= invFPS) { return(true); } return(false); }
public void EditorUpdateWhenDocumentModified_Tick() { bool update = false; var currentTime = EngineApp.GetSystemTime(); again :; for (int n = 0; n < editorUpdateWhenDocumentModified_NeedUpdate.Count; n++) { var time = editorUpdateWhenDocumentModified_NeedUpdate[n]; if (currentTime >= time) { editorUpdateWhenDocumentModified_NeedUpdate.RemoveAt(n); update = true; goto again; } } //update if (update) { if (loadedResource != null && loadedResource.ResultComponent != null) { var rootComponent = loadedResource.ResultComponent; var component2 = rootComponent as IComponent_EditorUpdateWhenDocumentModified; if (component2 != null) { component2.EditorUpdateWhenDocumentModified(); } foreach (var component in rootComponent.GetComponents <IComponent_EditorUpdateWhenDocumentModified>(checkChildren: true)) { component.EditorUpdateWhenDocumentModified(); } } } }
private void timer1_Tick(object sender, EventArgs e) { if (!IsHandleCreated || EditorUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication) { return; } var newValue = avalonTextEditor.Editor.Text; if (sentTextToEngineUndoSystem != newValue) { sentTextToEngineUndoSystem = newValue; var oldValue = Script.Code; //!!!!в опции редактора var time = 3.0; disableUpdateRestoreTime = EngineApp.GetSystemTime() + time; Script.TemporarilyDisableUpdate = true; if (newValue != Script.Code.Value) { //update Code Script.Code = newValue; //add undo var undoItems = new List <UndoActionPropertiesChange.Item>(); var property = (Metadata.Property)MetadataManager.GetTypeOfNetType( typeof(Component_ShaderScript)).MetadataGetMemberBySignature("property:Code"); undoItems.Add(new UndoActionPropertiesChange.Item(Script, property, oldValue)); var undoAction = new UndoActionPropertiesChange(undoItems); Document.CommitUndoAction(undoAction); } } if (disableUpdateRestoreTime != 0 && EngineApp.GetSystemTime() > disableUpdateRestoreTime) { Script.TemporarilyDisableUpdate = false; disableUpdateRestoreTime = 0; //!!!! ////to refresh preview texture //Script.RaiseCodeChangedEventAndSetNeedUpdate(); //update materials. EditorUpdateWhenDocumentModified Document.EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime() + 0.1); } if (displayLineNumbers != ProjectSettings.Get.ShaderEditorDisplayLineNumbers) { displayLineNumbers = ProjectSettings.Get.ShaderEditorDisplayLineNumbers; avalonTextEditor.Editor.ShowLineNumbers = displayLineNumbers; } if (wordWrap != ProjectSettings.Get.ShaderEditorWordWrap) { wordWrap = ProjectSettings.Get.ShaderEditorWordWrap; avalonTextEditor.Editor.WordWrap = wordWrap; } UpdateBackgroundForeground(); UpdateFont(); }
private void timer1_Tick(object sender, EventArgs e) { if (EditorUtility.IsDesignerHosted(this)) { return; } if (!loaded) { return; } //!!!!!slowly? //!!!!!! //if( needSelectResource != null ) //{ // var selectResource = needSelectResource; // needSelectResource = null; // //ContentObjectSettings.Instance.SelectResource( selectResource ); //} //UpdatePagesVisibility(); //!!!!! //!!!!где еще вызывать? if (EngineApp.Instance != null) { EngineApp.DoTick(); } if (EngineApp.GetSystemTime() - lastSlowUpdatingTime > 0.2 && !firstTick) { QATButtonsUpdate(); RibbonUpdate(); UpdateText(); lastSlowUpdatingTime = EngineApp.GetSystemTime(); } //save editor settings EditorSettingsSerialization.Dump(); ScreenNotifications.Update(); if (!needClose) { EditorAPI.SelectedDocumentWindowChangedUpdate(); } if (!needClose) { foreach (var document in EditorAPI.Documents) { document.EditorUpdateWhenDocumentModified_Tick(); } } if (!needClose) { PreviewIconsManager.Update(); } ////!!!!temp //CheckRestartApplicationToApplyChanged(); if (!needClose) { UpdateSoundSystem(); } //save editor settings if (!needClose) { KryptonAutoHiddenSlidePanel.Animate = ProjectSettings.Get.AnimateWindowsAutoHiding; } //if( !needClose ) // ScriptEditorEngine.Instance.UpdateSettings(); UpdateVisibilityOfFloatingWindows(); if (needClose) { needClose = false; Close(); } if (firstTick) { //!!!!new firstTick = false; if (SplashForm.Instance != null) { SplashForm.Instance.AllowClose = true; } // hide cover show ribbon. kryptonRibbon.Visible = true; if (coverControl != null) { Controls.Remove(coverControl); } //coverControl.Visible = false; if (EditorSettingsSerialization.ShowTipsAsStartup) { EditorAPI.ShowTips(); } } canSaveConfig = true; firstTick = false; }
private void timer1_Tick(object sender, EventArgs e) { if (!IsHandleCreated || WinFormsUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication) { return; } if (!loaded) { return; } //!!!!!slowly? //!!!!!! //if( needSelectResource != null ) //{ // var selectResource = needSelectResource; // needSelectResource = null; // //ContentObjectSettings.Instance.SelectResource( selectResource ); //} //UpdatePagesVisibility(); //!!!!! //!!!!где еще вызывать? if (EngineApp.Instance != null) { EngineApp.DoTick(); } if (EngineApp.GetSystemTime() - lastSlowUpdatingTime > 0.2 && !firstTick) { QATButtonsUpdate(); RibbonUpdate(); UpdateText(); lastSlowUpdatingTime = EngineApp.GetSystemTime(); } //save editor settings EditorSettingsSerialization.Dump(); ScreenNotifications.Update(); if (!needClose) { EditorAPI.SelectedDocumentWindowChangedUpdate(); } if (!needClose) { foreach (var document in EditorAPI.Documents) { document.EditorUpdateWhenDocumentModified_Tick(); } } //if( !needClose ) // PreviewImagesManager.Update(); ////!!!!temp //CheckRestartApplicationToApplyChanged(); if (!needClose) { UpdateSoundSystem(); } //save editor settings if (!needClose) { KryptonAutoHiddenSlidePanel.Animate = ProjectSettings.Get.AnimateWindowsAutoHiding; } //if( !needClose ) // ScriptEditorEngine.Instance.UpdateSettings(); UpdateVisibilityOfFloatingWindows(); if (needClose) { needClose = false; Close(); } //open file at startup if (firstTick && !needClose) { var realFileName = EditorSettingsSerialization.OpenFileAtStartup; EditorSettingsSerialization.OpenFileAtStartup = ""; if (File.Exists(realFileName)) { //select new file in Resources window EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { realFileName }); //open file EditorAPI.OpenFileAsDocument(realFileName, true, true); } } if (firstTick) { firstTick = false; if (SplashForm.Instance != null) { SplashForm.Instance.AllowClose = true; } // hide cover show ribbon. kryptonRibbon.Visible = true; if (coverControl != null) { Controls.Remove(coverControl); } //coverControl.Visible = false; Invalidate(true); if (EditorSettingsSerialization.ShowTipsAsStartup) { EditorAPI.ShowTips(); } } if (unlockFormUpdateInTimer.HasValue && (DateTime.Now - unlockFormUpdateInTimer.Value).TotalSeconds > 0) { KryptonWinFormsUtility.LockFormUpdate(null); unlockFormUpdateInTimer = null; } if (!needClose) { EngineToolTipManager.Update(); } canSaveConfig = true; }
//private void Editor_TextChanged( object sender, EventArgs e ) //{ //if( disableTextChanged ) // return; //var newText = scriptEditorControl.Editor.Text; //if( Script.Code.Value != newText ) //{ // var oldValue = Script.Code; // //!!!! // Script.DisableUpdate = true; // Script.Code = newText; // var undoItems = new List<UndoActionPropertiesChange.Item>(); // var property = (Metadata.Property)MetadataManager.GetTypeOfNetType( // typeof( Component_CSharpScript ) ).MetadataGetMemberBySignature( "property:Code" ); // undoItems.Add( new UndoActionPropertiesChange.Item( Script, property, oldValue ) ); // var undoAction = new UndoActionPropertiesChange( undoItems ); // Document.CommitUndoAction( undoAction ); // //!!!! // Log.Info( "undo added" ); // //!!!! // scriptEditorControl.Editor.Document.UndoStack.ClearAll(); //} //} private void timer1_Tick(object sender, EventArgs e) { if (!IsHandleCreated || EditorUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication) { return; } var newValue = scriptEditorControl.Editor.Text; if (sentTextToEngineUndoSystem != newValue) { sentTextToEngineUndoSystem = newValue; var oldValue = Script.Code; //!!!!в опции редактора var time = 3.0; disableUpdateRestoreTime = EngineApp.GetSystemTime() + time; Script.DisableUpdate = true; if (newValue != Script.Code.Value) { //update Code Script.Code = newValue; //add undo var undoItems = new List <UndoActionPropertiesChange.Item>(); var property = (Metadata.Property)MetadataManager.GetTypeOfNetType( typeof(Component_CSharpScript)).MetadataGetMemberBySignature("property:Code"); undoItems.Add(new UndoActionPropertiesChange.Item(Script, property, oldValue)); var undoAction = new UndoActionPropertiesChange(undoItems); Document.CommitUndoAction(undoAction); } } if (disableUpdateRestoreTime != 0 && EngineApp.GetSystemTime() > disableUpdateRestoreTime) { Script.DisableUpdate = false; disableUpdateRestoreTime = 0; //to refresh preview texture Script.RaiseCodeChangedEventAndSetNeedUpdate(); } //scriptEditorControl.Editor.Document.UndoStack.ClearAll(); ////check for update Script.Code //{ // var editor = scriptEditorControl.Editor; // if( Script.Code.Value != editor.Text ) // { // ////var caret = editor.TextArea.Caret.Location; // //var selectionStart = editor.SelectionStart; // //var selectionLength = editor.SelectionLength; // disableTextChanged = true; // //xx xx; // editor.Document.Text = Script.Code.Value; // scriptEditorControl.Editor.Document.UndoStack.ClearAll(); // disableTextChanged = false; // //try // //{ // // //editor.TextArea.Caret.Location = caret; // // editor.Select( selectionStart, selectionLength ); // //} // //catch { } // } //} }
public void TryRender() { if (DrawSplashScreen) { return; } if (!IsAllowRender()) { ////!!!!new //DestroyRenderTarget(); return; } UpdateInput(); //!!!!в OnPaint рисовать? //create render window if (needCreateRenderWindow && allowCreateRenderWindow && !disableRecreationRenderWindow && EngineApp.Instance != null && EngineApp.Created) { if (CreateRenderTarget()) { needCreateRenderWindow = false; } } //!!!!где еще такое RendererWorld.ViewportsDuringUpdate.Contains(viewport) if (renderWindow != null && !RenderingSystem.ViewportsDuringUpdate.Contains(viewport)) { //!!!!? double time = EngineApp.GetSystemTime(); //double time = EngineApp.Instance.EngineTime; if (lastRenderTime == 0) { lastRenderTime = time; } double step = time - lastRenderTime; float invFPS = 0; if (automaticUpdateFPS != 0) { invFPS = 1.0f / automaticUpdateFPS; } if (automaticUpdateFPS == 0 || step >= invFPS) { lastRenderTime = time; OneFrameChangeCursor = viewport.MouseRelativeMode ? GetHidedCursor() : Cursors.Default; //OneFrameChangeCursor = Cursors.Default; //!!!!new. тут? EngineApp.DoTick(); //!!!!так ли. где еще if (!DrawSplashScreen) { viewport.PerformTick((float)step); } //!!!! ////tick and entity world tick //if( WinFormsAppEngineApp.Instance != null ) // WinFormsAppEngineApp.Instance.DoTick(); //!!!!!было //if( renderWindow.Size.X != 0 && renderWindow.Size.Y != 0 ) // camera.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y; //if( renderWindow.Size.X != 0 && renderWindow.Size.Y != 0 ) // guiRenderer.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y; //update //!!!!так? viewport.Update(true, OverrideCameraSettings); // false ); //!!!!возможно надо свапать только раз. делать цепь из всех существующих. //!!!!wait vsync? //viewport.Parent.SwapBuffers( false ); //!!!! //Log.Fatal( "viewport.Parent.SwapBuffers( true )" ); //viewport.Parent.SwapBuffers( true ); //renderWindow.Update( true ); //!!!!так? if (Cursor != OneFrameChangeCursor) { Cursor = OneFrameChangeCursor; } OneFrameChangeCursor = viewport.MouseRelativeMode ? GetHidedCursor() : Cursors.Default; //OneFrameChangeCursor = Cursors.Default; WinFormsUtility.InvalidateParentComposedStyleControl(this); } } }
public void PerformUpdate(bool forceUpdate = false) { if (!IsHandleCreated || WinFormsUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication) { return; } if (Destroyed || destroying) { return; } double updateTime = 0.05; if (SelectedObjects != null) { if (SelectedObjects.Length > 2000) { updateTime = 2.0; } else if (SelectedObjects.Length > 500) { updateTime = 1.0; } else if (SelectedObjects.Length > 250) { updateTime = 0.5; } else if (SelectedObjects.Length > 100) { updateTime = 0.35; } else { updateTime = 0.1; } } if (EngineApp.GetSystemTime() - lastUpdateTime < updateTime && !forceUpdate) { return; } if (duringUpdate) { return; } try { duringUpdate = true; //start timer //if( firstUpdate ) timer50ms?.Start(); UpdateItems(); //firstUpdate = false; } finally { lastUpdateTime = EngineApp.GetSystemTime(); duringUpdate = false; } }