commit 176a46c2e98c396d0d341b298a26f3c563f6ca96 Author: Elizabeth Cray Date: Sun Jun 18 04:17:25 2023 -0400 MVP Wallpaper Setter diff --git a/project.json b/project.json new file mode 100644 index 0000000..5564968 --- /dev/null +++ b/project.json @@ -0,0 +1,44 @@ +{ + "file" : "scene.html", + "description": "Storage limit: 10240 images because of windows max path and locastorage limits", + "general" : + { + "properties" : + { + "schemecolor" : + { + "order" : 0, + "text" : "ui_browse_properties_scheme_color", + "type" : "color", + "value" : "0.8980392156862745 0.18823529411764706 0.9294117647058824" + }, + "dir" : + { + "index" : 2, + "order": 102, + "mode" : "fetchall", + "text" : "Wallpaper Dir", + "type" : "directory" + }, + "uri" : + { + "index" : 1, + "order" : 101, + "text" : "Socket URI", + "type" : "textinput", + "value" : "" + }, + "systemid" : + { + "index" : 0, + "order" : 100, + "text" : "System ID", + "type" : "textinput", + "value" : "" + } + } + }, + "title" : "PluralKit", + "type" : "scene", + "version" : 0 +} diff --git a/scene.html b/scene.html new file mode 100644 index 0000000..893a0c6 --- /dev/null +++ b/scene.html @@ -0,0 +1,22 @@ + + + + + + Bootstrap Background + + + + + + + + + + + diff --git a/scene.json b/scene.json new file mode 100644 index 0000000..a739988 --- /dev/null +++ b/scene.json @@ -0,0 +1,45 @@ +{ + "camera" : + { + "center" : "0.00000 0.00000 -1.00000", + "eye" : "0.00000 0.00000 0.00000", + "up" : "0.00000 1.00000 0.00000" + }, + "general" : + { + "ambientcolor" : "0.30000 0.30000 0.30000", + "bloom" : false, + "bloomhdrfeather" : 0.1, + "bloomhdriterations" : 8, + "bloomhdrscatter" : 1.619, + "bloomhdrstrength" : 2.0, + "bloomhdrthreshold" : 1.0, + "bloomstrength" : 2.0, + "bloomthreshold" : 0.64999998, + "camerafade" : true, + "cameraparallax" : false, + "cameraparallaxamount" : 0.5, + "cameraparallaxdelay" : 0.1, + "cameraparallaxmouseinfluence" : 0.5, + "camerapreview" : true, + "camerashake" : false, + "camerashakeamplitude" : 0.5, + "camerashakeroughness" : 1.0, + "camerashakespeed" : 3.0, + "clearcolor" : "0.70000 0.70000 0.70000", + "clearenabled" : true, + "farz" : 10000.0, + "fov" : 50.0, + "hdr" : false, + "nearz" : 0.0099999998, + "orthogonalprojection" : + { + "height" : 2160, + "width" : 3840 + }, + "skylightcolor" : "0.30000 0.30000 0.30000", + "zoom" : 1.0 + }, + "objects" : [], + "version" : 1 +} \ No newline at end of file diff --git a/scripts/scene.js b/scripts/scene.js new file mode 100644 index 0000000..4ad3e35 --- /dev/null +++ b/scripts/scene.js @@ -0,0 +1,169 @@ +let socket +let socketStatus = false + +let jsonValid = (json) => { + try { + JSON.parse(json); + if (json == null) { + return false; + } + } catch (e) { + return false; + } + return true; +} + +let setWallpaper = (path) => { + console.log(`Setting wallpaper to ${path}`) + let wallpaper = document.getElementById('wallpaper') + // wallpaper.src = path + wallpaper.style.backgroundImage = `url(${path})` +} + +let dumpStorage = () => { + console.log('%cDumping Local Storage', 'color: #EBCB8B; font-family: monospace; font-size: 18px;') + console.log(' Member:' + localStorage.getItem('member')) + // console.log(' Token' + localStorage.getItem('token')) + console.log(' System:' + localStorage.getItem('systemId')) + console.log(' Socket:' + localStorage.getItem('socket')) + console.log(' Wallpapers:' + localStorage.getItem('wallpapers')) +} + +let grabLatestFronter = () => { + let systemId = localStorage.getItem('systemId') + if (systemId != null) { + var xhr = new XMLHttpRequest() + xhr.withCredentials = true + xhr.addEventListener("readystatechange", function() { + if(this.readyState === 4) { + // console.log(this.responseText) + let fronter = JSON.parse(this.responseText).members[0].id + localStorage.setItem('member', fronter) + console.log(`%cFronter: ${fronter}`, 'color: #ECEFF4; font-family: monospace;') + pickWallpaper() + } + }) + xhr.open("GET", "https://api.pluralkit.me/v2/systems/"+systemId+"/fronters") + xhr.send() + }else{ + localStorage.setItem('member', 'null') + } +} + +let pickWallpaper = () => { + let wallpapers = localStorage.getItem('wallpapers') + if (jsonValid(wallpapers)) { + wallpapers = JSON.parse(localStorage.getItem('wallpapers')) + } else { + wallpapers = [] + console.log('%cWallpapers not found in Local Storage', 'color: #BF616A; font-size: 18px; font-family: monospace;') + } + // for (let index = wallpapers.length-1; index >= 0; index--) { + // if (!wallpapers.includes(localStorage.getItem('member'))) { + // wallpapers.splice(index, 1) + // } + // } + let validWallpapers = [] + wallpapers.forEach(wp => { + if (wp.includes(localStorage.getItem('member'))) { + validWallpapers.push(wp) + } + }) + let wallpaper = "file:///" + validWallpapers[Math.floor(Math.random() * validWallpapers.length)] + if (validWallpapers.length == 0) { + wallpaper = "https://picsum.photos/3840/2160" + } + setWallpaper(wallpaper) +} + +let loadSocket = () => { + console.log('%cLoading Socket', 'color: #ECEFF4; font-family: monospace;') + if (socket){ + try { + socket.close() + } catch (error) { + console.log('%cSocket not found', 'color: #BF616A; font-size: 18px; font-family: monospace;') + } + } + socket = new WebSocket(localStorage.getItem('socket')) + socket.onopen = (e) => { + console.log('%cSocket Opened', 'color: #A3BE8C; font-size: 18px; font-family: serif;') + socketStatus = true + } + socket.onmessage = (e) => { + console.log('%cMessage Received', 'color: #ECEFF4; font-family: monospace;') + + // e.data contains member ID + // console.dir(e) + localStorage.setItem('member', e.data) + pickWallpaper() + + // Copilot-generated Code + // let data = JSON.parse(e.data) + // if (data.type === 'wallpaper') { + // setWallpaper(data.path) + // } + } + socket.onclose = (e) => { + console.log('%cSocket Closed', 'color: #BF616A; font-size: 18px; font-family: serif;') + socketStatus = false + setTimeout(() => { + loadSocket() + }, 1200) + } + socket.onerror = (e) => { + console.log('%cSocket Error', 'color: #BF616A; font-size: 18px; font-family: monospace;') + console.dir(e) + } +} + +window.wallpaperPropertyListener = { + applyUserProperties: function(properties) { + // Grab PKit token, System ID, and Socket URI + // if (properties.token) { + // // config.token = properties.token.value + // localStorage.setItem('token', properties.token.value) + // } + if (properties.systemid) { + // config.systemId = properties.systemid.value + localStorage.setItem('systemId', properties.systemid.value) + } + if (properties.uri) { + // config.socket = properties.uri.value + localStorage.setItem('socket', properties.uri.value) + } + dumpStorage() + // Reload Socket + if (socketStatus) { + socketStatus = false + socket.close() + } + loadSocket() + }, + userDirectoryFilesAddedOrChanged: function(propertyName, changedFiles) { + // Do something with the list of added files here + // console.dir(propertyName) + console.dir(changedFiles) // Array of filepaths added + let wallpapers = localStorage.getItem('wallpapers') + if (jsonValid(wallpapers)) { + wallpapers = JSON.parse(localStorage.getItem('wallpapers')) + } else { + wallpapers = [] + console.log('%cWallpapers not found in Local Storage', 'color: #BF616A; font-size: 18px; font-family: monospace;') + } + changedFiles.forEach((file) => { + if (!wallpapers.includes(file)) { + wallpapers.push(file) + } + }) + localStorage.setItem('wallpapers', JSON.stringify(wallpapers)) + }, +} + +window.onload = () => { + console.log("%cPage Loaded.", "background: #2E3440; color: #A3BE8C; font-size: 24px;") + // Set default member + dumpStorage() + grabLatestFronter() + loadSocket() +} diff --git a/shaders/blobsSM40/17c2a4938150c8cd48d3e8fb072494e164286e08_EDIT.dxs b/shaders/blobsSM40/17c2a4938150c8cd48d3e8fb072494e164286e08_EDIT.dxs new file mode 100644 index 0000000..6ea0e6e Binary files /dev/null and b/shaders/blobsSM40/17c2a4938150c8cd48d3e8fb072494e164286e08_EDIT.dxs differ diff --git a/shaders/blobsSM40/29e22deaafc8a184bebf7de53d5ded737b12094a_EDIT.dxs b/shaders/blobsSM40/29e22deaafc8a184bebf7de53d5ded737b12094a_EDIT.dxs new file mode 100644 index 0000000..320da2c Binary files /dev/null and b/shaders/blobsSM40/29e22deaafc8a184bebf7de53d5ded737b12094a_EDIT.dxs differ diff --git a/shaders/blobsSM40/6a5e0fde4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs b/shaders/blobsSM40/6a5e0fde4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs new file mode 100644 index 0000000..4a142c5 Binary files /dev/null and b/shaders/blobsSM40/6a5e0fde4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs differ diff --git a/shaders/blobsSM40/815f979888d7a7d3cb622eee67d445c0fc94469b_EDIT.dxs b/shaders/blobsSM40/815f979888d7a7d3cb622eee67d445c0fc94469b_EDIT.dxs new file mode 100644 index 0000000..75d904b Binary files /dev/null and b/shaders/blobsSM40/815f979888d7a7d3cb622eee67d445c0fc94469b_EDIT.dxs differ diff --git a/shaders/blobsSM40/8f9dbbcf869533aad3134bccd806f380afd260b5_EDIT.dxs b/shaders/blobsSM40/8f9dbbcf869533aad3134bccd806f380afd260b5_EDIT.dxs new file mode 100644 index 0000000..05260a6 Binary files /dev/null and b/shaders/blobsSM40/8f9dbbcf869533aad3134bccd806f380afd260b5_EDIT.dxs differ