From 176a46c2e98c396d0d341b298a26f3c563f6ca96 Mon Sep 17 00:00:00 2001 From: Elizabeth Cray Date: Sun, 18 Jun 2023 04:17:25 -0400 Subject: [PATCH] MVP Wallpaper Setter --- project.json | 44 +++++ scene.html | 22 +++ scene.json | 45 +++++ scripts/scene.js | 169 ++++++++++++++++++ ...38150c8cd48d3e8fb072494e164286e08_EDIT.dxs | Bin 0 -> 3380 bytes ...aafc8a184bebf7de53d5ded737b12094a_EDIT.dxs | Bin 0 -> 2461 bytes ...e4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs | Bin 0 -> 3380 bytes ...888d7a7d3cb622eee67d445c0fc94469b_EDIT.dxs | Bin 0 -> 1452 bytes ...f869533aad3134bccd806f380afd260b5_EDIT.dxs | Bin 0 -> 2452 bytes 9 files changed, 280 insertions(+) create mode 100644 project.json create mode 100644 scene.html create mode 100644 scene.json create mode 100644 scripts/scene.js create mode 100644 shaders/blobsSM40/17c2a4938150c8cd48d3e8fb072494e164286e08_EDIT.dxs create mode 100644 shaders/blobsSM40/29e22deaafc8a184bebf7de53d5ded737b12094a_EDIT.dxs create mode 100644 shaders/blobsSM40/6a5e0fde4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs create mode 100644 shaders/blobsSM40/815f979888d7a7d3cb622eee67d445c0fc94469b_EDIT.dxs create mode 100644 shaders/blobsSM40/8f9dbbcf869533aad3134bccd806f380afd260b5_EDIT.dxs 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 0000000000000000000000000000000000000000..6ea0e6e6221859ff611b71cd50f1940e098a106a GIT binary patch literal 3380 zcmb7_PiS0K6vl5R?KFnOl+c0{7f)9TqG<@FY7^filW796BlD&){(&@Yr%9kSaXN(} zQe!Dd7uAg$w*f(zZd%+3f+8*yL=ZvUnT3>Yx-g=MO5^u?@1Eo}^ffaF&O7IQ_ulWE zbMJlUMH9v8fq|iC-P^mJE6$9L)j#<4uV3DI^V%0TuNV7^xgR^6i^nwVhNOQ>rvwh= z#i)P$GH(PVY9e9TqHXU59qO3^i& zWpS=)96t0Lsfls+2>^!&0mnDoDgnng+}2}J!*|I?!0-*{>=1B#!}EX=aD4C|q)1$w ztjdn@&C;Uj+0A;J&1N)FtbDEHLan%=xvwa6>HR=n!Z9oQ`rhOu@dxF@U6a2aB)Iu$ zoO%r>Kl7=}{M{*^{O1)LPI888LEDBsq_S6itm*wp{6Xg)UiUXFzY?qzG|wa#;)SEm z1yY9=@;-04DxNFfk>n3HDvX?;^PKPxK9K)Qh1?38=D+OM9Z1EbE^4{evla8EFk=4H zdoRX*mG*7c*_*0UBZ=g~*iyFYqt0+Nodfm2)9rInJ-yV;{%gPVOe7a#tqy9^cq(u9 zoi(=awtt-6bbc%Ee$C?yZU5}d;(7kez#jMWQhU?&mB(_S2(}4p>Kf-xl=`>gUG`W< z$byv@Ms#JOYN6WD+kPo~jdV-N-^6fx-^nHscbb)qpH`Ce;CDO!S$*T~w;QX6_PrPU z`|@>SGR9uegMX8L2dKlptxcl`f1+0t?nKgqH{u?AN$;;qInV6^4SHV6I$}`ohD0VF z>y?fBY~w<`HW1C7TUP6&U)NHwYqi@poAlc?advs72bx%peQHMFEpW@CU r^ho|SCU9p-dY;XB(0rSNC0@=)O=5G(RNEufiABYCZ*3A=h)v18mMWFl>NPE-rlwJghz6+( zLENYdHzMLfi9ewzXwhFF6x<8$L`rcX*6%xy+cd;l2PQLTX1eyGatovg z|6UUJg?J407}s@(7;-K3nY5@p4VUgxr&Kket;@tZz! zHGt_=bb9<^u`pG*T(Wm&cGr3|wFEP}UPG{nxQb{A{n2ux40k9#HvlRx~nTKR@ z(tcK2bPed-8|^^}cQ6~&tyC&*Z#)x2A_v)c7U09lhc+~oBa8IKHg%)aJE60#5B-O& z>_(?O2R!YptM?b})Nx6TO_uF)H~dx9{9eaIHmdxQ89Q)y3bCF!m=D;%ZaGxT@4#Ku zNTvoc%t=gjF3W)-AmYmJOwEHrG!}v3-jnU>Y_#3gwva<$x$6Xu=6c;;2`fBrK>XIj z!74a^m1T96b=OKBim~t7HoV;7&h0pM^~wCvn@7)Y<$3AjUf6dJVE6@&A^AKu$G#iD znsINy{B~5|Ey=#y4#zERhgdcNp)FB z?wTmh6Y2NHivHACA%97%br7JBI1B#Sw`jxx)Y02q?pxUZw{JNo_UK%k6E@gT^_)Pv zd)=8+2@kV{z5W~*;vn!9xVG2N@pHJKZg^-ju5VK5XU+&Q+J=7DbHM04hhH@ZaDI#T zoe(1WL%$UJk(9ixq{(k$nB!|l{TR5KiYAYxV<3sC#+#n6t+7@->oe#7;4$l4YWHS2 zNFvG@4~AtAHr>@{=+Lr7OY~>p+pTR!v=p|88l16p)XYunA-JE#*5&)*F0g7bc*_wY zAANe_MPgIe=jm_9=}+qW60@MlCV(@nyKYMqnf_6j-5zFWk=&m!2se(xbxWFg9l_KyA+`~z8Q B2fhFR literal 0 HcmV?d00001 diff --git a/shaders/blobsSM40/6a5e0fde4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs b/shaders/blobsSM40/6a5e0fde4a01ee99d94e166f7d38c5d152f2c1e6_EDIT.dxs new file mode 100644 index 0000000000000000000000000000000000000000..4a142c596af93632c8c3c603f3c61da248656a78 GIT bin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Hf-OQfp`W37Bwj*o!>k&JlX8r~H8@XQh3^>uZ(ndT;d>oPvI;Aa!Scp@Dj=BGb@WsFHN-WHKUU z1;P^Nj%hfHmQ#1@)`GZZvtn7cAwgha<|6WY%}gH{&J1V8GY`S;jB=J+JM)7eaB7Bq z7x@xSKMvc%3jJITUgXcf=PVESj27V?+{!k5;?y%DQz}=D>xuQ_n(E=GkJx?HS3;v~ z&Yi~y$1S@)qDexrBz;0WXFsCu`G0zJ6q7R#9zFf_yz~40#paQBFFySE$}^c$oG}1w zK|euX zDp7aKeo)&j+w-Q2_d;HO16G2bgx-GdGDr3c3UEh+^1CUMOK}sYB)1l!Q%%w{Fj=mdmgS${@ l<9T76^g|%=Q9TK0q&JE0_M_h9mlgN}8j&ocR7lt%{ufc{rL6z} literal 0 HcmV?d00001 diff --git a/shaders/blobsSM40/8f9dbbcf869533aad3134bccd806f380afd260b5_EDIT.dxs b/shaders/blobsSM40/8f9dbbcf869533aad3134bccd806f380afd260b5_EDIT.dxs new file mode 100644 index 0000000000000000000000000000000000000000..05260a6dd62ead2342cfdd19c29c089787c7cd02 GIT binary patch literal 2452 zcmcIlT}zZf6dvDQS6wYl$jFplBq$@ouf(MEU0qiNb!~T93eAmUn{8=rhM8-8+sVrgMY?dXRRv(1XXnZg+7#&fGzOmkDG!{lJQDDxCA2CP4mMo^P!sv-Z zvY3^S?`n&f;(d1*?_uuT8t@5EPRFfBeYYR(#6d!_M#F38-p zMPzk6Y;gY!Q`WuIbx@9+HW-e_o%J&--aTCh@qU&YzkuJY*2XC6=(8nQwnjY@(kt5w zTcft2My`&BPc}DYJ>O;aEH%ZsGtqxPX!a0uy_SCQ-1MQXT6DFt+V_UFPl|5Ko~tN_ z*&w#71@W!YUxG6a$?@