移除demo

This commit is contained in:
yhh
2020-11-23 16:07:30 +08:00
parent 14a73e4010
commit 0f17aff8fd
149 changed files with 1 additions and 183711 deletions
-43
View File
@@ -1,43 +0,0 @@
{
"engineVersion": "5.2.33",
"compilerVersion": "5.2.33",
"template": {},
"target": {
"current": "web"
},
"modules": [
{
"name": "egret"
},
{
"name": "eui"
},
{
"name": "assetsmanager"
},
{
"name": "game"
},
{
"name": "tween"
},
{
"name": "promise"
},
{
"name": "dragonBones"
},
{
"name": "fairygui",
"path": "./libs/fairygui"
},
{
"name": "framework",
"path": "./libs/framework"
},
{
"name": "framework_tiled",
"path": "./libs/framework_tiled"
}
]
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

-95
View File
@@ -1,95 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Egret</title>
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
html, body {
-ms-touch-action: none;
background: #888888;
padding: 0;
border: 0;
margin: 0;
height: 100%;
}
</style>
</head>
<body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
data-entry-class="Main"
data-orientation="auto"
data-scale-mode="fixedWidth"
data-frame-rate="60"
data-content-width="640"
data-content-height="1136"
data-multi-fingered="2"
data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div>
<script>
var loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
loadSingleScript(list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
};
loadNext();
};
var loadSingleScript = function (src, callback) {
var s = document.createElement('script');
s.async = false;
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
s.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
var xhr = new XMLHttpRequest();
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
xhr.addEventListener("load", function () {
var manifest = JSON.parse(xhr.response);
var list = manifest.initial.concat(manifest.game);
loadScript(list, function () {
/**
* {
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
* "calculateCanvasScaleFactor": //a function return canvas scale factor
* }
**/
egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
return (window.devicePixelRatio || 1) / backingStore;
}});
});
});
xhr.send(null);
</script>
</body>
</html>
-52
View File
@@ -1,52 +0,0 @@
declare module skins{
class ButtonSkin extends eui.Skin{
}
}
declare module skins{
class CheckBoxSkin extends eui.Skin{
}
}
declare module skins{
class HScrollBarSkin extends eui.Skin{
}
}
declare module skins{
class HSliderSkin extends eui.Skin{
}
}
declare module skins{
class ItemRendererSkin extends eui.Skin{
}
}
declare module skins{
class PanelSkin extends eui.Skin{
}
}
declare module skins{
class ProgressBarSkin extends eui.Skin{
}
}
declare module skins{
class RadioButtonSkin extends eui.Skin{
}
}
declare module skins{
class ScrollerSkin extends eui.Skin{
}
}
declare module skins{
class TextInputSkin extends eui.Skin{
}
}
declare module skins{
class ToggleSwitchSkin extends eui.Skin{
}
}
declare module skins{
class VScrollBarSkin extends eui.Skin{
}
}
declare module skins{
class VSliderSkin extends eui.Skin{
}
}
-2444
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-2638
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-357
View File
@@ -1,357 +0,0 @@
declare module es {
class TiledMapRenderer extends RenderableComponent {
tiledMap: TmxMap;
physicsLayer: Ref<number>;
layerIndicesToRender: number[];
private toContainer;
readonly width: number;
readonly height: number;
collisionLayer: TmxLayer;
_shouldCreateColliders: boolean;
_colliders: Collider[];
constructor(tiledMap: TmxMap, collisionLayerName?: string, shouldCreateColliders?: boolean);
setLayerToRender(layerName: string): void;
setLayersToRender(...layerNames: string[]): void;
private getLayerIndex;
getRowAtWorldPosition(yPos: number): number;
getColumnAtWorldPosition(xPos: number): number;
onEntityTransformChanged(comp: transform.Component): void;
onAddedToEntity(): void;
onRemovedFromEntity(): void;
update(): void;
render(camera: es.Camera): void;
addColliders(): void;
removeColliders(): void;
}
}
declare module es {
class TmxGroup implements ITmxLayer {
map: TmxMap;
offsetX: number;
offsetY: number;
opacity: number;
properties: Map<string, string>;
visible: boolean;
name: string;
layers: ITmxLayer[];
tileLayers: TmxLayer[];
objectGroups: TmxObjectGroup[];
imageLayers: TmxImageLayer[];
groups: TmxGroup[];
}
}
declare module es {
interface ITmxLayer {
offsetX: number;
offsetY: number;
opacity: number;
visible: boolean;
properties: Map<string, string>;
}
}
declare module es {
class TmxImageLayer implements ITmxLayer {
map: TmxMap;
name: string;
offsetX: number;
offsetY: number;
opacity: number;
properties: Map<string, string>;
visible: boolean;
width?: number;
height?: number;
image: TmxImage;
}
}
declare module es {
class TmxLayer implements ITmxLayer {
map: TmxMap;
name: string;
opacity: number;
offsetX: number;
offsetY: number;
properties: Map<string, string>;
visible: boolean;
readonly offset: Vector2;
width: number;
height: number;
tiles: TmxLayerTile[];
getTileWithGid(gid: number): TmxLayerTile;
getTile(x: number, y: number): TmxLayerTile;
getCollisionRectangles(): Rectangle[];
findBoundsRect(startX: number, endX: number, startY: number, checkedIndexes?: boolean[]): Rectangle;
}
class TmxLayerTile {
static readonly FLIPPED_HORIZONTALLY_FLAG: number;
static readonly FLIPPED_VERTICALLY_FLAG: number;
tileset: TmxTileset;
gid: number;
x: number;
y: number;
readonly position: Vector2;
horizontalFlip: boolean;
verticalFlip: boolean;
_tilesetTileIndex?: number;
readonly tilesetTile: TmxTilesetTile;
constructor(map: TmxMap, id: number, x: number, y: number);
}
}
declare module es {
class TmxDocument {
tmxDirectory: string;
constructor();
}
interface ITmxElement {
name: string;
}
class TmxImage {
texture: egret.Bitmap;
bitmap: egret.SpriteSheet;
source: string;
format: string;
data: any;
trans: number;
width: number;
height: number;
dispose(): void;
}
}
declare module es {
class TmxMap extends TmxDocument {
version: string;
tiledVersion: string;
width: number;
height: number;
readonly worldWidth: number;
readonly worldHeight: number;
tileWidth: number;
tileHeight: number;
hexSideLength?: number;
orientation: OrientationType;
staggerAxis: StaggerAxisType;
staggerIndex: StaggerIndexType;
renderOrder: RenderOrderType;
backgroundColor: number;
nextObjectID?: number;
layers: ITmxLayer[];
tilesets: TmxTileset[];
tileLayers: TmxLayer[];
objectGroups: TmxObjectGroup[];
imageLayers: TmxImageLayer[];
groups: TmxGroup[];
properties: Map<string, string>;
maxTileWidth: number;
maxTileHeight: number;
readonly requiresLargeTileCulling: boolean;
getTilesetForTileGid(gid: number): TmxTileset;
worldToTilePositionX(x: number, clampToTilemapBounds?: boolean): number;
worldToTilePositionY(y: number, clampToTilemapBounds?: boolean): number;
getLayer(name: string): ITmxLayer;
update(): void;
_isDisposed: any;
dispose(disposing?: boolean): void;
}
enum OrientationType {
unknown = 0,
orthogonal = 1,
isometric = 2,
staggered = 3,
hexagonal = 4
}
enum StaggerAxisType {
x = 0,
y = 1
}
enum StaggerIndexType {
odd = 0,
even = 1
}
enum RenderOrderType {
rightDown = 0,
rightUp = 1,
leftDown = 2,
leftUp = 3
}
}
declare module es {
class TmxObjectGroup implements ITmxLayer {
map: TmxMap;
name: string;
opacity: number;
visible: boolean;
offsetX: number;
offsetY: number;
color: number;
drawOrder: DrawOrderType;
objects: TmxObject[];
properties: Map<string, string>;
}
class TmxObject implements ITmxElement {
id: number;
name: string;
shape: egret.Shape;
textField: egret.TextField;
objectType: TmxObjectType;
type: string;
x: number;
y: number;
width: number;
height: number;
rotation: number;
tile: TmxLayerTile;
visible: boolean;
text: TmxText;
points: Vector2[];
properties: Map<string, string>;
constructor();
}
class TmxText {
fontFamily: string;
pixelSize: number;
wrap: boolean;
color: number;
bold: boolean;
italic: boolean;
underline: boolean;
strikeout: boolean;
kerning: boolean;
alignment: TmxAlignment;
value: string;
}
class TmxAlignment {
horizontal: TmxHorizontalAlignment;
vertical: TmxVerticalAlignment;
}
enum TmxObjectType {
basic = 0,
point = 1,
tile = 2,
ellipse = 3,
polygon = 4,
polyline = 5,
text = 6
}
enum DrawOrderType {
unkownOrder = -1,
TopDown = 0,
IndexOrder = 1
}
enum TmxHorizontalAlignment {
left = 0,
center = 1,
right = 2,
justify = 3
}
enum TmxVerticalAlignment {
top = 0,
center = 1,
bottom = 2
}
}
declare module es {
class TiledMapLoader {
static loadTmxMap(map: TmxMap, filePath: string): Promise<TmxMap>;
static loadTmxMapData(map: TmxMap, xMap: any, info: any): Promise<TmxMap>;
static parseLayers(container: any, xEle: any, map: TmxMap, width: number, height: number, tmxDirectory: string): Promise<void>;
static loadTmxGroup(group: TmxGroup, map: TmxMap, xGroup: any, width: number, height: number, tmxDirectory: string): Promise<TmxGroup>;
static loadTmxImageLayer(layer: TmxImageLayer, map: TmxMap, xImageLayer: any, tmxDirectory: string): Promise<TmxImageLayer>;
static loadTmxLayer(layer: TmxLayer, map: TmxMap, xLayer: any, width: number, height: number): TmxLayer;
private static updateMaxTileSizes;
static parseOrientationType(type: string): OrientationType;
static parseStaggerAxisType(type: string): StaggerAxisType;
static parseStaggerIndexType(type: string): StaggerIndexType;
static parseRenderOrderType(type: string): RenderOrderType;
static parsePropertyDict(prop: any): Map<string, string>;
static parseTmxTileset(map: TmxMap, xTileset: any): Promise<TmxTileset>;
static loadTmxTileset(tileset: TmxTileset, map: TmxMap, xTileset: any, firstGid: number): Promise<TmxTileset>;
static loadTmxTilesetTile(tile: TmxTilesetTile, tileset: TmxTileset, xTile: any, terrains: TmxTerrain[], tmxDirectory: string): Promise<TmxTilesetTile>;
static loadTmxAnimationFrame(frame: TmxAnimationFrame, xFrame: any): TmxAnimationFrame;
static loadTmxObjectGroup(group: TmxObjectGroup, map: TmxMap, xObjectGroup: any): TmxObjectGroup;
static loadTmxObject(obj: TmxObject, map: TmxMap, xObject: any): TmxObject;
static loadTmxText(text: TmxText, xText: any): TmxText;
static loadTmxAlignment(alignment: TmxAlignment, xText: any): TmxAlignment;
static parsePoints(xPoints: any): any[];
static parsePoint(pt: {
x: number;
y: number;
}): Vector2;
static parseTmxTerrain(xTerrain: any): TmxTerrain;
static parseTmxTileOffset(xTileOffset: any): TmxTileOffset;
static loadTmxImage(image: TmxImage, xImage: any, tmxDirectory: string): Promise<TmxImage>;
}
}
declare module es {
class TiledRendering {
static renderMap(map: TmxMap, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void;
static renderLayer(layer: TmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void;
static renderLayerRenderCamera(layer: ITmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number, camerClipBounds: Rectangle): void;
static renderLayerCamera(layer: TmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number, camerClipBounds: Rectangle): void;
static renderImageLayer(layer: TmxImageLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void;
static renderObjectGroup(objGroup: TmxObjectGroup, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void;
private static renderTilesetTile;
static renderGroup(group: TmxGroup, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void;
static renderTile(tile: TmxLayerTile, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, tileWidth: number, tileHeight: number, color: egret.ColorMatrixFilter, layerDepth: number): void;
}
}
declare module es {
class TmxTileset extends TmxDocument implements ITmxElement {
map: TmxMap;
firstGid: number;
name: any;
tileWidth: number;
tileHeight: number;
spacing: number;
margin: number;
columns?: number;
tileCount?: number;
tiles: Map<number, TmxTilesetTile>;
tileOffset: TmxTileOffset;
properties: Map<string, string>;
image: TmxImage;
terrains: TmxTerrain[];
tileRegions: Map<number, Rectangle>;
update(): void;
}
class TmxTileOffset {
x: number;
y: number;
}
class TmxTerrain implements ITmxElement {
name: any;
tile: number;
properties: Map<string, string>;
}
}
declare module es {
class TmxTilesetTile {
tileset: TmxTileset;
id: number;
terrainEdges: TmxTerrain[];
probability: number;
type: string;
properties: Map<string, string>;
image: TmxImage;
objectGroups: TmxObjectGroup[];
animationFrames: TmxAnimationFrame[];
readonly currentAnimationFrameGid: number;
_animationElapsedTime: number;
_animationCurrentFrame: number;
isDestructable: boolean;
isSlope: boolean;
isOneWayPlatform: boolean;
slopeTopLeft: number;
slopeTopRight: number;
processProperties(): void;
updateAnimatedTiles(): void;
}
class TmxAnimationFrame {
gid: number;
duration: number;
}
}
declare module es {
class TmxUtils {
static decode(data: any, encoding: any, compression: string): Array<number>;
static color16ToUnit($color: string): number;
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-15371
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-15047
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-2502
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-1350
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-53
View File
@@ -1,53 +0,0 @@
{
"initial": [
"libs/modules/egret/egret.js",
"libs/modules/egret/egret.web.js",
"libs/modules/eui/eui.js",
"libs/modules/assetsmanager/assetsmanager.js",
"libs/modules/game/game.js",
"libs/modules/tween/tween.js",
"libs/modules/promise/promise.js",
"libs/modules/dragonBones/dragonBones.js",
"libs/fairygui/fairygui.js",
"libs/framework/framework.js",
"libs/framework_tiled/framework_tiled.js"
],
"game": [
"bin-debug/Fgui/common/commonBinder.js",
"bin-debug/UI/mvc/BaseView.js",
"bin-debug/SampleHelpers/SampleScene.js",
"bin-debug/Scenes/NinjaAdventure/ProjectileHitDetector.js",
"bin-debug/UI/loading/LoadingView.js",
"bin-debug/Scenes/NinjaAdventure/CameraBounds.js",
"bin-debug/Fgui/loading/loadingBinder.js",
"bin-debug/Fgui/loading/UI_View_loading.js",
"bin-debug/Fgui/sc/scBinder.js",
"bin-debug/Fgui/sc/UI_btn_sc.js",
"bin-debug/Fgui/sc/UI_combo_sc_popup.js",
"bin-debug/Fgui/sc/UI_View_sc.js",
"bin-debug/Platform.js",
"bin-debug/Scenes/AnimatedTiles/AnimatedTilesScene.js",
"bin-debug/Scenes/EmptyScene/BasicScene.js",
"bin-debug/Scenes/GOAP/GoapScene.js",
"bin-debug/Scenes/LineCasting/LineCaster.js",
"bin-debug/Scenes/LineCasting/LineCastingScene.js",
"bin-debug/Main.js",
"bin-debug/Scenes/NinjaAdventure/FireballProjectileController.js",
"bin-debug/Scenes/NinjaAdventure/Ninja.js",
"bin-debug/Scenes/NinjaAdventure/NinjaAdventureScene.js",
"bin-debug/ThemeAdapter.js",
"bin-debug/UI/PopManager.js",
"bin-debug/UI/loading/LoadingControl.js",
"bin-debug/UI/loading/LoadingEvents.js",
"bin-debug/AssetAdapter.js",
"bin-debug/Fgui/common/UI_com_tips.js",
"bin-debug/UI/mvc/EventManager.js",
"bin-debug/UI/mvc/Extension.js",
"bin-debug/UI/mvc/FguiUtils.js",
"bin-debug/UI/mvc/LayerManager.js",
"bin-debug/UI/mvc/ViewManager.js",
"bin-debug/UI/sc/ScControl.js",
"bin-debug/UI/sc/ScEvents.js",
"bin-debug/UI/sc/ScView.js"
]
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

-126
View File
@@ -1,126 +0,0 @@
{
"groups": [
{
"keys": "bg_png,bgNorm_png,moon_png,orange_png,moonNorm_png,orangeNorm_png,tiledMap_json,orthogonal-outside_json,tilemap_json,plume_png,cabbage_png",
"name": "preload"
},
{
"keys": "loading",
"name": "loading"
},
{
"keys": "sc",
"name": "sc"
},
{
"keys": "common",
"name": "common"
},
{
"keys": "1_png,2_png,3_png,4_png,5_png,6_png",
"name": "characters"
}
],
"resources": [
{
"url": "preload/bg.png",
"type": "image",
"name": "bg_png"
},
{
"url": "preload/bgNorm.png",
"type": "image",
"name": "bgNorm_png"
},
{
"url": "preload/moon.png",
"type": "image",
"name": "moon_png"
},
{
"url": "preload/orange.png",
"type": "image",
"name": "orange_png"
},
{
"url": "preload/moonNorm.png",
"type": "image",
"name": "moonNorm_png"
},
{
"url": "preload/orangeNorm.png",
"type": "image",
"name": "orangeNorm_png"
},
{
"url": "characters/1.png",
"type": "image",
"name": "1_png"
},
{
"url": "characters/2.png",
"type": "image",
"name": "2_png"
},
{
"url": "characters/3.png",
"type": "image",
"name": "3_png"
},
{
"url": "characters/4.png",
"type": "image",
"name": "4_png"
},
{
"url": "characters/5.png",
"type": "image",
"name": "5_png"
},
{
"url": "characters/6.png",
"type": "image",
"name": "6_png"
},
{
"url": "fgui/common.zip",
"type": "bin",
"name": "common"
},
{
"url": "fgui/sc.zip",
"type": "bin",
"name": "sc"
},
{
"url": "fgui/loading.zip",
"type": "bin",
"name": "loading"
},
{
"url": "preload/caveman/tiledMap.json",
"type": "json",
"name": "tiledMap_json"
},
{
"url": "preload/orthogonal/orthogonal-outside.json",
"type": "json",
"name": "orthogonal-outside_json"
},
{
"url": "preload/ninja/tilemap.json",
"type": "json",
"name": "tilemap_json"
},
{
"url": "preload/plume.png",
"type": "image",
"name": "plume_png"
},
{
"url": "preload/cabbage.png",
"type": "image",
"name": "cabbage_png"
}
]
}
-34
View File
@@ -1,34 +0,0 @@
{
"skins": {
"eui.Button": "resource/eui_skins/ButtonSkin.exml",
"eui.CheckBox": "resource/eui_skins/CheckBoxSkin.exml",
"eui.HScrollBar": "resource/eui_skins/HScrollBarSkin.exml",
"eui.HSlider": "resource/eui_skins/HSliderSkin.exml",
"eui.Panel": "resource/eui_skins/PanelSkin.exml",
"eui.TextInput": "resource/eui_skins/TextInputSkin.exml",
"eui.ProgressBar": "resource/eui_skins/ProgressBarSkin.exml",
"eui.RadioButton": "resource/eui_skins/RadioButtonSkin.exml",
"eui.Scroller": "resource/eui_skins/ScrollerSkin.exml",
"eui.ToggleSwitch": "resource/eui_skins/ToggleSwitchSkin.exml",
"eui.VScrollBar": "resource/eui_skins/VScrollBarSkin.exml",
"eui.VSlider": "resource/eui_skins/VSliderSkin.exml",
"eui.ItemRenderer": "resource/eui_skins/ItemRendererSkin.exml"
},
"autoGenerateExmlsList": true,
"exmls": [
"resource/eui_skins/ButtonSkin.exml",
"resource/eui_skins/CheckBoxSkin.exml",
"resource/eui_skins/HScrollBarSkin.exml",
"resource/eui_skins/HSliderSkin.exml",
"resource/eui_skins/ItemRendererSkin.exml",
"resource/eui_skins/PanelSkin.exml",
"resource/eui_skins/ProgressBarSkin.exml",
"resource/eui_skins/RadioButtonSkin.exml",
"resource/eui_skins/ScrollerSkin.exml",
"resource/eui_skins/TextInputSkin.exml",
"resource/eui_skins/ToggleSwitchSkin.exml",
"resource/eui_skins/VScrollBarSkin.exml",
"resource/eui_skins/VSliderSkin.exml"
],
"path": "resource/default.thm.json"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

-193
View File
@@ -1,193 +0,0 @@
{ "height":30,
"infinite":false,
"layers":[
{
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 2147483652, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"height":30,
"id":1,
"name":"main",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":40,
"x":0,
"y":0
},
{
"draworder":"topdown",
"id":2,
"name":"objects",
"objects":[
{
"height":14.8796,
"id":6,
"name":"spawn",
"rotation":0,
"type":"",
"visible":true,
"width":14.8796,
"x":48.4346,
"y":240.503
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}],
"nextlayerid":3,
"nextobjectid":7,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.2.1",
"tileheight":16,
"tilesets":[
{
"columns":2,
"firstgid":1,
"image":"tileset.png",
"imageheight":32,
"imagewidth":32,
"margin":0,
"name":"tileset",
"spacing":0,
"tilecount":4,
"tileheight":16,
"tiles":[
{
"id":0,
"objectgroup":
{
"draworder":"index",
"name":"",
"objects":[
{
"height":16,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
}
},
{
"id":2,
"objectgroup":
{
"draworder":"index",
"name":"",
"objects":[
{
"height":3,
"id":1,
"name":"",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
},
"properties":[
{
"name":"filewtf",
"type":"file",
"value":""
},
{
"name":"floaty",
"type":"float",
"value":0
},
{
"name":"inty",
"type":"int",
"value":0
},
{
"name":"nez:isOneWayPlatform",
"type":"bool",
"value":true
},
{
"name":"poop",
"type":"color",
"value":""
}]
},
{
"id":3,
"objectgroup":
{
"draworder":"index",
"name":"",
"objects":[
{
"height":0,
"id":1,
"name":"",
"polygon":[
{
"x":0,
"y":0
},
{
"x":0,
"y":16
},
{
"x":16,
"y":16
}],
"rotation":0,
"type":"",
"visible":true,
"width":0,
"x":0,
"y":0
}],
"opacity":1,
"type":"objectgroup",
"visible":true,
"x":0,
"y":0
},
"properties":[
{
"name":"nez:isSlope",
"type":"bool",
"value":true
},
{
"name":"nez:slopeTopLeft",
"type":"int",
"value":0
},
{
"name":"nez:slopeTopRight",
"type":"int",
"value":15
}]
}],
"tilewidth":16
}],
"tilewidth":16,
"type":"map",
"version":1.2,
"width":40
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

-452
View File
@@ -1,452 +0,0 @@
/**
* ResourceManager
*/
type ResourceManagerConfig = {
/**
*
*/
buildConfig: (param: BuildConfigParam) => UserConfig,
/**
*
*/
typeSelector: (path: string) => (string | null | undefined)
/**
*
*/
mergeSelector?: (path: string) => (string | null | undefined),
/**
*
* beta 使
*/
nameSelector?: (path: string) => (string | null | undefined)
}
/**
*
*/
type UserConfig = {
/**
*
*/
outputDir: string,
/**
*
*/
commands: (string | plugins.Command)[]
}
type BuildConfigParam = {
/**
* build command
*/
readonly command: string;
/**
*
*/
readonly target: string;
/**
*
*/
readonly version: string;
/**
*
*/
readonly projectName: string;
/**
*
*/
readonly projectRoot: string;
/**
*
*/
readonly projectConfig: ProjectConfig;
}
type ProjectConfig = {
entryClassName: string;
orientation: string;
frameRate: number;
scaleMode: string;
contentWidth: number;
contentHeight: number;
showFPS: boolean;
fpsStyles: string;
showLog: boolean;
maxTouches: number;
}
/**
* from to
* from glob , to [path][name][hash][ext]
* { from:"resource/**.*" , to:"[path][name]_[hash].[ext]" }
*/
type Matcher = {
from: string,
to: string
}
declare namespace plugins {
interface CommandContext {
/**
*
*/
createFile(relativeFilePath: string, contents: Buffer);
/**
*
*/
buildConfig: BuildConfigParam;
/**
*
*/
projectRoot: string;
/**
*
*/
outputDir: string;
}
/**
* 线
*/
interface Command {
/**
* file null 线
*/
onFile?(file: File): Promise<File | null>
/**
*
*
*/
onFinish?(pluginContext?: CommandContext): Promise<void>
[options: string]: any;
}
interface File {
/**
*
*/
contents: Buffer;
/**
*
*/
path: string;
/**
*
*/
readonly base: string;
/**
* base
*/
readonly relative: string;
/**
* history[0] origin
*/
readonly history: ReadonlyArray<string>;
/**
*
*/
readonly dirname: string;
/**
*
*/
readonly basename: string;
/**
*
*/
readonly extname: string;
/**
*
*/
readonly origin: string;
/**
*
*/
[customProperty: string]: any;
}
}
declare module 'built-in' {
/**
*
*/
type UglifyPluginOption = { sources: string[], target: string };
type UglifyPluginOptions = UglifyPluginOption[];
/**
*
*/
export class UglifyPlugin implements plugins.Command {
constructor(mergeSelector: UglifyPluginOptions);
}
type LibraryType = "debug" | "release";
type CompilePluginOptions = { libraryType: LibraryType, defines?: any };
/**
*
*/
export class CompilePlugin implements plugins.Command {
constructor(options: CompilePluginOptions);
}
/**
* EXML EXML
*/
export class ExmlPlugin implements plugins.Command {
constructor(publishPolicy: EXML_Publish_Policy);
}
/**
*
* * debug : 默认策略
* * contents : EXML
* * gjs : 将生成的JS文件写入到主题文件中
* * commonjs : 将EXML合并为一个 CommonJS
* * commonjs2 : 将EXML合并为一个含有解析方法和皮肤定义的文件
* * json : 将每个EXML文件生成一份配置
*/
type EXML_Publish_Policy = "debug" | "contents" | "gjs" | "commonjs" | "commonjs2" | "json"
/**
* manifest JavaScript
*/
export class ManifestPlugin implements plugins.Command {
constructor(options?: ManifestPluginOptions)
}
/**
*
* json js
*/
type ManifestPluginOptions = {
output: string,
hash?: "crc32",
/**
*
*/
verbose?: boolean,
/**
*
*/
info?:any
/**
* use wechat engine plugin
*/
useWxPlugin?: boolean
/**
* use QQgame engine plugin
*/
qqPlugin?: { use: boolean, pluginList: string[] }
}
/**
* EmitResConfigFilePlugin
* * output: 生成路径 *.res.js *.res.json
* * typeSelector: 根据文件路径决定文件类型
* * nameSelector: 根据文件路径决定文件的资源名
* * groupSelector: 根据文件路径决定资源所述的资源组
*/
type EmitResConfigFilePluginOptions = {
output: string,
typeSelector: (path: string) => string | null | undefined,
nameSelector: (path: string) => string | null | undefined,
groupSelector: (path: string) => string | null | undefined,
}
/**
* res.json res.js
*/
export class EmitResConfigFilePlugin implements plugins.Command {
constructor(options: EmitResConfigFilePluginOptions)
}
export type ConvertResourceConfigPluginOption = {
resourceConfigFiles: { filename: string, root: string }[];
nameSelector: (url: string) => string;
TM_Verbose: boolean;
}
export class ConvertResConfigFilePlugin implements plugins.Command {
constructor(options: ConvertResourceConfigPluginOption);
}
/**
*
* JavaScript 线 js
* watch
*/
export class IncrementCompilePlugin implements plugins.Command {
}
type TextureMergerOptions = {
textureMergerRoot: string[];
}
/**
* 使 TextureMerger TextureMerger 1.7
*/
export class TextureMergerPlugin implements plugins.Command {
constructor(options: TextureMergerOptions);
}
type CleanPluginOptions = {
matchers: string[]
}
export class CleanPlugin implements plugins.Command {
constructor(options: CleanPluginOptions);
}
type RenamePluginOptions = {
/**
*
* Whether to output the log
*/
verbose?: boolean
/**
* hash crc32
* What hash algorithm is used, currently only crc32 is supported
*/
hash?: "crc32"
/**
*
*
* Set up matching rules to copy specified files to other folders
* This parameter is an array that allows multiple matching rules to be set
*/
matchers: Matcher[]
/**
*
* The callback function, return value includes some information about the file
*/
callback?: Function
}
/**
*
*/
export class RenamePlugin implements plugins.Command {
constructor(options: RenamePluginOptions);
}
type ResSplitPluginOptions = {
/**
*
* Whether to output the log
*/
verbose?: boolean
/**
*
*
* Set up matching rules to copy specified files to other folders
* This parameter is an array that allows multiple matching rules to be set
*/
matchers: Matcher[]
}
export class ResSplitPlugin implements plugins.Command {
constructor(options: ResSplitPluginOptions);
}
type ZipPluginOptions = {
mergeSelector: (p: string) => string
}
export class ZipPlugin implements plugins.Command {
constructor(option: ZipPluginOptions);
}
type MergeEuiJsonPluginOptions = {
mergeSelector?: (p: string) => string | null,
createConfig?: boolean
}
export class MergeEuiJsonPlugin implements plugins.Command {
constructor(option?: MergeEuiJsonPluginOptions);
}
}
-82
View File
@@ -1,82 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
export class BaidugamePlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "game.js");
if(!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布百度小游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "game.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.deviceOrientation = orientation;
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
}
}
-64
View File
@@ -1,64 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
type ManifestConfig = {
initial: string[],
game: string[]
}
export class BricksPlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
const filename = file.basename;
if (filename == 'manifest.json') {
const contents = file.contents.toString();
const jsonData: ManifestConfig = JSON.parse(contents);
let content = '';
content += `BK.Script.loadlib("GameRes://js/promise.js");\n`;
for (let item of jsonData.initial) {
if (item != 'js/promise.js' && item != 'js/promise.min.js') {
content += `BK.Script.loadlib("GameRes://${item}");\n`
}
}
for (let item of jsonData.game) {
content += `BK.Script.loadlib("GameRes://${item}");\n`
}
content += `BK.Script.loadlib("GameRes://egret.bricks.js");\n`
file.path = file.dirname + '/manifest.js'
file.contents = new Buffer(content);
} else if (filename == 'main.js') {
const content = file.contents.toString();
let result = content.replace(/RES\.loadConfig\("resource\/default\.res\.json", "resource\/"\)/gm, 'RES.loadConfig("GameRes://resource/default.res.json", "GameRes://resource/")');
result = result.replace(/eui\.Theme\("resource\/default\.thm\.json", _this\.stage\)/gm, 'eui.Theme("GameRes://resource/default.thm.json", _this.stage)');
result += ";global.Main = Main;";
file.path = file.dirname + '/main.js'
file.contents = new Buffer(result);
} else if (filename == 'promise.js') {
return null;
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步index.html 配置到main.js
let mainJSPath = path.join(pluginContext.outputDir, 'main.js');
let mainJSContent = fs.readFileSync(mainJSPath, { encoding: "utf8" });
let projectConfig = pluginContext.buildConfig.projectConfig;
mainJSContent = mainJSContent.replace(/frameRate: 30/gm, `frameRate: ${projectConfig.frameRate}`);
mainJSContent = mainJSContent.replace(/contentWidth: 640/gm, `contentWidth: ${projectConfig.contentWidth}`);
mainJSContent = mainJSContent.replace(/contentHeight: 1136/gm, `contentHeight: ${projectConfig.contentHeight}`);
mainJSContent = mainJSContent.replace(/entryClassName: "Main"/gm, `entryClassName: ${projectConfig.entryClassName}`);
mainJSContent = mainJSContent.replace(/scaleMode: "showAll"/gm, `scaleMode: ${projectConfig.scaleMode}`);
mainJSContent = mainJSContent.replace(/orientation: "auto"/gm, `orientation: ${projectConfig.orientation}`);
fs.writeFileSync(mainJSPath, mainJSContent);
}
}
declare var egret;
-52
View File
@@ -1,52 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_android/assets/game`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new ManifestPlugin({ output: 'manifest.json' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.json' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-63
View File
@@ -1,63 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import { BaidugamePlugin } from './baidugame/baidugame';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_baidugame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new BaidugamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new BaidugamePlugin(),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-55
View File
@@ -1,55 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import { BricksPlugin } from './bricks/bricks';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_bricks/PublicBrickEngineGame/Res`;
if (command == 'build') {
return {
outputDir,
commands: [
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new ManifestPlugin({ output: 'manifest.json' }),
new BricksPlugin()
]
}
}
else if (command == 'publish') {
console.log('执行publish')
return {
outputDir,
commands: [
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new ManifestPlugin({ output: 'manifest.json' }),
new UglifyPlugin([{
sources: ["main.js"],
target: "js/main.min.js"
}
]),
new BricksPlugin(),
]
}
} else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-52
View File
@@ -1,52 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_ios/assets/game`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new ManifestPlugin({ output: 'manifest.json' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.json' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-63
View File
@@ -1,63 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import { MygamePlugin } from './mygame/mygame';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_mygame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new MygamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new MygamePlugin(),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-62
View File
@@ -1,62 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in';
import { OppogamePlugin } from './oppogame/oppogame';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_oppogame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new OppogamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new OppogamePlugin(),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-62
View File
@@ -1,62 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in';
import { MiqgamePlugin } from './qgame/qgame';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_qgame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new MiqgamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new MiqgamePlugin(),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-65
View File
@@ -1,65 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import { QQgamePlugin } from './qqgame/qqgame';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
//是否使用QQ小游戏引擎插件
const useQQPlugin: boolean = false;
let pluginList: string[] = []
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_qqgame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new QQgamePlugin(useQQPlugin, pluginList),
new ManifestPlugin({ output: 'manifest.js', qqPlugin: { use: useQQPlugin, pluginList: pluginList } })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new QQgamePlugin(useQQPlugin, pluginList),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js', qqPlugin: { use: useQQPlugin, pluginList: pluginList } })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-95
View File
@@ -1,95 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, IncrementCompilePlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, RenamePlugin } from 'built-in';
import { WxgamePlugin } from './wxgame/wxgame';
import { BricksPlugin } from './bricks/bricks';
import { CustomPlugin } from './myplugin';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
if (command == 'build') {
const outputDir = '.';
return {
outputDir,
commands: [
// new EmitResConfigFilePlugin({
// output: "resource/default.res.json",
// typeSelector: config.typeSelector,
// nameSelector: p => path.basename(p).replace(/\./gi, "_"),
// groupSelector: p => "preload"
// }),
new ExmlPlugin('debug'), // 非 EUI 项目关闭此设置
new IncrementCompilePlugin(),
]
}
}
else if (command == 'publish') {
const outputDir = `bin-release/web/${version}`;
return {
outputDir,
commands: [
new CustomPlugin(),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}]),
new RenamePlugin({
verbose: true, hash: 'crc32', matchers: [
{ from: "**/*.js", to: "[path][name]_[hash].[ext]" }
]
}),
new ManifestPlugin({ output: "manifest.json" })
]
}
}
else {
throw `unknown command : ${params.command}`
}
},
mergeSelector: (path) => {
if (path.indexOf("assets/bitmap/") >= 0) {
return "assets/bitmap/sheet.sheet"
}
else if (path.indexOf("armature") >= 0 && path.indexOf(".json") >= 0) {
return "assets/armature/1.zip";
}
},
typeSelector: (path) => {
const ext = path.substr(path.lastIndexOf(".") + 1);
const typeMap = {
"jpg": "image",
"png": "image",
"webp": "image",
"json": "json",
"fnt": "font",
"pvr": "pvr",
"mp3": "sound",
"zip": "zip",
"sheet": "sheet",
"exml": "text"
}
let type = typeMap[ext];
if (type == "json") {
if (path.indexOf("sheet") >= 0) {
type = "sheet";
} else if (path.indexOf("movieclip") >= 0) {
type = "movieclip";
};
}
return type;
}
}
export = config;
-62
View File
@@ -1,62 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in';
import { VivogamePlugin } from './vivogame/vivogame';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_vivogame/src`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["../engine/js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new VivogamePlugin(),
new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["../engine/js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new VivogamePlugin(),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-65
View File
@@ -1,65 +0,0 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import { WxgamePlugin } from './wxgame/wxgame';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
//是否使用微信分离插件
const useWxPlugin: boolean = false;
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_wxgame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource", "egret-library"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new WxgamePlugin(useWxPlugin),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource", "egret-library"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new WxgamePlugin(useWxPlugin),
new UglifyPlugin([
// 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置
// {
// sources: ["resource/default.thm.js"],
// target: "default.thm.min.js"
// },
{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js', useWxPlugin: useWxPlugin })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
-82
View File
@@ -1,82 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
export class MygamePlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "game.js");
if (!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布支付宝小游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "game.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.deviceOrientation = orientation;
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
}
}
-17
View File
@@ -1,17 +0,0 @@
/**
* http://developer.egret.com/cn/github/egret-docs/Engine2D/projectConfig/cmdExtensionPlugin/index.html
*
*/
export class CustomPlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
return file;
}
async onFinish(commandContext: plugins.CommandContext) {
}
}
-4209
View File
File diff suppressed because it is too large Load Diff
-90
View File
@@ -1,90 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
export class OppogamePlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
if(filename == "libs/modules/eui/eui.js"){
content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds");
content = content.replace("function getIds","window.getIds=function getIds");
content = content.replace("function toXMLString","window.toXMLString=function toXMLString");
content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations");
content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr");
}
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "main.js");
if(!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布Oppo快游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.orientation = orientation;
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
}
}
-90
View File
@@ -1,90 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
export class MiqgamePlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
if(filename == "libs/modules/eui/eui.js"){
content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds");
content = content.replace("function getIds","window.getIds=function getIds");
content = content.replace("function toXMLString","window.toXMLString=function toXMLString");
content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations");
content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr");
}
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "main.js");
if(!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布小米快游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.orientation = orientation;
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
}
}
-118
View File
@@ -1,118 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
export class QQgamePlugin implements plugins.Command {
private useQQPlugin: boolean = false;
private pliginList: string[] = [];//qq engine plugin
constructor(useQQPlugin: boolean, pliginList: string[]) {
this.useQQPlugin = useQQPlugin
this.pliginList = pliginList
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (this.useQQPlugin) {
const basename = file.basename
//QQ 小游戏引擎插件,支持下列官方库
let engineJS = ['assetsmanager', 'dragonBones', 'egret', 'game', 'eui', 'socket', 'tween']
for (let i in engineJS) {
let jsName = engineJS[i]
if (basename == jsName + ".js" || basename == jsName + ".min.js") {
this.pliginList.push(`requirePlugin("egret-library/${jsName}.min.js")`);
return null
}
}
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
let { projectRoot, outputDir, buildConfig } = pluginContext
//同步 index.html 配置到 game.js
const gameJSPath = path.join(outputDir, "game.js");
if (!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布QQ小游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(outputDir, "game.json");
let gameJSONContent = this.readData(gameJSONPath);
gameJSONContent.deviceOrientation = orientation;
if (!gameJSONContent.plugins) {
gameJSONContent.plugins = {}
}
if (!this.useQQPlugin) {
delete gameJSONContent.plugins["egret-library"]
} else {
let engineVersion = this.readData(path.join(projectRoot, "egretProperties.json")).engineVersion;
gameJSONContent.plugins["egret-library"] = {
"provider": "1110108620",
"version": engineVersion
}
}
this.writeData(gameJSONContent, gameJSONPath)
}
readData(filePath: string): any {
return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" }));
}
writeData(data: object, filePath: string) {
fs.writeFileSync(filePath, JSON.stringify(data, null, "\t"));
}
}
-50
View File
@@ -1,50 +0,0 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
"lib": [
"es5",
"es2015.promise"
], /* Specify library files to be included in the compilation: */
"allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
/* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}
-126
View File
@@ -1,126 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
export class VivogamePlugin implements plugins.Command {
jsFileList: any = []
constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
this.jsFileList.push(file.basename)
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
if (filename == "libs/modules/eui/eui.js") {
content = content.replace("function getRepeatedIds", "window.getRepeatedIds=function getRepeatedIds");
content = content.replace("function getIds", "window.getIds=function getIds");
content = content.replace("function toXMLString", "window.toXMLString=function toXMLString");
content = content.replace("function checkDeclarations", "window.checkDeclarations=function checkDeclarations");
content = content.replace("function getPropertyStr", "window.getPropertyStr=function getPropertyStr");
}
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "game.js");
if (!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布 Vivo 小游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.deviceOrientation = orientation;
let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion
if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={}
gameJSONContent.thirdEngine.egret = engineVersion
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
let isPublish = pluginContext.buildConfig.command == "publish" ? true : false;
let configArr: any[] = []
for (var i = 0, len = this.jsFileList.length; i < len; i++) {
let jsFile = this.jsFileList[i];
if (isPublish) {
if (jsFile == "main.js") {
jsFile = 'main.min.js'
} else if (jsFile == "default.thm.js") {
jsFile = "default.thm.min.js"
}
}
configArr.push(JSON.stringify({
module_name: `./js/${jsFile}`,
module_path: `./js/${jsFile}`,
module_from: `engine/js/${jsFile}`,
}, null, "\t"))
}
const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----';
const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js");
if(!fs.existsSync(minigameConfigPath)){
//5.2.28版本,vivo更新了项目结构,老项目需要升级
fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目");
}else{
let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" });
configJSContent = configJSContent.replace(reg, replaceConfigStr);
fs.writeFileSync(minigameConfigPath, configJSContent);
}
}
readData(filePath: string): any {
return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" }));
}
}
-149
View File
@@ -1,149 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
const crypto = require('crypto');
export class WxgamePlugin implements plugins.Command {
private useWxPlugin:boolean = false;
constructor(useWxPlugin:boolean) {
this.useWxPlugin = useWxPlugin
}
md5Obj = {}
md5(content) {
let md5 = crypto.createHash('md5');
return md5.update(content).digest('hex');
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
this.md5Obj[path.basename(filename)] = this.md5(content)
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
if (filename == 'libs/long/long.js' || filename == 'libs/long/long.min.js'){
content += "window.Long = long;"
}
this.md5Obj[path.basename(filename)] = this.md5(content)
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
let { projectRoot, outputDir, buildConfig } = pluginContext
//同步 index.html 配置到 game.js
const gameJSPath = path.join(outputDir, "game.js");
if (!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布微信小游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(outputDir, "game.json");
let gameJSONContent = this.readData(gameJSONPath)
gameJSONContent.deviceOrientation = orientation;
if (buildConfig.command !== "publish" && gameJSONContent.plugins && gameJSONContent.plugins['egret-library']) {
delete gameJSONContent.plugins["egret-library"]
}
this.writeData(gameJSONContent, gameJSONPath)
//下面的流程是配置开启微信插件的功能
let engineVersion = this.readData(path.join(projectRoot, "egretProperties.json")).engineVersion;
if (!gameJSONContent.plugins) {
gameJSONContent.plugins = {}
}
if(buildConfig.command == "publish" && this.useWxPlugin){
gameJSONContent.plugins["egret-library"] = {
"provider": "wx7e2186943221985d",
"version": engineVersion,
"path": "egret-library"
}
}else{
gameJSONContent.plugins = {}
}
this.writeData(gameJSONContent, gameJSONPath)
if (buildConfig.command !== "publish" || !this.useWxPlugin) {
return
}
let libDir = path.join(outputDir, "egret-library")
fs.mkdirSync(libDir)
let pluginData = { "main": "index.js" }
this.writeData(pluginData, path.join(libDir, "plugin.json"))
let engineJS = ['assetsmanager', 'dragonBones', 'egret', 'game', 'eui', 'socket', 'tween']
let signatureData: any = {
"provider": "wx7e2186943221985d",
"signature": []
}
for (let i in engineJS) {
let name = engineJS[i] + '.min.js'
if (this.md5Obj[name]) {
let jsInfo: any = {
"path": name,
"md5": this.md5Obj[name]
}
signatureData.signature.push(jsInfo)
}
}
this.writeData(signatureData, path.join(libDir, "signature.json"))
fs.writeFileSync(path.join(libDir, "index.js"), null);
}
readData(filePath: string): any {
return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" }));
}
writeData(data: object, filePath: string) {
fs.writeFileSync(filePath, JSON.stringify(data, null, "\t"));
}
}
-56
View File
@@ -1,56 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
class AssetAdapter implements eui.IAssetAdapter {
/**
* @language zh_CN
*
* @param source
* @param compFunc callBack(content:any,source:string):void;
* @param thisObject callBack的 this
*/
public getAsset(source: string, compFunc:Function, thisObject: any): void {
function onGetRes(data: any): void {
compFunc.call(thisObject, data, source);
}
if (RES.hasRes(source)) {
let data = RES.getRes(source);
if (data) {
onGetRes(data);
}
else {
RES.getResAsync(source, onGetRes, this);
}
}
else {
RES.getResByUrl(source, onGetRes, this, RES.ResourceItem.TYPE_IMAGE);
}
}
}
-19
View File
@@ -1,19 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.common {
export class UI_com_tips extends fairygui.GComponent {
public m_content:fairygui.GTextField;
public static URL:string = "ui://minsdstak7mf0";
public static createInstance():UI_com_tips {
return <UI_com_tips>(fairygui.UIPackage.createObject("common", "com_tips"));
}
protected constructFromXML(xml:any):void {
super.constructFromXML(xml);
this.m_content = <fairygui.GTextField>(this.getChildAt(1));
}
}
}
-10
View File
@@ -1,10 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.common {
export class commonBinder {
public static bindAll():void {
fairygui.UIObjectFactory.setPackageItemExtension(UI_com_tips.URL, UI_com_tips);
}
}
}
-21
View File
@@ -1,21 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.loading {
export class UI_View_loading extends fairygui.GComponent {
public m_title:fairygui.GTextField;
public m_pg_loading:fairygui.GProgressBar;
public static URL:string = "ui://mk2d64e7r5ro0";
public static createInstance():UI_View_loading {
return <UI_View_loading>(fairygui.UIPackage.createObject("loading", "View_loading"));
}
protected constructFromXML(xml:any):void {
super.constructFromXML(xml);
this.m_title = <fairygui.GTextField>(this.getChildAt(1));
this.m_pg_loading = <fairygui.GProgressBar>(this.getChildAt(2));
}
}
}
-10
View File
@@ -1,10 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.loading {
export class loadingBinder {
public static bindAll():void {
fairygui.UIObjectFactory.setPackageItemExtension(UI_View_loading.URL, UI_View_loading);
}
}
}
-21
View File
@@ -1,21 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.sc {
export class UI_View_sc extends fairygui.GComponent {
public m_list_sc:fairygui.GList;
public m_combo_transition:fairygui.GComboBox;
public static URL:string = "ui://m4sln17ak7mf0";
public static createInstance():UI_View_sc {
return <UI_View_sc>(fairygui.UIPackage.createObject("sc", "View_sc"));
}
protected constructFromXML(xml:any):void {
super.constructFromXML(xml);
this.m_list_sc = <fairygui.GList>(this.getChildAt(0));
this.m_combo_transition = <fairygui.GComboBox>(this.getChildAt(1));
}
}
}
-19
View File
@@ -1,19 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.sc {
export class UI_btn_sc extends fairygui.GButton {
public m_name:fairygui.GTextField;
public static URL:string = "ui://m4sln17ak7mf2";
public static createInstance():UI_btn_sc {
return <UI_btn_sc>(fairygui.UIPackage.createObject("sc", "btn_sc"));
}
protected constructFromXML(xml:any):void {
super.constructFromXML(xml);
this.m_name = <fairygui.GTextField>(this.getChildAt(3));
}
}
}
-19
View File
@@ -1,19 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.sc {
export class UI_combo_sc_popup extends fairygui.GComponent {
public m_list:fairygui.GList;
public static URL:string = "ui://m4sln17ajde14";
public static createInstance():UI_combo_sc_popup {
return <UI_combo_sc_popup>(fairygui.UIPackage.createObject("sc", "combo_sc_popup"));
}
protected constructFromXML(xml:any):void {
super.constructFromXML(xml);
this.m_list = <fairygui.GList>(this.getChildAt(1));
}
}
}
-12
View File
@@ -1,12 +0,0 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.sc {
export class scBinder {
public static bindAll():void {
fairygui.UIObjectFactory.setPackageItemExtension(UI_combo_sc_popup.URL, UI_combo_sc_popup);
fairygui.UIObjectFactory.setPackageItemExtension(UI_View_sc.URL, UI_View_sc);
fairygui.UIObjectFactory.setPackageItemExtension(UI_btn_sc.URL, UI_btn_sc);
}
}
}
-70
View File
@@ -1,70 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
import LoadingView = loading.LoadingView;
class Main extends es.Core {
protected initialize() {
try {
es.Core.debugRenderEndabled = true;
es.TimeRuler.Instance.showLog = true;
this.runGame();
} catch(err) {
console.error(err);
}
}
private runGame() {
egret.ImageLoader.crossOrigin = "anonymous";
this.initUIConfig();
this.loadResource();
this.initGameControl();
}
private initUIConfig(){
LayerManager.getInstance().init(this.stage);
FguiUtils.packageNamespace = FUI;
fairygui.UIConfig.defaultFont = "黑体";
fairygui.UIConfig.bringWindowToFrontOnClick = false;
this.stage.addChild(fgui.GRoot.inst.displayListContainer);
}
private loadResource() {
RES.loadConfig("resource/default.res.json", "resource/").then(()=>{
EventManager.getInstance().dispatch(loading.LoadingEvents.OPENVIEW);
}).catch(err =>{
console.error(err);
});
}
private initGameControl(){
loading.LoadingControl.getInstance();
sc.ScControl.getInstance();
}
}
-41
View File
@@ -1,41 +0,0 @@
/**
*
*
*
* Promise
*/
declare interface Platform {
getUserInfo(): Promise<any>;
login(): Promise<any>
}
class DebugPlatform implements Platform {
async getUserInfo() {
return { nickName: "username" }
}
async login() {
}
}
if (!window.platform) {
window.platform = new DebugPlatform();
}
declare let platform: Platform;
declare interface Window {
platform: Platform
}
-27
View File
@@ -1,27 +0,0 @@
module samples {
import ScreenSpaceRenderer = es.ScreenSpaceRenderer;
import RenderLayerExcludeRenderer = es.RenderLayerExcludeRenderer;
import SpriteRenderer = es.SpriteRenderer;
export class SampleScene extends es.Scene {
public static readonly screenSpaceRenderLayer = 999;
public static _needsFullRender: boolean;
public _screenSpaceRenderer: ScreenSpaceRenderer;
constructor(addExcludeRenderer: boolean = true, needsFullRender: boolean = false){
super();
SampleScene._needsFullRender = needsFullRender;
if (needsFullRender){
this._screenSpaceRenderer = this.addRenderer(new ScreenSpaceRenderer(100, SampleScene.screenSpaceRenderLayer));
this._screenSpaceRenderer.shouldDebugRender = false;
}else{
this.addRenderer(new ScreenSpaceRenderer(100, SampleScene.screenSpaceRenderLayer));
}
if (addExcludeRenderer)
this.addRenderer(new RenderLayerExcludeRenderer(0, SampleScene.screenSpaceRenderLayer));
}
}
}
@@ -1,21 +0,0 @@
module samples {
export class AnimatedTilesScene extends SampleScene {
constructor(){
super(true, true);
}
public initialize(){
super.initialize();
let tiledEntity = this.createEntity("tiled-map-entity");
try {
es.TiledMapLoader.loadTmxMap(new es.TmxMap(), "orthogonal-outside_json").then(map => {
tiledEntity.addComponent(new es.TiledMapRenderer(map));
manager.AlterManager.alter_tips("Tiled tiles场景加载成功");
});
} catch (err){
console.error(err);
}
}
}
}
-27
View File
@@ -1,27 +0,0 @@
module samples {
export class BasicScene extends SampleScene {
public async onStart() {
super.onStart();
manager.AlterManager.alter_tips("空白场景加载成功");
this.content.loadRes("moon_png").then(moonTexture => {
let moonEntity = this.createEntity("moon");
moonEntity.position = new es.Vector2(0, 0);
moonEntity.addComponent(new es.SpriteRenderer(moonTexture));
this.camera.entity.addComponent(new es.FollowCamera(moonEntity));
// this.entities.frameAllocate = true;
// this.entities.maxAllocate = 10;
// for (let i = 0; i < 10000; i ++){
// this.createEntity("");
// }
});
}
public update(){
super.update();
// console.log(this.entities.buffer.length);
}
}
}
-117
View File
@@ -1,117 +0,0 @@
module samples {
export class MinerState {
public readonly maxFatigue = 10;
public readonly maxGold = 8;
public readonly maxThirst = 5;
public fatigue: number = 10;
public thirst: number = 0;
public gold: number = 0;
public goldInBank: number = 0;
public currentLocation: Location = Location.home;
}
export class GoapScene extends SampleScene {
public _destinationLocation: Location;
public planner: es.ActionPlanner;
public _actionPlan: es.Action[];
public minerState: MinerState;
public initialize(): void {
super.initialize();
// 在我们做任何事情之前,我们需要一个行动计划
this.planner = new es.ActionPlanner();
this.minerState = new MinerState();
// 设置我们的动作并将它们添加到计划器中
let sleep = new es.Action("sleep");
sleep.setPrecondition("fatigued", true);
sleep.setPostcondition("fatigued", false);
this.planner.addAction(sleep);
let drink = new es.Action("drink");
drink.setPrecondition("thirsty", true);
drink.setPostcondition("thirsty", false);
this.planner.addAction(drink);
let mine = new es.Action("mine");
mine.setPrecondition("hasenoughgold", false);
mine.setPostcondition("hasenoughgold", true);
this.planner.addAction(mine);
let depositGold = new es.Action("depositGold");
depositGold.setPrecondition("hasenoughgold", true);
depositGold.setPostcondition("hasenoughgold", false);
this.planner.addAction(depositGold);
// 制定一个计划,让我们从当前状态运行到目标状态
this._actionPlan = this.planner.plan(this.getWorldState(), this.getGoalState());
if (this._actionPlan != null && this._actionPlan.length > 0){
this.goTo();
console.log(`得到了一个行动计划与${this._actionPlan.length}行动`);
} else {
console.log(`没有满足我们目标的行动计划`);
}
}
private goTo(){
let action = this._actionPlan[this._actionPlan.length - 1].name;
switch (action){
case "sleep":
this._destinationLocation = Location.home;
break;
case "drink":
this._destinationLocation = Location.saloon;
break;
case "mine":
this._destinationLocation = Location.mine;
break;
case "depositeGold":
this._destinationLocation = Location.bank;
break;
}
if (this.minerState.currentLocation == this._destinationLocation){
} else {
this.minerState.currentLocation = Location.inTransit;
}
}
public getWorldState(): es.WorldState {
let worldState = this.planner.createWorldState();
worldState.set("fatigued", this.minerState.fatigue >= this.minerState.maxFatigue);
worldState.set("thirsty", this.minerState.thirst >= this.minerState.maxThirst);
worldState.set("hasenoughgold", this.minerState.gold >= this.minerState.maxGold);
return worldState;
}
public getGoalState(): es.WorldState {
let goalState = this.planner.createWorldState();
if (this.minerState.fatigue >= this.minerState.maxFatigue){
goalState.set("fatigued", false);
} else if(this.minerState.thirst >= this.minerState.maxThirst){
goalState.set("thirsty", false);
} else if(this.minerState.gold >= this.minerState.maxGold){
goalState.set("hasenoughgold", false);
} else {
goalState.set("hasenoughgold", true);
}
return goalState;
}
}
enum Location {
inTransit,
bank,
mine,
home,
saloon,
}
}

Some files were not shown because too many files have changed in this diff Show More