Skip to content

Commit

Permalink
支持扩展导入 mspm 文件
Browse files Browse the repository at this point in the history
这样就可以制作与 1.x 完全兼容的双版本模组/扩展了,之前只能制作兼容的插件/扩展
如果要判断是否是 2.x 版本可以通过检查 fetchSelf 是否为 undefined 来确定
  • Loading branch information
Yesterday17 committed Aug 17, 2019
1 parent f3df0ec commit ca55180
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ data/
# exported files
*.mspr
*.mspe
*.mspm
*.mspt
Binary file removed assets/bin/icon.png
Binary file not shown.
26 changes: 16 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,30 @@
"ext": [
"mspr",
"mspe",
"mspm",
"mspt"
],
"description": "Majsoul Plus ResourcePack/Extension/Tool",
"icon": "assets/bin/icon.png"
"icon": "assets/bin/icons/icon.ico"
},
"dmg": {
"artifactName": "Majsoul_Plus-${platform}-${arch}.${ext}"
},
"mac": {
"icon": "assets/bin/icon.png",
"icon": "assets/bin/icons/icon.icns",
"artifactName": "Majsoul_Plus-${platform}-${arch}.${ext}",
"darkModeSupport": true
},
"win": {
"icon": "assets/bin/icon.png",
"icon": "assets/bin/icons/icon.ico",
"target": [
"nsis",
"portable",
"zip"
]
},
"linux": {
"icon": "assets/bin/icon.png",
"icon": "assets/bin/icons/icon.png",
"category": "Game",
"target": [
"tar.gz",
Expand All @@ -64,18 +65,23 @@
"fileAssociations": [
{
"ext": "mspr",
"description": "Majsoul Plus ResourcePack/Extension/Tool",
"icon": "assets/bin/icon.png"
"description": "Majsoul Plus ResourcePack",
"icon": "assets/bin/icons/icon.ico"
},
{
"ext": "mspe",
"description": "Majsoul Plus ResourcePack/Extension/Tool",
"icon": "assets/bin/icon.png"
"description": "Majsoul Plus Extension",
"icon": "assets/bin/icons/icon.ico"
},
{
"ext": "mspm",
"description": "Majsoul Plus Extension",
"icon": "assets/bin/icons/icon.ico"
},
{
"ext": "mspt",
"description": "Majsoul Plus ResourcePack/Extension/Tool",
"icon": "assets/bin/icon.png"
"description": "Majsoul Plus Tool",
"icon": "assets/bin/icons/icon.ico"
}
]
}
Expand Down
19 changes: 9 additions & 10 deletions src/manager/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class ResourceManager {
const type = {
'.mspr': 'resourcepack',
'.mspe': 'extension',
'.mspm': 'extension',
'.mspt': 'tool'
}[ext]
if (type) {
Expand Down Expand Up @@ -189,21 +190,19 @@ class ResourceManager {
},
{
name: i18n.text.manager.fileTypeMSPE(),
extensions: ['mspe']
extensions: ['mspe', 'mspm']
},
{
name: i18n.text.manager.fileTypeMSPT(),
extensions: ['mspt']
}
].filter(
ext =>
ext.extensions[0] ===
{
ResourcePack: 'mspr',
Extension: 'mspe',
Tool: 'mspt'
}[type]
),
].filter(ext => {
return {
ResourcePack: ['mspr'],
Extension: ['mspe', 'mspm'],
Tool: ['mspt']
}[type].includes(ext.extensions[0])
}),
properties: ['openFile', 'multiSelections']
},
files => {
Expand Down
2 changes: 1 addition & 1 deletion src/manager/majsoul_plus_manager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare namespace MajsoulPlus_Manager {

// 导出包的信息
export interface ExportInfo {
extend: string
extend: string[]
typeText: string
}

Expand Down
2 changes: 1 addition & 1 deletion src/manager/pages/Extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CardList from '../ui/CardList'
class Extension extends CardList {
protected getExportInfo() {
return {
extend: 'mspe',
extend: ['mspe', 'mspm'],
typeText: i18n.text.manager.fileTypeMSPE()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/manager/pages/ResourcePacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CardList from '../ui/CardList'
class ResourcePack extends CardList {
protected getExportInfo() {
return {
extend: 'mspr',
extend: ['mspr'],
typeText: i18n.text.manager.fileTypeMSPR()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/manager/pages/Tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Tool extends CardList {

getExportInfo() {
return {
extend: 'mspt',
extend: ['mspt'],
typeText: i18n.text.manager.fileTypeMSPT()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/manager/ui/CardList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class CardList {
filters: [
{
name: typeText,
extensions: [extend]
extensions: extend
}
],
defaultPath: `${exp.metadata.name}(${id}) - ${
Expand Down
1 change: 1 addition & 0 deletions src/utilities/openFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class OpenFile extends Utility {
const type = {
'.mspr': 'resourcepack',
'.mspe': 'extension',
'.mspm': 'extension',
'.mspt': 'tool'
}[ext]
if (type) {
Expand Down

0 comments on commit ca55180

Please sign in to comment.