Messing with buttons & fonts

This commit is contained in:
2015-08-23 04:55:50 +10:00
parent caf6403a76
commit 57a4fc8380
11 changed files with 45 additions and 60 deletions
+25 -42
View File
@@ -68,61 +68,37 @@ void ClientApplication::Init(int argc, char* argv[]) {
std::cout << "Initialized the window" << std::endl;
//-------------------------
//DEBUG: detecting platforms & versions
//DEBUG: detecting platforms, versions & appropriate fonts
//-------------------------
SDL_SysWMinfo windowInfo;
SDL_VERSION(&windowInfo.version);
if (SDL_GetWindowWMInfo(window, &windowInfo)) {
//NOTE: Raw copy/paste from the SDL wiki
// success
std::string subsystem;
switch(windowInfo.subsystem) {
case SDL_SYSWM_UNKNOWN:
subsystem = "an unknown system!";
break;
//
std::string platform;
std::string fontPath;
//get the info
switch(windowInfo.subsystem) {
case SDL_SYSWM_WINDOWS:
subsystem = "Microsoft Windows(TM)";
//TODO: ensure that this works
platform = "Microsoft Windows";
fontPath = "C:/Windows/Fonts/arialuni.ttf";
break;
case SDL_SYSWM_X11:
subsystem = "X Window System";
break;
case SDL_SYSWM_DIRECTFB:
subsystem = "DirectFB";
platform = "X Window System";
fontPath = "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf";
break;
//NOTE: OS X is currently unsupported, but it could be
case SDL_SYSWM_COCOA:
subsystem = "Apple OS X";
platform = "Apple OS X";
fontPath = "/System/Library/Fonts/arialuni.ttf";
break;
case SDL_SYSWM_UIKIT:
subsystem = "UIKit";
break;
#if SDL_VERSION_ATLEAST(2, 0, 2)
case SDL_SYSWM_WAYLAND:
subsystem = "Wayland";
break;
case SDL_SYSWM_MIR:
subsystem = "Mir";
break;
#endif
#if SDL_VERSION_ATLEAST(2, 0, 3)
case SDL_SYSWM_WINRT:
subsystem = "WinRT";
break;
#endif
#if SDL_VERSION_ATLEAST(2, 0, 4)
case SDL_SYSWM_ANDROID:
subsystem = "Android";
break;
#endif
default:
platform = "an unsupported platform";
}
//final output
@@ -130,10 +106,17 @@ void ClientApplication::Init(int argc, char* argv[]) {
std::cout << (int)windowInfo.version.major << ".";
std::cout << (int)windowInfo.version.minor << ".";
std::cout << (int)windowInfo.version.patch << " on ";
std::cout << subsystem << std::endl;
std::cout << platform << std::endl;
//handle the default font paths
if (config["client.font"].size() == 0) {
config["client.font"] = fontPath;
}
}
else {
std::cerr << "(Non-Fatal) Failed to retrieve window info: " << SDL_GetError() << std::endl;
std::ostringstream msg;
msg << "Failed to retrieve window info: " << SDL_GetError();
throw(msg.str());
}
//-------------------------
+3 -3
View File
@@ -40,7 +40,7 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
accountIndex(*argAccountIndex)
{
//setup the utility objects
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button_red.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
@@ -52,9 +52,9 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
//setup the buttons
disconnectButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
disconnectButton.SetText(GetRenderer(), font, "Disconnect", {255, 255, 255, 255});
disconnectButton.SetText(GetRenderer(), font, "Disconnect", COLOR_BLUE);
shutdownButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
shutdownButton.SetText(GetRenderer(), font, "Shutdown", {255, 255, 255, 255});
shutdownButton.SetText(GetRenderer(), font, "Shutdown", COLOR_BLUE);
//set the button positions
disconnectButton.SetX(50);
+2 -2
View File
@@ -37,7 +37,7 @@ DisconnectedScreen::DisconnectedScreen() {
//setup the utility objects
//TODO: (1) resource tool, to prevent reloading like this
image.Load(GetRenderer(), config["dir.interface"] + "button.png");
image.Load(GetRenderer(), config["dir.interface"] + "button_red.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
@@ -49,7 +49,7 @@ DisconnectedScreen::DisconnectedScreen() {
//setup the button
backButton.SetBackgroundTexture(GetRenderer(), image.GetTexture());
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
backButton.SetText(GetRenderer(), font, "Back", COLOR_BLUE);
//set the button positions
backButton.SetX(50);
+4 -4
View File
@@ -39,7 +39,7 @@ LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex):
accountIndex = -1;
//setup the utility objects
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button_red.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
@@ -51,11 +51,11 @@ LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex):
//setup the buttons
searchButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
searchButton.SetText(GetRenderer(), font, "Search", {255, 255, 255, 255});
searchButton.SetText(GetRenderer(), font, "Search", COLOR_BLUE);
joinButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
joinButton.SetText(GetRenderer(), font, "Join", {255, 255, 255, 255});
joinButton.SetText(GetRenderer(), font, "Join", COLOR_BLUE);
backButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
backButton.SetText(GetRenderer(), font, "Back", COLOR_BLUE);
//set the button positions (assumed)
searchButton.SetX(50);
+4 -4
View File
@@ -34,7 +34,7 @@ MainMenu::MainMenu() {
ConfigUtility& config = ConfigUtility::GetSingleton();
//setup the utility objects
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button_red.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
@@ -46,11 +46,11 @@ MainMenu::MainMenu() {
//setup the buttons
startButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
startButton.SetText(GetRenderer(), font, "Start", {255, 255, 255, 255});
startButton.SetText(GetRenderer(), font, "Start", COLOR_BLUE);
optionsButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
optionsButton.SetText(GetRenderer(), font, "Options", {255, 255, 255, 255});
optionsButton.SetText(GetRenderer(), font, "Options", COLOR_BLUE);
quitButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
quitButton.SetText(GetRenderer(), font, "Quit", {255, 255, 255, 255});
quitButton.SetText(GetRenderer(), font, "Quit", COLOR_BLUE);
//set the button positions
startButton.SetX(50);
+2 -2
View File
@@ -34,7 +34,7 @@ OptionsMenu::OptionsMenu() {
ConfigUtility& config = ConfigUtility::GetSingleton();
//setup the utility objects
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button_red.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
@@ -46,7 +46,7 @@ OptionsMenu::OptionsMenu() {
//setup the button
backButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
backButton.SetText(GetRenderer(), font, "Back", {255, 255, 255, 255});
backButton.SetText(GetRenderer(), font, "Back", COLOR_BLUE);
//set the button positions
backButton.SetX(50);
+1 -1
Submodule common updated: 93a955caf9...540f646209
+2 -2
View File
@@ -12,8 +12,8 @@ server.dbname = database.db
#client.screen.h = 600
client.screen.f = false
#TODO: change this based on platform?
client.font = /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
#set this to overwrite the default fonts (platform issues)
#client.font = /path/to/font/file.ttf
client.username = username
client.handle = handle

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

+2
View File
@@ -132,6 +132,8 @@ void ServerApplication::Init(int argc, char* argv[]) {
//debug output
//-------------------------
#define DEBUG_INTERNAL_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl;
std::cout << "Internal sizes:" << std::endl;
DEBUG_INTERNAL_VAR(NETWORK_VERSION);