-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f35c393
commit 6c75ffc
Showing
42 changed files
with
2,720 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// ------------------------------------------------------------------------------ | ||
// Copyright (c) 2016 Goodgame Studios. All Rights Reserved. | ||
// | ||
// NOTICE: You are permitted to use, modify, and distribute this file | ||
// in accordance with the terms of the license agreement accompanying it. | ||
// ------------------------------------------------------------------------------ | ||
|
||
import { | ||
IBundle, | ||
IContext, | ||
LogLevel | ||
} from "robotlegs"; | ||
|
||
import { ContextViewExtension } from "../../extensions/contextView/ContextViewExtension"; | ||
import { ContextViewListenerConfig } from "../../extensions/contextView/impl/ContextViewListenerConfig"; | ||
import { StageSyncExtension } from "../../extensions/contextView/StageSyncExtension"; | ||
import { MediatorMapExtension } from "../../extensions/mediatorMap/MediatorMapExtension"; | ||
import { StageCrawlerExtension } from "../../extensions/viewManager/StageCrawlerExtension"; | ||
import { StageObserverExtension } from "../../extensions/viewManager/StageObserverExtension"; | ||
import { ViewManagerExtension } from "../../extensions/viewManager/ViewManagerExtension"; | ||
|
||
/** | ||
* For that Classic Robotlegs flavour | ||
* | ||
* <p>This bundle installs a number of extensions commonly used | ||
* in typical Robotlegs applications and modules.</p> | ||
*/ | ||
export class PixiBundle implements IBundle { | ||
|
||
/*============================================================================*/ | ||
/* Public Functions */ | ||
/*============================================================================*/ | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public extend(context: IContext): void { | ||
context.logLevel = LogLevel.DEBUG; | ||
|
||
context.install( | ||
ContextViewExtension, | ||
ViewManagerExtension, | ||
StageObserverExtension, | ||
MediatorMapExtension, | ||
StageCrawlerExtension, | ||
StageSyncExtension | ||
); | ||
|
||
context.configure(ContextViewListenerConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/robotlegs/bender/extensions/contextView/PixiExtension.ts
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
src/robotlegs/bender/extensions/contextView/StageSyncExtension.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// ------------------------------------------------------------------------------ | ||
// Copyright (c) 2016 Goodgame Studios. All Rights Reserved. | ||
// | ||
// NOTICE: You are permitted to use, modify, and distribute this file | ||
// in accordance with the terms of the license agreement accompanying it. | ||
// ------------------------------------------------------------------------------ | ||
|
||
import { | ||
instanceOfType, | ||
IContext, | ||
IExtension, | ||
ILogger | ||
} from "robotlegs"; | ||
|
||
import { ContextView } from "./impl/ContextView"; | ||
|
||
/** | ||
* <p>This Extension waits for a ContextView to be added as a configuration, | ||
* and initializes and destroys the context based on the contextView's stage presence.</p> | ||
* | ||
* <p>It should be installed before context initialization.</p> | ||
*/ | ||
export class StageSyncExtension implements IExtension { | ||
|
||
/*============================================================================*/ | ||
/* Private Properties */ | ||
/*============================================================================*/ | ||
|
||
private _context: IContext; | ||
|
||
private _contextView: any; | ||
|
||
private _logger: ILogger; | ||
|
||
/*============================================================================*/ | ||
/* Public Functions */ | ||
/*============================================================================*/ | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public extend(context: IContext): void { | ||
this._context = context; | ||
this._logger = context.getLogger(this); | ||
this._context.addConfigHandler(instanceOfType(ContextView), this.handleContextView.bind(this)); | ||
} | ||
|
||
/*============================================================================*/ | ||
/* Private Functions */ | ||
/*============================================================================*/ | ||
|
||
private handleContextView(contextView: ContextView): void { | ||
if (this._contextView) { | ||
this._logger.warn("A contextView has already been installed, ignoring {0}", [contextView.view]); | ||
return; | ||
} | ||
this._contextView = contextView.view; | ||
if (this._contextView.stage) { | ||
this.initializeContext(); | ||
} else { | ||
this._logger.debug("Context view is not yet on stage. Waiting..."); | ||
// this._contextView.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage); | ||
} | ||
} | ||
|
||
private onAddedToStage(event: Event): void { | ||
// this._contextView.removeEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage); | ||
this.initializeContext(); | ||
} | ||
|
||
private initializeContext(): void { | ||
this._logger.debug("Context view is now on stage. Initializing context..."); | ||
this._context.initialize(); | ||
// this._contextView.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage); | ||
} | ||
|
||
private onRemovedFromStage(event: Event): void { | ||
this._logger.debug("Context view has left the stage. Destroying context..."); | ||
// this._contextView.removeEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage); | ||
this._context.destroy(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/robotlegs/bender/extensions/contextView/api/IContextView.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// ------------------------------------------------------------------------------ | ||
// Copyright (c) 2016 Goodgame Studios. All Rights Reserved. | ||
// | ||
// NOTICE: You are permitted to use, modify, and distribute this file | ||
// in accordance with the terms of the license agreement accompanying it. | ||
// ------------------------------------------------------------------------------ | ||
|
||
export let IContextView = Symbol("IContextView"); | ||
export interface IContextView { | ||
view: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/robotlegs/bender/extensions/contextView/impl/ContextViewListenerConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// ------------------------------------------------------------------------------ | ||
// Copyright (c) 2016 Goodgame Studios. All Rights Reserved. | ||
// | ||
// NOTICE: You are permitted to use, modify, and distribute this file | ||
// in accordance with the terms of the license agreement accompanying it. | ||
// ------------------------------------------------------------------------------ | ||
|
||
import { injectable, inject } from "inversify"; | ||
|
||
import { IConfig } from "robotlegs"; | ||
|
||
import { IContextView } from "../api/IContextView"; | ||
import { IViewManager } from "../../viewManager/api/IViewManager"; | ||
|
||
/** | ||
* This configuration file adds the ContextView to the viewManager. | ||
* | ||
* It requires that the ViewManagerExtension, ContextViewExtension | ||
* and a ContextView have been installed. | ||
*/ | ||
@injectable() | ||
export class ContextViewListenerConfig implements IConfig { | ||
|
||
/*============================================================================*/ | ||
/* Public Properties */ | ||
/*============================================================================*/ | ||
|
||
private _contextView: IContextView; | ||
|
||
private _viewManager: IViewManager; | ||
|
||
/*============================================================================*/ | ||
/* Public Functions */ | ||
/*============================================================================*/ | ||
|
||
constructor( | ||
@inject(IContextView) contextView: IContextView, | ||
@inject(IViewManager) viewManager: IViewManager | ||
) { | ||
this._contextView = contextView; | ||
this._viewManager = viewManager; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public configure(): void { | ||
// Adds the Context View to the View Manager at startup | ||
this._viewManager.addContainer(this._contextView.view); | ||
} | ||
} |
10 changes: 1 addition & 9 deletions
10
src/robotlegs/bender/extensions/contextView/pixiPatch/eventemitter3-patch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/robotlegs/bender/extensions/contextView/pixiPatch/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.