Skip to content

Commit

Permalink
Added stuff for output window line preamble
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Sep 25, 2010
1 parent eae4020 commit 549e662
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 19 deletions.
19 changes: 16 additions & 3 deletions doc.h
Expand Up @@ -722,7 +722,7 @@ class CMUSHclientDoc : public CDocument
CString m_strAutoLogFileName; // name of file to log to
CString m_strLogLinePreambleOutput; // put at start of each log line - output
CString m_strLogLinePreambleInput; // put at start of each log line - input
CString m_strLogLinePreambleNotes; // put at start of each log line - world.note
CString m_strLogLinePreambleNotes; // put at start of each log line - world.Note
CString m_strWorldGetFocus; // script called when the world gets the focus
CString m_strWorldLoseFocus; // script called when the world loses the focus
CString m_strLogFilePostamble; // written when log file closed
Expand Down Expand Up @@ -767,7 +767,7 @@ class CMUSHclientDoc : public CDocument

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

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


// version 4.62

CString m_strOutputLinePreambleOutput; // put at start of each output line - MUD output
CString m_strOutputLinePreambleInput; // put at start of each output line - input
CString m_strOutputLinePreambleNotes; // put at start of each output line - world.Note

COLORREF m_OutputLinePreambleOutputTextColour; // text colour - MUD output preamble
COLORREF m_OutputLinePreambleOutputBackColour; // back colour - MUD output preamble
COLORREF m_OutputLinePreambleInputTextColour; // text colour - input preamble
COLORREF m_OutputLinePreambleInputBackColour; // back colour - input preamble
COLORREF m_OutputLinePreambleNotesTextColour; // text colour - Note preamble
COLORREF m_OutputLinePreambleNotesBackColour; // back colour - Note preamble

// end of stuff saved to disk **************************************************************

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

bool m_bNotesInRGB; // are notes in RGB mode? (ie. world.note, world.tell)
bool m_bNotesInRGB; // are notes in RGB mode? (ie. world.Note, world.Tell)
COLORREF m_iNoteColourFore; // RGB notes text colour
COLORREF m_iNoteColourBack; // RGB notes background colour
unsigned short m_iNoteStyle; // notes style: HILITE, UNDERLINE, BLINK, INVERSE
Expand Down
105 changes: 89 additions & 16 deletions mushview.cpp
Expand Up @@ -506,8 +506,10 @@ int iUnicodeCharacters = 0;
pDoc->m_iPixelOffset + pixel + textsize.cx,
- pDoc->m_iPixelOffset + (line + 1) * pDoc->m_FontHeight);

// allow for scroll position
OffsetRect (&r, -m_scroll_position.x, -m_scroll_position.y);


// allow for text rectangle
OffsetRect (&r, pDoc->m_TextRectangle.left, pDoc->m_TextRectangle.top);

if (bBackground)
Expand All @@ -525,23 +527,23 @@ int iUnicodeCharacters = 0;
{
if (pDoc->m_bUTF_8) // Unicode output
ExtTextOutW( // W = wide
pDC->m_hDC,
r.left, // pDoc->m_iPixelOffset + pixel - m_scroll_position.x,
r.top, // - pDoc->m_iPixelOffset + line * pDoc->m_FontHeight - m_scroll_position.y,
0, // transparent
&r,
sUnicodeText,
iUnicodeCharacters,
NULL);
pDC->m_hDC,
r.left,
r.top,
0, // transparent
&r,
sUnicodeText,
iUnicodeCharacters,
NULL);
else // Ascii output
pDC->ExtTextOut (
r.left, // pDoc->m_iPixelOffset + pixel - m_scroll_position.x,
r.top, //- pDoc->m_iPixelOffset + line * pDoc->m_FontHeight - m_scroll_position.y,
0, // transparent
&r,
&pLine->text [thiscol],
thislen,
NULL);
r.left,
r.top,
0, // transparent
&r,
&pLine->text [thiscol],
thislen,
NULL);

}
thiscol += thislen;
Expand Down Expand Up @@ -1077,6 +1079,77 @@ COLORREF iBackColour = BLACK;

pixel = 0;

// line preamble - version 4.62

CString strPreamble;
COLORREF cPreambleText,
cPreambleBack;

// get appropriate preamble text, and colours, depending on line type
if (pLine->flags & COMMENT)
{
strPreamble = pDoc->m_strOutputLinePreambleNotes;
cPreambleText = pDoc->m_OutputLinePreambleNotesTextColour;
cPreambleBack = pDoc->m_OutputLinePreambleNotesBackColour;
}
else if (pLine->flags & USER_INPUT)
{
strPreamble = pDoc->m_strOutputLinePreambleInput;
cPreambleText = pDoc->m_OutputLinePreambleInputTextColour;
cPreambleBack = pDoc->m_OutputLinePreambleInputBackColour;
}
else
{
strPreamble = pDoc->m_strOutputLinePreambleOutput;
cPreambleText = pDoc->m_OutputLinePreambleOutputTextColour;
cPreambleBack = pDoc->m_OutputLinePreambleOutputBackColour;
}

