Re-enabled FPS display, fix other display issues

This commit is contained in:
2015-08-23 01:53:13 +10:00
parent 915660da0e
commit 41d601ab06
5 changed files with 13 additions and 9 deletions
+2
View File
@@ -33,6 +33,7 @@
#include "image.hpp"
#include "button.hpp"
#include "tile_sheet.hpp"
#include "text_line.hpp"
//common
#include "frame_rate.hpp"
@@ -146,6 +147,7 @@ private:
Button disconnectButton;
Button shutdownButton;
FrameRate fps;
TextLine fpsTextLine;
//the camera structure
struct {
+7 -5
View File
@@ -185,13 +185,15 @@ void World::RenderFrame(SDL_Renderer* renderer) {
//draw UI
disconnectButton.DrawTo(renderer);
shutdownButton.DrawTo(renderer);
std::ostringstream msg;
//TODO: FPS
// msg << fps.GetFrameRate();
// font.DrawStringTo(msg.str(), screen, 0, 0);
//FPS
fps.Calculate();
fpsTextLine.DrawTo(renderer, 0, 0);
int fpsRet = fps.Calculate();
if (fpsRet != -1) {
std::ostringstream msg;
msg << "FPS: " << fpsRet;
fpsTextLine.SetText(renderer, font, msg.str(), {255, 255, 255, 255});
}
}
//-------------------------
+1 -1
View File
@@ -92,7 +92,7 @@ void DisconnectedScreen::FrameEnd() {
void DisconnectedScreen::RenderFrame(SDL_Renderer* renderer) {
backButton.DrawTo(renderer);
textLine.DrawTo(renderer, 50, 50);
textLine.DrawTo(renderer, 50, 30);
}
//-------------------------
+2 -2
View File
@@ -121,7 +121,7 @@ void LobbyMenu::RenderFrame(SDL_Renderer* renderer) {
//draw the server's info
serverVector[i].nameImage.DrawTo(renderer, boundingBox.x, boundingBox.y + boundingBox.h * i);
serverVector[i].playerCountImage.DrawTo(renderer, boundingBox.x, boundingBox.y + boundingBox.h * i);
serverVector[i].playerCountImage.DrawTo(renderer, boundingBox.x+300, boundingBox.y + boundingBox.h * i);
}
}
@@ -242,7 +242,7 @@ void LobbyMenu::HandleBroadcastResponse(ServerPacket* const argPacket) {
//fancy itoa
auto itoa_base10 = [](int i) -> std::string {
char str[20];
printf(str, "%d", i);
sprintf(str, "%d", i);
return std::string(str);
};