Skip to content

Commit

Permalink
Merge pull request TK11235#160 from entyu/v1.11.0b0
Browse files Browse the repository at this point in the history
V1.11.0b0
  • Loading branch information
entyu authored Mar 5, 2023
2 parents 3547e55 + 4a322a3 commit 61509cc
Show file tree
Hide file tree
Showing 17 changed files with 464 additions and 7 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.1",
"version": "1.11.0b0",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { OverviewPanelComponent } from 'component/overview-panel/overview-panel.
import { PasswordCheckComponent } from 'component/password-check/password-check.component';
import { PeerCursorComponent } from 'component/peer-cursor/peer-cursor.component';
import { PeerMenuComponent } from 'component/peer-menu/peer-menu.component';
import { ReConnectComponent } from 'component/re-connect/re-connect.component';
import { RoomSettingComponent } from 'component/room-setting/room-setting.component';

import { RangeComponent } from 'component/range/range.component';
Expand Down Expand Up @@ -156,6 +157,7 @@ import { AppComponent } from './app.component';
ImportCharacterImgComponent,

LobbyComponent,
ReConnectComponent,
ModalComponent,
OverviewPanelComponent,
PasswordCheckComponent,
Expand Down
8 changes: 8 additions & 0 deletions src/app/class/core/synchronize-object/object-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ export class ObjectStore {
}

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

return object;
}

private markForDelete(identifier: string) {
console.log("円柱 markForDelete" + identifier);
this.garbageMap.set(identifier, performance.now());
this.garbageCollection(10 * 60 * 1000);
}
Expand Down Expand Up @@ -144,6 +146,12 @@ export class ObjectStore {
this.garbageMap.clear();
}

dispGarbageMap(){
for(let map of this.garbageMap){
console.log("garbageMap 履歴:" + map);
}
}

private garbageCollection(garbage: ObjectContext)
private garbageCollection(ms: number)
private garbageCollection(arg: any) {
Expand Down
7 changes: 7 additions & 0 deletions src/app/class/core/system/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export class Network {
window.addEventListener('unload', this.callbackUnload, false);
}

connectionClose(){//円柱デバッグ
if (this.connection) this.connection.close();
this.connection = null;
window.removeEventListener('unload', this.callbackUnload, false);
console.log('Network close...円柱');
}

private close() {
if (this.connection) this.connection.close();
this.connection = null;
Expand Down
5 changes: 5 additions & 0 deletions src/app/class/peer-cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export class PeerCursor extends GameObject {
@SyncVar() voteAnswer = -1; // 投票選択肢のindex値、-2:棄権
@SyncVar() voteId = -1; // 回答した投票のID

private _reConnectPass = '';

private _timestampSend = -1;
private _timestampReceive = -1;

Expand Down Expand Up @@ -79,6 +81,9 @@ export class PeerCursor extends GameObject {
get totalTimeSignNum(): number { return this._totalTimeSignNum; }
set totalTimeSignNum( num: number ){ this._totalTimeSignNum = num ; }

get reConnectPass(): string { return this._reConnectPass; }
set reConnectPass( pass: string ){ this._reConnectPass = pass ; }

get vote(): Vote { return ObjectStore.instance.get<Vote>('Vote'); }

static myCursor: PeerCursor = null;
Expand Down
16 changes: 16 additions & 0 deletions src/app/component/game-character/game-character.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
OnInit,
ViewChild
} from '@angular/core';
import { GameObject } from '@udonarium/core/synchronize-object/game-object';
import { ImageFile } from '@udonarium/core/file-storage/image-file';
import { ObjectNode } from '@udonarium/core/synchronize-object/object-node';
import { ObjectStore } from '@udonarium/core/synchronize-object/object-store';
Expand Down Expand Up @@ -285,6 +286,16 @@ export class GameCharacterComponent implements OnInit, OnDestroy, AfterViewInit
SoundEffect.play(PresetSound.sweep);
}
},
/*
{
name: '削除', action: () => {
console.log("円柱_削除実行_キャラコマ");
this.gameCharacter.setLocation('graveyard');
this.deleteGameObject(this.gameCharacter);
ObjectStore.instance.clearDeleteHistory();
}
},
*/
ContextMenuSeparator,
(this.isLock
? {
Expand All @@ -311,6 +322,11 @@ export class GameCharacterComponent implements OnInit, OnDestroy, AfterViewInit
], this.name);
}

