Add slash commands for chat styles and continue

This commit is contained in:
Cohee
2023-07-02 22:40:38 +03:00
parent 2e80de230e
commit 7a33042ea9
3 changed files with 29 additions and 2 deletions

View File

@ -1213,6 +1213,13 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
messageText = mes.extra.display_text;
}
// Forbidden black magic
// This allows to use "continue" on user messages
if (type === 'swipe' && mes.swipe_id === undefined) {
mes.swipe_id = 0;
mes.swipes = [mes.mes];
}
if (mes.name === name1) {
var characterName = name1; //set to user's name by default
} else { var characterName = mes.name }

View File

@ -51,7 +51,7 @@ const avatar_styles = {
RECTANGULAR: 1,
}
const chat_styles = {
export const chat_styles = {
DEFAULT: 0,
BUBBLES: 1,
DOCUMENT: 2,

View File

@ -21,7 +21,7 @@ import {
saveSettings,
} from "../script.js";
import { humanizedDateTime } from "./RossAscends-mods.js";
import { power_user } from "./power-user.js";
import { chat_styles, power_user } from "./power-user.js";
export {
executeSlashCommands,
registerSlashCommand,
@ -107,11 +107,19 @@ parser.addCommand('sendas', sendMessageAs, [], ` sends message as a specific
parser.addCommand('sys', sendNarratorMessage, [], '<span class="monospace">(text)</span> sends message as a system narrator', false, true);
parser.addCommand('sysname', setNarratorName, [], '<span class="monospace">(name)</span> sets a name for future system narrator messages in this chat (display only). Default: System. Leave empty to reset.', true, true);
parser.addCommand('comment', sendCommentMessage, [], '<span class="monospace">(text)</span> adds a note/comment message not part of the chat', false, true);
parser.addCommand('single', setStoryModeCallback, ['story'], ' sets the message style to single document mode without names or avatars visible', true, true);
parser.addCommand('bubble', setBubbleModeCallback, ['bubbles'], ' sets the message style to bubble chat mode', true, true);
parser.addCommand('flat', setFlatModeCallback, ['default'], ' sets the message style to flat chat mode', true, true);
parser.addCommand('continue', continueChatCallback, ['cont'], ' continues the last message in the chat', true, true);
const NARRATOR_NAME_KEY = 'narrator_name';
const NARRATOR_NAME_DEFAULT = 'System';
const COMMENT_NAME_DEFAULT = 'Note';
function continueChatCallback() {
$('#option_continue').trigger('click');
}
function syncCallback() {
$('#sync_name_button').trigger('click');
}
@ -120,6 +128,18 @@ function bindCallback() {
$('#lock_user_name').trigger('click');
}
function setStoryModeCallback() {
$('#chat_display').val(chat_styles.DOCUMENT).trigger('change');
}
function setBubbleModeCallback() {
$('#chat_display').val(chat_styles.BUBBLES).trigger('change');
}
function setFlatModeCallback() {
$('#chat_display').val(chat_styles.DEFAULT).trigger('change');
}
function setNameCallback(_, name) {
if (!name) {
toastr.warning('you must specify a name to change to')