Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
improve recorder, add a bunch of tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnut committed Mar 14, 2024
1 parent c862b7d commit 36fb764
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 28 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"gd": {
"win": "2.204"
},
"version": "v2.8.4",
"version": "v2.8.5",
"id": "maxnu.gd_mega_overlay",
"name": "GD Mega Overlay",
"developers": ["maxnu", "SpaghettDev"],
Expand Down
3 changes: 2 additions & 1 deletion src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ void Common::updateCheating()
bool noShaders = Settings::get<bool>("level/no_shaders", false);
bool instantComplete = Settings::get<bool>("level/instant_complete", false);
bool hitboxMultiplier = Settings::get<bool>("level/hitbox_multiplier", false);
bool layoutMode = Settings::get<bool>("level/layout_mode", false);

if (speedhack != 1.f || Macrobot::playerMode == 0 || (showHitbox && !onDeath) || hidePause || hitboxMultiplier || noShaders || instantComplete)
if (speedhack != 1.f || Macrobot::playerMode == 0 || (showHitbox && !onDeath) || hidePause || hitboxMultiplier || noShaders || instantComplete || layoutMode)
{
isCheating = true;
return;
Expand Down
6 changes: 6 additions & 0 deletions src/GUI/Widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,4 +566,10 @@ void GUI::popItemWidth()
return;

ImGui::PopItemWidth();
}

void GUI::tooltip(const std::string tooltip)
{
if(ImGui::IsItemHovered())
ImGui::SetTooltip(tooltip.c_str());
}
1 change: 1 addition & 0 deletions src/GUI/Widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace GUI
void sameLine(float offset_from_start_x = 0, float spacing_w = -1);
void pushItemWidth(float width);
void popItemWidth();
void tooltip(const std::string);

bool customCheckbox(const char* label, bool* v);
};
4 changes: 2 additions & 2 deletions src/GUI/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void Window::draw()
if(blurEnabled && !blurGD)
Blur::blurWindowBackground();

if(Settings::get<bool>("menu/drop_shadow/enabled", true))
dropShadow(Settings::get<float>("menu/drop_shadow/size", 24.f), 255);
if(Settings::get<bool>("menu/box_shadow/enabled", true))
dropShadow(Settings::get<float>("menu/box_shadow/size", 24.f), 255);

ImGui::SetWindowFontScale(Settings::get<float>("menu/ui_scale", 1.f));

Expand Down
3 changes: 1 addition & 2 deletions src/JsonPatches/JsonPatches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ void JsonPatches::drawFromPatches(JsonPatches::patch_group_type& patchGroup)
if (GUI::checkbox(name, "patch/" + name, false))
togglePatch(patchGroup, name);

if (ImGui::IsItemHovered())
ImGui::SetTooltip(jpatch.description.c_str());
GUI::tooltip(jpatch.description);
}
}
28 changes: 25 additions & 3 deletions src/Macrobot/Macrobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ class $modify(CCKeyboardDispatcher)

if (key == enumKeyCodes::KEY_A || key == enumKeyCodes::KEY_ArrowLeft)
direction = down ? -1 : 0;

if (!down || arr)
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, arr);

int advanceKey = Settings::get<int>("macrobot/frame_step/key", ImGuiKey_G);

int convertedKey = ConvertKeyEnum(key);

if(convertedKey == advanceKey)
holdingAdvance = down;

if (!down || arr)
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, arr);

if (convertedKey == advanceKey && PlayLayer::get())
targetSteps = PlayLayer::get()->m_gameState.m_unk1f8 + Settings::get<int>("macrobot/frame_step/steps", 1);

Expand Down Expand Up @@ -78,6 +81,7 @@ class $modify(PlayLayer)