private deleteGameObject(gameObject: GameObject) {
gameObject.destroy();
this.changeDetector.markForCheck();
}

onMove() {
SoundEffect.play(PresetSound.piecePick);
}
Expand Down
8 changes: 7 additions & 1 deletion src/app/component/game-table/game-table.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, ElementRef, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';

import { Card } from '@udonarium/card';
import { CardStack } from '@udonarium/card-stack';
Expand Down Expand Up @@ -94,6 +94,7 @@ export class GameTableComponent implements OnInit, OnDestroy, AfterViewInit {
get peerCursors(): PeerCursor[] { return this.tabletopService.peerCursors; }

constructor(
private changeDetector: ChangeDetectorRef,
private ngZone: NgZone,
private contextMenuService: ContextMenuService,
private pointerDeviceService: PointerDeviceService,
Expand All @@ -111,6 +112,11 @@ export class GameTableComponent implements OnInit, OnDestroy, AfterViewInit {
console.log('UPDATE_GAME_OBJECT GameTableComponent ' + this.currentTable.identifier);
this.setGameTableGrid(this.currentTable.width, this.currentTable.height, this.currentTable.gridSize, this.currentTable.gridType, this.currentTable.gridColor);
})
.on('RE_DRAW_TABLE', event => {
console.log("テーブル再描画");
this.changeDetector.detectChanges();
this.changeDetector.markForCheck();
})
.on('DRAG_LOCKED_OBJECT', event => {
this.isTableTransformMode = true;
this.pointerDeviceService.isDragging = false;
Expand Down
4 changes: 4 additions & 0 deletions src/app/component/lobby/lobby.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export class LobbyComponent implements OnInit, OnDestroy {
get isConnected(): boolean {
return Network.peerIds.length <= 1 ? false : true;
}

get myPeer(): PeerCursor { return PeerCursor.myCursor; }

constructor(
private panelService: PanelService,
private modalService: ModalService
Expand Down Expand Up @@ -90,6 +93,7 @@ export class LobbyComponent implements OnInit, OnDestroy {
if (context.hasPassword) {
password = await this.modalService.open<string>(PasswordCheckComponent, { peerId: context.peerId, title: `${context.roomName}/${context.roomId}` });
if (password == null) password = '';
this.myPeer.reConnectPass = password;
}

if (!context.verifyPassword(password)) return;
Expand Down
5 changes: 5 additions & 0 deletions src/app/component/peer-menu/peer-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
</span>
</span>
</div>
<div>
<button (click)="showReConnect()" class="danger">
<span>再接続</span>
</button>
</div>
</ng-container>
<hr/>
<div>
Expand Down
34 changes: 33 additions & 1 deletion src/app/component/peer-menu/peer-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, NgZone, OnDestroy, OnInit } from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit } from '@angular/core';

import { ObjectStore } from '@udonarium/core/synchronize-object/object-store';
import { PeerContext } from '@udonarium/core/system/network/peer-context';
Expand All @@ -7,10 +7,28 @@ import { PeerCursor } from '@udonarium/peer-cursor';

import { FileSelecterComponent } from 'component/file-selecter/file-selecter.component';
import { LobbyComponent } from 'component/lobby/lobby.component';
import { ReConnectComponent } from 'component/re-connect/re-connect.component';
import { AppConfigService } from 'service/app-config.service';
import { ModalService } from 'service/modal.service';
import { PanelService } from 'service/panel.service';

import { TabletopActionService } from 'service/tabletop-action.service';
import { TableSelecter } from '@udonarium/table-selecter';

import { Card } from '@udonarium/card';
import { CardStack } from '@udonarium/card-stack';
import { GameObject } from '@udonarium/core/synchronize-object/game-object';
import { DiceSymbol } from '@udonarium/dice-symbol';
import { GameCharacter } from '@udonarium/game-character';
import { GameTableMask } from '@udonarium/game-table-mask';
import { RangeArea } from '@udonarium/range';
import { Terrain } from '@udonarium/terrain';
import { TextNote } from '@udonarium/text-note';

import { CutIn } from '@udonarium/cut-in';
import { DiceTable } from '@udonarium/dice-table';


@Component({
selector: 'peer-menu',
templateUrl: './peer-menu.component.html',
Expand All @@ -29,12 +47,16 @@ export class PeerMenuComponent implements OnInit, OnDestroy, AfterViewInit {
get myPeer(): PeerCursor { return PeerCursor.myCursor; }

constructor(
private tabletopActionService: TabletopActionService,
private changeDetector: ChangeDetectorRef,
private ngZone: NgZone,
private modalService: ModalService,
private panelService: PanelService,
public appConfigService: AppConfigService
) { }

get tableSelecter(): TableSelecter { return TableSelecter.instance; }

ngOnInit() {
Promise.resolve().then(() => this.panelService.title = '接続情報');
}
Expand Down Expand Up @@ -77,6 +99,10 @@ export class PeerMenuComponent implements OnInit, OnDestroy, AfterViewInit {
this.modalService.open(LobbyComponent, { width: 700, height: 400, left: 0, top: 400 });
}

showReConnect() {
this.modalService.open(ReConnectComponent, { width: 700, height: 400, left: 0, top: 400 });
}

togglePasswordVisibility() {
this.isPasswordVisible = !this.isPasswordVisible;
}
Expand Down Expand Up @@ -126,6 +152,12 @@ export class PeerMenuComponent implements OnInit, OnDestroy, AfterViewInit {
return degree ;
}

checkConnect(){
console.log("自身のUserid:" + this.networkService.peerContext.userId );
for (let context of this.networkService.peerContexts){
console.log("接続対象ID:" + context.peerId );
}
}

myTime = 0;
dispInfo(){
Expand Down
47 changes: 47 additions & 0 deletions src/app/component/re-connect/re-connect.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
:host {
display: block;
}

.box {
border-bottom:1px dotted #888;
}
.image {
padding: 0px;
width: 64px;
height: 64px;
display: inline-block;
vertical-align: top;
}

.contain {
background-position: center center;
background-repeat: no-repeat;
background-size: contain;
}

.room-list {
font-size: 12px;
border: 0;
border-spacing: 0;
padding: 0;
width: 100%;
max-width: 100%;
white-space: nowrap;
}

.room-list > tr > * {
padding: 1px 0.5em;
text-align: center;
}

.room-name {
white-space: normal;
word-wrap: break-word;
overflow-wrap: anywhere;
word-break: break-word;
min-width: 50%;
}

.is-small-font {
font-size: 10px;
}
27 changes: 27 additions & 0 deletions src/app/component/re-connect/re-connect.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div>
※試験的機能です<br>
<button (click)="cancel()">キャンセル</button>&nbsp;&nbsp;&nbsp;&nbsp;
<span *ngIf="isDisconnect" style="color: #bbb;">STEP1</span>
<span *ngIf="!isDisconnect" style="color: #000;">STEP1</span>
<button (click)="reConnect()" class="danger" [disabled]="isDisconnect">切断実行</button>
<span *ngIf="!isDisconnect" style="color: #bbb;">STEP2</span>
<span *ngIf="isDisconnect" style="color: #000;">STEP2</span>
<button (click)="reConnect2()" class="danger" [disabled]="!isDisconnect">再接続実行</button>
<hr/>
</div>
<span style="font-size: 16px;">
画像や音楽の再ダウンロードを行わず高速に部屋に再接続します。<br>
ただし、確実に成功するわけではありません。<br>
うまくいかない場合は、従来どおりページリロードで最初からの接続を試みてください。<br>
<font color="red">注意:他に部屋データの保持者が居ない場合、データが破棄された上に失敗します。<br>
必要に応じて部屋データの保存を行ってから実行してください。</font><br>
<br>
STEP1、2の順で実行してください。<br>
<br>
STEP1:既存の接続を切断し、同期が取れなくなった可能性のある要素を削除します。<br>
STEP2:ルームに再度接続し、データ同期の回復を試みます。<br>
<br>
STEP2は1度の試みで成功しない場合があります。<br>
STEP2を複数回試みても復帰できない場合はページリロードし、部屋に入り直してください。
</span>

25 changes: 25 additions & 0 deletions src/app/component/re-connect/re-connect.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { ReConnectComponent } from './re-connect.component';

describe('ReConnectComponent', () => {
let component: ReConnectComponent;
let fixture: ComponentFixture<ReConnectComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ReConnectComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ReConnectComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit 61509cc

Please sign in to comment.