void WordWrapRenderUI(CanvasRenderer renderer, string localizedText) { var screenRect = GetScreenRectangle(); var screenSize = GetScreenSize(); var verticalIndention = VerticalIndention.Value; var screenVerticalIndention = GetScreenOffsetByValue(new UIMeasureValueVector2(verticalIndention.Measure, 0, verticalIndention.Value)).Y; var font = Font.Value; if (font == null) { font = renderer.DefaultFont; } if (font == null || font.Disposed) { return; } //if(font == null || font.Disposed) // fon //EngineFont fontInternal = font; //if( fontInternal == null ) // fontInternal = renderer.DefaultFont; var fontSize = GetFontSizeScreen(); //slowly to calculate every time? var lines = new List <LineItem>(); { double posY = 0; var word = new StringBuilder(localizedText.Length); double wordLength = 0; var toDraw = new StringBuilder(localizedText.Length); double toDrawLength = 0; double spaceCharacterLength = font.GetCharacterWidth(fontSize, renderer, ' '); foreach (char c in localizedText) { if (c == ' ') { if (word.Length != 0) { toDraw.Append(' '); toDraw.Append(word); toDrawLength += spaceCharacterLength + wordLength; word.Length = 0; wordLength = 0; } else { toDraw.Append(' '); toDrawLength += spaceCharacterLength; } continue; } if (c == '\n') { toDraw.Append(' '); toDraw.Append(word); toDrawLength += wordLength; lines.Add(new LineItem(toDraw.ToString().Trim(), false)); posY += fontSize + screenVerticalIndention; //if( posY >= screenSize.Y ) // break; toDraw.Length = 0; toDrawLength = 0; word.Length = 0; wordLength = 0; } //slowly? double characterWidth = font.GetCharacterWidth(fontSize, renderer, c); if (toDrawLength + wordLength + characterWidth >= screenSize.X) { if (toDraw.Length == 0) { toDraw.Length = 0; toDraw.Append(word.ToString()); toDrawLength = wordLength; word.Length = 0; wordLength = 0; } lines.Add(new LineItem(toDraw.ToString().Trim(), TextHorizontalAlignment.Value == EHorizontalAlignment.Stretch)); posY += fontSize + screenVerticalIndention; //if( posY >= screenSize.Y ) // break; toDraw.Length = 0; toDrawLength = 0; } word.Append(c); wordLength += characterWidth; } string s = string.Format("{0} {1}", toDraw, word); s = s.Trim(); if (s.Length != 0) { //bool skip = false; //if( clipRectangle && posY >= screenSize.Y ) // skip = true; //if( !skip ) lines.Add(new LineItem(s, false)); } } if (lines.Count != 0) { var shadowColor = ShadowColor.Value; var textColor = Color.Value; var shadowScreenOffset = Shadow ? GetScreenOffsetByValue(ShadowOffset) : Vector2.Zero; //var shadowLocalOffset = Shadow ? GetLocalOffsetByValue( ShadowOffset ) : Vec2.Zero; double startY = 0; switch (TextVerticalAlignment.Value) { case EVerticalAlignment.Top: startY = screenRect.Top; break; case EVerticalAlignment.Center: { double height = fontSize * (double)lines.Count + screenVerticalIndention * ((double)lines.Count - 1); startY = screenRect.Top + (screenRect.GetSize().Y - height) / 2; } break; case EVerticalAlignment.Bottom: { double height = fontSize * (double)lines.Count + screenVerticalIndention * ((double)lines.Count - 1); startY = screenRect.Bottom - height; } break; } //!!!! double stepY = fontSize + screenVerticalIndention; for (int nStep = Shadow ? 0 : 1; nStep < 2; nStep++) { double positionY = startY; foreach (LineItem line in lines) { if (line.alignByWidth) { string[] words = line.text.Split(new char[] { ' ' }); double[] lengths = new double[words.Length]; double totalLength = 0; for (int n = 0; n < lengths.Length; n++) { double length = font.GetTextLength(fontSize, renderer, words[n]); lengths[n] = length; totalLength += length; } double space = 0; if (words.Length > 1) { space = (screenSize.X - totalLength) / (words.Length - 1); } double posX = screenRect.Left; for (int n = 0; n < words.Length; n++) { Vector2 pos = new Vector2(posX, positionY) + GetScreenOffsetByValue(Offset); if (nStep == 0) { renderer.AddText(font, fontSize, words[n], pos + shadowScreenOffset, //LocalToScreen( ScreenToLocal( pos ) + shadowLocalOffset ), EHorizontalAlignment.Left, EVerticalAlignment.Top, shadowColor); } else { renderer.AddText(font, fontSize, words[n], pos, EHorizontalAlignment.Left, EVerticalAlignment.Top, textColor); } posX += lengths[n] + space; } } else { double positionX = 0; switch (TextHorizontalAlignment.Value) { case EHorizontalAlignment.Left: case EHorizontalAlignment.Stretch: positionX = screenRect.Left; break; case EHorizontalAlignment.Center: positionX = screenRect.Left + (screenRect.GetSize().X - font.GetTextLength(fontSize, renderer, line.text)) / 2; break; case EHorizontalAlignment.Right: positionX = screenRect.Right - font.GetTextLength(fontSize, renderer, line.text); break; } Vector2 pos = new Vector2(positionX, positionY) + GetScreenOffsetByValue(Offset); if (nStep == 0) { renderer.AddText(font, fontSize, line.text, pos + shadowScreenOffset, //LocalToScreen( ScreenToLocal( pos ) + shadowLocalOffset ), EHorizontalAlignment.Left, EVerticalAlignment.Top, shadowColor); } else { renderer.AddText(font, fontSize, line.text, pos, EHorizontalAlignment.Left, EVerticalAlignment.Top, textColor); } } positionY += stepY; } } } }
protected override void OnRenderUI(CanvasRenderer renderer) { base.OnRenderUI(renderer); Vector2I size = GetNeededSize(); if (browser == null) { CreateBrowser(); } //update brower engine and texture if (browser != null) { if (viewSize != size /*&& !browser.IsResizing */) { var oldSize = viewSize; viewSize = size; OnResized(oldSize, viewSize); } //create texture if (texture == null || textureSize != size || needRecreateTexture) { if (texture != null) { texture.Dispose(); texture = null; } textureSize = size; bool mipmaps = false; //!!!! //if( ControlManager != null && ControlManager is UI3DControlContainer ) // mipmaps = renderingIn3DMipmaps; var usage = Component_Image.Usages.WriteOnly; if (mipmaps) { usage |= Component_Image.Usages.AutoMipmaps; } texture = ComponentUtility.CreateComponent <Component_Image>(null, true, false); texture.CreateType = Component_Image.TypeEnum._2D; texture.CreateSize = textureSize; texture.CreateMipmaps = mipmaps; // ? -1 : 0; texture.CreateFormat = PixelFormat.A8R8G8B8; texture.CreateUsage = usage; texture.Enabled = true; //Log.Info( textureSize.ToString() ); //if( mipmaps ) //{ // texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize, // 1, -1, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable | Texture.Usage.AutoMipmap ); //} //else //{ // texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize, // 1, 0, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable ); //} needUpdateTexture = true; needRecreateTexture = false; } if (needInvalidate) { browserHost.SetZoomLevel(Zoom); browserHost.Invalidate(new CefRectangle(0, 0, 100000, 100000), CefPaintElementType.View); needInvalidate = false; } //update texture if (/*browser.IsDirty ||*/ needUpdateTexture) { if (texture != null) { UpdateTexture(); } needUpdateTexture = false; } } //draw texture { //bool backColorZero = BackColor == new ColorValue( 0, 0, 0, 0 ); //ColorValue color = new ColorValue( 1, 1, 1 ); ////ColorValue color = backColorZero ? new ColorValue( 1, 1, 1 ) : BackColor; //if( texture == null ) // color = new ColorValue( 0, 0, 0, color.Alpha ); //color *= GetTotalColorMultiplier(); //var color = GetTotalColorMultiplier(); //if( color.Alpha > 0 ) //{ var color = new ColorValue(1, 1, 1); //color.Saturate(); GetScreenRectangle(out var rect); Component_Image tex = null; if (renderBuffer != null && renderBufferForSize == ViewSize && renderBuffer.Length == ViewSize.X * ViewSize.Y * 4) { tex = texture; } if (tex == null) { tex = ResourceUtility.WhiteTexture2D; } if (renderer.IsScreen) //&& !renderer._OutGeometryTransformEnabled ) { ////screen per pixel accuracy Vector2 viewportSize = renderer.ViewportForScreenCanvasRenderer.SizeInPixels.ToVector2F(); var v = size.ToVector2() / viewportSize; Rectangle fixedRect = new Rectangle(rect.LeftTop, rect.LeftTop + v); //Vec2 leftTop = rect.LeftTop; //leftTop *= viewportSize; //leftTop = new Vec2( (int)( leftTop.X + .9999f ), (int)( leftTop.Y + .9999f ) ); ////!!!!! ////if( RenderSystem.Instance.IsDirect3D() ) //// leftTop -= new Vec2( .5f, .5f ); //leftTop /= viewportSize; //Vec2 rightBottom = rect.RightBottom; //rightBottom *= viewportSize; //rightBottom = new Vec2( (int)( rightBottom.X + .9999f ), (int)( rightBottom.Y + .9999f ) ); ////!!!!! ////if( RenderSystem.Instance.IsDirect3D() ) //// rightBottom -= new Vec2( .5f, .5f ); //rightBottom /= viewportSize; //Rect fixedRect = new Rect( leftTop, rightBottom ); renderer.PushTextureFilteringMode(CanvasRenderer.TextureFilteringMode.Point); renderer.AddQuad(fixedRect, new Rectangle(0, 0, 1, 1), tex, color, true); renderer.PopTextureFilteringMode(); } else { renderer.AddQuad(rect, new Rectangle(0, 0, 1, 1), tex, color, true); } //} } if (!IsSupportedByThisPlatform()) { var text = string.Format("UIWebBrowser: {0} is not supported.", SystemSettings.CurrentPlatform); var center = GetScreenRectangle().GetCenter(); renderer.AddText(text, center, EHorizontalAlignment.Center, EVerticalAlignment.Center, new ColorValue(1, 0, 0)); } }
protected virtual void OnRenderList(UIList control, CanvasRenderer renderer) { var rect = control.GetScreenRectangle(); renderer.AddQuad(rect, new ColorValue(0, 0, 0)); //renderer.AddQuad( rect, new ColorValue( 0.2, 0.2, 0.2 ) ); var rect2 = rect; rect2.Expand(-control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 2, 2))); //border var color = new ColorValue(0.75, 0.75, 0.75); renderer.AddQuad(new Rectangle(rect.Left, rect.Top, rect2.Left, rect.Bottom), color); renderer.AddQuad(new Rectangle(rect2.Left, rect.Top, rect2.Right, rect2.Top), color); renderer.AddQuad(new Rectangle(rect2.Right, rect.Top, rect.Right, rect.Bottom), color); renderer.AddQuad(new Rectangle(rect.Left, rect2.Bottom, rect2.Right, rect.Bottom), color); var font = control.Font.Value; if (font == null) { font = renderer.DefaultFont; } var fontSize = control.GetFontSizeScreen(); var itemSize = GetListItemSizeScreen(control, renderer); var totalItemsHeight = itemSize * control.Items.Count; var scrollBar = control.GetScrollBar(); //!!!!тут? //update scroll bar properties if (scrollBar != null) { double screenSizeY = rect2.Size.Y; double scrollScreenSizeY = totalItemsHeight - screenSizeY; scrollBar.Visible = control.AlwaysShowScrollBar || totalItemsHeight > screenSizeY; if (scrollBar.Visible) { scrollBar.ValueRange = new Range(0, scrollScreenSizeY); } //ensure visible if (listEnsureVisible != -1) { if ((float)listEnsureVisible * itemSize > screenSizeY / 2) { var factor = (float)listEnsureVisible / (float)(control.Items.Count - 1); var v = scrollScreenSizeY * factor; scrollBar.Value = MathEx.Clamp(v, 0, scrollBar.ValueRange.Value.Maximum); } else { scrollBar.Value = 0; } listEnsureVisible = -1; } //if( scrollBar.Visible ) //{ // if( scrollScreenSizeY > 0 ) // { // double currentScrollScreenPosY = scrollBar.Value * scrollScreenSizeY; // double itemScrollScreenPosY = itemSize * (double)control.SelectedIndex; // Range itemScrollScreenRangeY = new Range( itemScrollScreenPosY, itemScrollScreenPosY + itemSize ); // if( itemScrollScreenRangeY.Minimum < currentScrollScreenPosY ) // { // currentScrollScreenPosY = itemScrollScreenRangeY.Minimum; // } // else // { // if( itemScrollScreenRangeY.Maximum > currentScrollScreenPosY + screenSizeY ) // currentScrollScreenPosY = itemScrollScreenRangeY.Maximum + itemSize - screenSizeY; // } // scrollBar.Value = currentScrollScreenPosY / scrollScreenSizeY; // } // else // scrollBar.Value = 0; //} //else // scrollBar.Value = 0; } //items if (control.Items.Count != 0) { renderer.PushClipRectangle(rect2); var positionY = rect2.Top; if (scrollBar != null && scrollBar.VisibleInHierarchy && scrollBar.EnabledInHierarchy) { positionY -= scrollBar.Value; } for (int n = 0; n < control.Items.Count; n++) { var item = control.Items[n]; var itemRectangle = new Rectangle(rect2.Left, positionY, rect2.Right, positionY + itemSize); if (scrollBar != null && scrollBar.EnabledInHierarchy && scrollBar.VisibleInHierarchy) { itemRectangle.Right -= scrollBar.GetScreenSize().X; } if (itemRectangle.Intersects(rect2)) { renderer.PushClipRectangle(itemRectangle); if (n == control.SelectedIndex) { var color2 = control.ReadOnlyInHierarchy ? new ColorValue(0.5, 0.5, 0.5) : new ColorValue(0, 0, 0.8); renderer.AddQuad(itemRectangle, color2); } var positionX = rect2.Left + control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 2, 0)).X; renderer.AddText(font, fontSize, item, new Vector2(positionX, itemRectangle.GetCenter().Y), EHorizontalAlignment.Left, EVerticalAlignment.Center, new ColorValue(1, 1, 1)); renderer.PopClipRectangle(); } positionY += itemSize; } renderer.PopClipRectangle(); } }
public virtual bool IsNeedRenderObjectInteraction(Component_GameMode gameMode, UIControl playScreen, CanvasRenderer renderer) { bool result = true; IsNeedRenderObjectInteractionEvent?.Invoke(this, gameMode, playScreen, renderer, ref result); return(result); }
//static UIStyleDefault _default; //public static UIStyleDefault Default //{ // get // { // if( _default == null ) // { // _default = new UIStyleDefault(); // _default.Name = "Default"; // } // return _default; // } //} ///////////////////////////////////////// protected virtual void OnRenderControl(UIControl control, CanvasRenderer renderer) { }
public void PerformRenderControl(UIControl control, CanvasRenderer renderer) { OnRenderControl(control, renderer); RenderControl?.Invoke(control, renderer); }
protected virtual void OnRenderCheck(UICheck control, CanvasRenderer renderer) { var borderColor = new ColorValue(0.5, 0.5, 0.5); var insideColor = new ColorValue(0, 0, 0); var checkColor = new ColorValue(1, 1, 0); var textColor = new ColorValue(1, 1, 1); switch (control.State) { //case UICheck.StateEnum.Hover: // checkColor = new ColorValue( 1, 1, 1 ); // break; case UICheck.StateEnum.Pushed: checkColor = new ColorValue(1, 1, 1); break; case UICheck.StateEnum.Disabled: checkColor = new ColorValue(0.7, 0.7, 0.7); textColor = new ColorValue(0.5, 0.5, 0.5); break; } var colorMultiplier = new ColorValue(1, 1, 1); //var colorMultiplier = control.GetTotalColorMultiplier(); //if( colorMultiplier.Alpha > 0 ) //{ control.GetScreenRectangle(out var rect); renderer.AddQuad(rect, borderColor * colorMultiplier); renderer.AddQuad(Multiply(rect, new Rectangle(0.1, 0.1, 0.9, 0.9)), insideColor * colorMultiplier); //Checked image if (control.Checked.Value == UICheck.CheckValue.Checked) { var points = new Vector2[] { new Vector2(290.04, 33.286), new Vector2(118.861, 204.427), new Vector2(52.32, 137.907), new Vector2(0, 190.226), new Vector2(118.861, 309.071), new Vector2(342.357, 85.606), }; var points2 = new Vector2[points.Length]; for (int n = 0; n < points2.Length; n++) { points2[n] = points[n] / new Vector2(342.357, 342.357); } var color2 = checkColor * colorMultiplier; var vertices = new CanvasRenderer.TriangleVertex[points2.Length]; for (int n = 0; n < points2.Length; n++) { vertices[n] = new CanvasRenderer.TriangleVertex(Multiply(rect, points2[n]).ToVector2F(), color2); } var indices = new int[] { 0, 1, 5, 5, 4, 1, 1, 2, 3, 3, 1, 4 }; renderer.AddTriangles(vertices, indices); } //Indeterminate image if (control.Checked.Value == UICheck.CheckValue.Indeterminate) { renderer.AddQuad(Multiply(rect, new Rectangle(0.3, 0.3, 0.7, 0.7)), checkColor * colorMultiplier); } //!!!!странно рисует чуть ниже, чем посередине //text renderer.AddText(" " + control.Text, new Vector2(rect.Right, rect.GetCenter().Y), EHorizontalAlignment.Left, EVerticalAlignment.Center, textColor * colorMultiplier); //renderer.AddText( " " + control.Text, new Vector2( rect.Right, rect.Top ), EHorizontalAlignment.Left, EVerticalAlignment.Top, textColor * colorMultiplier ); //} }
protected virtual void OnRenderCombo(UICombo control, CanvasRenderer renderer) { control.RenderDefaultStyle(renderer); }
public static void PerformRenderUI() { CanvasRenderer renderer = MainViewport.CanvasRenderer; if (transparency == 0.0f) { return; } //load backgrouund texture and font if (texture != null && texture.Disposed) { needLoadTextureAndFont = true; } if (needLoadTextureAndFont) { texture = ResourceManager.LoadResource <Component_Image>("Base\\UI\\Images\\Console.png"); //texture = ResourceManager.LoadResource<Component_Image>( "Base\\UI\\Images\\Console.jpg" ); font = renderer.DefaultFont; //font = EngineFontManager.Instance.LoadFont( "Default", .025f ); needLoadTextureAndFont = false; } if (font == null) { return; } Vector2F viewportSize = renderer.ViewportForScreenCanvasRenderer.SizeInPixels.ToVector2F(); Vector2F shadowOffset = new Vector2F(1, 1) / viewportSize; //draw background var textureRect = new Rectangle(0, 0, 10 * renderer.AspectRatio, 10 / 2); textureRect -= textureOffset; renderer.AddQuad(new Rectangle(0, 0, 1, .5f), textureRect, texture, new ColorValue(1, 1, 1, transparency), false); //var textureRect = new Rectangle( 0, 1.0 - renderer.AspectRatioInv, 1, 1 ); //renderer.AddQuad( new Rectangle( 0, 0, 1, .5f ), textureRect, texture, new ColorValue( 0.7, 0.7, 0.7, transparency ), false ); //draw border line renderer.AddQuad(new Rectangle(0, .5f, 1, .508f), new ColorValue(0.29f, 0.6f, 0.86f, 0.9f * transparency)); //draw background info string staticText = "Press \"~\" or \"F12\" to hide console\r\nPress \"Ctrl + ~\" to hide and disable auto opening"; renderer.AddTextWordWrap(staticText, new RectangleF(0, 0, .995f, .495f), EHorizontalAlignment.Right, false, EVerticalAlignment.Bottom, 0, new ColorValue(0.8, 0.8, 0.8, transparency)); float fontheight = (float)fontSize; // font.Height; float x = .01f; float y = .5f - fontheight; string str; if (stringDownPosition != strings.Count - 1) { str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" + " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"; } else { str = currentString + "_"; } renderer.PushClipRectangle(new RectangleF(0, 0, .975f, 1)); renderer.AddText(font, fontSize, str, new Vector2F(x, y) + shadowOffset, EHorizontalAlignment.Left, EVerticalAlignment.Center, new ColorValue(0, 0, 0, transparency / 2)); renderer.AddText(font, fontSize, str, new Vector2F(x, y), EHorizontalAlignment.Left, EVerticalAlignment.Center, new ColorValue(1, 1, 1, transparency)); renderer.PopClipRectangle(); y -= fontheight + fontheight * .5f; int startpos = stringDownPosition; if (startpos > strings.Count - 1) { startpos = strings.Count - 1; } for (int n = startpos; n >= 0 && y - fontheight > 0; n--) { var text = strings[n].text; int lineCount = text.Count(f => f == '\n') + 1; float y2 = y - fontheight * (lineCount - 1) / 2; renderer.AddText(font, fontSize, text, new Vector2F(x, y2) + shadowOffset, EHorizontalAlignment.Left, EVerticalAlignment.Center, strings[n].color * new ColorValue(0, 0, 0, transparency / 2)); renderer.AddText(font, fontSize, text, new Vector2F(x, y2), EHorizontalAlignment.Left, EVerticalAlignment.Center, strings[n].color * new ColorValue(1, 1, 1, transparency)); y -= fontheight * lineCount; } }
public virtual void RenderUI(CanvasRenderer renderer, Component_RenderingPipeline.RenderSceneData.LightItem lightItem, Viewport viewport, double intensity) { var lightPosition = lightItem.Position; //!!!!override real position //{ // if( Sun.Instances.Count > 0 ) // { // //get first sun entity on the map. // Sun sun = Sun.Instances[ 0 ]; // Vec3 direction; // if( sun.BillboardOverridePosition != Vec3.Zero ) // direction = sun.BillboardOverridePosition.GetNormalize(); // else // direction = -sun.Rotation.GetForward(); // position = camera.Position + direction * 100000; // return true; // } // position = Vec3.Zero; // return false; //} if (viewport.CameraSettings.ProjectToScreenCoordinates(lightPosition, out var screenLightPosition)) { //get enabled flares var flares = GetComponents <Component_LensFlare>(onlyEnabledInHierarchy: true); //sort by position CollectionUtility.SelectionSort(flares, delegate(Component_LensFlare f1, Component_LensFlare f2) { if (f1.Position > f2.Position) { return(-1); } if (f1.Position < f2.Position) { return(1); } return(0); }); //for( int n = 0; n < flares.Count; n++ ) // sortedFlares[ n ].tempSmoothIntensityFactor = cameraInfo.SmoothIntensityFactors[ n ]; //render foreach (var flare in flares) { var image = flare.Image.Value; var flareVector = screenLightPosition - new Vector2(0.5, 0.5); var flarePosition = new Vector2(0.5, 0.5) + flareVector * flare.Position; var size = flare.Size.Value; var flareSize = new Vector2(size.X, size.Y * renderer.AspectRatio); var rectangle = new Rectangle(flarePosition - flareSize * 0.5, flarePosition + flareSize * 0.5); var flareColor = Color.Value * flare.Color * new ColorValue(1, 1, 1, intensity); // * new ColorValue( 1, 1, 1, item.tempSmoothIntensityFactor ); if (flareColor.Alpha > 0) { renderer.PushBlendingType(flare.Blending.Value); renderer.AddQuad(rectangle, new RectangleF(0, 0, 1, 1), image, flareColor, true); renderer.PopBlendingType(); } } } }
////Tick //public void PerformUITick( double delta ) //{ // CheckCachedParameters(); // UpdateTopMouseCoversControl(); // if( capturedControl != null && capturedControl.ParentContainer == null ) // capturedControl = null; // if( focusedControl != null && focusedControl.ParentContainer == null ) // focusedControl = null; // OnUITick( delta ); // //!!!!где еще вызывать это? и для каких типов объектов //} //Render //public void DoRender() //{ //CheckCachedParameters(); //UpdateTopMouseCoversControl(); //CurrentCursor = defaultCursor; //было, не нужно //OnRenderWithChildren(); //} void DrawCursor(CanvasRenderer renderer) { //hide cursor for mouse relative mode if (MouseRelativeMode) { currentCursor = null; } //!!!!!!focused иначе проверять //!!!!!!EngineApp.Instance.ApplicationWindow.Focused? if (!string.IsNullOrEmpty(currentCursor)) //!!!!!EngineApp.Instance.ApplicationWindow.Focused/*IsWindowFocused()*/ && EngineApp.Instance.IsCreated && !LongOperationCallbackManager.DuringCallingCallback ) { //!!!!Wait var textureIns = ResourceManager.LoadResource <Component_Image>(currentCursor); GpuTexture texture = textureIns?.Result; if (texture != null) { //!!!!было //texture._ThisIsGuiTexture = true; if (drawCursorWithPerPixelAccuracy) { Vector2 screenPixelSize = viewport.SizeInPixels.ToVector2(); Vector2 m = MousePosition * screenPixelSize; Vector2 leftTop = m - texture.SourceSize.ToVector2F() * .5f; Vector2 rightBottom = m + texture.SourceSize.ToVector2F() * .5f; //!!!!! //per pixel alignment //if( this is UIContainerScreen ) { leftTop = new Vector2((int)(leftTop.X + .9999f), (int)(leftTop.Y + .9999f)); //!!!! //if( RenderSystem.Instance.IsDirect3D() ) // leftTop -= new Vec2( .5f, .5f ); rightBottom = new Vector2((int)(rightBottom.X + .9999f), (int)(rightBottom.Y + .9999f)); //!!!! //if( RenderSystem.Instance.IsDirect3D() ) // rightBottom -= new Vec2( .5f, .5f ); } leftTop /= screenPixelSize; rightBottom /= screenPixelSize; Rectangle rectangle = new Rectangle(leftTop, rightBottom); renderer.AddQuad(rectangle, new Rectangle(0, 0, 1, 1), textureIns, new ColorValue(1, 1, 1), true); } else { double baseHeight = UIControlsWorld.ScaleByResolutionBaseHeight; Vector2 size = texture.SourceSize.ToVector2F() / new Vector2(baseHeight * renderer.AspectRatio, baseHeight); Rectangle rectangle = new Rectangle(-size / 2, size / 2) + MousePosition; renderer.AddQuad(rectangle, new Rectangle(0, 0, 1, 1), textureIns, new ColorValue(1, 1, 1), true); } } } }