Commit de1fdac1 authored by limingzhe's avatar limingzhe

feat: 更改子模板跳转 字体加载

parent 397452a5
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
export async function loadFonts () { export async function loadFonts (fontName, fontFile) {
// const font = new FontFace( // const font = new FontFace(
...@@ -11,10 +11,10 @@ export async function loadFonts () { ...@@ -11,10 +11,10 @@ export async function loadFonts () {
// ); // );
try { try {
console.log(location.href.split("#")[0] + "assets/play/font/DroidSansFallback.ttf"); console.log(location.href.split("#")[0] + "assets/play/font/" + fontFile);
const font = new FontFace( const font = new FontFace(
"DroidSansFallback", fontName,
"url(" + location.href.split("#")[0] + "assets/play/font/DroidSansFallback.ttf" + ")" "url(" + location.href.split("#")[0] + "assets/play/font/" + fontFile + ")"
); );
console.log('start: ', new Date().getTime()) console.log('start: ', new Date().getTime())
...@@ -22,6 +22,9 @@ export async function loadFonts () { ...@@ -22,6 +22,9 @@ export async function loadFonts () {
console.log('end: ', new Date().getTime()) console.log('end: ', new Date().getTime())
document.fonts.add(font); document.fonts.add(font);
document.body.classList.add("fonts-loaded"); document.body.classList.add("fonts-loaded");
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
......
<span style="font-family:'BRLNSDB'" ></span> <span style="font-family:'DroidSansFallback'" ></span>
<span style="font-family:'Aileron-Black'" ></span>
<div class="game-container" #wrap> <div class="game-container" #wrap>
<canvas id="canvas" style="width: 100%; height: 100%;" #canvas></canvas> <canvas id="canvas" style="width: 100%; height: 100%;" #canvas></canvas>
...@@ -6,7 +7,7 @@ ...@@ -6,7 +7,7 @@
<div #iframeContent style="position: absolute; top: 0;"> <div #iframeContent style="position: absolute; top: 0;">
<div *ngFor="let t of templateArr; let i = index"> <div *ngFor="let t of templateArr; let i = index">
<iframe *ngIf="t.isShow" [src]="t.playUrl || ''" style="width: 100vw; height: 100vh; border: 0px solid #ccc; padding: 5px;" frameborder="0"> <iframe *ngIf="t.isShow" [src]="t.playUrl || ''" style="width: 100vw; height: 100vh; border: 0px solid #ccc; " frameborder="0">
</iframe> </iframe>
</div> </div>
</div> </div>
......
...@@ -140,9 +140,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -140,9 +140,10 @@ export class PlayComponent implements OnInit, OnDestroy {
async ngOnInit() { async ngOnInit() {
await loadFonts();
// await loadFonts();
const getData = (<any>window).courseware.getData; const getData = (<any>window).courseware.getData;
getData((data, aspect) => { getData((data, aspect) => {
...@@ -438,12 +439,24 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -438,12 +439,24 @@ export class PlayComponent implements OnInit, OnDestroy {
// 预加载资源 // 预加载资源
this.loadResources().then(() => { this.loadResources().then(() => {
// this.setfontData(); // this.setfontData();
console.log('aaaaaa');
loadFonts('DroidSansFallback', 'DroidSansFallback.ttf').then(() => {
console.log('bbbbb');
loadFonts('Aileron-Black', 'Aileron-Black.ttf').then(() => {
console.log('cccc');
this.addServerListener(); this.addServerListener();
window['air'].hideAirClassLoading(this.KEY, this.data); window['air'].hideAirClassLoading(this.KEY, this.data);
})
})
}); });
} }
...@@ -901,7 +914,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -901,7 +914,7 @@ export class PlayComponent implements OnInit, OnDestroy {
btnLabel.fontSize = 64; btnLabel.fontSize = 64;
btnLabel.fontName = 'Aileron-Black'; btnLabel.fontName = 'Aileron-Black';
btnLabel.textAlign = 'center'; btnLabel.textAlign = 'center';
btnLabel.text = 'Sent'; btnLabel.text = 'Send';
btnLabel.y = 5; btnLabel.y = 5;
btnLabel.fontColor = '#ffffff'; btnLabel.fontColor = '#ffffff';
btn.addChild(btnLabel, 3); btn.addChild(btnLabel, 3);
...@@ -980,6 +993,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -980,6 +993,8 @@ export class PlayComponent implements OnInit, OnDestroy {
console.log('rect.height: ', rect.height); console.log('rect.height: ', rect.height);
colorRect.alpha = 0; colorRect.alpha = 0;
richText.addChild(colorRect); richText.addChild(colorRect);
this.sentenceEmptyArr.push(colorRect); this.sentenceEmptyArr.push(colorRect);
...@@ -1313,6 +1328,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1313,6 +1328,8 @@ export class PlayComponent implements OnInit, OnDestroy {
mapMove(event) { mapMove(event) {
event.preventDefault()
if (!this.curMoveItem) { if (!this.curMoveItem) {
return; return;
} }
...@@ -1328,6 +1345,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1328,6 +1345,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.curMoveItem.x += this.curMoveItem.moveOffX; this.curMoveItem.x += this.curMoveItem.moveOffX;
this.curMoveItem.y += this.curMoveItem.moveOffY; this.curMoveItem.y += this.curMoveItem.moveOffY;
} }
} }
...@@ -1350,11 +1369,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1350,11 +1369,14 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
checkShowSubTemplateOne() { checkShowSubTemplateOne() {
if (this.submitCount == 1) {
this.showSubTemplate(1);
} else {
this.showSubTemplate(0); this.showSubTemplate(0);
}
// if (this.submitCount == 1) {
// this.showSubTemplate(1);
// } else {
// this.showSubTemplate(0);
// }
} }
...@@ -1611,6 +1633,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1611,6 +1633,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
showSubTemplate(index) { showSubTemplate(index) {
console.log('showSubTemplate _ ', index);
const arr = this.templateArr; const arr = this.templateArr;
for (let i=0; i<arr.length; i++) { for (let i=0; i<arr.length; i++) {
arr[i].isShow = false; arr[i].isShow = false;
...@@ -1673,8 +1696,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1673,8 +1696,8 @@ export class PlayComponent implements OnInit, OnDestroy {
// }, 300); // }, 300);
} }
if (msgData.action === "sendResult") { if (msgData.action === "temp_send_result") {
console.log('in temp_send_result __ msgData: ', msgData);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment