public void loadXML(string fileName, bool bOnlyGlobalSettings) { try { //textBox1.Text = fileName; List <LightXML> saveThelocalLights = mLightSet.mLights; //XmlSerializer s = new XmlSerializer(typeof(lightSetXML), new Type[] { }); //Stream st = File.OpenRead(fileName); //mLightSet = (lightSetXML)s.Deserialize(st); //st.Close(); mLightSet = SimGlobals.getSimMain().LoadScenarioLights(fileName, !bOnlyGlobalSettings); if (bOnlyGlobalSettings == true) { mLightSet.mLights = saveThelocalLights; } this.betterPropertyGrid1.SelectedObject = mLightSet; } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnException(ex); } }
//----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- void calculateWorldBounds(bool includeSimMod) { float tileScale = TerrainGlobals.getTerrain().getTileScale(); mWorldMin = TerrainGlobals.getTerrain().getQuadNodeRoot().getDesc().m_min; mWorldMax = TerrainGlobals.getTerrain().getQuadNodeRoot().getDesc().m_max; mWorldMin.Y -= 1.0f; mWorldMax.Y += 1.0f; mWorldMin.X = (float)Math.Floor(mWorldMin.X); mWorldMin.Y = (float)Math.Floor(mWorldMin.Y); mWorldMin.Z = (float)Math.Floor(mWorldMin.Z); mWorldMax.X = (float)Math.Ceiling(mWorldMax.X); mWorldMax.Y = (float)Math.Ceiling(mWorldMax.Y); mWorldMax.Z = (float)Math.Ceiling(mWorldMax.Z); if (includeSimMod) { //include any bounding boxes from objects we're including.. BBoundingBox bb = SimGlobals.getSimMain().getBBoxForDecalObjects(); bb.addPoint(mWorldMax); bb.addPoint(mWorldMin); mWorldMin.Y = bb.min.Y; mWorldMax.Y = bb.max.Y; } if (mWorldMin.X < 0) { mWorldMin.X = 0; } if (mWorldMin.Z < 0) { mWorldMin.Z = 0; } }
private void button4_Click(object sender, EventArgs e) { if (mLightSet.getObjectIDForFLSGen() == -1) { MessageBox.Show("You must specify a light probe object before generating an FLS file"); return; } EditorObject eo = SimGlobals.getSimMain().GetEditorObjectByID(mLightSet.getObjectIDForFLSGen()); if (eo == null) { return; } HelperPositionObject hao = eo as HelperPositionObject; string lightsetFile = Path.Combine(CoreGlobals.ScenarioDirectory, CoreGlobals.ScenarioLightsetFilename); string flsName = Path.ChangeExtension(lightsetFile, ".fls"); // CoreGlobals.getEditorMain().mIGUI.doQuickView(false); // System.Threading.Thread.Sleep(10000); XFSInterface.generateFLS(hao.getPosition().X, hao.getPosition().Y, hao.getPosition().Z, flsName); }
// Delete an objective from the list box private void Delete_Click(object sender, EventArgs e) { if (listBoxObjectives.SelectedItem == null) { return; } // Pause painting listBoxObjectives.BeginUpdate(); // Delete objective from local list SimGlobals.getSimMain().ObjectivesData.mObjectives.Remove(FindObjectiveByName(listBoxObjectives.SelectedItem.ToString())); // Grab objective from list box object deletedObjective = listBoxObjectives.SelectedItem; // Select the next objective in the list box if ((listBoxObjectives.SelectedIndex + 1) < listBoxObjectives.Items.Count) { listBoxObjectives.SelectedIndex += 1; } else if (listBoxObjectives.Items.Count >= 2) { listBoxObjectives.SelectedIndex -= 1; } // Delete the objective from list box listBoxObjectives.Items.Remove(deletedObjective); // Continue painting listBoxObjectives.EndUpdate(); ObjectivesChanged(); }
private void timer1_Tick(object sender, EventArgs e) { timer1.Interval = 250; if (SimGlobals.getSimMain().EditorListChanged() || ListVisibleCheckBox.Checked) { updateListFromSim(); updateSelectionFromSim(); } else { updateSelectionFromSim(); } if (SimGlobals.getSimMain().AllowDepartmentChanges != mbLastDepartmentPermission) { mbLastDepartmentPermission = SimGlobals.getSimMain().AllowDepartmentChanges; betterPropertyGrid1.AddMetaDataForProp("SimObjectData", "Department", "ReadOnly", !mbLastDepartmentPermission); betterPropertyGrid1.SelectedObjects = betterPropertyGrid1.SelectedObjects; } if (mLastDepartementMode != SimGlobals.getSimMain().GetCurrentDepartmentMode()) { mLastDepartementMode = SimGlobals.getSimMain().GetCurrentDepartmentMode(); updateListFromSim(); } //else if (SimGlobals.getSimMain().selectedListChanged()) //{ // updateSelectionFromSim(); // SetProperties(); //} }
private void button1_Click(object sender, EventArgs e) { SimGlobals.getSimMain().moveObjectsExplicit((float)xValue.NumericValue, (float)yValue.NumericValue, (float)zValue.NumericValue, false); }
public void UpdateData() { //mInternalDefinitions = SimGlobals.getSimMain(); InternalScriptsList.ObjectList = mInternalDefinitions;//new List<InternalScriptDescription>(); mExternalDefinitions = SimGlobals.getSimMain().ExternalScripts; ExternalScriptsList.ObjectList = mExternalDefinitions; }
private void button1_Click(object sender, EventArgs e) { SimGlobals.getSimMain().rotateObjectsExplicit(Geometry.DegreeToRadian((float)xValue.NumericValue), Geometry.DegreeToRadian((float)yValue.NumericValue), Geometry.DegreeToRadian((float)zValue.NumericValue), false, checkBox1.Checked); }
// Assign ID based on max ID from scenario private void AssignID(ObjectiveXML objective) { // Bump current ID level SimGlobals.getSimMain().ObjectivesData.MaxObjectiveID++; // Assign ID objective.mID = SimGlobals.getSimMain().ObjectivesData.MaxObjectiveID; }
private void SnapToVisButton_Click(object sender, EventArgs e) { float amount = ((float)AlignmentSlider.NumericValue / 100f); bool setRotation = SetRotationCheckBox.Checked; SimGlobals.getSimMain().updateHeightsFromTerrain(SimGlobals.getSimMain().mSelectedEditorObjects, setRotation, amount); CoreGlobals.getEditorMain().mOneFrame = true; }
private void SimObjAdvNumericMove_Activated(object sender, EventArgs e) { Vector3 widgetPos = SimGlobals.getSimMain().giveWidgetPos(); xValue.NumericValue = widgetPos.X; yValue.NumericValue = widgetPos.Y; zValue.NumericValue = widgetPos.Z; }
private void PropertiesChangedTimer_Tick(object sender, EventArgs e) { if (SimGlobals.getSimMain().selectedListChanged()) { updateSelectionFromSim(); SetProperties(); } }
private void listView1_DoubleClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count >= 1) { ObjectListItemWrapper item = listView1.SelectedItems[0] as ObjectListItemWrapper; SimGlobals.getSimMain().LookAtObject(item.mEditorObject); } }
private void SetToOriginButton_Click(object sender, EventArgs e) { Matrix m = Matrix.Identity; foreach (EditorObject obj in SimGlobals.getSimMain().mSelectedEditorObjects) { obj.setMatrix(m); } CoreGlobals.getEditorMain().mOneFrame = true; }
private void LockByListCheckBox_CheckedChanged(object sender, EventArgs e) { //updateListFromSim(); if (LockByListCheckBox.Checked == true) { SimGlobals.getSimMain().setSelectableObjects(mObjectsInList); } else { SimGlobals.getSimMain().setSelectableObjects(SimGlobals.getSimMain().mEditorObjects); } MainWindow.mMainWindow.SetClientFocus(); }
public void apply() { if (mData.Object == null || mData.Object == "") { return; } //clear our sim first // SimGlobals.getSimMain().selectAll(); // SimGlobals.getSimMain().DeleteSelected(); SimGlobals.getSimMain().placeItemToMaskSimple(mData.Object, true, mData.NumberToPlace); }
// Create a new objective in the local data and add it to the list box private void btnNew_Click(object sender, EventArgs e) { ObjectiveXML newObjective = new ObjectiveXML(); // Set default name int offset = 1; string name = FixupNamePrefix("Objective" + FormatCount(listBoxObjectives.Items.Count + offset), true); while (FindObjectiveByName(name) != null) { offset++; name = FixupNamePrefix("Objective" + FormatCount(listBoxObjectives.Items.Count + offset), true); } newObjective.mObjectiveName = name; // Set default flags newObjective.setFlag(true, "Required"); newObjective.setFlag(true, "Player1"); // Set default description // fixme - encode? newObjective.mDescription = ""; // Set default hint newObjective.mHint = ""; // Set the default score newObjective.mScore = 0; // Assign objective ID AssignID(newObjective); // Add to data SimGlobals.getSimMain().ObjectivesData.mObjectives.Add(newObjective); // Pause painting listBoxObjectives.BeginUpdate(); // Add to list box listBoxObjectives.Items.Add(newObjective.mObjectiveName); // Assign list box selection to the new objective listBoxObjectives.SelectedIndex = listBoxObjectives.Items.IndexOf(newObjective.mObjectiveName); // Resume painting listBoxObjectives.EndUpdate(); ObjectivesChanged(); }
private void onlyRenderList_CheckedChanged(object sender, EventArgs e) { //updateListFromSim(); if (onlyRenderList.Checked == true) { SimGlobals.getSimMain().setVisibleObjects(mObjectsInList); } else { SimGlobals.getSimMain().setVisibleObjects(SimGlobals.getSimMain().mEditorObjects); } MainWindow.mMainWindow.SetClientFocus(); }
private void button1_Click(object sender, EventArgs e) { if (CoreGlobals.getEditorMain().mPhoenixScenarioEditor.CheckTopicPermission("Sim") == false) { return; } string res = SimGlobals.getSimMain().placeItemsToMask(mObjectPlacementSettings); if (res != "") { MessageBox.Show(res); } }
public bool saveXML(string fileName) { if (!Monitor.TryEnter(this)) { return(false); } try { if (fileName == "") { return(false); } if (File.Exists(fileName)) { File.SetAttributes(fileName, FileAttributes.Normal); File.Delete(fileName); } //if (File.Exists(fileName) && ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)) if (File.Exists(fileName) && ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)) { MessageBox.Show(fileName + " is readonly. please check it out"); LiveUpdateCheckBox.Checked = false; return(false); } try { //textBox1.Text = fileName; //XmlSerializer s = new XmlSerializer(typeof(lightSetXML), new Type[] { }); //Stream st = File.Open(fileName, FileMode.OpenOrCreate); //s.Serialize(st, mLightSet); //st.Close(); SimGlobals.getSimMain().SaveScenarioLights(fileName, this.mLightSet); return(true); } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnException(ex); LiveUpdateCheckBox.Checked = false; } } finally { Monitor.Exit(this); } return(false); }
// Find objective data by name private ObjectiveXML FindObjectiveByName(string name) { ObjectiveXML retObjective = null; foreach (ObjectiveXML objective in SimGlobals.getSimMain().ObjectivesData.mObjectives) { if (objective.mObjectiveName == name) { retObjective = objective; break; } } return(retObjective); }
//-------------------------------------------------------------------------- void generateDepthBuffer(ref Surface resultSurf, uint width, uint height, bool furthestDepth, Matrix worldToView, Matrix viewToProj, bool includeSimMod) { renderInit(width, height, targetTexSurf, furthestDepth, worldToView, viewToProj); renderTerrain(0); if (includeSimMod) { SimGlobals.getSimMain().renderObjectsForDecal(); } renderDeinit(pTargetTex); BRenderDevice.getDevice().GetRenderTargetData(targetTexSurf, resultSurf); }
public void LoadListData() { mImageList.ImageSize = new System.Drawing.Size(32, 32); mImageList.Images.Add(new Bitmap(32, 32)); if (SimGlobals.getSimMain().mSimFileData.mProtoObjectsXML != null) { foreach (SimUnitXML unit in SimGlobals.getSimMain().mSimFileData.mProtoObjectsXML.mUnits) { UISimObjectItem n = new UISimObjectItem(unit); mItems.Add(n); } } }
private void JoinButton_Click(object sender, EventArgs e) { if (SimGlobals.getSimMain().mSelectedEditorObjects.Count < 2) { return; } Matrix m = SimGlobals.getSimMain().mSelectedEditorObjects[0].getMatrix(); foreach (EditorObject obj in SimGlobals.getSimMain().mSelectedEditorObjects) { obj.setMatrix(m); } CoreGlobals.getEditorMain().mOneFrame = true; }
private void MatchRotationButton_Click(object sender, EventArgs e) { if (SimGlobals.getSimMain().mSelectedEditorObjects.Count < 2) { return; } Matrix m = SimGlobals.getSimMain().mSelectedEditorObjects[0].getRotationOnly(); foreach (EditorObject obj in SimGlobals.getSimMain().mSelectedEditorObjects) { Matrix trans = m * Matrix.Translation(obj.getPosition()); obj.setMatrix(trans); } CoreGlobals.getEditorMain().mOneFrame = true; }
private void SimObjAdvNumericMove_Load(object sender, EventArgs e) { Vector3 minBounds = CoreGlobals.getEditorMain().mITerrainShared.getBBMin(); Vector3 maxBounds = CoreGlobals.getEditorMain().mITerrainShared.getBBMax(); Vector3 size = maxBounds - minBounds; xValue.Setup(-size.X, size.X, true); yValue.Setup(-size.Y, size.Y, true); zValue.Setup(-size.Z, size.Z, true); Vector3 widgetPos = SimGlobals.getSimMain().giveWidgetPos(); xValue.NumericValue = widgetPos.X; yValue.NumericValue = widgetPos.Y; zValue.NumericValue = widgetPos.Z; }
private void Import_Click(object sender, EventArgs e) { OpenFileDialog d = new OpenFileDialog(); d.Filter = "Global Lightset (*.gls)|*.gls"; d.FilterIndex = 0; d.InitialDirectory = CoreGlobals.getSaveLoadPaths().mGameLightsetBaseDirectory; if (d.ShowDialog() == DialogResult.OK) { loadXML(d.FileName, true); SimGlobals.getSimMain().SetLightsDirty(); CoreGlobals.getSaveLoadPaths().mGameLightsetBaseDirectory = Path.GetDirectoryName(d.FileName); } }
private void WorldObjectListRefresh() { if (mbPauseListUpdate || !mbValidSelectionState) { return; } SimGlobals.getSimMain().mSelectedEditorObjects.Clear(); foreach (ObjectListItemWrapper item in listView1.SelectedItems) { if (item.mEditorObject != null) { SimGlobals.getSimMain().addSelectedObject(item.mEditorObject);//.mSelectedEditorObjects.Add(item.mEditorObject); } } SetProperties(); }
//-------------------------------------------------------------------------- void generateHeightBuffer(ref Surface resultSurf, uint width, uint height, bool furthestDepth, Matrix worldToView, Matrix viewToProj, bool includeSimMod) { renderInit(width, height, targetTexSurf, furthestDepth, worldToView, viewToProj); BRenderDevice.getDevice().Clear(ClearFlags.ZBuffer | ClearFlags.Target, 0, 1, 0); BRenderDevice.getDevice().SetRenderState(RenderStates.ZBufferFunction, (int)Compare.LessEqual); renderTerrain(2); if (includeSimMod) { SimGlobals.getSimMain().renderObjectsForSimrep(); } renderDeinit(pTargetTex); BRenderDevice.getDevice().GetRenderTargetData(targetTexSurf, resultSurf); }
private void updateListFromSim() { int playerFilter = -1; if (PlayerFilterComboBox.SelectedItem != null && PlayerFilterComboBox.SelectedItem.ToString() != "All") { int.TryParse(PlayerFilterComboBox.SelectedItem.ToString(), out playerFilter); } List <EditorObject> visibleObjects = SimGlobals.getSimMain().getEditorObjects(ListVisibleCheckBox.Checked, (SimMain.eFilterTypes)TypeComboBox.SelectedIndex, playerFilter, onlyRenderList.Checked); if (!CompareObjectLists(visibleObjects, mLastVisibleObjects)) { mLastVisibleObjects = visibleObjects; PopulateListBox(visibleObjects); mLastSelectedObjects.Clear(); } }