The Position Keyframe Button now turns into a Spectator Keyframe Button when Spectator Keyframe is selected or no Position Keyframe Selected and spectating an Entity

This commit is contained in:
CrushedPixel
2015-06-14 10:42:51 +02:00
parent 5c0565bcc7
commit 2f7692d863
4 changed files with 40 additions and 3 deletions

View File

@@ -154,9 +154,44 @@ public class GuiReplayOverlay extends Gui {
}
}, "replaymod.gui.ingame.menu.removeposkeyframe");
private final GuiElement buttonSpectatorNotSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 40, 40, 20, new Runnable() {
@Override
public void run() {
Entity cam = mc.getRenderViewEntity();
if (cam != null) {
Position position = new Position(cam.posX, cam.posY, cam.posZ, cam.rotationPitch,
cam.rotationYaw % 360, ReplayHandler.getCameraTilt());
if (ReplayHandler.isCamera())
ReplayHandler.addKeyframe(new PositionKeyframe(ReplayHandler.getRealTimelineCursor(), position));
else
ReplayHandler.addKeyframe(new PositionKeyframe(ReplayHandler.getRealTimelineCursor(), cam.getEntityId()));
}
}
}, "replaymod.gui.ingame.menu.addspeckeyframe");
private final GuiElement buttonSpectatorSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 40, 60, 20, new Runnable() {
@Override
public void run() {
ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
}
}, "replaymod.gui.ingame.menu.removespeckeyframe");
@Override
public GuiElement delegate() {
return ReplayHandler.getSelectedKeyframe() instanceof PositionKeyframe ? buttonSelected : buttonNotSelected;
boolean selected = ReplayHandler.getSelectedKeyframe() instanceof PositionKeyframe;
boolean camera = true;
if(selected) {
camera = ((PositionKeyframe)ReplayHandler.getSelectedKeyframe()).getSpectatedEntityID() == null;
} else {
camera = ReplayHandler.isCamera();
}
if(camera) {
return selected ? buttonSelected : buttonNotSelected;
} else {
return selected ? buttonSpectatorSelected : buttonSpectatorNotSelected;
}
}
};