diff --git a/Latite/LatiteForm.Designer.cs b/Latite/LatiteForm.Designer.cs index a925583..67affe7 100644 --- a/Latite/LatiteForm.Designer.cs +++ b/Latite/LatiteForm.Designer.cs @@ -44,6 +44,7 @@ private void InitializeComponent() this.zoomCheckbox = new System.Windows.Forms.CheckBox(); this.zoomLabel = new System.Windows.Forms.Label(); this.optionsTabControl = new System.Windows.Forms.TabPage(); + this.transparentOverlayToggle = new System.Windows.Forms.CheckBox(); this.settingsUseConsole = new System.Windows.Forms.CheckBox(); this.consoleTab = new System.Windows.Forms.TabPage(); this.cinGo = new System.Windows.Forms.Button(); @@ -59,6 +60,13 @@ private void InitializeComponent() this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.LatiteIcon1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.launchButton = new System.Windows.Forms.Button(); + this.lookBehindLabel = new System.Windows.Forms.Label(); + this.lookBehindEnabled = new System.Windows.Forms.CheckBox(); + this.lookBehindPanel = new System.Windows.Forms.Panel(); + this.lookBehindBind = new System.Windows.Forms.TextBox(); + this.lookBehindBindLabel = new System.Windows.Forms.Label(); + this.lookBehindDesc = new System.Windows.Forms.Label(); this.modsControl.SuspendLayout(); this.modsTabPage.SuspendLayout(); this.zoomPanel.SuspendLayout(); @@ -68,6 +76,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.LatiteIcon1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.lookBehindPanel.SuspendLayout(); this.SuspendLayout(); // // LatiteLabel1 @@ -113,7 +122,10 @@ private void InitializeComponent() // modsTabPage // this.modsTabPage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.modsTabPage.Controls.Add(this.lookBehindDesc); + this.modsTabPage.Controls.Add(this.lookBehindLabel); this.modsTabPage.Controls.Add(this.zoomPanel); + this.modsTabPage.Controls.Add(this.lookBehindPanel); this.modsTabPage.Controls.Add(this.zoomLabel); this.modsTabPage.Location = new System.Drawing.Point(4, 35); this.modsTabPage.Name = "modsTabPage"; @@ -138,11 +150,12 @@ private void InitializeComponent() // // zoomBindBox // - this.zoomBindBox.Location = new System.Drawing.Point(73, 135); + this.zoomBindBox.Location = new System.Drawing.Point(73, 133); this.zoomBindBox.Name = "zoomBindBox"; this.zoomBindBox.Size = new System.Drawing.Size(24, 33); this.zoomBindBox.TabIndex = 6; this.zoomBindBox.Text = "C"; + this.zoomBindBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.zoomBindBox.TextChanged += new System.EventHandler(this.zoomBindBox_TextChanged); // // zoomKeybindLabel @@ -203,6 +216,7 @@ private void InitializeComponent() this.zoomCheckbox.TabIndex = 0; this.zoomCheckbox.Text = "Enabled"; this.zoomCheckbox.UseVisualStyleBackColor = true; + this.zoomCheckbox.CheckedChanged += new System.EventHandler(this.zoomCheckbox_CheckedChanged); // // zoomLabel // @@ -216,6 +230,7 @@ private void InitializeComponent() // optionsTabControl // this.optionsTabControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.optionsTabControl.Controls.Add(this.transparentOverlayToggle); this.optionsTabControl.Controls.Add(this.settingsUseConsole); this.optionsTabControl.Location = new System.Drawing.Point(4, 22); this.optionsTabControl.Name = "optionsTabControl"; @@ -224,6 +239,17 @@ private void InitializeComponent() this.optionsTabControl.TabIndex = 1; this.optionsTabControl.Text = "Options"; // + // transparentOverlayToggle + // + this.transparentOverlayToggle.AutoSize = true; + this.transparentOverlayToggle.Location = new System.Drawing.Point(23, 57); + this.transparentOverlayToggle.Name = "transparentOverlayToggle"; + this.transparentOverlayToggle.Size = new System.Drawing.Size(202, 30); + this.transparentOverlayToggle.TabIndex = 1; + this.transparentOverlayToggle.Text = "Transparent Overlay"; + this.transparentOverlayToggle.UseVisualStyleBackColor = true; + this.transparentOverlayToggle.CheckedChanged += new System.EventHandler(this.transparentOverlayToggle_CheckedChanged); + // // settingsUseConsole // this.settingsUseConsole.AutoSize = true; @@ -385,7 +411,7 @@ private void InitializeComponent() this.disconnectButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.disconnectButton.Font = new System.Drawing.Font("Calibri", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.disconnectButton.ForeColor = System.Drawing.Color.White; - this.disconnectButton.Location = new System.Drawing.Point(12, 427); + this.disconnectButton.Location = new System.Drawing.Point(13, 388); this.disconnectButton.Name = "disconnectButton"; this.disconnectButton.Size = new System.Drawing.Size(90, 33); this.disconnectButton.TabIndex = 12; @@ -424,11 +450,92 @@ private void InitializeComponent() this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // + // launchButton + // + this.launchButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.launchButton.Cursor = System.Windows.Forms.Cursors.Hand; + this.launchButton.FlatAppearance.BorderColor = System.Drawing.Color.Lime; + this.launchButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56))))); + this.launchButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(96)))), ((int)(((byte)(96))))); + this.launchButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.launchButton.Font = new System.Drawing.Font("Calibri", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.launchButton.ForeColor = System.Drawing.Color.White; + this.launchButton.Location = new System.Drawing.Point(13, 427); + this.launchButton.Name = "launchButton"; + this.launchButton.Size = new System.Drawing.Size(90, 33); + this.launchButton.TabIndex = 13; + this.launchButton.Text = "Launch"; + this.launchButton.UseVisualStyleBackColor = false; + this.launchButton.Click += new System.EventHandler(this.launchButton_Click); + // + // lookBehindLabel + // + this.lookBehindLabel.AutoSize = true; + this.lookBehindLabel.Location = new System.Drawing.Point(23, 215); + this.lookBehindLabel.Name = "lookBehindLabel"; + this.lookBehindLabel.Size = new System.Drawing.Size(112, 26); + this.lookBehindLabel.TabIndex = 7; + this.lookBehindLabel.Text = "LookBehind"; + // + // lookBehindEnabled + // + this.lookBehindEnabled.AutoSize = true; + this.lookBehindEnabled.Checked = true; + this.lookBehindEnabled.CheckState = System.Windows.Forms.CheckState.Checked; + this.lookBehindEnabled.ForeColor = System.Drawing.Color.White; + this.lookBehindEnabled.Location = new System.Drawing.Point(17, 12); + this.lookBehindEnabled.Name = "lookBehindEnabled"; + this.lookBehindEnabled.Size = new System.Drawing.Size(99, 30); + this.lookBehindEnabled.TabIndex = 0; + this.lookBehindEnabled.Text = "Enabled"; + this.lookBehindEnabled.UseVisualStyleBackColor = true; + this.lookBehindEnabled.CheckedChanged += new System.EventHandler(this.lookBehindEnabled_CheckedChanged); + // + // lookBehindPanel + // + this.lookBehindPanel.Controls.Add(this.lookBehindBind); + this.lookBehindPanel.Controls.Add(this.lookBehindBindLabel); + this.lookBehindPanel.Controls.Add(this.lookBehindEnabled); + this.lookBehindPanel.Location = new System.Drawing.Point(28, 248); + this.lookBehindPanel.Name = "lookBehindPanel"; + this.lookBehindPanel.Size = new System.Drawing.Size(200, 169); + this.lookBehindPanel.TabIndex = 8; + // + // lookBehindBind + // + this.lookBehindBind.Location = new System.Drawing.Point(73, 56); + this.lookBehindBind.Name = "lookBehindBind"; + this.lookBehindBind.Size = new System.Drawing.Size(24, 33); + this.lookBehindBind.TabIndex = 6; + this.lookBehindBind.Text = "G"; + this.lookBehindBind.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.lookBehindBind.TextChanged += new System.EventHandler(this.lookBehindBind_TextChanged); + // + // lookBehindBindLabel + // + this.lookBehindBindLabel.AutoSize = true; + this.lookBehindBindLabel.Location = new System.Drawing.Point(17, 59); + this.lookBehindBindLabel.Name = "lookBehindBindLabel"; + this.lookBehindBindLabel.Size = new System.Drawing.Size(50, 26); + this.lookBehindBindLabel.TabIndex = 5; + this.lookBehindBindLabel.Text = "Bind"; + // + // lookBehindDesc + // + this.lookBehindDesc.AutoSize = true; + this.lookBehindDesc.Font = new System.Drawing.Font("Calibri", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lookBehindDesc.Location = new System.Drawing.Point(141, 221); + this.lookBehindDesc.Name = "lookBehindDesc"; + this.lookBehindDesc.Size = new System.Drawing.Size(172, 18); + this.lookBehindDesc.TabIndex = 9; + this.lookBehindDesc.Text = "Rear view by holding a key"; + // // LatiteForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); this.ClientSize = new System.Drawing.Size(704, 556); + this.Controls.Add(this.launchButton); this.Controls.Add(this.disconnectButton); this.Controls.Add(this.connectedLabel); this.Controls.Add(this.optionsButton); @@ -463,6 +570,8 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.LatiteIcon1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.lookBehindPanel.ResumeLayout(false); + this.lookBehindPanel.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -499,6 +608,14 @@ private void InitializeComponent() private System.Windows.Forms.TextBox zoomBindBox; private System.ComponentModel.BackgroundWorker moduleWorker; private System.Windows.Forms.Button disconnectButton; + private System.Windows.Forms.CheckBox transparentOverlayToggle; + private System.Windows.Forms.Button launchButton; + private System.Windows.Forms.Label lookBehindDesc; + private System.Windows.Forms.Label lookBehindLabel; + private System.Windows.Forms.Panel lookBehindPanel; + private System.Windows.Forms.TextBox lookBehindBind; + private System.Windows.Forms.Label lookBehindBindLabel; + private System.Windows.Forms.CheckBox lookBehindEnabled; } } diff --git a/Latite/LatiteForm.cs b/Latite/LatiteForm.cs index 13bf60d..6836440 100644 --- a/Latite/LatiteForm.cs +++ b/Latite/LatiteForm.cs @@ -17,13 +17,15 @@ namespace Latite { public partial class LatiteForm : Form { + [DllImport("LatiteCore.dll")] + static extern void setEnabled(uint modId, bool enabled); [DllImport("LatiteCore.dll")] static extern void consoleMain(); [DllImport("LatiteCore.dll")] static extern ulong attach(); // extern "C" LATITE_API bool connectedToMinecraft(int type = 2); [DllImport("LatiteCore.dll")] - static extern bool connectedToMinecraft(int type = 2); + public static extern bool connectedToMinecraft(int type = 2); [DllImport("LatiteCore.dll")] static extern void detach(); [DllImport("LatiteCore.dll")] @@ -37,11 +39,15 @@ public partial class LatiteForm : Form static extern void mod_zoom_setBind(char bind); [DllImport("LatiteCore.dll")] static extern void mod_zoom_setAmount(float amount); + [DllImport("LatiteCore.dll")] + static extern void mod_lookBehind_setBind(char bind); public LatiteForm() { InitializeComponent(); } + private Overlay OverlayForm = new Overlay(); + readonly string[] Commands = { "help", "info", "print ", "clear", "connect", "disconnect" }; readonly string Info = "Latite Client\r\n\r\nLicense: GPLv3\r\n\r\nSource: github.com/Imrglop/Latite\r\n\r\nMade by Imrglop"; private bool IsConsole = false; @@ -55,7 +61,7 @@ public void Coutln(string OutputString) consoleOutput.Text += (OutputString + "\r\n"); } - private void ConnectToMc() + private void ConnectToMc(bool show = true) { try { @@ -76,15 +82,24 @@ private void ConnectToMc() moduleWorker.RunWorkerAsync(); disconnectButton.Visible = true; Coutln("Connected to Minecraft!"); - MessageBox.Show("Connected to Minecraft!"); + if (this.OverlayForm.IsDisposed) + { + this.OverlayForm = new Overlay(); + } + this.OverlayForm.Show(); + if (show) + MessageBox.Show("Connected to Minecraft!"); } else { - Coutln("Couldn't connect to Minecraft! Error code: " + Status.ToString()); - var Result = MessageBox.Show("Could not connect to Minecraft! Error Code: " + Status.ToString(), "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); - if (Result == DialogResult.Retry) + if (show) { - ConnectToMc(); + Coutln("Couldn't connect to Minecraft! Error code: " + Status.ToString()); + var Result = MessageBox.Show("Could not connect to Minecraft! Error Code: " + Status.ToString(), "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Hand); + if (Result == DialogResult.Retry) + { + ConnectToMc(); + } } } } @@ -111,6 +126,7 @@ private void DisconnectFromMc() connectButton.Visible = true; connectedToMinecraft(0); // false connectedLabel.Visible = false; + this.OverlayForm.Close(); detach(); } } @@ -230,8 +246,36 @@ private void zoomBindBox_TextChanged(object sender, EventArgs e) private void LatiteForm_Load(object sender, EventArgs e) { - Overlay OverlayForm = new Overlay(); - OverlayForm.Show(); + ConnectToMc(false); // silently connect on launch + } + + private void transparentOverlayToggle_CheckedChanged(object sender, EventArgs e) + { + this.OverlayForm.TransparentPanels(transparentOverlayToggle.Checked); ; + } + + private void launchButton_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start("minecraft://"); + Thread.Sleep(100); + ConnectToMc(false); + } + + private void zoomCheckbox_CheckedChanged(object sender, EventArgs e) + { + setEnabled(1, zoomCheckbox.Checked); + } + + private void lookBehindEnabled_CheckedChanged(object sender, EventArgs e) + { + setEnabled(2, lookBehindEnabled.Checked); + } + + private void lookBehindBind_TextChanged(object sender, EventArgs e) + { + string SetStr = zoomBindBox.Text.ToUpper(); + if (SetStr.Length > 0) + mod_lookBehind_setBind(SetStr[0]); } } } diff --git a/Latite/LatiteForm.resx b/Latite/LatiteForm.resx index ee8ad82..439daa5 100644 --- a/Latite/LatiteForm.resx +++ b/Latite/LatiteForm.resx @@ -120,6 +120,9 @@ 17, 17 + + 63 + diff --git a/Latite/Overlay.Designer.cs b/Latite/Overlay.Designer.cs index 4112588..72fc5af 100644 --- a/Latite/Overlay.Designer.cs +++ b/Latite/Overlay.Designer.cs @@ -48,6 +48,14 @@ private void InitializeComponent() this.keystrokeLabel = new System.Windows.Forms.Label(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.secondRunner = new System.ComponentModel.BackgroundWorker(); + this.motionLabel = new System.Windows.Forms.Label(); + this.motionYLabel = new System.Windows.Forms.Label(); + this.posPanel = new System.Windows.Forms.Panel(); + this.zPosLabel = new System.Windows.Forms.Label(); + this.yPosLabel = new System.Windows.Forms.Label(); + this.xPosLabel = new System.Windows.Forms.Label(); + this.motionTopLabel = new System.Windows.Forms.Label(); + this.toggleSprintLabel = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.Keystrokes_RMB.SuspendLayout(); this.Keystrokes_LMB.SuspendLayout(); @@ -55,6 +63,7 @@ private void InitializeComponent() this.keyStrokes_A.SuspendLayout(); this.keyStrokes_S.SuspendLayout(); this.keyStrokes_W.SuspendLayout(); + this.posPanel.SuspendLayout(); this.SuspendLayout(); // // panel1 @@ -176,7 +185,7 @@ private void InitializeComponent() // kLabel3 // this.kLabel3.AutoSize = true; - this.kLabel3.Location = new System.Drawing.Point(16, 17); + this.kLabel3.Location = new System.Drawing.Point(19, 17); this.kLabel3.Name = "kLabel3"; this.kLabel3.Size = new System.Drawing.Size(21, 23); this.kLabel3.TabIndex = 3; @@ -227,11 +236,98 @@ private void InitializeComponent() // this.secondRunner.DoWork += new System.ComponentModel.DoWorkEventHandler(this.secondRunner_DoWork); // + // motionLabel + // + this.motionLabel.AutoSize = true; + this.motionLabel.Location = new System.Drawing.Point(6, 98); + this.motionLabel.Name = "motionLabel"; + this.motionLabel.Size = new System.Drawing.Size(81, 23); + this.motionLabel.TabIndex = 1; + this.motionLabel.Text = "Motion X"; + // + // motionYLabel + // + this.motionYLabel.AutoSize = true; + this.motionYLabel.Location = new System.Drawing.Point(6, 121); + this.motionYLabel.Name = "motionYLabel"; + this.motionYLabel.Size = new System.Drawing.Size(80, 23); + this.motionYLabel.TabIndex = 2; + this.motionYLabel.Text = "Motion Y"; + // + // posPanel + // + this.posPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(60)))), ((int)(((byte)(70))))); + this.posPanel.Controls.Add(this.zPosLabel); + this.posPanel.Controls.Add(this.yPosLabel); + this.posPanel.Controls.Add(this.xPosLabel); + this.posPanel.Controls.Add(this.motionTopLabel); + this.posPanel.Controls.Add(this.motionLabel); + this.posPanel.Controls.Add(this.motionYLabel); + this.posPanel.Location = new System.Drawing.Point(12, 296); + this.posPanel.Name = "posPanel"; + this.posPanel.Size = new System.Drawing.Size(155, 155); + this.posPanel.TabIndex = 4; + this.posPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.posPanel_Paint); + // + // zPosLabel + // + this.zPosLabel.AutoSize = true; + this.zPosLabel.ForeColor = System.Drawing.Color.RoyalBlue; + this.zPosLabel.Location = new System.Drawing.Point(6, 78); + this.zPosLabel.Name = "zPosLabel"; + this.zPosLabel.Size = new System.Drawing.Size(28, 23); + this.zPosLabel.TabIndex = 6; + this.zPosLabel.Text = "??"; + // + // yPosLabel + // + this.yPosLabel.AutoSize = true; + this.yPosLabel.ForeColor = System.Drawing.Color.Lime; + this.yPosLabel.Location = new System.Drawing.Point(6, 55); + this.yPosLabel.Name = "yPosLabel"; + this.yPosLabel.Size = new System.Drawing.Size(28, 23); + this.yPosLabel.TabIndex = 5; + this.yPosLabel.Text = "??"; + // + // xPosLabel + // + this.xPosLabel.AutoSize = true; + this.xPosLabel.ForeColor = System.Drawing.Color.Red; + this.xPosLabel.Location = new System.Drawing.Point(6, 32); + this.xPosLabel.Name = "xPosLabel"; + this.xPosLabel.Size = new System.Drawing.Size(28, 23); + this.xPosLabel.TabIndex = 4; + this.xPosLabel.Text = "??"; + // + // motionTopLabel + // + this.motionTopLabel.AutoSize = true; + this.motionTopLabel.Font = new System.Drawing.Font("Calibri", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.motionTopLabel.ForeColor = System.Drawing.Color.LightBlue; + this.motionTopLabel.Location = new System.Drawing.Point(25, 2); + this.motionTopLabel.Name = "motionTopLabel"; + this.motionTopLabel.Size = new System.Drawing.Size(102, 33); + this.motionTopLabel.TabIndex = 3; + this.motionTopLabel.Text = "Position"; + // + // toggleSprintLabel + // + this.toggleSprintLabel.AutoSize = true; + this.toggleSprintLabel.Location = new System.Drawing.Point(8, 615); + this.toggleSprintLabel.Name = "toggleSprintLabel"; + this.toggleSprintLabel.Size = new System.Drawing.Size(153, 23); + this.toggleSprintLabel.TabIndex = 5; + this.toggleSprintLabel.Text = "Sprinting (toggled)"; + this.toggleSprintLabel.Visible = false; + // // Overlay // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 23F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(10)))), ((int)(((byte)(10))))); this.ClientSize = new System.Drawing.Size(1133, 666); + this.Controls.Add(this.toggleSprintLabel); + this.Controls.Add(this.posPanel); this.Controls.Add(this.panel1); this.Font = new System.Drawing.Font("Calibri", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.ForeColor = System.Drawing.Color.White; @@ -254,7 +350,10 @@ private void InitializeComponent() this.keyStrokes_S.PerformLayout(); this.keyStrokes_W.ResumeLayout(false); this.keyStrokes_W.PerformLayout(); + this.posPanel.ResumeLayout(false); + this.posPanel.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -279,5 +378,13 @@ private void InitializeComponent() private System.Windows.Forms.Label RMBLabel; private System.Windows.Forms.Label LMBLabel; private System.ComponentModel.BackgroundWorker secondRunner; + private System.Windows.Forms.Label motionLabel; + private System.Windows.Forms.Label motionYLabel; + private System.Windows.Forms.Panel posPanel; + private System.Windows.Forms.Label zPosLabel; + private System.Windows.Forms.Label yPosLabel; + private System.Windows.Forms.Label xPosLabel; + private System.Windows.Forms.Label motionTopLabel; + private System.Windows.Forms.Label toggleSprintLabel; } } \ No newline at end of file diff --git a/Latite/Overlay.cs b/Latite/Overlay.cs index b5587f3..286ccd3 100644 --- a/Latite/Overlay.cs +++ b/Latite/Overlay.cs @@ -18,6 +18,18 @@ public partial class Overlay : Form bool W_Pressed, A_Pressed, S_Pressed, D_Pressed, LMB_Pressed, RMB_Pressed; int lcps, rcps = 0; + [DllImport("LatiteCore.dll")] + static extern float LPGetYMotion(); + [DllImport("LatiteCore.dll")] + static extern float LPGetXPos(); + [DllImport("LatiteCore.dll")] + static extern float LPGetYPos(); + [DllImport("LatiteCore.dll")] + static extern float LPGetZPos(); + + [DllImport("LatiteCore.dll")] + static extern float LPGetMotion(); + [DllImport("user32.dll")] public static extern short GetKeyState(int nVirtKey); // winuser.h @@ -38,12 +50,28 @@ public partial class Overlay : Form public static IntPtr hWnd = FindWindowA(null, "Minecraft"); // find minecraft public static RECT rect; - + public struct RECT { public int left, top, right, bottom; } + private void posPanel_Paint(object sender, PaintEventArgs e) + { + + } + + public void TransparentPanels(bool b) + { + if (b) + { + posPanel.BackColor = Color.Transparent; + } else + { + posPanel.BackColor = Color.FromArgb(50, 60, 70); + } + } + private void secondRunner_DoWork(object sender, DoWorkEventArgs e) { while (true) @@ -58,6 +86,10 @@ private void secondRunner_DoWork(object sender, DoWorkEventArgs e) } } + public void toggleSprint(bool val = true) + { + toggleSprintLabel.Visible = val; + } public Overlay() { InitializeComponent(); @@ -66,13 +98,6 @@ public Overlay() private void Overlay_Load(object sender, EventArgs e) { this.KeyPreview = true; - if (hWnd != (IntPtr)0) - { - - } else - { - MessageBox.Show("Please open Minecraft first for the keystrokes and other things to work"); - } // cause transparency BackColor = Color.Brown; TransparencyKey = Color.Brown; @@ -130,10 +155,10 @@ private void UpdateKeystrokes() } if (LMB_Pressed) Keystrokes_LMB.BackColor = Color.FromArgb(PressedColor[0], PressedColor[1], PressedColor[2]); - else Keystrokes_LMB.BackColor = Color.FromArgb(NotPressedColor[0], PressedColor[1], PressedColor[2]); + else Keystrokes_LMB.BackColor = Color.FromArgb(NotPressedColor[0], NotPressedColor[1], NotPressedColor[2]); if (RMB_Pressed) Keystrokes_RMB.BackColor = Color.FromArgb(PressedColor[0], PressedColor[1], PressedColor[2]); - else Keystrokes_RMB.BackColor = Color.FromArgb(NotPressedColor[0], PressedColor[1], PressedColor[2]); + else Keystrokes_RMB.BackColor = Color.FromArgb(NotPressedColor[0], NotPressedColor[1], NotPressedColor[2]); //MessageBox.Show("Updated kEystrokes"); } @@ -142,6 +167,15 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) while (true) { Thread.Sleep(10); // Cooldown + if (LatiteForm.connectedToMinecraft()) + { + xPosLabel.Text = Math.Round(LPGetXPos(), 2) + ""; + yPosLabel.Text = Math.Round(LPGetYPos(), 2) + ""; + zPosLabel.Text = Math.Round(LPGetZPos(), 2) + ""; + motionLabel.Text = Math.Round(LPGetMotion(), 3) + ""; + motionYLabel.Text = Math.Round(LPGetYMotion(), 3) + ""; + } + if (GetForegroundWindow() != hWnd) { IntPtr hWnd = FindWindowA(null, "Minecraft"); diff --git a/LatiteCore/LatiteCore.vcxproj b/LatiteCore/LatiteCore.vcxproj index 5c47885..d9cbebe 100644 --- a/LatiteCore/LatiteCore.vcxproj +++ b/LatiteCore/LatiteCore.vcxproj @@ -153,8 +153,8 @@ - + @@ -162,6 +162,7 @@ + diff --git a/LatiteCore/LatiteCore.vcxproj.filters b/LatiteCore/LatiteCore.vcxproj.filters index 5e7e45c..8873e48 100644 --- a/LatiteCore/LatiteCore.vcxproj.filters +++ b/LatiteCore/LatiteCore.vcxproj.filters @@ -21,9 +21,6 @@ - - Header Files - Source Files @@ -39,6 +36,9 @@ Source Files\Tools + + Source Files\Mods + @@ -56,5 +56,8 @@ Source Files\Tools + + Source Files\Mods + \ No newline at end of file diff --git a/LatiteCore/LocalPlayer.cpp b/LatiteCore/LocalPlayer.cpp index 5d18a8e..37a42a1 100644 --- a/LatiteCore/LocalPlayer.cpp +++ b/LatiteCore/LocalPlayer.cpp @@ -33,3 +33,63 @@ void LocalPlayer::setFOV(float fov) log << "Fov address is 0 will not set fov.\n"; } } + +void LocalPlayer::setSensitivity(float sens) +{ + auto sensAddress = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_FSENS_BASEADDY), + ADDRESS_FSENS_SEMI_OFFSETS) + ADDRESS_FSENS_LAST_OFFSET; + if (sensAddress == 0) return; + WriteProcessMemory(getHProcess(), (void*)sensAddress, &sens, sizeof(sens), NULL); +} + +float LocalPlayer::getSensitivity() +{ + float val = 0; + auto sensAddress = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_FSENS_BASEADDY), + ADDRESS_FSENS_SEMI_OFFSETS) + ADDRESS_FSENS_LAST_OFFSET; + if (sensAddress == 0) return 0.f; + ReadProcessMemory(getHProcess(), (void*)sensAddress, &val, sizeof(val), NULL); + return val; +} + +unsigned char LocalPlayer::getHideHand() +{ + auto hhAddress = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_FHH_BASEADDY), ADDRESS_FHH_SEMI_OFFSETS) + ADDRESS_FSENS_LAST_OFFSET; + unsigned char val = 0; + ReadProcessMemory(getHProcess(), (void*)hhAddress, &val, sizeof(val), NULL); + return val; +} + +void LocalPlayer::setHideHand(unsigned char val) +{ + auto hhAddress = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_FHH_BASEADDY), ADDRESS_FHH_SEMI_OFFSETS) + ADDRESS_FHH_LAST_OFFSET; + if (!WriteProcessMemory(getHProcess(), (void*)hhAddress, &val, sizeof(val), NULL)) + { + log << "WPM error while setting Hide Hand to " << (int)val << ": " << GetLastError() << '\n'; + }; +} + +bool LocalPlayer::isInGame() +{ + // check if the Y position address is initialized + ADDRESS yAddy = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_Y_BASEADDY), ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + if ((void*)yAddy == nullptr) return false; + return true; +} + +unsigned char LocalPlayer::getPerspective() +{ + unsigned char retVal = 0; + ADDRESS pAddy = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_PRESPECTIVE_BASEADDY), ADDRESS_PRESPECTIVE_OFFSETS) + ADDRESS_PRESPECTIVE_LAST_OFFSET; + if (pAddy != 0) + ReadProcessMemory(getHProcess(), (void*)pAddy, &retVal, sizeof(retVal), NULL); + return retVal; +} + + +void LocalPlayer::setPerspective(unsigned char val) +{ + ADDRESS pAddy = GetMLPtrAddy((void*)(currentModuleBase() + ADDRESS_PRESPECTIVE_BASEADDY), ADDRESS_PRESPECTIVE_OFFSETS) + ADDRESS_PRESPECTIVE_LAST_OFFSET; + if (pAddy != 0) + WriteProcessMemory(getHProcess(), (void*)pAddy, &val, sizeof(val), NULL); +} diff --git a/LatiteCore/LocalPlayer.h b/LatiteCore/LocalPlayer.h index 9ee8a5e..289d474 100644 --- a/LatiteCore/LocalPlayer.h +++ b/LatiteCore/LocalPlayer.h @@ -10,7 +10,20 @@ struct LocalPlayer static float getFOV(); // Set the player's field of view static void setFOV(float fov); - + // Set sensitivity + static void setSensitivity(float sens); + // Get sensitivity + static float getSensitivity(); + // Gets hide hand setting + static unsigned char getHideHand(); + // Sets hide hand setting + static void setHideHand(unsigned char val); + // Tells whether the player is in game or not + static bool isInGame(); + // Gets your perspective 0: first person 1: 3rd person back 2: 3rd person front + static unsigned char getPerspective(); + // Sets your prespective + static void setPerspective(unsigned char val); // -------------------- }; diff --git a/LatiteCore/LookBehind.cpp b/LatiteCore/LookBehind.cpp new file mode 100644 index 0000000..c40305e --- /dev/null +++ b/LatiteCore/LookBehind.cpp @@ -0,0 +1,52 @@ +#include "LookBehind.h" +#include "LocalPlayer.h" +#include "dllmain.h" + +char lbBind_; +unsigned char oldView; +bool lbKeyPressed = false; + +void lookBehind() +{ + LocalPlayer::setPerspective(2); +} + +void goBack() +{ + if (oldView != 2) // small optimization + LocalPlayer::setPerspective(oldView); +} + +void LookBehind::setBind(char b) +{ + this->bind = b; + lbBind_ = b; +} + +void LookBehind::onDisable() +{ + this->enabled = false; + // back to old view + goBack(); +} + +void LookBehind::onEnable() +{ + lbBind_ = this->bind; +} + +void LookBehind::onTick() +{ + if ((GetKeyState(lbBind_) & 0x8000) && !lbKeyPressed) // started being held down + { + lbKeyPressed = true; + if (this->enabled) + lookBehind(); + } + else if (!(GetKeyState(lbBind_) & 0x8000) && lbKeyPressed) + { + lbKeyPressed = false; + if (this->enabled) + goBack(); + } +} diff --git a/LatiteCore/LookBehind.h b/LatiteCore/LookBehind.h new file mode 100644 index 0000000..741e8f3 --- /dev/null +++ b/LatiteCore/LookBehind.h @@ -0,0 +1,16 @@ +#pragma once + +#ifndef LOOKBEHIND_H +#define LOOKBEHIND_H + +class LookBehind { +public: + char bind = 'G'; + bool enabled = false; + void setBind(char b); + void onDisable(); + void onEnable(); + void onTick(); +}; + +#endif diff --git a/LatiteCore/Mods/ModManager.cpp b/LatiteCore/Mods/ModManager.cpp index 211e025..1a210c6 100644 --- a/LatiteCore/Mods/ModManager.cpp +++ b/LatiteCore/Mods/ModManager.cpp @@ -1,24 +1,37 @@ #include "ModManager.h" Zoom zoom; +LookBehind lookBehind; void Mod::disableAll() { zoom.enabled = false; zoom.onDisable(); + lookBehind.enabled = false; + lookBehind.onDisable(); } void Mod::initialize() { - log << "initialize mods\n"; + log << "Initializing mods\n"; + zoom.onEnable(); + lookBehind.onEnable(); + zoom.enabled = true; + lookBehind.enabled = true; } void Mod::tickModules() { zoom.onTick(); + lookBehind.onTick(); } Zoom getZoomModule() { return zoom; } + +LookBehind getLookBehindModule() +{ + return lookBehind; +} diff --git a/LatiteCore/Mods/ModManager.h b/LatiteCore/Mods/ModManager.h index 2d4e160..fc17442 100644 --- a/LatiteCore/Mods/ModManager.h +++ b/LatiteCore/Mods/ModManager.h @@ -7,6 +7,7 @@ #include "../dllmain.h" #include "Zoom.h" +#include "../LookBehind.h" class Mod { // void onEnable(); @@ -18,5 +19,6 @@ class Mod { }; Zoom getZoomModule(); +LookBehind getLookBehindModule(); #endif \ No newline at end of file diff --git a/LatiteCore/Mods/Zoom.cpp b/LatiteCore/Mods/Zoom.cpp index efa391f..b450243 100644 --- a/LatiteCore/Mods/Zoom.cpp +++ b/LatiteCore/Mods/Zoom.cpp @@ -3,25 +3,34 @@ #include "ModManager.h" float pastFOV; +float pastSens; +unsigned char pastHideHand; bool keyPressed = false; float fovAmt = 45; +char bind_ = 'C'; void unzoom() { - log << "pastfov: " << pastFOV << '\n'; LocalPlayer::setFOV(pastFOV); + LocalPlayer::setSensitivity(pastSens); + LocalPlayer::setHideHand(pastHideHand); } void zoom() { + pastSens = LocalPlayer::getSensitivity(); pastFOV = LocalPlayer::getFOV(); - for (float i = pastFOV; i > fovAmt; i -= 10) + pastHideHand = LocalPlayer::getHideHand(); + +/* for (float i = pastFOV; i > fovAmt; i -= 10) { // smoother thing Sleep(10); LocalPlayer::setFOV(i); - } + }*/ LocalPlayer::setFOV(pastFOV - fovAmt); + LocalPlayer::setSensitivity(0.3); + LocalPlayer::setHideHand(1); } void Zoom::setFovAmount(float fov) @@ -33,17 +42,19 @@ void Zoom::setFovAmount(float fov) void Zoom::setBind(char b) { + bind_ = b; this->bind = b; } void Zoom::onDisable() { + this->enabled = false; unzoom(); } void Zoom::onEnable() { - + this->enabled = true; } void Zoom::onTick() @@ -51,12 +62,12 @@ void Zoom::onTick() /* check if they started pressing C (or whatever the key is) */ - if ((GetKeyState(Zoom::bind) & 0x8000) && !keyPressed) // started being held down + if ((GetKeyState(bind_) & 0x8000) && !keyPressed) // started being held down { keyPressed = true; zoom(); } - else if (!(GetKeyState(Zoom::bind) & 0x8000) && keyPressed) + else if (!(GetKeyState(bind_) & 0x8000) && keyPressed) { keyPressed = false; unzoom(); diff --git a/LatiteCore/dllmain.cpp b/LatiteCore/dllmain.cpp index 900542b..14b5183 100644 --- a/LatiteCore/dllmain.cpp +++ b/LatiteCore/dllmain.cpp @@ -17,6 +17,21 @@ DWORD pID; ADDRESS moduleBase; HANDLE hProcess; +std::string readVarString(ADDRESS address, int maxSize = 20) +{ + unsigned int size = 0; + char val; + vector retVal = {}; + for (int i = 0; i < maxSize; i++) + { + val = 0; + ReadProcessMemory(hProcess, (void*)(address + i), &val, 1, 0); + if (val == 0) break; + retVal.push_back(val); + } + return std::string(retVal.begin(), retVal.end()); +} + HANDLE GetProcessByName(WCHAR* processName) { PROCESSENTRY32 pe32; @@ -94,6 +109,68 @@ void mod_zoom_setBind(char bind) getZoomModule().setBind(bind); } +void mod_lookBehind_setBind(char bind) +{ + getLookBehindModule().setBind(bind); +} + +float LPGetMotion() +{ + // TODO get x and z motion + + ADDRESS yAddy = GetMLPtrAddy((void*)(moduleBase + ADDRESS_Y_BASEADDY), + ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + float xVel = 0.f; + float zVel = 0.f; + ADDRESS xVelAddy = yAddy + 56; + ADDRESS zVelAddy = yAddy + 64; + ReadProcessMemory(hProcess, (void*)xVelAddy, &xVel, sizeof(xVel), 0); + ReadProcessMemory(hProcess, (void*)zVelAddy, &zVel, sizeof(zVel), 0); + + return abs(xVel) + abs(zVel); +} + +float LPGetYMotion() +{ + // y position address + ADDRESS yAddy = GetMLPtrAddy((void*)(moduleBase + ADDRESS_Y_BASEADDY), + ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + float yVel = 0.f; + ADDRESS yVelAddy = yAddy + 60; + ReadProcessMemory(hProcess, (void*)yVelAddy, &yVel, sizeof(yVel), 0); + return yVel; +} + +float LPGetYPos() +{ + ADDRESS addy = GetMLPtrAddy((void*)(moduleBase + ADDRESS_Y_BASEADDY), + ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + float pos = 0.f; + ReadProcessMemory(hProcess, (void*)addy, &pos, sizeof(pos), 0); + return pos; +} + + +float LPGetXPos() +{ + ADDRESS addy = GetMLPtrAddy((void*)(moduleBase + ADDRESS_Y_BASEADDY), + ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + addy -= 4; // 1 float value (4 bytes) right before to the y position + float pos = 0.f; + ReadProcessMemory(hProcess, (void*)addy, &pos, sizeof(pos), 0); + return pos; +} + +float LPGetZPos() +{ + ADDRESS addy = GetMLPtrAddy((void*)(moduleBase + ADDRESS_Y_BASEADDY), + ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + addy += 4; // 1 float value (4 bytes) right after to the y position + float pos = 0.f; + ReadProcessMemory(hProcess, (void*)addy, &pos, sizeof(pos), 0); + return pos; +} + void mod_zoom_setAmount(float amount) { getZoomModule().setFovAmount(amount); @@ -153,6 +230,13 @@ DWORD attach() { if (hProcess == 0) return GetLastError(); log << "Module Base: " << (void*)moduleBase << '\n'; if (moduleBase == 0ui64) return GetLastError(); + + ADDRESS yPositionAddy = GetMLPtrAddy((void*)(moduleBase + ADDRESS_Y_BASEADDY), ADDRESS_Y_SEMI_OFFSETS) + ADDRESS_Y_LAST_OFFSET; + ADDRESS nameAddy = yPositionAddy + 996; + // Start up + log << "Name: \"" << readVarString(nameAddy) << "\"\n"; + Mod::initialize(); + return 0; } @@ -160,7 +244,29 @@ void loop() { if (connectedToMinecraft()) { - Mod::tickModules(); + if (GetForegroundWindow() == FindWindowA(NULL, "Minecraft")) + { + Mod::tickModules(); + } + } +} + +void setEnabled(unsigned int modId, bool enabled) +{ + switch (modId) + { + case 1: //zoom + if (!enabled) + getZoomModule().onDisable(); + else + getZoomModule().onEnable(); + break; + case 2: //lookbehind + if (!enabled) + getLookBehindModule().onDisable(); + else + getLookBehindModule().onEnable(); + break; } } diff --git a/LatiteCore/dllmain.h b/LatiteCore/dllmain.h index ffe1946..714ca20 100644 --- a/LatiteCore/dllmain.h +++ b/LatiteCore/dllmain.h @@ -32,9 +32,20 @@ extern "C" LATITE_API void consoleMain(); extern "C" LATITE_API void detach(); extern "C" LATITE_API void loop(); +extern "C" LATITE_API void setEnabled(unsigned int modId, bool enabled); + // this should be namespace if c# is good with that extern "C" LATITE_API void mod_zoom_setBind(char bind); extern "C" LATITE_API void mod_zoom_setAmount(float amount); +extern "C" LATITE_API void mod_lookBehind_setBind(char bind); + +// Local Player +extern "C" LATITE_API float LPGetYMotion(); +extern "C" LATITE_API float LPGetMotion(); + +extern "C" LATITE_API float LPGetXPos(); +extern "C" LATITE_API float LPGetYPos(); +extern "C" LATITE_API float LPGetZPos(); // TODO export local player? //extern "C" LATITE_API struct LocalPlayer; @@ -47,6 +58,22 @@ ADDRESS GetMLPtrAddy(void* addy, vector offsets); #define ADDRESS_FOV_BASEADDY 0x0369BD40 #define ADDRESS_FOV_SEMI_OFFSETS { 0x20, 0xC98, 0x68, 0x08, 0x1A0, 0x120 } +#define ADDRESS_FSENS_BASEADDY 0x0369BD40 +#define ADDRESS_FSENS_SEMI_OFFSETS { 0x20, 0xC00, 0x08, 0x0, 0x0 } +#define ADDRESS_FSENS_LAST_OFFSET 0x314 + +#define ADDRESS_FHH_BASEADDY 0x0369BD40 +#define ADDRESS_FHH_SEMI_OFFSETS { 0x20, 0x9F8, 0x1D8, 0x08, 0xD10 } +#define ADDRESS_FHH_LAST_OFFSET 0x1E0 + +#define ADDRESS_Y_BASEADDY 0x03699238 +#define ADDRESS_Y_SEMI_OFFSETS { 0x10, 0x128, 0x0, 0x138, 0x490, 0xc0 } +#define ADDRESS_Y_LAST_OFFSET 0x49C + +#define ADDRESS_PRESPECTIVE_BASEADDY 0x0369BD40 +#define ADDRESS_PRESPECTIVE_OFFSETS { 0x20, 0xE88, 0x1D8, 0x08, 0x20 } +#define ADDRESS_PRESPECTIVE_LAST_OFFSET 0x1E8 + ADDRESS currentModuleBase(); HANDLE getHProcess();