From 57a4fc83802d1654907d716f8d9e3ea4886fe4e5 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 23 Aug 2015 04:55:50 +1000 Subject: [PATCH] Messing with buttons & fonts --- client/client_application.cpp | 67 +++++++----------- client/gameplay_scenes/world_logic.cpp | 6 +- client/menu_scenes/disconnected_screen.cpp | 4 +- client/menu_scenes/lobby_menu.cpp | 8 +-- client/menu_scenes/main_menu.cpp | 8 +-- client/menu_scenes/options_menu.cpp | 4 +- common | 2 +- rsc/config.cfg | 4 +- .../interface/{button.png => button_blue.png} | Bin rsc/graphics/interface/button_red.png | Bin 0 -> 323 bytes server/server_logic.cpp | 2 + 11 files changed, 45 insertions(+), 60 deletions(-) rename rsc/graphics/interface/{button.png => button_blue.png} (100%) create mode 100644 rsc/graphics/interface/button_red.png diff --git a/client/client_application.cpp b/client/client_application.cpp index 1dbfa85..9819436 100644 --- a/client/client_application.cpp +++ b/client/client_application.cpp @@ -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()); } //------------------------- diff --git a/client/gameplay_scenes/world_logic.cpp b/client/gameplay_scenes/world_logic.cpp index 62b88e2..b09597f 100644 --- a/client/gameplay_scenes/world_logic.cpp +++ b/client/gameplay_scenes/world_logic.cpp @@ -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); diff --git a/client/menu_scenes/disconnected_screen.cpp b/client/menu_scenes/disconnected_screen.cpp index 36e8c51..1e447ac 100644 --- a/client/menu_scenes/disconnected_screen.cpp +++ b/client/menu_scenes/disconnected_screen.cpp @@ -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); diff --git a/client/menu_scenes/lobby_menu.cpp b/client/menu_scenes/lobby_menu.cpp index bdff03a..8481e2f 100644 --- a/client/menu_scenes/lobby_menu.cpp +++ b/client/menu_scenes/lobby_menu.cpp @@ -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); diff --git a/client/menu_scenes/main_menu.cpp b/client/menu_scenes/main_menu.cpp index 11b5f5d..ef153e8 100644 --- a/client/menu_scenes/main_menu.cpp +++ b/client/menu_scenes/main_menu.cpp @@ -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); diff --git a/client/menu_scenes/options_menu.cpp b/client/menu_scenes/options_menu.cpp index 499ea1e..dc30b15 100644 --- a/client/menu_scenes/options_menu.cpp +++ b/client/menu_scenes/options_menu.cpp @@ -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); diff --git a/common b/common index 93a955c..540f646 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 93a955caf97d62369f9f94ab4a4894b0b2ece308 +Subproject commit 540f646209f579ab1941b221ceeb44fab9d4322a diff --git a/rsc/config.cfg b/rsc/config.cfg index c43320d..2f9e46c 100644 --- a/rsc/config.cfg +++ b/rsc/config.cfg @@ -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 diff --git a/rsc/graphics/interface/button.png b/rsc/graphics/interface/button_blue.png similarity index 100% rename from rsc/graphics/interface/button.png rename to rsc/graphics/interface/button_blue.png diff --git a/rsc/graphics/interface/button_red.png b/rsc/graphics/interface/button_red.png new file mode 100644 index 0000000000000000000000000000000000000000..e708957041bb04f708130911f237bbd29a6744b1 GIT binary patch literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^DL`z)!3HEJ*vp>-Qfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#K8Ki)in)zvNj^~Mf~SjPNX4zUw+?b13J`G#tnc91 z_TZ2LOUw<2RUF$A1j7>Y%^o=M+-TRRsh-g)VX?hsC(q&L@O#UXV;|&axHxcd%;eAA zdw$d&gv>I1p1A^)78&qol`;+0Ig