Exemple #1
0
        public Num.Vector2 DrawCircleProgress(float radius, float thickness, int num_segments, float percent, Colour colr)
        {
            Num.Vector2 pos = ImGui.GetCursorPos();
            pos.X += ImGui.GetWindowPos().X + radius + thickness;
            pos.Y += ImGui.GetWindowPos().Y + radius + thickness;
            ImGui.GetWindowDrawList().PathClear();
            float a_min = 0;
            float a_max = (float)Math.PI * 2.0f * ((float)num_segments - (100 - percent)) / (float)num_segments;

            ImGui.GetWindowDrawList().PathArcTo(pos, radius, a_min, a_max, num_segments);
            ImGui.GetWindowDrawList().PathStroke(ImGui.GetColorU32(colr.RGBA()), false, thickness);
            return(pos);
        }
Exemple #2
0
        private void DrawWindow()
        {
            if (_check)
            {
                var tempCastBar = _getUi2ObjByName(Marshal.ReadIntPtr(_getBaseUiObj(), 0x20), "_CastBar", 1);
                if (tempCastBar != IntPtr.Zero)
                {
                    _wait = 1000;
                    if (_config)
                    {
                        ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver);
                        ImGui.Begin("SlideCast Config", ref _config);
                        ImGui.InputInt("Time (cs)", ref _slideTime);
                        ImGui.TextWrapped("The time for slidecasting is 50cs (half a second) by default.\n" +
                                          "Lower numbers make it later in the cast, higher numbers earlier in the cast.\n" +
                                          "Apart from missed packets, 50cs is the exact safe time to slidecast.");
                        ImGui.ColorEdit4("Bar Colour", ref _slideCol, ImGuiColorEditFlags.NoInputs);
                        ImGui.Checkbox("Enable Debug Mode", ref _debug);
                        ImGui.Separator();
                        if (ImGui.Button("Save and Close Config"))
                        {
                            SaveConfig();
                            _config = false;
                        }
                        ImGui.SameLine();
                        ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF);
                        ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF);
                        ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF);

                        if (ImGui.Button("Buy Haplo a Hot Chocolate"))
                        {
                            System.Diagnostics.Process.Start("https://ko-fi.com/haplo");
                        }
                        ImGui.PopStyleColor(3);
                        ImGui.End();
                    }

                    if (_enabled)
                    {
                        if (_castBar != tempCastBar)
                        {
                            _castBar = IntPtr.Zero;
                        }

                        if (_castBar != IntPtr.Zero)
                        {
                            _cbCastLast = _cbCastPer;
                            _cbX        = Marshal.ReadInt16(_castBar + 0x1BC);
                            _cbY        = Marshal.ReadInt16(_castBar + 0x1BE);
                            _cbScale    = Marshal.PtrToStructure <float>(_castBar + 0x1AC);
                            _cbCastTime = Marshal.ReadInt16(_castBar + 0x2BC);
                            _cbCastPer  = Marshal.PtrToStructure <float>(_castBar + 0x2C0);
                            var plus = 0;
                            _cbSpell = new List <byte>();

                            while (Marshal.ReadByte(_castBar + 0x242 + plus) != 0)
                            {
                                _cbSpell.Add(Marshal.ReadByte(_castBar + 0x242 + plus));
                                plus++;
                            }

                            if (_cbCastLast == _cbCastPer)
                            {
                                if (_cbCastSameCount < 5)
                                {
                                    _cbCastSameCount++;
                                }
                            }
                            else
                            {
                                _cbCastSameCount = 0;
                            }

                            if (_cbCastPer == 5)
                            {
                                _colS = new Colour(_col1S.R / 255f, _col1S.G / 255f, _col1S.B / 255f);
                            }

                            if (Marshal.ReadByte(_castBar + 0x182).ToString() != "84")
                            {
                                ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(_cbX, _cbY));
                                ImGui.Begin("SlideCast", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);
                                ImGui.SetWindowSize(new Num.Vector2(220 * _cbScale, 60 * _cbScale));
                                //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime);
                                float slidePer = ((float)_cbCastTime - (float)_slideTime) / (float)_cbCastTime;
                                ImGui.GetWindowDrawList().AddRectFilled(
                                    new Num.Vector2(
                                        ImGui.GetWindowPos().X + (48 * _cbScale) + (152 * slidePer * _cbScale),
                                        ImGui.GetWindowPos().Y + (20 * _cbScale)),
                                    new Num.Vector2(
                                        ImGui.GetWindowPos().X + (48 * _cbScale) + 5 + (152 * slidePer * _cbScale),
                                        ImGui.GetWindowPos().Y + (29 * _cbScale)),
                                    ImGui.GetColorU32(_slideCol));
                                ImGui.End();
                            }
                        }
                        else
                        {
                            _castBar = tempCastBar;
                        }

                        if (_debug)
                        {
                            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Num.Vector2(_cbX, _cbY));
                            ImGui.Begin("SlideCast DEBUG", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar);
                            ImGui.SetWindowSize(new Num.Vector2(220 * _cbScale, 60 * _cbScale));
                            //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime);
                            var slidePer = ((float)_cbCastTime - (float)_slideTime) / (float)_cbCastTime;
                            ImGui.GetWindowDrawList().AddRectFilled(
                                new Num.Vector2(
                                    ImGui.GetWindowPos().X + (48 * _cbScale) + (152 * slidePer * _cbScale),
                                    ImGui.GetWindowPos().Y + (20 * _cbScale)),
                                new Num.Vector2(
                                    ImGui.GetWindowPos().X + (48 * _cbScale) + 5 + (152 * slidePer * _cbScale),
                                    ImGui.GetWindowPos().Y + (29 * _cbScale)),
                                ImGui.GetColorU32(_slideCol));
                            ImGui.End();

                            ImGui.Begin("Slidecast Debug Values");
                            ImGui.Text("cbX: " + _cbX);
                            ImGui.Text("cbY: " + _cbY);
                            ImGui.Text("cbS: " + _cbScale);
                            ImGui.Text("cbCastTime: " + _cbCastTime);
                            ImGui.Text("cbCastPer: " + _cbCastPer);
                            ImGui.Text("Mem Addr: " + _castBar.ToString("X"));
                            ImGui.Text(_colS.Hue.ToString());
                            ImGui.Text(_colS.Saturation.ToString());
                            ImGui.Text(_colS.Brightness.ToString());
                            ImGui.End();
                        }
                    }
                }
                else
                {
                    _check = false;
                }
            }

            if (_wait > 0)
            {
                _wait--;
            }
            else
            {
                _check = true;
            }
        }
