|
|
|
@ -232,6 +232,7 @@ function initVictoryConditionsTrumbowyg() |
|
|
|
|
|
|
|
|
|
function updateTrumbowygFlagsDropdown( $ctrl ) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// FUDGE! For convenience, we show the flags for the current players at the start of the dropdown list,
|
|
|
|
|
// and while we can do this in makeDropdown() in our plugin, this only happens once for the Victory Conditions
|
|
|
|
|
// control. There doesn't seem to be a way to dynamically generate the list each time it drops down,
|
|
|
|
@ -251,26 +252,48 @@ function updateTrumbowygFlagsDropdown( $ctrl ) |
|
|
|
|
return ; |
|
|
|
|
|
|
|
|
|
// remove the dropdown's flag buttons from the DOM
|
|
|
|
|
var $btns = {} ; |
|
|
|
|
var $btns = { small: {}, large: {} } ; |
|
|
|
|
$dropdown.find( "button" ).detach().each( function() { |
|
|
|
|
var nat = $(this).find( "img" ).data( "nat" ) ; |
|
|
|
|
$btns[ nat ] = $(this) ; |
|
|
|
|
var $img = $(this).find( "img" ) ; |
|
|
|
|
var nat = $img.data( "nat" ) ; |
|
|
|
|
var size ; |
|
|
|
|
if ( $img.hasClass( "small" ) ) |
|
|
|
|
size = "small" ; |
|
|
|
|
else if ( $img.hasClass( "large" ) ) |
|
|
|
|
size = "large" ; |
|
|
|
|
else { |
|
|
|
|
console.log( "INTERNAL ERROR: Unknown flag type:", $img ) ; |
|
|
|
|
return ; |
|
|
|
|
} |
|
|
|
|
$btns[ size ][ nat ] = $(this) ; |
|
|
|
|
} ) ; |
|
|
|
|
|
|
|
|
|
// add the flag buttons back into the DOM
|
|
|
|
|
plugin.nationalities.forEach( function( nat ) { |
|
|
|
|
if ( nat === nat1 || nat === nat2 ) |
|
|
|
|
var clearLeft = false ; |
|
|
|
|
function addButton( $btn ) { |
|
|
|
|
if ( ! $btn ) |
|
|
|
|
return ; |
|
|
|
|
var $btn = $btns[ nat ] ; |
|
|
|
|
if ( $btn ) |
|
|
|
|
$dropdown.append( $btn ) ; |
|
|
|
|
} ) ; |
|
|
|
|
var $btn = $btns[ nat2 ] ; |
|
|
|
|
if ( $btn ) |
|
|
|
|
$dropdown.prepend( $btn ) ; |
|
|
|
|
$btn = $btns[ nat1 ] ; |
|
|
|
|
if ( $btn ) |
|
|
|
|
$dropdown.prepend( $btn ) ; |
|
|
|
|
if ( clearLeft ) { |
|
|
|
|
$btn.css( "clear", "left" ) ; |
|
|
|
|
clearLeft = false ; |
|
|
|
|
} |
|
|
|
|
$dropdown.append( $btn ) ; |
|
|
|
|
} |
|
|
|
|
function addButtons( size ) { |
|
|
|
|
Object.values( $btns[size] ).forEach( function( $btn ) { |
|
|
|
|
$btn.css( "clear", "none" ) ; |
|
|
|
|
} ) ; |
|
|
|
|
addButton( $btns[size][ nat1 ] ) ; |
|
|
|
|
addButton( $btns[size][ nat2 ] ) ; |
|
|
|
|
plugin.nationalities.forEach( function( nat ) { |
|
|
|
|
if ( nat === nat1 || nat === nat2 ) |
|
|
|
|
return ; |
|
|
|
|
addButton( $btns[size][ nat ] ) ; |
|
|
|
|
} ) ; |
|
|
|
|
} |
|
|
|
|
addButtons( "small" ) ; |
|
|
|
|
clearLeft = true ; |
|
|
|
|
addButtons( "large" ) ; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|