diff --git a/assets/icons/grass.svg b/assets/icons/grass.svg new file mode 100644 index 0000000..8b4ef76 --- /dev/null +++ b/assets/icons/grass.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/index.css b/index.css index 69b75b9..5cbc40f 100644 --- a/index.css +++ b/index.css @@ -273,4 +273,22 @@ button:active { height: 100%; border: 0; border-radius: 20px; +} + +.instances { + position: fixed; + width: 70%; + height: 80%; + padding: 0px; + margin: auto; + inset: 0px; + display: flex; + flex-direction: column; + backdrop-filter: blur(20px) brightness(40%); + border-radius: 20px; + box-shadow: 0px 0px 20px #00000055; + z-index: 7; /* i like the number 7 */ + opacity: 0; + scale: 0.8; + pointer-events: none; } \ No newline at end of file diff --git a/index.html b/index.html index 73f9151..db79f5f 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,9 @@
+
+ +
- +

Current Instance: Loading...

diff --git a/index.js b/index.js index 7a31fb2..d727ee1 100644 --- a/index.js +++ b/index.js @@ -157,6 +157,20 @@ function help(status) { } } +function instances(status) { + var instmenu = document.getElementById("instances"); + + if (status == "show") { + instmenu.classList.add("popup"); + instmenu.classList.remove("popout"); + } + + if (status == "hide") { + instmenu.classList.remove("popup"); + instmenu.classList.add("popout"); + } +} + // Listen for messages from iframe window.addEventListener('message', function(event) { console.log(event) @@ -187,6 +201,11 @@ window.addEventListener('message', function(event) { help('hide'); } + if (event.data == 'hideInstances') { + // Call instances function in the parent window + instances('hide'); + } + // if (event.data == 'offlinelogin') { // let offlineacc_data = [ localStorage.getItem('offlineusername') , localStorage.getItem('offlineuuid') ]; // pywebview.api.offline_account(offlineacc_data); @@ -202,4 +221,8 @@ window.addEventListener('message', function(event) { lastuser.textContent = "Logged in as: " + localStorage.getItem('current-username'); // i will figure out how to save last account, soon... }; + + if (event.data == 'launchminecraft') { + pywebview.api.launch_minecraft(localStorage.getItem('current-username'), localStorage.getItem('current-uuid'), localStorage.getItem('launchversion')); + }; }); \ No newline at end of file diff --git a/instances.css b/instances.css new file mode 100644 index 0000000..13aa8fb --- /dev/null +++ b/instances.css @@ -0,0 +1,345 @@ +body { + /*background-color: darkred;*/ + overflow-x: hidden; + overflow-y: auto; + padding-top: 40px; +} + +/* Customize scrollbar for WebKit browsers */ +body::-webkit-scrollbar { + width: 5px; /* Specify the width of the scrollbar */ +} + +/* Customize scrollbar thumb for WebKit browsers */ +body::-webkit-scrollbar-thumb { + background-color: #36204d; /* Specify the color of the scrollbar thumb */ + border-radius: 4px; /* Specify the border radius of the scrollbar thumb */ +} + +/* Hide the scrollbar track and button */ +body::-webkit-scrollbar-track { + background-color: transparent; /* Set background color of track to transparent */ + border: none; /* Remove border */ +} + +body::-webkit-scrollbar-button { + display: none; /* Hide the scrollbar button */ +} + +@font-face { + font-family: 'Inter'; + src: url('assets/fonts/inter/Inter-Regular.ttf'); +} + +@font-face { + font-family: 'InterThin'; + src: url('assets/fonts/inter/Inter-Thin.ttf'); +} + +p, h1, h2, h3, h4, h5, h6, div { + font-family: 'Inter'; + color: white; +} + +p { + margin: 0; +} + +iframe { + background-color: transparent; +} + +.close { + background-color: #00000000; + border: 0; + width: 40px; + height: 40px; +} + +.close:hover { + background-color: #00000050; + scale: 1.05; +} + +.titlebar { + background-color: #00000070; + position: fixed; + left: 0; + top: 0; + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + gap: 10px; + height: 40px; + z-index: 10; +} + +button { + background-color: #00000070; + font-family: 'Inter'; + color: white; + border: 0; + padding: 5px; + border-radius: 10px; + transition-duration: 0.2s +} + +button:hover { + background-color: #00000060; + box-shadow: 0px 0px 7px #00000020; + scale: 1.05; +} + +button:active { + background-color: #00000080; + scale: 0.97; +} + +button:disabled { + color: #ffffff50; +} + +.navbar { + background-color: #00000070; + position: fixed; + left: 0; + bottom: 0; + width: 100%; + display: flex; + flex-direction: row; + gap: 10px; + height: 30px; + z-index: 10; + padding: 7px; +} + +.align-right { + position: fixed; + right: 6px; +} + +.instance-btn { + background-color: #00000070; + font-family: 'Inter'; + color: white; + border: 0; + padding: 5px; + padding-left: 7px; + padding-right: 7px; + border-radius: 12px; + height: 30px; + transition-duration: 0.2s +} + +.instances { + width: 100%; + display: flex; + flex-direction: row; +} + +.instance { + border: 2px solid #ffffff20; + border-radius: 12px; + width: 90px; + height: 90px; + margin: 10px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + scale: 1; + transition-duration: 0.15s; + box-shadow: 0px 0px 20px #000000cc; +} + +.instance:hover { + scale: 1.05; + box-shadow: 0px 0px 10px #ffffff20; +} + +.instance:active { + scale: 0.98; +} + +/*hr { + opacity: 1; + margin: 0; + border: 1px solid #ffffff20; + width: 85%; +} + +.inst-icon { + margin-top: -5px; +} + +.inst-name { + margin-top: 5px; +}*/ + +.dialogbg { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: #00000050; + z-index: 12; + opacity: 0; + pointer-events: none; +} + +.new-inst { + position: fixed; + width: 250px; + height: 125px; + padding: 10px; + margin: auto; + inset: 0px; + display: flex; + flex-direction: column; + background-color: #4d0101; + border-radius: 20px; + box-shadow: 0px 0px 40px #2b0000; + z-index: 14; + gap: 5px; + text-align: center; + justify-content: center; + align-items: center; + opacity: 0; + scale: 0.8; +} + +.addaccbtn { + width: 100%; + box-shadow: 0px 0px 20px #00000050; +} + +input { + background-color: #00000070; + border: 0; + border-radius: 5px; + padding: 2px; + color: white; + font-family: 'Inter'; + outline: 0px solid #00000050; + transition-duration: 0.2s; + box-shadow: 0px 0px 20px #00000050; +} + +input:focus { + outline: 2px solid #00000050; +} + +select { + background-color: #00000070; + border: 0; + border-radius: 5px; + padding: 2px; + color: white; + font-family: 'Inter'; + outline: 0px solid #00000050; + transition-duration: 0.2s; + box-shadow: 0px 0px 20px #00000050; +} + +option { + background-color: #4d0101; + color: white; + font-family: 'Inter'; + transition-duration: 0.2s; +} + +option:hover { + font-size: 50px; +} + +/* Style scrollbars of a container element (not the + +
+ + +
+ + + +
+ +

