Skip to content

Commit

Permalink
Use only one global flag for FPS counter
Browse files Browse the repository at this point in the history
  • Loading branch information
carstene1ns committed Oct 7, 2015
1 parent a1d4fd5 commit b00c1ce
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_easyrpg_player_player_EasyRpgPlayerActivity_toggleFps
(JNIEnv *, jclass)
{
Graphics::show_fps = !Graphics::show_fps;
Player::fps_flag = !Player::fps_flag;
}

JNIEXPORT void JNICALL Java_org_easyrpg_player_player_EasyRpgPlayerActivity_endGame
Expand Down
7 changes: 2 additions & 5 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "player.h"

namespace Graphics {
bool show_fps;

void UpdateTitle();
void DrawFrame();
void DrawOverlay();
Expand Down Expand Up @@ -75,7 +73,6 @@ unsigned SecondToFrame(float const second) {
}

void Graphics::Init() {
show_fps = Player::fps_flag;
fps = 0;
frozen_screen = BitmapRef();
screen_erased = false;
Expand Down Expand Up @@ -150,7 +147,7 @@ void Graphics::UpdateTitle() {
std::stringstream title;
title << Player::game_title;

if (show_fps) {
if (Player::fps_flag) {
title << " - FPS " << real_fps;
}

Expand Down Expand Up @@ -204,7 +201,7 @@ void Graphics::DrawFrame() {
}

void Graphics::DrawOverlay() {
if (DisplayUi->IsFullscreen() && Graphics::show_fps) {
if (DisplayUi->IsFullscreen() && Player::fps_flag) {
std::stringstream text;
text << "FPS: " << real_fps;
DisplayUi->GetDisplaySurface()->TextDraw(2, 2, Color(255, 255, 255, 255), text.str());
Expand Down
2 changes: 0 additions & 2 deletions src/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ namespace Graphics {

void UpdateZCallback();

extern bool show_fps;

void Push();
void Pop();

Expand Down
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void Player::Update(bool update_scene) {

// Normal logic update
if (Input::IsTriggered(Input::TOGGLE_FPS)) {
Graphics::show_fps = !Graphics::show_fps;
fps_flag = !fps_flag;
}
if (Input::IsTriggered(Input::TAKE_SCREENSHOT)) {
Output::TakeScreenshot();
Expand Down

0 comments on commit b00c1ce

Please sign in to comment.