protected override void OnUpdate(GameTime gameTime) { base.OnUpdate(gameTime); if (_isPending) { var dt = gameTime.TotalGameTime.TotalSeconds; _animationFrame = (int)((dt * 5) % _connectingStates.Length); } else { var mouseState = Mouse.GetState(); _cursorPosition = GuiRenderer.Unproject(new Vector2(mouseState.X, mouseState.Y)).ToPoint(); if (RenderBounds.Contains(_cursorPosition)) { _renderLatency = true; } else { _renderLatency = false; } } }
void DrawTrianglesAndLines(GuiRenderer renderer) { List <GuiRenderer.TriangleVertex> vertices = new List <GuiRenderer.TriangleVertex>(32); Vec2 center = new Vec2(.7f, .4f); float radius = .1f; float step = MathFunctions.PI * 2 / 16; Vec2 lastPoint = Vec2.Zero; for (float angle = 0; angle <= MathFunctions.PI * 2 + step * .5f; angle += step) { Vec2 point = center + new Vec2( MathFunctions.Cos(angle) * radius / renderer.AspectRatio, MathFunctions.Sin(angle) * radius); if (angle != 0) { vertices.Add(new GuiRenderer.TriangleVertex(center, new ColorValue(1, 0, 0))); vertices.Add(new GuiRenderer.TriangleVertex(lastPoint, new ColorValue(0, 1, 0))); vertices.Add(new GuiRenderer.TriangleVertex(point, new ColorValue(0, 1, 0))); } lastPoint = point; } renderer.AddTriangles(vertices); Rect rect = new Rect( center.X - radius / renderer.AspectRatio, center.Y - radius, center.X + radius / renderer.AspectRatio, center.Y + radius); renderer.AddRectangle(rect, new ColorValue(1, 1, 0)); }
public void SetPing(long ms) { _ping = ms; _isPending = false; if (!_isOutdated) { int index = 0; for (int i = _qualityStateTextures.Length - 1; i > 0; i--) { index = i; if (ms > QualityThresholds[i]) { break; } } GuiTexture2D bg = _qualityStateTextures[_qualityStateTextures.Length - index]; if (!bg.HasValue && GuiRenderer != null) { bg = GuiRenderer.GetTexture(QualityStates[QualityStates.Length - index]); } Background = bg; } }
protected override void OnInitialize() { _gui = new GuiManager(GraphicsContext.WindowSize) { Desktop = { Transparent = true } }; _font = GraphicsContext.GetFont(); _guiLoader = new XmlLoader(_gui); InventorySlot.Register(_guiLoader); _guiRenderer = new GuiRenderer(GraphicsContext, new Faceless()); _consoleRenderer = new ConsoleRenderer(GraphicsContext, StaticConsole.Console) { Visible = false }; UVMapper.Register(_guiLoader); StaticTaskQueue.TaskQueue.CreateRepeatingTask("GUI Update", _gui.Update, 33); StaticConsole.Console.CommandBindings.Bind("load", "Load a GUI layout", LoadLayoutCommandHandler); StaticConsole.Console.CommandBindings.Bind("clear", "Clear the GUI", ClearLayoutCommandHandler); StaticConsole.Console.CommandBindings.Bind("loadw", "Load a GUI layout using file open dialog", LoadLayoutFileDialogCommandHandler); StaticConsole.Console.CommandBindings.Bind("ed", "Opens GUI xml in editor", OpenXmlForEditing); Logger.Add(new ConsoleLogger()); base.OnInitialize(); }
public GameForm() { this.FormWidth = this.Width; this.FormHeight = this.Height; this.InitializeComponent(); this.ProgresiveBarTimer = new Timer(); this.ProgresiveBarTimer.Interval = TimeForPlayerTurn * 1000; this.ProgresiveBarTimer.Tick += this.ProgresiveBarTimerTick; this.updateControlsTimer.Start(); this.updateControlsTimer.Interval = 2000; this.updateControlsTimer.Tick += this.UpdateControlsTick; this.InitializeControlsArrays(); IRenderer renderer = new GuiRenderer(this); IInputHandlerer inputHandlerer = new GuiInputHandlerer(this); this.gameEngine = new GameEngine(renderer, inputHandlerer); try { this.gameEngine.GameInit(); } catch (InputValueException ex) { renderer.ShowMessage(ex.Message); } }
protected override void OnRenderUI(GuiRenderer renderer) { base.OnRenderUI(renderer); List <string> lines = new List <string>(); lines.Add("Unit tasks:"); foreach (Entity entity in Map.Instance.Children) { Character character = entity as Character; if (character != null) { GameCharacterAI ai = character.Intellect as GameCharacterAI; if (ai != null) { if (lines.Count > 1) { lines.Add(""); } lines.Add(" " + ai.CurrentTask.ToString()); foreach (GameCharacterAI.Task task in ai.Tasks) { lines.Add(" " + task.ToString()); } } } } EngineApp.Instance.ScreenGuiRenderer.AddTextLines(lines, new Vec2(.95f, .075f), HorizontalAlign.Right, VerticalAlign.Top, 0, new ColorValue(1, 1, 1)); }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); Vec2 size = new Vec2( 232, 335 ); //size *= 1.0f + Time * .015f; size /= new Vec2( 768.0f * renderer.AspectRatio, 768.0f ); Rect rectangle = new Rect( -size / 2, size / 2 ) + new Vec2( .3f, .5f ); float alpha = 0; if( Time > 1 && Time <= 2 ) alpha = Time - 1; else if( Time > 2 && Time <= lifeTime - 2 - 2 ) alpha = 1; else if( Time >= lifeTime - 2 - 2 && Time < lifeTime - 1 ) alpha = 1 - ( Time - ( lifeTime - 2 - 2 ) ) / 3; if( alpha != 0 ) { renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), productTexture, new ColorValue( 1, 1, 1, alpha ) ); } }
protected override void OnRenderUI(GuiRenderer renderer) { base.OnRenderUI(renderer); Vec2 size = new Vec2(512, 215.0f); size *= 1.0f + Time * .015f; size /= new Vec2(768.0f * renderer.AspectRatio, 768.0f); Rect rectangle = new Rect(-size / 2, size / 2) + new Vec2(.5f, .5f); float alpha = 0; if (Time > 2 && Time <= 3) { alpha = Time - 2; } else if (Time > 3 && Time <= lifeTime - 2 - 2) { alpha = 1; } else if (Time >= lifeTime - 2 - 2 && Time < lifeTime - 1) { alpha = 1 - (Time - (lifeTime - 2 - 2)) / 3; } if (alpha != 0) { renderer.AddQuad(rectangle, new Rect(0, 0, 1, 1), engineTexture, new ColorValue(1, 1, 1, alpha)); } }
private void Init() { //TODO - just a test - WORKS! //_installedMods.Add(new TestMod()); GlSetup(); _itemRegistry = new ItemRegistry(); _blockRegistry = new BlockRegistry(); _recipeRegistry = new RecipeRegistry(); LoadMods(); GameRegistry(); WorldRenderer = new WorldRenderer(); EntityRenderer = new EntityRenderer(); GuiRenderer = new GuiRenderer(); FontRenderer = new FontRenderer(); SettingsManager.Load(); //load settings Camera.SetTargetFov(SettingsManager.GetFloat("fov")); _sensitivity = SettingsManager.GetFloat("sensitivity"); WorldRenderer.RenderDistance = SettingsManager.GetInt("renderdistance"); OpenGuiScreen(new GuiScreenMainMenu()); }
void renderTargetUserControl1_RenderUI(GuiRenderer renderer) { string text = "NeoAxis Engine " + EngineVersionInformation.Version; renderer.AddText(text, new Vec2(.01f, .01f), HorizontalAlign.Left, VerticalAlign.Top, new ColorValue(1, 1, 1)); }
protected override void OnBeforeRenderUIWithChildren(GuiRenderer renderer) { if (IsCustomShaderModeEnabled()) { //enable custom shader mode List <GuiRenderer.CustomShaderModeTexture> additionalTextures = new List <GuiRenderer.CustomShaderModeTexture>(); additionalTextures.Add(new GuiRenderer.CustomShaderModeTexture( "GUI\\Textures\\Engine.png", false)); List <GuiRenderer.CustomShaderModeParameter> parameters = new List <GuiRenderer.CustomShaderModeParameter>(); float offsetX = (EngineApp.Instance.Time / 60) % 1; Vec2 mouse = EngineApp.Instance.MousePosition; parameters.Add(new GuiRenderer.CustomShaderModeParameter("testParameter", new Vec4(offsetX, mouse.X, mouse.Y, 0))); renderer.PushCustomShaderMode("Base\\Shaders\\CustomGuiRenderingExample.cg_hlsl", additionalTextures, parameters); ////second way: bind custom shader mode to this control and to all children. //EnableCustomShaderMode( true, "Base\\Shaders\\CustomGuiRenderingExample.cg_hlsl", // additionalTextures, parameters ); } base.OnBeforeRenderUIWithChildren(renderer); }
protected override void LoadContent() { var fontStream = Assembly.GetEntryAssembly().GetManifestResourceStream("Alex.Resources.DebugFont.xnb"); DebugFont = (WrappedSpriteFont)Content.Load <SpriteFont>(fontStream.ReadAllBytes()); _spriteBatch = new SpriteBatch(GraphicsDevice); InputManager = new InputManager(this); GuiRenderer = new GuiRenderer(this); GuiManager = new GuiManager(this, InputManager, GuiRenderer); GuiDebugHelper = new GuiDebugHelper(GuiManager); AlexIpcService = new AlexIpcService(); Services.AddService <AlexIpcService>(AlexIpcService); AlexIpcService.Start(); OnCharacterInput += GuiManager.FocusManager.OnTextInput; GameStateManager = new GameStateManager(GraphicsDevice, _spriteBatch, GuiManager); var splash = new SplashScreen(); GameStateManager.AddState("splash", splash); GameStateManager.SetActiveState("splash"); WindowSize = this.Window.ClientBounds.Size; // Log.Info($"Initializing Alex..."); ThreadPool.QueueUserWorkItem((o) => { InitializeGame(splash); }); }
void DrawScreenText(GuiRenderer renderer) { const float fadeSpeed = 1; float step = RendererWorld.Instance.FrameRenderTimeStep; bool needShow = false; if (EngineApp.Instance.Time - lastTimeOfKeyDownOrMouseMove < 5) { needShow = true; } if (needShow) { screenTextAlpha += step / fadeSpeed; if (screenTextAlpha > 1) { screenTextAlpha = 1; } } else { screenTextAlpha -= step / fadeSpeed; if (screenTextAlpha < 0) { screenTextAlpha = 0; } } string text = LanguageManager.Instance.Translate("UISystem", "Press Space to play"); AddTextWithShadow(renderer, text, new Vec2(.5f, .8f), HorizontalAlign.Center, VerticalAlign.Center, new ColorValue(1, 1, 1, screenTextAlpha)); }
//Actions public void Print(string text, ColorValue color) { if (text == null) { text = "null"; } while (strings.Count > 256) { strings.RemoveAt(0); } GuiRenderer renderer = EngineApp.Instance.ScreenGuiRenderer; if (font != null && renderer != null) { Font.WordWrapLinesItem[] items = font.GetWordWrapLines(renderer, text, .98f); foreach (Font.WordWrapLinesItem item in items) { if (stringDownPosition == strings.Count - 1) { stringDownPosition++; } strings.Add(new OldString(item.Text, color)); } } else { if (stringDownPosition == strings.Count - 1) { stringDownPosition++; } strings.Add(new OldString(text, color)); } }
protected override void OnRenderUI(GuiRenderer renderer) { base.OnRenderUI(renderer); //productTexture.SourceSize = new Vec2(235, 523); //Vec2 size = new Vec2( 523, 235 ); //size *= 1.0f + Time * .015f; //size /= new Vec2( 768.0f * renderer.AspectRatio, 768.0f ); //Rect rectangle = new Rect(-size, size) + new Vec2(.5f, .5f); //float alpha = 0; //if( Time > 1 && Time <= 2 ) // alpha = Time - 1; //else if( Time > 2 && Time <= lifeTime - 2 - 2 ) // alpha = 1; //else if( Time >= lifeTime - 2 - 2 && Time < lifeTime - 1 ) // alpha = 1 - ( Time - ( lifeTime - 2 - 2 ) ) / 3; //if( alpha != 0 ) //{ // renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), productTexture, // new ColorValue( 1, 1, 1, alpha ) ); //} }
public DisplayManager(PresentationPanel presentationPanel, IGL gl, GLManager glManager) { GL = gl; GLManager = glManager; this.presentationPanel = presentationPanel; GraphicsControl = this.presentationPanel.GraphicsControl; CR_GraphicsControl = GLManager.GetContextForGraphicsControl(GraphicsControl); //it's sort of important for these to be initialized to something nonzero currEmuWidth = currEmuHeight = 1; if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK) { Renderer = new GuiRenderer(GL); } else if (GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9) { Renderer = new GuiRenderer(GL); } else { Renderer = new GDIPlusGuiRenderer((BizHawk.Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus)GL); } VideoTextureFrugalizer = new TextureFrugalizer(GL); ShaderChainFrugalizers = new RenderTargetFrugalizer[16]; //hacky hardcoded limit.. need some other way to manage these for (int i = 0; i < 16; i++) { ShaderChainFrugalizers[i] = new RenderTargetFrugalizer(GL); } RefreshUserShader(); }
protected override void OnAfterRenderUIWithChildren( GuiRenderer renderer ) { base.OnAfterRenderUIWithChildren( renderer ); //disable custom shader mode if( IsCustomShaderModeEnabled() ) renderer.PopCustomShaderMode(); }
public override void Render() { GuiRenderer.DrawTexture(_background, new Rectangle(0, 0, 960, 540), null); GuiRenderer.DrawTexture(_progressBar, new Rectangle(100, 340, (int)ScaledResolution.GuiResolution.X - 100, 420), null); GuiRenderer.DrawTexture(_progressBarFull, Rectangle.FromSize(100, 340, 800 / 100 * _progress, 80), null); //GuiRenderer.DrawTexture(background, new Vector4(-1,-1,1,1), new Vector4(0,0,1,1)); }
protected override void DrawTarget( GuiRenderer renderer ) { //disable target drawing in demo mode if( demoMode && !FreeCameraEnabled ) return; base.DrawTarget( renderer ); }
public override void onGui() { if (Input.GetKey(KeyCode.Space)) { return; } if (window != null) { RenderWindow(); return; } ResourceList instance = ResourceList.getInstance(); TitleTextures title = instance.Title; Texture2D gameTitle = title.GameTitle; Vector2 menuButtonSize = GuiRenderer.getMenuButtonSize(FontSize.Huge); Vector2 titleLocation = Singleton <TitleScene> .getInstance().getTitleLocation(); Vector2 menuLocation = Singleton <TitleScene> .getInstance().getMenuLocation(); float buttonLeftOffset = (float)Screen.width * 0.75f + (((float)Screen.width * 0.25f) - menuButtonSize.x) / 2; float num = (float)(Screen.height * gameTitle.height) / 1080f; float num2 = num * (float)gameTitle.width / (float)gameTitle.height; GUI.color = new Color(1f, 1f, 1f, this.mAlpha); GUI.DrawTexture(new Rect(titleLocation.x - num2 * 0.5f, titleLocation.y, num2, num), gameTitle); GUI.color = Color.white; Texture2D backgroundRight = title.BackgroundRight; float num3 = (float)(Screen.height * backgroundRight.height) / 1080f; float num4 = num3 * (float)backgroundRight.width / (float)backgroundRight.height; GUI.DrawTexture(new Rect((float)Screen.width - num4 + this.mRightOffset, ((float)Screen.height - num3) * 0.75f, num4, num3), backgroundRight); float num5 = menuLocation.y; float num6 = menuButtonSize.y * 1.3f; serverTarget = GUI.TextField(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), serverTarget, 21, createTextFieldStyle((int)menuButtonSize.x, (int)menuButtonSize.y)); num5 += num6; username = GUI.TextField(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), username, 21, createTextFieldStyle((int)menuButtonSize.x, (int)menuButtonSize.y)); num5 += num6; password = GUI.TextField(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), password, 21, createTextFieldStyle((int)menuButtonSize.x, (int)menuButtonSize.y)); num5 += num6 * 2; if (mGuiRenderer.renderTitleButton(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), "Connect", FontSize.Huge, true)) { DisableMultiplayer(); ConnectServer(); } num5 += num6; if (mGuiRenderer.renderTitleButton(new Rect(buttonLeftOffset + mRightOffset, num5, menuButtonSize.x, menuButtonSize.y), StringList.get("back"), FontSize.Huge, true)) { DisableMultiplayer(); GameManager.getInstance().setGameStateTitle(); } }
public GameStateMultiplayer(GameState previousState) { mShouldFadeIn = !previousState.isTitleState(); mRightOffset = (float)Screen.width * 0.25f; serverTarget = "127.0.0.1:8081"; username = "******"; password = "******"; mGuiRenderer = new GuiRenderer(); }
void AddTextWithShadow(GuiRenderer renderer, string text, Vec2 position, HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, ColorValue color) { Vec2 shadowOffset = 2.0f / RendererWorld.Instance.DefaultViewport.DimensionsInPixels.Size.ToVec2(); renderer.AddText(text, position + shadowOffset, horizontalAlign, verticalAlign, new ColorValue(0, 0, 0, color.Alpha / 2)); renderer.AddText(text, position, horizontalAlign, verticalAlign, color); }
public override void Run() { GuiRenderer renderer = FilterProgram.GuiRenderer; renderer.Begin(FindOutput().SurfaceFormat.Size); renderer.SetBlendState(FilterProgram.GL.BlendNone); renderer.Draw(InputTexture); renderer.End(); }
void AddTextWithShadow(GuiRenderer renderer, Font font, string text, Vec2 position, HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, ColorValue color) { Vec2 shadowOffset = 1.0f / renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2(); renderer.AddText(font, text, position + shadowOffset, horizontalAlign, verticalAlign, new ColorValue(0, 0, 0, color.Alpha / 2)); renderer.AddText(font, text, position, horizontalAlign, verticalAlign, color); }
private void SetupGamer() { this.player = new Gamer(); var form = new GameForm(); IRenderer renderer = new GuiRenderer(form); IInputHandlerer handler = new GuiInputHandlerer(); this.engine = new GameEngine(renderer, handler); }
protected override void OnRenderUI(GuiRenderer renderer) { base.OnRenderUI(renderer); if (hudControl != null) { hudControl.Visible = EngineDebugSettings.DrawGui; } }
public void openGui(GuiRenderer gui) { if (this.CurrentGuiRenderer != null) { this.CurrentGuiRenderer.onClosed(); } this.CurrentGuiRenderer = gui; this.CurrentGuiRenderer.onOpened(); }
public virtual void DrawProgressBar(GuiRenderer renderer, ProgressBar progressBar) { renderer.FillRectangle(progressBar.BoundingBox, Color.Gray); var contentBounds = progressBar.ContentRectangle; contentBounds.Width = (int)(contentBounds.Width * progressBar.Value); DrawSelectionBox(renderer, contentBounds, SelectionStyle.ItemActive); }
void renderTargetUserControl1_RenderUI(RenderTargetUserControl sender, GuiRenderer renderer) { string text = "NeoAxis Engine " + EngineVersionInformation.Version; renderer.AddText(text, new Vec2(.01f, .01f), HorizontalAlign.Left, VerticalAlign.Top, new ColorValue(1, 1, 1)); renderer.AddText("Camera control: W A S D, right mouse", new Vec2(.99f, .99f), HorizontalAlign.Right, VerticalAlign.Bottom, new ColorValue(1, 1, 1)); }
protected override void OnRenderUI(GuiRenderer renderer) { base.OnRenderUI(renderer); if (demoMode && !FreeCameraEnabled) { DrawFadingScreenQuad(renderer); DrawScreenText(renderer); } }
protected override void OnRenderUI(GuiRenderer renderer) { base.OnRenderUI(renderer); if (Map.Instance == null) { renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(.2f, .2f, .2f) * window.ColorMultiplier); } }
public void Init(GraphicsDevice graphicsDevice, IServiceProvider serviceProvider) { GraphicsDevice = graphicsDevice; SpriteBatch = new SpriteBatch(graphicsDevice); GuiRenderer.Init(graphicsDevice, serviceProvider); GuiSpriteBatch?.Dispose(); GuiSpriteBatch = new GuiSpriteBatch(GuiRenderer, graphicsDevice, SpriteBatch); GuiRenderArgs = new GuiRenderArgs(GraphicsDevice, SpriteBatch, ScaledResolution, GuiRenderer, new GameTime()); }
protected override void OnAfterRenderUIWithChildren(GuiRenderer renderer) { base.OnAfterRenderUIWithChildren(renderer); //disable custom shader mode if (IsCustomShaderModeEnabled()) { renderer.PopCustomShaderMode(); } }
void PerspectiveViewControl_RenderUI(GuiRenderer renderer) { if (_camera != null) Nameplates.RenderObjectsTips(renderer, _camera); string text = "FPS: " + Perspective.Fps + " loc: " + renderTarget.CameraPosition.ToString(0) + " dir: " + renderTarget.CameraDirection.ToString(0) + " mouse: " + _mouseIntersection.ToString(2) + " over: " + _worldViewModel.MouseOverEntity; renderer.AddText(text, new Vec2(.01f, .01f), HorizontalAlign.Left, VerticalAlign.Top, new ColorValue(1, 1, 1)); }
public void DrawDebug(Rect r, GuiRenderer renderer) { Rect[] rs = new Rect[5]; rs[0] = new Rect(Utils.TR(r, new Vec2(0.05f, 0.375f)), Utils.TR(r, new Vec2(0.30f, 0.625f))); rs[4] = new Rect(Utils.TR(r, new Vec2(0.05f, 0.05f)), Utils.TR(r, new Vec2(0.30f, 0.30f))); rs[2] = new Rect(Utils.TR(r, new Vec2(0.05f, 0.70f)), Utils.TR(r, new Vec2(0.30f, 0.95f))); rs[3] = new Rect(Utils.TR(r, new Vec2(0.375f, 0.375f)), Utils.TR(r, new Vec2(0.625f, 0.625f))); rs[1] = new Rect(Utils.TR(r, new Vec2(0.70f, 0.375f)), Utils.TR(r, new Vec2(0.95f, 0.625f))); for (int i = 0; i < aerofoils.Length; i++) aerofoils[i].DrawDebug(rs[i], renderer); float speed = awesomeAircraft.mainBody.LinearVelocity.Length(); renderer.AddText("speed:" + speed.ToString(), r.LeftTop); }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); Vec2 size = new Vec2( 523.0f / 1024.0f, 235.0f / 768.0f ); Rect rectangle = new Rect( -size / 2, size / 2 ) + new Vec2( .5f, .5f ); float alpha = 0; if( Time > 2 && Time <= 3 ) alpha = Time - 2; else if( Time > 3 && Time <= lifeTime - 2 - 2 ) alpha = 1; else if( Time >= lifeTime - 2 - 2 && Time < lifeTime - 1 ) alpha = 1 - ( Time - ( lifeTime - 2 - 2 ) ) / 3; if( alpha != 0 ) renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), engineTexture, new ColorValue( 1, 1, 1, alpha ) ); }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); Vec2 size = new Vec2( 512, 215.0f ); size *= 1.0f + Time * .015f; size /= new Vec2( 768.0f * renderer.AspectRatio, 768.0f ); Rect rectangle = new Rect( -size , size ) + new Vec2( .5f, .5f ); float alpha = 0; if( Time > 2 && Time <= 3 ) alpha = Time - 2; else if( Time > 3 && Time <= lifeTime - 2 - 2 ) alpha = 1; else if( Time >= lifeTime - 2 - 2 && Time < lifeTime - 1 ) alpha = 1 - ( Time - ( lifeTime - 2 - 2 ) ) / 3; if( alpha != 0 ) renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), engineTexture, new ColorValue( 1, 1, 1, alpha ) ); }
//Tank specific void DrawTankGunTarget( GuiRenderer renderer ) { Tank tank = GetPlayerUnit() as Tank; if( tank == null ) return; Gun gun = tank.MainGun; if( gun == null ) return; Vec3 gunPosition = gun.GetInterpolatedPosition(); Vec3 gunDirection = gun.GetInterpolatedRotation() * new Vec3( 1, 0, 0 ); RayCastResult[] piercingResult = PhysicsWorld.Instance.RayCastPiercing( new Ray( gunPosition, gunDirection * 1000 ), (int)ContactGroup.CastOnlyContact ); bool finded = false; Vec3 pos = Vec3.Zero; foreach( RayCastResult result in piercingResult ) { bool ignore = false; MapObject obj = MapSystemWorld.GetMapObjectByBody( result.Shape.Body ); Dynamic dynamic = obj as Dynamic; if( dynamic != null && dynamic.GetParentUnit() == tank ) ignore = true; if( !ignore ) { finded = true; pos = result.Position; break; } } if( !finded ) pos = gunPosition + gunDirection * 1000; Vec2 screenPos; RendererWorld.Instance.DefaultCamera.ProjectToScreenCoordinates( pos, out screenPos ); //draw quad { Texture texture = TextureManager.Instance.Load( "Cursors/Target.png" ); float size = .015f; float aspect = RendererWorld.Instance.DefaultCamera.AspectRatio; Rect rectangle = new Rect( screenPos.X - size, screenPos.Y - size * aspect, screenPos.X + size, screenPos.Y + size * aspect ); renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), texture, new ColorValue( 0, 1, 0 ) ); } }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); if( Map.Instance == null ) { renderer.AddQuad( new Rect( 0, 0, 1, 1 ), new ColorValue( .2f, .2f, .2f ) * window.ColorMultiplier ); } }
public override void OnRenderScreenUI( GuiRenderer renderer ) { base.OnRenderScreenUI( renderer ); if( drawTextOnScreen ) { renderer.AddText( "Add-on Example!", new Vec2( .5f, .9f ), HorizontalAlign.Center, VerticalAlign.Top, new ColorValue( 1, 0, 0 ) ); renderer.AddQuad( new Rect( .3f, .94f, .7f, .95f ), new ColorValue( 1, 1, 0 ) ); } }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); foreach( Page page in pages ) { if( page.PageControl.Visible ) page.OnUpdate(); } }
void workAreaControl_RenderUI( MultiViewRenderTargetControl sender, int viewIndex, GuiRenderer renderer ) { if( fontMedium == null ) fontMedium = FontManager.Instance.LoadFont( "Default", .04f ); if( fontBig == null ) fontBig = FontManager.Instance.LoadFont( "Default", .07f ); AddTextWithShadow( renderer, fontBig, string.Format( "View {0}", viewIndex ), new Vec2( .99f, .01f ), HorizontalAlign.Right, VerticalAlign.Top, new ColorValue( 1, 1, 1 ) ); if( viewIndex == 0 ) { AddTextWithShadow( renderer, fontMedium, "Camera control: W A S D, right mouse button", new Vec2( .99f, .99f ), HorizontalAlign.Right, VerticalAlign.Bottom, new ColorValue( 1, 1, 1 ) ); } Draw2DRectangles( renderer ); }
void AddTextWithShadow( GuiRenderer renderer, Engine.Renderer.Font font, string text, Vec2 position, HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, ColorValue color ) { Vec2 shadowOffset = 2.0f / renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2(); renderer.AddText( font, text, position + shadowOffset, horizontalAlign, verticalAlign, new ColorValue( 0, 0, 0, color.Alpha / 2 ) ); renderer.AddText( font, text, position, horizontalAlign, verticalAlign, color ); }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); //Draw some HUD information if( GetPlayerUnit() != null ) { if( GetRealCameraType() != CameraType.Free && !IsCutSceneEnabled() && GetActiveObserveCameraArea() == null ) { DrawTarget( renderer ); } DrawPlayerInformation( renderer ); bool activeConsole = EngineConsole.Instance != null && EngineConsole.Instance.Active; if( EngineApp.Instance.IsKeyPressed( EKeys.Tab ) && !activeConsole ) DrawPlayersStatistics( renderer ); if( GameNetworkServer.Instance != null || GameNetworkClient.Instance != null ) { renderer.AddText( "\"Tab\" for players statistics", new Vec2( .01f, .1f ), HorizontalAlign.Left, VerticalAlign.Top, new ColorValue( 1, 1, 1, .5f ) ); } } //Game is paused on server if( EntitySystemWorld.Instance.IsClientOnly() && !EntitySystemWorld.Instance.Simulation ) { renderer.AddText( "Game is paused on server", new Vec2( .5f, .5f ), HorizontalAlign.Center, VerticalAlign.Center, new ColorValue( 1, 0, 0 ) ); } }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); UpdateHUD(); //render user names for moving pieces by users foreach( Entity entity in Map.Instance.Children ) { JigsawPuzzlePiece piece = entity as JigsawPuzzlePiece; if( piece != null ) { string userName = null; if( EntitySystemWorld.Instance.IsServer() ) { if( piece.Server_MovingByUser != null ) userName = piece.Server_MovingByUser.Name; } if( EntitySystemWorld.Instance.IsClientOnly() ) { if( piece.Client_MovingByUser != null ) userName = piece.Client_MovingByUser.Name; } if( !string.IsNullOrEmpty( userName ) ) { Vec2 screenPosition; if( RendererWorld.Instance.DefaultCamera.ProjectToScreenCoordinates( piece.Position, out screenPosition ) ) { renderer.AddText( userName, screenPosition, HorizontalAlign.Left, VerticalAlign.Top, new ColorValue( 0, 1, 0, .75f ) ); } } } } //show list of users if( GameNetworkServer.Instance != null || GameNetworkClient.Instance != null ) { List<string> lines = new List<string>(); lines.Add( "Players:" ); if( GameNetworkServer.Instance != null ) { UserManagementServerNetworkService userService = GameNetworkServer.Instance.UserManagementService; foreach( UserManagementServerNetworkService.UserInfo user in userService.Users ) { string line = " " + user.Name; if( user == userService.ServerUser ) line += " (you)"; lines.Add( line ); } } if( GameNetworkClient.Instance != null ) { UserManagementClientNetworkService userService = GameNetworkClient.Instance.UserManagementService; foreach( UserManagementClientNetworkService.UserInfo user in userService.Users ) { string line = " " + user.Name; if( user == userService.ThisUser ) line += " (you)"; lines.Add( line ); } } renderer.AddTextLines( lines, new Vec2( .01f, .15f ), HorizontalAlign.Left, VerticalAlign.Top, 0, new ColorValue( 1, 1, 0 ) ); } //screenMessages { Vec2 pos = new Vec2( .01f, .9f ); for( int n = screenMessages.Count - 1; n >= 0; n-- ) { ScreenMessage message = screenMessages[ n ]; ColorValue color = new ColorValue( 1, 1, 1, message.timeRemaining ); if( color.Alpha > 1 ) color.Alpha = 1; renderer.AddText( message.text, pos, HorizontalAlign.Left, VerticalAlign.Top, color ); pos.Y -= renderer.DefaultFont.Height; } } //Game is paused on server if( EntitySystemWorld.Instance.IsClientOnly() && !EntitySystemWorld.Instance.Simulation ) { renderer.AddText( "Game is paused on server", new Vec2( .5f, .5f ), HorizontalAlign.Center, VerticalAlign.Center, new ColorValue( 1, 0, 0 ) ); } }
/// <summary> /// Draw a target at center of screen /// </summary> /// <param name="renderer"></param> void DrawTarget( GuiRenderer renderer ) { Unit playerUnit = GetPlayerUnit(); Weapon weapon = null; { //PlayerCharacter specific PlayerCharacter playerCharacter = playerUnit as PlayerCharacter; if( playerCharacter != null ) weapon = playerCharacter.ActiveWeapon; //Turret specific Turret turret = playerUnit as Turret; if( turret != null ) weapon = turret.MainGun; //Tank specific Tank tank = playerUnit as Tank; if( tank != null ) weapon = tank.MainGun; } //draw quad if( weapon != null || currentAttachedGuiObject != null || currentSwitch != null ) { Texture texture = TextureManager.Instance.Load( "Cursors/Target.png" ); float size = .02f; float aspect = RendererWorld.Instance.DefaultCamera.AspectRatio; Rect rectangle = new Rect( .5f - size, .5f - size * aspect, .5f + size, .5f + size * aspect ); renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), texture ); } //Tank specific DrawTankGunTarget( renderer ); }
public void RenderScreenUI(GuiRenderer renderer) { for (int viewIndex = 0; viewIndex < views.Count; viewIndex++) { View view = views[viewIndex]; //draw view on screen if (view.Opacity > 0) { renderer.PushTextureFilteringMode(GuiRenderer.TextureFilteringModes.Point); renderer.AddQuad(view.Rectangle, new Rect(0, 0, 1, 1), view.Texture, new ColorValue(1, 1, 1, view.Opacity), true); renderer.PopTextureFilteringMode(); } //draw debug info if (drawDebugInfo) { Viewport screenViewport = renderer.ViewportForScreenGuiRenderer; Vec2 pixelOffset = 1.0f / screenViewport.DimensionsInPixels.Size.ToVec2(); ColorValue color = new ColorValue(1, 1, 0); renderer.AddRectangle(new Rect( view.Rectangle.LeftTop + pixelOffset, view.Rectangle.RightBottom - pixelOffset * 2), color); renderer.AddLine(view.Rectangle.LeftTop, view.Rectangle.RightBottom, color); renderer.AddLine(view.Rectangle.RightTop, view.Rectangle.LeftBottom, color); if (debugFont == null) debugFont = FontManager.Instance.LoadFont("Default", .03f); string sizeString = ""; if (view.Texture != null) sizeString = string.Format("{0}x{1}", view.Texture.Size.X, view.Texture.Size.Y); string text = string.Format("View {0}, {1}", viewIndex, sizeString); Vec2 position = new Vec2(view.Rectangle.Right - pixelOffset.X * 5, view.Rectangle.Top); AddTextWithShadow(renderer, debugFont, text, position, HorizontalAlign.Right, VerticalAlign.Top, new ColorValue(1, 1, 1)); } } }
protected override void OnRenderScreenUI(GuiRenderer renderer) { base.OnRenderScreenUI(renderer); if (Map.Instance != null) Map.Instance.DoRenderUI(renderer); if (MultiViewRenderingManager.Instance != null) MultiViewRenderingManager.Instance.RenderScreenUI(renderer); controlManager.DoRenderUI(renderer); //screenMessages { Viewport viewport = RendererWorld.Instance.DefaultViewport; Vec2 shadowOffset = 2.0f / viewport.DimensionsInPixels.Size.ToVec2(); Vec2 pos = new Vec2(.03f, .75f); for (int n = screenMessages.Count - 1; n >= 0; n--) { ScreenMessage message = screenMessages[n]; float alpha = message.timeRemaining; if (alpha > 1) alpha = 1; renderer.AddText(message.text, pos + shadowOffset, HorizontalAlign.Left, VerticalAlign.Bottom, new ColorValue(0, 0, 0, alpha / 2)); renderer.AddText(message.text, pos, HorizontalAlign.Left, VerticalAlign.Bottom, new ColorValue(1, 1, 1, alpha)); pos.Y -= renderer.DefaultFont.Height; } } //fading in, out RenderFadingOut(renderer); RenderFadingIn(renderer); if (EngineConsole.Instance != null) EngineConsole.Instance.DoRenderUI(); }
void renderTargetUserControl1_RenderUI( RenderTargetUserControl sender, GuiRenderer renderer ) { string text = "NeoAxis 3D Engine " + EngineVersionInformation.Version; renderer.AddText( text, new Vec2( .01f, .01f ), HorizontalAlign.Left, VerticalAlign.Top, new ColorValue( 1, 1, 1 ) ); renderer.AddText( "Camera control: W A S D, right mouse", new Vec2( .99f, .99f ), HorizontalAlign.Right, VerticalAlign.Bottom, new ColorValue( 1, 1, 1 ) ); }
private void RenderFadingOut(GuiRenderer renderer) { if (IsScreenFadingOut()) { if (fadingOutTimer != 0) { float alpha = 1.0f - fadingOutTimer / fadingTime; MathFunctions.Saturate(ref alpha); renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha)); } } }
/// <summary> /// To draw some information of a player /// </summary> /// <param name="renderer"></param> void DrawPlayerInformation( GuiRenderer renderer ) { if( GetRealCameraType() == CameraType.Free ) return; if( IsCutSceneEnabled() ) return; //debug draw an influences. { float posy = .8f; foreach( Entity entity in GetPlayerUnit().Children ) { Influence influence = entity as Influence; if( influence == null ) continue; renderer.AddText( influence.Type.Name, new Vec2( .7f, posy ), HorizontalAlign.Left, VerticalAlign.Center ); int count = (int)( (float)influence.RemainingTime * 2.5f ); if( count > 50 ) count = 50; string str = ""; for( int n = 0; n < count; n++ ) str += "I"; renderer.AddText( str, new Vec2( .85f, posy ), HorizontalAlign.Left, VerticalAlign.Center ); posy -= .025f; } } }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); if( activePage != null ) activePage.OnUpdate(); }
//Draw minimap void Minimap_RenderUI( EControl sender, GuiRenderer renderer ) { Rect screenMapRect = sender.GetScreenRectangle(); Bounds initialBounds = Map.Instance.InitialCollisionBounds; Rect mapRect = new Rect( initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2() ); Vec2 mapSizeInv = new Vec2( 1, 1 ) / mapRect.Size; //draw units Vec2 screenPixel = new Vec2( 1, 1 ) / new Vec2( EngineApp.Instance.VideoMode.Size.ToVec2() ); foreach( Entity entity in Map.Instance.Children ) { RTSUnit unit = entity as RTSUnit; if( unit == null ) continue; Rect rect = new Rect( unit.MapBounds.Minimum.ToVec2(), unit.MapBounds.Maximum.ToVec2() ); rect -= mapRect.Minimum; rect.Minimum *= mapSizeInv; rect.Maximum *= mapSizeInv; rect.Minimum = new Vec2( rect.Minimum.X, 1.0f - rect.Minimum.Y ); rect.Maximum = new Vec2( rect.Maximum.X, 1.0f - rect.Maximum.Y ); rect.Minimum *= screenMapRect.Size; rect.Maximum *= screenMapRect.Size; rect += screenMapRect.Minimum; //increase 1 pixel rect.Maximum += new Vec2( screenPixel.X, -screenPixel.Y ); ColorValue color; if( playerFaction == null || unit.Intellect == null || unit.Intellect.Faction == null ) color = new ColorValue( 1, 1, 0 ); else if( playerFaction == unit.Intellect.Faction ) color = new ColorValue( 0, 1, 0 ); else color = new ColorValue( 1, 0, 0 ); renderer.AddQuad( rect, color ); } //Draw camera borders { Camera camera = RendererWorld.Instance.DefaultCamera; if( camera.Position.Z > 0 ) { Plane groundPlane = new Plane( 0, 0, 1, 0 ); Vec2[] points = new Vec2[ 4 ]; for( int n = 0; n < 4; n++ ) { Vec2 p = Vec2.Zero; switch( n ) { case 0: p = new Vec2( 0, 0 ); break; case 1: p = new Vec2( 1, 0 ); break; case 2: p = new Vec2( 1, 1 ); break; case 3: p = new Vec2( 0, 1 ); break; } Ray ray = camera.GetCameraToViewportRay( p ); float scale; groundPlane.RayIntersection( ray, out scale ); Vec3 pos = ray.GetPointOnRay( scale ); if( ray.Direction.Z > 0 ) pos = ray.Origin + ray.Direction.GetNormalize() * 10000; Vec2 point = pos.ToVec2(); point -= mapRect.Minimum; point *= mapSizeInv; point = new Vec2( point.X, 1.0f - point.Y ); point *= screenMapRect.Size; point += screenMapRect.Minimum; points[ n ] = point; } for( int n = 0; n < 4; n++ ) renderer.AddLine( points[ n ], points[ ( n + 1 ) % 4 ], new ColorValue( 1, 1, 1 ), screenMapRect ); } } }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); DrawHUD( renderer ); }
void DrawHUD( GuiRenderer renderer ) { if( selectMode && selectDraggedMouse ) { Rect rect = new Rect( selectStartPos ); rect.Add( EngineApp.Instance.MousePosition ); Vec2i windowSize = EngineApp.Instance.VideoMode.Size; Vec2 thickness = new Vec2( 1.0f / (float)windowSize.X, 1.0f / (float)windowSize.Y ); renderer.AddQuad( new Rect( rect.Left, rect.Top + thickness.Y, rect.Right, rect.Top + thickness.Y * 2 ), new ColorValue( 0, 0, 0, .5f ) ); renderer.AddQuad( new Rect( rect.Left, rect.Bottom, rect.Right, rect.Bottom + thickness.Y ), new ColorValue( 0, 0, 0, .5f ) ); renderer.AddQuad( new Rect( rect.Left + thickness.X, rect.Top, rect.Left + thickness.X * 2, rect.Bottom ), new ColorValue( 0, 0, 0, .5f ) ); renderer.AddQuad( new Rect( rect.Right, rect.Top, rect.Right + thickness.X, rect.Bottom ), new ColorValue( 0, 0, 0, .5f ) ); renderer.AddQuad( new Rect( rect.Left, rect.Top, rect.Right, rect.Top + thickness.Y ), new ColorValue( 0, 1, 0, 1 ) ); renderer.AddQuad( new Rect( rect.Left, rect.Bottom - thickness.Y, rect.Right, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) ); renderer.AddQuad( new Rect( rect.Left, rect.Top, rect.Left + thickness.X, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) ); renderer.AddQuad( new Rect( rect.Right - thickness.X, rect.Top, rect.Right, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) ); } }
void Draw2DRectangles( GuiRenderer renderer ) { Rect rect = new Rect( .01f, .9f, .25f, .99f ); renderer.AddQuad( rect, new ColorValue( .5f, .5f, .5f, .5f ) ); Rect rect2 = rect; rect2.Expand( new Vec2( .005f / renderer.AspectRatio, .005f ) ); renderer.AddRectangle( rect2, new ColorValue( 1, 1, 0 ) ); AddTextWithShadow( renderer, fontMedium, "2D GUI Drawing", rect.GetCenter(), HorizontalAlign.Center, VerticalAlign.Center, new ColorValue( 1, 1, 1 ) ); }
protected override void OnRenderUI( GuiRenderer renderer ) { base.OnRenderUI( renderer ); if( hudControl != null ) hudControl.Visible = EngineDebugSettings.DrawGui; }
void DrawPlayersStatistics( GuiRenderer renderer ) { if( IsCutSceneEnabled() ) return; if( PlayerManager.Instance == null ) return; renderer.AddQuad( new Rect( .1f, .2f, .9f, .8f ), new ColorValue( 0, 0, 1, .5f ) ); renderer.AddText( "Players statistics", new Vec2( .5f, .25f ), HorizontalAlign.Center, VerticalAlign.Center ); if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() ) { float posy = .3f; foreach( PlayerManager.ServerOrSingle_Player player in PlayerManager.Instance.ServerOrSingle_Players ) { string text = string.Format( "{0}, Frags: {1}, Ping: {2} ms", player.Name, player.Frags, (int)( player.Ping * 1000 ) ); renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left, VerticalAlign.Center ); posy += .025f; } } if( EntitySystemWorld.Instance.IsClientOnly() ) { float posy = .3f; foreach( PlayerManager.Client_Player player in PlayerManager.Instance.Client_Players ) { string text = string.Format( "{0}, Frags: {1}, Ping: {2} ms", player.Name, player.Frags, (int)( player.Ping * 1000 ) ); renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left, VerticalAlign.Center ); posy += .025f; } } }
private void RenderFadingIn(GuiRenderer renderer) { if (fadingInRemainingTime > 0) { //we are skip some amount of frames because resources can be loaded during it. if (fadingInSkipFirstFrames == 0) { fadingInRemainingTime -= RendererWorld.Instance.FrameRenderTimeStep; if (fadingInRemainingTime < 0) fadingInRemainingTime = 0; } else fadingInSkipFirstFrames--; float alpha = (float)fadingInRemainingTime / 1; MathFunctions.Saturate(ref alpha); renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha)); } }