mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
feat: add timestamps to console messages
This commit is contained in:
@@ -16,6 +16,7 @@ Features:
|
|||||||
* Add ability to change scale (relative to template) of internally stored images.
|
* Add ability to change scale (relative to template) of internally stored images.
|
||||||
* Impose some rudimentary constraints on the Image Slice Window's initial size.
|
* Impose some rudimentary constraints on the Image Slice Window's initial size.
|
||||||
* Merge String capitilization changes by @SoaringMoon.
|
* Merge String capitilization changes by @SoaringMoon.
|
||||||
|
* Add timestamps to console messages.
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
* Make viewer image rotate button operate clockwise to match dropdown options. (#9)
|
* Make viewer image rotate button operate clockwise to match dropdown options. (#9)
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ DECLARE_POINTER_TYPE(ConsoleMessage);
|
|||||||
class ConsoleMessage : public IntrusivePtrBase<ConsoleMessage> {
|
class ConsoleMessage : public IntrusivePtrBase<ConsoleMessage> {
|
||||||
public:
|
public:
|
||||||
MessageType type;
|
MessageType type;
|
||||||
String text; // string message
|
String text; // string message
|
||||||
|
wxDateTime timestamp;
|
||||||
Bitmap bitmap; // image message instead of string
|
Bitmap bitmap; // image message instead of string
|
||||||
ScriptValueP value; // other valued message (images? cards?)
|
ScriptValueP value; // other valued message (images? cards?)
|
||||||
// location of error messages
|
// location of error messages
|
||||||
@@ -38,7 +39,7 @@ public:
|
|||||||
int bottom() const { return top+height; }
|
int bottom() const { return top+height; }
|
||||||
|
|
||||||
ConsoleMessage(MessageType type, String const& text = _(""), bool joined_to_previous = false)
|
ConsoleMessage(MessageType type, String const& text = _(""), bool joined_to_previous = false)
|
||||||
: type(type), text(text), line_number(-1), joined_to_previous(joined_to_previous), top(-1), height(-1)
|
: type(type), text(text), timestamp(wxDateTime::Now()), line_number(-1), joined_to_previous(joined_to_previous), top(-1), height(-1)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -244,10 +245,12 @@ private:
|
|||||||
wxAutoBufferedPaintDC dc(this);
|
wxAutoBufferedPaintDC dc(this);
|
||||||
PrepareDC(dc);
|
PrepareDC(dc);
|
||||||
draw(dc);
|
draw(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(wxDC& dc) const {
|
void draw(wxDC& dc) const {
|
||||||
clearDC(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
clearDC(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||||
dc.SetFont(*wxNORMAL_FONT);
|
dc.SetFont(*wxNORMAL_FONT);
|
||||||
|
|
||||||
FOR_EACH_CONST(msg, messages) {
|
FOR_EACH_CONST(msg, messages) {
|
||||||
draw(dc, *msg);
|
draw(dc, *msg);
|
||||||
}
|
}
|
||||||
@@ -280,16 +283,31 @@ private:
|
|||||||
// draw background
|
// draw background
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.SetBrush(lerp(bg,color, 0.05));
|
dc.SetBrush(lerp(bg,color, 0.05));
|
||||||
dc.DrawRectangle(left,top,width,msg.height);
|
dc.DrawRectangle(left,top,width,msg.height);
|
||||||
|
|
||||||
|
// draw foreground
|
||||||
|
dc.SetTextForeground(fg);
|
||||||
|
|
||||||
|
// draw timestamp
|
||||||
|
dc.DrawText(msg.timestamp.FormatISOTime(), left + TIMESTAMP_PADDING, top + TEXT_PADDING_TOP);
|
||||||
|
|
||||||
|
wxSize timestamp_size = dc.GetTextExtent("55:55:55");
|
||||||
|
int timestamp_resolved_width = timestamp_size.GetWidth();
|
||||||
|
|
||||||
|
left += timestamp_resolved_width;
|
||||||
|
left += TIMESTAMP_PADDING * 2;
|
||||||
|
|
||||||
|
// draw line right of timestamp
|
||||||
|
dc.SetPen(lerp(bg, fg, 0.3));
|
||||||
|
dc.DrawLine(left, top, left, top + msg.height);
|
||||||
|
|
||||||
// draw icon
|
// draw icon
|
||||||
if (icons[msg.type].Ok()) {
|
if (icons[msg.type].Ok()) {
|
||||||
dc.DrawBitmap(icons[msg.type], left + ICON_PADDING,top + ICON_PADDING);
|
dc.DrawBitmap(icons[msg.type], left + ICON_PADDING_LEFT,top + ICON_PADDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
dc.SetTextForeground(fg);
|
int text_left = left + TEXT_PADDING_LEFT;
|
||||||
int text_left = TEXT_PADDING_LEFT;
|
|
||||||
int text_top = top + TEXT_PADDING_TOP;
|
int text_top = top + TEXT_PADDING_TOP;
|
||||||
// find line breaks in the text
|
// find line breaks in the text
|
||||||
String::const_iterator begin = msg.text.begin();
|
String::const_iterator begin = msg.text.begin();
|
||||||
@@ -313,11 +331,11 @@ private:
|
|||||||
if (msg.bitmap.Ok()) {
|
if (msg.bitmap.Ok()) {
|
||||||
dc.DrawBitmap(msg.bitmap, text_left, text_top);
|
dc.DrawBitmap(msg.bitmap, text_left, text_top);
|
||||||
text_top += msg.bitmap.GetHeight();
|
text_top += msg.bitmap.GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw line below item
|
// draw line below item
|
||||||
dc.SetPen(lerp(bg,fg, 0.3));
|
dc.SetPen(lerp(bg,fg, 0.3));
|
||||||
dc.DrawLine(left, top+msg.height, left+width, top+msg.height);
|
dc.DrawLine(0, top + msg.height, 0 + width, top + msg.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
int item_height(wxDC& dc, ConsoleMessage const& msg) const {
|
int item_height(wxDC& dc, ConsoleMessage const& msg) const {
|
||||||
@@ -338,6 +356,11 @@ private:
|
|||||||
}
|
}
|
||||||
if (begin != msg.text.end()) {
|
if (begin != msg.text.end()) {
|
||||||
text_height += dc.GetCharHeight() + TEXT_LINE_SPACING;
|
text_height += dc.GetCharHeight() + TEXT_LINE_SPACING;
|
||||||
|
}
|
||||||
|
|
||||||
|
// account for the height of a timestamp even if there is no other text content.
|
||||||
|
if (text_height == 0) {
|
||||||
|
text_height = dc.GetCharHeight() + TEXT_LINE_SPACING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// height of bitmap
|
// height of bitmap
|
||||||
@@ -347,10 +370,12 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------- : Layout
|
// --------------------------------------------------- : Layout
|
||||||
|
|
||||||
static constexpr int LIST_SPACING = 1;
|
static constexpr int LIST_SPACING = 1;
|
||||||
static constexpr int ICON_PADDING = 3;
|
static constexpr int TIMESTAMP_PADDING = 3;
|
||||||
static constexpr int TEXT_PADDING_LEFT = ICON_PADDING + 16 + 4;
|
static constexpr int ICON_PADDING = 3;
|
||||||
|
static constexpr int ICON_PADDING_LEFT = TIMESTAMP_PADDING + 3;
|
||||||
|
static constexpr int TEXT_PADDING_LEFT = ICON_PADDING_LEFT + 16 + 4;
|
||||||
static constexpr int TEXT_PADDING_RIGHT = 4;
|
static constexpr int TEXT_PADDING_RIGHT = 4;
|
||||||
static constexpr int TEXT_PADDING_TOP = 4;
|
static constexpr int TEXT_PADDING_TOP = 4;
|
||||||
static constexpr int TEXT_PADDING_BOTTOM = 2;
|
static constexpr int TEXT_PADDING_BOTTOM = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user