forked from opentibia/yatc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.h
146 lines (128 loc) · 4.45 KB
/
console.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//////////////////////////////////////////////////////////////////////
// Yet Another Tibia Client
//////////////////////////////////////////////////////////////////////
// Console
//////////////////////////////////////////////////////////////////////
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#ifndef __CONSOLE_H
#define __CONSOLE_H
#include <time.h>
#include <vector>
#include <string>
#ifndef __USE_GLSDL__
#include <SDL/SDL.h>
#else
#include <SDL/glSDL.h>
#endif
#include <GLICT/panel.h>
#include <GLICT/textbox.h>
#include <GLICT/button.h>
#include "stdinttypes.h"
#include "gamecontent/enums.h"
#include "popup.h"
class Console;
class ConsolePanel: public glictPanel
{
public:
ConsolePanel();
virtual ~ConsolePanel();
virtual void SetHeight(float h);
virtual void SetWidth(float w);
virtual bool CastEvent(glictEvents evt, void* wparam, long lparam, void* returnvalue);
void SetActiveConsole(Console* console);
void MakeConsole(Console* console, const std::string& name);
void DeleteConsole(Console* console);
glictPanel pnlConsoleResizer;
glictPanel pnlConsoleEntryContainer;
glictPanel pnlConsoleEntryView;
glictTextbox txtConsoleEntry;
std::vector<glictPanel*> pnlConsoleButtons;
glictPanel pnlConsoleButtonContainer;
glictButton btnSpeakLevel;
glictButton btnClose;
glictButton btnM;
glictButton btnChannelList;
glictButton btnIgnore;
protected:
static void pnlConsoleButton_OnClick(glictPos* relmousepos, glictContainer* caller);
static void onPaintConsole(glictRect* real, glictRect* clipped, glictContainer* callerclass);
static void onClickConsole(glictPos* relmousepos, glictContainer* callerclass);
// popup stuff
static void makeConsolePopup(Popup* popup, void* owner, void* arg);
static void onUnimplemented(Popup::Item *parent);
static void onCopyMessage(Popup::Item *parent);
static void onMessageTo(Popup::Item *parent);
static void makeConsoleBtnPopup(Popup* popup, void* owner, void* arg);
static void onCloseConsole(Popup::Item *parent);
static void onShowM(Popup::Item *parent);
static void onSaveConsole(Popup::Item *parent);
static void onClearConsole(Popup::Item *parent);
// button clicks
static void btnSpeak_OnClick(glictPos* relmousepos, glictContainer* caller);
};
class ConsoleEntry {
public:
ConsoleEntry(std::string text, TextColor_t c=TEXTCOLOR_WHITE)
{
m_text = text;
m_speaker = "";
m_color = c;
m_timestamp = time(NULL);
m_level = -1;
}
ConsoleEntry(std::string text, std::string speaker, int level, TextColor_t c=TEXTCOLOR_WHITE)
{
m_text = text;
m_speaker = speaker;
m_color = c;
m_timestamp = time(NULL);
m_level = level;
}
int paintEntry(float x, float y, float width = -1);
int getHeight();
const std::string& getSpeaker(){ return m_speaker; }
std::string getFullText();
private:
std::string m_text, m_speaker;
TextColor_t m_color;
uint32_t m_timestamp;
int m_level;
};
class Console {
public:
Console();
Console(uint32_t channelid);
Console(std::string speakername);
virtual ~Console();
void paintConsole(float left, float top, float right, float bottom);
void insertEntry(ConsoleEntry ce);
const std::string& getSpeakerName() const { return m_speakername; }
uint32_t getChannelId() const { return m_channelid; }
int getConsoleId() const {return m_consoleid;}
void setAssignedButton(glictPanel *pnl) { m_assignedButton = pnl; }
glictPanel *getAssignedButton() const { return m_assignedButton; }
ConsoleEntry* getConsoleEntryAt(float relx, float rely);
void clearEntries();
void dumpText();
int getHeight();
private:
std::vector <ConsoleEntry> m_content;
std::string m_speakername;
uint32_t m_channelid;
int m_consoleid;
glictPanel* m_assignedButton;
};
#endif