Merge pull request #38 from Cerapter/mega-merge-fixes

CC-original related feature fixes.
This commit is contained in:
oldmud0 2018-12-12 13:05:27 -06:00 committed by GitHub
commit d092691224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 146 deletions

View File

@ -40,13 +40,22 @@ void AOCharButton::reset()
ui_selector->hide(); ui_selector->hide();
} }
void AOCharButton::set_taken() void AOCharButton::set_taken(bool is_taken)
{
taken = is_taken;
}
void AOCharButton::apply_taken_image()
{ {
if (taken) if (taken)
{ {
ui_taken->move(0,0); ui_taken->move(0,0);
ui_taken->show(); ui_taken->show();
} }
else
{
ui_taken->hide();
}
} }
void AOCharButton::set_passworded() void AOCharButton::set_passworded()

View File

@ -20,9 +20,11 @@ public:
void refresh(); void refresh();
void reset(); void reset();
void set_taken(); void set_taken(bool is_taken);
void set_passworded(); void set_passworded();
void apply_taken_image();
void set_image(QString p_character); void set_image(QString p_character);
private: private:

View File

@ -39,10 +39,10 @@ void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme)
QString placeholder_path = ao_app->get_theme_path("placeholder.gif"); QString placeholder_path = ao_app->get_theme_path("placeholder.gif");
QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif"); QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif");
if (file_exists(misc_path)) if (file_exists(custom_path))
gif_path = misc_path;
else if (file_exists(custom_path))
gif_path = custom_path; gif_path = custom_path;
else if (file_exists(misc_path))
gif_path = misc_path;
else if (file_exists(custom_theme_path)) else if (file_exists(custom_theme_path))
gif_path = custom_theme_path; gif_path = custom_theme_path;
else if (file_exists(theme_path)) else if (file_exists(theme_path))

View File

@ -168,8 +168,7 @@ void Courtroom::put_button_in_place(int starting, int chars_on_this_page)
ui_char_button_list_filtered.at(n)->move(x_pos, y_pos); ui_char_button_list_filtered.at(n)->move(x_pos, y_pos);
ui_char_button_list_filtered.at(n)->show(); ui_char_button_list_filtered.at(n)->show();
ui_char_button_list_filtered.at(n)->apply_taken_image();
ui_char_button_list_filtered.at(n)->set_taken();
++x_mod_count; ++x_mod_count;
@ -240,6 +239,12 @@ void Courtroom::filter_character_list()
if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive))
continue; continue;
// We only really need to update the fact that a character is taken
// for the buttons that actually appear.
// You'd also update the passwordedness and etc. here later.
current_char->reset();
current_char->set_taken(char_list.at(i).taken);
ui_char_button_list_filtered.append(current_char); ui_char_button_list_filtered.append(current_char);
} }

View File

