Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
馃憖 Added transparency slider
Browse files Browse the repository at this point in the history
  • Loading branch information
whatsaxis committed Aug 25, 2021
1 parent 62d30ac commit 077f7ba
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 14 deletions.
3 changes: 2 additions & 1 deletion assets/@types/fonts.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
declare module '*.woff';
declare module '*.woff2';
declare module '*.woff2';
declare module '*.otf';
Binary file removed assets/fonts/Minecraft.woff
Binary file not shown.
Binary file removed assets/fonts/Minecraft.woff2
Binary file not shown.
Binary file added assets/fonts/MinecraftBold.otf
Binary file not shown.
Binary file added assets/fonts/MinecraftBoldItalic.otf
Binary file not shown.
Binary file added assets/fonts/MinecraftItalic.otf
Binary file not shown.
Binary file added assets/fonts/MinecraftRegular.otf
Binary file not shown.
6 changes: 6 additions & 0 deletions electron/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export const api = {
return response
},

// Appearance

setTransparency: (transparency: number) => {
ipcRenderer.send('set-transparency', transparency)
},

/**
* Provide an easier way to listen to events
*/
Expand Down
16 changes: 14 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const schema = {
type: 'string',
default: '',
},
'transparency': {
type: 'number',
maximum: 1,
minimum: 0,
default: 0.9
}
}

/*
Expand Down Expand Up @@ -93,7 +99,7 @@ function createWindow() {
})

mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY)
mainWindow.setOpacity(0.9)
mainWindow.setOpacity(storage.get('transparency'))

mainWindow.once('ready-to-show', () => {
mainWindow?.show()
Expand Down Expand Up @@ -251,7 +257,7 @@ async function registerListeners() {
break
case 'pvplounge':
exists = await checkIfExists(path.join(logsPath, '../../.pvplounge/logs'))
event.reply('check-game-dir-reply', exists)
event.reply('check-game-dir-reply', exists)
break
}
})
Expand All @@ -260,6 +266,12 @@ async function registerListeners() {
event.reply('get-game-dir-reply', getGameDirectory(installation))
})

// Appearance

ipcMain.on('set-transparency', (event, transparency: number) => {
mainWindow?.setOpacity(transparency)
})

// Logs API

const client = storage.get('client')
Expand Down
3 changes: 2 additions & 1 deletion electron/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export const storageKeys = <const>[
'username',
'client',
'api-key',
'transparency'
]

export type StorageKey = {
name: typeof storageKeys[number],
value: string
value: any
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",

"make": "electron-forge make",
"dist": "electron-builder --win=portable",
"release": "electron-forge publish",
Expand Down
20 changes: 19 additions & 1 deletion src/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,26 @@ const Settings: React.FC = () => {
/>
</Setting>

<h2>Appearance</h2>
<Setting>
<label>Transparency</label>
<input
name="transparency"
type="range"
defaultValue={ Number(window.Main.getSetting('transparency')) * 100 }
min={ 30 }
max={ 100 }
onChange={ async e => {
const transparency = Number(e.target.value) / 100

console.log(transparency)
window.Main.setTransparency(transparency)
window.Main.setSetting({ name: 'transparency', value: transparency })
} }
/>
</Setting>

<h2>Log File</h2>
<br />

<Setting className="inline-children">
<label>Client</label>
Expand Down
31 changes: 31 additions & 0 deletions src/components/Settings/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,37 @@ export const SettingsStyles = styled.div`
background-color: #666;
}
input[type=range] {
width: 45vw;
margin: 7.3px 0;
background-color: transparent;
-webkit-appearance: none;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
background: #c3c3c3;
border: 0.2px solid #010101;
border-radius: 1.3px;
width: 100%;
height: 6px;
cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
margin-top: -7.5px;
width: 12px;
height: 20px;
background: #ffffff;
border: 1.8px solid #00001e;
border-radius: 4px;
cursor: pointer;
-webkit-appearance: none;
}
input.blur:not(:focus) {
filter: blur(4px);
-webkit-filter: blur(4px);
Expand Down
2 changes: 2 additions & 0 deletions src/components/Sidebar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const SidebarStyles = styled.nav`
.selected {
background-color: #3e424b;
border-radius: 6px;
}
`

Expand Down Expand Up @@ -67,5 +68,6 @@ export const SidebarRoute = styled.li`
&:hover {
cursor: pointer;
background-color: #3e424b;
border-radius: 6px;
}
`
37 changes: 29 additions & 8 deletions src/styles/GlobalStyle.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
import styled, { createGlobalStyle } from 'styled-components'

import MinecraftWoff from '../../assets/fonts/Minecraft.woff'
import MinecraftWoff2 from '../../assets/fonts/Minecraft.woff2'
import MinecraftRegular from '../../assets/fonts/MinecraftRegular.otf'
import MinecraftItalic from '../../assets/fonts/MinecraftItalic.otf'
import MinecraftBold from '../../assets/fonts/MinecraftBold.otf'
import MinecraftBoldItalic from '../../assets/fonts/MinecraftBoldItalic.otf'

// For future use
// #353535
// #191621

export const GlobalStyle = createGlobalStyle`
@font-face {
font-family: Minecraft;
src: url(${MinecraftWoff2}) format('woff2'),
url(${MinecraftWoff}) format('woff');
font-family: 'Minecraft';
font-weight: normal;
font-style: normal;
src: url(${ MinecraftRegular }) format("opentype");
}
@font-face {
font-family: 'Minecraft';
font-weight: normal;
font-style: italic;
src: url(${ MinecraftItalic }) format("opentype");
}
@font-face {
font-family: 'Minecraft';
font-weight: bold;
font-style: normal;
src: url(${ MinecraftBold }) format("opentype");
}
@font-face {
font-family: 'Minecraft';
font-weight: bold;
font-style: italic;
src: url(${ MinecraftBoldItalic }) format("opentype");
}
:root {
Expand Down
2 changes: 1 addition & 1 deletion webpack/rules.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = [
}
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
test: /\.(png|woff|woff2|eot|ttf|svg|otf)$/,
use: ['url-loader']
}
]

0 comments on commit 077f7ba

Please sign in to comment.