Exemple #3
0
        private void DrawWindow()
        {
            if (check)
            {
                IntPtr baseUi = getBaseUIObj();
                if (baseUi == IntPtr.Zero)
                {
                    return;
                }
                IntPtr baseUiProperties = Marshal.ReadIntPtr(baseUi, 0x20);
                if (baseUiProperties == IntPtr.Zero)
                {
                    return;
                }
                IntPtr tempCastBar = getUI2ObjByName(baseUiProperties, "_CastBar", 1);
                if (tempCastBar != IntPtr.Zero)
                {
                    wait = 1000;
                    if (config)
                    {
                        ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver);
                        ImGui.Begin("SlideCast Config", ref config);
                        ImGui.Checkbox("Enable", ref enabled);
                        ImGui.InputInt("Time (cs)", ref slideTime);
                        ImGui.TextWrapped("The time for slidecasting is 50cs (half a second) by default.\n" +
                                          "Lower numbers make it later in the cast, higher numbers earlier in the cast.\n" +
                                          "Apart from missed packets, 50cs is the exact safe time to slidecast.");
                        ImGui.ColorEdit4("Bar Colour", ref slideCol, ImGuiColorEditFlags.NoInputs);
                        ImGui.Checkbox("Enable Debug Mode", ref debug);
                        ImGui.Separator();

                        /*
                         * ImGui.ColorEdit4("Start", ref colp1_s);
                         * ImGui.ColorEdit4("End", ref colp2_s);
                         * if (ImGui.Button("Set"))
                         * {
                         *  col1_s = new Colour(colp1_s.X, colp1_s.Y, colp1_s.Z, colp1_s.W);
                         *  col2_s = new Colour(colp2_s.X, colp2_s.Y, colp2_s.Z, colp2_s.W);
                         *
                         *  diffH_s = col2_s.Hue - col1_s.Hue;
                         *  diffS_s = col2_s.Saturation - col1_s.Saturation;
                         *  diffB_s = col2_s.Brightness - col1_s.Brightness;
                         * }
                         */

                        if (ImGui.Button("Save and Close Config"))
                        {
                            SaveConfig();
                            config = false;
                        }
                        ImGui.End();
                    }

                    if (enabled)
                    {
                        if (castBar != tempCastBar)
                        {
                            castBar = IntPtr.Zero;
                        }

                        if (castBar != IntPtr.Zero)
                        {
                            cbCastLast = cbCastPer;
                            cbX        = Marshal.ReadInt16(castBar + 0x1BC);
                            cbY        = Marshal.ReadInt16(castBar + 0x1BE);
                            cbScale    = Marshal.PtrToStructure <float>(castBar + 0x1AC);
                            cbCastTime = Marshal.ReadInt16(castBar + 0x2BC);
                            cbCastPer  = Marshal.PtrToStructure <float>(castBar + 0x2C0);
                            int plus = 0;
                            cbSpell = new List <byte>();

                            while (Marshal.ReadByte(castBar + 0x242 + plus) != 0)
                            {
                                cbSpell.Add(Marshal.ReadByte(castBar + 0x242 + plus));
                                plus++;
                            }
                            cbSpellname = "";
                            foreach (byte bit in cbSpell)
                            {
                                cbSpellname += (char)bit;
                            }


                            if (cbCastLast == cbCastPer)
                            {
                                if (cbCastSameCount < 5)
                                {
                                    cbCastSameCount++;
                                }
                            }
                            else
                            {
                                cbCastSameCount = 0;
                            }

                            if (cbCastPer == 5)
                            {
                                col_s = new Colour(col1_s.R / 255f, col1_s.G / 255f, col1_s.B / 255f);
                            }



                            if (Marshal.ReadByte(castBar + 0x182).ToString() != "84")
                            {
                                ImGui.Begin("SlideCast", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);
                                ImGui.SetWindowPos(new Num.Vector2(cbX, cbY));
                                ImGui.SetWindowSize(new Num.Vector2(220 * cbScale, 60 * cbScale));
                                //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime);
                                float slidePer = ((float)cbCastTime - (float)slideTime) / (float)cbCastTime;
                                ImGui.GetWindowDrawList().AddRectFilled(
                                    new Num.Vector2(ImGui.GetWindowPos().X + (48 * cbScale) + (152 * slidePer * cbScale), ImGui.GetWindowPos().Y + (20 * cbScale)),
                                    new Num.Vector2(ImGui.GetWindowPos().X + (48 * cbScale) + 5 + (152 * slidePer * cbScale), ImGui.GetWindowPos().Y + (29 * cbScale)),
                                    ImGui.GetColorU32(slideCol));
                                ImGui.End();
                            }

                            if (uiCastBar)
                            {
                                if (cbCastTime == 0)
                                {
                                    cbCastTime++;
                                }
                                if (cbCastSameCount < 5)
                                {
                                    double castTimeSec = ((double)cbCastTime / 100) - ((double)cbCastTime / 100) * (cbCastPer / 100);
                                    ImGui.Begin("uiCastBar_Self", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);

                                    col_s.setHSB(col1_s.Hue + (int)(diffH_s * (cbCastPer / 100)), col1_s.Saturation + (int)(diffS_s * (cbCastPer / 100)), col1_s.Brightness + (int)(diffB_s * (cbCastPer / 100)));

                                    Num.Vector2 centre = DrawCircleProgress(40f, 10f, 100, cbCastPer, col_s);

                                    ImGui.GetWindowDrawList().AddCircleFilled(
                                        new Num.Vector2(centre.X, centre.Y),
                                        35f,
                                        ImGui.GetColorU32(new Num.Vector4(0.2f, 0.2f, 0.2f, 0.2f)),
                                        100);
                                    ImGui.GetWindowDrawList().AddCircle(
                                        new Num.Vector2(centre.X, centre.Y),
                                        45f,
                                        ImGui.GetColorU32(new Num.Vector4(0.4f, 0.4f, 0.4f, 0.4f)),
                                        100);
                                    ImGui.GetWindowDrawList().AddCircleFilled(
                                        new Num.Vector2(centre.X, centre.Y),
                                        35f,
                                        ImGui.GetColorU32(new Num.Vector4(0.4f, 0.4f, 0.4f, 0.4f)),
                                        100);

                                    ImGui.SetCursorPos(new Num.Vector2(
                                                           centre.X - ImGui.GetWindowPos().X - (ImGui.CalcTextSize(cbSpellname).X) / 2,
                                                           centre.Y - 15f - ImGui.GetWindowPos().Y));
                                    ShadowFont(cbSpellname);

                                    ImGui.SetCursorPos(new Num.Vector2(
                                                           centre.X - ImGui.GetWindowPos().X - (ImGui.CalcTextSize(String.Format("{0:0.00}", castTimeSec)).X) / 2,
                                                           centre.Y - ImGui.GetWindowPos().Y));
                                    ShadowFont(String.Format("{0:0.00}", castTimeSec));

                                    ImGui.SetCursorPos(new Num.Vector2(
                                                           centre.X - ImGui.GetWindowPos().X - (ImGui.CalcTextSize(cbCastPer.ToString() + "%").X) / 2,
                                                           centre.Y + 15f - ImGui.GetWindowPos().Y));
                                    ShadowFont(cbCastPer.ToString() + "%%");

                                    ImGui.End();
                                }

                                if (pluginInterface.ClientState.LocalPlayer != null)
                                {
                                    if (pluginInterface.ClientState.LocalPlayer.TargetActorID != 0)
                                    {
                                        Dalamud.Game.ClientState.Actors.ActorTable actorTable = pluginInterface.ClientState.Actors;



                                        for (var k = 0; k < this.pluginInterface.ClientState.Actors.Length; k++)
                                        {
                                            var actor = this.pluginInterface.ClientState.Actors[k];

                                            if (actor == null)
                                            {
                                                continue;
                                            }

                                            if (pluginInterface.ClientState.LocalPlayer.TargetActorID == actor.ActorId)
                                            {
                                                float targetSpellCast = Marshal.PtrToStructure <float>(actor.Address + 0x1C74);
                                                float targetSpellTime = Marshal.PtrToStructure <float>(actor.Address + 0x1C78);
                                                float targetSpellPer  = 100 * (1 - ((targetSpellTime - targetSpellCast) / targetSpellTime));

                                                ImGui.Begin("uiCastBar_Target", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);
                                                ImGui.Text(targetSpellCast.ToString());
                                                ImGui.Text(targetSpellTime.ToString());
                                                ImGui.Text(targetSpellPer.ToString());
                                                Num.Vector2 centreT = DrawCircleProgress(40f, 10f, 100, targetSpellPer, col_s);


                                                ImGui.GetWindowDrawList().AddCircleFilled(
                                                    new Num.Vector2(centreT.X, centreT.Y),
                                                    35f,
                                                    ImGui.GetColorU32(new Num.Vector4(0.2f, 0.2f, 0.2f, 0.2f)),
                                                    100);
                                                ImGui.GetWindowDrawList().AddCircle(
                                                    new Num.Vector2(centreT.X, centreT.Y),
                                                    45f,
                                                    ImGui.GetColorU32(new Num.Vector4(0.4f, 0.4f, 0.4f, 0.4f)),
                                                    100);
                                                ImGui.GetWindowDrawList().AddCircleFilled(
                                                    new Num.Vector2(centreT.X, centreT.Y),
                                                    35f,
                                                    ImGui.GetColorU32(new Num.Vector4(0.4f, 0.4f, 0.4f, 0.4f)),
                                                    100);
                                                if (Marshal.ReadInt16(actor.Address + 0x1C44) != 0)
                                                {
                                                    //var actionRow = actionSheet.GetRow(Marshal.ReadInt16(actor.Address + 0x1C44));
                                                    //ImGui.Text(actionRow.Name);
                                                    ImGui.Text("THINGY");
                                                }
                                                ImGui.End();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            castBar = tempCastBar;
                        }

                        if (debug)
                        {
                            ImGui.Begin("SlideCast DEBUG", ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar);
                            ImGui.SetWindowPos(new Num.Vector2(cbX, cbY));
                            ImGui.SetWindowSize(new Num.Vector2(220 * cbScale, 60 * cbScale));
                            //float time = (float)cbCastTime - (0.01f * cbCastPer * (float)cbCastTime);
                            float slidePer = ((float)cbCastTime - (float)slideTime) / (float)cbCastTime;
                            ImGui.GetWindowDrawList().AddRectFilled(
                                new Num.Vector2(ImGui.GetWindowPos().X + (48 * cbScale) + (152 * slidePer * cbScale), ImGui.GetWindowPos().Y + (20 * cbScale)),
                                new Num.Vector2(ImGui.GetWindowPos().X + (48 * cbScale) + 5 + (152 * slidePer * cbScale), ImGui.GetWindowPos().Y + (29 * cbScale)),
                                ImGui.GetColorU32(slideCol));
                            ImGui.End();

                            ImGui.Begin("Slidecast Debug Values");
                            ImGui.Text("cbX: " + cbX.ToString());
                            ImGui.Text("cbY: " + cbY.ToString());
                            ImGui.Text("cbS: " + cbScale.ToString());
                            ImGui.Text("cbCastTime: " + cbCastTime.ToString());
                            ImGui.Text("cbCastPer: " + cbCastPer.ToString());
                            ImGui.Text("Mem Addr: " + castBar.ToString("X"));
                            ImGui.Text("Spell: " + cbSpellname);
                            ImGui.Text(col_s.Hue.ToString());
                            ImGui.Text(col_s.Saturation.ToString());
                            ImGui.Text(col_s.Brightness.ToString());
                            ImGui.End();
                        }
                    }
                }
                else
                {
                    check = false;
                }
            }

            if (wait > 0)
            {
                wait--;
            }
            else
            {
                check = true;
            }
        }