protected override bool OnSave(TextBlock block) { TextBlock normalModeBlock = block.FindChild("normalMode"); if (normalModeBlock == null) { Log.Fatal("{0} : normalMode Block not exists", Name); } if (!normalMode.Save(normalModeBlock)) { return(false); } TextBlock alternativeModeBlock = block.FindChild("alternativeMode"); if (alternativeModeBlock == null) { Log.Fatal("{0} : alternativeMode Block not exists", Name); } if (!alternativeMode.Save(alternativeModeBlock)) { return(false); } return(base.OnSave(block)); }
private static void A() { TextBlock textBlock = TextBlockUtils.LoadFromVirtualFile(ToolsLocalization.EL); if (textBlock != null) { TextBlock textBlock2 = textBlock.FindChild("groups"); if (textBlock2 != null) { foreach (TextBlock current in textBlock2.Children) { if (!(current.Name != "group")) { string data = current.Data; ToolsLocalization.GroupItem groupItem = new ToolsLocalization.GroupItem(data); ToolsLocalization.EM.Add(data, groupItem); foreach (TextBlock.Attribute current2 in current.Attributes) { groupItem.em.Add(current2.Name, current2.Value); } } } } } }
public void LoadGame(String filename) { if (!VirtualFile.Exists("Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata")) { ScreenMessages.Add("No file"); return; } TextBlock block = TextBlockUtility.LoadFromVirtualFile("Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata"); EnemiesKill = int.Parse(block.FindChild("EnemiesKill").Data); ScreenMessages.Add("EnemiesKill = " + EnemiesKill); Level = int.Parse(block.FindChild("Level").Data); ScreenMessages.Add("Level = " + Level); CheckPoint = block.FindChild("CheckPoint").Data; ScreenMessages.Add("CheckPoint = " + CheckPoint); hasWeapon = bool.Parse(block.FindChild("hasWeapon").Data); ScreenMessages.Add("hasWeapon = " + hasWeapon); ShowWin(false); AddEK(0); if (Level == 1) { LoadSc("File"); } else if (Level == 2) { LoadSc("File2"); } else { ScreenMessages.Add("No level"); } var sc = Component_Scene.First; var chpoint = (Component_Sensor)sc?.GetComponentByPath(CheckPoint); var chr = (Component_Character)sc?.GetComponentByPath("Character"); var chrcol = (Component_RigidBody)sc?.GetComponentByPath("Character\\Collision Body"); chrcol.Transform = chrcol.TransformV.UpdatePosition(new Vector3(chpoint.TransformV.Position.X, chpoint.TransformV.Position.Y, chr.TransformV.Position.Z)); GetWeapon(sc, chr, hasWeapon); ScreenMessages.Add("Load Done"); }
protected override bool OnLoad(TextBlock block) { if (!base.OnLoad(block)) { return(false); } //currentTask { TextBlock taskBlock = block.FindChild("currentTask"); if (taskBlock != null) { Task task = CreateTaskByClassName(taskBlock.GetAttribute("class")); if (task._Load(taskBlock)) { currentTask = task; } } } //tasks TextBlock tasksBlock = block.FindChild("tasks"); if (tasksBlock != null) { foreach (TextBlock taskBlock in tasksBlock.Children) { if (taskBlock.Name == "item") { Task task = CreateTaskByClassName(taskBlock.GetAttribute("class")); if (task._Load(taskBlock)) { tasks.Enqueue(task); } } } } return(true); }
protected override bool OnLoad(TextBlock block) { TextBlock normalModeBlock = block.FindChild("normalMode"); if (normalModeBlock != null) { if (!normalMode.Load(normalModeBlock)) { return(false); } } TextBlock alternativeModeBlock = block.FindChild("alternativeMode"); if (alternativeModeBlock != null) { if (!alternativeMode.Load(alternativeModeBlock)) { return(false); } } return(base.OnLoad(block)); }
public bool Load(TextBlock block) { //fireObjects TextBlock fireObjectsBlock = block.FindChild("fireObjects"); if (fireObjectsBlock != null) { if (!fireObjects.Load(fireObjectsBlock)) { return(false); } } return(true); }
protected override bool OnLoad(TextBlock block) { TextBlock stats = block.FindChild("defaultStatistics"); if (stats != null) { defaultStatistics = new Dictionary <string, int>(); foreach (TextBlock.Attribute att in stats.Attributes) { defaultStatistics.Add(att.Name, Convert.ToInt32(att.Value)); } } return(base.OnLoad(block)); }
//private void shouldgo() //{ // Go = true; //} //protected void Back(bool reallygo) //{ // if (reallygo) // shouldgo(); // if (positionY == maxout && Go && !done) // { // if (Map.Instance.Name.ToString() == "MainMap") // { // //this.OnDetach(); // ////Controls.Add(new MainMenuWindow()); // //MainMenuWindow.Instance.Go = false; // //done = true; // this.OnDetach(); // Controls.Add(new MPAKlobbyWindow()); // done = true; // } // else // { // //SetShouldDetach(); // } // } //} #endregion overrides private void UpdateVariantCost(int amountToAdd) { variantCost = 0; if (amountToAdd != -1) { AKunitType akt = spawner.Spawned.Type as AKunitType; for (int i = 0; i < akt.BodyParts.Count; i++) { TextBlock bodyPartBlock = variant.FindChild(akt.BodyParts[i].GUIDesplayName); if (bodyPartBlock != null) { int bodyPartIndex = i; int bodyPartBlockIndex = variant.Children.IndexOf(bodyPartBlock); AKunitType.BodyPart bodyPart = akt.BodyParts[i]; for (int j = 0; j < bodyPart.Weapons.Count; j++) { TextBlock bodyPartWeaponBlock = bodyPartBlock.FindChild(bodyPart.Weapons[j].MapObjectAlias); if (bodyPartWeaponBlock != null) { int alternateWeaponIndex = int.Parse(bodyPartWeaponBlock.Attributes[0].Value); variantCost += bodyPart.Weapons[j].Alternates[alternateWeaponIndex].Price; } } } } } UpdateCashText(); }
private void btnAddWeapon_Click(Button sender) { if (cbxWeaponSlots.SelectedItem == null || lstWeaponList.SelectedItem == null) { return; } AKunit u = spawner.Spawned as AKunit; AKunitType.WeaponItem wi = cbxWeaponSlots.SelectedItem as AKunitType.WeaponItem; AKunitType.AlternateWeaponItem awi = lstWeaponList.SelectedItem as AKunitType.AlternateWeaponItem; string selectedBodyPartName = GetBodyPartNameFromActiveButton(); int selectedBodyPartIndex = GetBodyPartIndex(selectedBodyPartName); int weaponFireGroup = u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].FireGroup; u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].Ammo = awi.Ammo; u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].MagazineCapacity = awi.MagazineCapacity; u.Bp[selectedBodyPartIndex].Weapons[cbxWeaponSlots.SelectedIndex].WeaponType = awi.WeaponType; TextBlock bodyPartBlock = variant.FindChild(selectedBodyPartName); if (bodyPartBlock == null) { bodyPartBlock = variant.AddChild(selectedBodyPartName); } if (bodyPartBlock != null) { TextBlock wBlock = bodyPartBlock.FindChild(wi.MapObjectAlias); if (wBlock == null) { wBlock = bodyPartBlock.AddChild(wi.MapObjectAlias); } if (wBlock != null) { wBlock.SetAttribute("i", lstWeaponList.SelectedIndex.ToString()); wBlock.SetAttribute("g", weaponFireGroup.ToString()); } } UpdateVariantCost(awi.Price); PopulateWeaponSlotsDropDown(selectedBodyPartName); }
protected override bool OnLoad(TextBlock block) { if (!base.OnLoad(block)) { return(false); } //hitObjects TextBlock hitObjectsBlock = block.FindChild("hitObjects"); if (hitObjectsBlock != null) { if (!hitObjects.Load(hitObjectsBlock)) { return(false); } } return(true); }
internal bool A(TextBlock textBlock) { TextBlock textBlock2 = textBlock.FindChild("waitItems"); if (textBlock2 != null) { foreach (TextBlock current in textBlock2.Children) { LogicEntityObject.WaitingThreadItem waitingThreadItem = new LogicEntityObject.WaitingThreadItem(); if (current.IsAttributeExist("threadName")) { waitingThreadItem.ThreadName = current.GetAttribute("threadName"); } if (current.IsAttributeExist("remainingTime")) { waitingThreadItem.RemainingTime = float.Parse(current.GetAttribute("remainingTime")); } TextBlock textBlock3 = current.FindChild("executeMethodInformations"); if (textBlock3 != null) { waitingThreadItem.currentExecutingMethodInformations = new List <LogicExecuteMethodInformation>(); foreach (TextBlock current2 in textBlock3.Children) { LogicExecuteMethodInformation logicExecuteMethodInformation = new LogicExecuteMethodInformation(); if (!logicExecuteMethodInformation.A(current2)) { return(false); } waitingThreadItem.currentExecutingMethodInformations.Add(logicExecuteMethodInformation); } } this.waitintThreads.Add(waitingThreadItem); } } if (this.waitintThreads.Count != 0) { this.ownerEntity.SubscribeToTickEvent(); } return(true); }
private bool LoadCustomSerializationValues(TextBlock textBlock) { TextBlock customValuesBlock = textBlock.FindChild("customSerializationValues"); if (customValuesBlock == null) { return(true); } foreach (TextBlock current in customValuesBlock.Children) { string name = current.Name; string typeName = current.GetAttribute("type"); string valueString = current.GetAttribute("value"); string text = string.Format("World: Custom serialization value \"{0}\"", name); Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Assembly assembly = assemblies[i]; type = assembly.GetType(typeName); if (type != null) { break; } } object value; if (type == null) { Log.Warning("Entity System: Serialization error. The class type is not found \"{0}\" ({1}).", typeName, text); } else if (EntityHelper.ConvertFromString(type, valueString, text, out value)) { SetCustomSerializationValue(name, value); } } return(true); }
protected override bool OnInitLibrary(bool allowHardwareAcceleration, bool editor) { instance = this; NativeLibraryManager.PreLoadLibrary("ode"); //int maxIterationCount = 20; //int hashSpaceMinLevel = 2;// 2^2 = 4 minimum cell size //int hashSpaceMaxLevel = 8;// 2^8 = 256 maximum cell size if (VirtualFile.Exists("Base/Constants/PhysicsSystem.config")) { TextBlock block = TextBlockUtils.LoadFromVirtualFile("Base/Constants/PhysicsSystem.config"); if (block != null) { TextBlock odeBlock = block.FindChild("odeSpecific"); if (odeBlock != null) { if (odeBlock.IsAttributeExist("maxIterationCount")) { defaultMaxIterationCount = int.Parse(odeBlock.GetAttribute("maxIterationCount")); } if (odeBlock.IsAttributeExist("hashSpaceMinLevel")) { hashSpaceMinLevel = int.Parse(odeBlock.GetAttribute("hashSpaceMinLevel")); } if (odeBlock.IsAttributeExist("hashSpaceMaxLevel")) { hashSpaceMaxLevel = int.Parse(odeBlock.GetAttribute("hashSpaceMaxLevel")); } } } } Ode.dInitODE2(0); return(true); }
protected override bool OnLoad(TextBlock block) { if (!base.OnLoad(block)) { return(false); } TextBlock editorLayersBlock = block.FindChild("editorLayers"); if (editorLayersBlock != null && rootEditorLayer.OnLoad(editorLayersBlock)) { if (Instance.RootEditorLayer != null) { Instance.Children.OfType <MapObject>().Any(_mo => { _mo.EditorLayer = Instance.RootEditorLayer.Find(_mo._editorLayerLast); return(false); }); } } return(true); }
private void btnSaveVariant_Click(Button sender) { if (string.IsNullOrEmpty(txtVariantName.Text)) { txtInfo.Text = "Variant name needed."; return; } //check if the file exists foreach (object item in lstWeaponList.Items) { VariantWeaponGroupItem vwgi = item as VariantWeaponGroupItem; TextBlock bodyPartBlock = variant.FindChild(vwgi.BodyPartName); TextBlock weaponBlock = bodyPartBlock.FindChild(vwgi.WeaponName); weaponBlock.SetAttribute("g", vwgi.NewWeaponGroup.ToString()); } if (SaveVariant != null) { SaveVariant(this, txtVariantName.Text.Trim(), variant); } }
public static bool LoadFieldValue(bool entitySerialize, object owner, FieldInfo field, TextBlock block, string errorString) { string fieldName = GetFieldSerializeName(entitySerialize, field); errorString += string.Format(", property: \"{0}\"", fieldName); bool isList = field.FieldType.IsGenericType && field.FieldType.Name == typeof(List <>).Name; bool isArray = field.FieldType.IsArray; if (isList || isArray) { if (isArray && field.FieldType.GetArrayRank() != 1) { Log.Fatal("Entity System: Serialization of arrays are supported only for one dimensions arrays ({0}).", errorString); return(false); } bool loadResult = LoadArrayFieldValue(entitySerialize, owner, field, block, errorString); return(loadResult); } bool isEntityType = typeof(EntityType).IsAssignableFrom(field.FieldType); bool isEntity = typeof(Entity).IsAssignableFrom(field.FieldType); bool typeSupport = (SimpleTypesUtils.IsSimpleType(field.FieldType) | isEntityType | isEntity) || typeof(Type) == field.FieldType; if (typeSupport) { if (!entitySerialize & isEntity) { Log.Fatal("Entity System: Serialization Entity classes in entity types is forbidden ({0}).", errorString); return(false); } bool fieldExists = block.IsAttributeExist(fieldName); if (fieldExists) { string fieldValue = block.GetAttribute(fieldName); object value; bool convertResult = ConvertFromString(field.FieldType, fieldValue, errorString, out value); if (!convertResult) { return(false); } field.SetValue(owner, value); } return(true); } TextBlock textBlock = block.FindChild(fieldName); if (textBlock == null) { return(true); } object obj = field.GetValue(owner); if (obj == null) { obj = field.FieldType.InvokeMember("", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null); field.SetValue(owner, obj); } Type type = field.FieldType; if (type == typeof(LogicEntityObject)) { type = field.GetValue(owner).GetType(); } while (type != null) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); for (int j = 0; j < fields.Length; j++) { FieldInfo fieldInfo = fields[j]; if (!IsFieldSerializable(fieldInfo, entitySerialize)) { continue; } bool loadFailure = !LoadFieldValue(entitySerialize, obj, fieldInfo, textBlock, errorString); if (loadFailure) { return(false); } } type = type.BaseType; } if (obj.GetType().IsValueType) { field.SetValue(owner, obj); } return(true); }
private void MainForm_Load(object sender, EventArgs e) { //Engine.config parameters string renderingSystemComponentName = ""; bool allowShaders = true; bool depthBufferAccess = true; string fullSceneAntialiasing = ""; RendererWorld.FilteringModes filtering = RendererWorld.FilteringModes.RecommendedSetting; string renderTechnique = ""; bool fullScreen = true; string videoMode = ""; bool multiMonitorMode = false; bool verticalSync = true; bool allowChangeDisplayFrequency = true; string physicsSystemComponentName = ""; //bool physicsAllowHardwareAcceleration = false; string soundSystemComponentName = ""; string language = "Autodetect"; bool localizeEngine = true; bool localizeToolset = true; string renderingDeviceName = ""; int renderingDeviceIndex = 0; //load from Deployment.config if (VirtualFileSystem.Deployed) { if (!string.IsNullOrEmpty(VirtualFileSystem.DeploymentParameters.DefaultLanguage)) { language = VirtualFileSystem.DeploymentParameters.DefaultLanguage; } } //load from Engine.config { string error; TextBlock block = TextBlockUtils.LoadFromRealFile( VirtualFileSystem.GetRealPathByVirtual("user:Configs/Engine.config"), out error); if (block != null) { //Renderer TextBlock rendererBlock = block.FindChild("Renderer"); if (rendererBlock != null) { renderingSystemComponentName = rendererBlock.GetAttribute("implementationComponent"); if (rendererBlock.IsAttributeExist("renderingDeviceName")) { renderingDeviceName = rendererBlock.GetAttribute("renderingDeviceName"); } if (rendererBlock.IsAttributeExist("renderingDeviceIndex")) { renderingDeviceIndex = int.Parse(rendererBlock.GetAttribute("renderingDeviceIndex")); } if (rendererBlock.IsAttributeExist("allowShaders")) { allowShaders = bool.Parse(rendererBlock.GetAttribute("allowShaders")); } if (rendererBlock.IsAttributeExist("depthBufferAccess")) { depthBufferAccess = bool.Parse(rendererBlock.GetAttribute("depthBufferAccess")); } if (rendererBlock.IsAttributeExist("fullSceneAntialiasing")) { fullSceneAntialiasing = rendererBlock.GetAttribute("fullSceneAntialiasing"); } if (rendererBlock.IsAttributeExist("filtering")) { try { filtering = (RendererWorld.FilteringModes) Enum.Parse(typeof(RendererWorld.FilteringModes), rendererBlock.GetAttribute("filtering")); } catch { } } if (rendererBlock.IsAttributeExist("renderTechnique")) { renderTechnique = rendererBlock.GetAttribute("renderTechnique"); } if (rendererBlock.IsAttributeExist("fullScreen")) { fullScreen = bool.Parse(rendererBlock.GetAttribute("fullScreen")); } if (rendererBlock.IsAttributeExist("videoMode")) { videoMode = rendererBlock.GetAttribute("videoMode"); } if (rendererBlock.IsAttributeExist("multiMonitorMode")) { multiMonitorMode = bool.Parse(rendererBlock.GetAttribute("multiMonitorMode")); } if (rendererBlock.IsAttributeExist("verticalSync")) { verticalSync = bool.Parse(rendererBlock.GetAttribute("verticalSync")); } if (rendererBlock.IsAttributeExist("allowChangeDisplayFrequency")) { allowChangeDisplayFrequency = bool.Parse( rendererBlock.GetAttribute("allowChangeDisplayFrequency")); } } //Physics system TextBlock physicsSystemBlock = block.FindChild("PhysicsSystem"); if (physicsSystemBlock != null) { physicsSystemComponentName = physicsSystemBlock.GetAttribute("implementationComponent"); //if( physicsSystemBlock.IsAttributeExist( "allowHardwareAcceleration" ) ) //{ // physicsAllowHardwareAcceleration = // bool.Parse( physicsSystemBlock.GetAttribute( "allowHardwareAcceleration" ) ); //} } //Sound system TextBlock soundSystemBlock = block.FindChild("SoundSystem"); if (soundSystemBlock != null) { soundSystemComponentName = soundSystemBlock.GetAttribute("implementationComponent"); } //Localization TextBlock localizationBlock = block.FindChild("Localization"); if (localizationBlock != null) { if (localizationBlock.IsAttributeExist("language")) { language = localizationBlock.GetAttribute("language"); } if (localizationBlock.IsAttributeExist("localizeEngine")) { localizeEngine = bool.Parse(localizationBlock.GetAttribute("localizeEngine")); } if (localizationBlock.IsAttributeExist("localizeToolset")) { localizeToolset = bool.Parse(localizationBlock.GetAttribute("localizeToolset")); } } } } //init toolset language if (localizeToolset) { if (!string.IsNullOrEmpty(language)) { string language2 = language; if (string.Compare(language2, "autodetect", true) == 0) { language2 = DetectLanguage(); } string languageDirectory = Path.Combine(LanguageManager.LanguagesDirectory, language2); string fileName = Path.Combine(languageDirectory, "Configurator.language"); ToolsLocalization.Init(fileName); } } //fill render system { EngineComponentManager.ComponentInfo[] components = GetSortedComponentsByType( EngineComponentManager.ComponentTypeFlags.RenderingSystem); if (string.IsNullOrEmpty(renderingSystemComponentName)) { //find component by default foreach (EngineComponentManager.ComponentInfo component2 in components) { if (component2.IsEnabledByDefaultForThisPlatform()) { renderingSystemComponentName = component2.Name; break; } } } //rendering systems combo box foreach (EngineComponentManager.ComponentInfo component in components) { string text = component.FullName; if (component.IsEnabledByDefaultForThisPlatform()) { text = string.Format(Translate("{0} (default)"), text); } int itemId = comboBoxRenderSystems.Items.Add(text); if (renderingSystemComponentName == component.Name) { comboBoxRenderSystems.SelectedIndex = itemId; } } if (comboBoxRenderSystems.Items.Count != 0 && comboBoxRenderSystems.SelectedIndex == -1) { comboBoxRenderSystems.SelectedIndex = 0; } //rendering device { if (comboBoxRenderingDevices.Items.Count > 1 && !string.IsNullOrEmpty(renderingDeviceName)) { int deviceCountWithSelectedName = 0; for (int n = 1; n < comboBoxRenderingDevices.Items.Count; n++) { string name = (string)comboBoxRenderingDevices.Items[n]; if (name == renderingDeviceName) { comboBoxRenderingDevices.SelectedIndex = n; deviceCountWithSelectedName++; } } if (deviceCountWithSelectedName > 1) { int comboBoxIndex = renderingDeviceIndex + 1; if (comboBoxIndex < comboBoxRenderingDevices.Items.Count) { string name = (string)comboBoxRenderingDevices.Items[comboBoxIndex]; if (name == renderingDeviceName) { comboBoxRenderingDevices.SelectedIndex = comboBoxIndex; } } } } if (comboBoxRenderingDevices.SelectedIndex == -1 && comboBoxRenderingDevices.Items.Count != 0) { comboBoxRenderingDevices.SelectedIndex = 0; } } //allowShaders checkBoxAllowShaders.Checked = allowShaders; //depthBufferAccess comboBoxDepthBufferAccess.Items.Add(Translate("No")); comboBoxDepthBufferAccess.Items.Add(Translate("Yes")); comboBoxDepthBufferAccess.SelectedIndex = depthBufferAccess ? 1 : 0; //fullSceneAntialiasing for (int n = 0; n < comboBoxAntialiasing.Items.Count; n++) { ComboBoxItem item = (ComboBoxItem)comboBoxAntialiasing.Items[n]; if (item.Identifier == fullSceneAntialiasing) { comboBoxAntialiasing.SelectedIndex = n; } } if (comboBoxAntialiasing.SelectedIndex == -1) { comboBoxAntialiasing.SelectedIndex = 0; } //filtering { Type enumType = typeof(RendererWorld.FilteringModes); LocalizedEnumConverter enumConverter = new LocalizedEnumConverter(enumType); RendererWorld.FilteringModes[] values = (RendererWorld.FilteringModes[])Enum.GetValues(enumType); for (int n = 0; n < values.Length; n++) { RendererWorld.FilteringModes value = values[n]; int index = comboBoxFiltering.Items.Add(enumConverter.ConvertToString(value)); if (filtering == value) { comboBoxFiltering.SelectedIndex = index; } } } //renderTechnique { comboBoxRenderTechnique.Items.Add(new ComboBoxItem("RecommendedSetting", "Recommended setting")); comboBoxRenderTechnique.Items.Add(new ComboBoxItem("Standard", "Low Dynamic Range (Standard)")); comboBoxRenderTechnique.Items.Add(new ComboBoxItem("HDR", "64-bit High Dynamic Range (HDR)")); for (int n = 0; n < comboBoxRenderTechnique.Items.Count; n++) { ComboBoxItem item = (ComboBoxItem)comboBoxRenderTechnique.Items[n]; if (item.Identifier == renderTechnique) { comboBoxRenderTechnique.SelectedIndex = n; } } if (comboBoxRenderTechnique.SelectedIndex == -1) { comboBoxRenderTechnique.SelectedIndex = 0; } } //video mode { comboBoxVideoMode.Items.Add(Translate("Current screen resolution")); comboBoxVideoMode.SelectedIndex = 0; comboBoxVideoMode.Items.Add(Translate("Use all displays (multi-monitor mode)")); if (multiMonitorMode) { comboBoxVideoMode.SelectedIndex = 1; } foreach (Vec2I mode in DisplaySettings.VideoModes) { if (mode.X < 640) { continue; } comboBoxVideoMode.Items.Add(string.Format("{0}x{1}", mode.X, mode.Y)); if (mode.ToString() == videoMode) { comboBoxVideoMode.SelectedIndex = comboBoxVideoMode.Items.Count - 1; } } if (!string.IsNullOrEmpty(videoMode) && comboBoxVideoMode.SelectedIndex == 0) { try { Vec2I mode = Vec2I.Parse(videoMode); comboBoxVideoMode.Items.Add(string.Format("{0}x{1}", mode.X, mode.Y)); comboBoxVideoMode.SelectedIndex = comboBoxVideoMode.Items.Count - 1; } catch { } } } //full screen checkBoxFullScreen.Checked = fullScreen; //vertical sync checkBoxVerticalSync.Checked = verticalSync; } //fill physics system page { EngineComponentManager.ComponentInfo[] components = GetSortedComponentsByType( EngineComponentManager.ComponentTypeFlags.PhysicsSystem); if (string.IsNullOrEmpty(physicsSystemComponentName)) { //find component by default foreach (EngineComponentManager.ComponentInfo component2 in components) { if (component2.IsEnabledByDefaultForThisPlatform()) { physicsSystemComponentName = component2.Name; break; } } } //update combo box foreach (EngineComponentManager.ComponentInfo component in components) { string text = component.FullName; if (component.IsEnabledByDefaultForThisPlatform()) { text = string.Format(Translate("{0} (default)"), text); } int itemId = comboBoxPhysicsSystems.Items.Add(text); if (physicsSystemComponentName == component.Name) { comboBoxPhysicsSystems.SelectedIndex = itemId; } } if (comboBoxPhysicsSystems.SelectedIndex == -1) { comboBoxPhysicsSystems.SelectedIndex = 0; } //if( checkBoxPhysicsAllowHardwareAcceleration.Enabled ) // checkBoxPhysicsAllowHardwareAcceleration.Checked = physicsAllowHardwareAcceleration; } //fill sound system page { EngineComponentManager.ComponentInfo[] components = GetSortedComponentsByType( EngineComponentManager.ComponentTypeFlags.SoundSystem); if (string.IsNullOrEmpty(soundSystemComponentName)) { //find component by default foreach (EngineComponentManager.ComponentInfo component2 in components) { if (component2.IsEnabledByDefaultForThisPlatform()) { soundSystemComponentName = component2.Name; break; } } } //update combo box foreach (EngineComponentManager.ComponentInfo component in components) { string text = component.FullName; if (component.IsEnabledByDefaultForThisPlatform()) { text = string.Format(Translate("{0} (default)"), text); } int itemId = comboBoxSoundSystems.Items.Add(text); if (soundSystemComponentName == component.Name) { comboBoxSoundSystems.SelectedIndex = itemId; } } if (comboBoxSoundSystems.SelectedIndex == -1) { comboBoxSoundSystems.SelectedIndex = 0; } } //fill localization page { List <string> languages = new List <string>(); { languages.Add(Translate("Autodetect")); string[] directories = VirtualDirectory.GetDirectories(LanguageManager.LanguagesDirectory, "*.*", SearchOption.TopDirectoryOnly); foreach (string directory in directories) { languages.Add(Path.GetFileNameWithoutExtension(directory)); } } foreach (string lang in languages) { int itemId = comboBoxLanguages.Items.Add(lang); if (string.Compare(language, lang, true) == 0) { comboBoxLanguages.SelectedIndex = itemId; } } if (comboBoxLanguages.SelectedIndex == -1) { comboBoxLanguages.SelectedIndex = 0; } checkBoxLocalizeEngine.Checked = localizeEngine; checkBoxLocalizeToolset.Checked = localizeToolset; } Translate(); formLoaded = true; }
public void Load( TextBlock block ) { if( block.IsAttributeExist( "scroll" ) ) scroll = Vec2.Parse( block.GetAttribute( "scroll" ) ); if( block.IsAttributeExist( "scale" ) ) scale = Vec2.Parse( block.GetAttribute( "scale" ) ); if( block.IsAttributeExist( "rotate" ) ) rotate = float.Parse( block.GetAttribute( "rotate" ) ); if( block.IsAttributeExist( "dynamicParameters" ) ) dynamicParameters = bool.Parse( block.GetAttribute( "dynamicParameters" ) ); TextBlock animationBlock = block.FindChild( "animation" ); if( animationBlock != null ) animation.Load( animationBlock ); }
private static bool LoadArrayFieldValue(bool entitySerialize, object targetObj, FieldInfo fieldInfo, TextBlock textBlock, string text) { bool isArray = fieldInfo.FieldType.IsArray; Type typeElement; if (isArray) { typeElement = fieldInfo.FieldType.GetElementType(); } else { typeElement = fieldInfo.FieldType.GetGenericArguments()[0]; } string name = GetFieldSerializeName(entitySerialize, fieldInfo); TextBlock blockChild = textBlock.FindChild(name); #region typeElement == typeof(string) if (typeElement == typeof(string)) { if (blockChild != null) { List <object> list = new List <object>(blockChild.Children.Count); foreach (TextBlock current in blockChild.Children) { string currentValue = current.GetAttribute("value"); if (string.IsNullOrEmpty(currentValue) && string.Compare(current.GetAttribute(NULL_ITEM), "true", true) == 0) { currentValue = null; } list.Add(currentValue); } SetArrayFieldValue(targetObj, fieldInfo, list); } return(true); } #endregion #region Simple Type bool typeIsEntityType = typeof(EntityType).IsAssignableFrom(typeElement); bool typeIsEntity = typeof(Entity).IsAssignableFrom(typeElement); if ((SimpleTypesUtils.IsSimpleType(typeElement) | typeIsEntityType | typeIsEntity) || typeof(Type) == typeElement) { if (!entitySerialize & typeIsEntity) { Log.Fatal("Entity System: Serialization Entity classes in entity types is forbidden ({0}).", text); return(false); } if (textBlock.IsAttributeExist(name)) { string nameAttr = textBlock.GetAttribute(name); string[] nameArr; if (nameAttr.Length != 0) { char c = ';'; bool flag11 = typeElement.IsPrimitive | typeIsEntity; if (flag11) { c = ' '; } nameArr = nameAttr.Split(new char[] { c }); } else { nameArr = new string[0]; } List <object> values = new List <object>(nameArr.Length); for (int i = 0; i < nameArr.Length; i++) { string strValue = nameArr[i]; object item; bool loadFailure = !ConvertFromString(typeElement, strValue, text, out item); if (loadFailure) { return(false); } values.Add(item); } SetArrayFieldValue(targetObj, fieldInfo, values); } return(true); } #endregion if (blockChild != null) { List <FieldInfo> typeElementFields = GetTypeSerializableFields(entitySerialize, typeElement); List <object> children = new List <object>(blockChild.Children.Count); foreach (TextBlock textChild in blockChild.Children) { object elementObject; if (string.Compare(textChild.GetAttribute(NULL_ITEM), "true", true) != 0) { elementObject = typeElement.InvokeMember("", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null); if (elementObject == null) { Log.Fatal("EntitySystem: Serialization: InvokeMember failed for \"{0}\"", typeElement); return(false); } using (List <FieldInfo> .Enumerator itElementField = typeElementFields.GetEnumerator()) { while (itElementField.MoveNext()) { FieldInfo currentField = itElementField.Current; bool loadOk = LoadFieldValue(entitySerialize, elementObject, currentField, textChild, text); if (!loadOk) { return(false); } } children.Add(elementObject); continue; } } children.Add(null); } SetArrayFieldValue(targetObj, fieldInfo, children); } return(true); }
protected override bool OnLoad( TextBlock block ) { if( !base.OnLoad( block ) ) return false; //General { if( block.IsAttributeExist( "blending" ) ) blending = (MaterialBlendingTypes)Enum.Parse( typeof( MaterialBlendingTypes ), block.GetAttribute( "blending" ) ); if( block.IsAttributeExist( "lighting" ) ) lighting = bool.Parse( block.GetAttribute( "lighting" ) ); if( block.IsAttributeExist( "ambientLighting" ) ) ambientLighting = bool.Parse( block.GetAttribute( "ambientLighting" ) ); if( block.IsAttributeExist( "doubleSided" ) ) doubleSided = bool.Parse( block.GetAttribute( "doubleSided" ) ); //old version compatibility if( block.IsAttributeExist( "culling" ) ) doubleSided = !bool.Parse( block.GetAttribute( "culling" ) ); if( block.IsAttributeExist( "useNormals" ) ) useNormals = bool.Parse( block.GetAttribute( "useNormals" ) ); if( block.IsAttributeExist( "receiveShadows" ) ) receiveShadows = bool.Parse( block.GetAttribute( "receiveShadows" ) ); if( block.IsAttributeExist( "receiveSimpleShadows" ) ) receiveSimpleShadows = bool.Parse( block.GetAttribute( "receiveSimpleShadows" ) ); if( block.IsAttributeExist( "alphaRejectFunction" ) ) alphaRejectFunction = (CompareFunction)Enum.Parse( typeof( CompareFunction ), block.GetAttribute( "alphaRejectFunction" ) ); if( block.IsAttributeExist( "alphaRejectValue" ) ) alphaRejectValue = byte.Parse( block.GetAttribute( "alphaRejectValue" ) ); if( block.IsAttributeExist( "alphaToCoverage" ) ) alphaToCoverage = bool.Parse( block.GetAttribute( "alphaToCoverage" ) ); if( block.IsAttributeExist( "fadingByDistanceRange" ) ) fadingByDistanceRange = Range.Parse( block.GetAttribute( "fadingByDistanceRange" ) ); if( block.IsAttributeExist( "allowFog" ) ) allowFog = bool.Parse( block.GetAttribute( "allowFog" ) ); if( block.IsAttributeExist( "depthWrite" ) ) depthWrite = bool.Parse( block.GetAttribute( "depthWrite" ) ); if( block.IsAttributeExist( "depthTest" ) ) depthTest = bool.Parse( block.GetAttribute( "depthTest" ) ); if( block.IsAttributeExist( "softParticles" ) ) softParticles = bool.Parse( block.GetAttribute( "softParticles" ) ); if( block.IsAttributeExist( "softParticlesFadingLength" ) ) softParticlesFadingLength = float.Parse( block.GetAttribute( "softParticlesFadingLength" ) ); if( block.IsAttributeExist( "depthOffset" ) ) depthOffset = float.Parse( block.GetAttribute( "depthOffset" ) ); if( block.IsAttributeExist( "halfLambert" ) ) halfLambert = bool.Parse( block.GetAttribute( "halfLambert" ) ); } //Diffuse { //old version compatibility if( block.IsAttributeExist( "diffuseScale" ) ) { diffuseColor = ColorValue.Parse( block.GetAttribute( "diffuseScale" ) ); float power = Math.Max( Math.Max( diffuseColor.Red, diffuseColor.Green ), diffuseColor.Blue ); if( power > 1 ) { diffuseColor.Red /= power; diffuseColor.Green /= power; diffuseColor.Blue /= power; diffusePower = power; } } if( block.IsAttributeExist( "diffuseColor" ) ) diffuseColor = ColorValue.Parse( block.GetAttribute( "diffuseColor" ) ); if( block.IsAttributeExist( "diffusePower" ) ) diffusePower = float.Parse( block.GetAttribute( "diffusePower" ) ); if( block.IsAttributeExist( "diffuseScaleDynamic" ) ) diffuseScaleDynamic = bool.Parse( block.GetAttribute( "diffuseScaleDynamic" ) ); if( block.IsAttributeExist( "diffuseVertexColor" ) ) diffuseVertexColor = bool.Parse( block.GetAttribute( "diffuseVertexColor" ) ); TextBlock diffuse1MapBlock = block.FindChild( "diffuse1Map" ); if( diffuse1MapBlock != null ) diffuse1Map.Load( diffuse1MapBlock ); TextBlock diffuse2MapBlock = block.FindChild( "diffuse2Map" ); if( diffuse2MapBlock != null ) diffuse2Map.Load( diffuse2MapBlock ); TextBlock diffuse3MapBlock = block.FindChild( "diffuse3Map" ); if( diffuse3MapBlock != null ) diffuse3Map.Load( diffuse3MapBlock ); TextBlock diffuse4MapBlock = block.FindChild( "diffuse4Map" ); if( diffuse4MapBlock != null ) diffuse4Map.Load( diffuse4MapBlock ); //old version compatibility if( block.IsAttributeExist( "diffuseMap" ) ) diffuse1Map.Texture = block.GetAttribute( "diffuseMap" ); } //Reflection { if( block.IsAttributeExist( "reflectionScale" ) ) { reflectionColor = ColorValue.Parse( block.GetAttribute( "reflectionScale" ) ); float power = Math.Max( Math.Max( reflectionColor.Red, reflectionColor.Green ), Math.Max( reflectionColor.Blue, reflectionColor.Alpha ) ); if( power > 1 ) { reflectionColor /= power; reflectionPower = power; } } if( block.IsAttributeExist( "reflectionColor" ) ) reflectionColor = ColorValue.Parse( block.GetAttribute( "reflectionColor" ) ); if( block.IsAttributeExist( "reflectionPower" ) ) reflectionPower = float.Parse( block.GetAttribute( "reflectionPower" ) ); if( block.IsAttributeExist( "reflectionScaleDynamic" ) ) reflectionScaleDynamic = bool.Parse( block.GetAttribute( "reflectionScaleDynamic" ) ); TextBlock reflectionMapBlock = block.FindChild( "reflectionMap" ); if( reflectionMapBlock != null ) reflectionMap.Load( reflectionMapBlock ); if( block.IsAttributeExist( "reflectionSpecificCubemap" ) ) reflectionSpecificCubemap = block.GetAttribute( "reflectionSpecificCubemap" ); //old version compatibility if( block.IsAttributeExist( "reflectionMap" ) ) reflectionMap.Texture = block.GetAttribute( "reflectionMap" ); if( block.IsAttributeExist( "reflectionBoxParallaxCorrectedCubemaps" ) ) reflectionBoxParallaxCorrectedCubemaps = bool.Parse( block.GetAttribute( "reflectionBoxParallaxCorrectedCubemaps" ) ); } //Emission { if( block.IsAttributeExist( "emissionScale" ) ) { emissionColor = ColorValue.Parse( block.GetAttribute( "emissionScale" ) ); float power = Math.Max( Math.Max( emissionColor.Red, emissionColor.Green ), Math.Max( emissionColor.Blue, emissionColor.Alpha ) ); if( power > 1 ) { emissionColor /= power; emissionPower = power; } } if( block.IsAttributeExist( "emissionColor" ) ) emissionColor = ColorValue.Parse( block.GetAttribute( "emissionColor" ) ); if( block.IsAttributeExist( "emissionPower" ) ) emissionPower = float.Parse( block.GetAttribute( "emissionPower" ) ); if( block.IsAttributeExist( "emissionScaleDynamic" ) ) emissionScaleDynamic = bool.Parse( block.GetAttribute( "emissionScaleDynamic" ) ); TextBlock emissionMapBlock = block.FindChild( "emissionMap" ); if( emissionMapBlock != null ) emissionMap.Load( emissionMapBlock ); //old version compatibility if( block.IsAttributeExist( "emissionMap" ) ) emissionMap.Texture = block.GetAttribute( "emissionMap" ); } //Specular { if( block.IsAttributeExist( "specularScale" ) ) { specularColor = ColorValue.Parse( block.GetAttribute( "specularScale" ) ); float power = Math.Max( Math.Max( specularColor.Red, specularColor.Green ), Math.Max( specularColor.Blue, specularColor.Alpha ) ); if( power > 1 ) { specularColor /= power; specularPower = power; } } if( block.IsAttributeExist( "specularColor" ) ) specularColor = ColorValue.Parse( block.GetAttribute( "specularColor" ) ); if( block.IsAttributeExist( "specularPower" ) ) specularPower = float.Parse( block.GetAttribute( "specularPower" ) ); if( block.IsAttributeExist( "specularScaleDynamic" ) ) specularScaleDynamic = bool.Parse( block.GetAttribute( "specularScaleDynamic" ) ); TextBlock specularMapBlock = block.FindChild( "specularMap" ); if( specularMapBlock != null ) specularMap.Load( specularMapBlock ); if( block.IsAttributeExist( "specularShininess" ) ) specularShininess = float.Parse( block.GetAttribute( "specularShininess" ) ); //old version compatibility if( block.IsAttributeExist( "specularMap" ) ) specularMap.Texture = block.GetAttribute( "specularMap" ); } //Translucency { if( block.IsAttributeExist( "translucencyColor" ) ) translucencyColor = ColorValue.Parse( block.GetAttribute( "translucencyColor" ) ); if( block.IsAttributeExist( "translucencyPower" ) ) translucencyPower = float.Parse( block.GetAttribute( "translucencyPower" ) ); if( block.IsAttributeExist( "translucencyDynamic" ) ) translucencyDynamic = bool.Parse( block.GetAttribute( "translucencyDynamic" ) ); TextBlock translucencyMapBlock = block.FindChild( "translucencyMap" ); if( translucencyMapBlock != null ) translucencyMap.Load( translucencyMapBlock ); if( block.IsAttributeExist( "translucencyClearness" ) ) translucencyClearness = float.Parse( block.GetAttribute( "translucencyClearness" ) ); } //Height { TextBlock normalMapBlock = block.FindChild( "normalMap" ); if( normalMapBlock != null ) normalMap.Load( normalMapBlock ); TextBlock heightMapBlock = block.FindChild( "heightMap" ); if( heightMapBlock != null ) heightMap.Load( heightMapBlock ); if( block.IsAttributeExist( "heightFromNormalMapAlpha" ) ) heightFromNormalMapAlpha = bool.Parse( block.GetAttribute( "heightFromNormalMapAlpha" ) ); if( block.IsAttributeExist( "displacementTechnique" ) ) { displacementTechnique = (DisplacementTechniques)Enum.Parse( typeof( DisplacementTechniques ), block.GetAttribute( "displacementTechnique" ) ); } if( block.IsAttributeExist( "heightScale" ) ) heightScale = float.Parse( block.GetAttribute( "heightScale" ) ); //old version compatibility if( block.IsAttributeExist( "normalMap" ) ) normalMap.Texture = block.GetAttribute( "normalMap" ); if( block.IsAttributeExist( "heightMap" ) ) heightMap.Texture = block.GetAttribute( "heightMap" ); } return true; }
public virtual void Load( TextBlock block ) { if( block.IsAttributeExist( "texture" ) ) texture = block.GetAttribute( "texture" ); if( block.IsAttributeExist( "texCoord" ) ) texCoord = (TexCoordIndexes)Enum.Parse( typeof( TexCoordIndexes ), block.GetAttribute( "texCoord" ) ); if( block.IsAttributeExist( "clamp" ) ) clamp = bool.Parse( block.GetAttribute( "clamp" ) ); TextBlock transformBlock = block.FindChild( "transform" ); if( transformBlock != null ) transform.Load( transformBlock ); }
protected virtual bool OnLoad(TextBlock block) { if (block.IsAttributeExist("logicClass")) { this.logicClass = (Entities.Instance.GetLoadingEntityBySerializedUIN(uint.Parse(block.GetAttribute("logicClass"))) as LogicClass); } if (this.logicObject == null && this.logicClass != null) { this.CreateLogicObject(); TextBlock textBlock = block.FindChild("logicObject"); if (textBlock != null && !this.logicObject.A(textBlock)) { return(false); } } string text = this.Type.Name; if (this.name != "") { text += string.Format(" ({0})", this.name); } text = string.Format("Entity: \"{0}\"", text); for (EntityTypes.ClassInfo classInfo = this.Type.ClassInfo; classInfo != null; classInfo = classInfo.BaseClassInfo) { foreach (EntityTypes.ClassInfo.EntitySerializableFieldItem current in classInfo.EntitySerializableFields) { if (/*EntitySystemWorld.Instance.isEntitySerializable(current.SupportedSerializationTypes) &&*/ !EntityHelper.LoadFieldValue(true, this, current.Field, block, text)) { return(false); } } } string text2 = null; if (block.IsAttributeExist("subscriptionsToDeletionEvent")) { text2 = block.GetAttribute("subscriptionsToDeletionEvent"); } else if (block.IsAttributeExist("relationships")) { text2 = block.GetAttribute("relationships"); } else if (block.IsAttributeExist("relations")) { text2 = block.GetAttribute("relations"); } if (text2 != null) { string[] array = text2.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); this.subscriptionsToDeletionEvent = new List <Entity>(Math.Max(array.Length, 4)); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; Entity loadingEntityBySerializedUIN = Entities.Instance.GetLoadingEntityBySerializedUIN(uint.Parse(s)); if (loadingEntityBySerializedUIN != null) { this.subscriptionsToDeletionEvent.Add(loadingEntityBySerializedUIN); } } } TextBlock textBlock2 = block.FindChild("extendedProperties"); if (textBlock2 != null) { string typeClass = textBlock2.GetAttribute("class"); Type type = EntitySystemWorld.Instance.FindEntityClassType(typeClass); if (type == null) { Log.Error("Extended properties class \"{0}\" not exists.", typeClass); return(false); } this.CreateExtendedProperties(type); if (!this.extendedProperties.OnLoad(textBlock2)) { return(false); } } if (block.IsAttributeExist("textUserData")) { string attribute2 = block.GetAttribute("textUserData"); if (!string.IsNullOrEmpty(attribute2)) { this.SetTag("TextUserData", attribute2); } } return(true); }
protected override bool OnLoad(TextBlock block) { if (!base.OnLoad(block)) return false; //hitObjects TextBlock hitObjectsBlock = block.FindChild("hitObjects"); if (hitObjectsBlock != null) { if (!hitObjects.Load(hitObjectsBlock)) return false; } return true; }
void InitializeHDRCompositor() { bool editor = EngineApp.Instance.IsResourceEditor || EngineApp.Instance.IsMapEditor; //Add HDR compositor HDRCompositorInstance instance = (HDRCompositorInstance) RendererWorld.Instance.DefaultViewport.AddCompositor("HDR", 0); if (instance == null) { return; } //Enable HDR compositor instance.Enabled = true; //Load default settings TextBlock fileBlock = TextBlockUtils.LoadFromVirtualFile("Definitions/Renderer.config"); if (fileBlock != null) { TextBlock hdrBlock = fileBlock.FindChild("hdr"); if (hdrBlock != null) { if (!editor) //No adaptation in the editors { if (hdrBlock.IsAttributeExist("adaptation")) { HDRCompositorInstance.Adaptation = bool.Parse(hdrBlock.GetAttribute("adaptation")); } if (hdrBlock.IsAttributeExist("adaptationVelocity")) { HDRCompositorInstance.AdaptationVelocity = float.Parse(hdrBlock.GetAttribute("adaptationVelocity")); } if (hdrBlock.IsAttributeExist("adaptationMiddleBrightness")) { HDRCompositorInstance.AdaptationMiddleBrightness = float.Parse(hdrBlock.GetAttribute("adaptationMiddleBrightness")); } if (hdrBlock.IsAttributeExist("adaptationMinimum")) { HDRCompositorInstance.AdaptationMinimum = float.Parse(hdrBlock.GetAttribute("adaptationMinimum")); } if (hdrBlock.IsAttributeExist("adaptationMaximum")) { HDRCompositorInstance.AdaptationMaximum = float.Parse(hdrBlock.GetAttribute("adaptationMaximum")); } } if (hdrBlock.IsAttributeExist("bloomBrightThreshold")) { HDRCompositorInstance.BloomBrightThreshold = float.Parse(hdrBlock.GetAttribute("bloomBrightThreshold")); } if (hdrBlock.IsAttributeExist("bloomScale")) { HDRCompositorInstance.BloomScale = float.Parse(hdrBlock.GetAttribute("bloomScale")); } } } }
public void TestLoadAndSave() { TextBlock textBlock = new TextBlock(); string id = "09234"; string name = "你的名字"; textBlock.SetAttribute("id", id); textBlock.SetAttribute("name", name); string section = "管理器"; TextBlock ctb = textBlock.AddChild(section); string section_id = "sec_928023874"; string section_name = "中文系统简要设计"; ctb.SetAttribute("id", section_id); ctb.SetAttribute("name", section_name); string rowsName = "rows"; TextBlock rowsBlock = ctb.AddChild(rowsName); int rowCount = 8; rowsBlock.SetAttribute("cnt", Convert.ToString(rowCount)); for (int i = 0; i < rowCount; i++) { string row_name = string.Format("row_{0}", i); string row_value = string.Format("值_{0}", i); rowsBlock.SetAttribute(row_name, row_value); } string textResult = textBlock.DumpToString(); string errorMessage = ""; TextBlock block = TextBlock.Parse(textResult, out errorMessage); Assert.IsNotNull(block); // Level 0 string _id = block.GetAttribute("id"); Assert.IsTrue(id == _id); string _name = block.GetAttribute("name"); Assert.IsTrue(name == _name); TextBlock _tbRnd = block.FindChild(Guid.NewGuid().ToString()); Assert.IsNull(_tbRnd); TextBlock _ctb = block.FindChild(section); Assert.IsNotNull(_ctb); string _section_id = _ctb.GetAttribute("id"); Assert.IsTrue(section_id == _section_id); string _section_name = _ctb.GetAttribute("name"); Assert.IsTrue(section_name == _section_name); TextBlock _rowsBlock = _ctb.FindChild(rowsName); Assert.IsNotNull(_rowsBlock); string _cnt = _rowsBlock.GetAttribute("cnt"); int nCnt = -1; int.TryParse(_cnt, out nCnt); Assert.IsTrue(nCnt == rowCount); for (int i = 0; i < nCnt; i++) { string _row_name = string.Format("row_{0}", i); string _row_value = string.Format("值_{0}", i); Assert.IsTrue(_rowsBlock.IsAttributeExist(_row_name)); string __row_value = _rowsBlock.GetAttribute(_row_name); Assert.IsTrue(__row_value == _row_value); } }
protected override bool OnLoad( TextBlock block ) { TextBlock normalModeBlock = block.FindChild( "normalMode" ); if( normalModeBlock != null ) if( !normalMode.Load( normalModeBlock ) ) return false; TextBlock alternativeModeBlock = block.FindChild( "alternativeMode" ); if( alternativeModeBlock != null ) if( !alternativeMode.Load( alternativeModeBlock ) ) return false; return base.OnLoad( block ); }
//static NxAssertResponse ReportAssertViolation( IntPtr pMessage, IntPtr pFile, int line ) //{ // string message = Wrapper.GetOutString( pMessage ); // string file = Wrapper.GetOutString( pFile ); // if( file == null ) // file = "NULL"; // string text = string.Format( "PhysXPhysicsSystem: {0} ({1}:{2})", message, file, line ); // Log.Fatal( text ); // return NxAssertResponse.NX_AR_BREAKPOINT; //} protected override bool OnInitLibrary(bool allowHardwareAcceleration, bool editor) { instance = this; NativeLibraryManager.PreLoadLibrary("PhysXNativeWrapper"); //change current directory for loading PhysX dlls from specified NativeDlls directory. string saveCurrentDirectory = null; if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows) { saveCurrentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(NativeLibraryManager.GetNativeLibrariesDirectory()); } try { preventLogErrors = true; reportErrorDelegate = ReportError; logDelegate = LogMessage; IntPtr errorStringPtr; if (!PhysXNativeWorld.Init(reportErrorDelegate, out errorStringPtr, logDelegate, skinWidth)) { string errorString = Wrapper.GetOutString(errorStringPtr); if (string.IsNullOrEmpty(errorString)) { errorString = "Unknown error."; } Log.Fatal("PhysX: Initialization error: " + errorString); return(false); } preventLogErrors = false; } finally { //restore current directory if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows) { Directory.SetCurrentDirectory(saveCurrentDirectory); } } //configs if (VirtualFile.Exists("Base/Constants/PhysicsSystem.config")) { TextBlock block = TextBlockUtils.LoadFromVirtualFile("Base/Constants/PhysicsSystem.config"); if (block != null) { TextBlock physXBlock = block.FindChild("physXSpecific"); if (physXBlock != null) { if (physXBlock.IsAttributeExist("supportHeightFields")) { supportHeightFields = bool.Parse(physXBlock.GetAttribute("supportHeightFields")); } if (physXBlock.IsAttributeExist("supportVehicles")) { supportVehicles = bool.Parse(physXBlock.GetAttribute("supportVehicles")); } if (physXBlock.IsAttributeExist("writeCacheForCookedTriangleMeshes")) { writeCacheForCookedTriangleMeshes = bool.Parse( physXBlock.GetAttribute("writeCacheForCookedTriangleMeshes")); } if (physXBlock.IsAttributeExist("mainSceneMaxThreads")) { mainSceneMaxThreads = int.Parse(physXBlock.GetAttribute("mainSceneMaxThreads")); } } } } return(true); }
void ChangeToBetterDefaultSettings() { bool shadowTechniqueInitialized = false; bool shadowTextureSizeInitialized = false; if (!string.IsNullOrEmpty(EngineApp.ConfigName)) { string error; TextBlock block = TextBlockUtils.LoadFromRealFile( VirtualFileSystem.GetRealPathByVirtual(EngineApp.ConfigName), out error); if (block != null) { TextBlock blockVideo = block.FindChild("Video"); if (blockVideo != null) { if (blockVideo.IsAttributeExist("shadowTechnique")) { shadowTechniqueInitialized = true; } if (blockVideo.IsAttributeExist("shadowDirectionalLightTextureSize")) { shadowTextureSizeInitialized = true; } } } } //shadowTechnique if (!shadowTechniqueInitialized) { if (RenderSystem.Instance.GPUIsGeForce()) { if (RenderSystem.Instance.GPUCodeName >= GPUCodeNames.GeForce_NV10 && RenderSystem.Instance.GPUCodeName <= GPUCodeNames.GeForce_NV40) { shadowTechnique = ShadowTechniques.ShadowmapLow; } if (RenderSystem.Instance.GPUCodeName == GPUCodeNames.GeForce_G70) { shadowTechnique = ShadowTechniques.ShadowmapMedium; } } if (RenderSystem.Instance.GPUIsRadeon()) { if (RenderSystem.Instance.GPUCodeName >= GPUCodeNames.Radeon_R100 && RenderSystem.Instance.GPUCodeName <= GPUCodeNames.Radeon_R400) { shadowTechnique = ShadowTechniques.ShadowmapLow; } if (RenderSystem.Instance.GPUCodeName == GPUCodeNames.Radeon_R500) { shadowTechnique = ShadowTechniques.ShadowmapMedium; } } if (!RenderSystem.Instance.HasShaderModel2()) { shadowTechnique = ShadowTechniques.None; } } //shadow texture size if (!shadowTextureSizeInitialized) { if (RenderSystem.Instance.GPUIsGeForce()) { if (RenderSystem.Instance.GPUCodeName >= GPUCodeNames.GeForce_NV10 && RenderSystem.Instance.GPUCodeName <= GPUCodeNames.GeForce_G70) { shadowDirectionalLightTextureSize = 1024; shadowSpotLightTextureSize = 1024; shadowPointLightTextureSize = 512; } } else if (RenderSystem.Instance.GPUIsRadeon()) { if (RenderSystem.Instance.GPUCodeName >= GPUCodeNames.Radeon_R100 && RenderSystem.Instance.GPUCodeName <= GPUCodeNames.Radeon_R500) { shadowDirectionalLightTextureSize = 1024; shadowSpotLightTextureSize = 1024; shadowPointLightTextureSize = 512; } } else { shadowDirectionalLightTextureSize = 1024; shadowSpotLightTextureSize = 1024; shadowPointLightTextureSize = 512; } } }
private bool _Startup() { #region 缺省 Entity.tickDelta = 20; #endregion TextBlock textBlock = null; if (VirtualFile.Exists("Base/Constants/EntitySystem.config")) { textBlock = TextBlockUtils.LoadFromVirtualFile("Base/Constants/EntitySystem.config"); if (textBlock != null) { } } if (JxEngineApp.Instance != null) { Entity.tickDelta = JxEngineApp.Instance.LoopInterval; } CreateEntityClassAssembly(typeof(EntitySystemWorld).Assembly); CreateEntityClassAssembly(Assembly.GetExecutingAssembly()); /* * Assembly item = AssemblyUtils.LoadAssemblyByRealFileName("MapSystem.dll", false); * entityClassAssemblies.Add(item); * //*/ ComponentManager.ComponentInfo[] componentsByType = ComponentManager.Instance.GetComponentsByType(ComponentManager.ComponentTypeFlags.EntityClasses, true); for (int i = 0; i < componentsByType.Length; i++) { ComponentManager.ComponentInfo componentInfo = componentsByType[i]; ComponentManager.ComponentInfo.PathInfo[] allEntryPointsForThisPlatform = componentInfo.GetAllEntryPointsForThisPlatform(); LongOperationNotifier.Notify("初始化组件({0}/{1}): {2}, 入口数: {3}", i + 1, componentsByType.Length, componentInfo.FullName, allEntryPointsForThisPlatform.Length); for (int j = 0; j < allEntryPointsForThisPlatform.Length; j++) { ComponentManager.ComponentInfo.PathInfo pathInfo = allEntryPointsForThisPlatform[j]; Assembly assembly = AssemblyUtils.LoadAssemblyByRealFileName(pathInfo.Path, false); CreateEntityClassAssembly(assembly); } } if (textBlock != null) { TextBlock logicSystemBlock = textBlock.FindChild("logicSystem"); if (logicSystemBlock != null) { TextBlock logicSystemClassAssembliesBlock = logicSystemBlock.FindChild("systemClassesAssemblies"); if (logicSystemClassAssembliesBlock != null) { foreach (TextBlock current in logicSystemClassAssembliesBlock.Children) { string assemblyFileName = current.GetAttribute("file"); logicSystemSystemClassesAssemblies.Add(assemblyFileName); } } } } LogicSystemClasses.Init(); if (!EntityTypes.Init()) { return(false); } if (textBlock != null) { string defaultWorldType = textBlock.GetAttribute("defaultWorldType"); if (!string.IsNullOrEmpty(defaultWorldType)) { this.defaultWorldType = EntityTypes.Instance.GetByName(defaultWorldType) as WorldType; if (this.defaultWorldType == null) { this.defaultWorldType = EntityTypes.Instance.GetByName(typeof(DefaultWorld).Name) as WorldType; } } if (this.defaultWorldType == null) { Log.Fatal("EntitySystemWorld: Init: World type \"{0}\" is not defined or it is not a WorldType (Base\\Constants\\EntitySystem.config: \"defaultWorldType\" attribute).", defaultWorldType); return(false); } } Log.Info(">> 默认WorldType: {0}", defaultWorldType); return(true); }
protected override bool OnLoad( TextBlock block ) { if( !base.OnLoad( block ) ) return false; //dieObjects TextBlock dieObjectsBlock = block.FindChild( "dieObjects" ); if( dieObjectsBlock != null ) { if( !dieObjects.Load( dieObjectsBlock ) ) return false; } //old version compatibility if( block.IsAttributeExist( "lifeMax" ) ) healthMax = float.Parse( block.GetAttribute( "lifeMax" ) ); if( block.IsAttributeExist( "lifeMin" ) ) healthMin = float.Parse( block.GetAttribute( "lifeMin" ) ); return true; }
public bool Load( TextBlock block ) { //fireObjects TextBlock fireObjectsBlock = block.FindChild( "fireObjects" ); if( fireObjectsBlock != null ) { if( !fireObjects.Load( fireObjectsBlock ) ) return false; } return true; }
protected virtual void OnSave(TextBlock block) { block.SetAttribute("type", Type.Name); block.SetAttribute("uin", uin.ToString()); if (!(this is LogicComponent)) { block.SetAttribute("classPrompt", Type.ClassInfo.entityClassType.Name); } if (subscriptionsToDeletionEvent != null && subscriptionsToDeletionEvent.Count != 0) { string _subscriptionsToDeletionEvent = string.Join(" ", subscriptionsToDeletionEvent.Select(_x => _x.UIN)); block.SetAttribute("subscriptionsToDeletionEvent", _subscriptionsToDeletionEvent); } string text = Type.Name; if (this.name != "") { text += string.Format(" ({0})", this.name); } text = string.Format("Entity: \"{0}\"", text); for (EntityTypes.ClassInfo classInfo = Type.ClassInfo; classInfo != null; classInfo = classInfo.BaseClassInfo) { foreach (EntityTypes.ClassInfo.EntitySerializableFieldItem current2 in classInfo.EntitySerializableFields) { //if (EntitySystemWorld.Instance.IsEntityFieldSerializable(current2.SupportedSerializationTypes)) { if (!EntityHelper.SaveFieldValue(true, this, current2.Field, block, text)) { return; } } } } if (logicClass != null) { block.SetAttribute("logicClass", logicClass.UIN.ToString()); } if (extendedProperties != null) { TextBlock textBlock = block.AddChild("extendedProperties"); textBlock.SetAttribute("class", this.extendedProperties.GetType().Name); extendedProperties.OnSave(textBlock); } if (logicObject != null) { TextBlock logicObjectBlock = block.FindChild("logicObject"); if (logicObjectBlock == null) { logicObjectBlock = block.AddChild("logicObject"); } logicObject.OnSave(logicObjectBlock); return; } }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); ComboBox comboBox; ScrollBar scrollBar; CheckBox checkBox; window = ControlDeclarationManager.Instance.CreateControl("Gui\\OptionsWindow.gui"); Controls.Add(window); tabControl = (TabControl)window.Controls["TabControl"]; BackColor = new ColorValue(0, 0, 0, .5f); MouseCover = true; //load Engine.config TextBlock engineConfigBlock = LoadEngineConfig(); TextBlock rendererBlock = null; if (engineConfigBlock != null) { rendererBlock = engineConfigBlock.FindChild("Renderer"); } //page buttons pageButtons[0] = (Button)window.Controls["ButtonVideo"]; pageButtons[1] = (Button)window.Controls["ButtonShadows"]; pageButtons[2] = (Button)window.Controls["ButtonSound"]; pageButtons[3] = (Button)window.Controls["ButtonControls"]; pageButtons[4] = (Button)window.Controls["ButtonLanguage"]; foreach (Button pageButton in pageButtons) { pageButton.Click += new Button.ClickDelegate(pageButton_Click); } //Close button ((Button)window.Controls["Close"]).Click += delegate(Button sender) { SetShouldDetach(); }; //pageVideo { Control pageVideo = tabControl.Controls["Video"]; Vec2I currentMode = EngineApp.Instance.VideoMode; //screenResolutionComboBox comboBox = (ComboBox)pageVideo.Controls["ScreenResolution"]; comboBox.Enable = !EngineApp.Instance.MultiMonitorMode; comboBoxResolution = comboBox; if (EngineApp.Instance.MultiMonitorMode) { comboBox.Items.Add(string.Format("{0}x{1} (multi-monitor)", currentMode.X, currentMode.Y)); comboBox.SelectedIndex = 0; } else { foreach (Vec2I mode in DisplaySettings.VideoModes) { if (mode.X < 640) { continue; } comboBox.Items.Add(string.Format("{0}x{1}", mode.X, mode.Y)); if (mode == currentMode) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { ChangeVideoMode(); }; } //gamma scrollBar = (ScrollBar)pageVideo.Controls["Gamma"]; scrollBar.Value = GameEngineApp._Gamma; scrollBar.Enable = true; scrollBar.ValueChange += delegate(ScrollBar sender) { float value = float.Parse(sender.Value.ToString("F1")); GameEngineApp._Gamma = value; pageVideo.Controls["GammaValue"].Text = value.ToString("F1"); }; pageVideo.Controls["GammaValue"].Text = GameEngineApp._Gamma.ToString("F1"); //MaterialScheme { comboBox = (ComboBox)pageVideo.Controls["MaterialScheme"]; foreach (MaterialSchemes materialScheme in Enum.GetValues(typeof(MaterialSchemes))) { comboBox.Items.Add(materialScheme.ToString()); if (GameEngineApp.MaterialScheme == materialScheme) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { if (sender.SelectedIndex != -1) { GameEngineApp.MaterialScheme = (MaterialSchemes)sender.SelectedIndex; } }; } //fullScreen checkBox = (CheckBox)pageVideo.Controls["FullScreen"]; checkBox.Enable = !EngineApp.Instance.MultiMonitorMode; checkBox.Checked = EngineApp.Instance.FullScreen; checkBox.CheckedChange += delegate(CheckBox sender) { EngineApp.Instance.FullScreen = sender.Checked; }; //RenderTechnique { comboBox = (ComboBox)pageVideo.Controls["RenderTechnique"]; comboBox.Items.Add(new ComboBoxItem("RecommendedSetting", Translate("Recommended setting"))); comboBox.Items.Add(new ComboBoxItem("Standard", Translate("Low Dynamic Range (Standard)"))); comboBox.Items.Add(new ComboBoxItem("HDR", Translate("High Dynamic Range (HDR)"))); string renderTechnique = ""; if (rendererBlock != null && rendererBlock.IsAttributeExist("renderTechnique")) { renderTechnique = rendererBlock.GetAttribute("renderTechnique"); } for (int n = 0; n < comboBox.Items.Count; n++) { ComboBoxItem item = (ComboBoxItem)comboBox.Items[n]; if (item.Identifier == renderTechnique) { comboBox.SelectedIndex = n; } } if (comboBox.SelectedIndex == -1) { comboBox.SelectedIndex = 0; } comboBox.SelectedIndexChange += comboBoxRenderTechnique_SelectedIndexChange; } //Filtering { comboBox = (ComboBox)pageVideo.Controls["Filtering"]; Type enumType = typeof(RendererWorld.FilteringModes); LocalizedEnumConverter enumConverter = new LocalizedEnumConverter(enumType); RendererWorld.FilteringModes filtering = RendererWorld.FilteringModes.RecommendedSetting; //get value from Engine.config. if (rendererBlock != null && rendererBlock.IsAttributeExist("filtering")) { try { filtering = (RendererWorld.FilteringModes)Enum.Parse(enumType, rendererBlock.GetAttribute("filtering")); } catch { } } RendererWorld.FilteringModes[] values = (RendererWorld.FilteringModes[])Enum.GetValues(enumType); for (int n = 0; n < values.Length; n++) { RendererWorld.FilteringModes value = values[n]; string valueStr = enumConverter.ConvertToString(value); comboBox.Items.Add(new ComboBoxItem(value.ToString(), Translate(valueStr))); if (filtering == value) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } if (comboBox.SelectedIndex == -1) { comboBox.SelectedIndex = 0; } comboBox.SelectedIndexChange += comboBoxFiltering_SelectedIndexChange; } //DepthBufferAccess { checkBox = (CheckBox)pageVideo.Controls["DepthBufferAccess"]; checkBoxDepthBufferAccess = checkBox; bool depthBufferAccess = true; //get value from Engine.config. if (rendererBlock != null && rendererBlock.IsAttributeExist("depthBufferAccess")) { depthBufferAccess = bool.Parse(rendererBlock.GetAttribute("depthBufferAccess")); } checkBox.Checked = depthBufferAccess; checkBox.CheckedChange += checkBoxDepthBufferAccess_CheckedChange; } //FSAA { comboBox = (ComboBox)pageVideo.Controls["FSAA"]; comboBoxAntialiasing = comboBox; UpdateComboBoxAntialiasing(); string fullSceneAntialiasing = ""; if (rendererBlock != null && rendererBlock.IsAttributeExist("fullSceneAntialiasing")) { fullSceneAntialiasing = rendererBlock.GetAttribute("fullSceneAntialiasing"); } for (int n = 0; n < comboBoxAntialiasing.Items.Count; n++) { ComboBoxItem item = (ComboBoxItem)comboBoxAntialiasing.Items[n]; if (item.Identifier == fullSceneAntialiasing) { comboBoxAntialiasing.SelectedIndex = n; } } comboBoxAntialiasing.SelectedIndexChange += comboBoxAntialiasing_SelectedIndexChange; } //VerticalSync { checkBox = (CheckBox)pageVideo.Controls["VerticalSync"]; bool verticalSync = RendererWorld.InitializationOptions.VerticalSync; //get value from Engine.config. if (rendererBlock != null && rendererBlock.IsAttributeExist("verticalSync")) { verticalSync = bool.Parse(rendererBlock.GetAttribute("verticalSync")); } checkBox.Checked = verticalSync; checkBox.CheckedChange += checkBoxVerticalSync_CheckedChange; } //VideoRestart { Button button = (Button)pageVideo.Controls["VideoRestart"]; button.Click += buttonVideoRestart_Click; } //waterReflectionLevel comboBox = (ComboBox)pageVideo.Controls["WaterReflectionLevel"]; foreach (WaterPlane.ReflectionLevels level in Enum.GetValues( typeof(WaterPlane.ReflectionLevels))) { comboBox.Items.Add(level); if (GameEngineApp.WaterReflectionLevel == level) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { GameEngineApp.WaterReflectionLevel = (WaterPlane.ReflectionLevels)sender.SelectedItem; }; //showDecorativeObjects checkBox = (CheckBox)pageVideo.Controls["ShowDecorativeObjects"]; checkBox.Checked = GameEngineApp.ShowDecorativeObjects; checkBox.CheckedChange += delegate(CheckBox sender) { GameEngineApp.ShowDecorativeObjects = sender.Checked; }; //showSystemCursorCheckBox checkBox = (CheckBox)pageVideo.Controls["ShowSystemCursor"]; checkBox.Checked = GameEngineApp._ShowSystemCursor; checkBox.CheckedChange += delegate(CheckBox sender) { GameEngineApp._ShowSystemCursor = sender.Checked; sender.Checked = GameEngineApp._ShowSystemCursor; }; //showFPSCheckBox checkBox = (CheckBox)pageVideo.Controls["ShowFPS"]; checkBox.Checked = GameEngineApp._DrawFPS; checkBox.CheckedChange += delegate(CheckBox sender) { GameEngineApp._DrawFPS = sender.Checked; sender.Checked = GameEngineApp._DrawFPS; }; } //pageShadows { Control pageShadows = tabControl.Controls["Shadows"]; //ShadowTechnique { comboBox = (ComboBox)pageShadows.Controls["ShadowTechnique"]; comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.None, "None")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapLow, "Shadowmap Low")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapMedium, "Shadowmap Medium")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapHigh, "Shadowmap High")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapLowPSSM, "PSSMx3 Low")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapMediumPSSM, "PSSMx3 Medium")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.ShadowmapHighPSSM, "PSSMx3 High")); comboBox.Items.Add(new ShadowTechniqueItem(ShadowTechniques.Stencil, "Stencil")); for (int n = 0; n < comboBox.Items.Count; n++) { ShadowTechniqueItem item = (ShadowTechniqueItem)comboBox.Items[n]; if (item.Technique == GameEngineApp.ShadowTechnique) { comboBox.SelectedIndex = n; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { if (sender.SelectedIndex != -1) { ShadowTechniqueItem item = (ShadowTechniqueItem)sender.SelectedItem; GameEngineApp.ShadowTechnique = item.Technique; } UpdateShadowControlsEnable(); }; UpdateShadowControlsEnable(); } //ShadowUseMapSettings { checkBox = (CheckBox)pageShadows.Controls["ShadowUseMapSettings"]; checkBox.Checked = GameEngineApp.ShadowUseMapSettings; checkBox.CheckedChange += delegate(CheckBox sender) { GameEngineApp.ShadowUseMapSettings = sender.Checked; if (sender.Checked && Map.Instance != null) { GameEngineApp.ShadowPSSMSplitFactors = Map.Instance.InitialShadowPSSMSplitFactors; GameEngineApp.ShadowFarDistance = Map.Instance.InitialShadowFarDistance; GameEngineApp.ShadowColor = Map.Instance.InitialShadowColor; } UpdateShadowControlsEnable(); if (sender.Checked) { ((ScrollBar)pageShadows.Controls["ShadowFarDistance"]).Value = GameEngineApp.ShadowFarDistance; pageShadows.Controls["ShadowFarDistanceValue"].Text = ((int)GameEngineApp.ShadowFarDistance).ToString(); ColorValue color = GameEngineApp.ShadowColor; ((ScrollBar)pageShadows.Controls["ShadowColor"]).Value = (color.Red + color.Green + color.Blue) / 3; } }; } //ShadowPSSMSplitFactor1 scrollBar = (ScrollBar)pageShadows.Controls["ShadowPSSMSplitFactor1"]; scrollBar.Value = GameEngineApp.ShadowPSSMSplitFactors[0]; scrollBar.ValueChange += delegate(ScrollBar sender) { GameEngineApp.ShadowPSSMSplitFactors = new Vec2( sender.Value, GameEngineApp.ShadowPSSMSplitFactors[1]); pageShadows.Controls["ShadowPSSMSplitFactor1Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[0].ToString("F2")).ToString(); }; pageShadows.Controls["ShadowPSSMSplitFactor1Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[0].ToString("F2")).ToString(); //ShadowPSSMSplitFactor2 scrollBar = (ScrollBar)pageShadows.Controls["ShadowPSSMSplitFactor2"]; scrollBar.Value = GameEngineApp.ShadowPSSMSplitFactors[1]; scrollBar.ValueChange += delegate(ScrollBar sender) { GameEngineApp.ShadowPSSMSplitFactors = new Vec2( GameEngineApp.ShadowPSSMSplitFactors[0], sender.Value); pageShadows.Controls["ShadowPSSMSplitFactor2Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[1].ToString("F2")).ToString(); }; pageShadows.Controls["ShadowPSSMSplitFactor2Value"].Text = (GameEngineApp.ShadowPSSMSplitFactors[1].ToString("F2")).ToString(); //ShadowFarDistance scrollBar = (ScrollBar)pageShadows.Controls["ShadowFarDistance"]; scrollBar.Value = GameEngineApp.ShadowFarDistance; scrollBar.ValueChange += delegate(ScrollBar sender) { GameEngineApp.ShadowFarDistance = sender.Value; pageShadows.Controls["ShadowFarDistanceValue"].Text = ((int)GameEngineApp.ShadowFarDistance).ToString(); }; pageShadows.Controls["ShadowFarDistanceValue"].Text = ((int)GameEngineApp.ShadowFarDistance).ToString(); //ShadowColor scrollBar = (ScrollBar)pageShadows.Controls["ShadowColor"]; scrollBar.Value = (GameEngineApp.ShadowColor.Red + GameEngineApp.ShadowColor.Green + GameEngineApp.ShadowColor.Blue) / 3; scrollBar.ValueChange += delegate(ScrollBar sender) { float color = sender.Value; GameEngineApp.ShadowColor = new ColorValue(color, color, color, color); }; //ShadowDirectionalLightTextureSize { comboBox = (ComboBox)pageShadows.Controls["ShadowDirectionalLightTextureSize"]; for (int value = 256, index = 0; value <= 8192; value *= 2, index++) { comboBox.Items.Add(value); if (GameEngineApp.ShadowDirectionalLightTextureSize == value) { comboBox.SelectedIndex = index; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { GameEngineApp.ShadowDirectionalLightTextureSize = (int)sender.SelectedItem; }; } ////ShadowDirectionalLightMaxTextureCount //{ // comboBox = (EComboBox)pageVideo.Controls[ "ShadowDirectionalLightMaxTextureCount" ]; // for( int n = 0; n < 3; n++ ) // { // int count = n + 1; // comboBox.Items.Add( count ); // if( count == GameEngineApp.ShadowDirectionalLightMaxTextureCount ) // comboBox.SelectedIndex = n; // } // comboBox.SelectedIndexChange += delegate( EComboBox sender ) // { // GameEngineApp.ShadowDirectionalLightMaxTextureCount = (int)sender.SelectedItem; // }; //} //ShadowSpotLightTextureSize { comboBox = (ComboBox)pageShadows.Controls["ShadowSpotLightTextureSize"]; for (int value = 256, index = 0; value <= 8192; value *= 2, index++) { comboBox.Items.Add(value); if (GameEngineApp.ShadowSpotLightTextureSize == value) { comboBox.SelectedIndex = index; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { GameEngineApp.ShadowSpotLightTextureSize = (int)sender.SelectedItem; }; } //ShadowSpotLightMaxTextureCount { comboBox = (ComboBox)pageShadows.Controls["ShadowSpotLightMaxTextureCount"]; for (int n = 0; n < 3; n++) { int count = n + 1; comboBox.Items.Add(count); if (count == GameEngineApp.ShadowSpotLightMaxTextureCount) { comboBox.SelectedIndex = n; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { GameEngineApp.ShadowSpotLightMaxTextureCount = (int)sender.SelectedItem; }; } //ShadowPointLightTextureSize { comboBox = (ComboBox)pageShadows.Controls["ShadowPointLightTextureSize"]; for (int value = 256, index = 0; value <= 8192; value *= 2, index++) { comboBox.Items.Add(value); if (GameEngineApp.ShadowPointLightTextureSize == value) { comboBox.SelectedIndex = index; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { GameEngineApp.ShadowPointLightTextureSize = (int)sender.SelectedItem; }; } //ShadowPointLightMaxTextureCount { comboBox = (ComboBox)pageShadows.Controls["ShadowPointLightMaxTextureCount"]; for (int n = 0; n < 3; n++) { int count = n + 1; comboBox.Items.Add(count); if (count == GameEngineApp.ShadowPointLightMaxTextureCount) { comboBox.SelectedIndex = n; } } comboBox.SelectedIndexChange += delegate(ComboBox sender) { GameEngineApp.ShadowPointLightMaxTextureCount = (int)sender.SelectedItem; }; } } //pageSound { bool enabled = SoundWorld.Instance.DriverName != "NULL"; Control pageSound = tabControl.Controls["Sound"]; //soundVolumeCheckBox scrollBar = (ScrollBar)pageSound.Controls["SoundVolume"]; scrollBar.Value = enabled ? GameEngineApp.SoundVolume : 0; scrollBar.Enable = enabled; scrollBar.ValueChange += delegate(ScrollBar sender) { GameEngineApp.SoundVolume = sender.Value; }; //musicVolumeCheckBox scrollBar = (ScrollBar)pageSound.Controls["MusicVolume"]; scrollBar.Value = enabled ? GameEngineApp.MusicVolume : 0; scrollBar.Enable = enabled; scrollBar.ValueChange += delegate(ScrollBar sender) { GameEngineApp.MusicVolume = sender.Value; }; } //pageControls { Control pageControls = tabControl.Controls["Controls"]; //MouseHSensitivity scrollBar = (ScrollBar)pageControls.Controls["MouseHSensitivity"]; scrollBar.Value = GameControlsManager.Instance.MouseSensitivity.X; scrollBar.ValueChange += delegate(ScrollBar sender) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; value.X = sender.Value; GameControlsManager.Instance.MouseSensitivity = value; }; //MouseVSensitivity scrollBar = (ScrollBar)pageControls.Controls["MouseVSensitivity"]; scrollBar.Value = Math.Abs(GameControlsManager.Instance.MouseSensitivity.Y); scrollBar.ValueChange += delegate(ScrollBar sender) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; bool invert = ((CheckBox)pageControls.Controls["MouseVInvert"]).Checked; value.Y = sender.Value * (invert ? -1.0f : 1.0f); GameControlsManager.Instance.MouseSensitivity = value; }; //MouseVInvert checkBox = (CheckBox)pageControls.Controls["MouseVInvert"]; checkBox.Checked = GameControlsManager.Instance.MouseSensitivity.Y < 0; checkBox.CheckedChange += delegate(CheckBox sender) { Vec2 value = GameControlsManager.Instance.MouseSensitivity; value.Y = ((ScrollBar)pageControls.Controls["MouseVSensitivity"]).Value * (sender.Checked ? -1.0f : 1.0f); GameControlsManager.Instance.MouseSensitivity = value; }; //AlwaysRun checkBox = (CheckBox)pageControls.Controls["AlwaysRun"]; checkBox.Checked = GameControlsManager.Instance.AlwaysRun; checkBox.CheckedChange += delegate(CheckBox sender) { GameControlsManager.Instance.AlwaysRun = sender.Checked; }; //Devices comboBox = (ComboBox)pageControls.Controls["InputDevices"]; comboBoxInputDevices = comboBox; comboBox.Items.Add("Keyboard/Mouse"); if (InputDeviceManager.Instance != null) { foreach (InputDevice device in InputDeviceManager.Instance.Devices) { comboBox.Items.Add(device); } } comboBox.SelectedIndex = 0; comboBox.SelectedIndexChange += delegate(ComboBox sender) { UpdateBindedInputControlsTextBox(); }; //Controls UpdateBindedInputControlsTextBox(); } //pageLanguage { Control pageLanguage = tabControl.Controls["Language"]; //Language { comboBox = (ComboBox)pageLanguage.Controls["Language"]; List <string> languages = new List <string>(); { languages.Add("Autodetect"); string[] directories = VirtualDirectory.GetDirectories(LanguageManager.LanguagesDirectory, "*.*", SearchOption.TopDirectoryOnly); foreach (string directory in directories) { languages.Add(Path.GetFileNameWithoutExtension(directory)); } } string language = "Autodetect"; if (engineConfigBlock != null) { TextBlock localizationBlock = engineConfigBlock.FindChild("Localization"); if (localizationBlock != null && localizationBlock.IsAttributeExist("language")) { language = localizationBlock.GetAttribute("language"); } } foreach (string lang in languages) { string displayName = lang; if (lang == "Autodetect") { displayName = Translate(lang); } comboBox.Items.Add(new ComboBoxItem(lang, displayName)); if (string.Compare(language, lang, true) == 0) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } if (comboBox.SelectedIndex == -1) { comboBox.SelectedIndex = 0; } comboBox.SelectedIndexChange += comboBoxLanguage_SelectedIndexChange; } //LanguageRestart { Button button = (Button)pageLanguage.Controls["LanguageRestart"]; button.Click += buttonLanguageRestart_Click; } } tabControl.SelectedIndex = lastPageIndex; tabControl.SelectedIndexChange += tabControl_SelectedIndexChange; UpdatePageButtonsState(); }
protected override bool OnLoad(TextBlock block) { if (!base.OnLoad(block)) return false; //currentTask { TextBlock taskBlock = block.FindChild("currentTask"); if (taskBlock != null) { Task task = CreateTaskByClassName(taskBlock.GetAttribute("class")); if (task._Load(taskBlock)) currentTask = task; } } //tasks TextBlock tasksBlock = block.FindChild("tasks"); if (tasksBlock != null) { foreach (TextBlock taskBlock in tasksBlock.Children) { if (taskBlock.Name == "item") { Task task = CreateTaskByClassName(taskBlock.GetAttribute("class")); if (task._Load(taskBlock)) tasks.Enqueue(task); } } } return true; }
protected override bool OnSave( TextBlock block ) { TextBlock normalModeBlock = block.FindChild( "normalMode" ); if( normalModeBlock == null ) Log.Fatal( "{0} : normalMode Block not exists", Name ); if( !normalMode.Save( normalModeBlock ) ) return false; TextBlock alternativeModeBlock = block.FindChild( "alternativeMode" ); if( alternativeModeBlock == null ) Log.Fatal( "{0} : alternativeMode Block not exists", Name ); if( !alternativeMode.Save( alternativeModeBlock ) ) return false; return base.OnSave( block ); }
private void btnBuy_Click(Button sender) { //find hangar for what we are trying to spawn Hangar selectedHangar = null; if (currentList == MechDBUnits) { selectedHangar = mechHangar; } if (currentList == GDBUnits) { selectedHangar = groundUnitHangar; } if (currentList == ADBUnits) { selectedHangar = airUnitHangar; } if (currentList == JDBUnits) { selectedHangar = jetHangar; } string un = currentPriceList.Type.PriceLists[ int.Parse(SelectedB.Controls["RelatedUnitID"].Text)].PricedUnit.Name; UnitType ut = (UnitType)EntityTypes.Instance.GetByName(un); TextBlock variant = null; if (variantList.SelectedIndex > 0) { string varName = string.Format("{0}\\Variants\\{1}\\{2}", VirtualFileSystem.UserDirectoryPath, ut.Name, variantList.SelectedItem.ToString()); variant = TextBlockUtils.LoadFromRealFile(varName); } //parse TextBlock to int[] so it can be networked more efficiently AKunitType akt = ut as AKunitType; int[] varData = null; string varDataString = string.Empty; if (variant != null) { //calculate the elements needed for the compressed variant data { int elementCount = 0; foreach (TextBlock c in variant.Children) { elementCount += c.Children.Count; } elementCount *= 4; varData = new int[elementCount]; } int x = 0; for (int i = 0; i < akt.BodyParts.Count; i++) { TextBlock bodyPartBlock = variant.FindChild(akt.BodyParts[i].GUIDesplayName); if (bodyPartBlock != null) { int bodyPartIndex = i; int bodyPartBlockIndex = variant.Children.IndexOf(bodyPartBlock); AKunitType.BodyPart bodyPart = akt.BodyParts[i]; for (int j = 0; j < bodyPart.Weapons.Count; j++) { TextBlock bodyPartWeaponBlock = bodyPartBlock.FindChild(bodyPart.Weapons[j].MapObjectAlias); if (bodyPartWeaponBlock != null) { int bodyPartWeaponIndex = j; int alternateWeaponIndex = int.Parse(bodyPartWeaponBlock.Attributes[0].Value); int fireGroup = int.Parse(bodyPartWeaponBlock.Attributes[1].Value); varData[x] = bodyPartIndex; varData[x + 1] = bodyPartWeaponIndex; varData[x + 2] = alternateWeaponIndex; varData[x + 3] = fireGroup; if (varDataString != string.Empty) { varDataString += ":"; } varDataString += string.Format("{0}:{1}:{2}:{3}", bodyPartIndex, bodyPartWeaponIndex, alternateWeaponIndex, fireGroup); x += 4; } } } } } if (EntitySystemWorld.Instance.IsClientOnly()) { selectedHangar.Client_SendSpawnRequestToServer(ut.Name, varDataString); } else { selectedHangar.SpawnNewUnit(ut, varData); } SetShouldDetach(); }
void LoadAnimationState( TextBlock block ) { TextBlock itemBlock = block.FindChild( "currentAnimationItem" ); if( itemBlock != null ) { string animationBaseName = itemBlock.GetAttribute( "animationBaseName" ); bool allowRandomAnimationNumber = bool.Parse( itemBlock.GetAttribute( "allowRandomAnimationNumber", "true" ) ); bool loop = bool.Parse( itemBlock.GetAttribute( "loop", "true" ) ); currentAnimationItem = animationController.Add( animationBaseName, allowRandomAnimationNumber, loop ); if( currentAnimationItem != null ) { MeshObjectAnimationController.AnimationItem item = currentAnimationItem; if( itemBlock.IsAttributeExist( "velocity" ) ) item.Velocity = float.Parse( itemBlock.GetAttribute( "velocity" ) ); if( itemBlock.IsAttributeExist( "weight" ) ) item.Weight = float.Parse( itemBlock.GetAttribute( "weight" ) ); if( itemBlock.IsAttributeExist( "timePosition" ) ) item.TimePosition = float.Parse( itemBlock.GetAttribute( "timePosition" ) ); } } if( block.IsAttributeExist( "forceAnimationRemainingTime" ) ) { forceAnimationRemainingTime = float.Parse( block.GetAttribute( "forceAnimationRemainingTime" ) ); } }
internal bool A(TextBlock textBlock) { if (textBlock.IsAttributeExist("method")) { this.aAO = (Entities.Instance.GetLoadingEntityBySerializedUIN(uint.Parse(textBlock.GetAttribute("method"))) as LogicMethod); } if (textBlock.IsAttributeExist("logicClassType")) { string attribute = textBlock.GetAttribute("logicClassType"); Type left = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Assembly assembly = assemblies[i]; left = assembly.GetType(attribute); if (left != null) { break; } } if (left == null) { Log.Warning("Entity System: Serialization error. The logic class type is not found \"{0}\".", attribute); return(false); } this.aAo = left; } if (textBlock.IsAttributeExist("logicEntityObjectOwnerEntity")) { this.aAP = Entities.Instance.GetLoadingEntityBySerializedUIN(uint.Parse(textBlock.GetAttribute("logicEntityObjectOwnerEntity"))); } if (textBlock.IsAttributeExist("needReturn")) { this.aAQ = bool.Parse(textBlock.GetAttribute("needReturn")); } if (textBlock.IsAttributeExist("needReturnForWait")) { this.aAq = bool.Parse(textBlock.GetAttribute("needReturnForWait")); } TextBlock textBlock2 = textBlock.FindChild("localVariablesBlock"); if (textBlock2 != null) { foreach (TextBlock current in textBlock2.Children) { LogicLocalVariable logicLocalVariable = new LogicLocalVariable(); if (!logicLocalVariable.A(current)) { return(false); } this.aAR.Add(logicLocalVariable.Name, logicLocalVariable); } } if (textBlock.IsAttributeExist("currentClassActionsLevelIndex")) { this.aAr = int.Parse(textBlock.GetAttribute("currentClassActionsLevelIndex")); } if (textBlock.IsAttributeExist("callActionsLevelIndexes")) { string[] array = textBlock.GetAttribute("callActionsLevelIndexes").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; for (int j = 0; j < array2.Length; j++) { string s = array2[j]; this.aAS.Add(int.Parse(s)); } } return(true); }