@ -1309,7 +1309,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
chatlogpiece* temp = new chatlogpiece(ao_app->get_showname(char_list.at(f_char_id).name), f_showname, ": " + m_chatmessage[MESSAGE], false); chatlogpiece* temp = new chatlogpiece(ao_app->get_showname(char_list.at(f_char_id).name), f_showname, ": " + m_chatmessage[MESSAGE], false);
ic_chatlog_history.append(*temp); ic_chatlog_history.append(*temp);
while(ic_chatlog_history.size() > log_maximum_blocks) while(ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0)
{ {
ic_chatlog_history.removeFirst(); ic_chatlog_history.removeFirst();
} }
@ -1565,13 +1565,13 @@ void Courtroom::handle_chatmessage_2()
switch (emote_mod) switch (emote_mod)
{ {
case 1: case 2: case 6: case 1: case 2: case 6:
play_preanim(); play_preanim(false);
break; break;
case 0: case 5: case 0: case 5:
if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0) if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0)
handle_chatmessage_3(); handle_chatmessage_3();
else else
play_noninterrupting_preanim(); play_preanim(true);
break; break;
default: default:
qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); qDebug() << "W: invalid emote mod: " << QString::number(emote_mod);
@ -1674,15 +1674,8 @@ void Courtroom::handle_chatmessage_3()
} }
void Courtroom::append_ic_text(QString p_text, QString p_name) QString Courtroom::filter_ic_text(QString p_text)
{ {
QTextCharFormat bold;
QTextCharFormat normal;
bold.setFontWeight(QFont::Bold);
normal.setFontWeight(QFont::Normal);
const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
// Get rid of centering. // Get rid of centering.
if(p_text.startsWith(": ~~")) if(p_text.startsWith(": ~~"))
{ {
@ -1815,85 +1808,10 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
} }
} }
// After all of that, let's jot down the message into the IC chatlog. return p_text;
if (log_goes_downwards)
{
const bool is_scrolled_down = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum();
ui_ic_chatlog->moveCursor(QTextCursor::End);
if (!first_message_sent)
{
ui_ic_chatlog->textCursor().insertText(p_name, bold);
first_message_sent = true;
}
else
{
ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold);
}
ui_ic_chatlog->textCursor().insertText(p_text, normal);
// If we got too many blocks in the current log, delete some from the top.
while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0)
{
ui_ic_chatlog->moveCursor(QTextCursor::Start);
ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
ui_ic_chatlog->textCursor().removeSelectedText();
ui_ic_chatlog->textCursor().deleteChar();
//qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
}
if (old_cursor.hasSelection() || !is_scrolled_down)
{
// The user has selected text or scrolled away from the bottom: maintain position.
ui_ic_chatlog->setTextCursor(old_cursor);
ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
}
else
{
// The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
ui_ic_chatlog->moveCursor(QTextCursor::End);
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->maximum());
}
}
else
{
const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum();
ui_ic_chatlog->moveCursor(QTextCursor::Start);
ui_ic_chatlog->textCursor().insertText(p_name, bold);
ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal);
// If we got too many blocks in the current log, delete some from the bottom.
while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0)
{
ui_ic_chatlog->moveCursor(QTextCursor::End);
ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
ui_ic_chatlog->textCursor().removeSelectedText();
ui_ic_chatlog->textCursor().deletePreviousChar();
//qDebug() << ui_ic_chatlog->document()->blockCount() << " < " << log_maximum_blocks;
}
if (old_cursor.hasSelection() || !is_scrolled_up)
{
// The user has selected text or scrolled away from the top: maintain position.
ui_ic_chatlog->setTextCursor(old_cursor);
ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
}
else
{
// The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
ui_ic_chatlog->moveCursor(QTextCursor::Start);
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
}
}
} }
// Call it ugly, call it a hack, but I wanted to do something special with the songname changes. void Courtroom::append_ic_text(QString p_text, QString p_name, bool is_songchange)
void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
{ {
QTextCharFormat bold; QTextCharFormat bold;
QTextCharFormat normal; QTextCharFormat normal;
@ -1904,6 +1822,9 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
if (!is_songchange)
p_text = filter_ic_text(p_text);
if (log_goes_downwards) if (log_goes_downwards)
{ {
const bool is_scrolled_down = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum(); const bool is_scrolled_down = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum();
@ -1920,8 +1841,15 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold); ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold);
} }
if (is_songchange)
{
ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal);
ui_ic_chatlog->textCursor().insertText(p_songname + ".", italics); ui_ic_chatlog->textCursor().insertText(p_text + ".", italics);
}
else
{
ui_ic_chatlog->textCursor().insertText(p_text, normal);
}
// If we got too many blocks in the current log, delete some from the top. // If we got too many blocks in the current log, delete some from the top.
while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0)
@ -1954,8 +1882,15 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
ui_ic_chatlog->textCursor().insertText(p_name, bold); ui_ic_chatlog->textCursor().insertText(p_name, bold);
if (is_songchange)
{
ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal); ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal);
ui_ic_chatlog->textCursor().insertText(p_songname + "." + '\n', italics); ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics);
}
else
{
ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal);
}
// If we got too many blocks in the current log, delete some from the bottom. // If we got too many blocks in the current log, delete some from the bottom.
while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0)
@ -1982,7 +1917,7 @@ void Courtroom::append_ic_songchange(QString p_songname, QString p_name)
} }
} }
void Courtroom::play_preanim() void Courtroom::play_preanim(bool noninterrupting)
{ {
QString f_char = m_chatmessage[CHAR_NAME]; QString f_char = m_chatmessage[CHAR_NAME];
QString f_preanim = m_chatmessage[PRE_EMOTE]; QString f_preanim = m_chatmessage[PRE_EMOTE];
@ -2004,52 +1939,26 @@ void Courtroom::play_preanim()
if (!file_exists(anim_to_find) || if (!file_exists(anim_to_find) ||
preanim_duration < 0) preanim_duration < 0)
{ {
anim_state = 1; if (noninterrupting)
preanim_done(); anim_state = 4;
qDebug() << "could not find " + anim_to_find;
return;
}
ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration);
anim_state = 1;
if (text_delay >= 0)
text_delay_timer->start(text_delay);
}
void Courtroom::play_noninterrupting_preanim()
{
QString f_char = m_chatmessage[CHAR_NAME];
QString f_preanim = m_chatmessage[PRE_EMOTE];
//all time values in char.inis are multiplied by a constant(time_mod) to get the actual time
int ao2_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim);
int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * 60;
int preanim_duration;
if (ao2_duration < 0)
preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
else else
preanim_duration = ao2_duration; anim_state = 1;
sfx_delay_timer->start(sfx_delay);
QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
if (!file_exists(anim_to_find) ||
preanim_duration < 0)
{
anim_state = 4;
preanim_done(); preanim_done();
qDebug() << "could not find " + anim_to_find; qDebug() << "could not find " + anim_to_find;
return; return;
} }
ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration); ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration);
if (noninterrupting)
anim_state = 4; anim_state = 4;
else
anim_state = 1;
if (text_delay >= 0) if (text_delay >= 0)
text_delay_timer->start(text_delay); text_delay_timer->start(text_delay);
if (noninterrupting)
handle_chatmessage_3(); handle_chatmessage_3();
} }
@ -2611,12 +2520,12 @@ void Courtroom::handle_song(QStringList *p_contents)
chatlogpiece* temp = new chatlogpiece(str_char, str_show, f_song, true); chatlogpiece* temp = new chatlogpiece(str_char, str_show, f_song, true);
ic_chatlog_history.append(*temp); ic_chatlog_history.append(*temp);
while(ic_chatlog_history.size() > log_maximum_blocks) while(ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0)
{ {
ic_chatlog_history.removeFirst(); ic_chatlog_history.removeFirst();
} }
append_ic_songchange(f_song_clear, str_show); append_ic_text(f_song_clear, str_show, true);
music_player->play(f_song); music_player->play(f_song);
} }
} }
@ -3476,14 +3385,14 @@ void Courtroom::on_showname_enable_clicked()
if (ui_showname_enable->isChecked()) if (ui_showname_enable->isChecked())
{ {
if (item.get_is_song()) if (item.get_is_song())
append_ic_songchange(item.get_message(), item.get_showname()); append_ic_text(item.get_message(), item.get_showname(), true);
else else
append_ic_text(item.get_message(), item.get_showname()); append_ic_text(item.get_message(), item.get_showname());
} }
else else
{ {
if (item.get_is_song()) if (item.get_is_song())
append_ic_songchange(item.get_message(), item.get_name()); append_ic_text(item.get_message(), item.get_name(), true);
else else
append_ic_text(item.get_message(), item.get_name()); append_ic_text(item.get_message(), item.get_name());
} }

