public void MakeAdjustments(float deltaTime) { pos.Y += deltaTime / 1.5; var dynText = SingleComposer.GetDynamicText("text"); Vec3d projectedPos = MatrixToolsd.Project(pos, capi.Render.PerspectiveProjectionMat, capi.Render.PerspectiveViewMat, capi.Render.FrameWidth, capi.Render.FrameHeight); if (projectedPos.Z < 0) { dynText.SetNewText(""); } SingleComposer.Bounds.absFixedX = projectedPos.X - SingleComposer.Bounds.OuterWidth / 2; SingleComposer.Bounds.absFixedY = capi.Render.FrameHeight - projectedPos.Y - SingleComposer.Bounds.OuterHeight; dynText.Font = font.WithColor(new double[] { color[0], color[1], color[2], expiryTime / 2.0 }).WithStroke(new double[] { 0.0, 0.0, 0.0, expiryTime / 2.0 }, 1.0); dynText.RecomposeText(); expiryTime -= deltaTime; if (expiryTime < 0) { TryClose(); Dispose(); } }
// TODO: Fix code duplication from GuiDialogBlockEntity /// <summary> /// Render's the object in Orthographic mode. /// </summary> /// <param name="deltaTime">The time elapsed.</param> public override void OnRenderGUI(float deltaTime) { if (capi.Settings.Bool["immersiveMouseMode"]) { double offX = owningEntity.SelectionBox.X2 - owningEntity.OriginSelectionBox.X2; double offZ = owningEntity.SelectionBox.Z2 - owningEntity.OriginSelectionBox.Z2; Vec3d aboveHeadPos = new Vec3d(owningEntity.Pos.X + offX, owningEntity.Pos.Y + FloatyDialogPosition, owningEntity.Pos.Z + offZ); Vec3d pos = MatrixToolsd.Project(aboveHeadPos, capi.Render.PerspectiveProjectionMat, capi.Render.PerspectiveViewMat, capi.Render.FrameWidth, capi.Render.FrameHeight); // Z negative seems to indicate that the name tag is behind us \o/ if (pos.Z < 0) { return; } SingleComposer.Bounds.Alignment = EnumDialogArea.None; SingleComposer.Bounds.fixedOffsetX = 0; SingleComposer.Bounds.fixedOffsetY = 0; SingleComposer.Bounds.absFixedX = pos.X - SingleComposer.Bounds.OuterWidth / 2; SingleComposer.Bounds.absFixedY = capi.Render.FrameHeight - pos.Y - SingleComposer.Bounds.OuterHeight * FloatyDialogAlign; SingleComposer.Bounds.absMarginX = 0; SingleComposer.Bounds.absMarginY = 0; } base.OnRenderGUI(deltaTime); }
public override void OnRender2D(float deltaTime) { if (capi.Settings.Bool["floatyGuis"]) { EntityPlayer entityPlayer = capi.World.Player.Entity; Vec3d aboveHeadPos = new Vec3d(blockEntityPos.X + 0.5, blockEntityPos.Y + 1.5, blockEntityPos.Z + 0.5); Vec3d pos = MatrixToolsd.Project(aboveHeadPos, capi.Render.PerspectiveProjectionMat, capi.Render.PerspectiveViewMat, capi.Render.FrameWidth, capi.Render.FrameHeight); // Z negative seems to indicate that the name tag is behind us \o/ if (pos.Z < 0) { return; } SingleComposer.Bounds.Alignment = EnumDialogArea.None; SingleComposer.Bounds.fixedOffsetX = 0; SingleComposer.Bounds.fixedOffsetY = 0; SingleComposer.Bounds.absFixedX = pos.X - SingleComposer.Bounds.OuterWidth / 2; SingleComposer.Bounds.absFixedY = capi.Render.FrameHeight - pos.Y; SingleComposer.Bounds.absMarginX = 0; SingleComposer.Bounds.absMarginY = 0; } base.OnRender2D(deltaTime); }
public override void OnRenderGUI(float deltaTime) { if (capi.Settings.Bool["immersiveMouseMode"]) { Vec3d aboveHeadPos = new Vec3d(blockEntityPos.X + 0.5, blockEntityPos.Y + floatyDialogPosition, blockEntityPos.Z + 0.5); Vec3d pos = MatrixToolsd.Project(aboveHeadPos, capi.Render.PerspectiveProjectionMat, capi.Render.PerspectiveViewMat, capi.Render.FrameWidth, capi.Render.FrameHeight); if (pos.Z < 0) { return; } SingleComposer.Bounds.Alignment = EnumDialogArea.None; SingleComposer.Bounds.fixedOffsetX = 0; SingleComposer.Bounds.fixedOffsetY = 0; SingleComposer.Bounds.absFixedX = pos.X - SingleComposer.Bounds.OuterWidth / 2; SingleComposer.Bounds.absFixedY = capi.Render.FrameHeight - pos.Y - SingleComposer.Bounds.OuterHeight * floatyDialogAlign; SingleComposer.Bounds.absMarginX = 0; SingleComposer.Bounds.absMarginY = 0; } base.OnRenderGUI(deltaTime); }
public override void DoRender2D(float dt) { if (isSpectator || (nameTagTexture == null && debugTagTexture == null)) { return; } if ((entity as EntityPlayer)?.ServerControls.Sneak == true && debugTagTexture == null) { return; } IRenderAPI rapi = capi.Render; EntityPlayer entityPlayer = capi.World.Player.Entity; Vec3d aboveHeadPos; if (capi.World.Player.Entity.EntityId == entity.EntityId) { if (rapi.CameraType == EnumCameraMode.FirstPerson) { return; } aboveHeadPos = new Vec3d(entityPlayer.CameraPos.X + entityPlayer.LocalEyePos.X, entityPlayer.CameraPos.Y + 0.4 + entityPlayer.LocalEyePos.Y, entityPlayer.CameraPos.Z + entityPlayer.LocalEyePos.Z); } else { var thisMount = (entity as EntityAgent)?.MountedOn; var selfMount = entityPlayer.MountedOn; if (thisMount?.MountSupplier != null && thisMount.MountSupplier == selfMount?.MountSupplier) { var mpos = thisMount.MountSupplier.GetMountOffset(entity); aboveHeadPos = new Vec3d(entityPlayer.CameraPos.X + entityPlayer.LocalEyePos.X, entityPlayer.CameraPos.Y + 0.4 + entityPlayer.LocalEyePos.Y, entityPlayer.CameraPos.Z + entityPlayer.LocalEyePos.Z); aboveHeadPos.Add(mpos); } else { float f = 1; /*if (entity.Code.Path.Contains("bot") && entity.AnimManager.ActiveAnimationsByAnimCode.ContainsKey("sitflooridle")) * { * f = 0.55f; * }*/ aboveHeadPos = new Vec3d(entity.Pos.X, entity.Pos.Y + entity.SelectionBox.Y2 * f + 0.2, entity.Pos.Z); } } double offX = entity.SelectionBox.X2 - entity.OriginSelectionBox.X2; double offZ = entity.SelectionBox.Z2 - entity.OriginSelectionBox.Z2; aboveHeadPos.Add(offX, 0, offZ); Vec3d pos = MatrixToolsd.Project(aboveHeadPos, rapi.PerspectiveProjectionMat, rapi.PerspectiveViewMat, rapi.FrameWidth, rapi.FrameHeight); // Z negative seems to indicate that the name tag is behind us \o/ if (pos.Z < 0) { return; } float scale = 4f / Math.Max(1, (float)pos.Z); float cappedScale = Math.Min(1f, scale); if (cappedScale > 0.75f) { cappedScale = 0.75f + (cappedScale - 0.75f) / 2; } float offY = 0; double dist = entityPlayer.Pos.SquareDistanceTo(entity.Pos); if (nameTagTexture != null && (!showNameTagOnlyWhenTargeted || capi.World.Player.CurrentEntitySelection?.Entity == entity) && renderRange * renderRange > dist) { float posx = (float)pos.X - cappedScale * nameTagTexture.Width / 2; float posy = rapi.FrameHeight - (float)pos.Y - (nameTagTexture.Height * Math.Max(0, cappedScale)); rapi.Render2DTexture( nameTagTexture.TextureId, posx, posy, cappedScale * nameTagTexture.Width, cappedScale * nameTagTexture.Height, 20 ); offY += nameTagTexture.Height; } if (debugTagTexture != null) { float posx = (float)pos.X - cappedScale * debugTagTexture.Width / 2; float posy = rapi.FrameHeight - (float)pos.Y - (offY + debugTagTexture.Height) * Math.Max(0, cappedScale); rapi.Render2DTexture( debugTagTexture.TextureId, posx, posy - offY, cappedScale * debugTagTexture.Width, cappedScale * debugTagTexture.Height, 20 ); } if (messageTextures != null) { offY += 0; foreach (MessageTexture mt in messageTextures) { offY += (mt.tex.Height * cappedScale) + 4; float posx = (float)pos.X - cappedScale * mt.tex.Width / 2; float posy = (float)pos.Y + offY; rapi.Render2DTexture( mt.tex.TextureId, posx, rapi.FrameHeight - posy, cappedScale * mt.tex.Width, cappedScale * mt.tex.Height, 20 ); } } }
public override void DoRender2D(float dt) { if (isSpectator || (nameTagTexture == null && debugTagTexture == null)) { return; } if ((entity as EntityPlayer)?.ServerControls.Sneak == true) { return; } IRenderAPI rapi = capi.Render; EntityPlayer entityPlayer = capi.World.Player.Entity; Vec3d aboveHeadPos; if (capi.World.Player.Entity.EntityId == entity.EntityId) { if (rapi.CameraType == EnumCameraMode.FirstPerson) { return; } aboveHeadPos = new Vec3d(entityPlayer.CameraPos.X, entityPlayer.CameraPos.Y + entity.CollisionBox.Y2 + 0.2, entityPlayer.CameraPos.Z); } else { aboveHeadPos = new Vec3d(entity.Pos.X, entity.Pos.Y + entity.CollisionBox.Y2 + 0.2, entity.Pos.Z); } double offX = entity.CollisionBox.X2 - entity.OriginCollisionBox.X2; double offZ = entity.CollisionBox.Z2 - entity.OriginCollisionBox.Z2; aboveHeadPos.Add(offX, 0, offZ); Vec3d pos = MatrixToolsd.Project(aboveHeadPos, rapi.PerspectiveProjectionMat, rapi.PerspectiveViewMat, rapi.FrameWidth, rapi.FrameHeight); // Z negative seems to indicate that the name tag is behind us \o/ if (pos.Z < 0) { return; } float scale = 4f / Math.Max(1, (float)pos.Z); float cappedScale = Math.Min(1f, scale); if (cappedScale > 0.75f) { cappedScale = 0.75f + (cappedScale - 0.75f) / 2; } float offY = 0; double dist = entityPlayer.Pos.SquareDistanceTo(entity.Pos); if (nameTagTexture != null && (!showNameTagOnlyWhenTargeted || capi.World.Player.CurrentEntitySelection?.Entity == entity) && renderRange * renderRange > dist) { float posx = (float)pos.X - cappedScale * nameTagTexture.Width / 2; float posy = rapi.FrameHeight - (float)pos.Y - (nameTagTexture.Height * Math.Max(0, cappedScale)); rapi.Render2DTexture( nameTagTexture.TextureId, posx, posy, cappedScale * nameTagTexture.Width, cappedScale * nameTagTexture.Height, 20 ); offY += nameTagTexture.Height; } if (debugTagTexture != null) { float posx = (float)pos.X - cappedScale * debugTagTexture.Width / 2; float posy = rapi.FrameHeight - (float)pos.Y - (offY + debugTagTexture.Height) * Math.Max(0, cappedScale); rapi.Render2DTexture( debugTagTexture.TextureId, posx, posy - offY, cappedScale * debugTagTexture.Width, cappedScale * debugTagTexture.Height, 20 ); } if (messageTextures != null) { offY += 0; foreach (MessageTexture mt in messageTextures) { offY += (mt.tex.Height * cappedScale) + 4; float posx = (float)pos.X - cappedScale * mt.tex.Width / 2; float posy = (float)pos.Y + offY; rapi.Render2DTexture( mt.tex.TextureId, posx, rapi.FrameHeight - posy, cappedScale * mt.tex.Width, cappedScale * mt.tex.Height, 20 ); // - cappedScale * mt.tex.height } } }
public override void DoRender2D(float dt) { if (isSpectator || (nameTagTexture == null && debugTagTexture == null)) { return; } IRenderAPI rapi = capi.Render; EntityPlayer entityPlayer = capi.World.Player.Entity; Vec3d aboveHeadPos; if (capi.World.Player.Entity.EntityId == entity.EntityId) { if (rapi.CameraType == EnumCameraMode.FirstPerson) { return; } aboveHeadPos = new Vec3d(entityPlayer.CameraPos.X, entityPlayer.CameraPos.Y + entity.CollisionBox.Y2 + 0.5, entityPlayer.CameraPos.Z); } else { aboveHeadPos = new Vec3d(entity.Pos.X, entity.Pos.Y + entity.CollisionBox.Y2 + 0.5, entity.Pos.Z); } Vec3d pos = MatrixToolsd.Project(aboveHeadPos, rapi.PerspectiveProjectionMat, rapi.PerspectiveViewMat, rapi.FrameWidth, rapi.FrameHeight); // Z negative seems to indicate that the name tag is behind us \o/ if (pos.Z < 0) { return; } float scale = 4f / Math.Max(1, (float)pos.Z); float cappedScale = Math.Min(1f, scale); if (cappedScale > 0.75f) { cappedScale = 0.75f + (cappedScale - 0.75f) / 2; } float offY = 0; if (nameTagTexture != null) { float posx = (float)pos.X - cappedScale * nameTagTexture.Width / 2; float posy = rapi.FrameHeight - (float)pos.Y + (nameTagTexture.Height * Math.Max(0, scale - 1)); rapi.Render2DTexture( nameTagTexture.TextureId, posx, posy, cappedScale * nameTagTexture.Width, cappedScale * nameTagTexture.Height, 20 ); } if (debugTagTexture != null) { float posx = (float)pos.X - cappedScale * debugTagTexture.Width / 2; float posy = rapi.FrameHeight - (float)pos.Y - (debugTagTexture.Height * Math.Max(0, cappedScale)); rapi.Render2DTexture( debugTagTexture.TextureId, posx, posy - offY, cappedScale * debugTagTexture.Width, cappedScale * debugTagTexture.Height, 20 ); } if (messageTextures != null) { offY += 0; foreach (MessageTexture mt in messageTextures) { offY += (mt.tex.Height * cappedScale) + 4; float posx = (float)pos.X - cappedScale * mt.tex.Width / 2; float posy = (float)pos.Y + offY; rapi.Render2DTexture( mt.tex.TextureId, posx, rapi.FrameHeight - posy, cappedScale * mt.tex.Width, cappedScale * mt.tex.Height, 20 ); // - cappedScale * mt.tex.height } } }