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:
@@ -44,11 +44,16 @@ void ClientApplication::Init(int argc, char* argv[]) {
|
|||||||
//create and check the window
|
//create and check the window
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
|
//get the config values
|
||||||
int w = config.Int("client.screen.w");
|
int w = config.Int("client.screen.w");
|
||||||
int h = config.Int("client.screen.h");
|
int h = config.Int("client.screen.h");
|
||||||
int f = config.Bool("client.screen.f") ? SDL_WINDOW_FULLSCREEN : 0;
|
int f = config.Bool("client.screen.f") ? SDL_WINDOW_FULLSCREEN : 0;
|
||||||
|
|
||||||
window = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w ? w : 800, h ? h : 600, f);
|
//default sizes
|
||||||
|
w = w ? w : 800;
|
||||||
|
h = h ? h : 600;
|
||||||
|
|
||||||
|
window = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, f);
|
||||||
|
|
||||||
if (!window) {
|
if (!window) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
@@ -86,12 +91,21 @@ void ClientApplication::Init(int argc, char* argv[]) {
|
|||||||
//initialize SDL_net
|
//initialize SDL_net
|
||||||
if (SDLNet_Init()) {
|
if (SDLNet_Init()) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Failed to initialize SDL_net: " << SDL_GetError();
|
msg << "Failed to initialize SDL_net 2.0: " << SDL_GetError();
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
UDPNetworkUtility::GetSingleton().Open(0);
|
UDPNetworkUtility::GetSingleton().Open(0);
|
||||||
|
|
||||||
std::cout << "Initialized SDL_net" << std::endl;
|
std::cout << "Initialized SDL_net 2.0" << std::endl;
|
||||||
|
|
||||||
|
//setting up SDL2_ttf
|
||||||
|
if (TTF_Init()) {
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << "Failed to initialize SDL_ttf 2.0: " << SDL_GetError();
|
||||||
|
throw(std::runtime_error(msg.str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Initialized SDL_ttf 2.0" << std::endl;
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//debug output
|
//debug output
|
||||||
@@ -181,6 +195,7 @@ void ClientApplication::Quit() {
|
|||||||
//clean up after the program
|
//clean up after the program
|
||||||
std::cout << "Shutting down" << std::endl;
|
std::cout << "Shutting down" << std::endl;
|
||||||
UDPNetworkUtility::GetSingleton().Close();
|
UDPNetworkUtility::GetSingleton().Close();
|
||||||
|
TTF_Quit();
|
||||||
SDLNet_Quit();
|
SDLNet_Quit();
|
||||||
BaseScene::SetRenderer(nullptr);
|
BaseScene::SetRenderer(nullptr);
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include "udp_network_utility.hpp"
|
#include "udp_network_utility.hpp"
|
||||||
|
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
|
#include "SDL2/SDL_net.h"
|
||||||
|
#include "SDL2/SDL_ttf.h"
|
||||||
|
|
||||||
class ClientApplication: public Singleton<ClientApplication> {
|
class ClientApplication: public Singleton<ClientApplication> {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
|||||||
#source
|
#source
|
||||||
CXXSRC=$(wildcard *.cpp)
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
#DEBUG: Overwrite the wildcard
|
|
||||||
CXXSRC=world_logic.cpp
|
|
||||||
|
|
||||||
#objects
|
#objects
|
||||||
OBJDIR=obj
|
OBJDIR=obj
|
||||||
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
@@ -19,7 +16,7 @@ OUT=$(addprefix $(OUTDIR)/,client.a)
|
|||||||
|
|
||||||
#targets
|
#targets
|
||||||
all: $(OBJ) $(OUT)
|
all: $(OBJ) $(OUT)
|
||||||
# ar -crs $(OUT) $(OBJ)
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
$(OBJ): | $(OBJDIR)
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
|
|||||||
|
|
||||||
//fill the character's info
|
//fill the character's info
|
||||||
character->SetHandle(argPacket->handle);
|
character->SetHandle(argPacket->handle);
|
||||||
character->SetAvatar(argPacket->avatar);
|
character->SetAvatar(GetRenderer(), argPacket->avatar);
|
||||||
character->SetOwner(argPacket->accountIndex);
|
character->SetOwner(argPacket->accountIndex);
|
||||||
character->SetOrigin(argPacket->origin);
|
character->SetOrigin(argPacket->origin);
|
||||||
character->SetMotion(argPacket->motion);
|
character->SetMotion(argPacket->motion);
|
||||||
@@ -82,8 +82,8 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
|
|||||||
localCharacter = static_cast<LocalCharacter*>(character);
|
localCharacter = static_cast<LocalCharacter*>(character);
|
||||||
|
|
||||||
//focus the camera on this character's sprite
|
//focus the camera on this character's sprite
|
||||||
camera.marginX = (camera.width / 2 - localCharacter->GetSprite()->GetImage()->GetClipW() / 2);
|
camera.marginX = (camera.width / 2 - localCharacter->GetSprite()->GetClipW() / 2);
|
||||||
camera.marginY = (camera.height/ 2 - localCharacter->GetSprite()->GetImage()->GetClipH() / 2);
|
camera.marginY = (camera.height/ 2 - localCharacter->GetSprite()->GetClipH() / 2);
|
||||||
|
|
||||||
//focus on this character's info
|
//focus on this character's info
|
||||||
characterIndex = argPacket->characterIndex;
|
characterIndex = argPacket->characterIndex;
|
||||||
@@ -135,6 +135,7 @@ void World::hCharacterDelete(CharacterPacket* const argPacket) {
|
|||||||
|
|
||||||
void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
||||||
//prevent a double message about this player's character
|
//prevent a double message about this player's character
|
||||||
|
//TODO: why is this commented out?
|
||||||
// if (argPacket->accountIndex == accountIndex) {
|
// if (argPacket->accountIndex == accountIndex) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
@@ -152,7 +153,7 @@ void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
|||||||
character->SetMotion(argPacket->motion);
|
character->SetMotion(argPacket->motion);
|
||||||
character->SetBounds({CHARACTER_BOUNDS_X, CHARACTER_BOUNDS_Y, CHARACTER_BOUNDS_WIDTH, CHARACTER_BOUNDS_HEIGHT});
|
character->SetBounds({CHARACTER_BOUNDS_X, CHARACTER_BOUNDS_Y, CHARACTER_BOUNDS_WIDTH, CHARACTER_BOUNDS_HEIGHT});
|
||||||
character->SetHandle(argPacket->handle);
|
character->SetHandle(argPacket->handle);
|
||||||
character->SetAvatar(argPacket->avatar);
|
character->SetAvatar(GetRenderer(), argPacket->avatar);
|
||||||
character->SetOwner(argPacket->accountIndex);
|
character->SetOwner(argPacket->accountIndex);
|
||||||
character->CorrectSprite();
|
character->CorrectSprite();
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void World::CheckHeartBeat() {
|
|||||||
if (attemptedBeats > 2) {
|
if (attemptedBeats > 2) {
|
||||||
//escape to the disconnect screen
|
//escape to the disconnect screen
|
||||||
SendDisconnectRequest();
|
SendDisconnectRequest();
|
||||||
SetNextScene(SceneList::DISCONNECTEDSCREEN);
|
SetSceneSignal(SceneSignal::DISCONNECTEDSCREEN);
|
||||||
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "Error: Lost connection to the server";
|
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "Error: Lost connection to the server";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -122,13 +122,13 @@ void World::hLogoutResponse(ClientPacket* const argPacket) {
|
|||||||
|
|
||||||
void World::hDisconnectResponse(ClientPacket* const argPacket) {
|
void World::hDisconnectResponse(ClientPacket* const argPacket) {
|
||||||
hLogoutResponse(argPacket);//shortcut
|
hLogoutResponse(argPacket);//shortcut
|
||||||
SetNextScene(SceneList::DISCONNECTEDSCREEN);
|
SetSceneSignal(SceneSignal::DISCONNECTEDSCREEN);
|
||||||
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have successfully logged out";
|
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have successfully logged out";
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::hAdminDisconnectForced(ClientPacket* const argPacket) {
|
void World::hAdminDisconnectForced(ClientPacket* const argPacket) {
|
||||||
hDisconnectResponse(argPacket);//shortcut
|
hDisconnectResponse(argPacket);//shortcut
|
||||||
SetNextScene(SceneList::DISCONNECTEDSCREEN);
|
SetSceneSignal(SceneSignal::DISCONNECTEDSCREEN);
|
||||||
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have been forcibly disconnected by the server";
|
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have been forcibly disconnected by the server";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
||||||
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
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
|
//setup the buttons
|
||||||
disconnectButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
disconnectButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
||||||
disconnectButton.SetText(GetRenderer(), font, "Disconnect", {255, 255, 255, 255});
|
disconnectButton.SetText(GetRenderer(), font, "Disconnect", {255, 255, 255, 255});
|
||||||
@@ -216,6 +223,10 @@ void World::MouseButtonUp(SDL_MouseButtonEvent const& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::MouseWheel(SDL_MouseWheelEvent const& event) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
void World::KeyDown(SDL_KeyboardEvent const& key) {
|
void World::KeyDown(SDL_KeyboardEvent const& key) {
|
||||||
//hotkeys
|
//hotkeys
|
||||||
switch(key.keysym.sym) {
|
switch(key.keysym.sym) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void World::UpdateMap() {
|
|||||||
}
|
}
|
||||||
else if (regionChecksum(region) == 0) {
|
else if (regionChecksum(region) == 0) {
|
||||||
//checksum failed
|
//checksum failed
|
||||||
//NOTE: this patches bug #45, but does not resolve it
|
//BUG: #45 Regions occasionally lose their tile data; this patches the issue, but does not resolve it
|
||||||
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
||||||
//remove the erroneous region
|
//remove the erroneous region
|
||||||
return region == &ref;
|
return region == &ref;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void World::hMonsterCreate(MonsterPacket* const argPacket) {
|
|||||||
|
|
||||||
//fill the monster's info
|
//fill the monster's info
|
||||||
monster->SetHandle(argPacket->handle);
|
monster->SetHandle(argPacket->handle);
|
||||||
monster->SetAvatar(argPacket->avatar);
|
monster->SetAvatar(GetRenderer(), argPacket->avatar);
|
||||||
monster->SetBounds(argPacket->bounds);
|
monster->SetBounds(argPacket->bounds);
|
||||||
monster->SetOrigin(argPacket->origin);
|
monster->SetOrigin(argPacket->origin);
|
||||||
monster->SetMotion(argPacket->motion);
|
monster->SetMotion(argPacket->motion);
|
||||||
@@ -89,7 +89,7 @@ void World::hQueryMonsterExists(MonsterPacket* const argPacket) {
|
|||||||
|
|
||||||
//fill the monster's info
|
//fill the monster's info
|
||||||
monster->SetHandle(argPacket->handle);
|
monster->SetHandle(argPacket->handle);
|
||||||
monster->SetAvatar(argPacket->avatar);
|
monster->SetAvatar(GetRenderer(), argPacket->avatar);
|
||||||
monster->SetBounds(argPacket->bounds);
|
monster->SetBounds(argPacket->bounds);
|
||||||
monster->SetOrigin(argPacket->origin);
|
monster->SetOrigin(argPacket->origin);
|
||||||
monster->SetMotion(argPacket->motion);
|
monster->SetMotion(argPacket->motion);
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ all: $(OBJ) $(OUT)
|
|||||||
$(MAKE) -C entities
|
$(MAKE) -C entities
|
||||||
$(MAKE) -C gameplay_scenes
|
$(MAKE) -C gameplay_scenes
|
||||||
$(MAKE) -C menu_scenes
|
$(MAKE) -C menu_scenes
|
||||||
# $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
||||||
|
|
||||||
$(OBJ): | $(OBJDIR)
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "config_utility.hpp"
|
#include "config_utility.hpp"
|
||||||
#include "udp_network_utility.hpp"
|
#include "udp_network_utility.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -39,6 +40,13 @@ DisconnectedScreen::DisconnectedScreen() {
|
|||||||
image.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
image.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
||||||
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
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 button
|
//setup the button
|
||||||
backButton.SetBackgroundTexture(GetRenderer(), image.GetTexture());
|
backButton.SetBackgroundTexture(GetRenderer(), image.GetTexture());
|
||||||
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
|
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
|
||||||
@@ -105,6 +113,10 @@ void DisconnectedScreen::MouseButtonUp(SDL_MouseButtonEvent const& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisconnectedScreen::MouseWheel(SDL_MouseWheelEvent const& event) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
void DisconnectedScreen::KeyDown(SDL_KeyboardEvent const& event) {
|
void DisconnectedScreen::KeyDown(SDL_KeyboardEvent const& event) {
|
||||||
switch(event.keysym.sym) {
|
switch(event.keysym.sym) {
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
||||||
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
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
|
//setup the buttons
|
||||||
searchButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
searchButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
||||||
searchButton.SetText(GetRenderer(), font, "Search", {255, 255, 255, 255});
|
searchButton.SetText(GetRenderer(), font, "Search", {255, 255, 255, 255});
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include "config_utility.hpp"
|
#include "config_utility.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//Public access members
|
//Public access members
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -34,6 +37,13 @@ MainMenu::MainMenu() {
|
|||||||
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
||||||
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
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
|
//setup the buttons
|
||||||
startButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
startButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
||||||
startButton.SetText(GetRenderer(), font, "Start", {255, 255, 255, 255});
|
startButton.SetText(GetRenderer(), font, "Start", {255, 255, 255, 255});
|
||||||
@@ -53,7 +63,7 @@ MainMenu::MainMenu() {
|
|||||||
//text box
|
//text box
|
||||||
textBox.PushLine(GetRenderer(), font, "Thanks for playing!", {255, 255, 255, 255});
|
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, "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
|
//debug
|
||||||
//
|
//
|
||||||
@@ -84,7 +94,10 @@ void MainMenu::RenderFrame(SDL_Renderer* renderer) {
|
|||||||
optionsButton.DrawTo(renderer);
|
optionsButton.DrawTo(renderer);
|
||||||
quitButton.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) {
|
void MainMenu::KeyDown(SDL_KeyboardEvent const& event) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include "config_utility.hpp"
|
#include "config_utility.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//Public access members
|
//Public access members
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -34,6 +37,13 @@ OptionsMenu::OptionsMenu() {
|
|||||||
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
|
||||||
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
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 button
|
//setup the button
|
||||||
backButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
backButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
||||||
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
|
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
|
||||||
@@ -89,6 +99,10 @@ void OptionsMenu::MouseButtonUp(SDL_MouseButtonEvent const& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsMenu::MouseWheel(SDL_MouseWheelEvent const& event) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsMenu::KeyDown(SDL_KeyboardEvent const& event) {
|
void OptionsMenu::KeyDown(SDL_KeyboardEvent const& event) {
|
||||||
switch(event.keysym.sym) {
|
switch(event.keysym.sym) {
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
SplashScreen::SplashScreen() {
|
SplashScreen::SplashScreen() {
|
||||||
|
//TODO: I need a logo that isn't partially invisible
|
||||||
logo.Load(GetRenderer(), ConfigUtility::GetSingleton()["dir.logos"] + "krstudios.png");
|
logo.Load(GetRenderer(), ConfigUtility::GetSingleton()["dir.logos"] + "krstudios.png");
|
||||||
startTick = std::chrono::steady_clock::now();
|
startTick = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
@@ -49,5 +50,6 @@ void SplashScreen::FrameStart() {
|
|||||||
void SplashScreen::RenderFrame(SDL_Renderer* renderer) {
|
void SplashScreen::RenderFrame(SDL_Renderer* renderer) {
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
SDL_RenderGetLogicalSize(renderer, &w, &h);
|
SDL_RenderGetLogicalSize(renderer, &w, &h);
|
||||||
logo.DrawTo(renderer, (w - logo.GetClipW()) / 2, (h - logo.GetClipH()) / 2);
|
//TODO: fix logo position
|
||||||
|
logo.DrawTo(renderer, (w - logo.GetClipW() / 4) / 2, (h - logo.GetClipH() / 4) / 2, .25, .25);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule common updated: 345980af5e...03e643a17a
Reference in New Issue
Block a user