Skip to content

Commit

Permalink
Merge pull request TK11235#151 from entyu/v1.10.0b1_honke_merge
Browse files Browse the repository at this point in the history
V1.10.0b1 honke merge
  • Loading branch information
entyu authored Jan 18, 2023
2 parents d67add1 + e49895c commit a22e68c
Show file tree
Hide file tree
Showing 99 changed files with 1,054 additions and 593 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "udonarium_lily",
"version": "1.10.0b0.2",
"version": "1.10.0b1",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="app-table-layer" style="position: absolute; width: 100%; height: 100%; overflow: hidden;">
<game-table></game-table>
</div>
<ui-panel [top]="0" [left]="0" [width]="105" [height]="475" [title]="'メニュー'">
<ui-panel [top]="0" [left]="0" [width]="105" [height]="475" [title]="'メニュー'" [showTitleButtons]="false">
<nav>
<ul>
<li (click)="open('PeerMenuComponent')">
Expand Down
19 changes: 8 additions & 11 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { PeerCursor } from '@udonarium/peer-cursor';
import { PresetSound, SoundEffect } from '@udonarium/sound-effect';
import { ReloadCheck } from '@udonarium/reload-check';
import { TableSelecter } from '@udonarium/table-selecter';
import { MarkDown } from '@udonarium/mark-down';

import { CutIn } from '@udonarium/cut-in';
import { CutInLauncher } from '@udonarium/cut-in-launcher';
Expand Down Expand Up @@ -118,6 +119,9 @@ export class AppComponent implements AfterViewInit, OnDestroy {
let jukebox: Jukebox = new Jukebox('Jukebox');
jukebox.initialize();

let markdown: MarkDown = new MarkDown('markdwon');
markdown.initialize();

let cutInLauncher = new CutInLauncher('CutInLauncher');
cutInLauncher.initialize();

Expand Down Expand Up @@ -250,13 +254,6 @@ export class AppComponent implements AfterViewInit, OnDestroy {
this.panelService.open(PeerMenuComponent, { width: 500, height: 450, left: 100 });
this.panelService.open(ChatWindowComponent, { width: 700, height: 400, left: 100, top: 450 });
}, 0);
/*
setInterval(() => {
this.dispcounter = this.dispcounter + 1;
if ( this.dispcounter > 100 )this.dispcounter = 0;
// PeerCursor.myCursor.time = new Date();
}, 2 );
*/
}

ngOnDestroy() {
Expand Down Expand Up @@ -362,8 +359,8 @@ export class AppComponent implements AfterViewInit, OnDestroy {
}

open(componentName: string) {
let component: new(...args: any[]) => any = null;
let option: PanelOption = { width: 450, height: 600, left: 100 };
let component: { new(...args: any[]): any } = null;
let option: PanelOption = { width: 450, height: 600, left: 100 }
switch (componentName) {
case 'PeerMenuComponent':
component = PeerMenuComponent;
Expand Down Expand Up @@ -420,7 +417,7 @@ export class AppComponent implements AfterViewInit, OnDestroy {
}

handleFileSelect(event: Event) {
let input = <HTMLInputElement> event.target;
let input = <HTMLInputElement>event.target;
let files = input.files;

this.reloadCheck.reloadCheckStart(this.networkService.peerContext.roomName != '');
Expand Down Expand Up @@ -452,8 +449,8 @@ export class AppComponent implements AfterViewInit, OnDestroy {
}, 100);
}
}

}

