diff options
| author | ghostfeesh <codeviscerate@gmail.com> | 2018-07-28 07:06:42 +0800 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2018-07-27 19:06:42 -0400 |
| commit | 3129d2aded8a323dce9a184e3da99daac8bea35a (patch) | |
| tree | 2e48fe5c7153da07ef1f836f81f5d56f5d42a020 | |
| parent | bd1cda1bd65d390c5f8a915afdef610608a81871 (diff) | |
Reverse IC log config option (#22)
The way it should have been.
Reverse IC logs, now in configurable in config.ini. Set to false by default. Now you can go up or down as and when you please.
(thanks argo for putting up with my trash code)
| -rw-r--r-- | aoapplication.h | 3 | ||||
| -rw-r--r-- | base/config.ini | 13 | ||||
| -rw-r--r-- | courtroom.cpp | 27 | ||||
| -rw-r--r-- | text_file_functions.cpp | 6 |
4 files changed, 39 insertions, 10 deletions
diff --git a/aoapplication.h b/aoapplication.h index 08f12c62..2aa7d16c 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -138,6 +138,9 @@ public: //Returns true if discord is enabled in config.ini and false otherwise bool is_discord_enabled(); + //Returns true if reverse IC is enabled in config.ini and false otherwise + bool ic_scroll_down_enabled(); + //Returns the list of words in callwords.ini QStringList get_call_words(); diff --git a/base/config.ini b/base/config.ini index a71b2595..1e8705fa 100644 --- a/base/config.ini +++ b/base/config.ini @@ -1,3 +1,10 @@ -theme = default -discord = true -; master = master.aceattorneyonline.com
\ No newline at end of file +theme = default
+blip_rate = 1
+blank_blip = false
+default_music = 50
+default_sfx = 50
+default_blip = 50
+discord = true
+ic_scroll_down = false
+; master = master.aceattorneyonline.com
+; ooc_name = Phoenix
\ No newline at end of file diff --git a/courtroom.cpp b/courtroom.cpp index 717a13c3..76d6b03f 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1145,14 +1145,27 @@ void Courtroom::append_ic_text(QString p_text, QString p_name) normal.setFontWeight(QFont::Normal); const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); - const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum(); - - ui_ic_chatlog->moveCursor(QTextCursor::Start); + + QTextCursor::MoveOperation move_op; + int scrollbar_limit; + + if(ao_app->ic_scroll_down_enabled()) { + scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum(); + move_op = QTextCursor::End; + } + else { + scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->minimum(); + move_op = QTextCursor::Start; + } + + const bool is_fully_scrolled = old_scrollbar_value == scrollbar_limit; + + ui_ic_chatlog->moveCursor(move_op); ui_ic_chatlog->textCursor().insertText(p_name, bold); ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal); - - if (old_cursor.hasSelection() || !is_scrolled_up) + + if (old_cursor.hasSelection() || !is_fully_scrolled) { // The user has selected text or scrolled away from the top: maintain position. ui_ic_chatlog->setTextCursor(old_cursor); @@ -1161,8 +1174,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name) 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()); + ui_ic_chatlog->moveCursor(move_op); + ui_ic_chatlog->verticalScrollBar()->setValue(scrollbar_limit); } } diff --git a/text_file_functions.cpp b/text_file_functions.cpp index b77e1788..1aebc35e 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -581,3 +581,9 @@ bool AOApplication::is_discord_enabled() QString f_result = read_config("discord"); return !f_result.startsWith("false"); } + +bool AOApplication::ic_scroll_down_enabled() +{ + QString f_result = read_config("ic_scroll_down"); + return f_result.startsWith("true"); +}
\ No newline at end of file |
