-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e11847
commit a2a618d
Showing
7 changed files
with
117 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,14 @@ | |
* Github: https://github.com/lolitee | ||
* Discord: Tee#0001 | ||
* | ||
* Last Modified: Sunday, 12th February 2023 4:41:29 pm | ||
* Last Modified: Monday, 8th May 2023 11:23:00 am | ||
* Modified By: Tee ([email protected]) | ||
* | ||
* Copyright (c) 2023 Tee, Stainless Love | ||
*/ | ||
|
||
|
||
import { rpcConfiguration, extensionConfiguration, hasProp, getConfiguration, setConfiguration } from "./configuration"; | ||
// import { rpcConfiguration, extensionConfiguration, hasProp, getConfiguration, setConfiguration } from "./configuration"; | ||
|
||
const csInterface = new CSInterface(); | ||
|
||
|
@@ -27,31 +27,15 @@ class Controller { | |
} | ||
|
||
init(){ | ||
this.logz("Initializing localstorage") | ||
this.logz("Registering log event") | ||
csInterface.addEventListener('com.tee.panel.log', (e) => { | ||
this.logz(e.data) | ||
}) | ||
|
||
if (!getConfiguration('rpc')){ | ||
this.logz("Defining rpc configuration") | ||
setConfiguration('rpc', rpcConfiguration) | ||
} | ||
|
||
if(!hasProp(getConfiguration('rpc'), rpcConfiguration)){ | ||
this.logz("Mismatched Rich Presence configuration, resetting!") | ||
setConfiguration('rpc', rpcConfiguration) | ||
} | ||
|
||
if (!getConfiguration('extension')){ | ||
this.logz("Defining extension configuration") | ||
setConfiguration('extension', extensionConfiguration) | ||
} | ||
|
||
if(!hasProp(getConfiguration('extension'), extensionConfiguration)){ | ||
this.logz("Mismatched Extension configuration, resetting!") | ||
setConfiguration('extension', extensionConfiguration) | ||
} | ||
this.logz("Registering localstorage") | ||
csInterface.addEventListener('com.tee.panel.localstorage', (e) => { | ||
window.localStorage.setItem(e.data.name, e.data.value) | ||
}) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,34 @@ | |
* Github: https://github.com/lolitee | ||
* Discord: Tee#0001 | ||
* | ||
* Last Modified: Sunday, 12th February 2023 7:43:21 pm | ||
* Last Modified: Wednesday, 10th May 2023 10:21:25 am | ||
* Modified By: Tee ([email protected]) | ||
* | ||
* Copyright (c) 2023 Tee, Stainless Love | ||
*/ | ||
|
||
import React from 'react'; | ||
import React, {useEffect, useState} from 'react'; | ||
import ConfigItem from '../components/ConfigItem' | ||
import { rpcConfiguration, extensionConfiguration } from '../configuration'; | ||
import { dispatchEvent } from '..'; | ||
export default function Config() { | ||
|
||
const [config, setConfig] = useState({}) | ||
|
||
useEffect(() => { | ||
|
||
|
||
dispatchEvent("com.tee.rpc.update", {}) | ||
window.parent.csInterface.addEventListener("com.tee.rpc.config", (e) => { | ||
setConfig(e.data) | ||
console.log(e.data) | ||
}) | ||
|
||
}, []) | ||
|
||
return ( | ||
<div className='flex flex-col gap-2'> | ||
<ConfigItem title="Rich Presence Configuration" configuration={rpcConfiguration} /> | ||
<ConfigItem title="Extension Configuration" configuration={extensionConfiguration} /> | ||
{/* <ConfigItem title="Rich Presence Configuration" configuration={rpcConfiguration} /> */} | ||
{/* <ConfigItem title="Extension Configuration" configuration={extensionConfiguration} /> */} | ||
|
||
<div className='flex flex-row gap-2 self-center'> | ||
<button className='bg-button p-2 text-xs text-white rounded-sm'>Save Configuration</button> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* Github: https://github.com/lolitee | ||
* Discord: Tee#0001 | ||
* | ||
* Last Modified: Sunday, 12th February 2023 2:47:45 pm | ||
* Last Modified: Sunday, 12th February 2023 8:03:13 pm | ||
* Modified By: Tee ([email protected]) | ||
* | ||
* Copyright (c) 2023 Tee, Stainless Love | ||
|
@@ -38,7 +38,7 @@ export default function Preview() { | |
}, []) | ||
|
||
return ( | ||
<div className="w-screen rounded overflow-hidden h-96 pt-4"> | ||
<div className="w-screen rounded-sm overflow-hidden h-96 pt-4"> | ||
<div className="flex justify-center"> | ||
<div className="flex flex-col self-center bg-black rounded-sm"> | ||
<div className="flex flex-col -space-y-12"> | ||
|
175 changes: 86 additions & 89 deletions
175
src/client-src/configuration.js → src/rpc_client-src/localstorage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,87 @@ | ||
/* | ||
* File: configuration.js | ||
* Project: discord-rpc | ||
* File Created: Sunday, 12th February 2023 2:13:24 pm | ||
* Author: Tee ([email protected]) | ||
* Github: https://github.com/lolitee | ||
* Discord: Tee#0001 | ||
* | ||
* Last Modified: Sunday, 12th February 2023 7:12:57 pm | ||
* Modified By: Tee ([email protected]) | ||
* | ||
* Copyright (c) 2023 Tee, Stainless Love | ||
*/ | ||
|
||
export const rpcConfiguration = { | ||
details: { | ||
enabled: true, | ||
description: "", | ||
name: "Details" | ||
}, | ||
state: { | ||
enabled: true, | ||
description: "", | ||
name: "State" | ||
}, | ||
timestamp: { | ||
enabled: true, | ||
description: "", | ||
name: "Timestamp" | ||
}, | ||
largeImage: 'logo', | ||
largeImageKey: { | ||
enabled: true, | ||
description: "", | ||
name: "Large Icon" | ||
}, | ||
largeImageText: { | ||
enabled: true, | ||
description: "", | ||
name: "Large Icon Text" | ||
}, | ||
customLargeImage: { | ||
enabled: false, | ||
description: "", | ||
name: "Custom Icon" | ||
}, | ||
smallImageKey: { | ||
enabled: true, | ||
description: "", | ||
name: "Small Icon" | ||
}, | ||
smallImageText: { | ||
enabled: true, | ||
description: "", | ||
name: "Small Icon Text" | ||
}, | ||
} | ||
|
||
export const extensionConfiguration = { | ||
enabled: { | ||
enabled: true, | ||
description: "", | ||
name: "Rich Presence Enable" | ||
}, | ||
updateNotification: { | ||
enabled: true, | ||
description: "", | ||
name: "Update Notification" | ||
}, | ||
catMode: { | ||
enabled: false, | ||
description: "", | ||
name: "Cat Mode" | ||
}, | ||
} | ||
|
||
export function setConfiguration(name, configuration){ | ||
window.localStorage.setItem(name, configuration); | ||
} | ||
|
||
export function getConfiguration(name, property){ | ||
if(!property){ | ||
return window.localStorage.getItem(name) | ||
} | ||
return window.localStorage.getItem(name)[property] | ||
} | ||
|
||
export function hasProp(obj, prop) { | ||
return Object.keys(obj) === Object.keys(prop) ? true : false; | ||
/* | ||
* File: localstorage.js | ||
* Project: discord-rpc-client | ||
* File Created: Sunday, 12th February 2023 9:36:50 pm | ||
* Author: Tee ([email protected]) | ||
* Github: https://github.com/lolitee | ||
* Discord: Tee#0001 | ||
* | ||
* Last Modified: Sunday, 12th February 2023 9:41:04 pm | ||
* Modified By: Tee ([email protected]) | ||
* | ||
* Copyright (c) 2023 Tee, Stainless Love | ||
*/ | ||
|
||
const csInterface = new CSInterface(); | ||
|
||
export const rpcConfiguration = { | ||
enabled: { | ||
enabled: true, | ||
description: "", | ||
name: "Rich Presence Enable" | ||
}, | ||
details: { | ||
enabled: true, | ||
description: "", | ||
name: "Details" | ||
}, | ||
state: { | ||
enabled: true, | ||
description: "", | ||
name: "State" | ||
}, | ||
timestamp: { | ||
enabled: true, | ||
description: "", | ||
name: "Timestamp" | ||
}, | ||
largeImageKey: { | ||
enabled: true, | ||
description: "", | ||
name: "Large Icon" | ||
}, | ||
largeImageText: { | ||
enabled: true, | ||
description: "", | ||
name: "Large Icon Text" | ||
}, | ||
smallImageKey: { | ||
enabled: true, | ||
description: "", | ||
name: "Small Icon" | ||
}, | ||
smallImageText: { | ||
enabled: true, | ||
description: "", | ||
name: "Small Icon Text" | ||
}, | ||
} | ||
|
||
export const extensionConfiguration = { | ||
updateNotification: { | ||
enabled: true, | ||
description: "", | ||
name: "Update Notification" | ||
}, | ||
catMode: { | ||
enabled: false, | ||
description: "", | ||
name: "Cat Mode" | ||
}, | ||
} | ||
|
||
export function setConfiguration(name, configuration){ | ||
window.localStorage.setItem(name, configuration); | ||
csInterface.dispatchEvent('com.tee.panel.settings') | ||
} | ||
|
||
export function getConfiguration(name, property){ | ||
if(!property){ | ||
return window.localStorage.getItem(name) | ||
} | ||
return window.localStorage.getItem(name)[property] | ||
} | ||
|
||
export function hasProp(obj, prop) { | ||
return Object.keys(obj) === Object.keys(prop) ? true : false; | ||
}; |