Public Member Functions | Private Attributes | Friends
StatDebugTab Class Reference

#include <statdebugtab.h>

Inheritance diagram for StatDebugTab:
DebugTab ActionListener Container BasicContainer2 BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 StatDebugTab (const Widget2 *const widget)
void logic ()
void action (const ActionEvent &event)
- Public Member Functions inherited from DebugTab
void resize (const int x, const int y)
- Public Member Functions inherited from Container
 Container (const Widget2 *const widget)
 ~Container ()
bool safeRemove (Widget *const widget)
void removeControls ()
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 ~BasicContainer2 ()
void setOpaque (Opaque opaque)
bool isOpaque () const
virtual void add (Widget *const widget)
void addXY (Widget *const widget, const int x, const int y)
void draw (Graphics *const graphics)
void safeDraw (Graphics *const graphics)
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 ~BasicContainer ()
void showWidgetPart (Widget *const widget, const Rect &area)
void moveToTop (Widget *const widget)
void moveToBottom (Widget *const widget)
Rect getChildrenArea ()
void focusNext ()
void focusPrevious ()
void setFocusHandler (FocusHandler *const focusHandler)
void setInternalFocusHandler (FocusHandler *const focusHandler)
WidgetgetWidgetAt (int x, int y)
void death (const Event &event)
WidgetfindFirstWidget (const std::set< Widget * > &list)
void add (Widget *const widget)
virtual void remove (Widget *const widget)
virtual void clear ()
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 ~Widget ()
virtual void drawFrame (Graphics *graphics)
virtual void safeDrawFrame (Graphics *graphics)
void setFrameSize (const unsigned int frameSize)
unsigned int getFrameSize () const
WidgetgetParent () const
void setWidth (const int width)
int getWidth () const
void setHeight (const int height)
int getHeight () const
void setSize (const int width, const int height)
void setX (const int x)
int getX () const
void setY (const int y)
int getY () const
void setPosition (const int x, const int y)
void setDimension (const Rect &dimension)
const RectgetDimension () const
void setFocusable (const bool focusable)
bool isFocusable () const
virtual bool isFocused () const
void setEnabled (const bool enabled)
bool isEnabled () const
void setVisible (Visible visible)
bool isVisible () const
void setBaseColor (const Color &color)
const ColorgetBaseColor () const
void setForegroundColor (const Color &color)
const ColorgetForegroundColor () const
void setBackgroundColor (const Color &color)
const ColorgetBackgroundColor () const
virtual void requestFocus ()
virtual void requestMoveToTop ()
virtual void requestMoveToBottom ()
FocusHandlergetFocusHandler ()
void addActionListener (ActionListener *const actionListener)
void removeActionListener (ActionListener *const actionListener)
void addDeathListener (WidgetDeathListener *const deathListener)
void removeDeathListener (WidgetDeathListener *const deathListener)
void addMouseListener (MouseListener *const mouseListener)
void removeMouseListener (MouseListener *const mouseListener)
void addKeyListener (KeyListener *const keyListener)
void removeKeyListener (KeyListener *const keyListener)
void addFocusListener (FocusListener *const focusListener)
void removeFocusListener (FocusListener *const focusListener)
void addWidgetListener (WidgetListener *const widgetListener)
void removeWidgetListener (WidgetListener *const widgetListener)
void setActionEventId (const std::string &actionEventId)
const std::string & getActionEventId () const
virtual void getAbsolutePosition (int &x, int &y) const
virtual void setParent (Widget *parent)
FontgetFont () const
void setFont (Font *const font)
virtual void fontChanged ()
bool isTabInEnabled () const
void setTabInEnabled (const bool enabled)
bool isTabOutEnabled () const
void setTabOutEnabled (const bool enabled)
void requestModalFocus ()
virtual void requestModalMouseInputFocus ()
virtual void releaseModalFocus ()
virtual void releaseModalMouseInputFocus ()
virtual bool isModalFocused () const
virtual bool isModalMouseInputFocused () const
const std::list< MouseListener * > & getMouseListeners () const A_CONST
const std::list< KeyListener * > & getKeyListeners () const A_CONST
const std::list< FocusListener * > & getFocusListeners () const A_CONST
virtual FocusHandlergetInternalFocusHandler ()
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
void setId (const std::string &id)
const std::string & getId () const
virtual void showPart (const Rect &rectangle)
bool isAllowLogic () const
void setMouseConsume (const bool b)
bool isMouseConsume () const
void setRedraw (const bool b)
virtual bool isSelectable () const
void setSelectable (const bool selectable)
void windowResized ()
virtual void postInit ()
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
virtual void setWidget2 (const Widget2 *const widget)
void setPalette (int palette)
void checkPalette ()
void setForegroundColor2 (const Color &color)
WidgetgetWindow () const
virtual void setWindow (Widget *const window)
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()

