Planeshift
shortcutwindow.h
Go to the documentation of this file.
1 /*
2 * shortcutwindow.h - Author: Andrew Dai
3 * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
4 *
5 * Revision Author: Joe Lyon
6 * Copyright (C) 2013 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation (version 2 of the License)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20 
21 #ifndef PAWS_SHORTCUT_WINDOW
22 #define PAWS_SHORTCUT_WINDOW
23 
24 //=============================================================================
25 // Library Includes
26 //=============================================================================
27 // COMMON INCLUDES
28 #include "net/messages.h"
29 #include "net/clientmsghandler.h"
30 #include "net/cmdhandler.h"
31 
32 // CLIENT INCLUDES
33 #include "pscelclient.h"
34 #include "../globals.h"
35 #include "clientvitals.h"
36 #include "psclientchar.h"
37 
38 // PAWS INCLUDES
39 #include "gui/pawscontrolwindow.h"
40 #include "gui/pawsconfigkeys.h"
41 #include "paws/pawsprogressbar.h"
42 #include "pawsscrollmenu.h"
43 
44 
45 //=============================================================================
46 // Forward Declarations
47 //=============================================================================
48 class pawsChatWindow;
49 
50 //=============================================================================
51 // Defines
52 //=============================================================================
53 #define NUM_SHORTCUTS 256
54 
55 //=============================================================================
56 // Classes
57 //=============================================================================
58 
63 {
64 public:
66 
67  virtual ~pawsShortcutWindow();
68 
69  virtual bool Setup(iDocumentNode *node);
70  virtual bool PostSetup();
71 
72  bool OnMouseDown( int button, int modifiers, int x, int y );
73  bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* reporter);
74  bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget* reporter);
75  bool OnScroll(int direction, pawsScrollBar* widget);
76 
77  void OnResize();
78  bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods);
79 
85  void ExecuteCommand(int shortcutNum );
86 
92  const csString& GetCommandName(int shortcutNum );
93 
99  csString GetTriggerText(int shortcutNum);
100 
104  void LoadDefaultCommands();
105  void LoadCommandsFile();
106  void LoadCommands(const char *FN);
107  void SaveCommands();
108  void SaveCommands(const char *FN);
109 
110  void ResetEditWindow();
111 
112  void Show();
113 
114  void StartMonitors();
115  void StopMonitors();
116  int GetMonitorState();
120  char const * GetFontName()
121  {
122  return fontName;
123  }
124 
128  bool LoadUserPrefs();
129  bool LoadUserSharedPrefs();
130 
131  void SetHPWarnLevel( float val );
132  float GetHPWarnLevel();
133 
134  void SetHPDangerLevel( float val );
135  float GetHPDangerLevel();
136 
137  void SetHPFlashLevel( float val );
138  float GetHPFlashLevel();
139 
140  void SetManaWarnLevel( float val );
141  float GetManaWarnLevel();
142 
143  void SetManaDangerLevel( float val );
144  float GetManaDangerLevel();
145 
146  void SetManaFlashLevel( float val );
147  float GetManaFlashLevel();
148 
149  void SetHPOn( bool val );
150  void SetManaOn( bool val );
151 
152 protected:
156 
157  csArray<csString> cmds;
158  csArray<csString> names;
159  csArray<csString> toolTips;
160  csArray<csString> icon;
161 
162  csRef<iVFS> vfs;
163 
164  // The widget that holds the command data during editing
166 
167  // The widget that holds the button label data during editing
169 
170  // The widget that holds the shortcut lable data during editing
172 
174 
175  // Widget used to configure the shortcuts
177 
181 
183 
184  size_t edit;
186 
187  virtual void HandleMessage(MsgEntry *msg);
188 
189 private:
190  //status bars, optional;configured in XML
191  pawsProgressBar *main_hp;
192  pawsProgressBar *main_mana;
193  pawsProgressBar *phys_stamina;
194  pawsProgressBar *ment_stamina;
195  pawsScrollMenu *MenuBar;
196 
197  //custom controls, optional;configured in XML
198  pawsButton *UpButton;
199  pawsButton *DownButton;
200  pawsScrollBar *iconScrollBar;
201  pawsScrollBar *paletteScrollBar;
202 
203  csArray<csString> allIcons;
204  csArray<csString> allNames; //not populated at this time...
205  csArray<csString> stubArray;
206 
207  csString fileName;
208 
209  size_t position;
210  size_t buttonWidth;
211  int textSpacing;
212  float scrollSize;
213  int EditMode;
214 };
215 
216 
218 #endif
This is a window that is controlled by a button on the control bar.
void SetManaFlashLevel(float val)
pawsEditTextBox * labelBox
pawsWidget * subWidget
csArray< csString > cmds
float GetManaWarnLevel()
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
pawsTextBox * shortcutText
virtual bool PostSetup()
This is called after the widget and all of it&#39;s children have been created.
void SetHPFlashLevel(float val)
csString fontName
Name of currently selected font.
Definition: pawswidget.h:305
CREATE_PAWS_FACTORY(pawsShortcutWindow)
float GetManaFlashLevel()
float GetHPDangerLevel()
const csString & GetCommandName(int shortcutNum)
Get the short cut script.
void SetHPWarnLevel(float val)
Main Chat window for PlaneShift.
Definition: chatwindow.h:133
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
virtual bool Setup(iDocumentNode *node)
Setup this widget.
bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget *reporter)
Called whenever a button is released.
bool LoadUserPrefs()
Load the preferences set by the Shortcut Configuration interface.
void LoadDefaultCommands()
Load the commands, icon names and shortcut text keys.
A Drag-and-Drop capable button widget with timer.
Definition: pawsdndbutton.h:45
csString GetTriggerText(int shortcutNum)
Get the text of a buttons assigned shortcut key.
CmdHandler * cmdsource
An edit box widget/.
Definition: pawstextbox.h:409
bool OnFingering(csString string, psControl::Device device, uint button, uint32 mods)
Returns whether the combo was accepted and the fingering window should hide.
csArray< csString > icon
void SetManaWarnLevel(float val)
A scrolling list of buttons, each with an icon and which accepts drag-n-drop.
void SetManaOn(bool val)
csRef< iVFS > vfs
pawsDnDButton * iconDisplay
pawsScrollMenu * iconPalette
float GetManaDangerLevel()
void Show()
When the window is opened let the controller window know about it.
virtual ~pawsShortcutWindow()
A simple scroll bar widget.
Definition: pawscrollbar.h:64
bool OnMouseDown(int button, int modifiers, int x, int y)
Manage mouse down event to test for and apply window changes.
pawsChatWindow * chatWindow
chat window for easy access
pawsTextBox * title
void SetManaDangerLevel(float val)
bool LoadUserSharedPrefs()
char const * GetFontName()
return the name of the font
bool OnScroll(int direction, pawsScrollBar *widget)
Called whenever a window is scrolled.
A simple button widget.
Definition: pawsbutton.h:43
The shortcut window itself, including the window used to edit the shortcuts.
csString buttonBackgroundImage
void SetHPDangerLevel(float val)
void LoadCommands(const char *FN)
void OnResize()
Sets the new position of the close button.
virtual void HandleMessage(MsgEntry *msg)
This interface receive OnFingering notification from the FingeringWindow.
csArray< csString > toolTips
pawsWidget * editedButton
bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget *reporter)
Called whenever a button is pressed.
void ExecuteCommand(int shortcutNum)
Execute a short cut script.
A basic text box widget.
Definition: pawstextbox.h:42
void SetHPOn(bool val)
pawsMultilineEditTextBox * textBox
csArray< csString > names