Instances

+
+ +
+ + +
+ + + \ No newline at end of file diff --git a/instances.js b/instances.js new file mode 100644 index 0000000..20bb669 --- /dev/null +++ b/instances.js @@ -0,0 +1,120 @@ +console.log("'instances.js' loaded successfully") + +// function addInstance(name) { +// const a = document.createElement('a'); +// const div = document.createElement('div'); +// div.className = 'instance'; + +// const img = document.createElement('img'); +// img.width = 50; +// img.src = 'assets/icons/grass.svg'; + +// const p = document.createElement('p'); +// p.textContent = name; + +// div.appendChild(img); +// div.appendChild(p); +// a.appendChild(div); + +// const instances = document.querySelector('.instances'); +// instances.appendChild(a); +// }; + +function closeCreation() { + var bg = document.getElementById("dialogbg"); + var dialog = document.getElementById("newinst"); + + dialog.classList.remove('popup'); + dialog.classList.add('popout'); + bg.classList.add('fadeout'); + bg.classList.remove('fadein'); +} + +function startInstance() { + localStorage.setItem('launchversion', window.__selectedVer); + window.parent.postMessage('launchminecraft', '*'); + alert(`Check Python Console for Updates as Minecraft ${window.__selectedVer} currently opening...`) +} + +function selectInstance(version) { + var start = document.getElementById("startinst"); + window.__selectedVer = version; + // var edit = document.getElementById("editinst"); + + start.disabled = false; + // start.disabled = false; +} + +function addInstance() { + const a = document.createElement('a'); + const div = document.createElement('div'); + div.className = 'instance'; + + a.onclick = function() { + selectInstance(document.getElementById('mcversions').value); + } + + const img = document.createElement('img'); + img.width = 50; + img.src = 'assets/icons/grass.svg'; + + const p = document.createElement('p'); + p.textContent = document.getElementById('mcversions').value; + + div.appendChild(img); + div.appendChild(p); + a.appendChild(div); + + const instances = document.querySelector('.instances'); + instances.appendChild(a); + + closeCreation(); +}; + +// Adds information on load +document.addEventListener('DOMContentLoaded', function() { + window.parent.postMessage('awaitInstance', '*'); + fetch('https://launchermeta.mojang.com/mc/game/version_manifest_v2.json') + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); + }) + .then(data => { + const dropdown = document.getElementById('mcversions'); + const versions = data.versions; // Access the versions array + + versions.forEach(version => { + if (version.type === 'release') { // Check if type is 'release' + const option = document.createElement('option'); + option.value = version.id; + option.textContent = version.id; + dropdown.appendChild(option); + } + }); + }) + .catch(error => { + console.error('There was a problem with the fetch operation:', error); + }); + + +}); + + + + + +function closeWindow() { + window.parent.postMessage('hideInstances', '*'); +} + +function newInstance() { + var bg = document.getElementById("dialogbg"); + var dialog = document.getElementById("newinst"); + + bg.classList.add('fadein'); + bg.classList.remove('fadeout'); + dialog.classList.add('popup'); + dialog.classList.remove('popout'); +} \ No newline at end of file diff --git a/main.py b/main.py index 87f59ef..7d5e031 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,9 @@ import humanize import GPUtil import platform -import portablemc +# import portablemc +from portablemc.standard import Context, Version +from pathlib import Path # Note 2 Self (2024/07/09 - 3:40AM (it's my birthday wowzers)) # https://github.com/mindstorm38/portablemc/blob/main/doc/API.md @@ -25,7 +27,8 @@ |_ / / _` || |/ /| '__|| || '_ ` _ \ / __| / _ \ | '_ \ / / | (_| || < | | | || | | | | |\__ \| (_) || | | | /___| \__,_||_|\_\|_| |_||_| |_| |_||___/ \___/ |_| |_| - Written by MTSyntho & Artsign + Beta 1 -Launch Update- + Written by MTSyntho Dev """) @@ -246,6 +249,16 @@ def offline_account(self, username, uuid): print("New account has been appended to the file.") + def launch_minecraft(self, username, uuid, version): + print(f'\nLaunching Minecraft {version} with username: {username} (uuid: {uuid})\n') + print('Also im now realizing portablemc wont output anything, so please wait, it may take a long while to launch') + mcver = Version(version) + mccontext = Context(Path(".zdkrimson\\resources"), Path(".zdkrimson\\.minecraft")) + + mcver.set_auth_offline(username, uuid) + env = mcver.install() + env.run() + # Big thanks 2 ChatGPT for making the variables work globally throughtout the project, i didnt know how to get it working. # Instantiate Api class diff --git a/settings.css b/settings.css index 7a60959..593e5a1 100644 --- a/settings.css +++ b/settings.css @@ -105,7 +105,6 @@ p { margin-left: -3px; position: fixed; top: 0px; - } hr { @@ -286,6 +285,7 @@ button:active { } /* i've spent an unreasonable amount of time tryna figure out why the settings menu cant scroll */ +/* for flippin's sakes i still cant figure this shi out */ .dialogbg { position: fixed;