Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/iclog rewrite #259

Merged
merged 8 commits into from Aug 19, 2020
9 changes: 9 additions & 0 deletions include/aoapplication.h
Expand Up @@ -213,6 +213,15 @@ class AOApplication : public QApplication {
// or downwards (vanilla behaviour).
bool get_log_goes_downwards();

// Returns whether the log should separate name from text via newline or :
bool get_log_newline();

// Get spacing between IC log entries.
int get_log_margin();

// Returns whether the log should have a timestamp.
bool get_log_timestamp();

// Returns the username the user may have set in config.ini.
QString get_default_username();

Expand Down
6 changes: 6 additions & 0 deletions include/aooptionsdialog.h
Expand Up @@ -46,6 +46,12 @@ class AOOptionsDialog : public QDialog {
QCheckBox *ui_downwards_cb;
QLabel *ui_length_lbl;
QSpinBox *ui_length_spinbox;
QLabel *ui_log_newline_lbl;
QCheckBox *ui_log_newline_cb;
QLabel *ui_log_margin_lbl;
QSpinBox *ui_log_margin_spinbox;
QLabel *ui_log_timestamp_lbl;
QCheckBox *ui_log_timestamp_cb;
QFrame *ui_log_names_divider;
QLineEdit *ui_username_textbox;
QLabel *ui_username_lbl;
Expand Down
8 changes: 4 additions & 4 deletions include/chatlogpiece.h
Expand Up @@ -10,14 +10,14 @@ class chatlogpiece {
public:
chatlogpiece();
chatlogpiece(QString p_name, QString p_showname, QString p_message,
bool p_song,int color);
QString p_action,int color);
chatlogpiece(QString p_name, QString p_showname, QString p_message,
bool p_song, int color, QDateTime p_datetime);
QString p_action, int color, QDateTime p_datetime);

QString get_name();
QString get_showname();
QString get_message();
bool is_song();
QString get_action();
QDateTime get_datetime();
QString get_datetime_as_string();
int get_chat_color();
Expand All @@ -27,9 +27,9 @@ class chatlogpiece {
QString name;
QString showname;
QString message;
QString action;
QDateTime datetime;
int color;
bool p_is_song;
};

#endif // CHATLOGPIECE_H
17 changes: 15 additions & 2 deletions include/courtroom.h
Expand Up @@ -262,7 +262,6 @@ class Courtroom : public QMainWindow {
int m_viewport_width = 256;
int m_viewport_height = 192;

bool first_message_sent = false;
int maximumMessages = 0;

QParallelAnimationGroup *screenshake_animation_group =
Expand Down Expand Up @@ -319,7 +318,19 @@ class Courtroom : public QMainWindow {
int log_maximum_blocks = 0;

// True, if the log should go downwards.
bool log_goes_downwards = false;
bool log_goes_downwards = true;

// True, if log should display colors.
bool log_colors = true;

// True, if the log should display the message like name<br>text instead of name: text
bool log_newline = false;

// Margin in pixels between log entries for the IC log.
int log_margin = 0;

// True, if the log should have a timestamp.
bool log_timestamp = false;

// delay before chat messages starts ticking
QTimer *text_delay_timer;
Expand Down Expand Up @@ -649,6 +660,8 @@ class Courtroom : public QMainWindow {

void reset_ic();
void reset_ui();

void regenerate_ic_chatlog();
public slots:
void objection_done();
void preanim_done();
Expand Down
46 changes: 46 additions & 0 deletions src/aooptionsdialog.cpp
Expand Up @@ -120,6 +120,49 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)

ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_length_spinbox);

row += 1;
ui_log_newline_lbl = new QLabel(ui_form_layout_widget);
ui_log_newline_lbl->setText(tr("Log newline:"));
ui_log_newline_lbl->setToolTip(
tr("If ticked, new messages will appear separated, "
"with the message coming on the next line after the name. "
"When unticked, it displays it as 'name: message'."));

ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_newline_lbl);

ui_log_newline_cb = new QCheckBox(ui_form_layout_widget);
ui_log_newline_cb->setChecked(p_ao_app->get_log_newline());

ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_newline_cb);

