Skip to content

Commit

Permalink
enabled optimization
Browse files Browse the repository at this point in the history
no longer able to use level chooser on main menu
no longer able to enter invalid levels
  • Loading branch information
saturnaliam committed Jun 1, 2024
1 parent 975169d commit fc04964
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
files := src/main.cpp src/tiq.cpp src/utils.cpp src/gui.cpp $(wildcard src/imgui/*.cpp)
external := -ld3d9 -ld3dcompiler
CXXFLAGS = -Wall -Wextra -pedantic -std=c++20 -ggdb -O0
CXXFLAGS = -Wall -Wextra -pedantic -std=c++20 -ggdb -O2

tiq:
clang++ -o bin/tiq-level-chooser.exe $(files) $(external) $(CXXFLAGS)
19 changes: 14 additions & 5 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,32 @@ std::unique_ptr<TIQ> gui::Render(std::unique_ptr<TIQ> tiq) noexcept {
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);

static unsigned int level = 1;
static unsigned int current_level;
static bool level_chosen = false;
static unsigned int intended_level = 1;
constexpr unsigned int level_min = 1;
constexpr unsigned int level_max = 100;

ImGui::Text("Created by Lucia C (saturnalia)");

if (tiq->get_current_level() == 0) ImGui::BeginDisabled();

ImGui::DragScalar("Level", ImGuiDataType_U16, &level, 1, &level_min, &level_max);
bool clicked = ImGui::Button("Hook");
bool clicked = ImGui::Button("Go to level");
bool unhook = ImGui::Button("Unhook");
ImGui::SetItemTooltip("If your game freezes, locks up, or\notherwise seems to be acting\nweird, press this button.");
if (tiq->get_current_level() == 0) ImGui::EndDisabled();

if (clicked) {
intended_level = level;
if (clicked && level <= 100 && level >= 1) {
current_level = tiq->get_current_level();
level_chosen = true;
tiq->enable_hook(tiq->map_to_scene(level));
}

if (tiq->get_current_level() == tiq->map_to_scene(intended_level) && level_chosen) {
if (unhook) {
tiq->disable_hook();
}

if (tiq->get_current_level() != current_level && level_chosen) {
tiq->disable_hook();
level_chosen = false;
}
Expand Down

0 comments on commit fc04964

Please sign in to comment.