Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Interpolated scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo27 committed Apr 10, 2017
1 parent 6a2943b commit 54cd19f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
11 changes: 7 additions & 4 deletions core/src/chrislo27/rhre/editor/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class Editor extends InputAdapter implements Disposable {
private final Vector3 vec3Tmp2 = new Vector3();
private final List<InspectionType> highlightedInspections = new ArrayList<>();
private final GlyphLayout glyphLayout = new GlyphLayout();
private final Map<Series, Scroll> scrolls = new HashMap<>();
private final Map<Series, ScrollValue> scrolls = new HashMap<>();
private final Vector3 cameraPickVec3 = new Vector3();
public String status;
public Tool currentTool = Tool.NORMAL;
Expand Down Expand Up @@ -104,7 +104,7 @@ public Editor(Main m) {
remix = new Remix();

for (Series s : Series.values)
scrolls.put(s, new Scroll(0, 0));
scrolls.put(s, new ScrollValue(0, 0, 0));
snappingInterval = 0.25f;
}

Expand Down Expand Up @@ -594,7 +594,9 @@ public void render(SpriteBatch batch) {

float middle = MESSAGE_BAR_HEIGHT + PICKER_HEIGHT * 0.5f + main.getFontBordered().getCapHeight() * 0.5f;

for (int i = Math.max(0, scrolls.get(currentSeries).getPattern() - PATTERNS_ABOVE_BELOW), first = scrolls
scrolls.values().forEach(ScrollValue::update);

for (int i = Math.max(0, scrolls.get(currentSeries).getPattern() - PATTERNS_ABOVE_BELOW - 1), first = scrolls
.get(currentSeries).getPattern();
i < Math.min(game.getPatterns().size(), first + PATTERNS_ABOVE_BELOW + 900); i++) {
Pattern p = game.getPatterns().get(i);
Expand Down Expand Up @@ -627,12 +629,13 @@ public void render(SpriteBatch batch) {
main.getFontBordered().setColor(0.65f, 1, 1, 1);
}

float lerp = scrolls.get(currentSeries).getPatternLerp();
Main.Companion.drawCompressed(main.getFontBordered(), batch, p.getName() +
(DebugSetting.debug ? (" [GRAY](" +
(!p.getAutoGenerated() ? p.getId() : p.getCues().get(0).getId()) + ")[]") :
""),
main.camera.viewportWidth * 0.525f,
middle + (first - i) * PICKER_HEIGHT / (PATTERNS_ABOVE_BELOW * 2 + 1),
middle + (lerp - i) * PICKER_HEIGHT / (PATTERNS_ABOVE_BELOW * 2 + 1),
main.camera.viewportWidth * 0.45f, Align.left);
}

Expand Down
3 changes: 0 additions & 3 deletions core/src/chrislo27/rhre/editor/Scroll.kt

This file was deleted.

12 changes: 12 additions & 0 deletions core/src/chrislo27/rhre/editor/ScrollValue.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package chrislo27.rhre.editor

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.MathUtils

data class ScrollValue(var game: Int, var pattern: Int, var patternLerp: Float = pattern.toFloat()) {

fun update() {
patternLerp = MathUtils.lerp(patternLerp, pattern.toFloat(), Gdx.graphics.deltaTime * 16f)
}

}

0 comments on commit 54cd19f

Please sign in to comment.