PanelService.UIPanelComponentClass = UIPanelComponent;
ContextMenuService.ContextMenuComponentClass = ContextMenuComponent;
ModalService.ModalComponentClass = ModalComponent;
2 changes: 1 addition & 1 deletion src/app/class/Jukebox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Jukebox extends GameObject {

private playAfterFileUpdate() {
EventSystem.register(this)
.on('UPDATE_AUDIO_RESOURE', -100, event => {
.on('UPDATE_AUDIO_RESOURE', event => {
this._play();
});
}
Expand Down
1 change: 1 addition & 0 deletions src/app/class/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class Card extends TabletopObject {
}

get hasOwner(): boolean { return 0 < this.owner.length; }
get ownerIsOnline(): boolean { return this.hasOwner && Network.peerContexts.some(context => context.userId === this.owner && context.isOpen); }
get isHand(): boolean { return Network.peerContext.userId === this.owner; }
get isFront(): boolean { return this.state === CardState.FRONT; }
get isVisible(): boolean { return this.isHand || this.isFront; }
Expand Down
6 changes: 3 additions & 3 deletions src/app/class/chat-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export class ChatPalette extends ObjectNode {
//TODO: キャラシ項目のコピー

get paletteLines(): PaletteLine[] {
if (!this.isAnalized) this.parse(<string> this.value);
if (!this.isAnalized) this.parse(<string>this.value);
return this._paletteLines;
}

get paletteVariables(): PaletteVariable[] {
if (!this.isAnalized) this.parse(<string> this.value);
if (!this.isAnalized) this.parse(<string>this.value);
return this._paletteVariables;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export class ChatPalette extends ObjectNode {
private isAnalized: boolean = false;

getPalette(): string[] {
if (!this.isAnalized) this.parse(<string> this.value);
if (!this.isAnalized) this.parse(<string>this.value);
return this._palettes;
}

Expand Down
69 changes: 67 additions & 2 deletions src/app/class/chat-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,34 @@ export class ChatTab extends ObjectNode implements InnerXml {
return str;
}

messageHtmlCoc( tabName: string, message: ChatMessage ): string{
let str = '';
if ( message ) {
str += " <p style=\"color:" + message.messColor.toLowerCase() +";\">" + "\n";
str += " <span> [" + tabName + "]</span>" + "\n";
str += " <span>" + this.escapeHtml( message.name ).replace('<', '').replace('>', '') + "</span>" + "\n";
str += " <span>"+"\n";
str += " ";

if ( !message.isSecret || message.isSendFromSelf ){
if ( message.text ) str += this.escapeHtml( message.text ).replace(/\n/g, '<br>').replace(//g, '>');
}else{
str += '(シークレットダイス)';
}
let fixd = ''
if (message.fixd){
fixd = ' (編集済)';
}
str += fixd;
str += "\n";;

str += " </span>"+"\n";
str += " </p>"+"\n";
str += " "+"\n";
}
return str;
}

escapeHtml(string) {
if (typeof string !== 'string') {
return string;
Expand All @@ -268,7 +296,6 @@ export class ChatTab extends ObjectNode implements InnerXml {
}

logHtml( ): string {

let head : string =
"<?xml version='1.0' encoding='UTF-8'?>"+'\n'+
"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"+'\n'+
Expand All @@ -286,7 +313,6 @@ export class ChatTab extends ObjectNode implements InnerXml {

let main : string = "";


for (let mess of this.chatMessages ) {
let to = mess.to;
let from = mess.from;
Expand All @@ -306,6 +332,45 @@ export class ChatTab extends ObjectNode implements InnerXml {
return str;
}

logHtmlCoc( ): string {
let head : string =
"<!DOCTYPE html>"+'\n'+
"<html lang=\"ja\">"+'\n'+
" <head>"+'\n'+
" <meta charset=\"UTF-8\" />"+'\n'+
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />"+'\n'+
" <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />"+'\n'+
" <title>udonaliumlily - logs</title>"+'\n'+
" </head>"+'\n'+
" <body>"+'\n'+
" "+'\n';


let last : string =
" </body>"+'\n'+
"</html>";

let main : string = "";

for (let mess of this.chatMessages ) {
let to = mess.to;
let from = mess.from;
let myId = Network.peerContext.userId; // 1.13.xとのmargeで修正
console.log( 'from:' + mess.from
+ ' To:' + mess.to + 'myId:' + myId);
if ( to ){
if ( ( to != myId) && ( from != myId) ){
continue;
}
}

main += this.messageHtmlCoc( this.escapeHtml( this.name ) , mess );
}
let str: string = head + main + last;

return str;
}

parseInnerXml(element: Element) {
return super.parseInnerXml(element);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/class/core/file-storage/audio-sharing-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class AudioSharingSystem {
console.log('REQUEST_FILE_RESOURE AudioStorageService あぶれた...' + event.data.receiver, randomRequest.length);
}
})
.on('UPDATE_AUDIO_RESOURE', event => {
.on('UPDATE_AUDIO_RESOURE', 1000, event => {
let updateAudios: AudioFileContext[] = event.data;
console.log('UPDATE_AUDIO_RESOURE AudioStorageService ' + event.sendFrom + ' -> ', updateAudios);
for (let context of updateAudios) {
Expand Down
22 changes: 14 additions & 8 deletions src/app/class/core/file-storage/buffer-sharing-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class BufferSharingTask<T> {
private sendChankTimer: number;

private sentChankIndex = 0;
private bufferingChankRange: number = 4;
private completedChankIndex = 0;

private startTime = 0;
Expand Down Expand Up @@ -115,10 +116,10 @@ export class BufferSharingTask<T> {
.on<number>('FILE_MORE_CHANK_' + this.identifier, event => {
if (this.sendTo !== event.sendFrom) return;
this.completedChankIndex = event.data;
if (this.sendChankTimer == null) {
this.resetTimeout();
if (this.sendChankTimer == null && this.sentChankIndex + 1 < this.chanks.length) {
this.sendChank(this.sentChankIndex + 1);
}
this.resetTimeout();
})
.on('DISCONNECT_PEER', event => {
if (event.data.peerId !== this.sendTo) return;
Expand All @@ -130,6 +131,7 @@ export class BufferSharingTask<T> {
this._cancel();
});
this.sentChankIndex = this.completedChankIndex = 0;
this.startTime = performance.now();
setZeroTimeout(() => this.sendChank(0));
}

Expand All @@ -141,8 +143,9 @@ export class BufferSharingTask<T> {
this.sendChankTimer = null;
if (this.chanks.length <= index + 1) {
console.log('バッファ送信完了', this.identifier);
this.outputTransferRate(this.uint8Array.byteLength);
setZeroTimeout(() => this.finish());
} else if (this.completedChankIndex + 4 <= index) {
} else if (this.completedChankIndex + this.bufferingChankRange <= index) {
this.resetTimeout();
} else {
this.sendChankTimer = setZeroTimeout(() => { this.sendChank(this.sentChankIndex + 1); });
Expand Down Expand Up @@ -188,10 +191,7 @@ export class BufferSharingTask<T> {
let sumLength = 0;
for (let chank of this.chanks) { sumLength += chank.byteLength; }

let time = performance.now() - this.startTime;
let rate = (sumLength / 1024 / 1024) / (time / 1000);
console.log(`${(sumLength / 1024).toFixed(2)}KB ${(time / 1000).toFixed(2)}秒 転送速度: ${rate.toFixed(2)}MB/s`);

this.outputTransferRate(sumLength);
let uint8Array = new Uint8Array(sumLength);
let pos = 0;

Expand All @@ -205,7 +205,13 @@ export class BufferSharingTask<T> {
}

private resetTimeout() {
if (this.timeoutTimer == null) this.timeoutTimer = new ResettableTimeout(() => this.timeout(), 30 * 1000);
if (this.timeoutTimer == null) this.timeoutTimer = new ResettableTimeout(() => this.timeout(), 10 * 1000);
this.timeoutTimer.reset();
}

private outputTransferRate(byteLength: number) {
let time = performance.now() - this.startTime;
let rate = (byteLength / 1024 / 1024) / (time / 1000);
console.log(`${(byteLength / 1024).toFixed(2)}KB ${(time / 1000).toFixed(2)}秒 転送速度: ${rate.toFixed(2)}MB/s`);
}
}
4 changes: 2 additions & 2 deletions src/app/class/core/file-storage/file-archiver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { saveAs } from 'file-saver';
import * as JSZip from 'jszip/dist/jszip.min.js';
import * as JSZip from 'jszip';

import { EventSystem, Network } from '../system';
import { XmlUtil } from '../system/util/xml-util';
Expand Down Expand Up @@ -148,7 +148,7 @@ export class FileArchiver {
console.warn(reason);
return;
}
let zipEntries = [];
let zipEntries: JSZip.JSZipObject[] = [];
zip.forEach((relativePath, zipEntry) => zipEntries.push(zipEntry));
for (let zipEntry of zipEntries) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/app/class/core/file-storage/image-sharing-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class ImageSharingSystem {
console.log('REQUEST_FILE_RESOURE ImageStorageService あぶれた...' + event.data.receiver, randomRequest.length);
}
})
.on('UPDATE_FILE_RESOURE', event => {
.on('UPDATE_FILE_RESOURE', 1000, event => {
let updateImages: ImageContext[] = event.data.updateImages;
console.log('UPDATE_FILE_RESOURE ImageStorageService ' + event.sendFrom + ' -> ', updateImages);
for (let context of updateImages) {
Expand Down
4 changes: 4 additions & 0 deletions src/app/class/core/file-storage/mime-type.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
export namespace MimeType {
const types = {
avif: 'image/avif',
gif: 'image/gif',
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
jpe: 'image/jpeg',
jfif: 'image/jpeg',
pjpeg: 'image/jpeg',
pjp: 'image/jpeg',
png: 'image/png',
apng: 'image/apng',
webp: 'image/webp',
Expand Down
2 changes: 1 addition & 1 deletion src/app/class/core/synchronize-object/object-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ObjectStore {

private _delete(object: GameObject, shouldBroadcast: boolean): GameObject {
if (this.remove(object) === null) return null;
if (shouldBroadcast) EventSystem.call('DELETE_GAME_OBJECT', { identifier: object.identifier });
if (shouldBroadcast) EventSystem.call('DELETE_GAME_OBJECT', { aliasName: object.aliasName, identifier: object.identifier });

return object;
}
Expand Down
14 changes: 7 additions & 7 deletions src/app/class/core/synchronize-object/object-synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ObjectSynchronizer {
let catalog: CatalogItem[] = event.data;
for (let item of catalog) {
if (ObjectStore.instance.isDeleted(item.identifier)) {
EventSystem.call('DELETE_GAME_OBJECT', { identifier: item.identifier }, event.sendFrom);
EventSystem.call('DELETE_GAME_OBJECT', { aliasName: '', identifier: item.identifier }, event.sendFrom);
} else {
this.addRequestMap(item, event.sendFrom);
}
Expand All @@ -48,26 +48,26 @@ export class ObjectSynchronizer {
.on('REQUEST_GAME_OBJECT', event => {
if (event.isSendFromSelf) return;
if (ObjectStore.instance.isDeleted(event.data)) {
EventSystem.call('DELETE_GAME_OBJECT', { identifier: event.data }, event.sendFrom);
EventSystem.call('DELETE_GAME_OBJECT', { aliasName: '', identifier: event.data }, event.sendFrom);
} else {
let object: GameObject = ObjectStore.instance.get(event.data);
if (object) EventSystem.call('UPDATE_GAME_OBJECT', object.toContext(), event.sendFrom);
}
})
.on('UPDATE_GAME_OBJECT', event => {
.on('UPDATE_GAME_OBJECT', 1000, event => {
let context: ObjectContext = event.data;
let object: GameObject = ObjectStore.instance.get(context.identifier);
if (object) {
if (!event.isSendFromSelf) this.updateObject(object, context);
} else if (ObjectStore.instance.isDeleted(context.identifier)) {
EventSystem.call('DELETE_GAME_OBJECT', { identifier: context.identifier }, event.sendFrom);
EventSystem.call('DELETE_GAME_OBJECT', { aliasName: context.aliasName, identifier: context.identifier }, event.sendFrom);
} else {
this.createObject(context);
}
})
.on('DELETE_GAME_OBJECT', event => {
let context: ObjectContext = event.data;
ObjectStore.instance.delete(context.identifier, false);
.on('DELETE_GAME_OBJECT', 1000, event => {
let identifier: ObjectIdentifier = event.data.identifier;
ObjectStore.instance.delete(identifier, false);
});
}

Expand Down
Loading

0 comments on commit a22e68c

Please sign in to comment.