static public bool safeECFFileWrite(String filename, String ext) { String desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(filename, ext)); String tempDesiredFilename = desiredFilename; ensurePathExists(Path.GetDirectoryName(desiredFilename)); //now that we have all the chunks, write the XTT to file. tempDesiredFilename = Path.ChangeExtension(tempDesiredFilename, ext + "_"); ExportTo360.mECF.writeToFile(tempDesiredFilename); try { //NOW RENAME & DELETE TO ENSURE GOOD WRITES ALL THE TIME if (File.Exists(desiredFilename)) { File.Delete(desiredFilename); } FileInfo fi = new FileInfo(tempDesiredFilename); fi.MoveTo(desiredFilename); File.Delete(tempDesiredFilename); } catch (System.UnauthorizedAccessException ex) { if (!CoreGlobals.IsBatchExport) { CoreGlobals.ShowMessage("Error saving " + desiredFilename + ".\n Make sure this file is checked out from perforce, and that it is not open by XFS. \n EXPORT ABORTED"); } return(false); } return(true); }
private static bool P4CanEditFile(string filename) { if (CoreGlobals.UsingPerforce == false) { throw new System.Exception("Editor Bug. Invalid perforce use"); } SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(filename); if (status.InPerforce == false) { return(true); } if (!status.CheckedOut) { CoreGlobals.ShowMessage(Path.GetFileName(filename) + " is not checked out from perforce. Export Aborted!"); return(false); } if (status.CheckedOutOtherUser == true) { CoreGlobals.ShowMessage(Path.GetFileName(filename) + " is checked out by " + status.ActionOwner + ". Export Aborted!"); return(false); } return(true); }
private void Save() { try { if (mSavedFileName != "") { XmlSerializer s = new XmlSerializer(typeof(TriggerRoot), new Type[] { }); Stream st = File.Open(mSavedFileName, FileMode.Create); TriggerRoot root = TriggerData; root.Name = Path.GetFileName(mSavedFileName); root.Type = mType; s.Serialize(st, root); st.Close(); triggerHostArea1.Scan(true); TriggerFinalBake.eBuildMode mode = TriggerFinalBake.eBuildMode.NoOptimizations; try { mode = (TriggerFinalBake.eBuildMode)Enum.Parse(typeof(TriggerFinalBake.eBuildMode), buildMode.SelectedItem.ToString()); } catch (System.Exception ex2) { CoreGlobals.getErrorManager().OnException(ex2); } //must have _raw_ tag for optimizations if (mSavedFileName.Contains(TriggerFinalBake.sTriggerRaw) == false && TriggerFinalBake.eBuildMode.NoOptimizations != mode) { CoreGlobals.ShowMessage("filename not compatible with optimizations."); mode = TriggerFinalBake.eBuildMode.NoOptimizations; } if (TriggerFinalBake.eBuildMode.NoOptimizations == mode) { XMBProcessor.CreateXMB(mSavedFileName, false); } else { string tempFile = TriggerFinalBake.OptimizeTriggerScript(mSavedFileName, mode); XMBProcessor.CreateXMB(tempFile, false); //File.Copy(tempFile + ".xmb", mSavedFileName + ".xmb", true); } } else { SaveAs(); } } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnException(ex); } }
private void ArtistsDefaultTask_Click(object sender, Xceed.SmartUI.SmartItemClickEventArgs e) { if (mDefaultTinyMap != "") { MainWindow.mMainWindow.OpenScenario(mDefaultTinyMap); } else { CoreGlobals.ShowMessage("Artists_default map not found. please get latest"); } }
private void CheckInButton_Click(object sender, EventArgs e) { using (PerfSection p10 = new PerfSection("Perforce - Check in scenario component: " + mTopic.Name)) { Cursor.Current = Cursors.WaitCursor; PerforceChangeList newlist = CoreGlobals.getPerforce().GetNewChangeList("Scenario Topic: " + GetTopicAlias(mTopic.Name) + " Scenario: " + Path.GetFileNameWithoutExtension(CoreGlobals.ScenarioFile)); foreach (string file in mTopic.Files) { if (newlist.ReOpenFile(file) == false) { CoreGlobals.ShowMessage("Error re-opening: " + file); return; } } mTopic.mbPauseFileCheck = true; bool updateMemoryVersion = false; if (newlist.Submitchanges() == false) { CoreGlobals.ShowMessage("Error checking in files"); } using (PerfSection p1 = new PerfSection("Clean list")) { //CoreGlobals.getPerforce().CleanEmptyChangeLists("Scenario Topic: "); if (CoreGlobals.getPerforce().HasFilesOpen(newlist.ID) == false) { CoreGlobals.getPerforce().getConnection().P4DeleteList(newlist.ID); updateMemoryVersion = true; } } ///////Double check that this is good mTopic.UpdateState(updateMemoryVersion); UpdateUI(); if (!mbPaused && StateChanged != null) { StateChanged.Invoke(this, null); } Cursor.Current = Cursors.Default; mTopic.mbPauseFileCheck = false; } }
public void setTextureProperties() { BTerrainActiveTextureContainer act = TerrainGlobals.getTexturing().getActiveTexture(TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex); if (act == null) { CoreGlobals.ShowMessage("Error getting properties from active texture. index: = " + TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex.ToString()); TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = 0; redrawPreviewList(0); return; } uScalebar.Value = act.mUScale; vScalebar.Value = act.mVScale; specExponentVal.Value = (Decimal)act.mSpecExponent; fresnelBiasVal.Value = (Decimal)act.mFresnelBias; fresnelPowerVal.Value = (Decimal)act.mFresnelPower; fresnelScaleVal.Value = (Decimal)act.mFresnelScale; fresnelRefractVal.Value = (Decimal)act.mFresnelRefractPercent; }
public void CalculateLos() { //getClosestIntersectionPoint( //TileInfo tile = new TileInfo(); //mLowLOSVis float fromLevel = 2; // 2.5f;// 5; float targetLevel = 0; int targetX = 12; // 6; int targetZ = 12; // 6; float3 from = float3.Empty; float3 to = float3.Empty; float3 intersection = float3.Empty; //TileInfo tileInfo = new TileInfo(); mTileLOS = new TileInfo[mWidth * mHeight]; DateTime t = DateTime.Now; for (targetX = 0; targetX < mWidth - 1; targetX++) { for (targetZ = 0; targetZ < mHeight - 1; targetZ++) { try { TileInfo tileInfo = new TileInfo(); mTileLOS[targetX * mWidth + targetZ] = tileInfo; tileInfo.mLowLOSVis = new BitArray64((int)(mWidth * mHeight)); CalculateTileLOS(fromLevel, targetLevel, targetX, targetZ, ref from, ref to, ref intersection, tileInfo.mLowLOSVis); } catch (System.Exception ex) { ex.ToString(); } } } CoreGlobals.ShowMessage(((TimeSpan)(DateTime.Now - t)).TotalSeconds.ToString()); recalculateVisuals(); }
private void SaveButton_Click(object sender, EventArgs e) { string fileName = mFilename; if (File.Exists(fileName) == false) { CoreGlobals.ShowMessage("File Missing: " + fileName); return; } if ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { CoreGlobals.ShowMessage("Please check out: " + fileName); return; } BaseLoader <ProtoConceptDatabase> .Save(mFilename, mDatabase); XMBProcessor.CreateXMB(mFilename, false); }
public void popertiesToActiveTextures() { BTerrainActiveTextureContainer act = TerrainGlobals.getTexturing().getActiveTexture(TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex); if (act == null) { CoreGlobals.ShowMessage("Error setting properties to active texture. index: = " + TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex.ToString()); TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = 0; redrawPreviewList(0); return; } act.mUScale = uScalebar.Value; act.mVScale = vScalebar.Value; act.mSpecExponent = (float)specExponentVal.Value; act.mFresnelBias = (float)fresnelBiasVal.Value; act.mFresnelPower = (float)fresnelPowerVal.Value; act.mFresnelScale = (float)fresnelScaleVal.Value; act.mFresnelRefractPercent = (float)fresnelRefractVal.Value; // TerrainGlobals.getTexturing().writeTexturesToXML(); }
static bool checkSafeToWrite(string desiredFilename) { if (File.Exists(desiredFilename)) { if (CoreGlobals.UsingPerforce == true) { if (P4CanEditFile(desiredFilename)) { if (File.GetAttributes(desiredFilename) == FileAttributes.ReadOnly) { if (!CoreGlobals.IsBatchExport) { CoreGlobals.ShowMessage("ERROR File checked out, but still set as 'READ ONLY': " + desiredFilename); } return(false); } return(true); } else { CoreGlobals.ShowMessage("ERROR Cannot export. Please check out: " + desiredFilename); return(false); } } else { if ((File.GetAttributes(desiredFilename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { CoreGlobals.ShowMessage("ERROR file is set as 'READ ONLY': " + desiredFilename); return(false); } else { return(true); } } } return(false); }
public void loadProtoXML() { string fileName = CoreGlobals.getWorkPaths().GetProtoObjectFile(); mProtoObjectsDoc = new XmlDocument(); mProtoObjectsDoc.PreserveWhitespace = true; mProtoObjectsDoc.Load(fileName); mObjectNames.Clear(); mExistingSoundObjects.Clear(); XmlNodeList units = mProtoObjectsDoc.GetElementsByTagName("Object"); foreach (XmlNode unit in units) { XmlAttribute nameAttr = (XmlAttribute)unit.Attributes.GetNamedItem("name"); if (nameAttr == null) { continue; } if (mObjectNames.ContainsKey(nameAttr.Value)) { mDuplicates.Add(nameAttr.Value); } mObjectNames[nameAttr.Value] = true; //XmlAttribute idAttr = (XmlAttribute)unit.Attributes.GetNamedItem("id"); //if (idAttr != null) //{ // int id = System.Convert.ToInt32((string)idAttr.Value); // if (id > mHightestID) // { // mHightestID = id; // } //} if (nameAttr.Value.Contains("template_sound_object")) { mSoundTemplate = unit; } if (!nameAttr.Value.StartsWith(soundPrefix)) { continue; } mExistingSoundObjects.Add(nameAttr.Value.Replace(soundPrefix, "")); } if (mDuplicates.Count > 0) { StringWriter sw = new StringWriter(); sw.WriteLine("Duplicate Objects:"); foreach (string s in mDuplicates) { sw.WriteLine(s); } CoreGlobals.ShowMessage(sw.ToString()); } }
public void isActive() { isLoading = true; minXBounds.Setup(0, TerrainGlobals.getTerrain().getNumXVerts(), false); maxXBounds.Setup(0, TerrainGlobals.getTerrain().getNumXVerts(), false); minZBounds.Setup(0, TerrainGlobals.getTerrain().getNumXVerts(), false); maxZBounds.Setup(0, TerrainGlobals.getTerrain().getNumXVerts(), false); minXBounds.NumericValue = CoreGlobals.mPlayableBoundsMinX; maxXBounds.NumericValue = CoreGlobals.mPlayableBoundsMaxX; minZBounds.NumericValue = CoreGlobals.mPlayableBoundsMinZ; maxZBounds.NumericValue = CoreGlobals.mPlayableBoundsMaxZ; textBox1.Text = CoreGlobals.ScenarioMinimapTextureFilename; string[] temp = new string[CoreGlobals.ScenarioSoundbankFilenames.Count]; for (int i = 0; i < CoreGlobals.ScenarioSoundbankFilenames.Count; i++) { temp[i] = CoreGlobals.ScenarioSoundbankFilenames[i]; } soundBankBox.Lines = temp; //-- DJB: Yeah this is ugly, but we're at the end of the project, and it's not gonna change. worldComboBox.Items.Clear(); worldComboBox.Items.Add(""); worldComboBox.Items.Add("Harvest"); worldComboBox.Items.Add("Arcadia"); worldComboBox.Items.Add("SWI"); worldComboBox.Items.Add("SWE"); worldComboBox.Text = CoreGlobals.ScenarioWorld; cinematicListBox.Items.Clear(); talkingHeadVideos.Items.Clear(); int count = CoreGlobals.getGameResources().getNumCinematics(); for (int i = 0; i < count; i++) { EditorCinematic ecin = CoreGlobals.getGameResources().getCinematic(i); cinematicListBox.Items.Add(ecin.Name); } count = CoreGlobals.getGameResources().getNumTalkingHeadVideos(); for (int i = 0; i < count; i++) { EditorCinematic ecin = CoreGlobals.getGameResources().getTalkingHeadVideo(i); talkingHeadVideos.Items.Add(ecin.Name); } count = CoreGlobals.getGameResources().getNumLightsets(); LightsetListBox.Items.Clear(); for (int i = 0; i < count; i++) { EditorLightset ecin = CoreGlobals.getGameResources().getLightset(i); LightsetListBox.Items.Add(ecin.getIDString()); } comboBox1.Items.Clear(); comboBox2.Items.Clear(); int numSplatTex = TerrainGlobals.getTexturing().getActiveTextureCount(); for (int i = 0; i < numSplatTex; i++) { if (TerrainGlobals.getTexturing().getActiveTexture(i) == null) { if (mbThisErrorOnce1 == false) { mbThisErrorOnce1 = true; CoreGlobals.ShowMessage("Please report this error to Andrew and Colt: invalid index in isActive "); } continue; } comboBox1.Items.Add(Path.GetFileName(TerrainGlobals.getTexturing().getActiveTexture(i).mFilename)); comboBox2.Items.Add(Path.GetFileName(TerrainGlobals.getTexturing().getActiveTexture(i).mFilename)); } if (CoreGlobals.ScenarioBuildingTextureIndexUNSC >= comboBox1.Items.Count) { CoreGlobals.ScenarioBuildingTextureIndexUNSC = 0; } comboBox1.SelectedIndex = CoreGlobals.ScenarioBuildingTextureIndexUNSC; if (CoreGlobals.ScenarioBuildingTextureIndexCOVN >= comboBox1.Items.Count) { CoreGlobals.ScenarioBuildingTextureIndexCOVN = 0; } comboBox2.SelectedIndex = CoreGlobals.ScenarioBuildingTextureIndexCOVN; VeterancyCheck.Checked = CoreGlobals.mbAllowVeterancy; LoadVisRepBox.Checked = CoreGlobals.mbLoadTerrainVisRep; GlobalExcludeUnitsOptionChooser.Enabled = true; GlobalExcludeUnitsOptionChooser.SetOptions(TriggerSystemMain.mSimResources.mObjectTypeData.mObjectTypeList); GlobalExcludeUnitsOptionChooser.BoundSelectionList = SimGlobals.getSimMain().GlobalExcludeObjects; GlobalExcludeUnitsOptionChooser.AllowRepeats = false; GlobalExcludeUnitsOptionChooser.AutoSort = true; isLoading = false; }
/// <summary> /// This connects the ui elements based off of the data that was loaded. /// Templates hold the connection data when a connection to a template is made in the ActionBinder classes /// Templates always load the connections to the right(output), and load connections to the left if trigger control is left of them /// </summary> public void LoadExistingConnections() { Dictionary <BasicControlPoint, TriggersTemplateInputActionBinder> .Enumerator it = mInputActionCPs.GetEnumerator(); while (it.MoveNext()) { TriggersTemplateInputActionBinder binder = it.Current.Value; BasicControlPoint thisCp = it.Current.Key; foreach (TriggerBindInfo targetinfo in binder.TargetIDs) { if (targetinfo.HasTarget()) { if (targetinfo.LinkName == "Effect.False" || targetinfo.LinkName == "Effect.True") { TriggerControl targetC = mTriggerHost.GetTriggerControl(targetinfo.ID); if (targetC != null) { if (targetinfo.LinkName == "Effect.True") { targetC.GetEffectTruePoint().GetTargets().Add(thisCp); } else { targetC.GetEffectFalsePoint().GetTargets().Add(thisCp); } } } } } } Dictionary <BasicControlPoint, TriggersTemplateOutputActionBinder> .Enumerator it2 = mOutputActionCPs.GetEnumerator(); while (it2.MoveNext()) { TriggersTemplateOutputActionBinder binder = it2.Current.Value; BasicControlPoint thisCp = it2.Current.Key; List <TriggerBindInfo> toRemove = new List <TriggerBindInfo>(); foreach (TriggerBindInfo targetinfo in binder.TargetIDs) { if (targetinfo.HasTarget()) { //bound to trigger if (targetinfo.LinkName == "Activate" || targetinfo.LinkName == "Deactivate") { TriggerControl triggerTarget = mTriggerHost.GetTriggerControl(targetinfo.ID); if (triggerTarget != null) { if (targetinfo.LinkName == "Activate") { thisCp.GetTargets().Add(triggerTarget.GetActivationPoint()); } else if (targetinfo.LinkName == "Deactivate") { thisCp.GetTargets().Add(triggerTarget.GetDeactivationPoint()); } } } else //it is a template { TemplateControl c = mTriggerHost.GetTemplatetControl(targetinfo.ID); if (c != null) { BasicControlPoint cpTarget = c.GetInputControlPoint(targetinfo.LinkName); thisCp.GetTargets().Add(cpTarget); } else { string groupName = this.ParentTriggerNamespace.GetGroupName(TriggerTemplateMapping.GroupID); string errormsg = "Error connecting template " + this.TriggerTemplateMapping.Name + "(" + this.TriggerTemplateMapping.ID + ")" + "." + thisCp.Name + " to missing template input: " + targetinfo.LinkName + ", " + targetinfo.ID + " in group: " + groupName + " Bad Link removed (most likely harmless residue from an old deleted template that this was connected to)"; toRemove.Add(targetinfo); this.BackColor = Color.Red; this.TriggerNameText.Text = Path.GetFileNameWithoutExtension(TriggerTemplateMapping.Name) + "(" + this.TriggerTemplateMapping.ID + ")"; CoreGlobals.getErrorManager().OnSimpleWarning(errormsg); CoreGlobals.ShowMessage(errormsg); CoreGlobals.getErrorManager().LogErrorToNetwork(errormsg); } } } } foreach (TriggerBindInfo badBind in toRemove) { binder.TargetIDs.Remove(badBind); } } }