2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2009-02-23 06:17:57 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2009-02-23 06:17:57 +00:00
|
|
|
|
2013-08-24 00:13:54 +00:00
|
|
|
#include <functional>
|
2013-08-23 23:41:17 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-10-21 06:01:38 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2013-08-23 23:41:17 +00:00
|
|
|
namespace OSD
|
2009-02-23 06:17:57 +00:00
|
|
|
{
|
2016-02-02 15:35:27 +00:00
|
|
|
struct Message
|
|
|
|
{
|
|
|
|
Message() {}
|
|
|
|
Message(const std::string& s, u32 ts, u32 rgba) : m_str(s), m_timestamp(ts), m_rgba(rgba) {}
|
|
|
|
std::string m_str;
|
|
|
|
u32 m_timestamp;
|
|
|
|
u32 m_rgba;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class MessageType
|
|
|
|
{
|
|
|
|
NetPlayPing,
|
|
|
|
NetPlayBuffer,
|
|
|
|
|
|
|
|
// This entry must be kept last so that persistent typed messages are
|
|
|
|
// displayed before other messages
|
|
|
|
Typeless,
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace Color
|
|
|
|
{
|
|
|
|
constexpr u32 CYAN = 0xFF00FFFF;
|
|
|
|
constexpr u32 GREEN = 0xFF00FF00;
|
|
|
|
constexpr u32 RED = 0xFFFF0000;
|
|
|
|
constexpr u32 YELLOW = 0xFFFFFF30;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace Duration
|
|
|
|
{
|
|
|
|
constexpr u32 SHORT = 2000;
|
|
|
|
constexpr u32 NORMAL = 5000;
|
|
|
|
constexpr u32 VERY_LONG = 10000;
|
|
|
|
};
|
|
|
|
|
2015-01-01 18:23:34 +00:00
|
|
|
// On-screen message display (colored yellow by default)
|
2016-02-02 15:35:27 +00:00
|
|
|
void AddMessage(const std::string& message, u32 ms = Duration::SHORT, u32 rgba = Color::YELLOW);
|
|
|
|
void AddTypedMessage(MessageType type, const std::string& message, u32 ms = Duration::SHORT,
|
|
|
|
u32 rgba = Color::YELLOW);
|
|
|
|
void DrawMessage(const Message& msg, int top, int left, int time_left); // draw one message
|
|
|
|
void DrawMessages(); // draw the current messages on the screen. Only call once
|
|
|
|
// per frame.
|
2011-02-02 04:40:27 +00:00
|
|
|
void ClearMessages();
|
2009-02-23 06:17:57 +00:00
|
|
|
|
2013-04-13 05:48:53 +00:00
|
|
|
// On-screen callbacks
|
2016-01-02 19:45:41 +00:00
|
|
|
enum class CallbackType
|
2013-04-13 05:48:53 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
Initialization,
|
|
|
|
OnFrame,
|
|
|
|
Shutdown
|
2013-04-13 05:48:53 +00:00
|
|
|
};
|
2016-01-02 19:45:41 +00:00
|
|
|
using Callback = std::function<void()>;
|
2013-04-13 05:48:53 +00:00
|
|
|
|
2013-08-24 00:13:54 +00:00
|
|
|
void AddCallback(CallbackType type, Callback cb);
|
|
|
|
void DoCallbacks(CallbackType type);
|
|
|
|
} // namespace OSD
|