ToxSylph / SeaOfChoros

Sea Of Thieves Utility
51 stars 41 forks source link

Improving Show Oxygen Percent #13

Open DesErst opened 1 year ago

DesErst commented 1 year ago

when player is in water (IsInWater returns true) we show the oxygen bar and percent, I think it would be better to show these stuff when we lost oxygen : `

        if (cfg->client.oxygen && localPlayerActor->IsInWater())
        {
            error_code = 5;
            auto drownComp = localPlayerActor->DrowningComponent;
            if (drownComp)
            {
                float level = drownComp->GetOxygenLevel();
                if (level < 1) {  // very little change
                    auto posX = io.DisplaySize.x * 0.5f;
                    auto posY = io.DisplaySize.y * 0.85f;
                    auto barWidth = io.DisplaySize.x * 0.05f;
                    auto barHeight = io.DisplaySize.y * 0.0030f;
                    drawList->AddRectFilled({ posX - barWidth, posY - barHeight }, { posX + barWidth, posY + barHeight }, ImGui::GetColorU32(IM_COL32(0, 0, 0, 255)));
                    drawList->AddRectFilled({ posX - barWidth, posY - barHeight }, { posX - barWidth + barWidth * level * 2.f, posY + barHeight }, ImGui::GetColorU32(IM_COL32(0, 200, 255, 255)));
                    char buf[0x64];
                    float pLevel = level * 100.f;
                    sprintf_s(buf, sizeof(buf), "[ %.0f%% ]", pLevel);
                    auto oxColor = level > 0.25f ? ImVec4(0.f, 1.f, 0.f, 1.f) : ImVec4(1.f, 0.f, 0.f, 1.f);
                    RenderText(drawList, buf, FVector2D(posX + (barWidth * 0.5f), posY + barHeight + 10.f), oxColor, 20);
                }
            }
        }`

I know its should be pull request but anyway