Client builds & runs, can't test the gameplay without the server

SDL_ttf is now being initialized, and all usages of fonts are now checked for nullptr.
A bug where the renderer's logical size was not properly set has been fixed.
The FPS counter is disabled for now.
This commit is contained in:
2015-08-20 20:45:13 +10:00
parent dc5b09a9b4
commit 3d6509b5a5
15 changed files with 100 additions and 22 deletions
+19 -2
View File
@@ -23,6 +23,9 @@
#include "config_utility.hpp"
#include <sstream>
#include <stdexcept>
//-------------------------
//Public access members
//-------------------------
@@ -34,6 +37,13 @@ MainMenu::MainMenu() {
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
if (!font) {
std::ostringstream msg;
msg << "Failed to load a font file; " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
//setup the buttons
startButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
startButton.SetText(GetRenderer(), font, "Start", {255, 255, 255, 255});
@@ -53,7 +63,7 @@ MainMenu::MainMenu() {
//text box
textBox.PushLine(GetRenderer(), font, "Thanks for playing!", {255, 255, 255, 255});
textBox.PushLine(GetRenderer(), font, "You can get the latest version at: ", {255, 255, 255, 255});
textBox.PushLine(GetRenderer(), font, "krgamestudios.com", {255, 255, 255, 255});
textBox.PushLine(GetRenderer(), font, "krgamestudios.com", {255, 255, 255, 255}); //TODO: click to open the website/update
//debug
//
@@ -84,7 +94,10 @@ void MainMenu::RenderFrame(SDL_Renderer* renderer) {
optionsButton.DrawTo(renderer);
quitButton.DrawTo(renderer);
textBox.DrawTo(renderer, 50, 50, 12);
int h = -1;
SDL_RenderGetLogicalSize(GetRenderer(), nullptr, &h);
textBox.DrawTo(renderer, 50, h-50, -12);
}
//-------------------------
@@ -116,6 +129,10 @@ void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& event) {
}
}
void MainMenu::MouseWheel(SDL_MouseWheelEvent const& event) {
//
}
void MainMenu::KeyDown(SDL_KeyboardEvent const& event) {
//
}