2022-05-19 05:44:00 +08:00
const StartScreen = {
loaders : { }
} ;
2021-11-14 06:19:23 +08:00
function addStartScreenSection ( id , data ) {
if ( typeof id == 'object' ) {
data = id ;
id = '' ;
}
2022-03-16 23:19:56 +08:00
var obj = $ ( Interface . createElement ( 'section' , { id } ) )
2021-11-14 06:19:23 +08:00
if ( typeof data . graphic === 'object' ) {
var left = $ ( '<div class="start_screen_left graphic"></div>' )
obj . append ( left )
if ( data . graphic . type === 'icon' ) {
var icon = Blockbench . getIconNode ( data . graphic . icon )
left . addClass ( 'graphic_icon' )
left . append ( icon )
} else {
left . css ( 'background-image' , ` url(' ${ data . graphic . source } ') ` )
}
if ( data . graphic . width ) {
left . css ( 'width' , data . graphic . width + 'px' ) ;
}
if ( data . graphic . width && data . text ) {
left . css ( 'flex-shrink' , '0' ) ;
}
if ( data . graphic . width && data . graphic . height && Blockbench . isMobile ) {
left . css ( 'height' , '0' )
. css ( 'padding-top' , '0' )
. css ( 'padding-bottom' , ( data . graphic . height / data . graphic . width * 100 ) + '%' )
} else {
if ( data . graphic . height ) left . css ( 'height' , data . graphic . height + 'px' ) ;
if ( data . graphic . width && ! data . graphic . height && ! data . graphic . aspect _ratio ) left . css ( 'height' , data . graphic . width + 'px' ) ;
if ( data . graphic . aspect _ratio ) left . css ( 'aspect-ratio' , data . graphic . aspect _ratio ) ;
}
if ( data . graphic . description ) {
let content = $ ( marked ( data . graphic . description ) ) ;
content . css ( {
'bottom' : '15px' ,
'right' : '15px' ,
2021-12-21 22:30:01 +08:00
'color' : data . graphic . text _color || '#ffffff' ,
2021-11-14 06:19:23 +08:00
} ) ;
left . append ( content ) ;
}
}
if ( data . text instanceof Array ) {
var right = $ ( '<div class="start_screen_right"></div>' )
obj . append ( right )
data . text . forEach ( line => {
var content = line . text ? marked ( tl ( line . text ) ) : '' ;
switch ( line . type ) {
case 'h1' : var tag = 'h2' ; break ;
case 'h2' : var tag = 'h3' ; break ;
case 'list' :
var tag = 'ul class="list_style"' ;
line . list . forEach ( string => {
content += ` <li> ${ marked ( tl ( string ) ) } </li> ` ;
} )
break ;
case 'button' : var tag = 'button' ; break ;
default : var tag = 'p' ; break ;
}
var l = $ ( ` < ${ tag } > ${ content } </ ${ tag . split ( ' ' ) [ 0 ] } > ` ) ;
if ( typeof line . click == 'function' ) {
l . on ( 'click' , line . click ) ;
}
right . append ( l ) ;
} )
}
if ( data . layout == 'vertical' ) {
obj . addClass ( 'vertical' ) ;
}
if ( data . features instanceof Array ) {
let features _section = document . createElement ( 'ul' ) ;
features _section . className = 'start_screen_features'
data . features . forEach ( feature => {
let li = document . createElement ( 'li' ) ;
let img = new Image ( ) ; img . src = feature . image ;
let title = document . createElement ( 'h3' ) ; title . textContent = feature . title ;
let text = document . createElement ( 'p' ) ; text . textContent = feature . text ;
li . append ( img , title , text ) ;
features _section . append ( li ) ;
} )
obj . append ( features _section ) ;
}
if ( data . closable !== false ) {
obj . append ( ` <i class="material-icons start_screen_close_button">clear</i> ` ) ;
obj . find ( 'i.start_screen_close_button' ) . click ( ( e ) => {
obj . detach ( )
} ) ;
}
if ( typeof data . click == 'function' ) {
obj . on ( 'click' , event => {
if ( event . target . classList . contains ( 'start_screen_close_button' ) ) return ;
data . click ( )
} )
}
if ( data . color ) {
obj . css ( 'background-color' , data . color ) ;
if ( data . color == 'var(--color-bright_ui)' ) {
obj . addClass ( 'bright_ui' )
}
}
if ( data . text _color ) {
obj . css ( 'color' , data . text _color ) ;
}
if ( data . last ) {
2022-07-19 04:42:28 +08:00
$ ( '#start_screen > content' ) . append ( obj ) ;
2022-03-28 19:04:23 +08:00
} else if ( data . insert _after ) {
2022-07-19 04:42:28 +08:00
$ ( '#start_screen > content' ) . find ( ` # ${ data . insert _after } ` ) . after ( obj ) ;
2022-03-28 19:04:23 +08:00
} else if ( data . insert _before ) {
2022-07-19 04:42:28 +08:00
$ ( '#start_screen > content' ) . find ( ` # ${ data . insert _before } ` ) . before ( obj ) ;
2021-11-14 06:19:23 +08:00
} else {
2022-07-19 04:42:28 +08:00
$ ( '#start_screen > content' ) . prepend ( obj ) ;
2021-11-14 06:19:23 +08:00
}
2022-03-28 19:04:23 +08:00
if ( ! obj [ 0 ] . parentElement ) {
2022-07-19 04:42:28 +08:00
$ ( '#start_screen > content' ) . append ( obj ) ;
2022-03-28 19:04:23 +08:00
}
2022-04-05 04:56:51 +08:00
return {
delete ( ) {
obj [ 0 ] . remove ( ) ;
}
}
2021-11-14 06:19:23 +08:00
}
onVueSetup ( function ( ) {
StateMemory . init ( 'start_screen_list_type' , 'string' )
StartScreen . vue = new Vue ( {
el : '#start_screen' ,
2022-05-24 02:46:49 +08:00
components : { } ,
2021-11-14 06:19:23 +08:00
data : {
formats : Formats ,
2022-05-24 02:46:49 +08:00
loaders : ModelLoader . loaders ,
selected _format _id : '' ,
2021-11-14 06:19:23 +08:00
recent : isApp ? recent _projects : [ ] ,
list _type : StateMemory . start _screen _list _type || 'grid' ,
redact _names : settings . streamer _mode . value ,
redacted : tl ( 'generic.redacted' ) ,
search _term : '' ,
isApp ,
2022-05-19 05:44:00 +08:00
mobile _layout : Blockbench . isMobile ,
2021-11-14 06:19:23 +08:00
getIconNode : Blockbench . getIconNode
} ,
methods : {
getDate ( p ) {
if ( p . day ) {
var diff = ( 365e10 + Blockbench . openTime . dayOfYear ( ) - p . day ) % 365 ;
if ( diff <= 0 ) {
return tl ( 'dates.today' ) ;
} else if ( diff == 1 ) {
return tl ( 'dates.yesterday' ) ;
} else if ( diff <= 7 ) {
return tl ( 'dates.this_week' ) ;
} else {
return tl ( 'dates.weeks_ago' , [ Math . ceil ( diff / 7 ) ] ) ;
}
} else {
return '-'
}
} ,
openProject : function ( p , event ) {
Blockbench . read ( [ p . path ] , { } , files => {
loadModelFile ( files [ 0 ] ) ;
} )
} ,
getThumbnail ( model _path ) {
let hash = model _path . hashCode ( ) . toString ( ) . replace ( /^-/ , '0' ) ;
let path = PathModule . join ( app . getPath ( 'userData' ) , 'thumbnails' , ` ${ hash } .png ` ) ;
if ( ! fs . existsSync ( path ) ) return ;
return path + '?' + Math . round ( Math . random ( ) * 255 ) ;
} ,
setListType ( type ) {
this . list _type = type ;
StateMemory . start _screen _list _type = type ;
StateMemory . save ( 'start_screen_list_type' )
} ,
2022-07-02 02:38:21 +08:00
recentProjectContextMenu ( recent _project , event ) {
let menu = new Menu ( 'recent_project' , [
{
id : 'favorite' ,
name : 'mode.start.recent.favorite' ,
icon : recent _project . favorite ? 'fas.fa-star' : 'far.fa-star' ,
click : ( ) => {
this . toggleProjectFavorite ( recent _project ) ;
}
} ,
{
id : 'remove' ,
name : 'generic.remove' ,
icon : 'clear' ,
click : ( ) => {
recent _projects . remove ( recent _project ) ;
updateRecentProjects ( ) ;
}
}
] )
menu . show ( event ) ;
} ,
toggleProjectFavorite ( recent _project ) {
recent _project . favorite = ! recent _project . favorite ;
if ( recent _project . favorite ) {
recent _projects . remove ( recent _project ) ;
recent _projects . splice ( 0 , 0 , recent _project ) ;
}
updateRecentProjects ( ) ;
} ,
2022-05-19 05:44:00 +08:00
getFormatCategories ( ) {
let categories = { } ;
function add ( key , format ) {
if ( ! categories [ format . category ] ) {
categories [ format . category ] = {
name : tl ( 'format_category.' + format . category ) ,
entries : [ ]
}
}
categories [ format . category ] . entries . push ( format ) ;
}
for ( let key in this . formats ) {
add ( key , this . formats [ key ] )
}
for ( let key in this . loaders ) {
add ( key , this . loaders [ key ] )
}
return categories ;
} ,
loadFormat ( format _entry ) {
2022-05-24 02:46:49 +08:00
this . selected _format _id = format _entry . id ;
2022-06-16 00:54:38 +08:00
if ( format _entry . onFormatPage ) format _entry . onFormatPage ( ) ;
2022-05-19 05:44:00 +08:00
} ,
confirmSetupScreen ( format _entry ) {
2022-05-24 02:46:49 +08:00
this . selected _format _id = '' ;
2022-05-19 05:44:00 +08:00
if ( format _entry . onStart ) format _entry . onStart ( ) ;
if ( typeof format _entry . new == 'function' ) format _entry . new ( ) ;
} ,
2022-06-05 23:33:03 +08:00
openLink ( link ) {
Blockbench . openLink ( link ) ;
} ,
2021-11-14 06:19:23 +08:00
tl
} ,
computed : {
projects ( ) {
if ( ! this . search _term ) return this . recent ;
let terms = this . search _term . toLowerCase ( ) . split ( /\s/ ) ;
2021-11-15 06:47:56 +08:00
2021-11-14 06:19:23 +08:00
return this . recent . filter ( project => {
return ! terms . find ( term => (
! project . path . toLowerCase ( ) . includes ( term )
) )
} )
}
} ,
template : `
< div id = "start_screen" >
< content >
2022-05-19 05:44:00 +08:00
< section id = "start_files" >
2022-05-24 02:46:49 +08:00
< div class = "start_screen_left" v - if = "!(selected_format_id && mobile_layout)" >
2021-11-14 06:19:23 +08:00
< h2 > $ { tl ( 'mode.start.new' ) } < / h 2 >
< ul >
2022-05-19 05:44:00 +08:00
< li v - for = "(category, key) in getFormatCategories()" class = "format_category" : key = "key" >
< label > { { category . name } } < / l a b e l >
< ul >
< li
v - for = "format_entry in category.entries" : key = "format_entry.id"
2022-05-24 02:46:49 +08:00
class = "format_entry" : class = "{[format_entry instanceof ModelFormat ? 'format' : 'loader']: true, selected: format_entry.id == selected_format_id}"
2022-05-19 05:44:00 +08:00
: title = "format_entry.description"
2022-05-24 02:46:49 +08:00
: format = "format_entry.id"
2022-05-19 05:44:00 +08:00
v - if = "format_entry.show_on_start_screen && (!redact_names || !format_entry.confidential)"
@ click = "loadFormat(format_entry)"
@ dblclick = "confirmSetupScreen(format_entry)"
>
< span class = "icon_wrapper f_left" v - html = "getIconNode(format_entry.icon).outerHTML" > < / s p a n >
< label > { { format _entry . name } } < / l a b e l >
< / l i >
< / u l >
2021-11-14 06:19:23 +08:00
< / l i >
2022-06-05 23:33:03 +08:00
< li class = "format_category" >
< label > $ { tl ( 'mode.start.info' ) } < / l a b e l >
< ul >
< li class = "format_entry start_screen_link" @ click = "openLink('https://blockbench.net/quickstart')" >
< span class = "icon_wrapper f_left" > < i class = "material-icons" > help < / i > < / s p a n >
< label > $ { tl ( 'menu.help.quickstart' ) } < / l a b e l >
< / l i >
< li class = "format_entry start_screen_link" @ click = "openLink('https://blockbench.net/wiki')" >
< span class = "icon_wrapper f_left" > < i class = "material-icons" > menu _book < / i > < / s p a n >
< label > Blockbench Wiki < / l a b e l >
< / l i >
< / u l >
2021-11-14 06:19:23 +08:00
< / l i >
< / u l >
< / d i v >
2022-05-19 05:44:00 +08:00
2022-05-24 02:46:49 +08:00
< div class = "start_screen_right start_screen_format_page" v - if = "viewed_format = (selected_format_id && (formats[selected_format_id] || loaders[selected_format_id]) )" : id = "'format_page_'+selected_format_id" >
2022-07-01 14:47:05 +08:00
< div class = "tool format_page_close_button" @ click = "selected_format_id = ''" > < i class = "material-icons" > clear < / i > < / d i v >
2022-05-19 05:44:00 +08:00
< h2 style = "margin-bottom: 12px;" > { { viewed _format . name } } < / h 2 >
2022-05-24 02:46:49 +08:00
< template v - if = "viewed_format.format_page && viewed_format.format_page.component" >
< component : is = "'format_page_' + selected_format_id" / >
< / t e m p l a t e >
2022-05-19 05:44:00 +08:00
2022-05-24 02:46:49 +08:00
< template v - else >
< p class = "format_description" v - if = "viewed_format.description" > { { viewed _format . description } } < / p >
< p class = "format_target" v - if = "viewed_format.target" >
< b > $ { tl ( 'mode.start.target' ) } < / b > :
< template v - if = "viewed_format.target instanceof Array" >
< span v - for = "target in viewed_format.target" > { { target } } < / s p a n >
< / t e m p l a t e >
< span v - else > { { viewed _format . target } } < / s p a n >
< / p >
2022-05-19 05:44:00 +08:00
2022-05-24 02:46:49 +08:00
< content v - if = "viewed_format.format_page && viewed_format.format_page.content" >
< template v - for = "item in viewed_format.format_page.content" >
< img v - if = "item.type == 'image'" : src = "item.source" : width = "item.width" : height = "item.height" >
2022-07-01 14:47:05 +08:00
< h2 v - else - if = "item.type == 'h2'" class = "markdown" v - html = "marked(item.text.replace(/\\n/g, '\\n\\n'))" > < / h 2 >
< h3 v - else - if = "item.type == 'h3'" class = "markdown" v - html = "marked(item.text.replace(/\\n/g, '\\n\\n'))" > < / h 3 >
< h4 v - else - if = "item.type == 'h4'" class = "markdown" v - html = "marked(item.text.replace(/\\n/g, '\\n\\n'))" > < / h 4 >
< label v - else - if = "item.type == 'label'" class = "markdown" v - html = "marked(item.text.replace(/\\n/g, '\\n\\n'))" > < / l a b e l >
< p v - else class = "markdown" v - html = "marked((item.text || item).replace(/\\n/g, '\\n\\n'))" > < / p >
2022-05-24 02:46:49 +08:00
< / t e m p l a t e >
< / c o n t e n t >
2022-07-01 14:47:05 +08:00
< div class = "button_bar" v - if = "!viewed_format.format_page || viewed_format.format_page.button_text !== ''" >
< button style = "margin-top: 20px;" id = "create_new_model_button" @ click = "confirmSetupScreen(viewed_format)" >
< i class = "material-icons" > arrow _forward < / i >
{ { viewed _format . format _page && viewed _format . format _page . button _text ? tl ( viewed _format . format _page . button _text ) : '${tl(' mode . start . create _new ')}' } }
< / b u t t o n >
2022-05-24 02:46:49 +08:00
< / d i v >
< / t e m p l a t e >
2022-05-19 05:44:00 +08:00
< / d i v >
< div class = "start_screen_right" v - else >
2021-11-14 06:19:23 +08:00
< h2 class = "tl" > $ { tl ( 'mode.start.recent' ) } < / h 2 >
< div id = "start_screen_view_menu" v - if = "isApp && !redact_names" >
< search - bar : hide = "true" v - model = "search_term" > < / s e a r c h - b a r >
< li class = "tool" v - bind : class = "{selected: list_type == 'grid'}" v - on : click = "setListType('grid')" >
< i class = "material-icons" > view _module < / i >
< / l i >
< li class = "tool" v - bind : class = "{selected: list_type == 'list'}" v - on : click = "setListType('list')" >
< i class = "material-icons" > list < / i >
< / l i >
< / d i v >
< div v - if = "redact_names" > { { '[' + tl ( 'generic.redacted' ) + ']' } } < / d i v >
< ul v - else - if = "list_type == 'list'" >
2022-07-02 02:38:21 +08:00
< li v - for = "project in projects" : key = "project.path"
v - bind : title = "redact_names ? '' : project.path"
class = "recent_project"
@ click = "openProject(project, $event)"
@ contextmenu = "recentProjectContextMenu(project, $event)"
>
< div class = "recent_favorite_button" : class = "{favorite_enabled: project.favorite}" @ click . stop = "toggleProjectFavorite(project)" title = "${tl('mode.start.recent.favorite')}" >
< i : class = "'fa_big icon fa-star ' + (project.favorite ? 'fas' : 'far')" >
< / d i v >
2021-11-14 06:19:23 +08:00
< span class = "icon_wrapper" v - html = "getIconNode(project.icon).outerHTML" > < / s p a n >
< span class = "recent_project_name" > { { redact _names ? redacted : project . name } } < / s p a n >
< span class = "recent_project_date" > { { getDate ( project ) } } < / s p a n >
< / l i >
< div v - if = "recent.length == 0" > { { tl ( 'mode.start.no_recents' ) } } < / d i v >
< / u l >
2022-07-02 02:38:21 +08:00
< ul : class = "{redact: redact_names, recent_list_grid: true}" v - else >
< li v - for = "project in projects" : key = "project.path"
v - bind : title = "redact_names ? '' : project.path"
class = "recent_project thumbnail"
@ click = "openProject(project, $event)"
@ contextmenu = "recentProjectContextMenu(project, $event)"
>
2021-11-15 06:47:56 +08:00
< img class = "thumbnail_image" v - if = "getThumbnail(project.path)" : src = "getThumbnail(project.path)" / >
< span class = "recent_project_name" > { { redact _names ? redacted : project . name } } < / s p a n >
< span class = "icon_wrapper" v - html = "getIconNode(project.icon).outerHTML" > < / s p a n >
2022-07-02 02:38:21 +08:00
< div class = "recent_favorite_button" : class = "{favorite_enabled: project.favorite}" @ click . stop = "toggleProjectFavorite(project)" title = "${tl('mode.start.recent.favorite')}" >
< i : class = "'fa_big icon fa-star ' + (project.favorite ? 'fas' : 'far')" >
< / d i v >
2021-11-15 06:47:56 +08:00
< / l i >
2021-11-14 06:19:23 +08:00
< / u l >
2022-05-19 05:44:00 +08:00
< div class = "button_bar" >
< button style = "margin-top: 20px;" onclick = "BarItems.open_model.trigger()" > $ { tl ( 'action.open_model' ) } < / b u t t o n >
< / d i v >
2021-11-14 06:19:23 +08:00
< / d i v >
2022-05-19 05:44:00 +08:00
2021-11-14 06:19:23 +08:00
< / s e c t i o n >
< / c o n t e n t >
< / d i v >
`
} )
} ) ;
2022-05-24 02:46:49 +08:00
class ModelLoader {
constructor ( id , options ) {
this . id = id ;
this . name = tl ( options . name ) ;
this . description = options . description ? tl ( options . description ) : '' ;
this . icon = options . icon || 'arrow_forward' ;
this . category = options . category || 'loaders' ;
this . target = options . target || '' ;
this . show _on _start _screen = true ;
this . confidential = options . confidential || false ;
this . condition = options . condition ;
this . format _page = options . format _page ;
2022-06-16 00:54:38 +08:00
this . onFormatPage = options . onFormatPage ;
2022-05-24 02:46:49 +08:00
this . onStart = options . onStart ;
Vue . set ( ModelLoader . loaders , id , this ) ;
if ( this . format _page && this . format _page . component ) {
Vue . component ( ` format_page_ ${ this . id } ` , this . format _page . component )
}
}
2022-07-08 01:44:40 +08:00
new ( ) {
this . onStart ( ) ;
}
2022-05-24 02:46:49 +08:00
delete ( ) {
delete ModelLoader . loaders [ this . id ] ;
}
}
ModelLoader . loaders = { } ;
2021-11-14 06:19:23 +08:00
( function ( ) {
/ * $ . g e t J S O N ( ' . / c o n t e n t / n e w s . j s o n ' ) . t h e n ( d a t a = > {
addStartScreenSection ( 'new_version' , data . new _version )
} ) * /
2022-01-08 21:22:22 +08:00
var news _call = $ . ajax ( {
cache : false ,
url : 'https://web.blockbench.net/content/news.json' ,
dataType : 'json'
} ) ;
2021-11-14 06:19:23 +08:00
documentReady . then ( ( ) => {
Blockbench . startup _count = parseInt ( localStorage . getItem ( 'startups' ) || 0 )
//Backup Model
2022-05-30 04:29:19 +08:00
if ( localStorage . getItem ( 'backup_model' ) && ( ! isApp || ! currentwindow . webContents . second _instance ) && localStorage . getItem ( 'backup_model' ) . length > 40 ) {
var backup _models = localStorage . getItem ( 'backup_model' )
2021-11-14 06:19:23 +08:00
2022-05-30 04:29:19 +08:00
let section = addStartScreenSection ( {
2021-11-14 06:19:23 +08:00
color : 'var(--color-back)' ,
graphic : { type : 'icon' , icon : 'fa-archive' } ,
text : [
{ type : 'h2' , text : tl ( 'message.recover_backup.title' ) } ,
{ text : tl ( 'message.recover_backup.message' ) } ,
2022-05-30 04:29:19 +08:00
{ type : 'button' , text : tl ( 'message.recover_backup.recover' ) , click : ( e ) => {
2022-07-03 18:57:44 +08:00
let parsed _backup _models = JSON . parse ( backup _models ) ;
for ( let uuid in parsed _backup _models ) {
Codecs . project . load ( parsed _backup _models [ uuid ] , { path : 'backup.bbmodel' , no _file : true } )
2022-05-30 04:29:19 +08:00
}
section . delete ( ) ;
} } ,
{ type : 'button' , text : tl ( 'dialog.discard' ) , click : ( e ) => {
localStorage . removeItem ( 'backup_model' ) ;
section . delete ( ) ;
2021-11-14 06:19:23 +08:00
} }
]
} )
}
if ( settings . streamer _mode . value ) {
updateStreamerModeNotification ( )
}
2022-03-28 19:04:23 +08:00
addStartScreenSection ( 'splash_screen' , {
"text_color" : '#000000' ,
"graphic" : {
"type" : "image" ,
2022-07-22 05:51:14 +08:00
"source" : "./assets/splash_art.png?43" ,
2022-03-28 19:04:23 +08:00
"width" : 1000 ,
"aspect_ratio" : "21/9" ,
2022-07-22 05:51:14 +08:00
"description" : "Splash Art by [MisterGriimm](https://twitter.com/MisterGriimm) and [MidnitePixel_](https://twitter.com/MidnitePixel_)" ,
2022-03-28 19:04:23 +08:00
"text_color" : '#cfcfcf'
}
} )
if ( ! Blockbench . hasFlag ( 'after_update' ) ) {
document . getElementById ( 'start_screen' ) . scrollTop = 100 ;
}
2021-11-14 06:19:23 +08:00
//Twitter
let twitter _ad ;
if ( Blockbench . startup _count < 20 && Blockbench . startup _count % 5 === 4 ) {
twitter _ad = true ;
addStartScreenSection ( {
color : '#1da1f2' ,
text _color : '#ffffff' ,
graphic : { type : 'icon' , icon : 'fab.fa-twitter' } ,
text : [
{ type : 'h2' , text : 'Blockbench on Twitter' } ,
{ text : 'Follow Blockbench on Twitter for the latest news as well as cool models from the community! [twitter.com/blockbench](https://twitter.com/blockbench/)' }
] ,
last : true
} )
}
//Discord
if ( Blockbench . startup _count < 6 && ! twitter _ad ) {
addStartScreenSection ( {
color : '#5865F2' ,
text _color : '#ffffff' ,
graphic : { type : 'icon' , icon : 'fab.fa-discord' } ,
text : [
{ type : 'h2' , text : 'Discord Server' } ,
{ text : 'You need help with modeling or you want to chat about Blockbench? Join the official [Blockbench Discord](https://discord.gg/WVHg5kH)!' }
] ,
last : true
} )
}
2022-03-06 05:59:54 +08:00
// Quick Setup
2022-03-06 19:22:59 +08:00
if ( Blockbench . startup _count <= 1 ) {
2021-11-14 06:19:23 +08:00
2022-03-06 05:59:54 +08:00
let section = Interface . createElement ( 'section' , { id : 'quick_setup' } ) ;
2022-07-19 04:42:28 +08:00
$ ( '#start_screen > content' ) . prepend ( section ) ;
2021-11-14 06:19:23 +08:00
2022-03-06 05:59:54 +08:00
new Vue ( {
data ( ) { return {
language : Language . code ,
language _original : Language . code ,
languages : Language . options ,
keymap : 'default' ,
keymap _changed : false ,
theme : 'dark' ,
2022-05-15 02:37:35 +08:00
keymap _options : {
default : tl ( 'action.load_keymap.default' ) ,
mouse : tl ( 'action.load_keymap.mouse' ) ,
blender : 'Blender' ,
cinema4d : 'Cinema 4D' ,
maya : 'Maya' ,
} ,
2022-03-06 05:59:54 +08:00
} } ,
methods : {
tl ,
close ( ) {
obj . remove ( ) ;
} ,
reload ( ) {
Blockbench . reload ( ) ;
} ,
loadTheme ( theme _id ) {
this . theme = theme _id ;
let theme = CustomTheme . themes . find ( t => t . id == theme _id ) ;
if ( theme ) CustomTheme . loadTheme ( theme ) ;
} ,
getThemeThumbnailStyle ( theme _id ) {
let theme = CustomTheme . themes . find ( t => t . id == theme _id ) ;
let style = { } ;
if ( ! theme ) return style ;
for ( let key in theme . colors ) {
style [ ` --color- ${ key } ` ] = theme . colors [ key ] ;
}
return style ;
} ,
openThemes ( ) {
BarItems . theme _window . click ( ) ;
}
} ,
watch : {
language ( v ) {
settings . language . set ( v ) ;
Settings . save ( ) ;
} ,
keymap ( keymap , old _keymap ) {
this . keymap _changed = true ;
let success = Keybinds . loadKeymap ( keymap , true ) ;
if ( ! success ) this . keymap = old _keymap ;
}
} ,
template : `
< section id = "quick_setup" >
< i class = "material-icons start_screen_close_button" @ click = "close()" > clear < / i >
< h2 > $ { tl ( 'mode.start.quick_setup' ) } < / h 2 >
2021-11-14 06:19:23 +08:00
2022-03-06 05:59:54 +08:00
< div >
< label > $ { tl ( 'mode.start.keymap' ) } : < / l a b e l >
2022-05-15 02:37:35 +08:00
< select - input v - model = "keymap" : options = "keymap_options" / >
2022-03-06 05:59:54 +08:00
< p v - if = "keymap_changed" > { { tl ( 'action.load_keymap.' + keymap + '.desc' ) } } < / p >
< / d i v >
< div >
< label > $ { tl ( 'settings.language' ) } : < / l a b e l >
2022-05-15 02:37:35 +08:00
< select - input v - model = "language" : options = "languages" / >
2022-03-06 05:59:54 +08:00
< div class = "tool" @ click = "reload()" v - if = "language != language_original" : title = "tl('action.reload')" >
< i class = "material-icons" > refresh < / i >
< / d i v >
< p v - if = "language != language_original" > { { tl ( 'message.restart_to_update' ) } } < / p >
< / d i v >
< div style = "width: 640px;" >
< label > $ { tl ( 'dialog.settings.theme' ) } : < / l a b e l >
< div class = "quick_setup_theme" : class = "{selected: theme == 'dark'}" @ click = "loadTheme('dark')" > < div : style = "getThemeThumbnailStyle('dark')" > < / d i v > D a r k < / d i v >
< div class = "quick_setup_theme" : class = "{selected: theme == 'light'}" @ click = "loadTheme('light')" > < div : style = "getThemeThumbnailStyle('light')" > < / d i v > L i g h t < / d i v >
< div class = "quick_setup_theme" : class = "{selected: theme == 'contrast'}" @ click = "loadTheme('contrast')" > < div : style = "getThemeThumbnailStyle('contrast')" > < / d i v > C o n t r a s t < / d i v >
< div class = "quick_setup_theme more_themes" @ click = "openThemes()" > < div > < i class = "material-icons" > more _horiz < / i > < / d i v > { { t l ( ' m o d e . s t a r t . q u i c k _ s e t u p . m o r e _ t h e m e s ' ) } } < / d i v >
< / d i v >
< / s e c t i o n >
`
} ) . $mount ( section ) ;
2021-11-14 06:19:23 +08:00
}
} )
2022-03-28 19:04:23 +08:00
Promise . all ( [ news _call , documentReady ] ) . then ( ( data ) => {
if ( ! data || ! data [ 0 ] ) return ;
data = data [ 0 ] ;
//Update Screen
if ( Blockbench . hasFlag ( 'after_update' ) && data . new _version ) {
data . new _version . insert _after = 'splash_screen'
addStartScreenSection ( 'new_version' , data . new _version ) ;
jQuery . ajax ( {
url : 'https://blckbn.ch/api/event/successful_update' ,
type : 'POST' ,
data : {
version : Blockbench . version
}
} )
}
if ( data . psa ) {
( function ( ) {
if ( typeof data . psa . version == 'string' ) {
if ( data . psa . version . includes ( '-' ) ) {
limits = data . psa . version . split ( '-' ) ;
if ( limits [ 0 ] && compareVersions ( limits [ 0 ] , Blockbench . version ) ) return ;
if ( limits [ 1 ] && compareVersions ( Blockbench . version , limits [ 1 ] ) ) return ;
} else {
if ( data . psa . version != Blockbench . version ) return ;
}
}
addStartScreenSection ( data . psa )
} ) ( )
}
} )
2021-11-14 06:19:23 +08:00
} ) ( )