View File

@ -179,20 +179,20 @@ public:
void handle_chatmessage_2(); void handle_chatmessage_2();
void handle_chatmessage_3(); void handle_chatmessage_3();
//This function filters out the common CC inline text trickery, for appending to
//the IC chatlog.
QString filter_ic_text(QString p_text);
//adds text to the IC chatlog. p_name first as bold then p_text then a newlin //adds text to the IC chatlog. p_name first as bold then p_text then a newlin
//this function keeps the chatlog scrolled to the top unless there's text selected //this function keeps the chatlog scrolled to the top unless there's text selected
// or the user isn't already scrolled to the top // or the user isn't already scrolled to the top
void append_ic_text(QString p_text, QString p_name = ""); void append_ic_text(QString p_text, QString p_name = "", bool is_songchange = false);
// This is essentially the same as the above, but specifically for song changes.
void append_ic_songchange(QString p_songname, QString p_name = "");
//prints who played the song to IC chat and plays said song(if found on local filesystem) //prints who played the song to IC chat and plays said song(if found on local filesystem)
//takes in a list where the first element is the song name and the second is the char id of who played it //takes in a list where the first element is the song name and the second is the char id of who played it
void handle_song(QStringList *p_contents); void handle_song(QStringList *p_contents);
void play_preanim(); void play_preanim(bool noninterrupting);
void play_noninterrupting_preanim();
//plays the witness testimony or cross examination animation based on argument //plays the witness testimony or cross examination animation based on argument
void handle_wtce(QString p_wtce, int variant); void handle_wtce(QString p_wtce, int variant);

View File

@ -268,12 +268,49 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file)
QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat) QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat)
{ {
QColor return_color(255, 255, 255);
if (p_identifier == "_inline_grey")
{
return_color = QColor(187, 187, 187);
}
else
{
switch (p_identifier.toInt()) {
case 1:
return_color = QColor(0, 255, 0);
break;
case 2:
return_color = QColor(255, 0, 0);
break;
case 3:
return_color = QColor(255, 165, 0);
break;
case 4:
return_color = QColor(45, 150, 255);
break;
case 5:
return_color = QColor(255, 255, 0);
break;
case 7:
return_color = QColor(255, 192, 203);
break;
case 8:
return_color = QColor(0, 255, 255);
break;
case 0:
case 6: // 6 is rainbow.
default:
return_color = QColor(255, 255, 255);
break;
}
}
p_identifier = p_identifier.prepend("c"); p_identifier = p_identifier.prepend("c");
QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini"; QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini";
QString default_path = get_base_path() + "misc/default/config.ini"; QString default_path = get_base_path() + "misc/default/config.ini";
QString f_result = read_design_ini(p_identifier, design_ini_path); QString f_result = read_design_ini(p_identifier, design_ini_path);
QColor return_color(255, 255, 255);
if (f_result == "") if (f_result == "")
{ {
f_result = read_design_ini(p_identifier, default_path); f_result = read_design_ini(p_identifier, default_path);