v2.1.0: adjusted toolbar dimming behaviour to be less obtrusive

This commit is contained in:
Evan Debenham
2023-05-04 13:33:00 -04:00
parent 44f7c1954d
commit e10189928e
2 changed files with 26 additions and 5 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -228,6 +228,7 @@ public class Toolbar extends Component {
return true; return true;
} }
}); });
btnWait.icon( 176, 0, 16, 16 );
//hidden button for rest keybind //hidden button for rest keybind
add(new Button(){ add(new Button(){
@@ -314,6 +315,7 @@ public class Toolbar extends Component {
return true; return true;
} }
}); });
btnSearch.icon( 192, 0, 16, 16 );
add(btnInventory = new Tool(0, 0, 24, 26) { add(btnInventory = new Tool(0, 0, 24, 26) {
private CurrencyIndicator ind; private CurrencyIndicator ind;
@@ -376,7 +378,16 @@ public class Toolbar extends Component {
arrow.y = bottom()-arrow.height-1; arrow.y = bottom()-arrow.height-1;
arrow.angle = bottom() == camera().height ? 0 : 180; arrow.angle = bottom() == camera().height ? 0 : 180;
} }
@Override
public void enable(boolean value) {
if (value != active){
arrow.alpha( value ? 1f : 0.4f );
}
super.enable(value);
}
}); });
btnInventory.icon( 160, 0, 16, 16 );
//hidden button for inventory selector keybind //hidden button for inventory selector keybind
add(new Button(){ add(new Button(){
@@ -681,6 +692,7 @@ public class Toolbar extends Component {
private static final int BGCOLOR = 0x7B8073; private static final int BGCOLOR = 0x7B8073;
private Image base; private Image base;
private Image icon;
public Tool( int x, int y, int width, int height ) { public Tool( int x, int y, int width, int height ) {
super(); super();
@@ -695,6 +707,13 @@ public class Toolbar extends Component {
this.width = width; this.width = width;
this.height = height; this.height = height;
} }
public void icon( int x, int y, int width, int height){
if (icon == null) icon = new Image( Assets.Interfaces.TOOLBAR );
add(icon);
icon.frame( x, y, width, height);
}
@Override @Override
protected void createChildren() { protected void createChildren() {
@@ -710,10 +729,16 @@ public class Toolbar extends Component {
base.x = x; base.x = x;
base.y = y; base.y = y;
if (icon != null){
icon.x = x + (width()- icon.width())/2f;
icon.y = y + (height()- icon.height())/2f;
}
} }
public void alpha( float value ){ public void alpha( float value ){
base.alpha(value); base.alpha(value);
if (icon != null) icon.alpha(value);
} }
@Override @Override
@@ -732,11 +757,7 @@ public class Toolbar extends Component {
public void enable( boolean value ) { public void enable( boolean value ) {
if (value != active) { if (value != active) {
if (value) { if (icon != null) icon.alpha( value ? 1f : 0.4f);
base.resetColor();
} else {
base.tint( BGCOLOR, 0.7f );
}
active = value; active = value;
} }
} }