Skip to content

Commit

Permalink
Editor: Adds New Project submenu (#28325)
Browse files Browse the repository at this point in the history
* adds New Project submenu

* dont import MenubarExamples
  • Loading branch information
ycw committed May 9, 2024
1 parent 66a31ae commit 774fced
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 105 deletions.
66 changes: 0 additions & 66 deletions editor/js/Menubar.Examples.js

This file was deleted.

77 changes: 72 additions & 5 deletions editor/js/Menubar.File.js
Expand Up @@ -19,11 +19,31 @@ function MenubarFile( editor ) {
options.setClass( 'options' );
container.add( options );

// New
// New Project

let option = new UIRow();
option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/file/new' ) );
const newProjectSubmenuTitle = new UIRow().setTextContent( strings.getKey( 'menubar/file/newProject' ) ).addClass( 'option' ).addClass( 'submenu-title' );
newProjectSubmenuTitle.onMouseOver( function () {

const { top, right } = this.dom.getBoundingClientRect();
const { paddingTop } = getComputedStyle( this.dom );
newPorjectSubmenu.setLeft( right + 'px' );
newPorjectSubmenu.setTop( top - parseFloat( paddingTop ) + 'px' );
newPorjectSubmenu.setDisplay( 'block' );

} );
newProjectSubmenuTitle.onMouseOut( function () {

newPorjectSubmenu.setDisplay( 'none' );

} );
options.add( newProjectSubmenuTitle );

const newPorjectSubmenu = new UIPanel().setPosition( 'fixed' ).addClass( 'options' ).setDisplay( 'none' );
newProjectSubmenuTitle.add( newPorjectSubmenu );

// New Project / Empty

let option = new UIRow().setTextContent( strings.getKey( 'menubar/file/newProject/empty' ) ).setClass( 'option' );
option.onClick( function () {

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

} );
options.add( option );
newPorjectSubmenu.add( option );

//

newPorjectSubmenu.add( new UIHorizontalRule() );

// New Project / ...

const examples = [
{ title: 'menubar/file/newProject/Arkanoid', file: 'arkanoid.app.json' },
{ title: 'menubar/file/newProject/Camera', file: 'camera.app.json' },
{ title: 'menubar/file/newProject/Particles', file: 'particles.app.json' },
{ title: 'menubar/file/newProject/Pong', file: 'pong.app.json' },
{ title: 'menubar/file/newProject/Shaders', file: 'shaders.app.json' }
];

const loader = new THREE.FileLoader();

for ( let i = 0; i < examples.length; i ++ ) {

( function ( i ) {

const example = examples[ i ];

const option = new UIRow();
option.setClass( 'option' );
option.setTextContent( strings.getKey( example.title ) );
option.onClick( function () {

if ( confirm( strings.getKey( 'prompt/file/open' ) ) ) {

loader.load( 'examples/' + example.file, function ( text ) {

editor.clear();
editor.fromJSON( JSON.parse( text ) );

} );

}

} );
newPorjectSubmenu.add( option );

} )( i );

}

options.add( new UIHorizontalRule() );

// Import

Expand Down
2 changes: 0 additions & 2 deletions editor/js/Menubar.js
Expand Up @@ -3,7 +3,6 @@ import { UIPanel } from './libs/ui.js';
import { MenubarAdd } from './Menubar.Add.js';
import { MenubarEdit } from './Menubar.Edit.js';
import { MenubarFile } from './Menubar.File.js';
import { MenubarExamples } from './Menubar.Examples.js';
import { MenubarView } from './Menubar.View.js';
import { MenubarHelp } from './Menubar.Help.js';
import { MenubarStatus } from './Menubar.Status.js';
Expand All @@ -16,7 +15,6 @@ function Menubar( editor ) {
container.add( new MenubarFile( editor ) );
container.add( new MenubarEdit( editor ) );
container.add( new MenubarAdd( editor ) );
container.add( new MenubarExamples( editor ) );
container.add( new MenubarView( editor ) );
container.add( new MenubarHelp( editor ) );

Expand Down
61 changes: 29 additions & 32 deletions editor/js/Strings.js
Expand Up @@ -38,7 +38,13 @@ function Strings( config ) {
'command/SetValue': 'Set Value',

'menubar/file': 'File',
'menubar/file/new': 'New',
'menubar/file/newProject': 'New Project',
'menubar/file/newProject/empty': 'Empty',
'menubar/file/newProject/Arkanoid': 'Arkanoid',
'menubar/file/newProject/Camera': 'Camera',
'menubar/file/newProject/Particles': 'Particles',
'menubar/file/newProject/Pong': 'Pong',
'menubar/file/newProject/Shaders': 'Shaders',
'menubar/file/import': 'Import',
'menubar/file/export': 'Export',

Expand Down Expand Up @@ -83,13 +89,6 @@ function Strings( config ) {

'menubar/status/autosave': 'autosave',

'menubar/examples': 'Examples',
'menubar/examples/Arkanoid': 'Arkanoid',
'menubar/examples/Camera': 'Camera',
'menubar/examples/Particles': 'Particles',
'menubar/examples/Pong': 'Pong',
'menubar/examples/Shaders': 'Shaders',

'menubar/view': 'View',
'menubar/view/fullscreen': 'Fullscreen',

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

'menubar/file': 'Fichier',
'menubar/file/new': 'Nouveau',
'menubar/file/newProject': 'Nouveau projet',
'menubar/file/newProject/empty': 'Vide',
'menubar/file/newProject/Arkanoid': 'Arkanoid',
'menubar/file/newProject/Camera': 'Camera',
'menubar/file/newProject/Particles': 'Particles',
'menubar/file/newProject/Pong': 'Pong',
'menubar/file/newProject/Shaders': 'Shaders',

'menubar/file/import': 'Importer',
'menubar/file/export': 'Exporter',

Expand Down Expand Up @@ -468,13 +474,6 @@ function Strings( config ) {

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

'menubar/examples': 'Exemples',
'menubar/examples/Arkanoid': 'Arkanoid',
'menubar/examples/Camera': 'Camera',
'menubar/examples/Particles': 'Particles',
'menubar/examples/Pong': 'Pong',
'menubar/examples/Shaders': 'Shaders',

'menubar/view': 'View',
'menubar/view/fullscreen': 'Fullscreen',

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

'menubar/file': '文件',
'menubar/file/new': '新建',
'menubar/file/newProject': '新建项目',
'menubar/file/newProject/empty': '空',
'menubar/file/newProject/Arkanoid': '打砖块',
'menubar/file/newProject/Camera': ' 摄像机',
'menubar/file/newProject/Particles': '粒子',
'menubar/file/newProject/Pong': '乒乓球',
'menubar/file/newProject/Shaders': '着色器',
'menubar/file/import': '导入',
'menubar/file/export': '导出',

Expand Down Expand Up @@ -853,13 +858,6 @@ function Strings( config ) {

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

'menubar/examples': '示例',
'menubar/examples/Arkanoid': '打砖块',
'menubar/examples/Camera': ' 摄像机',
'menubar/examples/Particles': '粒子',
'menubar/examples/Pong': '乒乓球',
'menubar/examples/Shaders': '着色器',

'menubar/view': '视图',
'menubar/view/fullscreen': '全屏',

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

'menubar/file': 'ファイル',
'menubar/file/new': '新規',
'menubar/file/newProject': '新規プロジェクト',
'menubar/file/newProject/empty': '空',
'menubar/file/newProject/Arkanoid': 'ブロック崩し',
'menubar/file/newProject/Camera': 'カメラ',
'menubar/file/newProject/Particles': 'パーティクル',
'menubar/file/newProject/Pong': 'ピンポン',
'menubar/file/newProject/Shaders': 'シェーダー',
'menubar/file/import': 'インポート',
'menubar/file/export': 'エクスポート',

Expand Down Expand Up @@ -1238,13 +1242,6 @@ function Strings( config ) {

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

'menubar/examples': 'サンプル',
'menubar/examples/Arkanoid': 'ブロック崩し',
'menubar/examples/Camera': 'カメラ',
'menubar/examples/Particles': 'パーティクル',
'menubar/examples/Pong': 'ピンポン',
'menubar/examples/Shaders': 'シェーダー',

'menubar/view': '表示',
'menubar/view/fullscreen': 'フルスクリーン',

Expand Down

0 comments on commit 774fced

Please sign in to comment.