Skip to content

Commit 549e662

Browse files
committed
Added stuff for output window line preamble
1 parent eae4020 commit 549e662

File tree

3 files changed

+114
-19
lines changed

3 files changed

+114
-19
lines changed

doc.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ class CMUSHclientDoc : public CDocument
722722
CString m_strAutoLogFileName; // name of file to log to
723723
CString m_strLogLinePreambleOutput; // put at start of each log line - output
724724
CString m_strLogLinePreambleInput; // put at start of each log line - input
725-
CString m_strLogLinePreambleNotes; // put at start of each log line - world.note
725+
CString m_strLogLinePreambleNotes; // put at start of each log line - world.Note
726726
CString m_strWorldGetFocus; // script called when the world gets the focus
727727
CString m_strWorldLoseFocus; // script called when the world loses the focus
728728
CString m_strLogFilePostamble; // written when log file closed
@@ -767,7 +767,7 @@ class CMUSHclientDoc : public CDocument
767767

768768
CString m_strLogLinePostambleOutput; // put at end of each log line - output
769769
CString m_strLogLinePostambleInput; // put at end of each log line - input
770-
CString m_strLogLinePostambleNotes; // put at end of each log line - world.note
770+
CString m_strLogLinePostambleNotes; // put at end of each log line - world.Note
771771
CString m_strMappingFailure; // message for mapping failure
772772

773773
// callback routines for MXP
@@ -861,6 +861,19 @@ class CMUSHclientDoc : public CDocument
861861
unsigned short m_bPlaySoundsInBackground; // if true, PlaySound uses a global sound buffer
862862

863863

864+
// version 4.62
865+
866+
CString m_strOutputLinePreambleOutput; // put at start of each output line - MUD output
867+
CString m_strOutputLinePreambleInput; // put at start of each output line - input
868+
CString m_strOutputLinePreambleNotes; // put at start of each output line - world.Note
869+
870+
COLORREF m_OutputLinePreambleOutputTextColour; // text colour - MUD output preamble
871+
COLORREF m_OutputLinePreambleOutputBackColour; // back colour - MUD output preamble
872+
COLORREF m_OutputLinePreambleInputTextColour; // text colour - input preamble
873+
COLORREF m_OutputLinePreambleInputBackColour; // back colour - input preamble
874+
COLORREF m_OutputLinePreambleNotesTextColour; // text colour - Note preamble
875+
COLORREF m_OutputLinePreambleNotesBackColour; // back colour - Note preamble
876+
864877
// end of stuff saved to disk **************************************************************
865878

866879
// stuff from pre version 11, read from disk but not saved
@@ -1074,7 +1087,7 @@ class CMUSHclientDoc : public CDocument
10741087
COLORREF m_iForeColour; // RGB foreground colour, or ANSI/custom colour number
10751088
COLORREF m_iBackColour; // RGB background colour, or ANSI/custom colour number
10761089

1077-
bool m_bNotesInRGB; // are notes in RGB mode? (ie. world.note, world.tell)
1090+
bool m_bNotesInRGB; // are notes in RGB mode? (ie. world.Note, world.Tell)
10781091
COLORREF m_iNoteColourFore; // RGB notes text colour
10791092
COLORREF m_iNoteColourBack; // RGB notes background colour
10801093
unsigned short m_iNoteStyle; // notes style: HILITE, UNDERLINE, BLINK, INVERSE

mushview.cpp

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,10 @@ int iUnicodeCharacters = 0;
506506
pDoc->m_iPixelOffset + pixel + textsize.cx,
507507
- pDoc->m_iPixelOffset + (line + 1) * pDoc->m_FontHeight);
508508

509+
// allow for scroll position
509510
OffsetRect (&r, -m_scroll_position.x, -m_scroll_position.y);
510-
511+
512+
// allow for text rectangle
511513
OffsetRect (&r, pDoc->m_TextRectangle.left, pDoc->m_TextRectangle.top);
512514

513515
if (bBackground)
@@ -525,23 +527,23 @@ int iUnicodeCharacters = 0;
525527
{
526528
if (pDoc->m_bUTF_8) // Unicode output
527529
ExtTextOutW( // W = wide
528-
pDC->m_hDC,
529-
r.left, // pDoc->m_iPixelOffset + pixel - m_scroll_position.x,
530-
r.top, // - pDoc->m_iPixelOffset + line * pDoc->m_FontHeight - m_scroll_position.y,
531-
0, // transparent
532-
&r,
533-
sUnicodeText,
534-
iUnicodeCharacters,
535-
NULL);
530+
pDC->m_hDC,
531+
r.left,
532+
r.top,
533+
0, // transparent
534+
&r,
535+
sUnicodeText,
536+
iUnicodeCharacters,
537+
NULL);
536538
else // Ascii output
537539
pDC->ExtTextOut (
538-
r.left, // pDoc->m_iPixelOffset + pixel - m_scroll_position.x,
539-
r.top, //- pDoc->m_iPixelOffset + line * pDoc->m_FontHeight - m_scroll_position.y,
540-
0, // transparent
541-
&r,
542-
&pLine->text [thiscol],
543-
thislen,
544-
NULL);
540+
r.left,
541+
r.top,
542+
0, // transparent
543+
&r,
544+
&pLine->text [thiscol],
545+
thislen,
546+
NULL);
545547

546548
}
547549
thiscol += thislen;
@@ -1077,6 +1079,77 @@ COLORREF iBackColour = BLACK;
10771079

10781080
pixel = 0;
10791081

1082+
// line preamble - version 4.62
1083+
1084+
CString strPreamble;
1085+
COLORREF cPreambleText,
1086+
cPreambleBack;
1087+
1088+
// get appropriate preamble text, and colours, depending on line type
1089+
if (pLine->flags & COMMENT)
1090+
{
1091+
strPreamble = pDoc->m_strOutputLinePreambleNotes;
1092+
cPreambleText = pDoc->m_OutputLinePreambleNotesTextColour;
1093+
cPreambleBack = pDoc->m_OutputLinePreambleNotesBackColour;
1094+
}
1095+
else if (pLine->flags & USER_INPUT)
1096+
{
1097+
strPreamble = pDoc->m_strOutputLinePreambleInput;
1098+
cPreambleText = pDoc->m_OutputLinePreambleInputTextColour;
1099+
cPreambleBack = pDoc->m_OutputLinePreambleInputBackColour;
1100+
}
1101+
else
1102+
{
1103+
strPreamble = pDoc->m_strOutputLinePreambleOutput;
1104+
cPreambleText = pDoc->m_OutputLinePreambleOutputTextColour;
1105+
cPreambleBack = pDoc->m_OutputLinePreambleOutputBackColour;
1106+
}
1107+
1108+
// if not empty, do the work of drawing it
1109+
if (!strPreamble.IsEmpty ())
1110+
{
1111+
// convert codes like %H:%M:%S
1112+
strPreamble = pDoc->FormatTime (pLine->m_theTime, strPreamble, false);
1113+
1114+
// get plain font
1115+
pDC->SelectObject(pDoc->m_font [0]);
1116+
1117+
// find how big, so we can fill the background
1118+
1119+
RECT r;
1120+
CSize textsize = pDC->GetTextExtent (strPreamble, strPreamble.GetLength ());
1121+
1122+
// offsetting per above (in display_text)
1123+
SetRect (&r,
1124+
pDoc->m_iPixelOffset + pixel,
1125+
- pDoc->m_iPixelOffset + line * pDoc->m_FontHeight,
1126+
pDoc->m_iPixelOffset + pixel + textsize.cx,
1127+
- pDoc->m_iPixelOffset + (line + 1) * pDoc->m_FontHeight);
1128+
1129+
// allow for scroll position
1130+
OffsetRect (&r, -m_scroll_position.x, -m_scroll_position.y);
1131+
1132+
// allow for text rectangle
1133+
OffsetRect (&r, pDoc->m_TextRectangle.left, pDoc->m_TextRectangle.top);
1134+
1135+
// now draw preamble (background/text)
1136+
if (bBackground)
1137+
pDC->FillSolidRect (&r, pDoc->TranslateColour (cPreambleBack));
1138+
else
1139+
{
1140+
pDC->SetTextColor (pDoc->TranslateColour (cPreambleText));
1141+
pDC->ExtTextOut (r.left,
1142+
r.top,
1143+
0,
1144+
&r,
1145+
strPreamble,
1146+
strPreamble.GetLength (),
1147+
NULL);
1148+
}
1149+
pixel += textsize.cx; // start rest of line further over
1150+
1151+
}
1152+
10801153
// show the selection in a different colour
10811154

10821155
if (line == m_selstart_line && m_selstart_line == m_selend_line)

scriptingoptions.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ tConfigurationNumericOption OptionsTable [] = {
147147
{"output_font_height", 12, O(m_font_height), 1, 1000, OPT_UPDATE_VIEWS | OPT_UPDATE_OUTPUT_FONT},
148148
{"output_font_weight", FW_DONTCARE, O(m_font_weight), 0, 1000, OPT_UPDATE_VIEWS | OPT_UPDATE_OUTPUT_FONT},
149149
{"output_font_charset", DEFAULT_CHARSET, O(m_font_charset), 0, 65536, OPT_UPDATE_VIEWS | OPT_UPDATE_OUTPUT_FONT},
150+
{"output_line_preamble_input_text_colour", RGB (255, 255, 255), O(m_OutputLinePreambleInputTextColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
151+
{"output_line_preamble_notes_text_colour", RGB (255, 255, 255), O(m_OutputLinePreambleNotesTextColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
152+
{"output_line_preamble_output_text_colour", RGB (255, 255, 255), O(m_OutputLinePreambleOutputTextColour),0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
153+
{"output_line_preamble_input_back_colour", RGB (0, 0, 0), O(m_OutputLinePreambleInputBackColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
154+
{"output_line_preamble_notes_back_colour", RGB (0, 0, 0), O(m_OutputLinePreambleNotesBackColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
155+
{"output_line_preamble_output_back_colour", RGB (0, 0, 0), O(m_OutputLinePreambleOutputBackColour),0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
150156
{"paste_commented_softcode", false, O(m_bPasteCommentedSoftcode)},
151157
{"paste_delay", 0, O(m_nPasteDelay), 0, 100000},
152158
{"paste_delay_per_lines", 1, O(m_nPasteDelayPerLines), 1, 100000},
@@ -252,6 +258,9 @@ tConfigurationAlphaOption AlphaOptionsTable [] =
252258
{"on_world_lose_focus", "", A(m_strWorldLoseFocus)},
253259
{"on_world_open", "", A(m_strWorldOpen)},
254260
{"output_font_name", "FixedSys", A(m_font_name), OPT_UPDATE_OUTPUT_FONT},
261+
{"output_line_preamble_input", "", A(m_strOutputLinePreambleInput), OPT_KEEP_SPACES},
262+
{"output_line_preamble_notes", "", A(m_strOutputLinePreambleNotes), OPT_KEEP_SPACES},
263+
{"output_line_preamble_output", "", A(m_strOutputLinePreambleOutput), OPT_KEEP_SPACES},
255264
{"password", "", A(m_password), OPT_PASSWORD | OPT_PLUGIN_CANNOT_RW},
256265
{"paste_line_postamble", "", A(m_pasteline_postamble), OPT_KEEP_SPACES},
257266
{"paste_line_preamble", "", A(m_pasteline_preamble), OPT_KEEP_SPACES},

0 commit comments

Comments
 (0)