Bläddra i källkod

Editor: Make playback speed of animations configurable.

Mugen87 4 år sedan
förälder
incheckning
d9780565c5
2 ändrade filer med 29 tillägg och 6 borttagningar
  1. 26 6
      editor/js/Sidebar.Animation.js
  2. 3 0
      editor/js/Strings.js

+ 26 - 6
editor/js/Sidebar.Animation.js

@@ -1,4 +1,4 @@
-import { UIPanel, UIDiv, UIBreak, UISelect, UIButton, UIText } from './libs/ui.js';
+import { UIPanel, UIBreak, UISelect, UIButton, UIText, UINumber, UIRow } from './libs/ui.js';
 
 
 function SidebarAnimation( editor ) {
 function SidebarAnimation( editor ) {
 
 
@@ -30,6 +30,7 @@ function SidebarAnimation( editor ) {
 
 
 			animationsSelect.setOptions( options );
 			animationsSelect.setOptions( options );
 			animationsSelect.setValue( firstAnimation );
 			animationsSelect.setValue( firstAnimation );
+			mixerTimeScaleNumber.setValue( mixer.timeScale );
 
 
 		} else {
 		} else {
 
 
@@ -63,6 +64,12 @@ function SidebarAnimation( editor ) {
 
 
 	}
 	}
 
 
+	function changeTimeScale() {
+
+		mixer.timeScale = mixerTimeScaleNumber.getValue();
+
+	}
+
 	var container = new UIPanel();
 	var container = new UIPanel();
 	container.setDisplay( 'none' );
 	container.setDisplay( 'none' );
 
 
@@ -70,13 +77,26 @@ function SidebarAnimation( editor ) {
 	container.add( new UIBreak() );
 	container.add( new UIBreak() );
 	container.add( new UIBreak() );
 	container.add( new UIBreak() );
 
 
-	var div = new UIDiv();
-	container.add( div );
+	//
+
+	var animationsRow = new UIRow();
 
 
 	var animationsSelect = new UISelect().setFontSize( '12px' );
 	var animationsSelect = new UISelect().setFontSize( '12px' );
-	div.add( animationsSelect );
-	div.add( new UIButton( strings.getKey( 'sidebar/animations/play' ) ).setMarginLeft( '4px' ).onClick( playAction ) );
-	div.add( new UIButton( strings.getKey( 'sidebar/animations/stop' ) ).setMarginLeft( '4px' ).onClick( stopAction ) );
+	animationsRow.add( animationsSelect );
+	animationsRow.add( new UIButton( strings.getKey( 'sidebar/animations/play' ) ).setMarginLeft( '4px' ).onClick( playAction ) );
+	animationsRow.add( new UIButton( strings.getKey( 'sidebar/animations/stop' ) ).setMarginLeft( '4px' ).onClick( stopAction ) );
+
+	container.add( animationsRow );
+
+	//
+
+	var mixerTimeScaleRow = new UIRow();
+	var mixerTimeScaleNumber = new UINumber( 0.5 ).setWidth( '60px' ).setRange( - 10, 10 ).onChange( changeTimeScale );
+
+	mixerTimeScaleRow.add( new UIText( strings.getKey( 'sidebar/animations/timescale' ) ).setWidth( '90px' ) );
+	mixerTimeScaleRow.add( mixerTimeScaleNumber );
+
+	container.add( mixerTimeScaleRow );
 
 
 	return container;
 	return container;
 
 

+ 3 - 0
editor/js/Strings.js

@@ -77,6 +77,7 @@ function Strings( config ) {
 			'sidebar/animations': 'Animations',
 			'sidebar/animations': 'Animations',
 			'sidebar/animations/play': 'Play',
 			'sidebar/animations/play': 'Play',
 			'sidebar/animations/stop': 'Stop',
 			'sidebar/animations/stop': 'Stop',
+			'sidebar/animations/timescale': 'Time Scale',
 
 
 			'sidebar/scene': 'Scene',
 			'sidebar/scene': 'Scene',
 			'sidebar/scene/background': 'Background',
 			'sidebar/scene/background': 'Background',
@@ -400,6 +401,7 @@ function Strings( config ) {
 			'sidebar/animations': 'Animations',
 			'sidebar/animations': 'Animations',
 			'sidebar/animations/play': 'Play',
 			'sidebar/animations/play': 'Play',
 			'sidebar/animations/stop': 'Stop',
 			'sidebar/animations/stop': 'Stop',
+			'sidebar/animations/timescale': 'Time Scale',
 
 
 			'sidebar/scene': 'Scène',
 			'sidebar/scene': 'Scène',
 			'sidebar/scene/background': 'Arrière Plan',
 			'sidebar/scene/background': 'Arrière Plan',
@@ -723,6 +725,7 @@ function Strings( config ) {
 			'sidebar/animations': '动画',
 			'sidebar/animations': '动画',
 			'sidebar/animations/play': '播放',
 			'sidebar/animations/play': '播放',
 			'sidebar/animations/stop': '暂停',
 			'sidebar/animations/stop': '暂停',
+			'sidebar/animations/timescale': 'Time Scale',
 
 
 			'sidebar/scene': '场景',
 			'sidebar/scene': '场景',
 			'sidebar/scene/background': '背景',
 			'sidebar/scene/background': '背景',