mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
More chat stuff
This commit is contained in:
@@ -613,7 +613,7 @@ gensettingstf = [
|
|||||||
"children": [
|
"children": [
|
||||||
{"text": "Legacy", "value": 0},
|
{"text": "Legacy", "value": 0},
|
||||||
{"text": "Messages", "value": 1},
|
{"text": "Messages", "value": 1},
|
||||||
{"text": "Chat", "value": 2}
|
{"text": "Bubbles", "value": 2}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@@ -120,14 +120,15 @@ const shortcuts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const chat = {
|
const chat = {
|
||||||
STYLES: {LEGACY: 0, MESSAGES: 1, CHAT: 2},
|
STYLES: {LEGACY: 0, MESSAGES: 1, BUBBLES: 2},
|
||||||
style: "legacy",
|
style: "legacy",
|
||||||
lastEdit: null,
|
lastEdit: null,
|
||||||
|
|
||||||
get useV2() {
|
get useV2() {
|
||||||
|
console.log(`v2 Check: style=${this.style} mode=${story.mode}`)
|
||||||
return [
|
return [
|
||||||
this.STYLES.MESSAGES,
|
this.STYLES.MESSAGES,
|
||||||
this.STYLES.CHAT
|
this.STYLES.BUBBLES
|
||||||
].includes(this.style) && story.mode === story.MODES.CHAT
|
].includes(this.style) && story.mode === story.MODES.CHAT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,7 +414,7 @@ function do_story_text_updates(action) {
|
|||||||
current_chunk_number = action.id;
|
current_chunk_number = action.id;
|
||||||
let item = null;
|
let item = null;
|
||||||
|
|
||||||
if (chat.useV2()) {
|
if (chat.useV2) {
|
||||||
console.log(`[story_text_update] ${action.id}`)
|
console.log(`[story_text_update] ${action.id}`)
|
||||||
if (action.id === chat.lastEdit) {
|
if (action.id === chat.lastEdit) {
|
||||||
// Swallow update if we just caused it
|
// Swallow update if we just caused it
|
||||||
@@ -708,6 +709,11 @@ function var_changed(data) {
|
|||||||
if ((data.classname == 'story') && (data.name == 'privacy_mode')) {
|
if ((data.classname == 'story') && (data.name == 'privacy_mode')) {
|
||||||
privacy_mode(data.value);
|
privacy_mode(data.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.classname === "story" && data.name === "storymode") {
|
||||||
|
story.mode = data.value;
|
||||||
|
updateChatStyle();
|
||||||
|
}
|
||||||
|
|
||||||
//Special Case for Actions
|
//Special Case for Actions
|
||||||
if ((data.classname == "story") && (data.name == "actions")) {
|
if ((data.classname == "story") && (data.name == "actions")) {
|
||||||
@@ -751,8 +757,6 @@ function var_changed(data) {
|
|||||||
update_context(data.value);
|
update_context(data.value);
|
||||||
//special case for story_actionmode
|
//special case for story_actionmode
|
||||||
} else if (data.classname == "story" && data.name == "actionmode") {
|
} else if (data.classname == "story" && data.name == "actionmode") {
|
||||||
story.mode = data.value;
|
|
||||||
|
|
||||||
const button = document.getElementById('adventure_mode');
|
const button = document.getElementById('adventure_mode');
|
||||||
if (data.value == 1) {
|
if (data.value == 1) {
|
||||||
button.childNodes[1].textContent = "Adventure";
|
button.childNodes[1].textContent = "Adventure";
|
||||||
@@ -5951,5 +5955,32 @@ function computeChatGametext(actionId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateChatStyle() {
|
function updateChatStyle() {
|
||||||
console.log("hehehohohohihihihi")
|
if (chat.useV2) {
|
||||||
|
// Already bubbles, do nothing
|
||||||
|
if (document.getElementsByClassName("chat-message").length) {
|
||||||
|
console.info("Already bubbles, do nothing")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let addedMessages = 0;
|
||||||
|
|
||||||
|
for (const [chunkId, chunk] of Object.entries(actions_data)) {
|
||||||
|
for (const message of parseChatMessages(chunk["Selected Text"])) {
|
||||||
|
addMessage(message.author, message.text, chunkId, null);
|
||||||
|
addedMessages++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are empty, add an init message
|
||||||
|
if (!addedMessages) addInitChatMessage();
|
||||||
|
} else {
|
||||||
|
console.info("TODO: Convert 2 text")
|
||||||
|
|
||||||
|
if (!document.getElementsByClassName("chat-message").length) {
|
||||||
|
console.info("Already text, do nothing")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".chat-message").remove();
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user