Skip to content

Commit

Permalink
Updates and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbuffington committed Jul 1, 2018
1 parent a8dddea commit 2f652b5
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 62 deletions.
123 changes: 73 additions & 50 deletions js/georgia-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ pref.divider_img = fb.ProfilePath + 'georgia/images/divider.png';
pref.last_fm_img = fb.ProfilePath + 'georgia/images/last-fm-red-36.png';
pref.last_fmw_img = fb.ProfilePath + 'georgia/images/last-fm-36.png';
pref.label_base = fb.ProfilePath + 'images/recordlabel/'; // location of the record label logos for the bottom right corner
pref.logo_base = fb.ProfilePath + 'images/band logos/'; // location of band logos for the bottom left corner
pref.logo_hq = fb.ProfilePath + 'images/band logos HQ/'; // location of High-Qualiy band logos for the bottom left corner
pref.logo_hq = fb.ProfilePath + 'images/artistlogos/'; // location of High-Qualiy band logos for the bottom left corner
pref.logo_color = fb.ProfilePath + 'images/band logos color/';
pref.codec_base = fb.ProfilePath + 'images/codec logos/';
pref.flags_base = fb.ProfilePath + 'images/flags/'; // location of artist country flags
Expand Down Expand Up @@ -272,6 +271,7 @@ var album_art_loading; // for on_load_image_done()
var retrieveThemeColorsWhenLoaded = false; // only load theme colors on first image in aa_array
var newTrackFetchingArtwork = false; // only load theme colors when newTrackFetchingArtwork = true
var noArtwork = false; // only use default theme when noArtwork was found
var themeColorSet = false; // when no artwork, don't set themeColor every redraw
var playCountVerifiedByLastFm = false; // show Last.fm image when we %lastfm_play_count% > 0
var pauseBorderWidth = 2;
var art_off_center = false; // if true, album art has been shifted 40 pixels to the right
Expand Down Expand Up @@ -419,11 +419,14 @@ function on_paint(gr) {
gr.SetSmoothingMode(SmoothingMode.None);

// Background
if (!albumart && noArtwork) {
if (!albumart && fb.IsPlaying) { // should we remove noArtwork bool?
albumart_size.x = Math.floor(ww*0.33); // if there's no album art info panel takes up 1/3 screen
albumart_size.y = geo.top_art_spacing;
albumart_size.h = wh - albumart_size.y - geo.lower_bar_h - 32;
setTheme(blueTheme.colors);
if (!themeColorSet) {
setTheme(blueTheme.colors);
themeColorSet = true;
}
}
gr.FillSolidRect(0, geo.top_bg_h, ww, wh - geo.top_bg_h, col.bg);
gr.FillSolidRect(0, 0, ww, geo.top_bg_h, col.menu_bg);
Expand Down Expand Up @@ -511,7 +514,7 @@ function on_paint(gr) {
}
}

if (!displayPlaylist && fb.IsPlaying) {
if ((!displayPlaylist || (!albumart && noArtwork)) && fb.IsPlaying) {
if (albumart)
gridSpace = Math.round(albumart_size.x-geo.aa_shadow-textLeft);
else
Expand All @@ -520,9 +523,10 @@ function on_paint(gr) {

if (showExtraDrawTiming) drawTextGrid = fb.CreateProfiler("on_paint -> textGrid");

var trackInfoHeight = 0;
if (str.trackInfo) {
gr.SetTextRenderingHint(TextRenderingHint.ClearTypeGridFit);
var trackInfoHeight = gr.MeasureString(str.trackInfo, ft.track_info, 0, 0, 0, 0).Height;
trackInfoHeight = gr.MeasureString(str.trackInfo, ft.track_info, 0, 0, 0, 0).Height;
gr.DrawString(str.trackInfo, ft.track_info, col.title, ww - textLeft * 2 - text_width, geo.top_bg_h - trackInfoHeight - 15, text_width, trackInfoHeight, StringFormat(StringAlignment.Far));
gr.SetTextRenderingHint(TextRenderingHint.AntiAlias);
}
Expand Down Expand Up @@ -694,7 +698,7 @@ function on_paint(gr) {

} /* if (!displayPlaylist) */

if (!displayPlaylist) {
if (!displayPlaylist || (!albumart && noArtwork)) {
// BAND LOGO drawing code
showExtraDrawTiming && (drawBandLogos = fb.CreateProfiler("on_paint -> band logos"));
if (bandLogo) {
Expand Down Expand Up @@ -1021,11 +1025,11 @@ function onSettingsMenu(x, y) {
_menu.AppendMenuItem(pref.display_cdart ? MF_STRING : MF_DISABLED, 5, 'Rotate CD Art on track change');
_menu.CheckMenuItem(5, pref.rotate_cdart);

_rotationMenu.AppendMenuItem(MF_STRING, 30, '2 degrees');
_rotationMenu.AppendMenuItem(MF_STRING, 31, '3 degrees');
_rotationMenu.AppendMenuItem(MF_STRING, 32, '4 degrees');
_rotationMenu.AppendMenuItem(MF_STRING, 33, '5 degrees');
_rotationMenu.CheckMenuRadioItem(30, 33, parseInt(pref.rotation_amt)+28);
_rotationMenu.AppendMenuItem(MF_STRING, 130, '2 degrees');
_rotationMenu.AppendMenuItem(MF_STRING, 131, '3 degrees');
_rotationMenu.AppendMenuItem(MF_STRING, 132, '4 degrees');
_rotationMenu.AppendMenuItem(MF_STRING, 133, '5 degrees');
_rotationMenu.CheckMenuRadioItem(130, 133, parseInt(pref.rotation_amt)+128);
_rotationMenu.AppendTo(_menu, MF_STRING, 'CD Art Rotation Amount');

_menu.AppendMenuItem(pref.display_cdart ? MF_STRING : MF_DISABLED, 6, 'Display CD Art above cover');
Expand All @@ -1046,7 +1050,10 @@ function onSettingsMenu(x, y) {
_menu.AppendMenuSeparator();
_menu.AppendMenuItem(MF_STRING, 21, 'Update Progress Bar frequently (higher CPU)');
_menu.CheckMenuItem(21, pref.freq_update);
_menu.AppendMenuSeparator();
_menu.AppendMenuSeparator();
_menu.AppendMenuItem(MF_STRING, 30, 'Follow Hyperlinks only if CTRL-key is down');
_menu.CheckMenuItem(30, pref.hyperlinks_ctrl);
_menu.AppendMenuSeparator();

/* TODO: Remove this before release */
_debugMenu.AppendMenuItem(MF_STRING, 90, 'Show debug output');
Expand Down Expand Up @@ -1107,15 +1114,18 @@ function onSettingsMenu(x, y) {
case 21:
pref.freq_update = !pref.freq_update;
SetProgressBarRefresh();
break;
case 30:
case 31:
case 32:
case 33:
break;
case 30:
pref.hyperlinks_ctrl = !pref.hyperlinks_ctrl;
break;
case 130:
case 131:
case 132:
case 133:
pref.rotation_amt = (idx-28) % 360;
CreateRotatedCDImage();
RepaintWindow();
break;
break;
case 90:
pref.show_debug_log = !pref.show_debug_log;
break;
Expand Down Expand Up @@ -1246,9 +1256,15 @@ function on_playback_new_track(metadb) {
if (showDebugTiming) newTrackTime = fb.CreateProfiler('on_playback_new_track');
start_timer = 0;
lastLeftEdge = 0;
newTrackFetchingArtwork = true;
newTrackFetchingArtwork = true;
themeColorSet = false;

current_path = $('%directoryname%');
isSpotify = !!$('%path%').match(/^spotify\:/);
if (!isSpotify) {
current_path = $('%directoryname%');
} else {
current_path = '';
}

SetProgressBarRefresh();

Expand Down Expand Up @@ -1300,8 +1316,7 @@ function on_playback_new_track(metadb) {
bandLogoHQ = false;

var path = testBandLogo(pref.logo_hq, bandStr, true) || // try 800x310 white
testBandLogo(pref.logo_color, bandStr, true) || // try 800x310 color
testBandLogo(pref.logo_base, bandStr, false); // try 160x79
testBandLogo(pref.logo_color, bandStr, true); // try 800x310 color
if (path) {
bandLogo = gdi.Image(path);
}
Expand Down Expand Up @@ -2351,7 +2366,7 @@ function fetchNewArtwork(metadb) {
aa_list = [];
var disc_art_exists = true;

if (pref.display_cdart) { // we must attempt to load CD/vinyl art first so that the shadow is drawn correctly
if (pref.display_cdart && !isSpotify) { // we must attempt to load CD/vinyl art first so that the shadow is drawn correctly
cdartPath = $(pref.vinylside_path); // try vinyl%vinyl disc%.png first
if (!utils.FileTest(cdartPath, 'e')) {
cdartPath = $(pref.vinyl_path); // try vinyl.png
Expand Down Expand Up @@ -2381,30 +2396,36 @@ function fetchNewArtwork(metadb) {
}
if (showDebugTiming) artworkTime.Print();

for (k = 0; k < tf.glob_paths.length; k++) {
aa_list = aa_list.concat(utils.Glob($(tf.glob_paths[k])).toArray());
}
pattern = /(cd|vinyl)([0-9]*|[a-h])\.png/i;
aa_list = _.remove(_.uniq(aa_list), function (path) {
return !pattern.test(path);
});
// remove duplicates

if (aa_list.length) {
noArtwork = false;
if (aa_list.length > 1 && pref.aa_glob) {
globTimer = window.SetTimeout(function() {
doRotateImage();
}, pref.t_aa_glob * 1000);
}
albumArtIndex = 0;
glob_image(albumArtIndex); // display first image
} else {
noArtwork = true;
albumart = null;
if (isSpotify) {
albumart = utils.GetAlbumArtV2(metadb);
getThemeColors(albumart);
ResizeArtwork(true);
debugLog("Repainting on_playback_new_track due to no cover image");
RepaintWindow();
} else {
for (k = 0; k < tf.glob_paths.length; k++) {
aa_list = aa_list.concat(utils.Glob($(tf.glob_paths[k])).toArray());
}
pattern = /(cd|vinyl)([0-9]*|[a-h])\.png/i;
aa_list = _.remove(_.uniq(aa_list), function (path) {
return !pattern.test(path);
});
// remove duplicates

if (aa_list.length) {
noArtwork = false;
if (aa_list.length > 1 && pref.aa_glob) {
globTimer = window.SetTimeout(function() {
doRotateImage();
}, pref.t_aa_glob * 1000);
}
albumArtIndex = 0;
glob_image(albumArtIndex); // display first image
} else {
noArtwork = true;
albumart = null;
ResizeArtwork(true);
debugLog("Repainting on_playback_new_track due to no cover image");
RepaintWindow();
}
}
if (showDebugTiming) artworkTime.Print();
}
Expand Down Expand Up @@ -2432,7 +2453,7 @@ function createButtonObjects(ww, wh) {
//---> Transport buttons
if (pref.show_transport) {
var add = 0;
var count = pref.show_random_button ? 6 : 5;
var count = 4 + (pref.show_random_button ? 1 : 0) + (pref.show_reload_button ? 1 : 0);

var y = is_4k ? 20 : 10;
var w = is_4k ? 64 : 32;
Expand All @@ -2448,8 +2469,10 @@ function createButtonObjects(ww, wh) {
btns[++count] = new Button(x + (w + p) * count, y, w, h, "Next", btnImg.Next);
if (pref.show_random_button) {
btns[++count] = new Button(x + (w + p) * count, y, w, h, "Playback/Random", btnImg.PlaybackRandom, "Play Random Song");
}
btns[++count] = new Button(x + (w + p) * count, y, w, h, "Reload", btnImg.Reload);
}
if (pref.show_reload_button) {
btns[++count] = new Button(x + (w + p) * count, y, w, h, "Reload", btnImg.Reload);
}
}

//---> Caption buttons
Expand Down
17 changes: 9 additions & 8 deletions js/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ pref.add_properties(
rotate_cdart: ['Art: Rotate CD art on new track', true], // true: rotate cdArt based on track number. i.e. rotationAmt = %tracknum% * x degrees
cdart_ontop: ['Art: Show CD art above front cover', false], // true: display cdArt above front cover
show_debug_log: ['Debug: Show Debug Output', false], // true: show debug output in console
hide_cursor: ['Hide Cursor when stationary', true], // true: hide cursor when not moving, false: don't
generate_theme: ['Theme: Generate custom theme from artwork', true], // true: generate a new theme for artwork, false: use built in themes
hide_cursor: ['Hide Cursor when stationary', false], // true: hide cursor when not moving, false: don't
show_flags: ['Show country flags', true], // true: show the artist country flags
// check_multich: ['Check for MultiChannel version', false], // true: search paths in tf.MultiCh_paths to see if there is a multichannel version of the current album available
use_vinyl_nums: ['Use vinyl style numbering (e.g. A1)',true], // true: if the tags specified in tf.vinyl_side and tf.vinyl_tracknum are set, then we'll show vinyl style track numbers (i.e. "B2." instead of "04.")
start_Playlist: ['Display playlist on startup', false], // true: show the playlist window when the theme starts up
show_transport: ['Show transport controls', true], // true: show the play/pause/next/prev/random buttons at the top of the screen
show_random_button: ['Show Random Button', true], // true: show random button in transport controls, ignored if transport not shown
freq_update: ['Frequent progress bar updates', true], // true: update progress bar multiple times a second. Smoother, but uses more CPU
time_zone: ['Time-zone (formatted +/-HH:MM, e.g. -06:00)', '+00:00'], // used to create accurate timezone offsets. "Z", "-06:00", "+06:00", etc. are all valid values
show_reload_button: ['Show Reload Button', false], // true: show a button that reloads the theme when clicked. Useful for debugging only
freq_update: ['Frequent progress bar updates', true], // true: update progress bar multiple times a second. Smoother, but uses more CPU
time_zone: ['Time-zone (formatted +/-HH:MM, e.g. -06:00)', '+00:00'], // used to create accurate timezone offsets. "Z", "-06:00", "+06:00", etc. are all valid values
hyperlinks_ctrl: ['Playlist: Hyperlinks require CTRL Key', false], // true: clicking on hyperlinks only works if CTRL key is held down

lyrics_line_height: ['Lyrics: Line height', 24],
lyrics_normal_color:['Lyrics: Text Color', 'RGBA(255, 255, 255, 255);'],
Expand Down Expand Up @@ -139,10 +140,10 @@ tf.lyrics = "[$if2(%LYRICS%,$if2(%LYRIC%,$if2(%UNSYNCED LYRICS%,%UNSYNCED LYRIC

// GLOB PICTURES
tf.glob_paths = Array( // simply add, change or re-order entries as needed
"$replace(%path%,%filename_ext%,)folder*",
"$replace(%path%,%filename_ext%,)*.jpg",
"$replace(%path%,%filename_ext%,)*.png",
"$replace(%path%,%directoryname%\\%filename_ext%,)folder*" // all folder images in parent directory
'$replace(%path%,%filename_ext%,)folder*',
'$replace(%path%,%filename_ext%,)*.jpg',
'$replace(%path%,%filename_ext%,)*.png',
'$replace(%path%,%directoryname%\\%filename_ext%,)folder*' // all folder images in parent directory
);

tf.lyr_path = Array( // simply add, change or re-order entries as needed
Expand Down
10 changes: 6 additions & 4 deletions js/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ themeList.push({


function setTheme(theme) {
// theme.primary = rgb(192,192,160); // testing conflicts
// theme.primary = rgb(192,192,160); // testing conflicts
if (colorDistance(theme.primary, col.bg, true) < 45) {
console.log('>>> Theme primary color is too close to bg color. Adjusting.');
// darken theme.primary because it's too close to col.bg
Expand Down Expand Up @@ -145,6 +145,7 @@ function getThemeColorsJson(image, maxColorsToPull, maxColors) {
colorsWeighted = JSON.parse(image.GetColourSchemeJson(maxColorsToPull));
colorsWeighted.forEach(function (c, i) {
colorsWeighted[i].col = new Color(c.col);
console.log(colorsWeighted[i].col.getRGB(true,true), colorsWeighted[i].col.val);
});

console.log('idx color bright freq weight');
Expand Down Expand Up @@ -203,19 +204,20 @@ function getThemeColors(image) {
}
} else {
calculatedColor = getThemeColorsJson(image, 14, 3);
// calculatedColor = 0xffb04030;
}
if (!isNaN(calculatedColor)) {
var color = new Color(calculatedColor);
while (color.brightness >= 200) {
calculatedColor = shadeColor(calculatedColor, 3);
console.log(' >> Shading: ', colToRgb(calculatedColor), ' - brightness: ', color.brightness);
color = new Color(calculatedColor);
}
while (!color.isGreyscale && color.brightness <= 17) {
calculatedColor = tintColor(calculatedColor, 3);
console.log(' >> Tinting: ', colToRgb(calculatedColor), ' - brightness: ', color.brightness);
color = new Color(calculatedColor);
}
if (pref.generate_theme && color.brightness > 17) {
if (color.brightness > 17) {
var tObj = {
primary: calculatedColor,
darkAccent: shadeColor(calculatedColor, 30),
Expand Down Expand Up @@ -276,7 +278,7 @@ function colorDistance(a, b, log) {
// var distance = Math.sqrt((2 + rho/256) * deltaR + 4 * deltaG + (2 + (255 - rho)/256) * deltaB);
var distance = Math.sqrt(2 * deltaR + 4 * deltaG + 3 * deltaB + (rho * (deltaR - deltaB))/256);
if (log === true) {
console.log(aCol.getRGB(), bCol.getRGB(), distance);
console.log('distance:', aCol.getRGB(), bCol.getRGB(), distance);
}
return distance;
}

0 comments on commit 2f652b5

Please sign in to comment.