// if not empty, do the work of drawing it
if (!strPreamble.IsEmpty ())
{
// convert codes like %H:%M:%S
strPreamble = pDoc->FormatTime (pLine->m_theTime, strPreamble, false);

// get plain font
pDC->SelectObject(pDoc->m_font [0]);

// find how big, so we can fill the background

RECT r;
CSize textsize = pDC->GetTextExtent (strPreamble, strPreamble.GetLength ());

// offsetting per above (in display_text)
SetRect (&r,
pDoc->m_iPixelOffset + pixel,
- pDoc->m_iPixelOffset + line * pDoc->m_FontHeight,
pDoc->m_iPixelOffset + pixel + textsize.cx,
- pDoc->m_iPixelOffset + (line + 1) * pDoc->m_FontHeight);

// allow for scroll position
OffsetRect (&r, -m_scroll_position.x, -m_scroll_position.y);

// allow for text rectangle
OffsetRect (&r, pDoc->m_TextRectangle.left, pDoc->m_TextRectangle.top);

// now draw preamble (background/text)
if (bBackground)
pDC->FillSolidRect (&r, pDoc->TranslateColour (cPreambleBack));
else
{
pDC->SetTextColor (pDoc->TranslateColour (cPreambleText));
pDC->ExtTextOut (r.left,
r.top,
0,
&r,
strPreamble,
strPreamble.GetLength (),
NULL);
}
pixel += textsize.cx; // start rest of line further over

}

// show the selection in a different colour

if (line == m_selstart_line && m_selstart_line == m_selend_line)
Expand Down
9 changes: 9 additions & 0 deletions scriptingoptions.cpp
Expand Up @@ -147,6 +147,12 @@ tConfigurationNumericOption OptionsTable [] = {
{"output_font_height", 12, O(m_font_height), 1, 1000, OPT_UPDATE_VIEWS | OPT_UPDATE_OUTPUT_FONT},
{"output_font_weight", FW_DONTCARE, O(m_font_weight), 0, 1000, OPT_UPDATE_VIEWS | OPT_UPDATE_OUTPUT_FONT},
{"output_font_charset", DEFAULT_CHARSET, O(m_font_charset), 0, 65536, OPT_UPDATE_VIEWS | OPT_UPDATE_OUTPUT_FONT},
{"output_line_preamble_input_text_colour", RGB (255, 255, 255), O(m_OutputLinePreambleInputTextColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
{"output_line_preamble_notes_text_colour", RGB (255, 255, 255), O(m_OutputLinePreambleNotesTextColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
{"output_line_preamble_output_text_colour", RGB (255, 255, 255), O(m_OutputLinePreambleOutputTextColour),0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
{"output_line_preamble_input_back_colour", RGB (0, 0, 0), O(m_OutputLinePreambleInputBackColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
{"output_line_preamble_notes_back_colour", RGB (0, 0, 0), O(m_OutputLinePreambleNotesBackColour), 0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
{"output_line_preamble_output_back_colour", RGB (0, 0, 0), O(m_OutputLinePreambleOutputBackColour),0, 0xFFFFFF, OPT_RGB_COLOUR | OPT_UPDATE_VIEWS},
{"paste_commented_softcode", false, O(m_bPasteCommentedSoftcode)},
{"paste_delay", 0, O(m_nPasteDelay), 0, 100000},
{"paste_delay_per_lines", 1, O(m_nPasteDelayPerLines), 1, 100000},
Expand Down Expand Up @@ -252,6 +258,9 @@ tConfigurationAlphaOption AlphaOptionsTable [] =
{"on_world_lose_focus", "", A(m_strWorldLoseFocus)},
{"on_world_open", "", A(m_strWorldOpen)},
{"output_font_name", "FixedSys", A(m_font_name), OPT_UPDATE_OUTPUT_FONT},
{"output_line_preamble_input", "", A(m_strOutputLinePreambleInput), OPT_KEEP_SPACES},
{"output_line_preamble_notes", "", A(m_strOutputLinePreambleNotes), OPT_KEEP_SPACES},
{"output_line_preamble_output", "", A(m_strOutputLinePreambleOutput), OPT_KEEP_SPACES},
{"password", "", A(m_password), OPT_PASSWORD | OPT_PLUGIN_CANNOT_RW},
{"paste_line_postamble", "", A(m_pasteline_postamble), OPT_KEEP_SPACES},
{"paste_line_preamble", "", A(m_pasteline_preamble), OPT_KEEP_SPACES},
Expand Down

0 comments on commit 549e662

Please sign in to comment.