diff --git a/client/menu_scenes/disconnected_screen.cpp b/client/menu_scenes/disconnected_screen.cpp index 4bf368b..90d2a2b 100644 --- a/client/menu_scenes/disconnected_screen.cpp +++ b/client/menu_scenes/disconnected_screen.cpp @@ -23,6 +23,7 @@ #include "channels.hpp" #include "config_utility.hpp" +#include "text_util.hpp" #include "udp_network_utility.hpp" #include @@ -35,20 +36,17 @@ DisconnectedScreen::DisconnectedScreen() { ConfigUtility& config = ConfigUtility::GetSingleton(); //setup the utility objects - image.LoadSurface(config["dir.interface"] + "button_menu.bmp"); - image.SetClipH(image.GetClipH()/3); - font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp"); + //TODO: (1) resource tool, to prevent reloading like this + image.Load(GetRenderer(), config["dir.interface"] + "button.png"); + font = TTF_OpenFont(config["client.font"].c_str(), 12); - //pass the utility objects - backButton.SetImage(&image); - backButton.SetFont(&font); + //setup the button + backButton.SetBackgroundTexture(GetRenderer(), image.GetTexture()); + backButton.SetText(GetRenderer(), font, "Back", COLOR_WHITE); //set the button positions backButton.SetX(50); - backButton.SetY(50 + image.GetClipH() * 0); - - //set the button texts - backButton.SetText("Back"); + backButton.SetY(50); //full reset UDPNetworkUtility::GetSingleton().Unbind(Channels::SERVER); @@ -71,7 +69,7 @@ void DisconnectedScreen::FrameStart() { void DisconnectedScreen::Update() { if (std::chrono::steady_clock::now() - startTick > std::chrono::duration(10)) { - SetNextScene(SceneList::MAINMENU); + SetSceneSignal(SceneSignal::MAINMENU); } //Eat incoming packets @@ -86,7 +84,13 @@ void DisconnectedScreen::RenderFrame(SDL_Renderer* renderer) { ConfigUtility& config = ConfigUtility::GetSingleton(); backButton.DrawTo(renderer); - font.DrawStringTo(config["client.disconnectMessage"], screen, 50, 30); + //render output message + SDL_Texture* tex = renderPlainText(renderer, font, config["client.disconnectMessage"], COLOR_WHITE); + int w = 0, h = 0; + SDL_QueryTexture(tex, nullptr, nullptr, &w, &h); + SDL_Rect d = {50, 30, w, h}; + SDL_RenderCopy(renderer, tex, nullptr, &d); + SDL_DestroyTexture(tex); } //------------------------- diff --git a/client/menu_scenes/disconnected_screen.hpp b/client/menu_scenes/disconnected_screen.hpp index b4c2047..a82444b 100644 --- a/client/menu_scenes/disconnected_screen.hpp +++ b/client/menu_scenes/disconnected_screen.hpp @@ -21,14 +21,11 @@ */ #pragma once -//graphics -#include "image.hpp" -#include "button.hpp" - -//client #include "base_scene.hpp" +#include "button.hpp" +#include "image.hpp" +#include "SDL2/SDL_ttf.h" -//std namespace #include class DisconnectedScreen : public BaseScene { @@ -55,6 +52,7 @@ protected: //graphics Image image; + TTF_Font* font = nullptr; Button backButton; //auto return diff --git a/client/menu_scenes/makefile b/client/menu_scenes/makefile index e006dc4..f03de53 100644 --- a/client/menu_scenes/makefile +++ b/client/menu_scenes/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. .. ../../common/graphics ../../common/map ../../common/network ../../common/network/packet_types ../../common/ui ../../common/utilities +INCLUDES+=. .. ../client_utilities ../../common/graphics ../../common/map ../../common/network ../../common/network/packet_types ../../common/ui ../../common/utilities LIBS+= CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) diff --git a/rsc/config.cfg b/rsc/config.cfg index a081695..cf72bdc 100644 --- a/rsc/config.cfg +++ b/rsc/config.cfg @@ -12,12 +12,14 @@ 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 + client.username = username client.handle = handle client.avatar = elliot2.bmp #directories -dir.fonts = rsc/graphics/fonts/ dir.logos = rsc/graphics/logos/ dir.sprites = rsc/graphics/sprites/ dir.tilesets = rsc/graphics/tilesets/ diff --git a/rsc/graphics/fonts/pk_dark_16.bmp b/rsc/graphics/fonts/pk_dark_16.bmp deleted file mode 100644 index 97b23e0..0000000 Binary files a/rsc/graphics/fonts/pk_dark_16.bmp and /dev/null differ diff --git a/rsc/graphics/fonts/pk_dark_8.bmp b/rsc/graphics/fonts/pk_dark_8.bmp deleted file mode 100644 index 2293a14..0000000 Binary files a/rsc/graphics/fonts/pk_dark_8.bmp and /dev/null differ diff --git a/rsc/graphics/fonts/pk_white_8.bmp b/rsc/graphics/fonts/pk_white_8.bmp deleted file mode 100644 index edf2bd8..0000000 Binary files a/rsc/graphics/fonts/pk_white_8.bmp and /dev/null differ diff --git a/rsc/graphics/interface/button.png b/rsc/graphics/interface/button.png new file mode 100644 index 0000000..867cd63 Binary files /dev/null and b/rsc/graphics/interface/button.png differ diff --git a/rsc/graphics/interface/button_menu.bmp b/rsc/graphics/interface/button_menu.bmp deleted file mode 100644 index b2dcb2a..0000000 Binary files a/rsc/graphics/interface/button_menu.bmp and /dev/null differ