在软件开发中多采用自动生成工具,将配置表生成对应的脚本文件(如.lua)和读取脚本的配置文件(如.h与cpp),所有配置文件由管理器ConfigMgr统一加载入内存,程序运行时在需要的地方,即可直接从内存中查询
Private Sub CommandButton1_Click()
Dim fso, MyFile, txt, content1, content2, content3
Dim rows, columns
Dim firstID, cell_title, cell_value
'Set fso = CreateObject("Scripting.FileSystemObject")
'Set MyFile = fso.CreateTextFile(Split(ThisWorkbook.Path, "\²ß»®")(0) & "\Data_" & Split(ThisWorkbook.Name, ".")(0) & ".lua", True, True)
Dim filename
filename = Split(ThisWorkbook.Path, "\²ß»®")(0) & "\Data_" & Split(ThisWorkbook.Name, ".")(0) & ".lua"
Set fso = CreateObject("adodb.stream")
fso.Type = 2
fso.Mode = 3
fso.Charset = "UTF-8"
fso.Open
......
'创建文本内容
txt = "--[[" & Chr(13) & _
"From: " & Split(ThisWorkbook.Name, ".")(0) & ".xlsx" & Chr(13) & _
"]]" & Chr(13) & _
"_G._G = _G or {};" & Chr(13) & _
"_G._G.Data_" & Split(ThisWorkbook.Name, ".")(0) & "={" & Chr(13) & _
content1 & _
"}"
......
Call Utf8WithoutBom(filename & ".temp", filename) Kill filename & ".temp" MsgBox "转换完成"End Sub
Private Sub CommandButton2_Click()
Dim tabname, classname
Dim hfso, hFile, hStream, hTextStream, htxt, hcontent1, hcontentTab, hcontentClass, hcontentLine, hcontentData, hcontentData1, hcontentDataLine, hEditContent(2)
Dim cppfso, cppFile, cppStream, cppTextStream, cpptxt, cppcontent1, cppcontent, cppcontentLine, cppFunction, cppEditContent
Dim columns, isneedbuf, ishaslst
Dim valuename, valuetype, keyname
Dim hFileName, cppFileName
Dim isCreate
Dim Check, rows
Set Check = CreateObject("scripting.dictionary")
......
If IsEmpty(hFileName) Or IsEmpty(cppFileName) Then MsgBox "Ó¦¸ÃÑ¡ÔñÒ»¸ö.hºÍÒ»¸ö.cppÎļþ" End End If Set hfso = CreateObject("Scripting.FileSystemObject") Set cppfso = CreateObject("Scripting.FileSystemObject")
......
Function CharToBig(charS As String) As String If Asc(charS) >= 97 And Asc(charS) <= 122 Then CharToBig = Chr(Asc(charS) - 32) Else CharToBig = charS End IfEnd Function
#define CFG_CREATE(x) x::GetSingleton().Destory();\
if (false == x::GetSingleton().Create()) {\
LoLogs::WriteLog("%s create failed!\n", #x);\
return false; \
}
bool CConfigMgr::Create()
{
CFG_CREATE(CGlobalCfg);
CFG_CREATE(CActorTime);
CFG_CREATE(CActorAnimTimeCfg);
CFG_CREATE(CBulletCfg);
// 场景配置表
CFG_CREATE(CSceneCfg);
CFG_CREATE(CSceneBoxCfg);
CFG_CREATE(CAiCfg);
CFG_CREATE(CLevelupCfg);
CFG_CREATE(CActorBoxCfg);
CFG_CREATE(CActorBasicCfg);
CFG_CREATE(CActorStateCfg);
CFG_CREATE(CActorStrikeCfg);
//CFG_CREATE(CAnimationCfg);
CFG_CREATE(CBuffCfg);
CFG_CREATE(CBuffTriggerCfg);
CFG_CREATE(CSkillAnimTimeCfg);
CFG_CREATE(CSkillStoneCfg);
CFG_CREATE(CInitPlayerCfg);
CFG_CREATE(CTalentCfg);
CFG_CREATE(CTaskCfg);
CFG_CREATE(CTaskActiveCfg);
CFG_CREATE(CDungeonCfg);
CFG_CREATE(CStageAwardsCfg);
CFG_CREATE(CResStageCfg);
CFG_CREATE(CSignCfg);
return true;
}
bool CConfigMgr::Destory()
{
return true;
}