static void ExportDungeonData(string TargetFolder, bool AddCode, string code, Encoding encoding) { // 4. DungeonData.lua Export string swfilename; if (AddCode && code.Length > 0) { swfilename = TargetFolder + "\\DungeonData@" + code + ".lua"; } else { swfilename = TargetFolder + "\\DungeonData.lua"; } StreamReader srDungeonData = null; StreamWriter swDungeonData = null; try { srDungeonData = new StreamReader(ScriptTreeManager.strDungeonDir + "DungeonData.lua", Encoding.UTF8, false); swDungeonData = new StreamWriter(swfilename, false, encoding); // DungeonIDList만 잘 확인하고, 나머지는 전부 그대로 Output. Lua lua = new Lua(); LuaTool.DoFile(lua, ScriptTreeManager.strMajorDir + "Enum.lua"); while (false == srDungeonData.EndOfStream) { string strReadBuffer = srDungeonData.ReadLine(); if (strReadBuffer.Contains("dungeonID")) { int indexequal = strReadBuffer.IndexOf('='); int indexofcolon = strReadBuffer.IndexOf(','); string DIDEnumString = strReadBuffer.Substring(indexequal + 1, indexofcolon - indexequal - 1); DIDEnumString = DIDEnumString.Trim(); DIDEnumString = DIDEnumString.Replace("HARD", "NORMAL"); DIDEnumString = DIDEnumString.Replace("EXPERT", "NORMAL"); try { int IDValue = (int)(double)lua[LuaTool.ConvertStringForm(DIDEnumString)]; if (m_CheckList[IDValue]) { strReadBuffer = strReadBuffer.Replace("--dungeonID", "dungeonID"); } else { strReadBuffer = strReadBuffer.Replace("dungeonID", "--dungeonID"); } } catch (Exception) { // 딱히 List에 없었던 던전의 경우 그냥 넘어간다. } } swDungeonData.WriteLine(strReadBuffer); } } finally { if (srDungeonData != null) { srDungeonData.Close(); } if (swDungeonData != null) { swDungeonData.Close(); } } }
// 특정 Table만 있는 파일이고, 해당 Table의 형식은 Tablename = {} 으로 선언된 경우 static public bool ParseIDString(string filename, out Dictionary <int, string> OutputDic, out string TableName) { // ID - ID String 추출 OutputDic = new Dictionary <int, string>(); OutputDic.Clear(); TableName = null; StreamReader sr = null; try { sr = new StreamReader(filename, Encoding.UTF8, false); } catch (Exception e) { MessageBox.Show(e.Message); sr.Close(); return(false); } while (true) { string wstrStringRead; try { wstrStringRead = sr.ReadLine(); } catch (EndOfStreamException) { MessageBox.Show("Table Declaration Not Found"); sr.Close(); return(false); } catch (Exception e) { MessageBox.Show(e.Message); sr.Close(); return(false); } // 어떤 Table의 선언이 " = {} " 형식으로 되어 있다고 가정한다! if (wstrStringRead.IndexOf("{}") != -1) { int SubstrEndpos = wstrStringRead.IndexOf(' '); TableName = wstrStringRead.Substring(0, SubstrEndpos); break; } } if (TableName != null) { do { string wstrStringRead = sr.ReadLine(); if (wstrStringRead.IndexOf(TableName + "[") != -1) { int indexStart = wstrStringRead.IndexOf('['); int indexEnd = wstrStringRead.IndexOf(']', indexStart + 1); string EnumString = wstrStringRead.Substring(indexStart + 1, indexEnd - indexStart); EnumString = EnumString.Trim(); try { int IDValue = (int)(double)lua[LuaTool.ConvertStringForm(EnumString)]; OutputDic.Add(IDValue, EnumString); m_DicEnumString.Add(IDValue, EnumString); // 정보를 저장해두자 ㄲㄲ } catch (Exception e) { MessageBox.Show(e.Message); sr.Close(); return(false); } } } while (sr.EndOfStream == false); } sr.Close(); return(true); }
static void ExportDetailedLocalMapScript(string filename, string TargetFolder, bool AddCode, string code, Encoding encoding) { // 2-1. Export Files in DLG_Map_Local string swfilename; if (AddCode && code.Length > 0) { int extensionpos = filename.IndexOf(".lua"); string namepart = filename.Substring(0, extensionpos); swfilename = TargetFolder + "\\" + namepart + "@" + code + ".lua"; } else { swfilename = TargetFolder + "\\" + filename; } StreamReader srLocal = null; StreamWriter swLocal = null; try { srLocal = new StreamReader(ScriptTreeManager.strDialogDir + filename, Encoding.UTF8, false); swLocal = new StreamWriter(swfilename, false, encoding); // DungeonIDList만 잘 확인하고, 나머지는 전부 그대로 Output. bool bInDungeonIDList = false; int ContextDepth = 0; Lua lua = new Lua(); LuaTool.DoFile(lua, ScriptTreeManager.strMajorDir + "Enum.lua"); while (false == srLocal.EndOfStream) { string strReadBuffer = srLocal.ReadLine(); if (bInDungeonIDList) { int searchindex = 0; while (strReadBuffer.IndexOf('{', searchindex) != -1) { searchindex = strReadBuffer.IndexOf('{', searchindex) + 1; ContextDepth++; } searchindex = 0; while (strReadBuffer.IndexOf('}', searchindex) != -1) { searchindex = strReadBuffer.IndexOf('}', searchindex) + 1; ContextDepth--; } if (ContextDepth < 1) { bInDungeonIDList = false; } if (strReadBuffer.Contains("DUNGEON_ID")) { strReadBuffer = strReadBuffer.TrimStart('-'); strReadBuffer = strReadBuffer.TrimStart(); strReadBuffer = strReadBuffer.TrimStart('-'); int indexofcolon = strReadBuffer.IndexOf(','); string DIDEnumString = strReadBuffer.Substring(0, indexofcolon); int IDValue = (int)(double)lua[LuaTool.ConvertStringForm(DIDEnumString)]; if (m_CheckList[IDValue]) { strReadBuffer = "\t" + strReadBuffer; } else { strReadBuffer = "\t--" + strReadBuffer; } } } if (strReadBuffer.Contains("DungeonIDList =")) { bInDungeonIDList = true; } swLocal.WriteLine(strReadBuffer); } } finally { if (srLocal != null) { srLocal.Close(); } if (swLocal != null) { swLocal.Close(); } } }
// 파일내 특정 Table에서 ID - ID String 추출 static public bool ParseIDStringFromTable(string filename, string TableName, out Dictionary <int, string> OutputDic) { OutputDic = new Dictionary <int, string>(); if (TableName == "" || TableName == null) { return(false); } OutputDic.Clear(); StreamReader sr = null; try { sr = new StreamReader(filename, Encoding.UTF8, false); } catch (Exception e) { MessageBox.Show(e.Message); sr.Close(); return(false); } while (true) { string wstrStringRead; try { wstrStringRead = sr.ReadLine(); } catch (EndOfStreamException) { MessageBox.Show("Table Declaration Not Found"); sr.Close(); return(false); } catch (Exception e) { MessageBox.Show(e.Message); sr.Close(); return(false); } // 어떤 Table의 선언이 " Tablename = " 형식이라고 가정한다!! if (wstrStringRead.IndexOf(TableName) != -1 && wstrStringRead.IndexOf('=') != -1) { break; } } int depth = 0; do { string wstrStringRead = sr.ReadLine(); wstrStringRead = wstrStringRead.Replace("--", ""); wstrStringRead = wstrStringRead.Trim(); if (wstrStringRead.Length == 0) { continue; } int length = wstrStringRead.IndexOf(','); if (length != -1) { wstrStringRead = wstrStringRead.Substring(0, length); } int searchindex = 0; while (wstrStringRead.IndexOf('{', searchindex) != -1) { searchindex = wstrStringRead.IndexOf('{', searchindex) + 1; depth++; } searchindex = 0; while (wstrStringRead.IndexOf('}', searchindex) != -1) { searchindex = wstrStringRead.IndexOf('}', searchindex) + 1; depth--; } if (wstrStringRead.IndexOf("[") != -1 && wstrStringRead.IndexOf("]") != -1) { try { int IDValue = (int)(double)lua[LuaTool.ConvertStringForm(wstrStringRead)]; OutputDic.Add(IDValue, wstrStringRead); m_DicEnumString.Add(IDValue, wstrStringRead); // 정보를 저장해두자 ㄲㄲ } catch (Exception e) { MessageBox.Show(e.Message); sr.Close(); return(false); } } } while (depth > 0); sr.Close(); return(true); }