Messing with buttons & fonts
This commit is contained in:
@@ -68,61 +68,37 @@ void ClientApplication::Init(int argc, char* argv[]) {
|
|||||||
std::cout << "Initialized the window" << std::endl;
|
std::cout << "Initialized the window" << std::endl;
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//DEBUG: detecting platforms & versions
|
//DEBUG: detecting platforms, versions & appropriate fonts
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
SDL_SysWMinfo windowInfo;
|
SDL_SysWMinfo windowInfo;
|
||||||
SDL_VERSION(&windowInfo.version);
|
SDL_VERSION(&windowInfo.version);
|
||||||
if (SDL_GetWindowWMInfo(window, &windowInfo)) {
|
if (SDL_GetWindowWMInfo(window, &windowInfo)) {
|
||||||
//NOTE: Raw copy/paste from the SDL wiki
|
//
|
||||||
// success
|
std::string platform;
|
||||||
std::string subsystem;
|
std::string fontPath;
|
||||||
switch(windowInfo.subsystem) {
|
|
||||||
case SDL_SYSWM_UNKNOWN:
|
|
||||||
subsystem = "an unknown system!";
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
//get the info
|
||||||
|
switch(windowInfo.subsystem) {
|
||||||
case SDL_SYSWM_WINDOWS:
|
case SDL_SYSWM_WINDOWS:
|
||||||
subsystem = "Microsoft Windows(TM)";
|
//TODO: ensure that this works
|
||||||
|
platform = "Microsoft Windows";
|
||||||
|
fontPath = "C:/Windows/Fonts/arialuni.ttf";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SYSWM_X11:
|
case SDL_SYSWM_X11:
|
||||||
subsystem = "X Window System";
|
platform = "X Window System";
|
||||||
break;
|
fontPath = "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf";
|
||||||
|
|
||||||
case SDL_SYSWM_DIRECTFB:
|
|
||||||
subsystem = "DirectFB";
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//NOTE: OS X is currently unsupported, but it could be
|
||||||
case SDL_SYSWM_COCOA:
|
case SDL_SYSWM_COCOA:
|
||||||
subsystem = "Apple OS X";
|
platform = "Apple OS X";
|
||||||
|
fontPath = "/System/Library/Fonts/arialuni.ttf";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SYSWM_UIKIT:
|
default:
|
||||||
subsystem = "UIKit";
|
platform = "an unsupported platform";
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//final output
|
//final output
|
||||||
@@ -130,10 +106,17 @@ void ClientApplication::Init(int argc, char* argv[]) {
|
|||||||
std::cout << (int)windowInfo.version.major << ".";
|
std::cout << (int)windowInfo.version.major << ".";
|
||||||
std::cout << (int)windowInfo.version.minor << ".";
|
std::cout << (int)windowInfo.version.minor << ".";
|
||||||
std::cout << (int)windowInfo.version.patch << " on ";
|
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 {
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
accountIndex(*argAccountIndex)
|
accountIndex(*argAccountIndex)
|
||||||
{
|
{
|
||||||
//setup the utility objects
|
//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);
|
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
||||||
|
|
||||||
//check that the font loaded
|
//check that the font loaded
|
||||||
@@ -52,9 +52,9 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
|
|
||||||
//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", COLOR_BLUE);
|
||||||
shutdownButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
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
|
//set the button positions
|
||||||
disconnectButton.SetX(50);
|
disconnectButton.SetX(50);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ DisconnectedScreen::DisconnectedScreen() {
|
|||||||
|
|
||||||
//setup the utility objects
|
//setup the utility objects
|
||||||
//TODO: (1) resource tool, to prevent reloading like this
|
//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);
|
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
||||||
|
|
||||||
//check that the font loaded
|
//check that the font loaded
|
||||||
@@ -49,7 +49,7 @@ DisconnectedScreen::DisconnectedScreen() {
|
|||||||
|
|
||||||
//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", COLOR_BLUE);
|
||||||
|
|
||||||
//set the button positions
|
//set the button positions
|
||||||
backButton.SetX(50);
|
backButton.SetX(50);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
accountIndex = -1;
|
accountIndex = -1;
|
||||||
|
|
||||||
//setup the utility objects
|
//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);
|
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
||||||
|
|
||||||
//check that the font loaded
|
//check that the font loaded
|
||||||
@@ -51,11 +51,11 @@ LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
|
|
||||||
//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", COLOR_BLUE);
|
||||||
joinButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
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.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)
|
//set the button positions (assumed)
|
||||||
searchButton.SetX(50);
|
searchButton.SetX(50);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ MainMenu::MainMenu() {
|
|||||||
ConfigUtility& config = ConfigUtility::GetSingleton();
|
ConfigUtility& config = ConfigUtility::GetSingleton();
|
||||||
|
|
||||||
//setup the utility objects
|
//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);
|
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
||||||
|
|
||||||
//check that the font loaded
|
//check that the font loaded
|
||||||
@@ -46,11 +46,11 @@ MainMenu::MainMenu() {
|
|||||||
|
|
||||||
//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", COLOR_BLUE);
|
||||||
optionsButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
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.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
||||||
quitButton.SetText(GetRenderer(), font, "Quit", {255, 255, 255, 255});
|
quitButton.SetText(GetRenderer(), font, "Quit", COLOR_BLUE);
|
||||||
|
|
||||||
//set the button positions
|
//set the button positions
|
||||||
startButton.SetX(50);
|
startButton.SetX(50);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ OptionsMenu::OptionsMenu() {
|
|||||||
ConfigUtility& config = ConfigUtility::GetSingleton();
|
ConfigUtility& config = ConfigUtility::GetSingleton();
|
||||||
|
|
||||||
//setup the utility objects
|
//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);
|
font = TTF_OpenFont(config["client.font"].c_str(), 12);
|
||||||
|
|
||||||
//check that the font loaded
|
//check that the font loaded
|
||||||
@@ -46,7 +46,7 @@ OptionsMenu::OptionsMenu() {
|
|||||||
|
|
||||||
//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", COLOR_BLUE);
|
||||||
|
|
||||||
//set the button positions
|
//set the button positions
|
||||||
backButton.SetX(50);
|
backButton.SetX(50);
|
||||||
|
|||||||
+1
-1
Submodule common updated: 93a955caf9...540f646209
+2
-2
@@ -12,8 +12,8 @@ server.dbname = database.db
|
|||||||
#client.screen.h = 600
|
#client.screen.h = 600
|
||||||
client.screen.f = false
|
client.screen.f = false
|
||||||
|
|
||||||
#TODO: change this based on platform?
|
#set this to overwrite the default fonts (platform issues)
|
||||||
client.font = /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
|
#client.font = /path/to/font/file.ttf
|
||||||
|
|
||||||
client.username = username
|
client.username = username
|
||||||
client.handle = handle
|
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 |
@@ -132,6 +132,8 @@ void ServerApplication::Init(int argc, char* argv[]) {
|
|||||||
//debug output
|
//debug output
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
|
#define DEBUG_INTERNAL_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl;
|
||||||
|
|
||||||
std::cout << "Internal sizes:" << std::endl;
|
std::cout << "Internal sizes:" << std::endl;
|
||||||
|
|
||||||
DEBUG_INTERNAL_VAR(NETWORK_VERSION);
|
DEBUG_INTERNAL_VAR(NETWORK_VERSION);
|
||||||
|
|||||||
Reference in New Issue
Block a user