Private Attributes

LabelmStatLabels [PERFSTAT_LAST_STAT - 1]
LabelmWorseStatLabels [PERFSTAT_LAST_STAT - 1]
size_t mDrawIndex


class DebugWindow

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
static FontgetGloablFont ()
static void cleanGlobalFont ()
static bool widgetExists (const Widget *const widget)
static void distributeWindowResizeEvent ()
static WidgetcallPostInit (Widget *const widget)
- Data Fields inherited from Widget
Visible mVisible
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
typedef WidgetList::iterator WidgetListIterator
typedef WidgetList::const_iterator WidgetListConstIterator
typedef WidgetList::reverse_iterator WidgetListReverseIterator
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
typedef MouseListenerList::iterator MouseListenerIterator
typedef std::list< KeyListener * > KeyListenerList
typedef KeyListenerList::iterator KeyListenerIterator
typedef std::list< ActionListener * > ActionListenerList
typedef ActionListenerList::iterator ActionListenerIterator
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
typedef std::list< FocusListener * > FocusListenerList
typedef FocusListenerList::iterator FocusListenerIterator
typedef std::list< WidgetListener * > WidgetListenerList
typedef WidgetListenerList::iterator WidgetListenerIterator
- Protected Member Functions inherited from DebugTab
 DebugTab (const Widget2 *const widget)
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
virtual void safeDrawChildren (Graphics *const graphics)
virtual void logicChildren ()
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
void distributeResizedEvent ()
void distributeMovedEvent ()
void distributeHiddenEvent ()
void distributeShownEvent ()
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
- Protected Member Functions inherited from ActionListener
 ActionListener ()
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
WidgetList mLogicWidgets
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
KeyListenerList mKeyListeners
ActionListenerList mActionListeners
WidgetDeathListenerList mDeathListeners
FocusListenerList mFocusListeners
WidgetListenerList mWidgetListeners
Color mForegroundColor
Color mBackgroundColor
Color mBaseColor
Rect mDimension
std::string mActionEventId
std::string mId
unsigned int mFrameSize
bool mFocusable
bool mTabIn
bool mTabOut
bool mEnabled
bool mAllowLogic
bool mMouseConsume
bool mRedraw
bool mSelectable
- Protected Attributes inherited from Widget2
int mPaletteOffset
Color mForegroundColor2
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0

Detailed Description

Definition at line 34 of file statdebugtab.h.

Constructor & Destructor Documentation

◆ StatDebugTab()

StatDebugTab::StatDebugTab ( const Widget2 *const  widget)

Definition at line 40 of file statdebugtab.cpp.

40  :
41  DebugTab(widget),
42  // TRANSLATORS: debug window label, logic per second
43  mLPSLabel(new Label(this, strprintf(_("LPS: %d"), 0))),
44  // TRANSLATORS: debug window stats reset button
45  mResetButton(new Button(this, _("Reset"), "reset", BUTTON_SKIN, this)),
46  // TRANSLATORS: debug window stats copy button
47  mCopyButton(new Button(this, _("Copy"), "copy", BUTTON_SKIN, this)),
48  mStatLabels(),
50  mDrawIndex(0)
51 {
52  LayoutHelper h(this);
53  ContainerPlacer place = h.getPlacer(0, 0);
58  place(0, 0, mLPSLabel, 2, 1);
59  place(0, 1, mResetButton, 1, 1);
60  place(1, 1, mCopyButton, 1, 1);
61  for (size_t f = 1; f < PERFSTAT_LAST_STAT; f ++)
62  {
63  mStatLabels[f - 1] = new Label(this,
64  // TRANSLATORS: debug window stat label
65  strprintf(_("stat%u: %d ms"), CAST_U32(f), 1000));
66  mStatLabels[f - 1]->adjustSize();
67  mWorseStatLabels[f - 1] = new Label(this,
68  // TRANSLATORS: debug window stat label
69  strprintf(_("%d ms"), 1000));
70  place(0, CAST_S32(f + 1), mStatLabels[f - 1], 3, 1);
71  place(3, CAST_S32(f + 1), mWorseStatLabels[f - 1], 1, 1);
72  }
74  setDimension(Rect(0, 0, 200, 300));
75 }
const std::string BUTTON_SKIN
Definition: button.h:89
#define CAST_S32
Definition: cast.h:30
#define CAST_U32
Definition: cast.h:31
Definition: button.h:102
void adjustSize()
Definition: button.cpp:799
DebugTab(const Widget2 *const widget)
Definition: debugtab.h:44
Definition: label.h:91
void adjustSize()
Definition: label.cpp:200
Definition: rect.h:74
Label * mWorseStatLabels[PERFSTAT_LAST_STAT - 1]
Definition: statdebugtab.h:53
Label * mLPSLabel
Definition: statdebugtab.h:49
size_t mDrawIndex
Definition: statdebugtab.h:54
Button * mResetButton
Definition: statdebugtab.h:50
Label * mStatLabels[PERFSTAT_LAST_STAT - 1]
Definition: statdebugtab.h:52
Button * mCopyButton
Definition: statdebugtab.h:51
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
static const size_t PERFSTAT_LAST_STAT
Definition: perfstat.h:28
#define _(s)
Definition: gettext.h:35
std::string strprintf(const char *const format,...)

