Commit 10b88af5 authored by Master Q's avatar Master Q

几个弹窗和 逻辑之前逻辑修复

parent 54cd56f1
......@@ -262,29 +262,29 @@ module.exports = function(api, options) {
JSXSpreadChild(path) {
throw path.buildCodeFrameError("Spread children are not supported in React.");
},
CallExpression(path, state) {
const node = path.node
if (node.isSkip) return
const calleeName = path.get('callee').toString()
if (targetCalleeName.includes(calleeName)) {
const { line, column } = node.loc.start
// node.arguments.unshift(types.stringLiteral(`filename: (${line}, ${column})`))
const newNode = template.expression(`console.log('%c%s loc: %s', 'color: green', '${state.filename}', %%FILEPOSITION%%)`)({
// DATE: 'new Date().toLocaleString()',//'new Date().toLocaleString()',
FILEPOSITION: `'(${line}, ${column})'`
})
// CallExpression(path, state) {
// const node = path.node
// if (node.isSkip) return
// const calleeName = path.get('callee').toString()
// if (targetCalleeName.includes(calleeName)) {
// const { line, column } = node.loc.start
// // node.arguments.unshift(types.stringLiteral(`filename: (${line}, ${column})`))
// const newNode = template.expression(`console.log('%c%s loc: %s', 'color: green', '${state.filename}', %%FILEPOSITION%%)`)({
// // DATE: 'new Date().toLocaleString()',//'new Date().toLocaleString()',
// FILEPOSITION: `'(${line}, ${column})'`
// })
if (path.findParent(path => path.isJSXElement())) {
path.replaceWith(types.arrayExpression([newNode, node]))
path.skip()
} else {
path.insertBefore(newNode)
}
// if (path.findParent(path => path.isJSXElement())) {
// path.replaceWith(types.arrayExpression([newNode, node]))
// path.skip()
// } else {
// path.insertBefore(newNode)
// }
newNode.isSkip = true
node.isSkip = true
}
},
// newNode.isSkip = true
// node.isSkip = true
// }
// },
JSXElement: {
exit(path, state) {
......
......@@ -42,7 +42,8 @@
background-image: url("https://yun.duiba.com.cn/db_games/activity/game/1550472986/resource/assets/playscene/playscenebg.jpg"); */
}
</style>
<script src="//yun.duiba.com.cn/db_games/libs0924/fyge2020.min.js" crossorigin="anonymous"></script>
<!-- <script src="//yun.duiba.com.cn/db_games/libs0924/fyge2020.min.js" crossorigin="anonymous"></script> -->
<script src="//yun.duiba.com.cn/db_games/libs0924/fyge2044.min.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="ss" style="line-height:0;font-size:0;position: absolute;">
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,9 +3,13 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"sideEffects": [
"./src/Dream"
],
"scripts": {
"dev": "node ./scripts/devServer.js",
"flushRes": "node scripts/flushRes",
"handleLotS": "node scripts/handleLotS",
"handleRes": "node scripts/delRel && node scripts/copyRes && node scripts/imageMin.js",
"upload": "node scripts/upload",
"prod": "npm run handleRes && npm run upload && npm run buildTS",
......@@ -33,6 +37,7 @@
"co": "^4.6.0",
"del": "2.2.1",
"form-data": "^4.0.0",
"md5": "^2.3.0",
"progress": "^2.0.0",
"ts-loader": "^9.4.1",
"typescript": "^4.8.3",
......
{
"groups": [
{
"keys": "DFM1.png,DFMB.png",
"name": "DrawFailModal"
},
{
"keys": "DSM1.png,DSMB.png",
"name": "DrawSucModal"
},
{
"keys": "GOM0.png,GOM1.png,GameOverModalBack.png",
"name": "GameOverModal"
},
{
"keys": "GameResumeModalBack.png,cancelBtn.png,useRightNowBtn.png",
"name": "GameResumeModal"
},
{
"keys": "back.png,bottomAtom.png,gele1.png,player.png,scoreboard-t.png",
"name": "GameScene"
},
{
"keys": "closebtn.png",
"name": "common"
},
{
"keys": "786bf3500cf0986c9678f6b8a8cf24f6.png,b5d5c1070b13deb0230b0efe5c58ee9d.png,ca7b2a497afc6147cc076d55600154bd.png,d64a974a921d32ed81463c918bae137e.png,f49a78c8287be1a92ee75ce3a2b7a512.png",
"name": "countDown"
},
{
"keys": "548342251013e2f832a40380d1855bf5.png,af75d547153d9118b05d4dd8fbcfe022.png,fd0f936244fb973bddf520819997f5ba.png",
"name": "handLottie"
},
{
"keys": "nx1.jpg,ny1.jpg,nz1.jpg,px1.jpg,py1.jpg,pz1.jpg",
"name": "skybox"
},
{
"keys": "产品1.png,产品2.png,产品3.png,产品4.png,产品5.png,产品6.png,产品7.png,产品8.png",
"name": "产品输出"
}
],
"path": "./resource/"
......
const fs = require("fs");
const iconv = require('iconv-lite');
const path = require('path');
const trans = require("./trans");
const md5 = require('md5');
//用于处理带base64图片的lottie文件,取出图片,同名lottie文件夹,写入代码"./src/lotties/"中;
//别再执行,会覆盖
// return
const pathName = "./lotties";
const outPath = "./resource";
//读文件夹
const files = fs.readdirSync(pathName);
//对每个json文件作处理
files.forEach(function (lottiesFileName) {
// console.log(lottiesFileName)
//后缀不是json的,不处理
if (path.extname(lottiesFileName).indexOf(".json") < 0) return;
//用文件名作为类名和资源文件夹名
const cusName = lottiesFileName.substring(0, lottiesFileName.lastIndexOf(".json"));
//读数据
let data = iconv.decode(fs.readFileSync(pathName + "/" + lottiesFileName), "utf-8");//GBK
//反序列化
data = JSON.parse(data);
//存图片
const assets = data.assets;
if (!assets || !assets.length) return;
//删除属性
delete data.assets;
const copyAssets = [];
const imgOutPath = outPath + "/" + cusName;//data.nm
//建文件夹data.nm
if (!fs.existsSync(imgOutPath)) fs.mkdirSync(imgOutPath);
assets.forEach((e) => {
//没有base64数据,可能是嵌套的
if (!e.p) {
copyAssets.push(e);
return
}
let id = e.id;
// let uuid = guid();
// //存图片
const base64 = e.p.replace(/^data:image\/\w+;base64,/, "");//去掉图片base64码前面部分data:image/png;base64
const dataBuffer = /*new Buffer*/Buffer.from(base64, 'base64'); //把base64码转成buffer对象,
//用用到该图片的图层的名字当作图片名,必须是.png结尾,为了图片去重
let name = data.layers.find((l) => l.refId === id);
//没找到图层,
if (!name) {//再往嵌套图层里的找
for (let ii = 0; ii < assets.length; ii++) {
if (!assets[ii].p) {
name = assets[ii].layers.find((l) => l.refId === id);
if (name) break;
}
}
}
//还没找到图层,不处理
if (!name) return
//不用缓存了,直接用md5;
name = md5(base64);
//修改所有的refId
data.layers.forEach((l) => {
l.refId === id && (l.refId = name)
})
//还有嵌套的
assets.forEach((a) => {
if (!a.p) a.layers.forEach((l) => l.refId === id && (l.refId = name));
})
fs.writeFile(imgOutPath + "/" + name + ".png", dataBuffer, () => 0);
});
//如果存在嵌套图层的,assets加回
if (copyAssets.length) data.assets = copyAssets;
//开始删东西
//是否3d
delete data.ddd;
//版本号,版本必须5.6.10,否则可能有问题
delete data.v;
//遍历删除图层东西
for (let i = 0; i < data.layers.length; i++) {
const l = data.layers[i];
//是否3d,后缀,sr,ao,开始时间,混合模式,特效
["ddd", "cl", "sr", "ao", "st", "bm", "ef"].forEach((e) => delete l[e]);
//ks删除
["o", "r", "p", "a", "s"].forEach((e) => {
const d = l.ks[e];
//ix不知道干嘛用,删了
delete d.ix;
//貌似标记0是没有关键帧的,1是有关键帧的
delete d.a;
//删除k里数据,都要用了,不能删,看情况用吧,如果不需要补间的,用Tween拼的,就删掉,不删只是文件大点
// if (d.k.length && typeof d.k[0] == "object") {
// d.k.forEach((ee) => {
// ["i", "o", "ti", "to"/*, "h"*/].forEach((eee) => { delete ee[eee]; })//h需要判断是否是缓动
// })
// }
})
}
//导出代码到src的lotties文件夹,名字就是lottie动画名字,资源名字临时处理了,首页加载动画用图层的nm,bonustime用refid
const endPath = './src/lotties';
if (!fs.existsSync(endPath)) fs.mkdirSync(endPath);
//文件名字修改,中划线变成下划线,中文变拼音
const fileName = trans(cusName/*data.nm*/).replace(/-/g, "_");
//导出对象直接用lottie动画名字
const endFile = `export const ${fileName} = ${JSON.stringify(data, "", "\t")}`;
//文件名字用lottie动画名字
fs.writeFileSync(endPath + "/" + fileName + ".ts", endFile);
console.log("生成文件:" + fileName + ".ts");
});
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -102,7 +102,9 @@ export class DreamDotAni extends Dream.RenderContainer {
}
}
export const Container: OriginalElementWidthEvents = function() {
export const Container: OriginalElementWidthEvents<{
className?: string
}> = function() {
return (
<FYGE.Container>
</FYGE.Container>
......
......@@ -71,6 +71,11 @@ export function createElement<K extends new(p?: any) => ChildType, T extends Chi
throw TypeError(`class ${ConstructType} must extends RenderContainer or FYGE.Container...`)
}
if (props.className) {
// @ts-ignore
eleins['className'] = props.className
}
const ref = props.ref
if (typeof ref === 'function') {
nextTick(function() {
......
import { addChildFromParent, createElement } from "./development";
import { RenderContainer } from "./renderContainer";
import { EventsMap } from "./types";
import { nextTick } from "./utils";
export type DreamFC<T extends Record<string, any> = {}, R extends any = FYGE.Container> = (props: {
ref?: (c: R) => void,
inlineProps?: Record<string, any>
children?: FYGE.Container[], // 这样写的话,外面也能提示了 -。-
} & T) => FYGE.Container
export type OriginalElementWidthEvents<extraProps={}, T = FYGE.Container> = DreamFC<EventsMap & extraProps, T>
export default {
createElement: createElement,
RenderContainer: RenderContainer,
VirtualRender: addChildFromParent
VirtualRender: addChildFromParent,
nextTick: nextTick
}
\ No newline at end of file
export const ResJson = {
"groups": [
{
"keys": "DFM1.png,DFMB.png",
"name": "DrawFailModal"
},
{
"keys": "DSM1.png,DSMB.png",
"name": "DrawSucModal"
},
{
"keys": "GOM0.png,GOM1.png,GameOverModalBack.png",
"name": "GameOverModal"
},
{
"keys": "GameResumeModalBack.png,cancelBtn.png,useRightNowBtn.png",
"name": "GameResumeModal"
},
{
"keys": "back.png,bottomAtom.png,gele1.png,player.png,scoreboard-t.png",
"name": "GameScene"
},
{
"keys": "closebtn.png",
"name": "common"
},
{
"keys": "786bf3500cf0986c9678f6b8a8cf24f6.png,b5d5c1070b13deb0230b0efe5c58ee9d.png,ca7b2a497afc6147cc076d55600154bd.png,d64a974a921d32ed81463c918bae137e.png,f49a78c8287be1a92ee75ce3a2b7a512.png",
"name": "countDown"
},
{
"keys": "548342251013e2f832a40380d1855bf5.png,af75d547153d9118b05d4dd8fbcfe022.png,fd0f936244fb973bddf520819997f5ba.png",
"name": "handLottie"
},
{
"keys": "nx1.jpg,ny1.jpg,nz1.jpg,px1.jpg,py1.jpg,pz1.jpg",
"name": "skybox"
},
{
"keys": "产品1.png,产品2.png,产品3.png,产品4.png,产品5.png,产品6.png,产品7.png,产品8.png",
"name": "产品输出"
}
],
"path": "./resource/"
......
import { OriginalElementWidthEvents } from "../../Dream"
export const DreamContainer: OriginalElementWidthEvents<{
className?: string
}> = function() {
return new FYGE.Container()
}
\ No newline at end of file
import { OriginalElementWidthEvents } from "../../Dream";
export enum SpriteSizeType {
Contain = 'Contain',
Cover = 'Cover',
Default = 'Default'
}
// TODO SpriteSizeType 有空写下吧
export const DreamSprite: OriginalElementWidthEvents<{
src: string | FYGE.Texture,
width?: number,
height?: number,
sizeType?: SpriteSizeType
}> = (props) => {
const {
src,
width,
height,
sizeType
} = props
let _sp: FYGE.Sprite
if (typeof src === 'string') {
_sp = new FYGE.Sprite()
// 记得改一下 可能是加载过的
FYGE.GlobalLoader.loadImage((s, image) => {
if (s && image) {
const texture = FYGE.Texture.fromImage(image!)
_sp.texture = texture
}
}, src)
} else {
_sp = new FYGE.Sprite(src)
}
width && (_sp.width = width)
height && (_sp.height = height)
return _sp
}
\ No newline at end of file
import { OriginalElementWidthEvents } from "../../Dream";
export const DreamTextField: OriginalElementWidthEvents<{
text: string,
color?: string,
size?: number,
textWidth?: number,
align?: FYGE.TEXT_ALIGN,
bold?: boolean,
textHeight?: number
verticalAlign?: FYGE.VERTICAL_ALIGN
}, FYGE.TextField> = ({
text,
color='#000000',
size=30,
textWidth,
align=FYGE.TEXT_ALIGN.CENTER,
bold=false,
textHeight,
verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE
}) => {
const textIns = new FYGE.TextField()
textIns.fillColor = color;
textIns.size = size;
textWidth && (textIns.textWidth = textWidth);
textIns.textAlign = align;
textIns.text = text;
textIns.bold = bold
textHeight && (textIns.textHeight = textHeight)
textIns.verticalAlign = verticalAlign
return textIns
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import { destroyLayers, layers } from "./modules/layers";
import { SceneController } from "./modules/layers/ctrls";
import { RES } from "./modules/RES";
import { ResJson } from "./ResJson";
import { GameScene } from "./scenes/GameScene/GameScene";
import { HomeScene } from "./scenes/home";
import Tween = FYGE.Tween;
import EventDispatcher = FYGE.EventDispatcher;
......@@ -77,7 +78,7 @@ export class Main {
this.requestID = window.requestAnimationFrame(this.loop);
}
onAddToStage() {
async onAddToStage() {
// const realSceneLayer = new FYGE.Container()
// this.stage.addChild(realSceneLayer)
layers.init(this.stage)
......@@ -86,8 +87,9 @@ export class Main {
SceneController.init(layers.sceneLayer)
RES.loadConfig(ResJson)
await RES.loadGroup('common')
SceneController.changeScene(HomeScene)
SceneController.changeScene(GameScene)
}
initWebEvent(){
......
This diff is collapsed.
This diff is collapsed.
import Dream from "../Dream";
export class ModalComponent<T extends Record<string, any>> extends Dream.RenderContainer<{
closeModal: () => Promise<any>
} & T> {
}
\ No newline at end of file
This diff is collapsed.
......@@ -319,18 +319,21 @@ export namespace RES {
}
type GetResType<T> = T extends `${string}.${'png' | 'jpg'}` ? FYGE.Texture : any
/**
* 获取素材,
* @param str
* @return 已加载好得素材或null
*/
export function getRes(str: string)/*: Texture | VideoEntity*/ {
export function getRes<T extends string>(str: T): GetResType<T> {
if (!str) return null;
var type = str.substring(str.lastIndexOf(".") + 1, str.length);
if (type == "png" || type == "jpg") {
return textureHash[str] || FYGE.TextureCache[str] || null;
}
else if (type == "svga") {
// @ts-ignore
return videoEntityHash[str] || null;
}
else if (type == "mp3") {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment