Skip to content

Commit b3f93be

Browse files
committed
feat(editor): add publish modal ui
as new ui control;
1 parent 1e261ff commit b3f93be

96 files changed

Lines changed: 1378 additions & 63 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contributes/meta3d-action-mod-unit-init/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "meta3d-action-mod-unit-init",
3-
"version": "1.3.34",
3+
"version": "1.3.38",
44
"publisher": "meta3d",
55
"protocol": {
66
"name": "meta3d-action-mod-unit-init-protocol"

contributes/meta3d-action-mod-unit-init/src/Main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,17 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
320320

321321

322322
prop: [],
323+
324+
325+
326+
isShowPublishModal: false,
327+
328+
displayNameCN: "",
329+
displayNameEN: "",
330+
modIconBase64: api.nullable.getEmpty(),
331+
modIconTexture: api.nullable.getEmpty(),
332+
isPublic: false,
333+
description: "",
323334
}
324335
}
325336
}

contributes/meta3d-action-mod-unit-publish-to-game/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "meta3d-action-mod-unit-publish-to-game",
3-
"version": "1.3.11",
3+
"version": "1.3.22",
44
"publisher": "meta3d",
55
"protocol": {
66
"name": "meta3d-action-mod-unit-publish-to-game-protocol"

contributes/meta3d-action-mod-unit-publish-to-game/src/Main.ts

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,36 @@ import { state as meta3dState, getContribute as getContributeMeta3D, api } from
22
// import { language } from "meta3d-action-mod-unit-add-careerfeature-protocol"
33
import { actionContribute, service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
44
import { actionName, state, uiData } from "meta3d-action-mod-unit-publish-to-game-protocol"
5+
import { actionName as initActionName, state as initState } from "meta3d-action-mod-unit-init-protocol"
56
import { eventName, inputData } from "meta3d-action-mod-unit-publish-to-game-protocol/src/EventType"
6-
import { publish } from "meta3d-action-mod-unit-publish-utils/src/Main"
7+
import { publish, getUserName, checkModData, buildUniqueName } from "meta3d-action-mod-unit-publish-utils/src/Main"
8+
import { getLanguageTextData, isChinese } from "meta3d-language-utils/src/Main"
9+
import { languageKey } from "meta3d-language-utils/src/Type"
710

11+
let _checkPublishData = (api: api, meta3dState: meta3dState, { displayNameCN, displayNameEN, description, modIconBase64 }: initState, isChinese: boolean) => {
12+
let message = api.nullable.getEmpty<string>()
13+
14+
if (isChinese && displayNameCN.length <= 0) {
15+
message = api.nullable.return(getLanguageTextData(api, meta3dState, languageKey.NeedDisplayNameCN))
16+
}
17+
else if (!isChinese && displayNameEN.length <= 0) {
18+
message = api.nullable.return(getLanguageTextData(api, meta3dState, languageKey.NeedDisplayNameEN))
19+
}
20+
else if (description.length <= 0) {
21+
message = api.nullable.return(getLanguageTextData(api, meta3dState, languageKey.NeedDescription))
22+
}
23+
else if (api.nullable.isNullable(modIconBase64)) {
24+
message = api.nullable.return(getLanguageTextData(api, meta3dState, languageKey.NeedModIcon))
25+
}
26+
27+
return api.nullable.getWithDefault(
28+
api.nullable.map((message) => {
29+
api.message.warn(message)
30+
return true
31+
}, message),
32+
false
33+
)
34+
}
835

936
export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> = (api) => {
1037
return {
@@ -16,41 +43,36 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
1643

1744
return new Promise((resolve, reject) => {
1845
resolve(eventSourcingService.on<inputData>(meta3dState, eventName, 0, (meta3dState) => {
19-
// let characterType_ = api.action.getActionState<selectCharacterTypeState>(meta3dState, selectCharacterTypeActionName).characterType
20-
// let features = api.action.getActionState<addCareerFeatureState>(meta3dState, addCareerFeatureActionName).allSelectedCareerFeatureData.filter(d => {
21-
// return _isCharacterTypeEqual(d.characterType, characterType_)
22-
// })
23-
24-
// let assetIconBase64 = api.nullable.getWithDefault(
25-
// api.action.getActionState<loadModPreviewState>(meta3dState, loadModPreviewActionName).preview,
26-
// ""
27-
// )
28-
// let careerIconBase64 = api.nullable.getWithDefault(
29-
// api.action.getActionState<loadCareerPreviewState>(meta3dState, loadCareerPreviewActionName).preview,
30-
// ""
31-
// )
46+
console.log("publish mod")
3247

33-
// let isChinese = api.action.getActionState<languageState>(meta3dState, languageActionName).language == language.Chinese
48+
if (_checkPublishData(api, meta3dState, api.action.getActionState<initState>(meta3dState, initActionName), isChinese(api, meta3dState))
49+
|| checkModData(api, [getLanguageTextData, languageKey], meta3dState, api.action.getActionState<initState>(meta3dState, initActionName))
50+
) {
51+
return Promise.resolve(meta3dState)
52+
}
3453

35-
// if (_check(api, api.action.getActionState<state>(meta3dState, actionName), isChinese, features)) {
36-
// return Promise.resolve(meta3dState)
37-
// }
54+
api.flow.deferExec(api, (meta3dState) => {
55+
let initState = api.action.getActionState<initState>(meta3dState, initActionName)
3856

39-
console.log("publish mod")
4057

58+
let author = getUserName(api)
59+
return publish(api,
60+
meta3dState,
61+
buildUniqueName(author, initState.displayNameCN, initState.displayNameEN, isChinese(api, meta3dState)),
62+
author,
63+
initState.displayNameCN,
64+
initState.displayNameEN,
65+
initState.description,
66+
initState.isPublic,
67+
api.nullable.getExn(initState.modIconBase64)
68+
).then(meta3dState => {
69+
meta3dState = api.action.setActionState<initState>(meta3dState, initActionName, {
70+
...api.action.getActionState<initState>(meta3dState, initActionName),
71+
isShowPublishModal: false
72+
})
4173

42-
// meta3dState = api.action.setActionState<state>(meta3dState, actionName, {
43-
// ...api.action.getActionState<state>(meta3dState, actionName),
44-
// isShowModal: false
45-
// })
46-
// meta3dState = api.action.setActionState<infoState>(meta3dState, infoActionName, {
47-
// ...api.action.getActionState<infoState>(meta3dState, infoActionName),
48-
// info: isChinese ? api.nullable.return("正在发布中...") : api.nullable.return("Publishing...")
49-
// })
50-
api.flow.deferExec(api, (meta3dState) => {
51-
let author = "Official"
52-
let name = `unit-test1`
53-
return publish(api, meta3dState, name, author)
74+
return meta3dState
75+
})
5476
})
5577

5678
return Promise.resolve(meta3dState)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
.merlin
3+
.log
4+
.ninja_log
5+
.cmi
6+
.ast
7+
.cmt
8+
.bsdeps
9+
.compiler.log
10+
11+
.idea/
12+
.vscode/
13+
jest_0/
14+
reference/
15+
node_modules/
16+
mine/
17+
dist/
18+
lib/bs/
19+
.bs.js
20+
.gen.tsx
21+
lib/js/
22+
lib/es6_global/
23+
24+
coverage
25+
26+
dist/
27+
28+
npm-debug
29+
30+
.bsb.lock
31+
32+
yarn.lock
33+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var gulp = require("gulp");
2+
var path = require("path");
3+
var fs = require("fs");
4+
var publish = require("meta3d-tool-publish")
5+
var bundle = require("meta3d-tool-bundle-to-custom")
6+
var clipboard = require('clipboardy')
7+
8+
gulp.task("publish_local_env_bundle", function (done) {
9+
let filePath = "./src/Main.ts"
10+
11+
let bundleContent = bundle.bundle(
12+
bundle.getLocalModulePath(
13+
filePath
14+
),
15+
fs.readFileSync(filePath, "utf-8")
16+
)
17+
18+
let clipedBundleContent = `import { api } from "meta3d-type"
19+
import { service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
20+
` + bundleContent
21+
clipedBundleContent = clipedBundleContent.replace(/getContribute\s\=\s\(api\)/g, "getContribute = (api:api)")
22+
23+
clipboard.default.writeSync(
24+
clipedBundleContent
25+
)
26+
27+
28+
29+
publish.publishBundledContribute(
30+
"local",
31+
path.join(__dirname, "package.json"),
32+
bundleContent
33+
).then(() => {
34+
done()
35+
})
36+
});
37+
38+
39+
40+
// gulp.task("publish_local_env", function (done) {
41+
// publish.publishContribute(
42+
// "local",
43+
// path.join(__dirname, "package.json"),
44+
// path.join(__dirname, "dist/static/js", "main.js")
45+
// ).then(() => {
46+
// done()
47+
// })
48+
// });
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// declare module 'asset-loader!*' {
2+
// // const contents: { default: string }
3+
// const contents: string
4+
// // const contents: ArrayBuffer
5+
// export = contents
6+
// }
7+
8+
declare module '*' {
9+
// const contents: { default: string }
10+
const contents: string
11+
// const contents: ArrayBuffer
12+
export = contents
13+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "meta3d-action-mod-unit-show-publish-modal",
3+
"version": "1.3.2",
4+
"publisher": "meta3d",
5+
"protocol": {
6+
"name": "meta3d-action-mod-unit-show-publish-modal-protocol"
7+
},
8+
"license": "MIT",
9+
"scripts": {
10+
"watch": "tsc -w -noEmit",
11+
"webpack": "webpack --config webpack.config.js",
12+
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
13+
"meta3d:publish_dev": "cross-env NODE_ENV=development npm run webpack && gulp publish_local_env_bundle"
14+
},
15+
"keywords": [],
16+
"dependencies": {
17+
"meta3d-action-mod-unit-show-publish-modal-protocol": "^1.3.0",
18+
"meta3d-editor-whole-protocol": "^1.3.0",
19+
"meta3d-type": "^1.3.0"
20+
},
21+
"devDependencies": {
22+
"clean-webpack-plugin": "^4.0.0",
23+
"clipboardy": "^5.0.2",
24+
"cross-env": "^7.0.3",
25+
"cz-customizable": "^6.3.0",
26+
"gulp": "^4.0.2",
27+
"meta3d-tool-publish": "^1.3.0",
28+
"source-map-loader": "^3.0.0",
29+
"ts-loader": "^9.2.6",
30+
"typescript": "^5.1.0",
31+
"webpack": "^5.62.1",
32+
"webpack-cli": "^4.9.1"
33+
}
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { state as meta3dState, getContribute as getContributeMeta3D, api } from "meta3d-type"
2+
// import { language } from "meta3d-action-mod-unit-add-careerfeature-protocol"
3+
import { actionContribute, service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
4+
import { actionName as initActionName, state as initState } from "meta3d-action-mod-unit-init-protocol"
5+
import { actionName, state, uiData } from "meta3d-action-mod-unit-show-publish-modal-protocol"
6+
import { eventName, inputData } from "meta3d-action-mod-unit-show-publish-modal-protocol/src/EventType"
7+
8+
export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> = (api) => {
9+
return {
10+
actionName: actionName,
11+
init: (meta3dState) => {
12+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
13+
14+
return new Promise((resolve, reject) => {
15+
resolve(eventSourcingService.on<inputData>(meta3dState, eventName, 0, (meta3dState) => {
16+
meta3dState = api.action.setActionState<initState>(meta3dState, initActionName, {
17+
...api.action.getActionState<initState>(meta3dState, initActionName),
18+
isShowPublishModal: true
19+
})
20+
21+
return Promise.resolve(meta3dState)
22+
}, (meta3dState) => {
23+
return Promise.resolve(meta3dState)
24+
}))
25+
})
26+
},
27+
handler: (meta3dState, uiData) => {
28+
return new Promise<meta3dState>((resolve, reject) => {
29+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
30+
31+
resolve(eventSourcingService.addEvent<inputData>(meta3dState, {
32+
name: eventName,
33+
isOnlyRead: true,
34+
inputData: []
35+
}))
36+
})
37+
},
38+
createState: () => {
39+
return null
40+
}
41+
}
42+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "ES6",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"resolveJsonModule": true,
8+
"esModuleInterop": true,
9+
"jsx": "react",
10+
// "noEmit": true,
11+
// "noUnusedLocals": true,
12+
// "noUnusedParameters": true,
13+
"noImplicitReturns": true,
14+
"lib": [
15+
"DOM",
16+
"ESNext",
17+
],
18+
"types": [
19+
"node"
20+
],
21+
// "strict": true
22+
},
23+
"include": [
24+
"./src",
25+
"./loader.d.ts"
26+
]
27+
}

0 commit comments

Comments
 (0)