public void Render(GameInfo game, Device d3d9Device, LiveSplitHelper liveSplitHelper) { // TODO: Pass in a scaling factor here? At least figure our how overlay scaling will work. if (_overlayLookup.TryGetValue(game.State.Current, out var overlay)) { overlay.Render(game, d3d9Device, liveSplitHelper); } else { _overlayLookup[GameState.Other].Render(game, d3d9Device, liveSplitHelper); } }
/// <summary> /// The steps run upon creation, but before injection. /// /// The parameters for Run and the Constructor must be the same. /// </summary> /// <param name="context">Some context information about the environment in which this method is invoked.</param> /// <param name="channelName">The IPC Channel Name for communication.</param> /// <param name="lcGoLProcessId">The LCGoL Process Id.</param> public InjectionEntryPoint(IContext context, string channelName, int lcGoLProcessId) { _server = IpcConnectClient <ServerInterface>(channelName); _lcgolProcess = Process.GetProcessById(lcGoLProcessId); _lcgolInfo = new GameInfo(_lcgolProcess); _overlay = new LCGoLOverlay(); _server.Ping(); _injectorProcess = Process.GetProcessById(context.HostPID); // TODO: Once integrated into livesplit, the livesplit process should be the _injectorProcess var livesplitprocess = _injectorProcess; //livesplitprocess = Process.GetProcessesByName("LiveSplit").FirstOrDefault(); _liveSplitHelper = new LiveSplitHelper(livesplitprocess, channelName, _server); //_speedRunComHelper = new SpeedRunComHelper(_server); }
public void Render(GameInfo game, Device d3d9Device, LiveSplitHelper liveSplitHelper) { var y = 0; Text.DrawText(d3d9Device, $"{nameof(game.Level.Current)}: {game.Level.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.AreaCode.Current)}: {game.AreaCode.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.NumberOfPlayers.Current)}: {game.NumberOfPlayers.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.State.Current)}: {game.State.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.GameTime.Current)}: {game.GameTime.Current.ToTimerString()}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.ValidVSyncSettings.Current)}: {game.ValidVSyncSettings.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.HasControl.Current)}: {game.HasControl.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); }
private void GenerateLiveSplitSprite(Device d3d9Device, LiveSplitHelper liveSplitHelper) { _liveSplitTexture?.Dispose(); _liveSplitSprite?.Dispose(); var bitmap = liveSplitHelper.WindowBitmap; if (bitmap != null) { var bytes = (byte[])_converter.ConvertTo(bitmap, typeof(byte[])); _liveSplitRectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height); _liveSplitTexture = Texture.FromMemory(d3d9Device, bytes); _liveSplitSprite = new Sprite(d3d9Device); bitmap.Dispose(); } }
// TODO: Implement EndScreenOverlay Render public void Render(GameInfo game, Device d3d9Device, LiveSplitHelper liveSplitHelper) { }
public void Render(GameInfo game, Device d3d9Device, LiveSplitHelper liveSplitHelper) { if (game.State.Old != GameState.InEndScreen && game.State.Current == GameState.InEndScreen) { _prevLevelInfo = game.GetGameInfoSnapShot(); GenerateLiveSplitSprite(d3d9Device, liveSplitHelper); } if (game.State.Old != GameState.InLoadScreen && game.State.Current == GameState.InLoadScreen) { GenerateLiveSplitSprite(d3d9Device, liveSplitHelper); } var y = 0; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.Level)}: {_prevLevelInfo.Level.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.AreaCode)}: {_prevLevelInfo.AreaCode.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.NumberOfPlayers)}: {_prevLevelInfo.NumberOfPlayers.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.State)}: {_prevLevelInfo.State.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.GameTime)}: {_prevLevelInfo.GameTime.Current.ToTimerString()}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.ValidVSyncSettings)}: {_prevLevelInfo.ValidVSyncSettings.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(_prevLevelInfo.HasControl)}: {_prevLevelInfo.HasControl.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"------------------", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.Level)}: {game.Level.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.AreaCode)}: {game.AreaCode.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.NumberOfPlayers)}: {game.NumberOfPlayers.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.State)}: {game.State.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.GameTime)}: {game.GameTime.Current.ToTimerString()}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.ValidVSyncSettings)}: {game.ValidVSyncSettings.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); y += 36; Text.DrawText(d3d9Device, $"{nameof(game.HasControl)}: {game.HasControl.Current}", 34, 0, y, new RawColorBGRA(255, 255, 255, 255)); if (_liveSplitSprite != null && _liveSplitTexture != null) { _liveSplitSprite.Begin(); var w = d3d9Device.Viewport.Width; var h = d3d9Device.Viewport.Height; var pos = new RawVector3(w - _liveSplitRectangle.Width, h - _liveSplitRectangle.Height, 0); var color = new RawColorBGRA(255, 255, 255, 255); _liveSplitSprite.Draw(_liveSplitTexture, color, null, null, pos); _liveSplitSprite.End(); } }