Skip to content

Commit

Permalink
add toggle for stat color mode, 1.3.0 prep
Browse files Browse the repository at this point in the history
  • Loading branch information
TimStewartJ committed Jan 14, 2022
1 parent 5aadfee commit cc4e184
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.3.0] - 2022-01-13
### Changed
- Colors are now based on set cutoffs.
- Moved checkboxes to the left of their labels.
- Coloring individual stats or the whole player's stats is toggleable.

## [1.2.1] - 2022-01-13
### Changed
- Utility functions for improved runtime and readability.
Expand Down
12 changes: 9 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@ <h2>SETTINGS</h2>
<!-- <br/> -->

<p>
<label for="autowho">Autowho</label>
<input type="checkbox" id="autowho" name="autowho"/>
<input type="checkbox" id="autowho" name="autowho"/>
<label for="autowho">Autowho</label>
</p>

<p>
<label for="darkmode">Dark Mode</label>
<input type="checkbox" id="darkmode" name="darkmode"/>
<label for="darkmode">Dark Mode</label>

</p>

<p>
<input type="checkbox" id="statColor" name="statColor"/>
<label for="statColor">Color the whole player's stats instead of individual stats</label>
</p>
</div>

Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ app.on('ready', () => {
if(!read('theme-darkmode')) {
write('theme-darkmode', false);
}
if(!read('statColor')) {
write('statColor', false);
}

win.webContents.once('dom-ready', () => {
win.webContents.send('initSettings', {
path: read('path'),
client: read('client'),
autowho: read('autowho'),
mode: read('mode'),
darkmode: read('theme-darkmode')
darkmode: read('theme-darkmode'),
statColor: read('statColor')
});
// start reading from the file immediately
readFromFile(read('path'), win, read('key'));
Expand All @@ -107,6 +111,9 @@ app.on('ready', () => {
case 'darkmode':
write('theme-darkmode', data.darkmode);
break;
case 'statColor':
write('statColor', data.statColor);
break;
}
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arctic-overlay",
"version": "1.2.1",
"version": "1.3.0",
"description": "An overlay for Hypixel Bedwars",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 10 additions & 4 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let mode;

let playerData = {};

const colorMode = true;
let statColor = false;

const sortTable = (tableName) => {
console.time('sort');
Expand Down Expand Up @@ -99,7 +99,7 @@ window.players.update('updatePlayer', (data) => {
//if the player is not a nick, color them according to their threat level
if(!data.nick) {
// if we are on statsify color mode
if(!colorMode)
if(statColor)
{
const rgb = data.stats.bedwars[mode].colors.overall;
$(`#${data.user.toLowerCase()}`).css('color', `rgb(${rgb[0]},${rgb[1]},${rgb[2]})`);
Expand All @@ -125,7 +125,7 @@ window.players.update('updatePlayer', (data) => {
break;
default:
fieldContent = data.nick ? 'NICK' : ratios.includes(field) ? data.stats.bedwars[mode][field.toLowerCase()].toFixed(2) : data.stats.bedwars[mode][field.toLowerCase()];
if(!data.nick && colorMode)
if(!data.nick && !statColor)
{
const fieldColor = data.stats.bedwars[mode].colors[field.toLowerCase()];
fieldNode.style.color = `rgb(${fieldColor[0]},${fieldColor[1]},${fieldColor[2]})`;
Expand All @@ -135,7 +135,6 @@ window.players.update('updatePlayer', (data) => {
fieldNode.innerHTML = fieldContent;
field !== 'PLAYER' ? fieldNode.classList.add('centered') : fieldNode.classList.add('player-name');
playerRow.appendChild(fieldNode);
// playerRow.innerHTML += `<td${field !== 'PLAYER' ? ' class=\"centered\"' : ' class="player-name"'}${colorMode ? `rgb(${rgb[0]},${rgb[1]},${rgb[2]})` : ''}>${fieldContent}</td>`;
});
sortTable('main-table'); // re sort the table
});
Expand All @@ -161,8 +160,10 @@ window.settings.initSettings('initSettings', (settings) => {
$(`#${settings.client}`).prop('selected', true);
$('#autowho').prop('checked', settings.autowho);
$('#darkmode').prop('checked', settings.darkmode);
$('#statColor').prop('checked', settings.statColor);
$(`#${settings.mode}`).prop('selected', true);
mode = settings.mode;
statColor = settings.statColor;
themeChange(settings.darkmode);
});

Expand Down Expand Up @@ -238,6 +239,11 @@ $('#darkmode').change(async (data) => {
await window.settings.updateSettings({ type: 'darkmode', darkmode: data.target.checked });
});

$('#statColor').change(async (data) => {
statColor = data.target.checked;
await window.settings.updateSettings({ type: 'statColor', statColor: data.target.checked });
});

// misc functions

$('#lookup-form').submit((e) => {
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const tieredColors = [[170, 170, 170], [255,255,255], [255, 170, 0], [0, 170, 17
exports.color = (top, bottom, val) => {
const norm = 25/top;
val *= norm;
return tieredColors[Math.floor(Math.sqrt(val))];
return tieredColors[Math.min(tieredColors.length - 1, Math.floor(Math.sqrt(val)))];
};

exports.getBwLevel = (exp = 0) => {
Expand Down

0 comments on commit cc4e184

Please sign in to comment.