Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic version drawing #66

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions cpp/engine.cpp
Expand Up @@ -10,6 +10,7 @@
#include <SDL2/SDL_image.h>

#include "callbacks.h"
#include "config.h"
#include "texture.h"
#include "log.h"
#include "util/color.h"
Expand Down Expand Up @@ -219,6 +220,20 @@ bool Engine::draw_fps() {
return true;
}

// Shamelessly ripped off from draw_fps
bool Engine::draw_version() {
util::col {255, 255, 255, 255}.use();

// Draw version string in the lower left corner
this->dejavuserif20->render(
5, 15,
"openage version %s", config::version
);

return true;
}


void Engine::save_screenshot(const char* filename) {
log::msg("saving screenshot to %s...", filename);

Expand Down Expand Up @@ -322,6 +337,11 @@ void Engine::loop() {

// draw the fps overlay
this->draw_fps();

if (this->drawing_version)
{
this->draw_version();
}

// invoke all hud drawing callback methods
for (auto &action : this->on_drawhud) {
Expand Down
10 changes: 10 additions & 0 deletions cpp/engine.h
Expand Up @@ -116,6 +116,11 @@ class Engine : public ResizeHandler {
* draw the current frames per second number on screen.
*/
bool draw_fps();

/**
* Draw the game version in the lower left corner.
*/
bool draw_version();

/**
* register a new input event handler, run for each input event.
Expand Down Expand Up @@ -175,6 +180,11 @@ class Engine : public ResizeHandler {
* to be set to false to stop the engine loop.
*/
bool running;

/**
* Game version is drawn when this is true.
*/
bool drawing_version = true;

/**
* size of the game window, in coord_sdl.
Expand Down
3 changes: 3 additions & 0 deletions cpp/game_main.cpp
Expand Up @@ -478,6 +478,9 @@ bool GameMain::on_input(SDL_Event *e) {
//stop the game
engine.stop();
break;
case SDLK_F1:
engine.drawing_version = !engine.drawing_version;
break;
case SDLK_LCTRL:
this->ctrl_active = false;
break;
Expand Down