row += 1;
ui_log_margin_lbl = new QLabel(ui_form_layout_widget);
ui_log_margin_lbl->setText(tr("Log margin:"));
ui_log_margin_lbl->setToolTip(tr(
"The distance in pixels between each entry in the IC log. "
"Default: 0."));

ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_margin_lbl);

ui_log_margin_spinbox = new QSpinBox(ui_form_layout_widget);
ui_log_margin_spinbox->setMaximum(1000);
ui_log_margin_spinbox->setValue(p_ao_app->get_log_margin());

ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_margin_spinbox);

row += 1;
ui_log_timestamp_lbl = new QLabel(ui_form_layout_widget);
ui_log_timestamp_lbl->setText(tr("Log timestamp:"));
ui_log_timestamp_lbl->setToolTip(
tr("If ticked, log will contain a timestamp in UTC before the name."));

ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_timestamp_lbl);

ui_log_timestamp_cb = new QCheckBox(ui_form_layout_widget);
ui_log_timestamp_cb->setChecked(p_ao_app->get_log_timestamp());

ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_cb);

row += 1;
ui_log_names_divider = new QFrame(ui_form_layout_widget);
ui_log_names_divider->setFrameShape(QFrame::HLine);
Expand Down Expand Up @@ -726,6 +769,9 @@ void AOOptionsDialog::save_pressed()
configini->setValue("theme", ui_theme_combobox->currentText());
configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked());
configini->setValue("log_maximum", ui_length_spinbox->value());
configini->setValue("log_newline", ui_log_newline_cb->isChecked());
configini->setValue("log_margin", ui_log_margin_spinbox->value());
configini->setValue("log_timestamp", ui_log_timestamp_cb->isChecked());
configini->setValue("default_username", ui_username_textbox->text());
configini->setValue("show_custom_shownames", ui_showname_cb->isChecked());
configini->setValue("master", ui_ms_textbox->text());
Expand Down
28 changes: 15 additions & 13 deletions src/chatlogpiece.cpp
Expand Up @@ -6,29 +6,29 @@ chatlogpiece::chatlogpiece()
showname = tr("UNKNOWN");
message = tr("UNKNOWN");
color = 0;
p_is_song = false;
action = "";
datetime = QDateTime::currentDateTime().toUTC();
}

chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
QString p_message, bool p_song, int p_color)
QString p_message, QString p_action, int p_color)
{
name = p_name;
showname = p_showname;
message = p_message;
p_is_song = p_song;
action = p_action;
color = p_color;
datetime = QDateTime::currentDateTime().toUTC();
}

chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
QString p_message, bool p_song, int p_color,
QString p_message, QString p_action, int p_color,
QDateTime p_datetime)
{
name = p_name;
showname = p_showname;
message = p_message;
p_is_song = p_song;
action = p_action;
color = p_color;
datetime = p_datetime.toUTC();
}
Expand All @@ -41,7 +41,7 @@ QString chatlogpiece::get_message() { return message; }

QDateTime chatlogpiece::get_datetime() { return datetime; }

bool chatlogpiece::is_song() { return p_is_song; }
QString chatlogpiece::get_action() { return action; }

QString chatlogpiece::get_datetime_as_string() { return datetime.toString(); }

Expand All @@ -54,13 +54,15 @@ QString chatlogpiece::get_full()
full.append(get_datetime_as_string());
full.append("] ");
full.append(get_showname());
full.append(" (");
full.append(get_name());
full.append(")");
if (p_is_song)
full.append(tr(" has played a song: "));
else
full.append(": ");
if (get_showname() != get_name())
{
full.append(" (");
full.append(get_name());
full.append(")");
}
if (!get_action().isEmpty())
full.append(" " + get_action());
full.append(": ");
full.append(get_message());

return full;
Expand Down