openspades/Sources/Client/ChatWindow.h

91 lines
2.3 KiB
C
Raw Normal View History

2013-08-29 11:45:22 +09:00
/*
Copyright (c) 2013 yvt
2013-08-29 11:45:22 +09:00
This file is part of OpenSpades.
2013-08-29 11:45:22 +09:00
OpenSpades is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2013-08-29 11:45:22 +09:00
OpenSpades is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2013-08-29 11:45:22 +09:00
You should have received a copy of the GNU General Public License
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
2013-08-29 11:45:22 +09:00
*/
2013-08-18 16:18:06 +09:00
#pragma once
#include <list>
#include <string>
#include <Core/Math.h>
2013-08-18 16:18:06 +09:00
namespace spades {
namespace client {
class IRenderer;
class IFont;
class IImage;
2013-08-18 16:18:06 +09:00
class Client;
2013-08-18 16:18:06 +09:00
static const char MsgColorTeam1 = 1;
static const char MsgColorTeam2 = 2;
static const char MsgColorTeam3 = 3;
static const char MsgColorRed = 4;
static const char MsgColorGreen = 5;
static const char MsgColorRestore = 6;
2017-01-09 22:56:55 +09:00
static const char MsgColorGray = 7;
static const char MsgColorMax = 8;
static const char MsgColorFriendlyFire = MsgColorRed;
static const char MsgColorSysInfo = MsgColorGreen;
2013-08-18 16:18:06 +09:00
class ChatWindow {
Client *client;
IRenderer *renderer;
IFont *font;
2013-08-18 16:18:06 +09:00
struct ChatEntry {
std::string msg;
float height;
float fade = 0.0f; // usual fade opacity
float bufferFade = 0.0f;
2013-08-18 16:18:06 +09:00
float timeFade; // timeout fade opacity
ChatEntry(const std::string &Msg, float Height, float TimeFade)
: msg(Msg), height(Height), timeFade(TimeFade) {}
2013-08-18 16:18:06 +09:00
};
2013-08-18 16:18:06 +09:00
std::list<ChatEntry> entries;
float firstY;
2013-08-26 17:53:14 +09:00
bool killfeed;
bool expanded = false;
2013-08-18 16:18:06 +09:00
float GetWidth();
float GetNormalHeight();
float GetBufferHeight();
2013-08-18 16:18:06 +09:00
float GetLineHeight();
2013-08-18 16:18:06 +09:00
Vector4 GetColor(char);
2013-08-18 16:18:06 +09:00
public:
ChatWindow(Client *, IRenderer *rend, IFont *font, bool killfeed);
2013-08-18 16:18:06 +09:00
~ChatWindow();
void AddMessage(const std::string &);
static std::string ColoredMessage(const std::string &, char);
static std::string TeamColorMessage(const std::string &, int);
static std::string killImage(int killType, int weapon);
void SetExpanded(bool value) { expanded = value; }
2013-08-18 16:18:06 +09:00
void Update(float dt);
void Draw();
};
} // namespace client
} // namespace spades