ICT290 / src / scene / theArchanist / gui / gameOver.cpp
gameOver.cpp
Raw
#include "gameOver.h"
#include "../../../engine/UI.h"
#include "../../../glIncludes.h"

bool ARCH_GAME_OVER::mainMenu{false};

void ARCH_GAME_OVER::drawGameOver(float time,
                                  int level,
                                  int maxLevels,
                                  int difficulty,
                                  int enemiesKilled,
                                  bool victory,
                                  int seed) {
    UI::startUIFrame();

    int h, w;
    SDL_GetWindowSize(SDL_GL_GetCurrentWindow(), &w, &h);

    ImGui::SetNextWindowPos(ImVec2{(float)w / 2, (float)h / 2},
                            0,
                            ImVec2{0.5f, 0.5f});

    ImGui::Begin("victory", nullptr, FRAME::windowSettings());

    if (victory) {
        FRAME::victory();
    } else {
        FRAME::defeat();
    }

    ImGui::Text("Seed: %i\nTime: %.2f \nLevel: %i/%i",
                seed,
                time,
                level,
                maxLevels);

    if (difficulty == 0) {
        ImGui::Text("Difficulty: Easy");
    } else if (difficulty == 1) {
        ImGui::Text("Difficulty: Normal");
    } else {
        ImGui::Text("Difficulty: Hard");
    }

    ImGui::Text("Enemies killed: %i\n", enemiesKilled);

    if (ImGui::Button("Main Menu")) {
        mainMenu = true;
    }

    ImGui::End();

    UI::stopUIFrame();
}

void ARCH_GAME_OVER::FRAME::victory() {
    ImGui::Text(
        "Well done Archanist!\n\nYou have slain the keeper and banished the "
        "bolton grimore to the\nburning depths from which it came...\n\n"
        "The world may rest for now, but it is only a\nmatter of time until "
        "you "
        "will be needed again Archanist, so take rest\n"
        "and relish in your victory, for tomorrow there\nmay well be more "
        "scourge to destroy and evil to banish!\n\n");
}

void ARCH_GAME_OVER::FRAME::defeat() {
    ImGui::Text(
        "And thus the Archanist was no more...\n\nHis mere essence spilt on "
        "the ground...\n\n"
        "The only remnants of a once great hero...\n\nBut fear not, for no "
        "hero "
        "lives forever, take peace in the inspiration\nyour story will bring "
        "and those who will banish the keeper in your place...\n\n"
        "Rest easy Archanist...\n\n");
}

int ARCH_GAME_OVER::FRAME::windowSettings() {
    return ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar
           | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize
           | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove;
}