Merge pull request #180 from JsSucks/configs

Configs
This commit is contained in:
Alexei Stukov 2018-03-19 14:20:28 -03:00 committed by GitHub
commit 122036fd14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 770 additions and 59 deletions

View File

@ -44,7 +44,7 @@ export default class {
* returns {String}
*/
static get contentPath() {
return this._contentPath ? this._contentPath : (this._contentPath = Globals.getObject('paths').find(path => path.id === this.pathId).path);
return Globals.getPath(this.pathId);
}
/**

View File

@ -63,4 +63,16 @@ export default new class extends Module {
return this.state[name];
}
getPath(id) {
return this.state.paths.find(path => path.id === id).path;
}
static get paths() {
return this.state.paths;
}
static get version() {
return this.state.version;
}
}

View File

@ -133,6 +133,6 @@ export default new class Settings {
}
get dataPath() {
return this._dataPath ? this._dataPath : (this._dataPath = Globals.getObject('paths').find(p => p.id === 'data').path);
return Globals.getPath('data');
}
}

View File

@ -48,8 +48,8 @@ export default class {
try {
Events.emit('update-check-end');
Logger.info('Updater',
`Latest Version: ${e.version} - Current Version: ${Globals.getObject('version')}`);
if (e.version !== Globals.getObject('version')) {
`Latest Version: ${e.version} - Current Version: ${Globals.version}`);
if (e.version !== Globals.version) {
this.updatesAvailable = true;
Events.emit('updates-available');
}

View File

@ -11,39 +11,41 @@
const path = require('path');
const sass = require('node-sass');
/**
* DEVELOPMENT VARIABLES
*/
const clientScriptPath = path.resolve(__dirname, '..', '..', 'client', 'dist').replace(/\\/g, '/');
const __DEV = {
TESTING: false,
clientScriptPath: `${clientScriptPath}/betterdiscord.client.js`
}
const __dataPath = path.resolve(__dirname, '..', '..', 'tests', 'data');
const __pluginPath = path.resolve(__dirname, '..', '..', 'tests', 'plugins');
const __themePath = path.resolve(__dirname, '..', '..', 'tests', 'themes');
const __modulePath = path.resolve(__dirname, '..', '..', 'tests', 'modules');
const { Utils, FileUtils, BDIpc, Config, WindowUtils, CSSEditor, Database } = require('./modules');
const { FileUtils, BDIpc, Config, WindowUtils, CSSEditor, Database } = require('./modules');
const { BrowserWindow, dialog } = require('electron');
const tests = true;
const _clientScript = tests
? path.resolve(__dirname, '..', '..', 'client', 'dist', 'betterdiscord.client.js')
: path.resolve(__dirname, 'betterdiscord.client.js');
const _dataPath = tests
? path.resolve(__dirname, '..', '..', 'tests', 'data')
: path.resolve(__dirname, 'data');
const _extPath = tests
? path.resolve(__dirname, '..', '..', 'tests', 'ext')
: path.resolve(__dirname, 'ext');
const _pluginPath = path.resolve(_extPath, 'plugins');
const _themePath = path.resolve(_extPath, 'themes');
const _modulePath = path.resolve(_extPath, 'modules');
const paths = [
{ id: 'cs', path: _clientScript.replace(/\\/g, '/') },
{ id: 'data', path: _dataPath.replace(/\\/g, '/') },
{ id: 'ext', path: _extPath.replace(/\\/g, '/') },
{ id: 'plugins', path: _pluginPath.replace(/\\/g, '/') },
{ id: 'themes', path: _themePath.replace(/\\/g, '/') },
{ id: 'modules', path: _modulePath.replace(/\\/g, '/') }
];
const sparkplug = path.resolve(__dirname, 'sparkplug.js').replace(/\\/g, '/');
const Common = {};
const globals = {
version: '2.0.0a',
paths
}
const dummyArgs = {
'version': '2.0.0a',
'paths': [
{ 'id': 'base', 'path': 'basePath' },
{ 'id': 'data', 'path': __dataPath },
{ 'id': 'plugins', 'path': __pluginPath },
{ 'id': 'themes', 'path': __themePath },
{ 'id': 'modules', 'path': __modulePath }
]
};
const dbInstance = new Database(dummyArgs.paths.find(path => path.id === 'data').path);
console.log(dummyArgs);
const dbInstance = new Database(paths.find(path => path.id === 'data').path);
class Comms {
@ -120,7 +122,6 @@ class BetterDiscord {
constructor(args) {
if (BetterDiscord.loaded) {
// Creating two BetterDiscord objects???
console.log('Creating two BetterDiscord objects???');
return null;
}
@ -128,7 +129,7 @@ class BetterDiscord {
this.injectScripts = this.injectScripts.bind(this);
this.ignite = this.ignite.bind(this);
Common.Config = new Config(args || dummyArgs);
Common.Config = new Config(globals);
this.comms = new Comms(this);
this.init();
}
@ -139,16 +140,6 @@ class BetterDiscord {
this.csseditor = new CSSEditor(this);
//Log some events for now
//this.windowUtils.webContents.on('did-start-loading', e => this.windowUtils.executeJavascript(`console.info('did-start-loading');`));
//this.windowUtils.webContents.on('did-stop-loading', e => this.windowUtils.executeJavascript(`console.info('did-stop-loading');`));
//this.windowUtils.webContents.on('did-get-response-details', e => this.ignite(this.windowUtils.window));
//this.windowUtils.webContents.on('page-favicon-updated', e => this.windowUtils.executeJavascript(`console.info('page-favicon-updated');`));
//this.windowUtils.webContents.on('will-navigate', e => this.windowUtils.executeJavascript(`console.info('will-navigate');`));
//this.windowUtils.webContents.on('did-navigate', e => this.windowUtils.executeJavascript(`console.info('did-navigate');`));
//this.windowUtils.webContents.on('did-navigate-in-page', e => this.windowUtils.executeJavascript(`console.info('did-navigate-in-page');`));
//this.windowUtils.webContents.on('did-finish-load', e => this.injectScripts(true));
this.windowUtils.events('did-get-response-details', () => this.ignite(this.windowUtils.window));
this.windowUtils.events('did-finish-load', e => this.injectScripts(true));
@ -157,13 +148,13 @@ class BetterDiscord {
});
setTimeout(() => {
if (__DEV) { this.injectScripts(); }
this.injectScripts();
}, 500);
}
async waitForWindow() {
const self = this;
return new Promise((resolve, reject) => {
return new Promise(resolve => {
const defer = setInterval(() => {
const windows = BrowserWindow.getAllWindows();
@ -173,13 +164,7 @@ class BetterDiscord {
});
}
if (__DEV && __DEV.TESTING && windows.length > 0) {
resolve(windows[0]);
clearInterval(defer);
return;
}
if (windows.length === 1 && windows[0].webContents.getURL().includes("discordapp.com")) {
if (windows.length === 1 && windows[0].webContents.getURL().includes('discordapp.com')) {
resolve(windows[0]);
clearInterval(defer);
}
@ -189,15 +174,12 @@ class BetterDiscord {
ignite(window) {
//Hook things that Discord removes from global. These will be removed again in the client script
const sp = path.resolve(__dirname, 'sparkplug.js').replace(/\\/g, '/');
window.webContents.executeJavaScript(`require("${sp}");`);
window.webContents.executeJavaScript(`require("${sparkplug}");`);
}
injectScripts(reload = false) {
console.log(`RELOAD? ${reload}`);
if (__DEV) {
this.windowUtils.injectScript(__DEV.clientScriptPath);
}
this.windowUtils.injectScript(paths.find(path => path.id === 'cs').path);
}
get fileUtils() { return FileUtils; }

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

BIN
tests/ext/themes/SimplerFlat/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,198 @@
{
"info": {
"name": "SimplerFlat",
"authors": [ "Qwerasd" ],
"version": 1.02,
"description": "SimplerFlat is a solid colored dark flat theme with customizable colors.",
"type": "sass"
},
"main": "index.scss",
"defaultConfig": [
{
"category": "not default",
"category_name": "not default",
"type": "drawer",
"settings": [
{
"id": "color-light",
"type": "color",
"value": "#3E3E3E",
"text": "Light Color",
"hint": "The color of things that are lighter than the chat panel."
},
{
"id": "color-medium",
"type": "color",
"value": "#2E2E2E",
"text": "Medium Color",
"hint": "The color of the chat panel."
},
{
"id": "color-dark",
"type": "color",
"value": "#1E1E1E",
"text": "Dark Color",
"hint": "The color of the channels, and members panels."
},
{
"id": "color-very-dark",
"type": "color",
"value": "#0E0E0E",
"text": "Very Dark Color",
"hint": "The color of the guilds sidebar."
},
{
"id": "main-color",
"type": "color",
"value": "#00FAFA",
"text": "Accent Color",
"hint": "For when a little bit of sophistication is required."
},
{
"id": "main-text-color",
"type": "color",
"value": "#FAFAFA",
"text": "Text Color",
"hint": "Most text will be this color."
},
{
"id": "chat-text-color",
"type": "color",
"value": "#FFFFFF",
"text": "Chat Color",
"hint": "Text in the chat pane will be this color."
},
{
"id": "code-text-color",
"type": "color",
"value": "#CCCCCC",
"text": "Code Color",
"hint": "Non syntax-highlighted code in codeblocks will be this color."
},
{
"id": "tint-color",
"type": "color",
"value": "#00FAFA",
"text": "Tint Color",
"hint": "Tint all of the background colors using this color."
},
{
"id": "tint-strength",
"type": "slider",
"value": 0,
"min": 0,
"max": 100,
"step": 0.5,
"unit": "%",
"multi": "0.5",
"text": "Tint Strength",
"hint": "How strongly to tint the background colors."
},
{
"id": "collapsing-panels",
"type": "bool",
"value": false,
"text": "Collapsing Side Panels",
"hint": "Fancy channels and members panels that hide themselves when not needed."
},
{
"id": "compact-server-list",
"type": "bool",
"value": false,
"text": "Compact Server List",
"hint": "Squishes together your servers so that they take up less space."
}
]
}
],
"configSchemes": [
{
"id": "default",
"name": "Default Colors",
"hint": "The basic colors -- good for tinting.",
"settings": [
{
"category": "default",
"settings": [
{
"id": "color-light",
"value": "#3E3E3E"
},
{
"id": "color-medium",
"value": "#2E2E2E"
},
{
"id": "color-dark",
"value": "#1E1E1E"
},
{
"id": "color-very-dark",
"value": "#0E0E0E"
},
{
"id": "main-color",
"value": "#00FAFA"
},
{
"id": "main-text-color",
"value": "#FAFAFA"
},
{
"id": "chat-text-color",
"value": "#FFFFFF"
},
{
"id": "code-text-color",
"value": "#CCCCCC"
}
]
}
]
},
{
"id": "high-contrast",
"name": "High Contrast",
"hint": "Very high contrast scheme.",
"settings": [
{
"category": "default",
"settings": [
{
"id": "color-light",
"value": "#CCCCCC"
},
{
"id": "color-medium",
"value": "#000000"
},
{
"id": "color-dark",
"value": "#000000"
},
{
"id": "color-very-dark",
"value": "#000000"
},
{
"id": "main-color",
"value": "#FFFFFF"
},
{
"id": "main-text-color",
"value": "#FFFFFF"
},
{
"id": "chat-text-color",
"value": "#FFFFFF"
},
{
"id": "code-text-color",
"value": "#FFFFFF"
}
]
}
]
}
]
}

View File

@ -0,0 +1,479 @@
/*
SimplerFlat | Copyright © 2018, Qwerasd | All rights reserved | DO NOT DISTRIBUTE
*/
@import 'vars';
/* Panel colors */
/* Center panel */
.chat, .messages-wrapper, .chat>.content, .chat form, .chat div[class^="titleWrapper"]>div, div[class^="typing"] {
background-color: $color-medium!important;
}
/* User list panel */
.channel-members-wrap, .channel-members {
background-color: $color-dark!important;
}
/* Channel list panel */
div[class^="channels"], div[class^="channels"]>div[class^="flex"] {
background-color: $color-dark!important;
}
.guild {
background-color: transparent!important;
}
.guilds-add {
background-color: $color-very-dark!important;
}
.guilds-add, .guilds-add-inner {
color: $color-light!important;
border-color: $color-light!important;
}
/* Guilds list panel */
div#app-mount[class^="appMount"], div.guilds-wrapper {
background-color: $color-very-dark;
}
.app.flex-vertical>div[class^="layers-"],
.app.flex-vertical>div[class^="layers-"]>div[class^="layer-"],
.app.flex-vertical>div[class^="layers-"]>div[class^="layer-"]>div[class^="flex-"] {
background-color: $color-very-dark;
}
/* Right settings panel */
.ui-standard-sidebar-view .content-region {
background-color: $color-medium!important;
}
/* Left settings panel */
.ui-standard-sidebar-view .sidebar-region {
background-color: $color-dark!important;
}
/* Friends panel */
#friends, #friends>div {
background-color: $color-medium!important;
}
/* Context menus */
div[class^="contextMenu"] {
background-color: $color-dark!important;
}
div[class^="contextMenu"] div[class^="itemGroup"] div[class^="item"] {
background-color: $color-dark!important;
}
div[class^="contextMenu"] div[class^="itemGroup"] div[class^="item"]:hover {
background-color: $color-very-dark!important;
}
/* nochannel */
div[class^="noChannel"] {
background-color: $color-medium!important;
}
/* cards */
div[class^="row"]>div[class^="flex"]:before {
background-color: $color-dark!important;
border-color: $color-very-dark!important;
}
/* modals */
div[class^="theme-light wrapper"] {
background: transparent;
}
.form-header header, div[class^="blurb"], div[class^="expireText"] {
color: $main-text-color!important;
}
div[class^="modal-"] form {
border-radius: 5px;
}
div[class^="modal-"] form, .form-header, .form-inner {
background-color: $color-medium!important;
}
div[class^="modal-"] form>div:last-child, .form-actions {
background-color: $color-dark!important;
}
/* themed popouts */
.themed-popout {
background-color: $color-dark!important;
}
.themed-popout .header, .messages-popout .message-group {
background-color: $color-medium!important;
}
/* search results */
.search-results-wrap {
background-color: $color-medium!important;
}
.search-header {
background-color: $color-dark!important;
}
.search-result-message.hit {
background-color: $color-dark!important;
box-shadow: none!important;
}
.search-results-wrap .channel-separator .channel-name, .search-result:before, .search-result:after {
background: transparent!important;
}
.message-group:hover .action-buttons {
background: transparent!important;
box-shadow: none!important;
}
.action-buttons>div {
background-color: $color-light!important;
color: $color-very-dark!important;
border-radius: 3px;
}
.action-buttons>div>.text {
color: $color-very-dark!important;
}
/* Various other things */
.popout>div>div[class^="body"], .popout>div>div[class^="footer"] {
background-color: $color-dark!important;
}
/* Scroll bars */
.scroller-wrap .scroller::-webkit-scrollbar-track-piece, .bd-scroller-wrap .bd-scroller::-webkit-scrollbar-track-piece {
background-color: $color-medium!important;
background-clip:padding-box;
border:3px solid $color-light!important;
border-radius:7px;
}
.scroller-wrap .scroller::-webkit-scrollbar-thumb, .bd-scroller-wrap .bd-scroller::-webkit-scrollbar-thumb {
background-clip:padding-box;
background-color:$color-dark!important;
border:3px solid $color-light!important;
border-radius:7px;
}
/* Other bits and bobs */
div[class^="searchBar"], .searchBar-YMJBu9 {
background-color: $color-light!important;
}
/* message inside modal */
form div[class^="message"] {
background-color: $color-dark!important;
}
/* new messages divider */
.messages .divider span {
background-color: $color-medium!important;
}
/* Command autosuggest */
div[class^="autocomplete-"] {
background-color: $color-dark!important;
}
div[class^="selectorSelected"] {
background-color: $color-medium!important;
}
/* Code blocks */
.markup pre, .markup code {
background-color: $color-dark!important;
border-color: $color-very-dark!important;
}
/* message accessories */
.message .accessory>div {
background-color: $color-dark;
}
/* Text stuff */
.app :not(div[class^="channels"]) :not(code):not(.kawaii-linenumbers):not(li):not(span):not(.user-name):not(.member-username):not(.markup):not(form):not(textarea):not(button):not(.guild):not(a):not(.discord-tag):not(.username):not(.discriminator):not(.ui-button-contents) {
color:$main-text-color!important;
}
:not(code):not(kawaii-linenumbers):not(li):not(span):not(.markup):not(form):not(textarea) {
font-family:$global-font, Whitney, Helvetica Neue, Helvetica, Arial, sans-serif;
}
.markup,form,textarea {
color:$chat-text-color!important;
font-family:$chat-font, Whitney, Helvetica Neue, Helvetica, Arial, sans-serif;
}
.markup {
font-size:$chat-font-size!important;
}
div[class^="ace_"] {
font-family: $code-font, monospace!important;
}
code,code span,.kawaii-linenumbers,.kawaii-linenumbers li {
font-family: $code-font, Whitney, Helvetica Neue, Helvetica, Arial, sans-serif!important;
font-size: $code-font-size!important;
font-weight: $code-font-weight!important;
}
code,.kawaii-linenumbers {
color:$code-text-color!important;
}
/* Emoji Picker */
div[class^="emojiPicker-"] div[class^="stickyHeader-"] {
background: transparent;
}
div[class^="emojiPicker-"] {
background-color: $color-light;
}
.search-bar.search-bar-light {
background-color: $color-light;
}
.search-bar.search-bar-light input, .search-bar.search-bar-light input::-webkit-input-placeholder {
color: $main-text-color;
}
.search-bar.search-bar-light input::-webkit-input-placeholder {
opacity: 0.6;
}
.search-bar-light .search-bar-icon .icon {
filter: invert(100%);
}
div[class^="emojiPicker-"] div[class^="scroller-"]::-webkit-scrollbar-track-piece {
background-color: $color-medium;
background-clip:padding-box;
border-radius:7px;
}
div[class^="emojiPicker-"] div[class^="scroller-"]::-webkit-scrollbar-thumb {
background-clip:padding-box;
background-color:$color-dark!important;
border: none!important;
border-radius:7px;
}
/* Emoji drop shadow so that dark emojis are visible on the dark background */
.message-group .emoji {
filter: drop-shadow(0px 0px 1px #FFF);
}
/* BD button */
.bd-settings-wrapper .bd-settings-button:not(.bd-active) {
background-color: $color-very-dark;
}
/* BD interface */
/*sidebar*/
.bd-sidebar-view .bd-sidebar-region {
background-color: $color-dark;
}
/*content*/
.bd-sidebar-view .bd-content-region {
background-color: $color-medium;
}
/*modals*/
.bd-modal .bd-modal-inner {
background-color: $color-medium;
}
/*color picker*/
.bd-form-colourpicker .vc-chrome {
z-index: 1;
& .vc-chrome-body {
background-color: $color-medium;
}
}
/* Channel List stuff */
*[class^="colorUnread"] {
color: $main-color;
}
div[class^="wrapperHovered"] div[class^="content"] {
background-color: $color-very-dark;
}
*[class^="colorHovered"], *[class^="colorSelected"] {
color: #FFFFFF;
opacity: 0.8;
}
div[class^="nameUnread"] {
color: $main-color;
}
/** Collapsing stuff **/
@if $collapsing-panels {
/* Channels list */
div[class^="channels"]:not(:hover) {
width: 3em;
}
.channel.private a {
padding-left: 0.4em;
margin-left: 0px;
}
.private-channels .search-bar, .private-channels .btn-friends, .private-channels header {
overflow: hidden;
transition: height 0.3s;
}
.private-channels:not(:hover) .search-bar, .private-channels:not(:hover) .btn-friends, .private-channels:not(:hover) header {
height: 0px;
font-size: 0px;
}
div[class^="wrapperDefaultVoice"]+div, div[class^="wrapperHoveredVoice"]+div, div[class^="wrapperSelectedVoice"]+div {
padding-left: 0.5em;
}
/* Foldaway channel members sidebar */
.channel-members-wrap {
min-width:1px;
}
.channel-members-wrap:not(:hover) {
width: 1px;
}
.channel-members {
padding-top:0;
padding-bottom:0;
width: 100%;
}
}
/* Compact Server List */
@if $compact-server-list {
.guilds-wrapper .guilds .guild.selected:before {
margin-top: -10px;
}
.guilds-wrapper .guilds .guild.selected {
z-index: 2;
transform: scale(1.2);
margin: 10px;
margin-left: 5px;
}
.guilds-wrapper .guilds .guild.unread:not(.selected)::before {
margin-top: 1px;
height: 15px;
border-radius: 10px;
}
.guilds-wrapper .guilds .guild:not(.guilds-add) {
height: 30px;
}
.guilds-wrapper .guilds .guild:first-child {
height: 50px;
}
.guilds-wrapper .guilds .guild.selected::before {
animation: selectserver 0.4s cubic-bezier(1, 0, 1, 0);
-webkit-animation: selectserver 0.4s cubic-bezier(1, 0, 1, 0);
}
.guilds-wrapper .guilds .guild:not(:first-child):not(.selected) div:not(.badge) {
transition: height 0.5s;
-webkit-transition: height 0.5s;
}
.guilds-wrapper .guilds .guild:not(:first-child):not(.selected):hover div:not(.badge) {
height: 50px;
transform: scale(1.2);
-webkit-transform: scale(1.2);
transition: height 0.5s;
-webkit-transition: height 0.5s;
margin-bottom: 0px;
}
.guilds-wrapper .guilds .guild:not(:first-child):not(.selected):hover {
z-index: 3;
}
.guilds-wrapper .guilds .guild .badge {
bottom: 14px;
}
.guilds-wrapper .guilds .guild:not(:first-child):not(.selected):hover .badge {
transform:scale(1.35);
bottom: 19px;
right: -7px;
}
}

View File

@ -0,0 +1,40 @@
/* Theme */
$main-color: #00FAFA !default; /*Main general theme color (#00FAFA Light Cyan by default)*/
/* Text */
$main-text-color: #FAFAFA !default; /*The colour of text onscreen in most places (#FAFAFA light grey by default)*/
$chat-text-color: #FFFFFF !default; /*The chat will be this color*/
$code-text-color: #CCCCCC !default; /*The non-syntax hilighted bits in code blocks will be this color*/
/* Background */
$color-light: #3E3E3E !default; /*These are all colors used in the background*/
$color-medium: #2E2E2E !default;
$color-dark: #1E1E1E !default;
$color-very-dark: #0E0E0E !default;
/* Tinting */
$tint-color: $main-color !default;
$tint-strength: 0% !default;
/* Font */
$global-font: 'Whitney' !default; /*This font will appear most places*/
$chat-font: 'Whitney' !default; /*This font will appear in the main chat*/
$chat-font-size: 15px !default;
$code-font: monospace !default; /*This will appear in code blocks*/
$code-font-size: 14px !default;
$code-font-weight: 700 !default;
/* other */
$collapsing-panels: false !default;
$compact-server-list: false !default;
/* do some stuff with the vars */
$color-light: mix($tint-color, $color-light, $tint-strength);
$color-medium: mix($tint-color, $color-medium, $tint-strength);
$color-dark: mix($tint-color, $color-dark, $tint-strength);
$color-very-dark: mix($tint-color, $color-very-dark, $tint-strength);