diff --git a/.zdkrimson/settings.json b/.zdkrimson/settings.json
index 5b79d12..31dc018 100644
--- a/.zdkrimson/settings.json
+++ b/.zdkrimson/settings.json
@@ -1,5 +1,16 @@
{
- "lastaccount": "mt.",
+ "lastaccount": "",
"firsttime": 1,
- "lastinstance": ""
+ "lastinstance": "",
+ "maximizedefault": false,
+ "winwidth": 854,
+ "winheight": 480,
+ "demomode": false,
+ "multiplayer": true,
+ "gamechat": true,
+ "minmem": 512,
+ "maxmem": 1024,
+ "javapath": "javaw",
+ "jvmargs": "",
+ "customtheme": ""
}
\ No newline at end of file
diff --git a/index.html b/index.html
index a197a1d..73f9151 100644
--- a/index.html
+++ b/index.html
@@ -30,7 +30,7 @@
-
Current Instance: instname
+ Current Instance: Loading...
diff --git a/index.js b/index.js
index c083f8c..8aa70b0 100644
--- a/index.js
+++ b/index.js
@@ -1,12 +1,131 @@
-window.addEventListener('pywebviewready', function() {
- var lastuser = document.getElementById('lastuser');
- pywebview.api.get_username('recent').then(function(result) {
- // it took me an ungodly amount of time to figure this out, im so pissed rn
- lastuser.textContent = "Logged in as: " + result;
- });
- pywebview.api.get_host().then(function(result) {
- // it took me an ungodly amount of time to figure this out, im so pissed rn
- hostmachine = result;
+document.addEventListener('DOMContentLoaded', function() {
+ window.addEventListener('pywebviewready', function() {
+ var lastuser = document.getElementById('lastuser');
+ var lastinst = document.getElementById('instancename');
+ pywebview.api.get_username('recent').then(function(result) {
+ // it took me an ungodly amount of time to figure this out, im so pissed rn
+ if (result == "") {
+ lastuser.textContent = "Logged in as: Not Logged In!";
+ } else {
+ lastuser.textContent = "Logged in as: " + result;
+ }
+ });
+ pywebview.api.get_recentinstance().then(function(result) {
+ if (result == "") {
+ lastinst.textContent = "Current Instance: Not Selected";
+ } else {
+ lastinst.textContent = "Current Instance: " + result;
+ }
+ });
+ pywebview.api.get_host().then(function(result) {
+ // it took me an ungodly amount of time to figure this out, im so pissed rn
+ console.log('Host Machine: ' + result);
+ localStorage.setItem('hostmachine', result);
+ });
+ pywebview.api.get_mem().then(function(result) {
+ // i love copy n paste :)
+ console.log('Memory: ' + result);
+ localStorage.setItem('sysmem', result);
+ });
+ pywebview.api.get_gpu().then(function(result) {
+ console.log('GPU: ' + result);
+ localStorage.setItem('sysgpu', result);
+ });
+ pywebview.api.get_cpu().then(function(result) {
+ console.log('CPU: ' + result);
+ localStorage.setItem('syscpu', result);
+ });
+ });
+});
+
+// window.addEventListener('message', function(event) {
+// if (event.data === 'awaitConfig') {
+// console.log("'awaitConfig' Message from settings.js received by index.js")
+// // Sending settings to iframe (settings.html)
+// window.addEventListener('pywebviewready', function() {
+// var settingsiframe = document.getElementById('settings');
+// pywebview.api.get_settings().then(function(result) {
+// console.log(result);
+// var customtheme = result.customtheme;
+// var demomode = result.demomode;
+// var firsttime = result.firsttime;
+// var gamechat = result.gamechat;
+// var javapath = result.javapath;
+// var jvmargs = result.jvmargs;
+// var lastaccount = result.lastaccount;
+// var lastinstance = result.lastinstance;
+// var maximizedefault = result.maximizedefault;
+// var minmem = result.minmem;
+// var maxmem = result.maxmem;
+// var multiplayer = result.multiplayer;
+// var winheight = result.winheight;
+// var winwidth = result.winwidth;
+// document.addEventListener('DOMContentLoaded', function() {
+// console.log('Sending...')
+// document.getElementById("settings").contentWindow.postMessage(result, '*'); // '*' allows sending to any origin
+// console.log('Sent')
+// });
+// });
+// });
+// }
+// });
+
+// window.addEventListener('message', function(event) {
+// if (event.data === 'awaitConfig') {
+// console.log("'awaitConfig' Message from settings.js received by index.js");
+
+// window.addEventListener('pywebviewready', function() {
+// var settingsiframe = document.getElementById('settings');
+// pywebview.api.get_settings().then(function(result) {
+// console.log(result);
+// settingsiframe.contentWindow.postMessage(result, '*');
+// }).catch(function(error) {
+// console.error('Error fetching settings:', error);
+// });
+// });
+// }
+// });
+
+document.addEventListener('DOMContentLoaded', function() {
+ window.addEventListener('message', function(event) {
+ if (event.data === 'awaitConfig') {
+ console.log("'awaitConfig' Message from settings.js received by index.js")
+ // Sending settings to iframe (settings.html)
+ window.addEventListener('pywebviewready', function() {
+ var settingsiframe = document.getElementById('settings');
+ pywebview.api.get_settings().then(function(result) {
+ console.log(result);
+ // var customtheme = result.customtheme;
+ // var demomode = result.demomode;
+ // var firsttime = result.firsttime;
+ // var gamechat = result.gamechat;
+ // var javapath = result.javapath;
+ // var jvmargs = result.jvmargs;
+ // var lastaccount = result.lastaccount;
+ // var lastinstance = result.lastinstance;
+ // var maximizedefault = result.maximizedefault;
+ // var minmem = result.minmem;
+ // var maxmem = result.maxmem;
+ // var multiplayer = result.multiplayer;
+ // var winheight = result.winheight;
+ // var winwidth = result.winwidth;
+ localStorage.setItem('customtheme', result.customtheme);
+ localStorage.setItem('demomode', result.demomode);
+ localStorage.setItem('firsttime', result.firsttime);
+ localStorage.setItem('gamechat', result.gamechat);
+ localStorage.setItem('javapath', result.javapath);
+ localStorage.setItem('jvmargs', result.jvmargs);
+ localStorage.setItem('lastaccount', result.lastaccount);
+ localStorage.setItem('lastinstance', result.lastinstance);
+ localStorage.setItem('maximizedefault', result.maximizedefault);
+ localStorage.setItem('minmem', result.minmem);
+ localStorage.setItem('maxmem', result.maxmem);
+ localStorage.setItem('multiplayer', result.multiplayer);
+ localStorage.setItem('winheight', result.winheight);
+ localStorage.setItem('winwidth', result.winwidth);
+ });
+ });
+ }
});
});
@@ -40,6 +159,8 @@ function help(status) {
// Listen for messages from iframe
window.addEventListener('message', function(event) {
+ console.log(event)
+ console.log(event.data)
// Verify origin of the iframe (optional, for security)
// if (event.origin !== 'https://your-iframe-domain.com') return;
@@ -53,4 +174,4 @@ window.addEventListener('message', function(event) {
// Call help function in the parent window
help('hide');
}
-});
+});
\ No newline at end of file
diff --git a/main.py b/main.py
index 14e6528..4045761 100644
--- a/main.py
+++ b/main.py
@@ -2,6 +2,10 @@
import modelfetch
import json
import os
+import psutil
+import humanize
+import GPUtil
+import platform
from os import path
syshost=modelfetch.system.Model
@@ -27,7 +31,18 @@
config = {
"lastaccount": "",
"firsttime": 1,
- "lastinstance": ""
+ "lastinstance": "",
+ "maximizedefault": False,
+ "winwidth": 854,
+ "winheight": 480,
+ "demomode": False,
+ "multiplayer": True,
+ "gamechat": True,
+ "minmem": 512,
+ "maxmem": 1024,
+ "javapath": "javaw",
+ "jvmargs": "",
+ "customtheme": ""
}
configjson = json.dumps(config, indent=2)
with open(".zdkrimson\\settings.json", "w") as outfile:
@@ -35,47 +50,118 @@
lastaccount=""
firstime=1
lastinstance=""
+ maximizedefault=False
+ winwidth=854
+ winheight=480
+ demomode=False
+ multiplayer=True
+ gamechat=True
+ minmem=512
+ maxmem=1024
+ javapath="javaw" # a command gets executed instead assuming java's installed already
+ jvmargs=""
+ customtheme="" # themes aren't implemented yet, but i added this option anyway :p
if os.path.exists(".zdkrimson\\instances")==False:
- print("instances folder doesn't exist, created one just now.")
+ print("Instances Folder is missing! Folder has been created for you")
os.mkdir(".zdkrimson\\instances")
# loading json files
with open('.zdkrimson\\settings.json', 'r') as openfile:
configjson = json.load(openfile)
try:
- print(configjson['lastaccount'])
- print(configjson['firsttime'])
- print(configjson['lastinstance'])
lastaccount=configjson['lastaccount']
firsttime=configjson['firsttime']
lastinstance=configjson['lastinstance']
- print("imported settings json")
- print(lastaccount)
+ maximizedefault=configjson['maximizedefault']
+ winwidth=configjson['winwidth']
+ winheight=configjson['winheight']
+ demomode=configjson['demomode']
+ multiplayer=configjson['multiplayer']
+ gamechat=configjson['gamechat']
+ minmem=configjson['minmem']
+ maxmem=configjson['maxmem']
+ javapath=configjson['javapath']
+ jvmargs=configjson['jvmargs']
+ customtheme=configjson['customtheme']
+ # print(configjson)
+ print("Successfully imported 'settings.json'")
+ if lastaccount=="":
+ print("Last Used Account: Not Logged In!")
+ else:
+ print("Last Used Account:" + lastaccount)
except KeyError:
- print("Settings file isn't up-to-date")
+ print("Settings file isn't up-to-date, settings file should now be updated (info reset)")
config = {
"lastaccount": "",
"firsttime": 1,
- "lastinstance": ""
+ "lastinstance": "",
+ "maximizedefault": False,
+ "winwidth": 854,
+ "winheight": 480,
+ "demomode": False,
+ "multiplayer": True,
+ "gamechat": True,
+ "minmem": 512,
+ "maxmem": 1024,
+ "javapath": "javaw",
+ "jvmargs": "",
+ "customtheme": ""
}
configjson = json.dumps(config, indent=2)
with open(".zdkrimson\\settings.json", "w") as outfile:
outfile.write(configjson)
- lastaccount=""
+ lastaccount=""
firstime=1
lastinstance=""
+ maximizedefault=False
+ winwidth=854
+ winheight=480
+ demomode=False
+ multiplayer=True
+ gamechat=True
+ minmem=512
+ maxmem=1024
+ javapath="javaw" # a command gets executed instead assuming java's installed already
+ jvmargs=""
+ customtheme="" # themes aren't implemented yet, but i added this option anyway :p
class Api:
def get_host(self):
- print(syshost)
+ print("System Host: " + syshost)
return syshost
def get_username(self, uuid):
- print(uuid)
+ print("Account UUID: " + uuid)
if uuid=='recent':
return lastaccount
+ def get_recentinstance(self):
+ print("Last Instance: " + lastinstance)
+ return lastinstance
+
+ def get_settings(self):
+ return configjson
+
+ def get_mem(self):
+ # print('RAM: ' + psutil.virtual_memory().total)
+ print(psutil.virtual_memory().total)
+ print(humanize.naturalsize(psutil.virtual_memory().total))
+ return humanize.naturalsize(psutil.virtual_memory().total)
+
+ def get_gpu(self):
+ gpus = GPUtil.getGPUs()
+ if not gpus:
+ print('No GPUs Detected.')
+ return 'No Dedicated GPUs Found'
+ else:
+ print('GPU: ' + gpus.name)
+ return gpus.name
+
+ def get_cpu(self):
+ cpu_info = platform.uname()
+ print('CPU: ' + cpu_info.processor)
+ return cpu_info.processor
api = Api()
webview.create_window('zdkrimson', background_color="#210202", url="index.html", js_api=api)
webview.start(debug=True)
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index b452b90..bddc0b9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,10 @@
-customtkinter
-tkinter
+customtkinter - deprecated
pyngrok
requests
-portablemc
\ No newline at end of file
+portablemc
+pywebview
+wmi
+psutil
+humanize
+gputil
+lib-platform
\ No newline at end of file
diff --git a/settings.css b/settings.css
index 6e7d11c..7fa80fb 100644
--- a/settings.css
+++ b/settings.css
@@ -135,6 +135,7 @@ hr {
overflow-y: auto;
width: 100%;
height: 100%;
+ pointer-events: none;
}
.section {
diff --git a/settings.html b/settings.html
index dce0dac..b11e8d2 100644
--- a/settings.html
+++ b/settings.html
@@ -53,12 +53,12 @@
Launcher
Your Device
-
CPU:
-
GPU:
-
Memory:
-
Host:
-
Platform:
-
Resolution:
+
CPU: Loading...
+
GPU: Loading...
+
Memory: Loading...
+
Host: Loading...
+
Platform: Loading...
+
Resolution: Loading...
Minecraft Information
diff --git a/settings.js b/settings.js
index 9f844d2..14172ad 100644
--- a/settings.js
+++ b/settings.js
@@ -2,19 +2,31 @@ console.log("Platform: " + navigator.platform)
// Adds information on load
document.addEventListener('DOMContentLoaded', function() {
+ window.parent.postMessage('awaitConfig', '*');
var restext = document.getElementById('sysres');
var platformtext = document.getElementById('sysplat');
var syshost = document.getElementById('syshost');
-
- syshost.textContent = "Host: " + parent.hostmachine;
+ var sysmem = document.getElementById("sysmem");
+ var sysgpu = document.getElementById("sysgpu");
+ var syscpu = document.getElementById("syscpu");
+ var launcher = document.getElementById("launcher");
restext.textContent = "Resolution: " + window.screen.width + "x" + window.screen.height;
platformtext.textContent = "Platform: " + navigator.platform;
+ launcher.classList.add("fadein");
+ setTimeout(function(){
+ syshost.textContent = "Host: " + localStorage.getItem('hostmachine');
+ sysmem.textContent = "Memory: " + localStorage.getItem('sysmem');
+ sysgpu.textContent = "GPU: " + localStorage.getItem('sysgpu');
+ syscpu.textContent = "CPU: " + localStorage.getItem('syscpu');
+ }, 3000);
});
-window.addEventListener('pywebviewready', function(event) {
- console.log('ready')
-});
+
+// window.addEventListener('message', function(event) {
+// console.log(event)
+// console.log(event.data)
+// });
function closeSettings() {
// Send message from iframe to parent window