File tree Expand file tree Collapse file tree 8 files changed +66
-9
lines changed Expand file tree Collapse file tree 8 files changed +66
-9
lines changed Original file line number Diff line number Diff line change 4
4
</script >
5
5
6
6
<script lang =" ts" >
7
+ import { translate } from ' ../util/translation'
8
+
7
9
export let loaded: Valuable <boolean >
10
+ export let offline: Valuable <boolean >
8
11
</script >
9
12
10
- <div class =" floating" >
11
- {#if $loaded }
12
- <div >Animated Java Loaded Successfully!</div >
13
+ <div class ={` floating ${$offline ? ' red-border' : ' blue-border' } ` }>
14
+ {#if $offline }
15
+ <div style =" display: flex; flex-direction: column;" >
16
+ {@html translate (' popup.loading.offline' )
17
+ .split (' \n ' )
18
+ .map (v => ' <p>' + v + ' </p>' )
19
+ .join (' ' )}
20
+ </div >
21
+ {:else if $loaded }
22
+ <div >{translate (' popup.loading.success' )}</div >
13
23
{:else }
14
- <div class =" text" >Loading Animated Java... </div >
24
+ <div class ="text" >{ translate ( ' popup.loading.loading ' )} </div >
15
25
<img src ={RunningArmorStand } alt =" Running Armor Stand" />
16
26
{/if }
17
27
</div >
23
33
right : 2rem ;
24
34
background : var (--color-ui );
25
35
padding : 8px 16px ;
26
- border : 1px solid var (--color-accent );
27
36
display : flex ;
28
37
align-items : center ;
29
38
flex-direction : row ;
30
39
}
40
+ .blue-border {
41
+ border : 1px solid var (--color-accent );
42
+ }
43
+ .red-border {
44
+ border : 1px solid var (--color-error );
45
+ }
31
46
.text {
32
47
margin-right : 16px ;
33
48
}
Original file line number Diff line number Diff line change @@ -69,7 +69,11 @@ import { openUnexpectedErrorDialog } from './interface/unexpectedErrorDialog'
69
69
import { BLUEPRINT_CODEC , BLUEPRINT_FORMAT } from './blueprintFormat'
70
70
import { TextDisplay } from './outliner/textDisplay'
71
71
import { getLatestVersionClientDownloadUrl } from './systems/minecraft/assetManager'
72
- import { hideLoadingPopup , showLoadingPopup } from './interface/animatedJavaLoadingPopup'
72
+ import {
73
+ hideLoadingPopup ,
74
+ showLoadingPopup ,
75
+ showOfflineError ,
76
+ } from './interface/animatedJavaLoadingPopup'
73
77
import { getVanillaFont } from './systems/minecraft/fontManager'
74
78
import * as assetManager from './systems/minecraft/assetManager'
75
79
import * as itemModelManager from './systems/minecraft/itemModelManager'
@@ -81,6 +85,12 @@ import { exportProject } from './systems/exporter'
81
85
82
86
// Show loading popup
83
87
void showLoadingPopup ( ) . then ( async ( ) => {
88
+ if ( ! window . navigator . onLine ) {
89
+ showOfflineError ( )
90
+ // return
91
+ }
92
+ events . NETWORK_CONNECTED . dispatch ( )
93
+
84
94
await Promise . all ( [
85
95
new Promise < void > ( resolve => events . MINECRAFT_ASSETS_LOADED . subscribe ( ( ) => resolve ( ) ) ) ,
86
96
new Promise < void > ( resolve => events . MINECRAFT_REGISTRY_LOADED . subscribe ( ( ) => resolve ( ) ) ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { injectSvelteCompomponent } from '../util/injectSvelte'
4
4
import { Valuable } from '../util/stores'
5
5
6
6
const LOADED = new Valuable ( false )
7
+ const OFFLINE = new Valuable ( false )
7
8
let activeComponent : SvelteComponent | undefined
8
9
9
10
export async function showLoadingPopup ( ) {
@@ -12,6 +13,7 @@ export async function showLoadingPopup() {
12
13
svelteComponent : AnimatedJavaLoadingPopup ,
13
14
svelteComponentProperties : {
14
15
loaded : LOADED ,
16
+ offline : OFFLINE ,
15
17
} ,
16
18
elementSelector ( ) {
17
19
return document . body
@@ -28,3 +30,14 @@ export function hideLoadingPopup() {
28
30
activeComponent = undefined
29
31
} , 2000 )
30
32
}
33
+
34
+ export function showOfflineError ( ) {
35
+ if ( ! activeComponent ) return
36
+ OFFLINE . set ( true )
37
+ // FIXME - Change this into a X button instead of a timeout.
38
+ setTimeout ( ( ) => {
39
+ if ( ! activeComponent ) return
40
+ activeComponent . $destroy ( )
41
+ activeComponent = undefined
42
+ } , 10000 )
43
+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ animated_java.action.create_vanilla_block_display.title: Add Vanilla Block Displ
12
12
animated_java.action.open_vanilla_item_display_config.name : Vanilla Item Display Config
13
13
animated_java.action.open_vanilla_block_display_config.name : Vanilla Block Display Config
14
14
15
+ # ## Popups
16
+ animated_java.popup.loading.loading : Loading Animated Java...
17
+ animated_java.popup.loading.success : Animated Java Loaded Successfully!
18
+ animated_java.popup.loading.offline : |-
19
+ Animated Java Failed to Connect!
20
+ Some features may be unavailable.
21
+
15
22
# ## Dialogs
16
23
17
24
# # About
Original file line number Diff line number Diff line change @@ -103,5 +103,7 @@ export async function getBlockState(block: string) {
103
103
}
104
104
105
105
events . LOAD . subscribe ( ( ) => {
106
- void checkForRegistryUpdate ( )
106
+ void checkForRegistryUpdate ( ) . catch ( err => {
107
+ console . error ( err )
108
+ } )
107
109
} )
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ export async function checkForRegistryUpdate() {
178
178
requestAnimationFrame ( ( ) => events . MINECRAFT_REGISTRY_LOADED . dispatch ( ) )
179
179
}
180
180
181
- events . LOAD . subscribe ( ( ) => {
181
+ events . NETWORK_CONNECTED . subscribe ( ( ) => {
182
182
void checkForRegistryUpdate ( ) . then ( async ( ) => {
183
183
await checkForAssetsUpdate ( )
184
184
} )
Original file line number Diff line number Diff line change 1
- const VERSION_MANIFEST_URL = 'https://launchermeta.mojang.com/mc/game/version_manifest_v2.json'
1
+ export const VERSION_MANIFEST_URL =
2
+ 'https://launchermeta.mojang.com/mc/game/version_manifest_v2.json'
2
3
3
4
interface IMinecraftVersion {
4
5
id : string
@@ -21,6 +22,13 @@ export interface IMinecraftVersionManifest {
21
22
let latestMinecraftVersion : IMinecraftVersion | undefined
22
23
export async function getLatestVersion ( ) {
23
24
if ( latestMinecraftVersion ) return latestMinecraftVersion
25
+ if ( ! window . navigator . onLine ) {
26
+ console . warn ( 'Not connected to the internet! Using last known latest version.' )
27
+ latestMinecraftVersion = getCurrentVersion ( )
28
+ if ( ! latestMinecraftVersion )
29
+ throw new Error ( 'No internet connection, and no previous latest version cached!' )
30
+ return latestMinecraftVersion
31
+ }
24
32
let response : Response | undefined
25
33
try {
26
34
response = await fetch ( VERSION_MANIFEST_URL )
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ export const events = {
20
20
INJECT_MODS : new PluginEvent ( 'injectMods' ) ,
21
21
EXTRACT_MODS : new PluginEvent ( 'extractMods' ) ,
22
22
23
+ NETWORK_CONNECTED : new PluginEvent ( 'networkConnected' ) ,
24
+
23
25
MINECRAFT_ASSETS_LOADED : new PluginEvent ( 'minecraftAssetsLoaded' ) ,
24
26
MINECRAFT_REGISTRY_LOADED : new PluginEvent ( 'minecraftRegistriesLoaded' ) ,
25
27
MINECRAFT_FONTS_LOADED : new PluginEvent ( 'minecraftFontsLoaded' ) ,
You can’t perform that action at this time.
0 commit comments