Last active
September 28, 2017 19:48
-
-
Save DrewMcArthur/dae7f66c221fe0306b29f35128aa35a2 to your computer and use it in GitHub Desktop.
This code can be copied into your console when playing adarkroom.doublespeakgames.com to add some aesthetic features
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
// determine colors to set things, depending on if the lights are on | |
var focused = 'black'; | |
var faded = '#BBB'; | |
// when the mouse hovers over an item in either the craft or build list | |
$('#craftBtns > div, #buyBtns > div').not('.disabled').on('mouseenter', function(event){ | |
// TODO: this should change with the engine event | |
if(Engine.isLightsOff()){ | |
focused = 'white'; | |
faded = '#444'; | |
} else { | |
focused = 'black'; | |
faded = '#BBB'; | |
} | |
// first, grey out the supplies list on the right. | |
$('#stores div').css({'color': faded}); | |
// then, get information on what we’re hovering over | |
var el = $(event.currentTarget); | |
var required_items = $(el.children()[1]).children(); | |
var build_thing = el.attr('buildthing'); | |
// change the item we’re building to green | |
$('#storesContainer div#row_'+build_thing+' div').css({'color': '#AAFFAA'}); | |
// iterate through required items and highlight them in focused color (or red if insufficient) | |
for(var i =0; i < required_items.length; i++){ | |
// check for the 'row_key’ class, div.row_val’s have the number next to the item | |
if ($(required_items[i]).hasClass('row_key')) { | |
// then this div has info we want to highlight in our stores | |
var item = $(required_items[i]).text(); | |
var cost = $(required_items[i+1]).text(); | |
// use the information to recolor the correct row to the focused color | |
$('#stores div#row_'+item +' div').css({'color': focused}); | |
// if cost > amount of item you have, turn it red | |
if (parseInt(cost) > parseInt($('#stores div#row_'+item+' div.row_val').text())){ | |
$('#stores div#row_'+item +' div').css({'color': '#FFAAAA'}); | |
} | |
} | |
} | |
}); | |
// function that checks for the right light settings and restores coloring to normal | |
var restoreColors = function(){ | |
if(Engine.isLightsOff()){ | |
focused = 'white'; | |
faded = '#444'; | |
} else { | |
focused = 'black'; | |
faded = '#BBB'; | |
} | |
$('#storesContainer div').css({'color': focused}); | |
}; | |
// when we are no longer hovering, restore the original coloring | |
$('#craftBtns, #buyBtns').on('mouseleave', restoreColors); | |
$('#craftBtns div.disabled, #buyBtns div.disabled').on('mouseenter', restoreColors); | |
$('.lightsOff').on('click', restoreColors); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment