Skip to content

Commit

Permalink
fix: intro loading bar functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ominousg committed Feb 25, 2024
1 parent 585f553 commit ef8c19b
Show file tree
Hide file tree
Showing 17 changed files with 3,076 additions and 12,511 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
- 30/12/2023: Boton para activar pantalla completa usando requestFullscreen. Eliminando libreria screenfull.js [(6346180)](https://github.com/ominousg/ao-web-client/commit/634618075aff3497fc65da31dc7fe57007a9b728)
- 30/12/2023: Fix bug: los textos largos de consola no tenían saltos de linea [(75623e5)](https://github.com/ominousg/ao-web-client/commit/75623e5913be191ebcc095a4ebf8f3b3c3c4505f)
- 30/12/2023: Fix bug: al pedir información del hechizo y clickear otras cosas, los textos de consola se renderizaban uno arriba del otro. [(99b318e)](https://github.com/ominousg/ao-web-client/commit/99b318eaaa6069476c2188563838240cdfec866c)
- 01/01/2024: Agregando nuevo popup para ver los últimos 200 mensajes de consola. Bloqueando click derecho en el canvas del juego e interfaz. Nueva animación: tiembla la pantalla cuando bloqueás un golpe con el escudo. [(placeholder)](https://github.com/ominousg/ao-web-client/commit/placeholder)
- 01/01/2024: Agregando nuevo popup para ver los últimos 200 mensajes de consola. Bloqueando click derecho en el canvas del juego e interfaz. Nueva animación: tiembla la pantalla cuando bloqueás un golpe con el escudo. [(0f5a004)](https://github.com/ominousg/ao-web-client/commit/0f5a00412f22b1610851255813c697bb2d3d6529)
- 24/02/2024: Migración de PixiJS [v6.4.2](https://github.com/pixijs/pixijs/releases/tag/v6.4.2) a [v7.4.0](https://github.com/pixijs/pixijs/releases/tag/v7.4.0). [(placeholder)](https://github.com/ominousg/ao-web-client/commit/placeholder)
78 changes: 38 additions & 40 deletions client/js/assets/preloader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 3/22/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/

import { Assets } from 'pixi.js';
Expand All @@ -27,60 +28,57 @@ class Preloader {
// }
// });

// bitmap fonts
Assets.add({ alias: 'Roboto Mono', src: 'fonts/bitmaps/Roboto Mono.fnt' });
Assets.add({ alias: 'Ubuntu Mono', src: 'fonts/bitmaps/Ubuntu Mono.fnt' });
const allAssets = [
{ alias: 'Roboto Mono', src: 'fonts/bitmaps/Roboto Mono.fnt' },
{ alias: 'Ubuntu Mono', src: 'fonts/bitmaps/Ubuntu Mono.fnt' },
{ alias: 'indices', src: 'indices/graficos.json' },
{ alias: 'armas', src: 'indices/armas.json' },
{ alias: 'cuerpos', src: 'indices/cuerpos.json' },
{ alias: 'escudos', src: 'indices/escudos.json' },
{ alias: 'cabezas', src: 'indices/cabezas.json' },
{ alias: 'fxs', src: 'indices/fxs.json' },
...PreloadMapas.map((mapa) => ({ alias: mapa, src: `mapas/mapa${mapa}.json` })),
...PreloadGraficos.map((grafico) => ({ alias: grafico, src: `graficos/${grafico}.png` }))
];

// indices
Assets.add({ alias: 'indices', src: 'indices/graficos.json' });
Assets.add({ alias: 'armas', src: 'indices/armas.json' });
Assets.add({ alias: 'cuerpos', src: 'indices/cuerpos.json' });
Assets.add({ alias: 'escudos', src: 'indices/escudos.json' });
Assets.add({ alias: 'cabezas', src: 'indices/cabezas.json' });
Assets.add({ alias: 'fxs', src: 'indices/fxs.json' });
const totalAssets = allAssets.length;
let loadedAssets = 0;

for (let mapa of PreloadMapas) {
Assets.add({ alias: mapa, src: 'mapas/mapa' + mapa + '.json' });
}
allAssets.forEach((asset) => Assets.add(asset));

for (let grafico of PreloadGraficos) {
Assets.add({ alias: grafico, src: 'graficos/' + grafico + '.png' });
}
// trackeando progreso para la loadingBar
const updateProgress = () => {
loadedAssets++;
const progress = (loadedAssets / totalAssets) * 100;
progress_callback(progress);

try {
for (let key of [
...PreloadMapas,
...PreloadGraficos,
'indices',
'armas',
'cuerpos',
'escudos',
'cabezas',
'fxs',
'Roboto Mono',
'Ubuntu Mono'
]) {
await Assets.load(key, (progress) => progress_callback(progress));
if (loadedAssets === totalAssets) onAllAssetsLoaded();
};

if (PreloadGraficos.includes(key)) {
const loadedTexture = Assets.get(key);
if (loadedTexture) {
this.assetManager._setBaseTexture(key, loadedTexture);
} else {
console.error('No se pudo cargar el asset:', key);
}
const onAllAssetsLoaded = () => {
PreloadGraficos.forEach((key) => {
const loadedTexture = Assets.get(key);
if (loadedTexture) {
this.assetManager._setBaseTexture(key, loadedTexture);
} else {
console.error('No se pudo cargar el asset:', key);
}
}
});

const indicesData = Assets.get('indices');

if (indicesData && indicesData.length > 1) {
this.assetManager.indices = indicesData;
} else {
console.error('La data de los indices no se pudo cargar o tiene formato incorrecto.');
}

terminar_callback();
};

try {
for (let asset of allAssets) {
await Assets.load(asset.alias).then(updateProgress);
}
} catch (error) {
console.error('Error cargando assets:', error);
}
Expand Down
3 changes: 2 additions & 1 deletion client/js/model/charactermovement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 8/22/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Enums } from '../enums';
import Transition from '../transition';
Expand Down
3 changes: 2 additions & 1 deletion client/js/model/macros.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 5/3/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Enums } from '../enums';
import Font from '../font';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/charactername.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 07/06/2016.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Enums } from '../enums';
import { Text } from 'pixi.js';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/charactersprites.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 3/2/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Enums } from '../enums';
import { Container } from 'pixi.js';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/charactertext.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 3/9/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import Font from '../font';
import { Container, Text } from 'pixi.js';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/climarenderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 8/20/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Enums } from '../enums';
import { ParticleContainer } from 'pixi.js';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/consola.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 3/8/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import Font from '../font';
import { Container, Text } from 'pixi.js';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/containerordenado.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 3/14/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Container } from 'pixi.js';

Expand Down
3 changes: 2 additions & 1 deletion client/js/view/entityrenderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 8/20/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/

import { Enums } from '../enums';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/gametextstyle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 8/30/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/

import { TextStyle } from 'pixi.js';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/indicadormapa.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 13/08/2016.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { BitmapText } from 'pixi.js';

Expand Down
3 changes: 2 additions & 1 deletion client/js/view/maparenderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 8/21/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { Enums } from '../enums';
import Utils from '../utils/util';
Expand Down
3 changes: 2 additions & 1 deletion client/js/view/spritegrh.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Created by horacio on 3/10/16.
* Migration from PixiJS v4.0.3 to v6.4.2 by ominousf on 03/25/2023
* PixiJS migrations by ominousf: v4.0.3 to v6.4.2 on 03/25/2023
* v6.4.2 to 7.4.0 on 24/02/2024
*/
import { AnimatedSprite, Texture, RenderTexture } from 'pixi.js';

Expand Down
Loading

0 comments on commit ef8c19b

Please sign in to comment.