This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
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
0 parents
commit 2027c91
Showing
16 changed files
with
4,962 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Packages & Libs | ||
node_modules | ||
|
||
# Logs | ||
yarn-error.log | ||
npm-debug.log | ||
|
||
# Distribution Files | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"git.ignoreLimitWarning": true | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const gulp = require('gulp'); | ||
const sass = require('gulp-sass'); | ||
|
||
sass.compiler = require('node-sass'); | ||
|
||
gulp.task('sass', function () { | ||
return gulp.src('./src/scss/style.scss') | ||
.pipe(sass().on('error', sass.logError)) | ||
.pipe(gulp.dest('./src/public')); | ||
}); | ||
|
||
gulp.task('sass:watch', function () { | ||
gulp.watch('./src/scss/style.scss', ['sass']); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "myrpc", | ||
"version": "1.0.0", | ||
"description": "Distributed Discord RPC for @everyone!", | ||
"main": "src/main.js", | ||
"repository": "https://github.com/RailRunner166/MyRpc.git", | ||
"author": "Landon Gravat <[email protected]>", | ||
"license": "MIT", | ||
"private": false, | ||
"scripts": { | ||
"launch": "electron src/main.js", | ||
"styles": "gulp sass", | ||
"pack": "electron-builder --dir", | ||
"dist": "electron-builder" | ||
}, | ||
"build": { | ||
"appId": "me.railrunner16.myrpc", | ||
"productName": "MyRPC", | ||
"win": { | ||
"target": "msi", | ||
"icon": "src/assets/logo_square_512.png" | ||
} | ||
}, | ||
"dependencies": { | ||
"discord-rich-presence": "^0.0.7", | ||
"moment": "^2.23.0", | ||
"register-scheme": "github:devsnek/node-register-scheme" | ||
}, | ||
"devDependencies": { | ||
"electron": "^4.0.0", | ||
"electron-builder": "^20.38.4", | ||
"gulp": "^4.0.0", | ||
"gulp-sass": "^4.0.2", | ||
"node-sass": "^4.11.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
'use strict'; | ||
|
||
/* eslint-disable no-console */ | ||
|
||
const { app, BrowserWindow, nativeImage, ipcMain, globalShortcut } = require('electron'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
const rpc = require('discord-rich-presence')('528735337015410712'); | ||
|
||
const startTimestamp = new Date(); | ||
const rpcData = { | ||
startTimestamp, | ||
instance: true, | ||
details: 'Using MyRPC', | ||
state: 'Being totally awesome', | ||
largeImageText: 'MyRPC', | ||
smallImageText: 'Made by RailRunner16', | ||
largeImageKey: 'large_default', | ||
smallImageKey: 'small_default' | ||
} | ||
|
||
let mainWindow; | ||
|
||
const createWindow = () => { | ||
mainWindow = new BrowserWindow({ | ||
width: 1200, | ||
height: 1000, | ||
resizable: true, | ||
titleBarStyle: 'hidden', | ||
}); | ||
|
||
mainWindow.loadURL(url.format({ | ||
pathname: path.join(__dirname, 'public/index.html'), | ||
protocol: 'file:', | ||
slashes: true, | ||
})); | ||
|
||
const icon = nativeImage.createFromPath(path.join(__dirname, 'assets/logo_square_512.png')); | ||
mainWindow.setIcon(icon); | ||
|
||
mainWindow.on('closed', () => { | ||
mainWindow = null; | ||
}); | ||
} | ||
|
||
const setActivity = data => { | ||
if (!rpc || !mainWindow) { | ||
return; | ||
} | ||
|
||
return rpc.updatePresence(data); | ||
} | ||
|
||
app.on('ready', () => { | ||
createWindow() | ||
app.setName('MyRPC') | ||
|
||
globalShortcut.register('CommandOrControl+Shift+I', () => { | ||
mainWindow.webContents.openDevTools(); | ||
}); | ||
|
||
setActivity(rpcData); | ||
}); | ||
|
||
app.on('window-all-closed', () => { | ||
app.quit(); | ||
}); | ||
|
||
app.on('activate', () => { | ||
if (mainWindow === null) { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
ipcMain.on('asynchronous-message', (e, data) => { | ||
rpcData.details = data.details; | ||
rpcData.state = data.state; | ||
rpcData.largeImageText = data.largeImageText; | ||
rpcData.smallImageText = data.smallImageText; | ||
rpcData.largeImageKey = data.largeImageKey; | ||
rpcData.smallImageKey = data.smallImageKey; | ||
|
||
console.debug(rpcData); | ||
|
||
setActivity(rpcData); | ||
}) | ||
|
||
ipcMain.on('synchronous-message', (e, action) => { | ||
switch (action.toLowerCase()) { | ||
case 'get_time': | ||
e.returnValue = startTimestamp; | ||
} | ||
}); | ||
|
||
process.on('unhandledRejection', console.error); |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>MyRPC</title> | ||
<link rel=stylesheet href=style.css /> | ||
</head> | ||
<body> | ||
<h1 class="ui header"> | ||
MyRPC | ||
<span class="sub header">Easily set your Discord status to anything!</span> | ||
</h1> | ||
|
||
<div class="ui grid"> | ||
<div class="column"> | ||
<div class="ui form"> | ||
<div class="input"> | ||
<label for="inputDetails">Details</label> | ||
<input type="text" name="inputDetails" id="inputDetails" /> | ||
</div> | ||
<div class="input"> | ||
<label for="inputState">State</label> | ||
<input type="text" name="inputState" id="inputState" /> | ||
</div> | ||
<div class="input"> | ||
<label for="inputLargeImageText">Large Image Text</label> | ||
<input type="text" name="inputLargeImageText" id="inputLargeImageText" /> | ||
</div> | ||
<div class="input"> | ||
<label for="inputSmallImageText">Small Image Text</label> | ||
<input type="text" name="inputSmallImageText" id="inputSmallImageText" /> | ||
</div> | ||
<div class="input"> | ||
<label for="selectLargeImageKey">Large Image</label> | ||
<select name="selectLargeImageKey" id="selectLargeImageKey"> | ||
<option selected value="large_default">Default</option> | ||
</select> | ||
</div> | ||
<div class="input"> | ||
<label for="selectSmallImageKey">Small Image</label> | ||
<select name="selectSmallImageKey" id="selectSmallImageKey"> | ||
<option selected value="small_default">Default</option> | ||
</select> | ||
</div> | ||
|
||
<button id="buttonSubmit">Make it So!</button> | ||
</div> | ||
</div> | ||
<div class="column"> | ||
<div class="ui preview"> | ||
<div class="images"> | ||
<img class="big image" id="previewBigImg" alt="MyRPC" src="https://cdn.discordapp.com/app-assets/528735337015410712/528749698408906752.png"> | ||
<img class="small image" id="previewSmallImg" alt="Made by RailRunner16" src="https://cdn.discordapp.com/app-assets/528735337015410712/528761124267753473.png"> | ||
</div> | ||
<div class="info"> | ||
<span class="text row name">MyRPC</span> | ||
<span id="previewDetailsText" class="text row">Using MyRPC</span> | ||
<span id="previewStateText" class="text row">Being Totally Awesome</span> | ||
<span id="previewTimestampText" class="text row">00:00 elapsed</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<span class="ui credits">Made by <a class="link" title="chat.railrunner16.me" href="http://chat.railrunner16.me/" rel="nofollow" target="_blank">RailRunner16#0001</a> (Friend me on Discord!) with <span title="Love">❤️</span> and <span title="code">⌨️</span>.</span> | ||
<script src=renderer.js></script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use strict'; | ||
|
||
/* eslint-env browser */ | ||
|
||
const { ipcRenderer } = require('electron'); | ||
const moment = require('moment'); | ||
|
||
const time = ipcRenderer.sendSync('synchronous-message', 'get_time'); | ||
|
||
const detailsInput = document.getElementById('inputDetails'); | ||
const stateInput = document.getElementById('inputState'); | ||
const largeImageTextInput = document.getElementById('inputLargeImageText'); | ||
const smallImageTextInput = document.getElementById('inputSmallImageText'); | ||
const largeImageKeySelect = document.getElementById('selectLargeImageKey'); | ||
const smallImageKeySelect = document.getElementById('selectSmallImageKey'); | ||
const submitButton = document.getElementById('buttonSubmit'); | ||
|
||
const data = { | ||
details: 'Using MyRPC', | ||
state: 'Being totally awesome', | ||
largeImageText: 'MyRPC', | ||
smallImageText: 'Made by RailRunner16', | ||
largeImageKey: 'large_default', | ||
smallImageKey: 'small_default', | ||
}; | ||
|
||
const assets = { | ||
large_default: 'https://cdn.discordapp.com/app-assets/528735337015410712/528749698408906752.png', | ||
small_default: 'https://cdn.discordapp.com/app-assets/528735337015410712/528761124267753473.png', | ||
}; | ||
|
||
const updateInputs = () => { | ||
detailsInput.value = data.details; | ||
stateInput.value = data.state; | ||
largeImageTextInput.value = data.largeImageText; | ||
smallImageTextInput.value = data.smallImageText; | ||
largeImageKeySelect.value = data.largeImageKey; | ||
smallImageKeySelect.value = data.smallImageKey; | ||
}; | ||
|
||
const updatePreview = () => { | ||
data.details = detailsInput.value; | ||
data.state = stateInput.value; | ||
data.largeImageText = largeImageTextInput.value; | ||
data.smallImageText = smallImageTextInput.value; | ||
data.largeImageKey = largeImageKeySelect.value; | ||
data.smallImageKey = smallImageKeySelect.value; | ||
|
||
document.getElementById('previewDetailsText').innerHTML = data.details; | ||
document.getElementById('previewStateText').innerHTML = data.state; | ||
document.getElementById('previewTimestampText').innerHTML = `${moment(time).fromNow(true)} elapsed`; | ||
|
||
document.getElementById('previewBigImg').alt = data.largeImageText; | ||
document.getElementById('previewSmallImg').alt = data.smallImageText; | ||
|
||
document.getElementById('previewBigImg').src = assets[data.largeImageKey]; | ||
document.getElementById('previewSmallImg').src = assets[data.smallImageKey]; | ||
}; | ||
|
||
detailsInput.onchange = updatePreview; | ||
stateInput.onchange = updatePreview; | ||
largeImageTextInput.onchange = updatePreview; | ||
smallImageTextInput.onchange = updatePreview; | ||
largeImageKeySelect.onchange = updatePreview; | ||
smallImageKeySelect.onchange = updatePreview; | ||
|
||
updateInputs(); | ||
|
||
submitButton.onclick = () => { | ||
data.details = `${detailsInput.value}`; | ||
data.state = `${stateInput.value}`; | ||
data.largeImageText = `${largeImageTextInput.value}`; | ||
data.smallImageText = `${smallImageTextInput.value}`; | ||
data.largeImageKey = `${largeImageKeySelect.value}`; | ||
data.smallImageKey = `${smallImageKeySelect.value}`; | ||
|
||
ipcRenderer.send('asynchronous-message', data); | ||
|
||
updateInputs(); | ||
updatePreview(); | ||
}; | ||
|
||
setInterval(updatePreview, 100); | ||
|
||
document.onerror = console.error; |
Oops, something went wrong.