void resetLevel()
{
holdingAdvance = false;
targetSteps = 0;

if (playerMode != DISABLED)
Expand Down Expand Up @@ -200,8 +204,17 @@ class $modify(GJBaseGameLayer)
{
if (Settings::get<bool>("macrobot/frame_step/enabled", false))
{
if(Settings::get<bool>("macrobot/frame_step/hold", false) && holdingAdvance)
advanceHoldTime += dt;
else
advanceHoldTime = 0;

if (PlayLayer::get()->m_gameState.m_unk1f8 < targetSteps)
GJBaseGameLayer::update(dt);

if(advanceHoldTime > 0.5f)
targetSteps = PlayLayer::get()->m_gameState.m_unk1f8 + 1;

return;
}

Expand Down Expand Up @@ -564,6 +577,9 @@ void Macrobot::drawMacroTable()
Common::calculateFramerate();
PhysicsBypass::calculateTickrate();

layer->stopAllActions();
MBO(float, layer, 10960) = 0;//startgamedelayed
layer->startGame();
layer->resetLevelFromStart();

ImGui::CloseCurrentPopup();
Expand Down Expand Up @@ -625,12 +641,16 @@ void Macrobot::drawWindow()
if (GUI::combo("Corrections", &corrections, correctionType, 2))
Mod::get()->setSavedValue<int>("macrobot/corrections", corrections);

GUI::tooltip("The type of correction the macro will use.\nNone: the bot will not correct on playback.\nEvery action: the bot will correct player's position, velocity and rotation every action.");

GUI::checkbox("Click Sounds", "macrobot/clicks/enabled");
GUI::tooltip("Play click sounds when the bot plays an action.");
GUI::arrowButton("Clickpacks");
Clickpacks::drawGUI();
}

GUI::checkbox("Frame Step", "macrobot/frame_step/enabled");
GUI::tooltip("Makes the game only advance physics steps when the frame step button is pressed.");

GUI::arrowButton("Frame Step Settings");
GUI::modalPopup(
Expand All @@ -641,6 +661,8 @@ void Macrobot::drawWindow()
Mod::get()->setSavedValue<int>("macrobot/frame_step/key", key);

GUI::inputInt("Advance Steps", "macrobot/frame_step/steps", 1);

GUI::checkbox("Hold to Advance", "macrobot/frame_step/hold");
},
ImGuiWindowFlags_AlwaysAutoResize);

Expand Down
3 changes: 3 additions & 0 deletions src/Macrobot/Macrobot.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ namespace Macrobot
inline bool botInput = false;
inline bool resetFrame = false;
inline bool resetFromStart = true;
inline bool holdingAdvance = false;

inline PlayerMode playerMode = DISABLED;

inline unsigned int actionIndex = 0;
inline unsigned int targetSteps = 0;

inline float advanceHoldTime = 0;

inline int8_t direction = 0;

inline Macro macro;
Expand Down
56 changes: 49 additions & 7 deletions src/Macrobot/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ class $modify(PlayLayer)
PlayLayer::onQuit();
}

bool canPauseGame()
{
if(recorder.m_recording || recorder.m_recording_audio)
return false;

return PlayLayer::canPauseGame();
}

bool init(GJGameLevel* level, bool unk1, bool unk2)
{
bool res = PlayLayer::init(level, unk1, unk2);
Expand Down Expand Up @@ -116,10 +124,14 @@ void Recorder::start_audio()
}

levelDone = false;
m_after_end_duration = Settings::get<float>("recorder/after_end", 4.f);
m_after_end_duration = Settings::get<float>("recorder/after_end", 3.4f);
m_after_end_extra_time = 0.f;

recorder.m_recording_audio = true;

PlayLayer::get()->stopAllActions();
MBO(float, PlayLayer::get(), 10960) = 0;//startgamedelayed
PlayLayer::get()->startGame();
PlayLayer::get()->resetLevelFromStart();
recorder.m_recording = false;
}
Expand Down Expand Up @@ -171,7 +183,7 @@ void Recorder::start()
int bitrate = Settings::get<int>("recorder/bitrate", 30);
m_bitrate = std::to_string(bitrate) + "M";

float afterEnd = Settings::get<float>("recorder/after_end", 4.f);
float afterEnd = Settings::get<float>("recorder/after_end", 3.4f);

m_after_end_extra_time = 0.f;
m_after_end_duration = afterEnd; // hacks.afterEndDuration;
Expand All @@ -182,7 +194,10 @@ void Recorder::start()