References _, Button::adjustSize(), Label::adjustSize(), CAST_S32, CAST_U32, LayoutHelper::getPlacer(), mCopyButton, mLPSLabel, mResetButton, mStatLabels, mWorseStatLabels, PERFSTAT_LAST_STAT, Widget::setDimension(), and strprintf().

Member Function Documentation

◆ action()

void StatDebugTab::action ( const ActionEvent actionEvent)

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

actionEventThe event of the action.

Implements ActionListener.

Definition at line 99 of file statdebugtab.cpp.

100 {
101  const std::string &eventId = event.getId();
102  if (eventId == "reset")
103  {
104  Perf::init();
105  }
106  else if (eventId == "copy")
107  {
108  std::string data("perf:");
109  for (size_t f = 1; f < PERFSTAT_LAST_STAT; f ++)
110  {
111  data.append(strprintf(" %d",
113  }
114  data.append(",");
115  for (size_t f = 1; f < PERFSTAT_LAST_STAT; f ++)
116  {
117  data.append(strprintf(" %d",
119  }
121  true);
122  }
123 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
void addInputText(const std::string &text, const bool space)
static const int MILLISECONDS_IN_A_TICK
Definition: timer.h:30
uint32_t data
int getWorstTime(const size_t counterId)
Definition: perfstat.cpp:122
int getTime(const size_t frameId, const size_t counterId)
Definition: perfstat.cpp:111
void init()
Definition: perfstat.cpp:41

References ChatWindow::addInputText(), chatWindow, data, Perf::getTime(), Perf::getWorstTime(), Perf::init(), mDrawIndex, MILLISECONDS_IN_A_TICK, PERFSTAT_LAST_STAT, and strprintf().

◆ logic()

void StatDebugTab::logic ( )

Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.

See also

Reimplemented from DebugTab.

Definition at line 77 of file statdebugtab.cpp.

78 {
79  BLOCK_START("StatDebugTab::logic")
80  // TRANSLATORS: debug window label, logic per second
81  mLPSLabel->setCaption(strprintf(_("LPS: %d"), lps));
83  for (size_t f = 1; f < PERFSTAT_LAST_STAT; f ++)
84  {
85  mStatLabels[f - 1]->setCaption(
86  // TRANSLATORS: debug window stat label
87  strprintf(_("stat%u: %d ms"),
88  CAST_U32(f),
91  // TRANSLATORS: debug window stat label
92  strprintf(_("%d ms"),
94  }
96  BLOCK_END("StatDebugTab::logic")
97 }
void setCaption(const std::string &caption)
Definition: label.cpp:264
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
size_t prevPerfFrameId
Definition: perfstat.cpp:33
volatile int lps
Definition: timer.cpp:55

References _, BLOCK_END, BLOCK_START, CAST_U32, Perf::getTime(), Perf::getWorstTime(), lps, mDrawIndex, MILLISECONDS_IN_A_TICK, mLPSLabel, mStatLabels, mWorseStatLabels, PERFSTAT_LAST_STAT, prevPerfFrameId, Label::setCaption(), and strprintf().

Referenced by DebugWindow::slowLogic().

Friends And Related Function Documentation

◆ DebugWindow

friend class DebugWindow

Definition at line 37 of file statdebugtab.h.

Field Documentation

◆ mCopyButton

Button* StatDebugTab::mCopyButton

Definition at line 51 of file statdebugtab.h.

Referenced by StatDebugTab().

◆ mDrawIndex

size_t StatDebugTab::mDrawIndex

Definition at line 54 of file statdebugtab.h.

Referenced by action(), and logic().

◆ mLPSLabel

Label* StatDebugTab::mLPSLabel

Definition at line 49 of file statdebugtab.h.

Referenced by logic(), and StatDebugTab().

◆ mResetButton

Button* StatDebugTab::mResetButton

Definition at line 50 of file statdebugtab.h.

Referenced by StatDebugTab().

◆ mStatLabels

Label* StatDebugTab::mStatLabels[PERFSTAT_LAST_STAT - 1]

Definition at line 52 of file statdebugtab.h.

Referenced by logic(), and StatDebugTab().

◆ mWorseStatLabels

Label* StatDebugTab::mWorseStatLabels[PERFSTAT_LAST_STAT - 1]

Definition at line 53 of file statdebugtab.h.

Referenced by logic(), and StatDebugTab().

The documentation for this class was generated from the following files: