some arch changes for better sound support
parent
807e6a2a49
commit
0aed4f8625
|
|
@ -39,6 +39,7 @@ public class BottomBar extends GameObject implements IButtonListener, ITransient
|
||||||
|
|
||||||
int w = r - l;
|
int w = r - l;
|
||||||
Button btn = new SimpleButton(item.getTabName(), l, 576 - bottomBarHeight, w, bottomBarHeight, Layers.BOTTOM_BAR);
|
Button btn = new SimpleButton(item.getTabName(), l, 576 - bottomBarHeight, w, bottomBarHeight, Layers.BOTTOM_BAR);
|
||||||
|
if(item.isButtonClickSilent()) btn = btn.setClickSound(false);
|
||||||
btn.registerClickListener(this);
|
btn.registerClickListener(this);
|
||||||
add(btn);
|
add(btn);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ public class SelectionLayer extends GameObject implements IMouseCaptureArea, ITr
|
||||||
private List<ISelectable> selected = new ArrayList<ISelectable>();
|
private List<ISelectable> selected = new ArrayList<ISelectable>();
|
||||||
|
|
||||||
private void makeSelection(Vector4f a) {
|
private void makeSelection(Vector4f a) {
|
||||||
selected.clear();
|
List<ISelectable> newSelection = new ArrayList<ISelectable>();
|
||||||
|
|
||||||
Vector4f normalizedSelectionBoxScreen = sortVector(a);
|
Vector4f normalizedSelectionBoxScreen = sortVector(a);
|
||||||
Vector2f selectionBoxWorldMin = camera.screen2world(normalizedSelectionBoxScreen.x, normalizedSelectionBoxScreen.y);
|
Vector2f selectionBoxWorldMin = camera.screen2world(normalizedSelectionBoxScreen.x, normalizedSelectionBoxScreen.y);
|
||||||
Vector2f selectionBoxWorldMax = camera.screen2world(normalizedSelectionBoxScreen.z, normalizedSelectionBoxScreen.w);
|
Vector2f selectionBoxWorldMax = camera.screen2world(normalizedSelectionBoxScreen.z, normalizedSelectionBoxScreen.w);
|
||||||
|
|
@ -122,19 +123,19 @@ public class SelectionLayer extends GameObject implements IMouseCaptureArea, ITr
|
||||||
thingBox.x, thingBox.y,
|
thingBox.x, thingBox.y,
|
||||||
thingBox.z, thingBox.w
|
thingBox.z, thingBox.w
|
||||||
)) {
|
)) {
|
||||||
selected.add(thing);
|
newSelection.add(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
animation = 0;
|
animation = 0;
|
||||||
broadcastSelectionChanged();
|
updateSelection(newSelection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastSelectionChanged() {
|
private void broadcastSelectionChanged() {
|
||||||
Assets.sndSelectionChanged.play();
|
// Assets.sndSelectionChanged.play();
|
||||||
// if(selected.size() > 0) Assets.sndBubble.play();
|
if(selected.size() > 0) Assets.sndBubble.play();
|
||||||
// if(selected.size() == 0) Assets.sndCancel.play();
|
if(selected.size() == 0) Assets.sndCancel.play();
|
||||||
|
|
||||||
for(ISelectionChangeListener listener : listeners) {
|
for(ISelectionChangeListener listener : listeners) {
|
||||||
listener.selectionChanged(selected);
|
listener.selectionChanged(selected);
|
||||||
|
|
@ -142,6 +143,7 @@ public class SelectionLayer extends GameObject implements IMouseCaptureArea, ITr
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSelection(List<ISelectable> newSelection) {
|
public void updateSelection(List<ISelectable> newSelection) {
|
||||||
|
if(selected.size() == 0 && newSelection.size() == 0) return;
|
||||||
selected = newSelection;
|
selected = newSelection;
|
||||||
broadcastSelectionChanged();
|
broadcastSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
@ -191,12 +193,17 @@ public class SelectionLayer extends GameObject implements IMouseCaptureArea, ITr
|
||||||
if(selected.size() == 0) {
|
if(selected.size() == 0) {
|
||||||
buildTab.evoke();
|
buildTab.evoke();
|
||||||
} else {
|
} else {
|
||||||
selected.clear();
|
clearSelection();
|
||||||
broadcastSelectionChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearSelection() {
|
||||||
|
if(selected.size() == 0) return;
|
||||||
|
selected.clear();
|
||||||
|
broadcastSelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseUp(int button) {
|
public void mouseUp(int button) {
|
||||||
if(initialCoords != null && button == 0) {
|
if(initialCoords != null && button == 0) {
|
||||||
|
|
|
||||||
|
|
@ -135,11 +135,13 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rise() {
|
public void rise() {
|
||||||
|
Assets.sndBubble.play();
|
||||||
activate();
|
activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fall() {
|
public void fall() {
|
||||||
|
Assets.sndCancel.play();
|
||||||
deactiveate();
|
deactiveate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,7 +266,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
||||||
opened.toggle();
|
opened.toggle();
|
||||||
|
|
||||||
if(opened.value()) {
|
if(opened.value()) {
|
||||||
selection.updateSelection(new ArrayList<ISelectable>());
|
selection.clearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,4 +338,9 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
||||||
selectBuildable(newBuildableRecord);
|
selectBuildable(newBuildableRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isButtonClickSilent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,9 @@ public abstract class Tab extends GameObject implements IBottomBarItem, ITransie
|
||||||
protected void start() {
|
protected void start() {
|
||||||
bottombar.registerButton(this);
|
bottombar.registerButton(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isButtonClickSilent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import xyz.valnet.hadean.util.Assets;
|
||||||
|
|
||||||
public class Button extends GameObject implements IMouseCaptureArea, ITransient {
|
public class Button extends GameObject implements IMouseCaptureArea, ITransient {
|
||||||
|
|
||||||
|
private boolean clickSound = true;
|
||||||
|
|
||||||
private int x, y, width, height;
|
private int x, y, width, height;
|
||||||
private String text;
|
private String text;
|
||||||
protected Tile9 frame;
|
protected Tile9 frame;
|
||||||
|
|
@ -42,6 +44,11 @@ public class Button extends GameObject implements IMouseCaptureArea, ITransient
|
||||||
layer = l;
|
layer = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Button setClickSound(boolean b) {
|
||||||
|
this.clickSound = b;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +153,7 @@ public class Button extends GameObject implements IMouseCaptureArea, ITransient
|
||||||
state = HOVER;
|
state = HOVER;
|
||||||
}
|
}
|
||||||
listener.click(this);
|
listener.click(this);
|
||||||
Assets.sndBubble.play();
|
if (clickSound) Assets.sndBubble.play();
|
||||||
}
|
}
|
||||||
} else if (state == ACTIVE_NO_HOVER) {
|
} else if (state == ACTIVE_NO_HOVER) {
|
||||||
if(hovered) {
|
if(hovered) {
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,6 @@ public interface IBottomBarItem {
|
||||||
public void evoke();
|
public void evoke();
|
||||||
|
|
||||||
public String getTabName();
|
public String getTabName();
|
||||||
|
|
||||||
|
public boolean isButtonClickSilent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue