mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-19 09:27:53 +01:00
Pondering: the beginning and the end.
- Special-case seeking to the end of a ponder scene. - Draw indicators for seeking to the beginning and end. - Fix pulleys not rendering correctly.
This commit is contained in:
parent
841bba04bd
commit
f14661fb6f
2 changed files with 67 additions and 42 deletions
|
@ -239,4 +239,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
|
||||||
offset = forcedOffset;
|
offset = forcedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldRenderAsTE() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,36 +51,44 @@ public class PonderProgressBar extends AbstractSimiWidget {
|
||||||
@Override
|
@Override
|
||||||
protected boolean clicked(double mouseX, double mouseY) {
|
protected boolean clicked(double mouseX, double mouseY) {
|
||||||
return this.active && this.visible && !ponder.getActiveScene().keyframeTimes.isEmpty()
|
return this.active && this.visible && !ponder.getActiveScene().keyframeTimes.isEmpty()
|
||||||
&& mouseX >= (double) this.x && mouseX < (double) (this.x + this.width) && mouseY >= (double) this.y - 3
|
&& mouseX >= (double) this.x && mouseX < (double) (this.x + this.width + 4) && mouseY >= (double) this.y - 3
|
||||||
&& mouseY < (double) (this.y + this.height + 20);
|
&& mouseY < (double) (this.y + this.height + 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(double mouseX, double mouseY) {
|
public void onClick(double mouseX, double mouseY) {
|
||||||
PonderScene activeScene = ponder.getActiveScene();
|
PonderScene activeScene = ponder.getActiveScene();
|
||||||
int clickedAtTime = (int) ((mouseX - x) / ((double) width) * activeScene.totalTime);
|
|
||||||
|
|
||||||
int seekTime = 0;
|
|
||||||
|
|
||||||
IntegerList keyframeTimes = activeScene.keyframeTimes;
|
IntegerList keyframeTimes = activeScene.keyframeTimes;
|
||||||
for (int i = 0; i < keyframeTimes.size(); i++) {
|
|
||||||
int keyframeTime = keyframeTimes.get(i);
|
|
||||||
|
|
||||||
if (keyframeTime > clickedAtTime)
|
int keyframeIndex = getHoveredKeyframeIndex(activeScene, mouseX);
|
||||||
break;
|
|
||||||
|
|
||||||
seekTime = keyframeTime;
|
if (keyframeIndex == -1)
|
||||||
}
|
ponder.seekToTime(0);
|
||||||
ponder.seekToTime(seekTime);
|
else if (keyframeIndex == keyframeTimes.size())
|
||||||
|
ponder.seekToTime(activeScene.totalTime);
|
||||||
|
else
|
||||||
|
ponder.seekToTime(keyframeTimes.get(keyframeIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHoveredKeyframeIndex(double mouseX) {
|
public int getHoveredKeyframeIndex(PonderScene activeScene, double mouseX) {
|
||||||
PonderScene activeScene = ponder.getActiveScene();
|
IntegerList keyframeTimes = activeScene.keyframeTimes;
|
||||||
int clickedAtTime = (int) ((mouseX - x) / ((double) width) * activeScene.totalTime);
|
|
||||||
|
int totalTime = activeScene.totalTime;
|
||||||
|
int clickedAtTime = (int) ((mouseX - x) / ((double) width + 4) * totalTime);
|
||||||
|
|
||||||
|
{
|
||||||
|
int lastKeyframeTime = keyframeTimes.get(keyframeTimes.size() - 1);
|
||||||
|
|
||||||
|
int diffToEnd = totalTime - clickedAtTime;
|
||||||
|
int diffToLast = clickedAtTime - lastKeyframeTime;
|
||||||
|
|
||||||
|
if (diffToEnd > 0 && diffToEnd < diffToLast / 2) {
|
||||||
|
return keyframeTimes.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
IntegerList keyframeTimes = activeScene.keyframeTimes;
|
|
||||||
for (int i = 0; i < keyframeTimes.size(); i++) {
|
for (int i = 0; i < keyframeTimes.size(); i++) {
|
||||||
int keyframeTime = keyframeTimes.get(i);
|
int keyframeTime = keyframeTimes.get(i);
|
||||||
|
|
||||||
|
@ -125,28 +133,40 @@ public class PonderProgressBar extends AbstractSimiWidget {
|
||||||
int hoverIndex;
|
int hoverIndex;
|
||||||
|
|
||||||
if (isHovered) {
|
if (isHovered) {
|
||||||
hoverIndex = getHoveredKeyframeIndex(mouseX);
|
hoverIndex = getHoveredKeyframeIndex(activeScene, mouseX);
|
||||||
float flashValue = flash.getValue(partialTicks) * 3
|
float flashValue = flash.getValue(partialTicks) * 3
|
||||||
+ (float) Math.sin((AnimationTickHolder.getTicks() + partialTicks) / 6);
|
+ (float) Math.sin((AnimationTickHolder.getTicks() + partialTicks) / 6);
|
||||||
|
|
||||||
hoverEndColor = ColorHelper.applyAlpha(0x70ffffff, flashValue);
|
hoverEndColor = ColorHelper.applyAlpha(0x70ffffff, flashValue);
|
||||||
hoverStartColor = ColorHelper.applyAlpha(0x30ffffff, flashValue);
|
hoverStartColor = ColorHelper.applyAlpha(0x30ffffff, flashValue);
|
||||||
} else {
|
} else {
|
||||||
hoverIndex = -1;
|
hoverIndex = -2;
|
||||||
hoverEndColor = 0;
|
hoverEndColor = 0;
|
||||||
hoverStartColor = 0;
|
hoverStartColor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegerList keyframeTimes = activeScene.keyframeTimes;
|
IntegerList keyframeTimes = activeScene.keyframeTimes;
|
||||||
|
|
||||||
|
if (hoverIndex == -1)
|
||||||
|
drawKeyframe(activeScene, true, 0, 0, hoverStartColor, hoverEndColor, 8);
|
||||||
|
else if (hoverIndex == keyframeTimes.size())
|
||||||
|
drawKeyframe(activeScene, true, activeScene.totalTime, width + 4, hoverStartColor, hoverEndColor, 8);
|
||||||
|
|
||||||
for (int i = 0; i < keyframeTimes.size(); i++) {
|
for (int i = 0; i < keyframeTimes.size(); i++) {
|
||||||
int keyframeTime = keyframeTimes.get(i);
|
int keyframeTime = keyframeTimes.get(i);
|
||||||
int keyframePos = (int) (((float) keyframeTime) / ((float) activeScene.totalTime) * (width + 4));
|
int keyframePos = (int) (((float) keyframeTime) / ((float) activeScene.totalTime) * (width + 4));
|
||||||
|
|
||||||
int startColor = i == hoverIndex ? hoverStartColor : 0x30ffeedd;
|
boolean selected = i == hoverIndex;
|
||||||
int endColor = i == hoverIndex ? hoverEndColor : 0x60ffeedd;
|
int startColor = selected ? hoverStartColor : 0x30ffeedd;
|
||||||
int height = i == hoverIndex ? 8 : 4;
|
int endColor = selected ? hoverEndColor : 0x60ffeedd;
|
||||||
|
int height = selected ? 8 : 4;
|
||||||
|
|
||||||
if (i == hoverIndex) {
|
drawKeyframe(activeScene, selected, keyframeTime, keyframePos, startColor, endColor, height);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawKeyframe(PonderScene activeScene, boolean selected, int keyframeTime, int keyframePos, int startColor, int endColor, int height) {
|
||||||
|
if (selected) {
|
||||||
FontRenderer font = Minecraft.getInstance().fontRenderer;
|
FontRenderer font = Minecraft.getInstance().fontRenderer;
|
||||||
GuiUtils.drawGradientRect(500, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor);
|
GuiUtils.drawGradientRect(500, keyframePos, 10, keyframePos + 1, 10 + height, endColor, startColor);
|
||||||
RenderSystem.pushMatrix();
|
RenderSystem.pushMatrix();
|
||||||
|
@ -156,16 +176,17 @@ public class PonderProgressBar extends AbstractSimiWidget {
|
||||||
if (activeScene.currentTime < keyframeTime) {
|
if (activeScene.currentTime < keyframeTime) {
|
||||||
text = ">";
|
text = ">";
|
||||||
offset = -1 - font.getStringWidth(text);
|
offset = -1 - font.getStringWidth(text);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
text = "<";
|
text = "<";
|
||||||
offset = 3;
|
offset = 3;
|
||||||
}
|
}
|
||||||
font.drawString(text, keyframePos + offset, 10, endColor);
|
font.drawString(text, keyframePos + offset, 10, endColor);
|
||||||
RenderSystem.popMatrix();
|
RenderSystem.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiUtils.drawGradientRect(500, keyframePos, -1, keyframePos + 1, 2 + height, startColor, endColor);
|
GuiUtils.drawGradientRect(500, keyframePos, -1, keyframePos + 1, 2 + height, startColor, endColor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playDownSound(SoundHandler handler) {
|
public void playDownSound(SoundHandler handler) {
|
||||||
|
|
Loading…
Reference in a new issue