Skip to content

Commit 774fced

Browse files
authored
Editor: Adds New Project submenu (#28325)
* adds New Project submenu * dont import MenubarExamples
1 parent 66a31ae commit 774fced

File tree

4 files changed

+101
-105
lines changed

4 files changed

+101
-105
lines changed

editor/js/Menubar.Examples.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

editor/js/Menubar.File.js

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,31 @@ function MenubarFile( editor ) {
1919
options.setClass( 'options' );
2020
container.add( options );
2121

22-
// New
22+
// New Project
2323

24-
let option = new UIRow();
25-
option.setClass( 'option' );
26-
option.setTextContent( strings.getKey( 'menubar/file/new' ) );
24+
const newProjectSubmenuTitle = new UIRow().setTextContent( strings.getKey( 'menubar/file/newProject' ) ).addClass( 'option' ).addClass( 'submenu-title' );
25+
newProjectSubmenuTitle.onMouseOver( function () {
26+
27+
const { top, right } = this.dom.getBoundingClientRect();
28+
const { paddingTop } = getComputedStyle( this.dom );
29+
newPorjectSubmenu.setLeft( right + 'px' );
30+
newPorjectSubmenu.setTop( top - parseFloat( paddingTop ) + 'px' );
31+
newPorjectSubmenu.setDisplay( 'block' );
32+
33+
} );
34+
newProjectSubmenuTitle.onMouseOut( function () {
35+
36+
newPorjectSubmenu.setDisplay( 'none' );
37+
38+
} );
39+
options.add( newProjectSubmenuTitle );
40+
41+
const newPorjectSubmenu = new UIPanel().setPosition( 'fixed' ).addClass( 'options' ).setDisplay( 'none' );
42+
newProjectSubmenuTitle.add( newPorjectSubmenu );
43+
44+
// New Project / Empty
45+
46+
let option = new UIRow().setTextContent( strings.getKey( 'menubar/file/newProject/empty' ) ).setClass( 'option' );
2747
option.onClick( function () {
2848

2949
if ( confirm( strings.getKey( 'prompt/file/open' ) ) ) {
@@ -33,7 +53,54 @@ function MenubarFile( editor ) {
3353
}
3454

3555
} );
36-
options.add( option );
56+
newPorjectSubmenu.add( option );
57+
58+
//
59+
60+
newPorjectSubmenu.add( new UIHorizontalRule() );
61+
62+
// New Project / ...
63+
64+
const examples = [
65+
{ title: 'menubar/file/newProject/Arkanoid', file: 'arkanoid.app.json' },
66+
{ title: 'menubar/file/newProject/Camera', file: 'camera.app.json' },
67+
{ title: 'menubar/file/newProject/Particles', file: 'particles.app.json' },
68+
{ title: 'menubar/file/newProject/Pong', file: 'pong.app.json' },
69+
{ title: 'menubar/file/newProject/Shaders', file: 'shaders.app.json' }
70+
];
71+
72+
const loader = new THREE.FileLoader();
73+
74+
for ( let i = 0; i < examples.length; i ++ ) {
75+
76+
( function ( i ) {
77+
78+
const example = examples[ i ];
79+
80+
const option = new UIRow();
81+
option.setClass( 'option' );
82+
option.setTextContent( strings.getKey( example.title ) );
83+
option.onClick( function () {
84+
85+
if ( confirm( strings.getKey( 'prompt/file/open' ) ) ) {
86+
87+
loader.load( 'examples/' + example.file, function ( text ) {
88+
89+
editor.clear();
90+
editor.fromJSON( JSON.parse( text ) );
91+
92+
} );
93+
94+
}
95+
96+
} );
97+
newPorjectSubmenu.add( option );
98+
99+
} )( i );
100+
101+
}
102+
103+
options.add( new UIHorizontalRule() );
37104

38105
// Import
39106

editor/js/Menubar.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { UIPanel } from './libs/ui.js';
33
import { MenubarAdd } from './Menubar.Add.js';
44
import { MenubarEdit } from './Menubar.Edit.js';
55
import { MenubarFile } from './Menubar.File.js';
6-
import { MenubarExamples } from './Menubar.Examples.js';
76
import { MenubarView } from './Menubar.View.js';
87
import { MenubarHelp } from './Menubar.Help.js';
98
import { MenubarStatus } from './Menubar.Status.js';
@@ -16,7 +15,6 @@ function Menubar( editor ) {
1615
container.add( new MenubarFile( editor ) );
1716
container.add( new MenubarEdit( editor ) );
1817
container.add( new MenubarAdd( editor ) );
19-
container.add( new MenubarExamples( editor ) );
2018
container.add( new MenubarView( editor ) );
2119
container.add( new MenubarHelp( editor ) );
2220

editor/js/Strings.js

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ function Strings( config ) {
3838
'command/SetValue': 'Set Value',
3939

4040
'menubar/file': 'File',
41-
'menubar/file/new': 'New',
41+
'menubar/file/newProject': 'New Project',
42+
'menubar/file/newProject/empty': 'Empty',
43+
'menubar/file/newProject/Arkanoid': 'Arkanoid',
44+
'menubar/file/newProject/Camera': 'Camera',
45+
'menubar/file/newProject/Particles': 'Particles',
46+
'menubar/file/newProject/Pong': 'Pong',
47+
'menubar/file/newProject/Shaders': 'Shaders',
4248
'menubar/file/import': 'Import',
4349
'menubar/file/export': 'Export',
4450

@@ -83,13 +89,6 @@ function Strings( config ) {
8389

8490
'menubar/status/autosave': 'autosave',
8591

86-
'menubar/examples': 'Examples',
87-
'menubar/examples/Arkanoid': 'Arkanoid',
88-
'menubar/examples/Camera': 'Camera',
89-
'menubar/examples/Particles': 'Particles',
90-
'menubar/examples/Pong': 'Pong',
91-
'menubar/examples/Shaders': 'Shaders',
92-
9392
'menubar/view': 'View',
9493
'menubar/view/fullscreen': 'Fullscreen',
9594

@@ -423,7 +422,14 @@ function Strings( config ) {
423422
'command/SetValue': 'Définir la valeur',
424423

425424
'menubar/file': 'Fichier',
426-
'menubar/file/new': 'Nouveau',
425+
'menubar/file/newProject': 'Nouveau projet',
426+
'menubar/file/newProject/empty': 'Vide',
427+
'menubar/file/newProject/Arkanoid': 'Arkanoid',
428+
'menubar/file/newProject/Camera': 'Camera',
429+
'menubar/file/newProject/Particles': 'Particles',
430+
'menubar/file/newProject/Pong': 'Pong',
431+
'menubar/file/newProject/Shaders': 'Shaders',
432+
427433
'menubar/file/import': 'Importer',
428434
'menubar/file/export': 'Exporter',
429435

@@ -468,13 +474,6 @@ function Strings( config ) {
468474

469475
'menubar/status/autosave': 'enregistrement automatique',
470476

471-
'menubar/examples': 'Exemples',
472-
'menubar/examples/Arkanoid': 'Arkanoid',
473-
'menubar/examples/Camera': 'Camera',
474-
'menubar/examples/Particles': 'Particles',
475-
'menubar/examples/Pong': 'Pong',
476-
'menubar/examples/Shaders': 'Shaders',
477-
478477
'menubar/view': 'View',
479478
'menubar/view/fullscreen': 'Fullscreen',
480479

@@ -808,7 +807,13 @@ function Strings( config ) {
808807
'command/SetValue': '设定值',
809808

810809
'menubar/file': '文件',
811-
'menubar/file/new': '新建',
810+
'menubar/file/newProject': '新建项目',
811+
'menubar/file/newProject/empty': '空',
812+
'menubar/file/newProject/Arkanoid': '打砖块',
813+
'menubar/file/newProject/Camera': ' 摄像机',
814+
'menubar/file/newProject/Particles': '粒子',
815+
'menubar/file/newProject/Pong': '乒乓球',
816+
'menubar/file/newProject/Shaders': '着色器',
812817
'menubar/file/import': '导入',
813818
'menubar/file/export': '导出',
814819

@@ -853,13 +858,6 @@ function Strings( config ) {
853858

854859
'menubar/status/autosave': '自动保存',
855860

856-
'menubar/examples': '示例',
857-
'menubar/examples/Arkanoid': '打砖块',
858-
'menubar/examples/Camera': ' 摄像机',
859-
'menubar/examples/Particles': '粒子',
860-
'menubar/examples/Pong': '乒乓球',
861-
'menubar/examples/Shaders': '着色器',
862-
863861
'menubar/view': '视图',
864862
'menubar/view/fullscreen': '全屏',
865863

@@ -1193,7 +1191,13 @@ function Strings( config ) {
11931191
'command/SetValue': '値の設定',
11941192

11951193
'menubar/file': 'ファイル',
1196-
'menubar/file/new': '新規',
1194+
'menubar/file/newProject': '新規プロジェクト',
1195+
'menubar/file/newProject/empty': '空',
1196+
'menubar/file/newProject/Arkanoid': 'ブロック崩し',
1197+
'menubar/file/newProject/Camera': 'カメラ',
1198+
'menubar/file/newProject/Particles': 'パーティクル',
1199+
'menubar/file/newProject/Pong': 'ピンポン',
1200+
'menubar/file/newProject/Shaders': 'シェーダー',
11971201
'menubar/file/import': 'インポート',
11981202
'menubar/file/export': 'エクスポート',
11991203

@@ -1238,13 +1242,6 @@ function Strings( config ) {
12381242

12391243
'menubar/status/autosave': '自動保存',
12401244

1241-
'menubar/examples': 'サンプル',
1242-
'menubar/examples/Arkanoid': 'ブロック崩し',
1243-
'menubar/examples/Camera': 'カメラ',
1244-
'menubar/examples/Particles': 'パーティクル',
1245-
'menubar/examples/Pong': 'ピンポン',
1246-
'menubar/examples/Shaders': 'シェーダー',
1247-
12481245
'menubar/view': '表示',
12491246
'menubar/view/fullscreen': 'フルスクリーン',
12501247

0 commit comments

Comments
 (0)