From edaba46087a5d5adf8623ecd9b3cfa16b0ea0de5 Mon Sep 17 00:00:00 2001 From: uruk Date: Fri, 28 Jun 2013 18:25:28 +0200 Subject: AVALANCHE: Logger: replace namespace with class. --- engines/avalanche/logger2.cpp | 389 +++++++++++++++++++++--------------------- engines/avalanche/logger2.h | 30 +++- 2 files changed, 223 insertions(+), 196 deletions(-) (limited to 'engines/avalanche') diff --git a/engines/avalanche/logger2.cpp b/engines/avalanche/logger2.cpp index 24582a4e6c..09643f766a 100644 --- a/engines/avalanche/logger2.cpp +++ b/engines/avalanche/logger2.cpp @@ -25,235 +25,238 @@ * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. */ +/* LOGGER Handles the logging. */ + #include "avalanche/logger2.h" #include "avalanche/gyro2.h" +#include "avalanche/avalanche.h" //#include "avalanche/trip6.h" #include "common/system.h" #include "common/textconsole.h" namespace Avalanche { +const char Logger::divide[] = "--- oOo ---"; - namespace Logger { - - const char divide[] = "--- oOo ---"; - - /* Epson codes: - - startwith=''; - endwith=''; - double_width = #14; { shift out (SO) } - double_off = #20; { device control 4 (DC4) } - italic = #27+'4'; { switches italics on... } - italic_off = #27+'5'; { and off. } - emph_on = #27+#69; - emph_off = #27+#70; - divide_indent = 15; - - */ - - /* L'jet codes: */ - - //// Not sure if these will be needed at all... - // - //const Common::String startwith = Common::String('\33') + '\50' + "10J" + '\130'; - //const Common::String endwith = Common::String('\33') + '\105'; - //const Common::String italic = Common::String('\33') + '\50' + '\163' + '\61' + '\123'; /* switches italics on... */ - //const Common::String italic_off = Common::String('\33') + '\50' + '\163' + '\60' + '\123'; /* and off. */ - //const Common::String emph_on = Common::String('\33') + '\50' + '\163' + '\63' + '\102'; - //const Common::String emph_off = Common::String('\33') + '\50' + '\163' + '\60' + '\102'; - // - //const Common::String double_width = emph_on; /* There IS no double-width. */ - //const Common::String double_off = emph_off; /* So we'll have to use bold. */ - - - const Common::String quote = "ª"; - const Common::String unquote = "º"; - const Common::String copyright = "(c)"; - const int16 divide_indent = 30; - - Common::String scroll_line; - byte scroll_line_length; - - void centre(byte size, byte x) { /* Prints req'd number of spaces. */ - byte fv; - if (! Gyro::logging) return; - - warning("STUB: Logger::centre()"); - /*for (fv = 1; fv <= size - (x / 2); fv ++) - output << logfile << ' ';*/ - } - - void log_setup(Common::String name, bool printing) { /* Sets up. */ - - warning("STUB: Logger::log_setup()"); - - /* assign(logfile, name); - rewrite(logfile); - output << logfile << startwith; - log_epson = printing; - logging = true; - - if (! printing) { - quote = '"'; - unquote = '"'; - copyright = "(c)"; - }*/ - } - - void log_divider() { /* Prints the divider sign. */ - byte fv; - if (! Gyro::logging) return; - - warning("STUB: Logger::log_divider()"); - - /*if (Gyro::log_epson) { - output << logfile << Common::String(' ') + double_width; - for (fv = 1; fv <= divide_indent; fv ++) output << logfile << ' '; - output << logfile << Common::String(' ') + double_off; - } else - for (fv = 1; fv <= 36; fv ++) output << logfile << ' '; - output << logfile << divide << NL;*/ - } - - void log_command(Common::String x) { /* Prints a command */ - if (! Gyro::logging) return; - - warning("STUB: Logger::log_command()"); - - /*if (Gyro::log_epson) - output << logfile << double_width + '>' + double_off + ' ' + italic + x + italic_off << NL; - else - output << logfile << Common::String("> ") + x << NL;*/ +/* Epson codes: + + startwith=''; + endwith=''; + double_width = #14; { shift out (SO) } + double_off = #20; { device control 4 (DC4) } + italic = #27+'4'; { switches italics on... } + italic_off = #27+'5'; { and off. } + emph_on = #27+#69; + emph_off = #27+#70; + divide_indent = 15; + +*/ + +/* L'jet codes: */ + +//// Not sure if these will be needed at all... +// +//const Common::String startwith = Common::String('\33') + '\50' + "10J" + '\130'; +//const Common::String endwith = Common::String('\33') + '\105'; +//const Common::String italic = Common::String('\33') + '\50' + '\163' + '\61' + '\123'; /* switches italics on... */ +//const Common::String italic_off = Common::String('\33') + '\50' + '\163' + '\60' + '\123'; /* and off. */ +//const Common::String emph_on = Common::String('\33') + '\50' + '\163' + '\63' + '\102'; +//const Common::String emph_off = Common::String('\33') + '\50' + '\163' + '\60' + '\102'; +// +//const Common::String double_width = emph_on; /* There IS no double-width. */ +//const Common::String double_off = emph_off; /* So we'll have to use bold. */ + + + +const Common::String Logger::quote = "ª"; +const Common::String Logger::unquote = "º"; +const Common::String Logger::copyright = "(c)"; +const int16 Logger::divide_indent = 30; + + + +void Logger::setParent(AvalancheEngine *vm) { + _vm = vm; +} + +void Logger::centre(byte size, byte x) { /* Prints req'd number of spaces. */ + byte fv; + + if (! _vm->_gyro.logging) return; + + warning("STUB: Logger::centre()"); + /*for (fv = 1; fv <= size - (x / 2); fv ++) + output << logfile << ' ';*/ +} + +void Logger::log_setup(Common::String name, bool printing) { /* Sets up. */ + + warning("STUB: Logger::log_setup()"); + + /* assign(logfile, name); + rewrite(logfile); + output << logfile << startwith; + log_epson = printing; + logging = true; + + if (! printing) { + quote = '"'; + unquote = '"'; + copyright = "(c)"; + }*/ +} + +void Logger::log_divider() { /* Prints the divider sign. */ + byte fv; + if (! _vm->_gyro.logging) return; + + warning("STUB: Logger::log_divider()"); + + /*if (_vm->_gyro.log_epson) { + output << logfile << Common::String(' ') + double_width; + for (fv = 1; fv <= divide_indent; fv ++) output << logfile << ' '; + output << logfile << Common::String(' ') + double_off; + } else + for (fv = 1; fv <= 36; fv ++) output << logfile << ' '; + output << logfile << divide << NL;*/ +} + +void Logger::log_command(Common::String x) { /* Prints a command */ + if (! _vm->_gyro.logging) return; + + warning("STUB: Logger::log_command()"); + + /*if (_vm->_gyro.log_epson) + output << logfile << double_width + '>' + double_off + ' ' + italic + x + italic_off << NL; + else + output << logfile << Common::String("> ") + x << NL;*/ +} + +void Logger::log_addstuff(Common::String x) { + if (! _vm->_gyro.logging) return; + scroll_line += x; +} + +void Logger::log_scrollchar(Common::String x) { /* print one character */ + Common::String z; + if (! _vm->_gyro.logging) return; + switch (x[1]) { + case '`': + z = quote; + break; /* Open quotes: "66" */ + case '"': + z = unquote; + break; /* Close quotes: "99" */ + case '\357': + z = copyright; + break; /* Copyright sign. */ + default: + z = x; } + log_addstuff(z); + scroll_line_length += z.size(); +} - void log_addstuff(Common::String x) { - if (! Gyro::logging) return; - scroll_line += x; - } - - void log_scrollchar(Common::String x) { /* print one character */ - Common::String z; - if (! Gyro::logging) return; - switch (x[1]) { - case '`': - z = quote; - break; /* Open quotes: "66" */ - case '"': - z = unquote; - break; /* Close quotes: "99" */ - case '\357': - z = copyright; - break; /* Copyright sign. */ - default: - z = x; - } - log_addstuff(z); - scroll_line_length += z.size(); - } - - void log_italic() { - if (! Gyro::logging) return; - - warning("STUB: Logger::log_italic()"); +void Logger::log_italic() { + if (! _vm->_gyro.logging) return; - /*if (Gyro::log_epson) - log_addstuff(italic); - else - log_addstuff("*");*/ - } + warning("STUB: Logger::log_italic()"); - void log_roman() { - if (! Gyro::logging) return; + /*if (_vm->_gyro.log_epson) + log_addstuff(italic); + else + log_addstuff("*");*/ +} - warning("STUB: Logger::log_roman()"); +void Logger::log_roman() { + if (! _vm->_gyro.logging) return; - /* if (Gyro::log_epson) - log_addstuff(italic_off); - else - log_addstuff("*");*/ - } + warning("STUB: Logger::log_roman()"); - void log_epsonroman() { /* This only sends the Roman code if you're on Epson.*/ - if (! Gyro::logging) return; + /* if (_vm->_gyro.log_epson) + log_addstuff(italic_off); + else + log_addstuff("*");*/ +} - warning("STUB: Logger::log_epsonroman()"); +void Logger::log_epsonroman() { /* This only sends the Roman code if you're on Epson.*/ + if (! _vm->_gyro.logging) return; - //if (Gyro::log_epson) log_addstuff(italic_off); - } + warning("STUB: Logger::log_epsonroman()"); - void log_scrollline() { /* Set up a line for the scroll driver */ - scroll_line_length = 0; - scroll_line = ""; - } + //if (_vm->_gyro.log_epson) log_addstuff(italic_off); +} - void log_scrollendline(bool centred) { - byte x, fv; - if (! Gyro::logging) return; - x = 17; - if (centred) x += (50 - scroll_line_length) / 2; +void Logger::log_scrollline() { /* Set up a line for the scroll driver */ + scroll_line_length = 0; + scroll_line = ""; +} - warning("STUB: Logger::log_scrollendline()"); +void Logger::log_scrollendline(bool centred) { + byte x, fv; + if (! _vm->_gyro.logging) return; + x = 17; + if (centred) x += (50 - scroll_line_length) / 2; - /*for (fv = 1; fv <= x; fv ++) output << logfile << ' '; - output << logfile << scroll_line << NL;*/ - } + warning("STUB: Logger::log_scrollendline()"); - void log_bubbleline(byte linenum, byte whom, Common::String x) { - byte fv; - if (! Gyro::logging) return; + /*for (fv = 1; fv <= x; fv ++) output << logfile << ' '; + output << logfile << scroll_line << NL;*/ +} - warning("STUB: Logger::log_bubbleline()"); +void Logger::log_bubbleline(byte linenum, byte whom, Common::String x) { + byte fv; + if (! _vm->_gyro.logging) return; - /*if (linenum == 1) { - for (fv = 1; fv <= 15; fv ++) output << logfile << ' '; - output << logfile << italic + tr[whom].a.name + ": " + italic_off + x << NL; - } else { - for (fv = 1; fv <= 17; fv ++) output << logfile << ' '; - output << logfile << x << NL; - }*/ - } + warning("STUB: Logger::log_bubbleline()"); - void log_newline() { - warning("STUB: Logger::log_newline()"); + /*if (linenum == 1) { + for (fv = 1; fv <= 15; fv ++) output << logfile << ' '; + output << logfile << italic + tr[whom].a.name + ": " + italic_off + x << NL; + } else { + for (fv = 1; fv <= 17; fv ++) output << logfile << ' '; + output << logfile << x << NL; + }*/ +} - //if (Gyro::logging) output << logfile << NL; - } +void Logger::log_newline() { + warning("STUB: Logger::log_newline()"); - void log_newroom(Common::String where) { - byte fv; - if (! Gyro::logging) return; + //if (_vm->_gyro.logging) output << logfile << NL; +} - warning("STUB: Logger::log_newroom()"); +void Logger::log_newroom(Common::String where) { + byte fv; + if (! _vm->_gyro.logging) return; - /*for (fv = 1; fv <= 20; fv ++) output << logfile << ' '; - if (Gyro::log_epson) output << logfile << emph_on; - output << logfile << Common::String('(') + where + ')'; - if (Gyro::log_epson) output << logfile << emph_off; - output << logfile << NL;*/ - } + warning("STUB: Logger::log_newroom()"); - void log_aside(Common::String what) - /* This writes "asides" to the printer. For example, moves in Nim. */ - { - if (! Gyro::logging) return; + /*for (fv = 1; fv <= 20; fv ++) output << logfile << ' '; + if (_vm->_gyro.log_epson) output << logfile << emph_on; + output << logfile << Common::String('(') + where + ')'; + if (_vm->_gyro.log_epson) output << logfile << emph_off; + output << logfile << NL;*/ +} - warning("STUB: Logger::log_aside()"); +void Logger::log_aside(Common::String what) +/* This writes "asides" to the printer. For example, moves in Nim. */ +{ + if (! _vm->_gyro.logging) return; - //output << logfile << " (" << italic << what << italic_off << ')' << NL; - /* "What" is what to write. */ - } + warning("STUB: Logger::log_aside()"); - void log_score(uint16 credit, uint16 now) { - byte fv; - if (! Gyro::logging) return; + //output << logfile << " (" << italic << what << italic_off << ')' << NL; + /* "What" is what to write. */ +} - warning("STUB: Logger::log_score()"); +void Logger::log_score(uint16 credit, uint16 now) { + byte fv; + if (! _vm->_gyro.logging) return; - /*for (fv = 1; fv <= 50; fv ++) output << logfile << ' '; - output << logfile << "Score " << italic << "credit : " << credit << italic_off << " total : " << now << NL;*/ - } + warning("STUB: Logger::log_score()"); - } // End of namespace Logger + /*for (fv = 1; fv <= 50; fv ++) output << logfile << ' '; + output << logfile << "Score " << italic << "credit : " << credit << italic_off << " total : " << now << NL;*/ +} } // End of namespace Avalanche diff --git a/engines/avalanche/logger2.h b/engines/avalanche/logger2.h index a1b7882abf..bd54823495 100644 --- a/engines/avalanche/logger2.h +++ b/engines/avalanche/logger2.h @@ -25,14 +25,21 @@ * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. */ +/* LOGGER Handles the logging. */ + #ifndef LOGGER2_H #define LOGGER2_H -#include "common/system.h" +#include "common/scummsys.h" +#include "common/str.h" + namespace Avalanche { +class AvalancheEngine; - namespace Logger { +class Logger { +public: + void setParent(AvalancheEngine *vm); void log_setup(Common::String name, bool printing); @@ -62,7 +69,24 @@ namespace Avalanche { void log_score(uint16 credit, uint16 now); - } // End of namespace Logger +private: + AvalancheEngine *_vm; + + static const char divide[]; + + static const Common::String quote; + static const Common::String unquote; + static const Common::String copyright; + static const int16 divide_indent; + + Common::String scroll_line; + byte scroll_line_length; + + void centre(byte size, byte x); + + void log_addstuff(Common::String x); + +}; } // End of namespace Avalanche -- cgit v1.2.3