Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert stored line endings in repo to LF #4241

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
414 changes: 207 additions & 207 deletions examples/src/examples/user-interface/scroll-view.tsx

Large diffs are not rendered by default.

294 changes: 147 additions & 147 deletions examples/src/examples/user-interface/text-localization.tsx
Original file line number Diff line number Diff line change
@@ -1,147 +1,147 @@
import * as pc from '../../../../';
class TextLocalizationExample {
static CATEGORY = 'User Interface';
static NAME = 'Text Localization';
example(canvas: HTMLCanvasElement): void {
// Create the application with input and start the update loop
const app = new pc.Application(canvas, {
mouse: new pc.Mouse(document.body),
touch: new pc.TouchDevice(document.body),
elementInput: new pc.ElementInput(canvas)
});
const assets = {
'font': new pc.Asset('font', 'font', { url: '/static/assets/fonts/courier.json' })
};
const assetListLoader = new pc.AssetListLoader(Object.values(assets), app.assets);
assetListLoader.load(() => {
app.start();
app.i18n.addData({
header: {
version: 1
},
data: [{
info: {
locale: 'en-US'
},
messages: {
"HELLO": "Hi"
}
}, {
info: {
locale: 'fr-FR'
},
messages: {
"HELLO": "Salut"
}
}, {
info: {
locale: 'es-ES'
},
messages: {
"HELLO": "Hola"
}
}, {
info: {
locale: 'pt-BR'
},
messages: {
"HELLO": "Oi!"
}
}]
});
// Set the canvas to fill the window and automatically change resolution to be the same as the canvas size
app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
app.setCanvasResolution(pc.RESOLUTION_AUTO);
window.addEventListener("resize", function () {
app.resizeCanvas(canvas.width, canvas.height);
});
// Create a camera
const camera = new pc.Entity();
camera.addComponent("camera", {
clearColor: new pc.Color(30 / 255, 30 / 255, 30 / 255)
});
app.root.addChild(camera);
// Create a 2D screen
const screen = new pc.Entity();
screen.addComponent("screen", {
referenceResolution: new pc.Vec2(1280, 720),
scaleBlend: 0.5,
scaleMode: pc.SCALEMODE_BLEND,
screenSpace: true
});
app.root.addChild(screen);
// Create a basic text element
const text = new pc.Entity();
text.addComponent("element", {
anchor: [0.5, 0.5, 0.5, 0.5],
autoWidth: false,
fontAsset: assets.font.id,
fontSize: 128,
pivot: [0.5, 0.5],
key: "HELLO",
type: pc.ELEMENTTYPE_TEXT,
width: 640
});
screen.addChild(text);
function createButton(labelText: string, x: number, y: number) {
// Create a simple button
const button = new pc.Entity();
button.addComponent("button", {
imageEntity: button
});
button.addComponent("element", {
anchor: [0.5, 0.5, 0.5, 0.5],
height: 40,
pivot: [0.5, 0.5],
type: pc.ELEMENTTYPE_IMAGE,
width: 128,
useInput: true
});
// Create a label for the button
const label = new pc.Entity();
label.addComponent("element", {
anchor: [0.5, 0.5, 0.5, 0.5],
color: new pc.Color(0, 0, 0),
fontAsset: assets.font.id,
fontSize: 32,
height: 64,
pivot: [0.5, 0.5],
text: labelText,
type: pc.ELEMENTTYPE_TEXT,
width: 128,
wrapLines: true
});
button.addChild(label);
// Change the locale to the button text
button.button.on('click', function () {
app.i18n.locale = labelText;
});
button.setLocalPosition(x, y, 0);
return button;
}
screen.addChild(createButton("en-US", -225, -100));
screen.addChild(createButton("fr-FR", -75, -100));
screen.addChild(createButton("es-ES", 75, -100));
screen.addChild(createButton("pt-BR", 225, -100));
});
}
}
export default TextLocalizationExample;
import * as pc from '../../../../';

class TextLocalizationExample {
static CATEGORY = 'User Interface';
static NAME = 'Text Localization';

example(canvas: HTMLCanvasElement): void {

// Create the application with input and start the update loop
const app = new pc.Application(canvas, {
mouse: new pc.Mouse(document.body),
touch: new pc.TouchDevice(document.body),
elementInput: new pc.ElementInput(canvas)
});

const assets = {
'font': new pc.Asset('font', 'font', { url: '/static/assets/fonts/courier.json' })
};

const assetListLoader = new pc.AssetListLoader(Object.values(assets), app.assets);
assetListLoader.load(() => {
app.start();

app.i18n.addData({
header: {
version: 1
},
data: [{
info: {
locale: 'en-US'
},
messages: {
"HELLO": "Hi"
}
}, {
info: {
locale: 'fr-FR'
},
messages: {
"HELLO": "Salut"
}
}, {
info: {
locale: 'es-ES'
},
messages: {
"HELLO": "Hola"
}
}, {
info: {
locale: 'pt-BR'
},
messages: {
"HELLO": "Oi!"
}
}]
});

// Set the canvas to fill the window and automatically change resolution to be the same as the canvas size
app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
app.setCanvasResolution(pc.RESOLUTION_AUTO);

window.addEventListener("resize", function () {
app.resizeCanvas(canvas.width, canvas.height);
});

// Create a camera
const camera = new pc.Entity();
camera.addComponent("camera", {
clearColor: new pc.Color(30 / 255, 30 / 255, 30 / 255)
});
app.root.addChild(camera);

// Create a 2D screen
const screen = new pc.Entity();
screen.addComponent("screen", {
referenceResolution: new pc.Vec2(1280, 720),
scaleBlend: 0.5,
scaleMode: pc.SCALEMODE_BLEND,
screenSpace: true
});
app.root.addChild(screen);

// Create a basic text element
const text = new pc.Entity();
text.addComponent("element", {
anchor: [0.5, 0.5, 0.5, 0.5],
autoWidth: false,
fontAsset: assets.font.id,
fontSize: 128,
pivot: [0.5, 0.5],
key: "HELLO",
type: pc.ELEMENTTYPE_TEXT,
width: 640
});
screen.addChild(text);

function createButton(labelText: string, x: number, y: number) {
// Create a simple button
const button = new pc.Entity();
button.addComponent("button", {
imageEntity: button
});
button.addComponent("element", {
anchor: [0.5, 0.5, 0.5, 0.5],
height: 40,
pivot: [0.5, 0.5],
type: pc.ELEMENTTYPE_IMAGE,
width: 128,
useInput: true
});

// Create a label for the button
const label = new pc.Entity();
label.addComponent("element", {
anchor: [0.5, 0.5, 0.5, 0.5],
color: new pc.Color(0, 0, 0),
fontAsset: assets.font.id,
fontSize: 32,
height: 64,
pivot: [0.5, 0.5],
text: labelText,
type: pc.ELEMENTTYPE_TEXT,
width: 128,
wrapLines: true
});
button.addChild(label);

// Change the locale to the button text
button.button.on('click', function () {
app.i18n.locale = labelText;
});

button.setLocalPosition(x, y, 0);

return button;
}

screen.addChild(createButton("en-US", -225, -100));
screen.addChild(createButton("fr-FR", -75, -100));
screen.addChild(createButton("es-ES", 75, -100));
screen.addChild(createButton("pt-BR", 225, -100));
});
}
}

export default TextLocalizationExample;
Loading