Skip to content

Commit 3129d2a

Browse files
Poyoanonoldmud0
authored andcommitted
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)
1 parent bd1cda1 commit 3129d2a

4 files changed

Lines changed: 39 additions & 10 deletions

File tree

aoapplication.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ class AOApplication : public QApplication
138138
//Returns true if discord is enabled in config.ini and false otherwise
139139
bool is_discord_enabled();
140140

141+
//Returns true if reverse IC is enabled in config.ini and false otherwise
142+
bool ic_scroll_down_enabled();
143+
141144
//Returns the list of words in callwords.ini
142145
QStringList get_call_words();
143146

base/config.ini

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
theme = default
2-
discord = true
3-
; master = master.aceattorneyonline.com
1+
theme = default
2+
blip_rate = 1
3+
blank_blip = false
4+
default_music = 50
5+
default_sfx = 50
6+
default_blip = 50
7+
discord = true
8+
ic_scroll_down = false
9+
; master = master.aceattorneyonline.com
10+
; ooc_name = Phoenix

courtroom.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,14 +1145,27 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
11451145
normal.setFontWeight(QFont::Normal);
11461146
const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
11471147
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
1148-
const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum();
1149-
1150-
ui_ic_chatlog->moveCursor(QTextCursor::Start);
1148+
1149+
QTextCursor::MoveOperation move_op;
1150+
int scrollbar_limit;
1151+
1152+
if(ao_app->ic_scroll_down_enabled()) {
1153+
scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum();
1154+
move_op = QTextCursor::End;
1155+
}
1156+
else {
1157+
scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->minimum();
1158+
move_op = QTextCursor::Start;
1159+
}
1160+
1161+
const bool is_fully_scrolled = old_scrollbar_value == scrollbar_limit;
1162+
1163+
ui_ic_chatlog->moveCursor(move_op);
11511164

11521165
ui_ic_chatlog->textCursor().insertText(p_name, bold);
11531166
ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal);
1154-
1155-
if (old_cursor.hasSelection() || !is_scrolled_up)
1167+
1168+
if (old_cursor.hasSelection() || !is_fully_scrolled)
11561169
{
11571170
// The user has selected text or scrolled away from the top: maintain position.
11581171
ui_ic_chatlog->setTextCursor(old_cursor);
@@ -1161,8 +1174,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
11611174
else
11621175
{
11631176
// The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
1164-
ui_ic_chatlog->moveCursor(QTextCursor::Start);
1165-
ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
1177+
ui_ic_chatlog->moveCursor(move_op);
1178+
ui_ic_chatlog->verticalScrollBar()->setValue(scrollbar_limit);
11661179
}
11671180
}
11681181

text_file_functions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,9 @@ bool AOApplication::is_discord_enabled()
581581
QString f_result = read_config("discord");
582582
return !f_result.startsWith("false");
583583
}
584+
585+
bool AOApplication::ic_scroll_down_enabled()
586+
{
587+
QString f_result = read_config("ic_scroll_down");
588+
return f_result.startsWith("true");
589+
}

0 commit comments

Comments
 (0)