changeset 153:43a26de57fe7

Client: remove splashscreen state
author David Demelier <markand@malikania.fr>
date Wed, 13 Dec 2017 13:46:51 +0100
parents 16f27d6543bf
children 614ac46dac3e
files client/CMakeLists.txt client/assets/kingthings_spike.ttf client/main.cpp libclient/malikania/client/state/splashscreen_state.cpp libclient/malikania/client/state/splashscreen_state.hpp
diffstat 5 files changed, 2 insertions(+), 250 deletions(-) [+]
line wrap: on
line diff
--- 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
 )
Binary file client/assets/kingthings_spike.ttf has changed
--- 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 <malikania/client/client.hpp>
 #include <malikania/client/connection.hpp>
-#include <malikania/client/state/splashscreen_state.hpp>
+#include <malikania/client/state/login_state.hpp>
 #include <malikania/client/window.hpp>
 
-namespace res {
-
-namespace {
-
-#include <kingthings_spike.hpp>
-
-} // !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<mlk::client::splashscreen_state>(std::move(f), "Malikania Kingdom"));
+    clt.set_state(std::make_unique<mlk::client::login_state>(clt));
     clt.run();
 }
--- 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 <markand@malikania.fr>
- *
- * 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<login_state>(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<int>((size.width() - clip.width()) / 2),
-        static_cast<int>((size.height() - clip.height()) / 2)
-    });
-    win.present();
-}
-
-} // !client
-
-} // !mlk
--- 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 <markand@malikania.fr>
- *
- * 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 <cstdint>
-
-#include <boost/timer/timer.hpp>
-
-#include <malikania/client/color.hpp>
-#include <malikania/client/font.hpp>
-#include <malikania/client/state.hpp>
-
-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