FEATURE: improved the display of player names, with the font-family 'Press start 2P' and gray outlines
This commit is contained in:
parent
474323b95f
commit
12da6ddd6c
@ -12,6 +12,11 @@
|
|||||||
- The emote menu can be opened by clicking on your character.
|
- The emote menu can be opened by clicking on your character.
|
||||||
- Clicking on one of its element will close the menu and play an emote above your character.
|
- Clicking on one of its element will close the menu and play an emote above your character.
|
||||||
- This emote can be seen by other players.
|
- This emote can be seen by other players.
|
||||||
|
- Player names were improved. (@Kharhamel)
|
||||||
|
- We now create a GameObject.Text instead of GameObject.BitmapText
|
||||||
|
- now use the 'Press Start 2P' font family and added an outline
|
||||||
|
- As a result, we can now allow non-standard letters like french accents or chinese characters!
|
||||||
|
|
||||||
- Mobile support has been improved
|
- Mobile support has been improved
|
||||||
- WorkAdventure automatically sets the zoom level based on the viewport size to ensure a sensible size of the map is visible, whatever the viewport used
|
- WorkAdventure automatically sets the zoom level based on the viewport size to ensure a sensible size of the map is visible, whatever the viewport used
|
||||||
- Mouse wheel support to zoom in / out
|
- Mouse wheel support to zoom in / out
|
||||||
|
1
front/dist/index.tmpl.html
vendored
1
front/dist/index.tmpl.html
vendored
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet">
|
|
||||||
<link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" />
|
<link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" />
|
||||||
|
|
||||||
<title>WorkAdventure</title>
|
<title>WorkAdventure</title>
|
||||||
|
5
front/dist/resources/fonts/fonts.css
vendored
Normal file
5
front/dist/resources/fonts/fonts.css
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/*This file is a workaround to allow phaser to load directly this font */
|
||||||
|
@font-face {
|
||||||
|
font-family: "Press Start 2P";
|
||||||
|
src: url("/fonts/press-start-2p-latin-400-normal.woff2") format('woff2');
|
||||||
|
}
|
@ -34,6 +34,7 @@
|
|||||||
"webpack-dev-server": "^3.11.2"
|
"webpack-dev-server": "^3.11.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fontsource/press-start-2p": "^4.3.0",
|
||||||
"@types/simple-peer": "^9.6.0",
|
"@types/simple-peer": "^9.6.0",
|
||||||
"@types/socket.io-client": "^1.4.32",
|
"@types/socket.io-client": "^1.4.32",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
@ -9,9 +9,8 @@ export interface CharacterTexture {
|
|||||||
|
|
||||||
export const maxUserNameLength: number = MAX_USERNAME_LENGTH;
|
export const maxUserNameLength: number = MAX_USERNAME_LENGTH;
|
||||||
|
|
||||||
export function isUserNameValid(value: string): boolean {
|
export function isUserNameValid(value: unknown): boolean {
|
||||||
const regexp = new RegExp('^[A-Za-z0-9]{1,'+maxUserNameLength+'}$');
|
return typeof value === "string" && value.length > 0 && value.length < maxUserNameLength && value.indexOf(' ') === -1;
|
||||||
return regexp.test(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function areCharacterLayersValid(value: string[] | null): boolean {
|
export function areCharacterLayersValid(value: string[] | null): boolean {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {PlayerAnimationDirections, PlayerAnimationTypes} from "../Player/Animation";
|
import {PlayerAnimationDirections, PlayerAnimationTypes} from "../Player/Animation";
|
||||||
import {SpeechBubble} from "./SpeechBubble";
|
import {SpeechBubble} from "./SpeechBubble";
|
||||||
import BitmapText = Phaser.GameObjects.BitmapText;
|
import Text = Phaser.GameObjects.Text;
|
||||||
import Container = Phaser.GameObjects.Container;
|
import Container = Phaser.GameObjects.Container;
|
||||||
import Sprite = Phaser.GameObjects.Sprite;
|
import Sprite = Phaser.GameObjects.Sprite;
|
||||||
import {TextureError} from "../../Exception/TextureError";
|
import {TextureError} from "../../Exception/TextureError";
|
||||||
@ -23,7 +23,7 @@ const interactiveRadius = 35;
|
|||||||
|
|
||||||
export abstract class Character extends Container {
|
export abstract class Character extends Container {
|
||||||
private bubble: SpeechBubble|null = null;
|
private bubble: SpeechBubble|null = null;
|
||||||
private readonly playerName: BitmapText;
|
private readonly playerName: Text;
|
||||||
public PlayerValue: string;
|
public PlayerValue: string;
|
||||||
public sprites: Map<string, Sprite>;
|
public sprites: Map<string, Sprite>;
|
||||||
private lastDirection: PlayerAnimationDirections = PlayerAnimationDirections.Down;
|
private lastDirection: PlayerAnimationDirections = PlayerAnimationDirections.Down;
|
||||||
@ -55,9 +55,9 @@ export abstract class Character extends Container {
|
|||||||
this.addTextures(textures, frame);
|
this.addTextures(textures, frame);
|
||||||
this.invisible = false
|
this.invisible = false
|
||||||
})
|
})
|
||||||
|
|
||||||
this.playerName = new BitmapText(scene, 0, playerNameY, 'main_font', name, 7);
|
this.playerName = new Text(scene, 0, playerNameY, name, {fontFamily: '"Press Start 2P"', fontSize: '8px', strokeThickness: 2, stroke: "gray"});
|
||||||
this.playerName.setOrigin(0.5).setCenterAlign().setDepth(DEPTH_INGAME_TEXT_INDEX);
|
this.playerName.setOrigin(0.5).setDepth(DEPTH_INGAME_TEXT_INDEX);
|
||||||
this.add(this.playerName);
|
this.add(this.playerName);
|
||||||
|
|
||||||
if (this.isClickable()) {
|
if (this.isClickable()) {
|
||||||
|
@ -279,6 +279,14 @@ export class GameScene extends DirtyScene implements CenterListener {
|
|||||||
|
|
||||||
this.load.spritesheet('layout_modes', 'resources/objects/layout_modes.png', {frameWidth: 32, frameHeight: 32});
|
this.load.spritesheet('layout_modes', 'resources/objects/layout_modes.png', {frameWidth: 32, frameHeight: 32});
|
||||||
this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml');
|
this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml');
|
||||||
|
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(this.load as any).rexWebFont({
|
||||||
|
custom: {
|
||||||
|
families: ['Press Start 2P'],
|
||||||
|
urls: ['/resources/fonts/fonts.css'],
|
||||||
|
testString: 'abcdefg'
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
//this function must stay at the end of preload function
|
//this function must stay at the end of preload function
|
||||||
addLoader(this);
|
addLoader(this);
|
||||||
|
@ -9,7 +9,7 @@ import {SelectCharacterScene} from "./Phaser/Login/SelectCharacterScene";
|
|||||||
import {SelectCompanionScene} from "./Phaser/Login/SelectCompanionScene";
|
import {SelectCompanionScene} from "./Phaser/Login/SelectCompanionScene";
|
||||||
import {EnableCameraScene} from "./Phaser/Login/EnableCameraScene";
|
import {EnableCameraScene} from "./Phaser/Login/EnableCameraScene";
|
||||||
import {CustomizeScene} from "./Phaser/Login/CustomizeScene";
|
import {CustomizeScene} from "./Phaser/Login/CustomizeScene";
|
||||||
import {ResizableScene} from "./Phaser/Login/ResizableScene";
|
import WebFontLoaderPlugin from 'phaser3-rex-plugins/plugins/webfontloader-plugin.js';
|
||||||
import {EntryScene} from "./Phaser/Login/EntryScene";
|
import {EntryScene} from "./Phaser/Login/EntryScene";
|
||||||
import {coWebsiteManager} from "./WebRtc/CoWebsiteManager";
|
import {coWebsiteManager} from "./WebRtc/CoWebsiteManager";
|
||||||
import {MenuScene} from "./Phaser/Menu/MenuScene";
|
import {MenuScene} from "./Phaser/Menu/MenuScene";
|
||||||
@ -107,6 +107,13 @@ const config: GameConfig = {
|
|||||||
roundPixels: true,
|
roundPixels: true,
|
||||||
antialias: false
|
antialias: false
|
||||||
},
|
},
|
||||||
|
plugins: {
|
||||||
|
global: [{
|
||||||
|
key: 'rexWebFontLoader',
|
||||||
|
plugin: WebFontLoaderPlugin,
|
||||||
|
start: true
|
||||||
|
}]
|
||||||
|
},
|
||||||
physics: {
|
physics: {
|
||||||
default: "arcade",
|
default: "arcade",
|
||||||
arcade: {
|
arcade: {
|
||||||
|
4
front/src/rex-plugins.d.ts
vendored
4
front/src/rex-plugins.d.ts
vendored
@ -7,6 +7,10 @@ declare module 'phaser3-rex-plugins/plugins/gestures-plugin.js' {
|
|||||||
const content: any; // eslint-disable-line
|
const content: any; // eslint-disable-line
|
||||||
export default content;
|
export default content;
|
||||||
}
|
}
|
||||||
|
declare module 'phaser3-rex-plugins/plugins/webfontloader-plugin.js' {
|
||||||
|
const content: any; // eslint-disable-line
|
||||||
|
export default content;
|
||||||
|
}
|
||||||
declare module 'phaser3-rex-plugins/plugins/gestures.js' {
|
declare module 'phaser3-rex-plugins/plugins/gestures.js' {
|
||||||
export const Pinch: any; // eslint-disable-line
|
export const Pinch: any; // eslint-disable-line
|
||||||
}
|
}
|
||||||
|
1
front/style/fonts.scss
Normal file
1
front/style/fonts.scss
Normal file
@ -0,0 +1 @@
|
|||||||
|
@import "~@fontsource/press-start-2p/index.css";
|
@ -1,4 +1,5 @@
|
|||||||
@import "cowebsite.scss";
|
@import "cowebsite.scss";
|
||||||
@import "cowebsite-mobile.scss";
|
@import "cowebsite-mobile.scss";
|
||||||
@import "style.css";
|
@import "style.css";
|
||||||
@import "mobile-style.scss";
|
@import "mobile-style.scss";
|
||||||
|
@import "fonts.scss";
|
@ -19,8 +19,14 @@ describe("isUserNameValid()", () => {
|
|||||||
it("should not validate spaces", () => {
|
it("should not validate spaces", () => {
|
||||||
expect(isUserNameValid(' ')).toBe(false);
|
expect(isUserNameValid(' ')).toBe(false);
|
||||||
});
|
});
|
||||||
it("should not validate special characters", () => {
|
it("should validate special characters", () => {
|
||||||
expect(isUserNameValid('a&-')).toBe(false);
|
expect(isUserNameValid('%&-')).toBe(true);
|
||||||
|
});
|
||||||
|
it("should validate accents", () => {
|
||||||
|
expect(isUserNameValid('éàëè')).toBe(true);
|
||||||
|
});
|
||||||
|
it("should validate chinese characters", () => {
|
||||||
|
expect(isUserNameValid('中文鍵盤')).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -102,9 +102,17 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(ttf|eot|svg|png|gif|jpg)$/,
|
test: /\.(eot|svg|png|gif|jpg)$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
type: 'asset'
|
type: 'asset'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(woff(2)?|ttf)$/,
|
||||||
|
type: 'asset',
|
||||||
|
generator: {
|
||||||
|
filename: 'fonts/[name][ext]'
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -50,6 +50,11 @@
|
|||||||
minimatch "^3.0.4"
|
minimatch "^3.0.4"
|
||||||
strip-json-comments "^3.1.1"
|
strip-json-comments "^3.1.1"
|
||||||
|
|
||||||
|
"@fontsource/press-start-2p@^4.3.0":
|
||||||
|
version "4.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@fontsource/press-start-2p/-/press-start-2p-4.3.0.tgz#37124387f7fbfe7792b5fc9a1906b80d9aeda4c6"
|
||||||
|
integrity sha512-gmS4070EoZp5/6NUJ+tBnvtDiSmFcR+S+ClAOJ8NGFXDWOkO12yMnyGJEJaDCNCAMX0s2TQCcmr6qWKx5ad3RQ==
|
||||||
|
|
||||||
"@nodelib/fs.scandir@2.1.4":
|
"@nodelib/fs.scandir@2.1.4":
|
||||||
version "2.1.4"
|
version "2.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
|
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
|
||||||
|
Loading…
Reference in New Issue
Block a user