diff --git a/klite.embd b/klite.embd index 5f68c9f2b..7614f02b1 100644 --- a/klite.embd +++ b/klite.embd @@ -7089,7 +7089,7 @@ Current version indicated by LITEVER below. }); }else{ temp_scenario = null; - document.getElementById("scenariodesc").innerText = "Error: User input is invalid\n\n Please ensure you have input a valid Pygmalion.Chat UUID."; + document.getElementById("scenariodesc").innerText = "Error: User input is invalid\n\n Please ensure you have input a valid Pygmalion.Chat UUID or URL."; } } } @@ -7311,6 +7311,62 @@ Current version indicated by LITEVER below. } } + function character_creator() + { + hide_popups(); + document.getElementById("charcreator_name").value = document.getElementById("charcreator_persona").value = document.getElementById("charcreator_scenario").value = document.getElementById("charcreator_greeting").value = ""; + document.getElementById("charactercreator").classList.remove("hidden"); + tempAestheticInstructUISettings = deepCopyAestheticSettings(aestheticInstructUISettings); + character_creator_updateimg(); + } + function character_creator_updateimg() + { + document.getElementById("charcreator_avatar").style.backgroundImage = `url(` + (aestheticInstructUISettings.AI_portrait != "default" ? aestheticInstructUISettings.AI_portrait : niko_square) + `)`; + } + function character_creator_done(confirm) + { + if (!confirm) + { + aestheticInstructUISettings = deepCopyAestheticSettings(tempAestheticInstructUISettings); + updateUIFromData(); + } + else + { + let chatopponent = document.getElementById("charcreator_name").value; + chatopponent = chatopponent?chatopponent:"Bot"; + + let persona = document.getElementById("charcreator_persona").value; + let scenario = document.getElementById("charcreator_scenario").value; + scenario = scenario?scenario:""; + let memory = persona?("{{char}} Persona: "+persona):""; + let greeting = document.getElementById("charcreator_greeting").value; + greeting = greeting?greeting:"Hello there!"; + if(scenario!="") + { + scenario = "\n[Scenario: "+scenario+"]"; + } + let combinedmem = memory + scenario; + greeting = "\n{{char}}: "+ greeting; + restart_new_game(false); + + gametext_arr = []; + if(!localsettings.placeholder_tags) //do a one-time replace instead + { + greeting = replace_placeholders(greeting, false, true); + combinedmem = replace_placeholders(combinedmem, false, true); + } + gametext_arr.push(greeting); + if (combinedmem != "") { + current_memory = combinedmem; + } + localsettings.opmode = 3; + localsettings.gui_type_chat = 2; + localsettings.chatopponent = chatopponent; + render_gametext(); + } + tempAestheticInstructUISettings = null; + hide_popups(); + } function click_scenario(idx) { @@ -7561,7 +7617,8 @@ Current version indicated by LITEVER below. let scenarios = ``+ `` + `` + - ``; + `` + + ``; for(let i=0;i { + if (event.target.files.length > 0 && event.target.files[0]) { + const file = event.target.files[0]; + const reader = new FileReader(); + reader.onload = function(img) { + compressImage(img.target.result, loadCompressedImage, true); + function loadCompressedImage(compressedImageURI, aspectratio) { + + if(isSelfPortrait) + { + aestheticInstructUISettings.you_portrait = compressedImageURI; + document.getElementById('portrait_ratio_you').value = aspectratio.toFixed(2); + } + else + { + aestheticInstructUISettings.AI_portrait = compressedImageURI; + document.getElementById('portrait_ratio_AI').value = aspectratio.toFixed(2); + } + refreshPreview(true); + } + } + reader.readAsDataURL(file); + } + finput.value = ""; + }; + } + function initializeInstructUIFunctionality() { // Initialize foregroundColorPickers and backgroundColorPickers. @@ -17222,33 +17312,7 @@ Current version indicated by LITEVER below. // Initialize functionality for the portrait pickers. document.querySelectorAll('#you-portrait, #AI-portrait').forEach(element => { element.addEventListener('click', (e) => { - let finput = document.getElementById('portraitFileInput'); - finput.click(); - finput.onchange = (event) => { - if (event.target.files.length > 0 && event.target.files[0]) { - const file = event.target.files[0]; - const reader = new FileReader(); - reader.onload = function(img) { - compressImage(img.target.result, loadCompressedImage, true); - function loadCompressedImage(compressedImageURI, aspectratio) { - let isSelfPortrait = (element.id=="you-portrait"); - if(isSelfPortrait) - { - aestheticInstructUISettings.you_portrait = compressedImageURI; - document.getElementById('portrait_ratio_you').value = aspectratio.toFixed(2); - } - else - { - aestheticInstructUISettings.AI_portrait = compressedImageURI; - document.getElementById('portrait_ratio_AI').value = aspectratio.toFixed(2); - } - refreshPreview(true); - } - } - reader.readAsDataURL(file); - } - finput.value = ""; - }; + selectAvatarImage(element.id=="you-portrait"); }); element.addEventListener('mouseover', () => element.style.cursor = "pointer"); }); @@ -17299,6 +17363,7 @@ Current version indicated by LITEVER below. if (updateFromUI) { updateDataFromUI(); } updateUIFromData(); updateTextPreview(); + character_creator_updateimg(); } function updateDataFromUI() { @@ -17907,6 +17972,46 @@ Current version indicated by LITEVER below. + +