mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:13:15 +02:00
Make the time and slider follow the record.js toolbar
This commit is contained in:
parent
6b26f5f3a3
commit
b21bd3afa9
2 changed files with 33 additions and 21 deletions
|
@ -16,7 +16,7 @@ Script.include("/~/system/libraries/toolBars.js");
|
||||||
|
|
||||||
var recordingFile = "recording.hfr";
|
var recordingFile = "recording.hfr";
|
||||||
|
|
||||||
function setPlayerOptions() {
|
function setDefaultPlayerOptions() {
|
||||||
Recording.setPlayFromCurrentLocation(true);
|
Recording.setPlayFromCurrentLocation(true);
|
||||||
Recording.setPlayerUseDisplayName(false);
|
Recording.setPlayerUseDisplayName(false);
|
||||||
Recording.setPlayerUseAttachments(false);
|
Recording.setPlayerUseAttachments(false);
|
||||||
|
@ -40,10 +40,10 @@ var saveIcon;
|
||||||
var loadIcon;
|
var loadIcon;
|
||||||
var spacing;
|
var spacing;
|
||||||
var timerOffset;
|
var timerOffset;
|
||||||
setupToolBar();
|
|
||||||
|
|
||||||
var timer = null;
|
var timer = null;
|
||||||
var slider = null;
|
var slider = null;
|
||||||
|
|
||||||
|
setupToolBar();
|
||||||
setupTimer();
|
setupTimer();
|
||||||
|
|
||||||
var watchStop = false;
|
var watchStop = false;
|
||||||
|
@ -58,6 +58,8 @@ function setupToolBar() {
|
||||||
|
|
||||||
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
|
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
|
||||||
|
|
||||||
|
toolBar.onMove = onToolbarMove;
|
||||||
|
|
||||||
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
||||||
|
|
||||||
recordIcon = toolBar.addTool({
|
recordIcon = toolBar.addTool({
|
||||||
|
@ -146,6 +148,26 @@ function setupTimer() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onToolbarMove(newX, newY, deltaX, deltaY) {
|
||||||
|
print(newX);
|
||||||
|
Overlays.editOverlay(timer, {
|
||||||
|
x: newX + timerOffset - ToolBar.SPACING,
|
||||||
|
y: newY - ToolBar.SPACING
|
||||||
|
});
|
||||||
|
|
||||||
|
slider.x = newX - ToolBar.SPACING;
|
||||||
|
slider.y = newY - slider.h - ToolBar.SPACING;
|
||||||
|
|
||||||
|
Overlays.editOverlay(slider.background, {
|
||||||
|
x: slider.x,
|
||||||
|
y: slider.y
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(slider.foreground, {
|
||||||
|
x: slider.x,
|
||||||
|
y: slider.y
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function updateTimer() {
|
function updateTimer() {
|
||||||
var text = "";
|
var text = "";
|
||||||
if (Recording.isRecording()) {
|
if (Recording.isRecording()) {
|
||||||
|
@ -196,22 +218,6 @@ function formatTime(time) {
|
||||||
function moveUI() {
|
function moveUI() {
|
||||||
var relative = { x: 70, y: 40 };
|
var relative = { x: 70, y: 40 };
|
||||||
toolBar.move(relative.x, windowDimensions.y - relative.y);
|
toolBar.move(relative.x, windowDimensions.y - relative.y);
|
||||||
Overlays.editOverlay(timer, {
|
|
||||||
x: relative.x + timerOffset - ToolBar.SPACING,
|
|
||||||
y: windowDimensions.y - relative.y - ToolBar.SPACING
|
|
||||||
});
|
|
||||||
|
|
||||||
slider.x = relative.x - ToolBar.SPACING;
|
|
||||||
slider.y = windowDimensions.y - relative.y - slider.h - ToolBar.SPACING;
|
|
||||||
|
|
||||||
Overlays.editOverlay(slider.background, {
|
|
||||||
x: slider.x,
|
|
||||||
y: slider.y
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(slider.foreground, {
|
|
||||||
x: slider.x,
|
|
||||||
y: slider.y
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
|
@ -228,6 +234,9 @@ function mousePressEvent(event) {
|
||||||
} else {
|
} else {
|
||||||
Recording.stopRecording();
|
Recording.stopRecording();
|
||||||
toolBar.selectTool(recordIcon, true);
|
toolBar.selectTool(recordIcon, true);
|
||||||
|
setDefaultPlayerOptions();
|
||||||
|
// Plays the recording at the same spot as you recorded it
|
||||||
|
Recording.setPlayFromCurrentLocation(false);
|
||||||
Recording.setPlayerTime(0);
|
Recording.setPlayerTime(0);
|
||||||
Recording.loadLastRecording();
|
Recording.loadLastRecording();
|
||||||
toolBar.setAlpha(ALPHA_ON, playIcon);
|
toolBar.setAlpha(ALPHA_ON, playIcon);
|
||||||
|
@ -242,7 +251,6 @@ function mousePressEvent(event) {
|
||||||
toolBar.setAlpha(ALPHA_ON, saveIcon);
|
toolBar.setAlpha(ALPHA_ON, saveIcon);
|
||||||
toolBar.setAlpha(ALPHA_ON, loadIcon);
|
toolBar.setAlpha(ALPHA_ON, loadIcon);
|
||||||
} else if (Recording.playerLength() > 0) {
|
} else if (Recording.playerLength() > 0) {
|
||||||
setPlayerOptions();
|
|
||||||
Recording.setPlayerLoop(false);
|
Recording.setPlayerLoop(false);
|
||||||
Recording.startPlaying();
|
Recording.startPlaying();
|
||||||
toolBar.setAlpha(ALPHA_OFF, recordIcon);
|
toolBar.setAlpha(ALPHA_OFF, recordIcon);
|
||||||
|
@ -257,7 +265,6 @@ function mousePressEvent(event) {
|
||||||
toolBar.setAlpha(ALPHA_ON, saveIcon);
|
toolBar.setAlpha(ALPHA_ON, saveIcon);
|
||||||
toolBar.setAlpha(ALPHA_ON, loadIcon);
|
toolBar.setAlpha(ALPHA_ON, loadIcon);
|
||||||
} else if (Recording.playerLength() > 0) {
|
} else if (Recording.playerLength() > 0) {
|
||||||
setPlayerOptions();
|
|
||||||
Recording.setPlayerLoop(true);
|
Recording.setPlayerLoop(true);
|
||||||
Recording.startPlaying();
|
Recording.startPlaying();
|
||||||
toolBar.setAlpha(ALPHA_OFF, recordIcon);
|
toolBar.setAlpha(ALPHA_OFF, recordIcon);
|
||||||
|
@ -276,6 +283,7 @@ function mousePressEvent(event) {
|
||||||
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
||||||
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
||||||
Recording.loadRecording(recordingFile);
|
Recording.loadRecording(recordingFile);
|
||||||
|
setDefaultPlayerOptions();
|
||||||
}
|
}
|
||||||
if (Recording.playerLength() > 0) {
|
if (Recording.playerLength() > 0) {
|
||||||
toolBar.setAlpha(ALPHA_ON, playIcon);
|
toolBar.setAlpha(ALPHA_ON, playIcon);
|
||||||
|
|
|
@ -160,6 +160,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
this.spacing = [];
|
this.spacing = [];
|
||||||
|
this.onMove = null;
|
||||||
|
|
||||||
this.addTool = function(properties, selectable, selected) {
|
this.addTool = function(properties, selectable, selected) {
|
||||||
if (direction == ToolBar.HORIZONTAL) {
|
if (direction == ToolBar.HORIZONTAL) {
|
||||||
|
@ -254,6 +255,9 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
|
||||||
y: y - ToolBar.SPACING
|
y: y - ToolBar.SPACING
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (this.onMove !== null) {
|
||||||
|
this.onMove(x, y, dx, dy);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setAlpha = function(alpha, tool) {
|
this.setAlpha = function(alpha, tool) {
|
||||||
|
|
Loading…
Reference in a new issue