OregonCore  revision fb2a440-git
Your Favourite TBC server
Console.h
Go to the documentation of this file.
1 
2 #ifndef OREGON_CONSOLE_H
3 #define OREGON_CONSOLE_H
4 
5 #include "Common.h"
6 #include "Policies/Singleton.h"
7 #include <curses.h>
8 
9 typedef WINDOW Window;
10 class Master;
11 class UnixDebugger;
12 
13 class Console
14 {
15  public:
16  Console();
17  ~Console();
18 
19  protected:
20  friend class World;
21  friend class Master;
22  friend class Log;
23  friend class UnixDebugger;
24  friend void LoadSQLUpdates();
25 
26  void Initialize();
27 
28  /* Start-up Loading Stuff */
29  void SetLoading(bool show, const char* caption = "Initializing");
30  void SetLoadingLabel(const char* label, bool br = true);
31  void FatalError(const char* msg);
32 
33  /* Main Loops */
34  void MainLoop();
35  void RunCommandLoop();
36  void RunLogViewLoop();
37 
38  void DrawLogo();
39  bool IsEnabled() const
40  {
41  return m_IamEnabled;
42  }
43 
44  void Beep()
45  {
46  beep();
47  }
48 
50  {
51  public:
52  void run();
53  };
54 
55  void Restore();
56 
57  private:
58 
59  void SetTitle(const char* title)
60  {
61  #if PLATFORM == PLATFORM_WINDOWS
62  SetConsoleTitle("OregonCore");
63  #elif PLATFORM == PLATFORM_UNIX
64  printf("\033]0;%s\007", title);
65  fflush(stdout);
66  #endif
67  }
68 
69  void Refresh();
70 
71  int GetChar();
72 
73  void DrawLoading();
74  void UpdateLog();
75 
76  Window* MakeWindow(int h, int w, int y, int x);
77  void ResizeWindow(Window* win, int h, int w, int y, int x);
78  void DestroyWindow(Window* win);
79 
80  std::set<Window*> m_windows;
82 
83  typedef std::list<std::string> History;
84  #if PLATFORM == PLATFORM_WINDOWS
85  typedef HANDLE PipeType;
86  #else
87  typedef int PipeType;
88  #endif
89 
90  History m_cmdHistory;
91  PipeType m_loggerFd;
92 
97 };
98 
99 #define sConsole Oregon::Singleton<Console>::Instance()
100 
101 #endif
WINDOW Window
Definition: Console.h:9
void SetLoading(bool show, const char *caption="Initializing")
Definition: Console.cpp:690
Definition: World.h:457
bool IsEnabled() const
Definition: Console.h:39
History m_cmdHistory
Definition: Console.h:90
void DestroyWindow(Window *win)
Definition: Console.cpp:201
void DrawLoading()
PipeType m_loggerFd
Definition: Console.h:91
Definition: Master.h:26
Main logging class.
Definition: Log.h:90
Window * m_logViewer
Definition: Console.h:95
Window * m_cmdOutput
Definition: Console.h:96
void SetLoadingLabel(const char *label, bool br=true)
Definition: Console.cpp:714
Console()
Definition: Console.cpp:57
void SetTitle(const char *title)
Definition: Console.h:59
void RunLogViewLoop()
Definition: Console.cpp:625
Window * MakeWindow(int h, int w, int y, int x)
Definition: Console.cpp:193
void MainLoop()
Definition: Console.cpp:243
void Initialize()
Definition: Console.cpp:86
int GetChar()
Definition: Console.cpp:218
void FatalError(const char *msg)
Definition: Console.cpp:734
~Console()
Definition: Console.cpp:65
HANDLE PipeType
Definition: Console.h:85
void Beep()
Definition: Console.h:44
void Refresh()
Definition: Console.cpp:179
void ResizeWindow(Window *win, int h, int w, int y, int x)
Definition: Console.cpp:212
void UpdateLog()
Definition: Console.cpp:788
Window * m_logoWindow
Definition: Console.h:93
std::list< std::string > History
Definition: Console.h:83
void RunCommandLoop()
Definition: Console.cpp:455
bool m_IamEnabled
Definition: Console.h:81
Window * m_loadWindow
Definition: Console.h:94
friend void LoadSQLUpdates()
std::set< Window * > m_windows
Definition: Console.h:80
void Restore()
Definition: Console.cpp:187
void DrawLogo()
Definition: Console.cpp:760