private void Save() { try { mData.mMetadata.mTags = mTags;// mData.mMetadata.mSourceControl = (this.MarkForAddCheckBox.Checked == true) ? "InPerforce" : ""; mData.mMetadata.mCreator = System.Environment.UserName; //mData.mMetadata.mDescription = MetaDescriptionTextBox.Text; //GetNewChangeList() mData.Save(); if (CoreGlobals.UsingPerforce == true && MarkForAddCheckBox.Checked == true) { SimpleFileStatus status = CoreGlobals.getPerforce().GetFileStatusSimple(mData.mFileName); if (status.InPerforce == false) { PerforceChangeList list = CoreGlobals.getPerforce().GetNewChangeList("Auto checkin:Clipart"); list.AddFile(mData.mFileName); list.Submitchanges(); } } this.DialogResult = DialogResult.OK; this.Close(); } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } }
static private bool P4CanEdit(string filename, bool showAlerts) { SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(filename); if (status.InPerforce == false) { return(true); } if (status.CheckedOutOtherUser == true) { return(false); } if (status.CheckedOut == false) { if (showAlerts) { if (MessageBox.Show(Path.GetFileName(filename) + "is not checked out. Would you like to check it out and add it to a new perforce changelist?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { P4AddFileToChangeList(filename); return(true); } else { return(false); } } 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 RemovePallete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you'd like to delete this palette?", "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { string fname = CoreGlobals.getWorkPaths().mTerrainTexturesPath + @"\" + palleteListBox.SelectedItem.ToString() + SimTerrainType.mTextureSetExtention; SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(fname); if (status.InPerforce == true) { if (status.CheckedOut == false) { MessageBox.Show("You must check this file out from perforce before you delete it"); return; } else if (status.CheckedOutOtherUser == true) { MessageBox.Show("This file is checked out by " + status.ActionOwner + " you cannot delete it."); return; } } if (File.Exists(fname)) { File.Delete(fname); palleteListBox.Items.Remove(palleteListBox.SelectedItem); } } }
private bool P4CanEditFile(string filename, ref bool inPerforce) { SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(filename); inPerforce |= status.InPerforce; if (status.InPerforce == false) { return(true); } if (status.CheckedOutOtherUser == true) { outputMessage(Path.GetFileName(filename) + " is checked out by " + status.ActionOwner + ". Cannot convert"); mStatusResult = 1; return(false); } return(true); }
static private bool P4IsCheckedOut(string fileName, bool showAlert) { SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(fileName); if (status.CheckedOutOtherUser == true) { if (showAlert) { if (MessageBox.Show("This scenario is checked out by " + status.ActionOwner + " cannot check out", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { return(true); } else { return(false); } } return(true); } return(false); }
/// <summary> /// check out the stringtable /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mBtnCheckout_Click(object sender, EventArgs e) { // sync these without checking the error string strTablePath = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, mStringTableFilename); string strTableXsdPath = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, "stringtable.xsd"); // If this file is checked out, then we cannot edit it in the editor. It must be fixed up manually first. SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(strTablePath); if (status.CheckedOutThisUser == true) { MessageBox.Show(this, "The stringtable is already checked out and must be resolved in perforce before editing in the editor.", "Error", MessageBoxButtons.OK); return; } // sync without checking for an error. mP4.Sync(strTablePath); mP4.Sync(strTableXsdPath); ReloadStringtable(true); }
private void ImportButton_Click(object sender, EventArgs e) { SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(CoreGlobals.getWorkPaths().GetProtoObjectFile()); if (status.CheckedOutThisUser == true) { MessageBox.Show("Please check in objects.xml and try again"); return; } if (this.UsingPerforce) { mChangeList = CoreGlobals.getPerforce().GetNewChangeList("Batch Sound Objects Import"); if (mChangeList == null) { MessageBox.Show("Can't get new change list!"); return; } } //Sync if (this.UsingPerforce) { if (mChangeList != null) { if (mChangeList.SyncFile(CoreGlobals.getWorkPaths().GetProtoObjectFile()) == false) { MessageBox.Show("Perforce error: " + mChangeList.GetLastError()); return; } loadProtoXML(); } } //Start Edit if (this.UsingPerforce) { if (mChangeList.EditFile(CoreGlobals.getWorkPaths().GetProtoObjectFile()) == false) { MessageBox.Show("Perforce error: " + mChangeList.GetLastError()); return; } loadProtoXML(); } bool bSoundBehindFOW = SoundBehindFOWCheckBox.Checked; //Add Objects XmlNode protoNode = mProtoObjectsDoc.GetElementsByTagName("Objects")[0]; Dictionary <string, string> .Enumerator it = mSoundsToAdd.GetEnumerator(); while (it.MoveNext()) { mHightestID = mHightestID + 1; XmlNode toImport = CreateSoundObject(mHightestID, it.Current.Key, it.Current.Value, bSoundBehindFOW); if (toImport != null) { protoNode.AppendChild(toImport); } } mSoundsToAdd.Clear(); try { mProtoObjectsDoc.Save(CoreGlobals.getWorkPaths().GetProtoObjectFile()); if (this.UsingPerforce) { mChangeList.AddOrEdit(CoreGlobals.getWorkPaths().GetProtoObjectFile() + ".xmb"); } DBIDHelperTool.Run(); EditorCore.XMBProcessor.CreateXMB(CoreGlobals.getWorkPaths().GetProtoObjectFile(), false); } catch (UnauthorizedAccessException unEx) { MessageBox.Show("Error writing to objects.xml"); } //Checkin if (DoCheckin && this.UsingPerforce) { Checkin(); } //or revert? else if (Revert && this.UsingPerforce) { mChangeList.Revert(); } //refresh: loadProtoXML(); LoadSoundNames(); LoadUI(); SetButtonStatus(); }
private void UpdateUIStatus() { int numInPerforce = 0; int numCheckedoutByOther = 0; int numCheckedOutByUser = 0; int numCheckedOutByBoth = 0; mStatus.Clear(); if (mFiles.Count == 0) { return; } foreach (string file in mFiles) { SimpleFileStatus s = CoreGlobals.getPerforce().GetFileStatusSimple(file); mStatus.Add(s); if (s.InPerforce) { numInPerforce++; } if (s.State == eFileState.CheckedOutByUserAndOther) { numCheckedOutByBoth++; } else if (s.State == eFileState.CheckedOutByOther) { numCheckedoutByOther++; } else if (s.State == eFileState.CheckedOutByUser) { numCheckedOutByUser++; } } FileListGridControl.DataSource = mStatus; EnumViewer <eFileState> item = new EnumViewer <eFileState>(); item.mImageList = imageList1; CellViewerManager manager = new CellViewerManager(item, "Value"); FileListGridControl.Columns["State"].CellViewerManager = manager; if (numInPerforce < mFiles.Count && numInPerforce > 0) { mMode = ePerforcePageMode.SomeFilesInPerforce; AddOptions(); } else if (numInPerforce == 0) { mMode = ePerforcePageMode.NoFilesInPerforce; AddOptions(); } else if (numCheckedoutByOther > 0) { mMode = ePerforcePageMode.SomeCheckedOutByOther; CheckedOutByOtherOptions(); } else if (numCheckedoutByOther == mFiles.Count) { mMode = ePerforcePageMode.AllCheckedOutByOther; CheckedOutByOtherOptions(); } else if (numCheckedOutByUser == mFiles.Count) { mMode = ePerforcePageMode.AllCheckedOutByUser; CheckedOutByUserOptions(); } else if ((numInPerforce == mFiles.Count) && (numCheckedOutByUser > 0) && (numCheckedoutByOther == 0)) { mMode = ePerforcePageMode.SomeCheckedOutByUser; AllCheckedInOptions(); } else if ((numInPerforce == mFiles.Count) && (numCheckedoutByOther == 0)) { mMode = ePerforcePageMode.AllCheckedIn; AllCheckedInOptions(); } else { mMode = ePerforcePageMode.OtherState; //Not set up to handle this situation ResetUI(); } }
/// <summary> /// Save the changes back to the XML and check them in. /// </summary> /// <param name="sender"></param> /// <param name="ev"></param> private void mBtnSave_Click(object sender, EventArgs ev) { // check to see if we have any changes to save out DataSet changes = mDoc.DataSet.GetChanges(); if (changes == null) { MakeEditable(false); mEditMode = false; CheckEnableControls(); return; } // build our paths string strTablePath = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, mStringTableFilename); string strTableXsdPath = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, "stringtable.xsd"); string strTableXmbPath = strTablePath + ".xmb"; try { string backup = strTablePath + ".backup"; makeWriteable(backup); if (!SaveStringTableToFile(backup, mDoc)) { MessageBox.Show(this, "Error creating a backup copy of the stringtable.", "Error", MessageBoxButtons.OK); throw new Exception("error"); } // make the current stringtable file RO if (!makeReadOnly(strTablePath)) { return; } // get the latest file mP4.Sync(strTablePath); mP4.Sync(strTableXsdPath); // check out the existing file mP4.Checkout(strTablePath); SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(strTablePath); if (status.CheckedOutThisUser != true) { MessageBox.Show(this, "Could not check out the string table: \n\n" + mP4.LastError, "Error", MessageBoxButtons.OK); throw new Exception("error"); } // lock the string table if (!mP4.Lock(strTablePath)) { mP4.Revert(strTablePath); string errorMessage = "Could not lock the stringtable: \n\n" + mP4.LastError; throw new Exception(errorMessage); } // load the file into a data set XmlDataDocument origStringTable = new XmlDataDocument(); origStringTable.DataSet.ReadXmlSchema(strTableXsdPath); origStringTable.Load(strTablePath); System.Data.DataTable table = origStringTable.DataSet.Tables[2]; DataColumn[] PrimaryKeyColumns = new DataColumn[1]; PrimaryKeyColumns[0] = table.Columns["_locID"]; table.PrimaryKey = PrimaryKeyColumns; // merge the changes into the file origStringTable.DataSet.Merge(changes, false, MissingSchemaAction.Error); // Save out the stringtable changes if (!SaveStringTableToFileWithBackup(strTablePath, origStringTable)) { throw new Exception("error"); } // check the file back into perforce if (!mP4.Checkin(strTablePath, "String changes from the editor")) { MessageBox.Show(this, "An error occurred trying to checkin the stringtable: \n\n" + mP4.LastError, "", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new Exception("error"); } // XMB the file mP4.Sync(strTableXmbPath); EditorCore.XMBProcessor.CreateXMB(strTablePath, true); if (!mP4.Checkin(strTableXmbPath, "String changes from the editor")) { MessageBox.Show(this, "An error occurred trying to checkin the stringtable XMB file: stringtable.xml.xmb : \n\n" + mP4.LastError + "\n\n Please make sure this file get's checked in.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new Exception("error"); } // force a reload of the stringtable file for other areas in the editor that use it. EditorCore.CoreGlobals.getGameResources().mStringTable.Load(); ReloadStringtable(false); MessageBox.Show(this, "The stringtable was saved and checked in.", "", MessageBoxButtons.OK); } catch (Exception ex) { // do some clean up here SimpleFileStatus status = CoreGlobals.getPerforce().getConnection().P4GetFileStatusSimple(strTablePath); if (status.CheckedOutThisUser != true) { mP4.Revert(strTablePath); } // rethrow the exception throw ex; } }