protected bool LoadPlayer(string playerName, string customName = "") { mPlayerName = playerName; if (string.IsNullOrEmpty(mPlayerName)) { return(false); } ConfigReader reader = new ConfigReader(); if (string.IsNullOrEmpty(customName)) { customName = playerName; } string fileName = string.Format("{0}@{1}/{2}.air.txt", AppConfig.GetInstance().PlayerRootDir, playerName, customName); string str = AppConfig.GetInstance().Loader.LoadText(fileName); if (string.IsNullOrEmpty(str)) { return(false); } reader.LoadString(str); bool ret = LoadFromReader(reader); return(ret); }
public bool LoadFromStr(string str) { Clear(); if (string.IsNullOrEmpty(str)) { return(false); } ConfigReader reader = new ConfigReader(); reader.LoadString(str); return(LoadFromReader(reader)); }
public void LoadString(string str) { if (string.IsNullOrEmpty(str)) { return; } ConfigReader reader = new ConfigReader(); reader.LoadString(str); var section = reader.GetSection("Files"); if (section == null) { return; } mPlayerFiles = new PlayerFiles(); if (!section.GetPropertysValues(mPlayerFiles)) { mPlayerFiles = null; } section = reader.GetSection("Info"); mPlayerInfo = new PlayerInfo(); if (section != null) { if (!section.GetPropertysValues(mPlayerInfo)) { mPlayerInfo = null; } else { for (int i = 0; i < section.ContentListCount; ++i) { string key, value; if (section.GetKeyValue(i, out key, out value)) { if (string.Compare(key, "localcoord", true) == 0) { string[] vals = ConfigSection.Split(value); if (vals != null && vals.Length >= 2) { mPlayerInfo.designWidth = int.Parse(vals[0]); mPlayerInfo.designHeight = int.Parse(vals[1]); } } else if (string.Compare(key, "pal.defaults", true) == 0) { if (mPlayerFiles.HasPal) { continue; } string[] vals = ConfigSection.Split(value); if (vals != null && vals.Length > 0) { if (vals.Length >= 1) { mPlayerFiles.pal1 = vals[0]; } if (vals.Length >= 2) { mPlayerFiles.pal2 = vals[1]; } if (vals.Length >= 3) { mPlayerFiles.pal3 = vals[2]; } if (vals.Length >= 4) { mPlayerFiles.pal4 = vals[3]; } if (vals.Length >= 5) { mPlayerFiles.pal5 = vals[4]; } if (vals.Length >= 6) { mPlayerFiles.pal6 = vals[5]; } if (vals.Length >= 7) { mPlayerFiles.pal7 = vals[6]; } if (vals.Length >= 8) { mPlayerFiles.pal8 = vals[7]; } if (vals.Length >= 9) { mPlayerFiles.pal9 = vals[8]; } if (vals.Length >= 10) { mPlayerFiles.pal10 = vals[9]; } if (vals.Length >= 11) { mPlayerFiles.pal11 = vals[10]; } if (vals.Length >= 12) { mPlayerFiles.pal12 = vals[11]; } mPlayerFiles.IsDefaultPal = true; } } } } } } section = reader.GetSection("Palette Keymap"); mKeyMap = new PalletKeyMap(); if (section != null) { if (!section.GetPropertysValues(mKeyMap)) { mKeyMap = null; } } }
private bool LoadFromStr(string str) { Clear(); if (string.IsNullOrEmpty(str)) { return(false); } ConfigReader reader = new ConfigReader(); reader.LoadString(str); // 1 var section = reader.GetSection("Info"); if (section != null) { m_Info = new StageInfo(); if (!section.GetPropertysValues(m_Info)) { Clear(); return(false); } } else { Clear(); return(false); } // 2 section = reader.GetSection("Camera"); if (section == null) { Clear(); return(false); } m_Cam = new StageCamera(); if (!section.GetPropertysValues(m_Cam)) { Clear(); return(false); } // 3 section = reader.GetSection("PlayerInfo"); if (section == null) { Clear(); return(false); } m_Players = new StagePlayerInfo(); if (!section.GetPropertysValues(m_Players)) { Clear(); return(false); } // 4 section = reader.GetSection("Scaling"); if (section != null) { m_Scaling = new StageScaling(); if (!section.GetPropertysValues(m_Scaling)) { Clear(); return(false); } } else { m_Scaling = new StageScaling(); } // 5 m_AirConfig = new AirConfig(reader); if (!m_AirConfig.IsVaild) { Clear(); return(false); } // 6 section = reader.GetSection("BGdef"); if (section == null) { Clear(); return(false); } m_BgDef = new BgDef(); if (!section.GetPropertysValues(m_BgDef)) { Clear(); return(false); } // 7. m_BgCfg = new BgConfig(); if (!m_BgCfg.LoadFromReader(reader)) { Clear(); return(false); } return(IsVaild); }
public bool LoadFromFile(string fileName) { Reset(); string str = AppConfig.GetInstance().Loader.LoadText(fileName); if (str == null || string.IsNullOrEmpty(str)) { return(false); } ConfigReader reader = new ConfigReader(); reader.LoadString(str); ConfigSection section = reader.GetSection("Velocity"); if (section != null) { if (!LoadVelocity(section)) { return(false); } } section = reader.GetSection("Size"); if (section != null) { if (!LoadSize(section)) { return(false); } } string dd = "Statedef"; string ddd = "State"; for (int i = 0; i < reader.SectionCount; ++i) { section = reader.GetSections(i); if (section == null || string.IsNullOrEmpty(section.Tile)) { continue; } CNSStateDef parent = null; if (section.Tile.StartsWith(dd, StringComparison.CurrentCultureIgnoreCase)) { string name = section.Tile.Substring(dd.Length); if (string.IsNullOrEmpty(name)) { continue; } name = name.Trim(); if (string.IsNullOrEmpty(name)) { continue; } CNSStateDef def = new CNSStateDef(); if (def.LoadConfigReader(section)) { AddStateDef(name, def); parent = def; } else { parent = null; continue; } } if (section.Tile.StartsWith(ddd, StringComparison.CurrentCultureIgnoreCase)) { if (parent == null) { continue; } } } return(true); }