m_song_start_offset = PlayLayer::get()->m_levelSettings->m_songOffset;

PlayLayer::get()->resetLevel();
PlayLayer::get()->stopAllActions();
MBO(float, PlayLayer::get(), 10960) = 0;//startgamedelayed
PlayLayer::get()->startGame();
PlayLayer::get()->resetLevelFromStart();

std::string level_id = PlayLayer::get()->m_level->m_levelName.c_str() + ("_" + std::to_string(PlayLayer::get()->m_level->m_levelID.value()));
auto bg_volume = 1;
Expand Down Expand Up @@ -404,6 +419,28 @@ void Recorder::handle_recording(GJBaseGameLayer *play_layer, float dt)
{
m_extra_t = time - frame_dt;
m_last_frame_t = tfx;

float time = (static_cast<float>(play_layer->m_gameState.m_unk1f8) / Common::getTPS()) * 1000.f;
time += PlayLayer::get()->m_levelSettings->m_songOffset * 1000.f;

FMOD::Channel* audioChannel;

for(int i = 0; i < 2; i++)
{
FMODAudioEngine::sharedEngine()->m_system->getChannel(126 + i, &audioChannel);
if (audioChannel)
{
uint32_t channelTime = 0;
audioChannel->getPosition(&channelTime, FMOD_TIMEUNIT_MS);

if(channelTime <= 0)
continue;

if(channelTime - time > 0.15f)
audioChannel->setPosition(time, FMOD_TIMEUNIT_MS);
}
}

capture_frame();
}
}
Expand Down Expand Up @@ -456,7 +493,7 @@ void Record::renderWindow()
ImGui::EndDisabled();

disabled = !PlayLayer::get() || levelDone || Record::recorder.m_recording || Record::recorder.m_recording_audio || Macrobot::macro.inputs.size() <= 0 || Macrobot::playerMode != 0;

if (disabled)
ImGui::BeginDisabled();

Expand Down Expand Up @@ -524,7 +561,7 @@ void Record::renderWindow()
if (ImGui::IsItemDeactivatedAfterEdit())
Mod::get()->setSavedValue<int>("recorder/fps", framerate);

float afterEnd = Settings::get<float>("recorder/after_end", 4.f);
float afterEnd = Settings::get<float>("recorder/after_end", 3.4f);
GUI::inputFloat("Show End For", &afterEnd);

if (ImGui::IsItemDeactivatedAfterEdit())
Expand All @@ -537,6 +574,8 @@ void Record::renderWindow()
Mod::get()->setSavedValue<std::string>("recorder/extraArgsAfter", "-pix_fmt rgb0 -qp 16 -rc-lookahead 16 -preset slow");
Mod::get()->setSavedValue<std::string>("recorder/extraArgsVideo", "colorspace=all=bt709:iall=bt470bg:fast=1");
}

GUI::tooltip("Applies a preset for optimal rendering with the CPU");

GUI::sameLine();

Expand All @@ -548,6 +587,8 @@ void Record::renderWindow()
Mod::get()->setSavedValue<std::string>("recorder/extraArgsVideo", "colorspace=all=bt709:iall=bt470bg:fast=1");
}

GUI::tooltip("Applies a preset for optimal rendering with NVIDIA GPUs");

GUI::sameLine();

if (GUI::button("AMD"))
Expand All @@ -558,11 +599,12 @@ void Record::renderWindow()
Mod::get()->setSavedValue<std::string>("recorder/extraArgsVideo", "colorspace=all=bt709:iall=bt470bg:fast=1");
}

GUI::tooltip("Applies a preset for optimal rendering with AMD GPUs");

if(GUI::button("Advanced Settings"))
ImGui::OpenPopup("Advanced Settings##popup");

if(ImGui::IsItemHovered())
ImGui::SetTooltip("It is reccomended to use presets and not change these settings unless you know what you're doing!");
GUI::tooltip("It is reccomended to use presets and not change these settings unless you know what you're doing!");

GUI::modalPopup("Advanced Settings##popup", []{
std::string codec = Settings::get<std::string>("recorder/codec", "");
Expand Down
Loading

0 comments on commit 36fb764

Please sign in to comment.