# HG changeset patch # User David Demelier # Date 1513169211 -3600 # Node ID 43a26de57fe7a80e41fcbbbbe9063c2421c4b418 # Parent 16f27d6543bf9f924a5aa85d06586fca2bfaf3d1 Client: remove splashscreen state diff -r 16f27d6543bf -r 43a26de57fe7 client/CMakeLists.txt --- a/client/CMakeLists.txt Wed Dec 13 13:45:00 2017 +0100 +++ b/client/CMakeLists.txt Wed Dec 13 13:46:51 2017 +0100 @@ -23,14 +23,8 @@ ${mlk-client_SOURCE_DIR}/main.cpp ) -set( - ASSETS - ${mlk-client_SOURCE_DIR}/assets/kingthings_spike.ttf -) - malikania_define_executable( TARGET mlk-client SOURCES ${SOURCES} - ASSETS ${ASSETS} LIBRARIES libmlk-client-js ) diff -r 16f27d6543bf -r 43a26de57fe7 client/assets/kingthings_spike.ttf Binary file client/assets/kingthings_spike.ttf has changed diff -r 16f27d6543bf -r 43a26de57fe7 client/main.cpp --- a/client/main.cpp Wed Dec 13 13:45:00 2017 +0100 +++ b/client/main.cpp Wed Dec 13 13:46:51 2017 +0100 @@ -20,19 +20,9 @@ #include #include -#include +#include #include -namespace res { - -namespace { - -#include - -} // !namespace - -} // !res - int main() { boost::asio::io_service service; @@ -40,8 +30,7 @@ mlk::client::connection conn(service); mlk::client::window w; mlk::client::client clt(service, conn, w); - mlk::client::font f(std::string(res::kingthings_spike, sizeof (res::kingthings_spike)), 64); - clt.set_state(std::make_unique(std::move(f), "Malikania Kingdom")); + clt.set_state(std::make_unique(clt)); clt.run(); } diff -r 16f27d6543bf -r 43a26de57fe7 libclient/malikania/client/state/splashscreen_state.cpp --- a/libclient/malikania/client/state/splashscreen_state.cpp Wed Dec 13 13:45:00 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * splashscreen_state.cpp -- simple basic splashscreen - * - * Copyright (c) 2013-2017 David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "client.hpp" -#include "login_state.hpp" -#include "splashscreen_state.hpp" -#include "window.hpp" - -namespace mlk { - -namespace client { - -void splashscreen_state::update(client& clt) -{ - if (timer_.elapsed().wall / 1000000LL >= delay_) - clt.set_state(std::make_unique(clt)); -} - -void splashscreen_state::draw(client& clt) -{ - auto clip = font_.clip(text_); - auto size = mlk::size(640, 480); - auto& win = clt.window(); - - win.set_drawing_color(background_); - win.clear(); - win.set_drawing_color(foreground_); - win.draw_text(text_, font_, { - static_cast((size.width() - clip.width()) / 2), - static_cast((size.height() - clip.height()) / 2) - }); - win.present(); -} - -} // !client - -} // !mlk diff -r 16f27d6543bf -r 43a26de57fe7 libclient/malikania/client/state/splashscreen_state.hpp --- a/libclient/malikania/client/state/splashscreen_state.hpp Wed Dec 13 13:45:00 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,179 +0,0 @@ -/* - * splashscreen_state.hpp -- simple basic splashscreen - * - * Copyright (c) 2013-2017 David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MALIKANIA_CLIENT_SPLASHSCREEN_STATE_HPP -#define MALIKANIA_CLIENT_SPLASHSCREEN_STATE_HPP - -/** - * \file splashscreen_state.hpp - * \brief Simple basic splashscreen. - */ - -#include - -#include - -#include -#include -#include - -namespace mlk { - -namespace client { - -/** - * \brief Simple basic splashscreen. - */ -class splashscreen_state : public state { -private: - mlk::client::font font_; - mlk::client::color foreground_{0xff000000}; - mlk::client::color background_{0xffffffff}; - std::string text_; - std::uint16_t delay_{3000}; - boost::timer::cpu_timer timer_; - -public: - /** - * Construct the state. - * - * \param fn the font - * \param text the text to show - */ - inline splashscreen_state(mlk::client::font fn, std::string text) noexcept - : font_(std::move(fn)) - , text_(std::move(text)) - { - } - - /** - * Get the current font. - * - * \return the font - */ - inline const mlk::client::font& font() const noexcept - { - return font_; - } - - /** - * Set the font. - * - * \param fn the font - */ - inline void set_font(mlk::client::font fn) noexcept - { - font_ = std::move(fn); - } - - /** - * Get the text color. - * - * \return the color - */ - inline const color& foreground() const noexcept - { - return foreground_; - } - - /** - * Set the text color. - * - * \param c the color - */ - inline void set_foreground(color c) noexcept - { - foreground_ = std::move(c); - } - - /** - * Get the background color. - * - * \return the color - */ - inline const color& background() const noexcept - { - return background_; - } - - /** - * Set the background color. - * - * \param c the color - */ - inline void set_background(color c) noexcept - { - background_ = std::move(c); - } - - /** - * Get the text to show. - * - * \return the text - */ - inline const std::string& text() const noexcept - { - return text_; - } - - /** - * Set the text to show. - * - * \param text the text - */ - inline void set_text(std::string text) noexcept - { - text_ = std::move(text); - } - - /** - * Get the delay. - * - * \return the delay in milliseconds - */ - inline std::uint16_t delay() const noexcept - { - return delay_; - } - - /** - * Set the delay. - * - * \return the delay in milliseconds - */ - inline void set_delay(std::uint16_t delay) noexcept - { - delay_ = delay; - } - - /** - * \copydoc state::update - */ - void update(client& clt) override; - - /** - * \copydoc state::draw - */ - void draw(client& clt) override; -}; - -} // !client - -} // !mlk - -#endif // !MALIKANIA_CLIENT_SPLASHSCREEN_STATE_HPP