void OnMapSelectionChanged(int newIdx) { string mapluafile = MapLuaFiles[newIdx]; LstModes.Clear(); LstEras.Clear(); ModeSubs.Clear(); EraSubs.Clear(); object[] res = RT.CallLuaFunction("missionlist_ExpandModelist", 1, mapluafile); PhxLuaRuntime.Table modes = res[0] as PhxLuaRuntime.Table; foreach (KeyValuePair <object, object> entry in modes) { PhxLuaRuntime.Table mode = entry.Value as PhxLuaRuntime.Table; string modeNamePath = mode.Get <string>("showstr"); if (mode.Get("bIsWildcard") == null) { PhxListBoxItem item = LstModes.AddItem(ENV.GetLocalized(modeNamePath)); Texture2D icon = TextureLoader.Instance.ImportUITexture(mode.Get <string>("icon")); item.SetIcon(icon); string key = mode.Get <string>("key"); item.SetChecked(LastCheckedModes.Contains(key)); item.OnCheckChanged += (bool check) => { if (check) { LastCheckedModes.Add(key); } else { LastCheckedModes.Remove(key); } }; ModeSubs.Add(new SubIcon { Sub = mode.Get <string>("subst"), Icon = icon }); } } res = RT.CallLuaFunction("missionlist_ExpandEralist", 1, mapluafile); PhxLuaRuntime.Table eras = res[0] as PhxLuaRuntime.Table; foreach (KeyValuePair <object, object> entry in eras) { PhxLuaRuntime.Table era = entry.Value as PhxLuaRuntime.Table; string eraNamePath = era.Get <string>("showstr"); if (era.Get("bIsWildcard") == null) { PhxListBoxItem item = LstEras.AddItem(ENV.GetLocalized(eraNamePath)); Texture2D icon = TextureLoader.Instance.ImportUITexture(era.Get <string>("icon2")); item.SetIcon(icon); string key = era.Get <string>("key"); item.SetChecked(LastCheckedEras.Contains(key)); item.OnCheckChanged += (bool check) => { if (check) { LastCheckedEras.Add(key); } else { LastCheckedEras.Remove(key); } }; EraSubs.Add(new SubIcon { Sub = era.Get <string>("subst"), Icon = icon }); } } }
public void InitClass(EntityClass ec) { Name = ec.Name; ClassType = ec.ClassType; if (ClassType == EEntityClassType.WeaponClass) { string locPath = "weapons."; int splitIdx = Name.IndexOf('_'); locPath += Name.Substring(0, splitIdx) + ".weap." + Name.Substring(splitIdx + 1).Replace("weap_", ""); LocalizedName = ENV?.GetLocalized(locPath); } else { string locPath = "entity."; int splitIdx = Name.IndexOf('_'); locPath += Name.Substring(0, splitIdx) + '.' + Name.Substring(splitIdx + 1); LocalizedName = ENV?.GetLocalized(locPath); } Type type = GetType(); MemberInfo[] members = type.GetMembers(); foreach (MemberInfo member in members) { if (member.MemberType == MemberTypes.Field) { if (typeof(IPhxPropRef).IsAssignableFrom(type.GetField(member.Name).FieldType)) { IPhxPropRef refValue = type.GetField(member.Name).GetValue(this) as IPhxPropRef; P.Register(member.Name, refValue); PhxPropertyDB.AssignProp(ec, member.Name, refValue); } else if (typeof(PhxPropertySection).IsAssignableFrom(type.GetField(member.Name).FieldType)) { PhxPropertySection section = type.GetField(member.Name).GetValue(this) as PhxPropertySection; // Read properties from top to bottom to fill property sections ec.GetAllProperties(out uint[] propHashes, out string[] propValues); Debug.Assert(propHashes.Length == propValues.Length); var foundSections = new List <Dictionary <string, IPhxPropRef> >(); Dictionary <string, IPhxPropRef> currSection = null; for (int i = 0; i < propHashes.Length; ++i) { // Every time we encounter the section header, start a new section if (propHashes[i] == section.NameHash) { foundSections.Add(new Dictionary <string, IPhxPropRef>()); currSection = foundSections[foundSections.Count - 1]; } if (currSection != null) { for (int j = 0; j < section.Properties.Length; ++j) { string propName = section.Properties[j].Item1; uint propNameHash = HashUtils.GetFNV(propName); // if we encounter a matching property, grab it if (propHashes[i] == propNameHash) { IPhxPropRef prop = section.Properties[j].Item2.ShallowCopy(); prop.SetFromString(propValues[i]); currSection.Add(propName, prop); } } } } section.SetSections(foundSections.ToArray()); } } } EntityClass = ec; }