export-table-pulgin-csharp 1.1.78 → 1.1.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,7 +174,7 @@ namespace MEEC.ExportedConfigs
174
174
  {
175
175
  public static class DefaultConfigLoader{
176
176
  public static IEnumerable<Func<Task>> Load(){
177
- ${(0, export_table_lib_1.foreach)(tables, (table) => `
177
+ ${(0, export_table_lib_1.foreach)(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
178
178
  yield return ${firstLetterUpper(table.name)}.Load;
179
179
  `)}
180
180
  yield break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.1.78",
3
+ "version": "1.1.79",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -168,7 +168,7 @@ namespace MEEC.ExportedConfigs
168
168
  {
169
169
  public static class DefaultConfigLoader{
170
170
  public static IEnumerable<Func<Task>> Load(){
171
- ${foreach(tables, (table) => `
171
+ ${foreach(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
172
172
  yield return ${firstLetterUpper(table.name)}.Load;
173
173
  `)}
174
174
  yield break;
@@ -1,143 +0,0 @@
1
-
2
- import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper } from "export-table-lib"
3
- import * as fs from "fs-extra"
4
-
5
- let firstLetterUpper = makeFirstLetterUpper;
6
- function exportUJson(paras: HandleSheetParams): string | null {
7
- let {
8
- datas,
9
- fields,
10
- name,
11
- objects,
12
- table,
13
- } = paras;
14
-
15
- let firstLetterLower = function (str: string) {
16
- return str.charAt(0).toLowerCase() + str.slice(1);
17
- };
18
- let convMemberName = function (str: string) {
19
- return str.split("_").map(s => firstLetterUpper(s)).join("")
20
- }
21
-
22
- var fullName = `${table.workbookName}-${name}`
23
- let jsonString = JSON.stringify(objects.map(obj => {
24
- var newObj = Object.create(null);
25
- Object.keys(obj).forEach(key => {
26
- var newKey = convMemberName(key);
27
- newObj[newKey] = obj[key];
28
- })
29
- return newObj
30
- }));
31
-
32
- // !!!必须开头没有空格
33
- let temp = `%YAML 1.1
34
- %TAG !u! tag:unity3d.com,2011:
35
- --- !u!114 &11400000
36
- MonoBehaviour:
37
- m_ObjectHideFlags: 0
38
- m_CorrespondingSourceObject: {fileID: 0}
39
- m_PrefabInstance: {fileID: 0}
40
- m_PrefabAsset: {fileID: 0}
41
- m_GameObject: {fileID: 0}
42
- m_Enabled: 1
43
- m_EditorHideFlags: 0
44
- m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
45
- m_Name: ${fullName}
46
- m_EditorClassIdentifier:
47
- JsonText: ${JSON.stringify(jsonString)}
48
- `
49
- return temp
50
-
51
- }
52
-
53
- function exportUJsonLoader(paras: HandleSheetParams): string | null {
54
- let {
55
- datas,
56
- fields,
57
- name,
58
- objects,
59
- table,
60
- } = paras;
61
-
62
- let RowClass = firstLetterUpper(name)
63
- var fullName = `${table.workbookName}-${name}`
64
- // !!!必须开头没有空格
65
- let temp = `
66
- using lang.json;
67
- using UnityEngine.AddressableAssets;
68
- using System.Threading.Tasks;
69
- using UnityEngine;
70
-
71
- namespace MEEC.ExportedConfigs
72
- {
73
- public partial class ${RowClass}
74
- {
75
- public static async Task Load()
76
- {
77
- var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.asset";
78
- var configJson = await Addressables.LoadAssetAsync<ExcelConfigJson>(loadUrl).Task;
79
- if (configJson != null)
80
- {
81
- var jsonObjs = JSON.parse<${RowClass}[]>(configJson.JsonText);
82
- var configs = ${RowClass}.Configs;
83
- configs.Clear();
84
- configs.AddRange(jsonObjs);
85
- }
86
- else
87
- {
88
- Debug.LogError($"配表资源缺失: {loadUrl}");
89
- }
90
- }
91
- }
92
- }
93
- `
94
- return temp
95
-
96
- }
97
-
98
- export class ExportUJsonPluginV1 extends PluginBase {
99
- name = "ujson1"
100
- tags: string[] = ["ujson1"]
101
-
102
- handleSheet(paras: HandleSheetParams) {
103
- var fullName = `${paras.table.workbookName}-${paras.name}`
104
- {
105
- let content1 = exportUJsonLoader(paras)
106
- if (content1 != null) {
107
- let savePath = new OutFilePath(paras.outPath, fullName, "Loader.cs").fullPath
108
- fs.outputFileSync(savePath, content1, "utf-8")
109
- }
110
- }
111
- {
112
- let content2 = exportUJson(paras)
113
- if (content2 != null) {
114
- let savePath = new OutFilePath(paras.outPath, fullName, ".asset").fullPath
115
- fs.outputFileSync(savePath, content2, "utf-8")
116
- }
117
- return content2
118
- }
119
- }
120
-
121
- handleBatch(paras: HandleBatchParams): void {
122
- var tables = paras.tables;
123
- var temp = `
124
- using System;
125
- using System.Collections.Generic;
126
- using System.Threading.Tasks;
127
-
128
- namespace MEEC.ExportedConfigs
129
- {
130
- public static class DefaultConfigLoader{
131
- public static IEnumerable<Func<Task>> Load(){
132
- ${foreach(tables, (table) => `
133
- yield return ${firstLetterUpper(table.name)}.Load;
134
- `)}
135
- yield break;
136
- }
137
- }
138
- }
139
- `
140
- let savePath = paras.outPath + "/DefaultConfigLoader.cs";
141
- fs.outputFileSync(savePath, temp, "utf-8");
142
- }
143
- }