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.
|
||||
* Impose some rudimentary constraints on the Image Slice Window's initial size.
|
||||
* Merge String capitilization changes by @SoaringMoon.
|
||||
* Add timestamps to console messages.
|
||||
|
||||
Bug fixes:
|
||||
* Make viewer image rotate button operate clockwise to match dropdown options. (#9)
|
||||
|
||||
@@ -26,6 +26,7 @@ class ConsoleMessage : public IntrusivePtrBase<ConsoleMessage> {
|
||||
public:
|
||||
MessageType type;
|
||||
String text; // string message
|
||||
wxDateTime timestamp;
|
||||
Bitmap bitmap; // image message instead of string
|
||||
ScriptValueP value; // other valued message (images? cards?)
|
||||
// location of error messages
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
int bottom() const { return top+height; }
|
||||
|
||||
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)
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -245,9 +246,11 @@ private:
|
||||
PrepareDC(dc);
|
||||
draw(dc);
|
||||
}
|
||||
|
||||
void draw(wxDC& dc) const {
|
||||
clearDC(dc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
|
||||
FOR_EACH_CONST(msg, messages) {
|
||||
draw(dc, *msg);
|
||||
}
|
||||
@@ -282,14 +285,29 @@ private:
|
||||
dc.SetBrush(lerp(bg,color, 0.05));
|
||||
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
|
||||
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
|
||||
dc.SetTextForeground(fg);
|
||||
int text_left = TEXT_PADDING_LEFT;
|
||||
int text_left = left + TEXT_PADDING_LEFT;
|
||||
int text_top = top + TEXT_PADDING_TOP;
|
||||
// find line breaks in the text
|
||||
String::const_iterator begin = msg.text.begin();
|
||||
@@ -317,7 +335,7 @@ private:
|
||||
|
||||
// draw line below item
|
||||
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 {
|
||||
@@ -340,6 +358,11 @@ private:
|
||||
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
|
||||
int bitmap_height = msg.bitmap.Ok() ? msg.bitmap.GetHeight() : 0;
|
||||
|
||||
@@ -349,8 +372,10 @@ private:
|
||||
// --------------------------------------------------- : Layout
|
||||
|
||||
static constexpr int LIST_SPACING = 1;
|
||||
static constexpr int TIMESTAMP_PADDING = 3;
|
||||
static constexpr int ICON_PADDING = 3;
|
||||
static constexpr int TEXT_PADDING_LEFT = ICON_PADDING + 16 + 4;
|
||||
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_TOP = 4;
|
||||
static constexpr int TEXT_PADDING_BOTTOM = 2;
|
||||
|
||||
Reference in New Issue
Block a user