-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from Feodor0090/clock-offset-vis
Clock offset visualizer
- Loading branch information
Showing
4 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package nmania.ui.ng; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.microedition.lcdui.Graphics; | ||
import javax.microedition.lcdui.Image; | ||
import javax.microedition.lcdui.game.Sprite; | ||
|
||
import nmania.GL; | ||
import tube42.lib.imagelib.ColorUtils; | ||
|
||
public class OffsetBox extends NumberBox { | ||
|
||
public OffsetBox(int UUID, INumberBoxHandler handler, int value, boolean allowNegative) { | ||
super("Clock offset", UUID, handler, value, allowNegative); | ||
showPlusMinus = true; | ||
try { | ||
wf = Image.createImage("/ui/exwf.png"); | ||
} catch (IOException e) { | ||
GL.Log("Failed to load waveform image, screen will fail!"); | ||
} | ||
} | ||
|
||
private Image wf; | ||
|
||
public void Paint(Graphics g, int w, int h) { | ||
g.setColor(0); | ||
g.fillRect(w - 46, 5, 42, h - 10); | ||
g.setColor(-1); | ||
g.drawRect(w - 46, 5, 41, h - 11); | ||
int time = (int) (System.currentTimeMillis() % 723); | ||
int pprogress = (723 - time) * 112 / 723; | ||
// waveform | ||
{ | ||
g.drawRegion(wf, 112 - pprogress, 0, pprogress, 52, Sprite.TRANS_MIRROR_ROT90, w - 101, h - 5 - pprogress, | ||
0); | ||
int cy = h - 5 - pprogress - 112; | ||
while (cy > 5) { | ||
g.drawRegion(wf, 0, 0, 112, 52, Sprite.TRANS_MIRROR_ROT90, w - 101, cy, 0); | ||
cy -= 112; | ||
} | ||
int ty = -(cy - 5); | ||
g.drawRegion(wf, 0, 0, 112 - ty, 52, Sprite.TRANS_MIRROR_ROT90, w - 101, 5, 0); | ||
} | ||
// notes | ||
for (int i = -2; i < 30; i++) { | ||
int ny = h - 6 - pprogress - (56 * i) - (value * 112 / 723); | ||
for (int j = 0; j < 25; j++) { | ||
int ly = ny - j; | ||
if (ly <= 5) | ||
break; | ||
if (ly >= h - 6) | ||
continue; | ||
g.setColor(ColorUtils.blend(0, 0x00ff00, j * 255 / 24)); | ||
g.drawLine(w - 45, ly, w - 6, ly); | ||
} | ||
} | ||
super.Paint(g, w - 105, h); | ||
} | ||
|
||
public void OnTouch(IDisplay d, int s, int x, int y, int dx, int dy, int w, int h) { | ||
super.OnTouch(d, s, x, y, dx, dy, w - 105, h); | ||
} | ||
} |