When the game windows were initialized, the anhk icon for alignment was centered relative to Lawful/Neutral/Chaotic label but during the first status update it noticeably shifted left. Non-blank hunger or encumbrance states could change from centered to left justified when they were present and the icon was replaced. Oddly, resetting the 'centered' attribute for the widget wasn't sufficient to fix this. Running the resize code for that widget did. Another case of trial and error to make things work the way they ought. Also, don't highlight a change in alignment or dungeon location as "got worse" if the internal numeric value went down instead of up; always highlight as "got better" for those two fields. There ought to be a third choice for just "changed" but that would have been more complicated.
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
// Copyright (c) Warwick Allison, 1999.
|
|
// Qt4 conversion copyright (c) Ray Chason, 2012-2014.
|
|
// NetHack may be freely redistributed. See license for details.
|
|
|
|
// qt_icon.cpp -- a labelled icon
|
|
|
|
#ifndef QT4ICON_H
|
|
#define QT4ICON_H
|
|
|
|
namespace nethack_qt_ {
|
|
|
|
class NetHackQtLabelledIcon : public QWidget {
|
|
public:
|
|
NetHackQtLabelledIcon(QWidget* parent, const char* label);
|
|
NetHackQtLabelledIcon(QWidget* parent, const char* label, const QPixmap& icon);
|
|
|
|
enum { NoNum=-99999 };
|
|
void setLabel(const QString&, bool lower=true); // a string
|
|
void setLabel(const QString&, long, const QString& tail=""); // a number
|
|
void setLabel(const QString&, long show_value, long comparative_value, const QString& tail="");
|
|
void setIcon(const QPixmap&);
|
|
virtual void setFont(const QFont&);
|
|
|
|
void highlightWhenChanging();
|
|
void lowIsGood();
|
|
void dissipateHighlight();
|
|
void ForceResize();
|
|
|
|
virtual void show();
|
|
virtual QSize sizeHint() const;
|
|
virtual QSize minimumSizeHint() const;
|
|
|
|
protected:
|
|
void resizeEvent(QResizeEvent*);
|
|
|
|
private:
|
|
void initHighlight();
|
|
void setAlignments();
|
|
void highlight(const QString& highlight);
|
|
void unhighlight();
|
|
|
|
bool low_is_good;
|
|
int prev_value;
|
|
int turn_count; /* last time the value changed */
|
|
QString hl_good;
|
|
QString hl_bad;
|
|
|
|
QLabel* label;
|
|
QLabel* icon;
|
|
};
|
|
|
|
} // namespace nethack_qt_
|
|
|
|
#endif
|