private void AppendFormat(StringBuilder sb, string tableName, string elementName, string fieldName, FieldType fieldType, ScriptItem item) { switch (fieldType) { case FieldType.Boolean: sb.AppendFormat("{0}[\"{1}\"].{2} = {3}", tableName, DialogueLua.StringToTableIndex(elementName), DialogueLua.StringToTableIndex(fieldName), (item.booleanValue == BooleanType.True) ? "true" : "false"); break; case FieldType.Number: if (item.valueSetMode == ValueSetMode.To) { sb.AppendFormat("{0}[\"{1}\"].{2} = {3}", tableName, DialogueLua.StringToTableIndex(elementName), DialogueLua.StringToTableIndex(fieldName), item.floatValue); } else { sb.AppendFormat("{0}[\"{1}\"].{2} = {0}[\"{1}\"].{2} + {3}", tableName, DialogueLua.StringToTableIndex(elementName), DialogueLua.StringToTableIndex(fieldName), item.floatValue); } break; default: sb.AppendFormat("{0}[\"{1}\"].{2} = \"{3}\"", tableName, DialogueLua.StringToTableIndex(elementName), DialogueLua.StringToTableIndex(fieldName), item.stringValue); break; } }
private static int Comparer(ScriptItem x, ScriptItem y) { for (int i = 0; i < x.Filename.Length && i < y.Filename.Length;) { if (x.Filename[i] > y.Filename[i]) { return 1; } else if (x.Filename[i] == y.Filename[i]) { i++; } else { return -1; } } if (x.Filename.Length < y.Filename.Length) { return -1; } else if (x.Filename.Length == y.Filename.Length) { return 0; } else { return 1; } }
private QueryWindowHeader(ISscOperations sscOperations, ScriptItem scriptItem) { Controls.Add(new ChromiumControl("http://localhost:1337/query-header.html", sscOperations, scriptItem, new SscEndpoints()) { Dock = DockStyle.Fill }); Height = 52; }
private void RefreshScriptList( ) { _comboScriptList.Items.Clear( ); _comboScriptList.Items.Add( new ScriptItem( null ) ); foreach( Controls.ScriptAssetItem scriptAsset in Global.AssetsBrowser.ScriptItems.Values ) { ScriptItem scriptItem = new ScriptItem( scriptAsset.Script ); _comboScriptList.Items.Add( scriptItem ); if( world.Script == scriptAsset.Script ) _comboScriptList.SelectedItem = scriptItem; } if( _comboScriptList.SelectedIndex == -1 ) _comboScriptList.SelectedIndex = 0; }
public void AddNamedItem(string name, ScriptItem flags) { Debug.WriteLine ("AddNamedItem(\"" + name + "\", " + flags.ToString () + ")"); // What did he give us? object item; object typeinfo; if (this.site != null) { this.site.GetItemInfo (name, ScriptInfo.IUnknown, out item, out typeinfo); Type itemType = item.GetType (); if (itemType.FullName == "System.__ComObject") { throw new NotImplementedException (); } else { ProcessItem (name, flags, item, itemType); } } else { throw new NotImplementedException (); } //if (this.site != null) { // try { // this.site.GetItemInfo (name, ScriptInfo.IUnknown, out item, out typeinfo); // Debug.WriteLine ("item is " + item.ToString ()); // Type type = (item as IDispatch).GetTypeInfo (0, 0x409); // Debug.WriteLine ("Type is " + type.ToString ()); // foreach (System.Reflection.MemberInfo minfo in type.GetMembers ()) // Debug.WriteLine (minfo); // } // catch (Exception e) { // Debug.WriteLine ("Exception " + e.ToString ()); // } //} //else { // // I guess we can find out later. // Debug.WriteLine ("No site, but named items being added."); //} }
/// <summary> /// Indicating whether the script item has been deleted. /// </summary> /// <param name="scriptItem">ScriptItem.</param> /// <param name="status">Status.</param> /// <returns>Whether the script item has been deleted.</returns> public bool IsDeletedItem(ScriptItem scriptItem, ref TtsXmlStatus status) { bool isDeletedItem = false; status = null; foreach (XmlScriptFile xmlScriptFile in _xmlScriptFiles) { if (xmlScriptFile.DeletedItemsDict.ContainsKey(scriptItem)) { isDeletedItem = true; status = xmlScriptFile.DeletedItemsDict[scriptItem]; break; } } return isDeletedItem; }
private string DrawScriptWizard(Rect position, string luaCode) { int originalIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var rect = position; var x = position.x; var y = position.y; EditorGUI.BeginChangeCheck(); // Script items: ScriptItem itemToDelete = null; foreach (ScriptItem item in scriptItems) { var innerHeight = EditorGUIUtility.singleLineHeight + 2; DrawScriptItem(new Rect(x, y, position.width, innerHeight), item, ref itemToDelete); y += EditorGUIUtility.singleLineHeight + 2; } if (itemToDelete != null) { scriptItems.Remove(itemToDelete); } // "+", Revert, and Apply buttons: x = position.x; y = position.y + position.height - EditorGUIUtility.singleLineHeight; rect = new Rect(x, y, 22, EditorGUIUtility.singleLineHeight); if (GUI.Button(rect, new GUIContent("+", "Add a new script action."), EditorStyles.miniButton)) { scriptItems.Add(new ScriptItem()); } x += rect.width + 2; rect = new Rect(x, y, 72, EditorGUIUtility.singleLineHeight); append = EditorGUI.ToggleLeft(rect, "Append", append); if (EditorGUI.EndChangeCheck()) { ApplyScriptWizard(); } EditorGUI.BeginDisabledGroup(scriptItems.Count <= 0); rect = new Rect(position.x + position.width - 48 - 4 - 48, y, 48, EditorGUIUtility.singleLineHeight); if (GUI.Button(rect, new GUIContent("Revert", "Cancel these settings."), EditorStyles.miniButton)) { luaCode = CancelScriptWizard(); } rect = new Rect(position.x + position.width - 48, y, 48, EditorGUIUtility.singleLineHeight); GUI.Box(rect, GUIContent.none); if (GUI.Button(rect, new GUIContent("Apply", "Apply these settings"), EditorStyles.miniButton)) { luaCode = AcceptScriptWizard(); } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel = originalIndentLevel; return(luaCode); }
/// <summary> /// Splits the ScriptLine into sections and returns a special class that signifies it has been split /// </summary> /// <returns>A list of SplitScriptLines</returns> public List <SplitScriptLine> SplitIntoSections() { List <SplitScriptLine> lines = new List <SplitScriptLine>(); lines.Add(new SplitScriptLine()); int nSection = -1; bool first = true; bool forceSplitNext = false; for (int i = 0; i < NumberOfScriptItems; i++) { ScriptItem item = GetScriptItem(i); // Code A2 appears to denote the beginning of a new section, so we split it if (item.Command == TalkCommand.StartNewSection) { // It's a new section, so we simplu advance the section counter and add an empty SplitScriptLine nSection++; lines.Add(new SplitScriptLine()); } // if there is a IfElse branch for the Avatar's name the, a DoNothingSection or a goto label, then we add a new section, save the SplitScriptLine else if (item.Command == TalkCommand.IfElseKnowsName || item.Command == TalkCommand.DoNothingSection || item.Command == TalkCommand.DefineLabel) { // advance to next section nSection++; // add a stump section lines.Add(new SplitScriptLine()); // add the item as-is to the new section lines[nSection].AddScriptItem(item); // we need to tell the loop to force yet another split next time around // basically - these items need to part of a single item SplitScriptLine forceSplitNext = true; } // if there is a default message then it is the defintion of a new label else if (item.Command == TalkCommand.StartLabelDefinition) { // advance to next section nSection++; Debug.Assert(GetScriptItem(i + 1).Command == TalkCommand.DefineLabel); // StartLabelDefinition must ALWYAYS be followed with a DefineLabel // add the StartLabelDefintion to the new section lines[nSection].AddScriptItem(item); // add the next item - which is a DefineLabel to the section lines[nSection].AddScriptItem(GetScriptItem(i + 1)); // skip by the DefineLabel section since we just added i++; // we need to tell the loop to force yet another split next time around // basically - these items need to part of a single item SplitScriptLine forceSplitNext = true; } else // it is any other kind of TalkCommand { // welp - I really can't recall why I did this, but I need it. if (first) { nSection = 0; } // if we are forcing a new section from a previous run, then we increment the section number if (forceSplitNext) { forceSplitNext = false; nSection++; lines.Add(new SplitScriptLine()); } lines[nSection].AddScriptItem(item); } first = false; } return(lines); }
private void DrawScriptItem(ScriptItem item, ref ScriptItem itemToDelete) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Set", GUILayout.Width(32)); WizardResourceType newResourceType = (WizardResourceType) EditorGUILayout.EnumPopup(item.resourceType, GUILayout.Width(96)); if (newResourceType != item.resourceType) { item.resourceType = newResourceType; scriptQuestEntryNames = new string[0]; } if (item.resourceType == WizardResourceType.Quest) { // Quest: item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames); EditorGUILayout.LabelField("to", GUILayout.Width(22)); item.questState = (QuestState) EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); } else if (item.resourceType == WizardResourceType.QuestEntry) { // Quest Entry: int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; scriptQuestEntryNames = new string[0]; } if ((scriptQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { scriptQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, scriptQuestEntryNames); EditorGUILayout.LabelField("to", GUILayout.Width(22)); item.questState = (QuestState) EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); } else if (item.resourceType == WizardResourceType.Variable) { // Variable: item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variableNames); var variableType = GetWizardVariableType(item.variableNamesIndex); DrawValueSetMode(item, variableType); switch (variableType) { case FieldType.Boolean: item.booleanValue = (BooleanType) EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == WizardResourceType.Actor) { // Actor: item.actorNamesIndex = EditorGUILayout.Popup(item.actorNamesIndex, actorNames); item.actorFieldIndex = EditorGUILayout.Popup(item.actorFieldIndex, actorFieldNames); var actorFieldType = GetWizardActorFieldType(item.actorFieldIndex); DrawValueSetMode(item, actorFieldType); switch (actorFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType) EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == WizardResourceType.Item) { // Item: item.itemNamesIndex = EditorGUILayout.Popup(item.itemNamesIndex, itemNames); item.itemFieldIndex = EditorGUILayout.Popup(item.itemFieldIndex, itemFieldNames); var itemFieldType = GetWizardItemFieldType(item.itemFieldIndex); DrawValueSetMode(item, itemFieldType); switch (itemFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType) EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == WizardResourceType.Location) { // Location: item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames); item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames); var locationFieldType = GetWizardLocationFieldType(item.locationFieldIndex); DrawValueSetMode(item, locationFieldType); switch (locationFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType) EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } if (GUILayout.Button(new GUIContent("-", "Delete this script action."), EditorStyles.miniButton, GUILayout.Width(22))) { itemToDelete = item; } EditorGUILayout.EndHorizontal(); }
public void InsertScriptItemAtFront(ScriptItem scriptItem) { ScriptItems.Insert(0, scriptItem); }
/// <summary> /// Add an additional script item /// </summary> /// <param name="scriptItem"></param> public void AddScriptItem(ScriptItem scriptItem) { ScriptItems.Add(scriptItem); }
/// <summary> /// is this script item a question that the player asks an NPC? /// </summary> /// <returns></returns> public bool IsQuestion() { return(ScriptItem.IsQuestion(Str)); }
public void BuildDocument(string[] ScriptItems) { string FullDocFileName = Cappy.FolderName + @"\" + Cappy.Prefix + Cappy.FieldSeperator + Cappy.GetSaveTime() + Cappy.FieldSeperator + Cappy.DocExtension; using (DocX document = DocX.Create(FullDocFileName)) { foreach (string ScriptItem in ScriptItems) { if (ScriptItem != null) { // instantiate some // TODO: this loop contains alot of copy paste and hackiness because im tired and shit, please clean it up string[] Fields = ScriptItem.Split(';'); string ButtonAction = String.Empty; string ButtonClicked = String.Empty; string WindowText = String.Empty; string FullFileName = String.Empty; string FocusFileName = String.Empty; if (Fields.Length == 5) { ButtonAction = Fields[0]; ButtonClicked = Fields[1]; WindowText = Fields[2]; FullFileName = Fields[3]; FocusFileName = Fields[4]; } else if (Fields.Length == 3) { ButtonAction = Fields[0]; ButtonClicked = Fields[1]; FullFileName = Fields[2]; } string ParagraphText; if (Fields.Length == 5) { // because alot of things in windows have weird window names, or you perform more advanced actions on them then click, let's define some things to make our documents nicer if (!String.IsNullOrEmpty(WindowText)) { ParagraphText = ButtonAction + " " + WindowText; } else { // if we can't determine what was clicked, resort to this. ParagraphText = ButtonAction + " << FILL IN MISSING TEXT >>"; } // create our paragraph to work with Paragraph p = document.InsertParagraph(); // get bitmaps of the desired images System.Drawing.Image FullCaptureImage = GetImage(FullFileName); System.Drawing.Image FocusCaptureImage = GetImage(FocusFileName); // instantiate memory streams for writing our bitmaps to MemoryStream FullCaptureStream = new MemoryStream(); MemoryStream FocusCaptureStream = new MemoryStream(); // save our bitmaps into the memory stream FullCaptureImage.Save(FullCaptureStream, FullCaptureImage.RawFormat); FocusCaptureImage.Save(FocusCaptureStream, FocusCaptureImage.RawFormat); // set position in memory stream FullCaptureStream.Seek(0, SeekOrigin.Begin); FocusCaptureStream.Seek(0, SeekOrigin.Begin); // create the base image to work with, and add it to our document object for later Xceed.Document.NET.Image FullCapture = document.AddImage(FullCaptureStream); Xceed.Document.NET.Image FocusCapture = document.AddImage(FocusCaptureStream); // convert image to picture usable in a document Picture FullCapturePic = FullCapture.CreatePicture(); Picture FocusCapturePic = FocusCapture.CreatePicture(); // because screenshots will be a constant size, simply set a scalar to our desired resolution. we can also use this for calculating the focus size. const int imgWidth = 512; const int imgHeight = 288; // apply aforementioned scalar FullCapturePic.Width = imgWidth; FullCapturePic.Height = imgHeight; // create focused screenshot size Size focusbbox = new Size(imgWidth, imgHeight); // get the scaled version of focused image Size focusSize = ExpandToBound(FocusCaptureImage.Size, focusbbox); FocusCapturePic.Width = focusSize.Width; FocusCapturePic.Height = focusSize.Height; // insert bullet list var list = document.AddList(listType: ListItemType.Numbered, continueNumbering: true); document.AddListItem(list, ParagraphText, 0, listType: ListItemType.Numbered); // insert images p.InsertListBeforeSelf(list); p.AppendLine().AppendPicture(FullCapturePic); p.AppendLine(); // space the images p.AppendLine().AppendPicture(FocusCapturePic); p.AppendLine(); // leave a space for writing p.InsertPageBreakAfterSelf(); // release unneeded resources FullCaptureImage.Dispose(); FullCaptureStream.Dispose(); FocusCaptureImage.Dispose(); FocusCaptureStream.Dispose(); } if (Fields.Length == 3) { ParagraphText = ButtonAction + " " + ButtonClicked; // create our paragraph to work with Paragraph p = document.InsertParagraph(); // get bitmaps of the desired images System.Drawing.Image FullCaptureImage = GetImage(FullFileName); // instantiate memory streams for writing our bitmaps to MemoryStream FullCaptureStream = new MemoryStream(); // save our bitmaps into the memory stream FullCaptureImage.Save(FullCaptureStream, FullCaptureImage.RawFormat); // set position in memory stream FullCaptureStream.Seek(0, SeekOrigin.Begin); // create the base image to work with, and add it to our document object for later Xceed.Document.NET.Image FullCapture = document.AddImage(FullCaptureStream); // convert image to picture usable in a document Picture FullCapturePic = FullCapture.CreatePicture(); // because screenshots will be a constant size, simply set a scalar to our desired resolution. we can also use this for calculating the focus size. const int imgWidth = 512; const int imgHeight = 288; // apply aforementioned scalar FullCapturePic.Width = imgWidth; FullCapturePic.Height = imgHeight; // insert bullet list var list = document.AddList(listType: ListItemType.Numbered, continueNumbering: true); document.AddListItem(list, ParagraphText, 0, listType: ListItemType.Numbered); // insert images p.InsertListBeforeSelf(list); p.AppendLine().AppendPicture(FullCapturePic); p.AppendLine(); // space the images // leave a space for writing p.InsertPageBreakAfterSelf(); // release unneeded resources FullCaptureImage.Dispose(); FullCaptureStream.Dispose(); } } } document.Save(); } }
// This shows the info public void ShowInfo(Linedef l, Sidedef highlightside) { string peggedness; // Show/hide stuff depending on format if (!General.Map.FormatInterface.HasActionArgs) { arglbl1.Visible = false; arglbl2.Visible = false; arglbl3.Visible = false; arglbl4.Visible = false; arglbl5.Visible = false; arg1.Visible = false; arg2.Visible = false; arg3.Visible = false; arg4.Visible = false; arg5.Visible = false; infopanel.Width = doomformatwidth; } else { arglbl1.Visible = true; arglbl2.Visible = true; arglbl3.Visible = true; arglbl4.Visible = true; arglbl5.Visible = true; arg1.Visible = true; arg2.Visible = true; arg3.Visible = true; arg4.Visible = true; arg5.Visible = true; infopanel.Width = hexenformatwidth; } //mxd. Hide activation or tag and rearrange labels if (!General.Map.FormatInterface.HasBuiltInActivations && General.Map.FormatInterface.HasNumericLinedefActivations) //Hexen map format? { activation.Visible = true; activationlabel.Text = "Activation:"; activationlabel.Visible = true; taglabel.Visible = false; tag.Visible = false; //set activation foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates) { if (l.Activate == ai.Index) { activation.Text = ai.Title; break; } } activation.Enabled = (l.Activate != 0 || l.Action != 0); //mxd activationlabel.Enabled = (l.Activate != 0 || l.Action != 0); //mxd } else { if (General.Map.UDMF) { // Hijack activation labels to show lock numer... activationlabel.Text = "Lock:"; activationlabel.Visible = true; activation.Visible = true; int locknum = l.Fields.GetValue("locknumber", 0); if (locknum != 0) { activationlabel.Enabled = true; activation.Enabled = true; if (General.Map.Config.Enums.ContainsKey("keys")) { foreach (EnumItem item in General.Map.Config.Enums["keys"]) { if (item.GetIntValue() == locknum) { activation.Text = locknum + " - " + item.Title; break; } } } else { activation.Text = locknum.ToString(); } } else { activationlabel.Enabled = false; activation.Enabled = false; activation.Text = "None"; } } else { // Should be Doom map format activationlabel.Visible = false; activation.Visible = false; } taglabel.Visible = true; tag.Visible = true; //mxd. Set tag(s) if (l.Tags.Count > 1) { string[] tags = new string[l.Tags.Count]; for (int i = 0; i < l.Tags.Count; i++) { tags[i] = l.Tags[i].ToString(); } tag.Text = string.Join(", ", tags); tag.Enabled = true; taglabel.Enabled = true; taglabel.Text = "Tags:"; } else { tag.Text = l.Tag + (General.Map.Options.TagLabels.ContainsKey(l.Tag) ? " - " + General.Map.Options.TagLabels[l.Tag] : string.Empty); tag.Enabled = (l.Tag != 0); taglabel.Enabled = (l.Tag != 0); taglabel.Text = "Tag:"; } } // Get line action information LinedefActionInfo act = General.Map.Config.GetLinedefActionInfo(l.Action); // Determine peggedness bool upperunpegged = l.IsFlagSet(General.Map.Config.UpperUnpeggedFlag); bool lowerunpegged = l.IsFlagSet(General.Map.Config.LowerUnpeggedFlag); if (upperunpegged && lowerunpegged) { peggedness = "Upper & Lower"; } else if (upperunpegged) { peggedness = "Upper"; } else if (lowerunpegged) { peggedness = "Lower"; } else { peggedness = "None"; } // Linedef info #if DEBUG infopanel.Text = " Linedef " + l.Index + " (vert. " + l.Start.Index + " - vert. " + l.End.Index + ") "; #else infopanel.Text = " Linedef " + l.Index + " "; #endif action.Text = act.ToString(); length.Text = l.Length.ToString("0.##"); angle.Text = l.AngleDeg + "\u00B0"; unpegged.Text = peggedness; unpegged.Enabled = (peggedness != "None"); //mxd peglabel.Enabled = (peggedness != "None"); //mxd action.Enabled = (act.Index != 0); actionlabel.Enabled = (act.Index != 0); //mxd. ACS script argument names bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, l.Action) != -1); bool isarg0str = (General.Map.UDMF && l.Fields.ContainsKey("arg0str")); string arg0str = isarg0str ? l.Fields.GetValue("arg0str", string.Empty) : string.Empty; ScriptItem scriptitem = null; //mxd. Set default label colors arg1.ForeColor = SystemColors.ControlText; arglbl1.ForeColor = SystemColors.ControlText; // Named script? if (isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant())) { scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()]; } // Script number? else if (isacsscript && General.Map.NumberedScripts.ContainsKey(l.Args[0])) { scriptitem = General.Map.NumberedScripts[l.Args[0]]; arg0str = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString()); } // Apply script args? Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 }; Label[] args = { arg1, arg2, arg3, arg4, arg5 }; if (scriptitem != null) { int first; string[] argnames = scriptitem.GetArgumentsDescriptions(l.Action, out first); for (int i = 0; i < first; i++) { arglabels[i].Text = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":"; arglabels[i].Enabled = act.Args[i].Used; args[i].Enabled = act.Args[i].Used; } for (int i = first; i < argnames.Length; i++) { if (!string.IsNullOrEmpty(argnames[i])) { arglabels[i].Text = argnames[i] + ":"; arglabels[i].Enabled = true; args[i].Enabled = true; } else { arglabels[i].Text = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":"; arglabels[i].Enabled = act.Args[i].Used; args[i].Enabled = act.Args[i].Used; } } } else { for (int i = 0; i < act.Args.Length; i++) { arglabels[i].Text = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":"; arglabels[i].Enabled = act.Args[i].Used; args[i].Enabled = act.Args[i].Used; } // Special cases: unknown script name/index if (isacsscript) { arglbl1.Text = "Unknown script " + (isarg0str ? "name" : "number") + ":"; arg1.ForeColor = Color.DarkRed; arglbl1.ForeColor = Color.DarkRed; } } //mxd. Set argument value and label if (isarg0str) { arg1.Text = arg0str; } else { SetArgumentText(act.Args[0], arg1, l.Args[0]); } SetArgumentText(act.Args[1], arg2, l.Args[1]); SetArgumentText(act.Args[2], arg3, l.Args[2]); SetArgumentText(act.Args[3], arg4, l.Args[3]); SetArgumentText(act.Args[4], arg5, l.Args[4]); // Front side available? if (l.Front != null) { //mxd. Extended info shown? bool hasTopFields = false; bool hasMiddleFields = false; bool hasBottomFields = false; //mxd. Highlight this side? bool highlight = (l.Front == highlightside); frontpanel.ForeColor = (highlight ? SystemColors.HotTrack : SystemColors.WindowText); //mxd // Show sidedef info frontpanel.Visible = true; //mxd frontpanel.Text = " Front Sidedef " + l.Front.Index; //mxd if (General.Map.UDMF) { //light frontoffsetlabel.Text = "Front light:"; SetUDMFLight(l.Front, frontoffsetlabel, frontoffset, highlight); //global offset, sector index frontpanel.Text += ". Offset " + l.Front.OffsetX + ", " + l.Front.OffsetY + ". Sector " + l.Front.Sector.Index + " "; //sidedef top hasTopFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_top", "offsety_top", 0.0, frontTopUDMFOffsetLabel, frontTopUDMFOffset, highlight); hasTopFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_top", "scaley_top", 1.0, frontTopUDMFScaleLabel, frontTopUDMFScale, highlight); //sidedef middle hasMiddleFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_mid", "offsety_mid", 0.0, frontMidUDMFOffsetLabel, frontMidUDMFOffset, highlight); hasMiddleFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_mid", "scaley_mid", 1.0, frontMidUDMFScaleLabel, frontMidUDMFScale, highlight); //sidedef bottom hasBottomFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_bottom", "offsety_bottom", 0.0, frontBottomUDMFOffsetLabel, frontBottomUDMFOffset, highlight); hasBottomFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_bottom", "scaley_bottom", 1.0, frontBottomUDMFScaleLabel, frontBottomUDMFScale, highlight); //visibility frontTopUDMFOffset.Visible = hasTopFields; frontTopUDMFOffsetLabel.Visible = hasTopFields; frontTopUDMFScale.Visible = hasTopFields; frontTopUDMFScaleLabel.Visible = hasTopFields; frontMidUDMFOffset.Visible = hasMiddleFields; frontMidUDMFOffsetLabel.Visible = hasMiddleFields; frontMidUDMFScale.Visible = hasMiddleFields; frontMidUDMFScaleLabel.Visible = hasMiddleFields; frontBottomUDMFOffset.Visible = hasBottomFields; frontBottomUDMFOffsetLabel.Visible = hasBottomFields; frontBottomUDMFScale.Visible = hasBottomFields; frontBottomUDMFScaleLabel.Visible = hasBottomFields; } else { frontoffsetlabel.Text = "Front offset:"; if (l.Front.OffsetX != 0 || l.Front.OffsetY != 0) { frontoffset.Text = l.Front.OffsetX + ", " + l.Front.OffsetY; frontoffsetlabel.Enabled = true; frontoffset.Enabled = true; frontoffset.ForeColor = (highlight ? SystemColors.HotTrack : SystemColors.WindowText); frontoffsetlabel.ForeColor = frontoffset.ForeColor; } else { frontoffset.Text = "--, --"; frontoffsetlabel.Enabled = false; frontoffset.Enabled = false; } //mxd. Sector index frontpanel.Text += ". Sector " + l.Front.Sector.Index + " "; //visibility frontTopUDMFOffsetLabel.Visible = false; frontTopUDMFScaleLabel.Visible = false; frontMidUDMFOffsetLabel.Visible = false; frontMidUDMFScaleLabel.Visible = false; frontBottomUDMFOffsetLabel.Visible = false; frontBottomUDMFScaleLabel.Visible = false; } //mxd. Set texture names, update panel sizes UpdateTexturePanel(panelFrontTop, l.Front.HighTexture, fronthighname, labelTextureFrontTop, Math.Max(frontTopUDMFOffset.Right, frontTopUDMFScale.Right) + 4, fronthightex, frontTopUDMFOffsetLabel.Left, hasTopFields, l.Front.HighRequired()); UpdateTexturePanel(panelFrontMid, l.Front.MiddleTexture, frontmidname, labelTextureFrontMid, Math.Max(frontMidUDMFOffset.Right, frontMidUDMFScale.Right) + 4, frontmidtex, frontMidUDMFOffsetLabel.Left, hasMiddleFields, l.Front.MiddleRequired()); UpdateTexturePanel(panelFrontLow, l.Front.LowTexture, frontlowname, labelTextureFrontBottom, Math.Max(frontBottomUDMFOffset.Right, frontBottomUDMFScale.Right) + 4, frontlowtex, frontBottomUDMFOffsetLabel.Left, hasBottomFields, l.Front.LowRequired()); //mxd. Resize panel flowLayoutPanelFront.Width = panelFrontLow.Right; frontpanel.Width = flowLayoutPanelFront.Width + flowLayoutPanelFront.Left * 2 - 4; } else { // Show no info if (General.Map.UDMF) //mxd { frontoffsetlabel.Text = "Front light:"; frontoffset.Text = "--"; } else { frontoffsetlabel.Text = "Front offset:"; frontoffset.Text = "--, --"; } frontoffsetlabel.Enabled = false; frontoffset.Enabled = false; fronthightex.BackgroundImage = null; frontmidtex.BackgroundImage = null; frontlowtex.BackgroundImage = null; frontpanel.Visible = false; //mxd } // Back size available? if (l.Back != null) { //mxd. Extended info shown? bool hasTopFields = false; bool hasMiddleFields = false; bool hasBottomFields = false; //mxd. Highlight this side? bool highlight = l.Back == highlightside; backpanel.ForeColor = (highlight ? SystemColors.HotTrack : SystemColors.WindowText); //mxd // Show sidedef info backpanel.Visible = true; //mxd backpanel.Text = " Back Sidedef " + l.Back.Index; //mxd if (General.Map.UDMF) { //light backoffsetlabel.Text = "Back light:"; SetUDMFLight(l.Back, backoffsetlabel, backoffset, highlight); //global offset, sector index backpanel.Text += ". Offset " + l.Back.OffsetX + ", " + l.Back.OffsetY + ". Sector " + l.Back.Sector.Index + " "; //sidedef top hasTopFields = SetPairedUDMFFieldsLabel(l.Back.Fields, "offsetx_top", "offsety_top", 0.0, backTopUDMFOffsetLabel, backTopUDMFOffset, highlight); hasTopFields |= SetPairedUDMFFieldsLabel(l.Back.Fields, "scalex_top", "scaley_top", 1.0, backTopUDMFScaleLabel, backTopUDMFScale, highlight); //sidedef middle hasMiddleFields = SetPairedUDMFFieldsLabel(l.Back.Fields, "offsetx_mid", "offsety_mid", 0.0, backMidUDMFOffsetLabel, backMidUDMFOffset, highlight); hasMiddleFields |= SetPairedUDMFFieldsLabel(l.Back.Fields, "scalex_mid", "scaley_mid", 1.0, backMidUDMFScaleLabel, backMidUDMFScale, highlight); //sidedef bottom hasBottomFields = SetPairedUDMFFieldsLabel(l.Back.Fields, "offsetx_bottom", "offsety_bottom", 0.0, backBottomUDMFOffsetLabel, backBottomUDMFOffset, highlight); hasBottomFields |= SetPairedUDMFFieldsLabel(l.Back.Fields, "scalex_bottom", "scaley_bottom", 1.0, backBottomUDMFScaleLabel, backBottomUDMFScale, highlight); //visibility backTopUDMFOffset.Visible = hasTopFields; backTopUDMFOffsetLabel.Visible = hasTopFields; backTopUDMFScale.Visible = hasTopFields; backTopUDMFScaleLabel.Visible = hasTopFields; backMidUDMFOffset.Visible = hasMiddleFields; backMidUDMFOffsetLabel.Visible = hasMiddleFields; backMidUDMFScale.Visible = hasMiddleFields; backMidUDMFScaleLabel.Visible = hasMiddleFields; backBottomUDMFOffset.Visible = hasBottomFields; backBottomUDMFOffsetLabel.Visible = hasBottomFields; backBottomUDMFScale.Visible = hasBottomFields; backBottomUDMFScaleLabel.Visible = hasBottomFields; } else { backoffsetlabel.Text = "Back offset:"; if (l.Back.OffsetX != 0 || l.Back.OffsetY != 0) { backoffset.Text = l.Back.OffsetX + ", " + l.Back.OffsetY; backoffsetlabel.Enabled = true; backoffset.Enabled = true; backoffset.ForeColor = (highlight ? SystemColors.HotTrack : SystemColors.WindowText); backoffsetlabel.ForeColor = backoffset.ForeColor; } else { backoffset.Text = "--, --"; backoffsetlabel.Enabled = false; backoffset.Enabled = false; } // Sector index backpanel.Text += ". Sector " + l.Back.Sector.Index + " "; } //mxd. Set texture names, update panel sizes UpdateTexturePanel(panelBackTop, l.Back.HighTexture, backhighname, labelTextureBackTop, Math.Max(backTopUDMFOffset.Right, backTopUDMFScale.Right) + 4, backhightex, backTopUDMFOffsetLabel.Left, hasTopFields, l.Back.HighRequired()); UpdateTexturePanel(panelBackMid, l.Back.MiddleTexture, backmidname, labelTextureBackMid, Math.Max(backMidUDMFOffset.Right, backMidUDMFScale.Right) + 4, backmidtex, backMidUDMFOffsetLabel.Left, hasMiddleFields, l.Back.MiddleRequired()); UpdateTexturePanel(panelBackLow, l.Back.LowTexture, backlowname, labelTextureBackBottom, Math.Max(backBottomUDMFOffset.Right, backBottomUDMFScale.Right) + 4, backlowtex, backBottomUDMFOffsetLabel.Left, hasBottomFields, l.Back.LowRequired()); //mxd. Resize panel flowLayoutPanelBack.Width = panelBackLow.Right; backpanel.Width = flowLayoutPanelBack.Width + flowLayoutPanelBack.Left * 2 - 4; } else { // Show no info if (General.Map.UDMF) //mxd { backoffsetlabel.Text = "Back light:"; backoffset.Text = "--"; } else { backoffsetlabel.Text = "Back offset:"; backoffset.Text = "--, --"; } backoffsetlabel.Enabled = false; backoffset.Enabled = false; backhightex.BackgroundImage = null; backmidtex.BackgroundImage = null; backlowtex.BackgroundImage = null; backpanel.Visible = false; //mxd } //mxd. Flags and activations flags.Items.Clear(); // Add activations foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates) { if (l.Flags.ContainsKey(ai.Key) && l.Flags[ai.Key]) { flags.Items.Add(new ListViewItem(ai.Title) { Checked = true, ForeColor = SystemColors.HotTrack }); } } // And flags foreach (KeyValuePair <string, string> group in General.Map.Config.LinedefFlags) { if (l.Flags.ContainsKey(group.Key) && l.Flags[group.Key]) { flags.Items.Add(new ListViewItem(group.Value) { Checked = true }); } } // And front flags if (l.Front != null) { foreach (KeyValuePair <string, string> group in General.Map.Config.SidedefFlags) { if (l.Front.Flags.ContainsKey(group.Key) && l.Front.Flags[group.Key]) { flags.Items.Add(new ListViewItem("Front: " + group.Value) { Checked = true }); } } } // And back flags if (l.Back != null) { foreach (KeyValuePair <string, string> group in General.Map.Config.SidedefFlags) { if (l.Back.Flags.ContainsKey(group.Key) && l.Back.Flags[group.Key]) { flags.Items.Add(new ListViewItem("Back: " + group.Value) { Checked = true }); } } } //mxd. Flags panel visibility and size flagsPanel.Visible = (flags.Items.Count > 0); if (flags.Items.Count > 0) { Rectangle rect = flags.GetItemRect(0); int itemspercolumn = 1; // Check how many items per column we have... for (int i = 1; i < flags.Items.Count; i++) { if (flags.GetItemRect(i).X != rect.X) { break; } itemspercolumn++; } flags.Width = rect.Width * (int)Math.Ceiling(flags.Items.Count / (float)itemspercolumn); flagsPanel.Width = flags.Width + flags.Left * 2; } // Show the whole thing this.Show(); //this.Update(); // ano - don't think this is needed, and is slow }
/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// is created as a new child specifically for this object, and will not /// be passed onto other configuration objects. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); if (!this.Enabled || !this.IsInitialized) { return(false); } Debug.Assert(_settings != null, "The settings object is required."); if (_settings == null || _context == null) { return(false); } //<component type="Sandcastle.Components.ConceptualPostTransComponent" assembly="$(SandAssistComponent)"> // <paths outputPath=".\Output\"/> // <attributes> // <attribute name="DocSet" value="NETFramework" /> // <attribute name="DocSet" value="NETCompactFramework"/> // </attributes> // <scripts> // <IncludeItem item="assistScripts" /> // </scripts> // <styles> // <!-- Include the various styles used by the Sandcastle Assist --> // <IncludeItem item="codeStyle" /> // <IncludeItem item="assistStyle" /> // </styles> // <header> // <!-- Include the logo image support --> // <IncludeItem item="logoImage" /> // <!--<tables> // <table name="" operation="" /> // </tables>--> // </header> //</component> BuildFeedback feeback = _settings.Feedback; Debug.Assert(feeback != null, "Feedback object cannot be null (or Nothing)."); if (feeback == null) { return(false); } BuildStyle buildStyle = _settings.Style; Debug.Assert(buildStyle != null, "The style object cannot be null (or Nothing)."); if (buildStyle == null) { return(false); } writer.WriteStartElement("paths"); //start: paths writer.WriteAttributeString("outputPath", @".\Output\"); writer.WriteEndElement(); //end: paths AttributeContent attributes = _settings.Attributes; if (attributes != null && attributes.Count != 0) { writer.WriteStartElement("attributes"); //start: attributes for (int i = 0; i < attributes.Count; i++) { AttributeItem attribute = attributes[i]; if (attribute.IsEmpty) { continue; } writer.WriteStartElement("attribute"); //start: attribute writer.WriteAttributeString("name", attribute.Name); writer.WriteAttributeString("value", attribute.Value); writer.WriteEndElement(); //end: attribute } writer.WriteEndElement(); //end: attributes } writer.WriteStartElement("scripts"); //start: scripts ScriptContent scriptContent = buildStyle.Scripts; if (scriptContent != null && !scriptContent.IsEmpty) { for (int i = 0; i < scriptContent.Count; i++) { ScriptItem scriptItem = scriptContent[i]; // a. Empty item is no use. // b. Overriding scripts are added to the documentation // by the transform. if (scriptItem.IsEmpty || scriptItem.Overrides) { continue; } writer.WriteStartElement("script"); //start: script writer.WriteAttributeString("file", scriptItem.ScriptFile); writer.WriteAttributeString("condition", scriptItem.Condition); writer.WriteEndElement(); //end: script } } writer.WriteEndElement(); //end: scripts writer.WriteStartElement("styles"); //start: styles StyleSheetContent styleContent = buildStyle.StyleSheets; if (styleContent != null && !styleContent.IsEmpty) { for (int i = 0; i < styleContent.Count; i++) { StyleSheetItem styleItem = styleContent[i]; // a. Empty item is no use. // b. Overriding styles are added to the documentation // by the transform. if (styleItem.IsEmpty || styleItem.Overrides) { continue; } writer.WriteStartElement("style"); //start: style writer.WriteAttributeString("file", styleItem.StyleFile); writer.WriteAttributeString("condition", styleItem.Condition); writer.WriteEndElement(); //end: style } } writer.WriteEndElement(); //end: styles // Let the Feedback option object configure itself... feeback.Configure(group, writer); return(true); }
void ProcessItem(string name, ScriptItem flags, object item, Type itemType) { if ((flags & ScriptItem.IsVisible) != 0) { CL.SetSymbolValue (CL.Intern (name), item); } if ((flags & ScriptItem.GlobalMembers) != 0) { foreach (FieldInfo fieldInfo in itemType.GetFields ()) { Debug.WriteLine ("Process Field " + fieldInfo.ToString ()); } foreach (PropertyInfo propertyInfo in itemType.GetProperties ()) { string propName = propertyInfo.Name; CL.SetSymbolValue (CL.Intern (propName), propertyInfo); } Debug.WriteLine ("Installed"); } Debug.WriteLine ("processed"); }
/// <summary> /// Splits the ScriptLine into sections and returns a special class that signifies it has been split /// </summary> /// <returns>A list of SplitScriptLines</returns> public List <SplitScriptLine> SplitIntoSections() { List <SplitScriptLine> lines = new List <SplitScriptLine>(); lines.Add(new SplitScriptLine()); int nSection = -1; bool first = true; bool forceSplitNext = false; for (int i = 0; i < NumberOfScriptItems; i++) { ScriptItem item = GetScriptItem(i); // Code A2 appears to denote the beginning of a new section, so we split it if (item.Command == TalkCommand.StartNewSection) { // It's a new section, so we simply advance the section counter and add an empty SplitScriptLine nSection++; lines.Add(new SplitScriptLine()); } // if there is a IfElse branch for the Avatar's name the, a DoNothingSection or a goto label, then we add a new section, save the SplitScriptLine else if (item.Command == TalkCommand.IfElseKnowsName || item.Command == TalkCommand.DoNothingSection || item.Command == TalkCommand.DefineLabel) { // advance to next section nSection++; // add a stump section lines.Add(new SplitScriptLine()); // add the item as-is to the new section lines[nSection].AddScriptItem(item); // we need to tell the loop to force yet another split next time around // basically - these items need to part of a single item SplitScriptLine forceSplitNext = true; } else if (item.Command == TalkCommand.Change) { // advance to next section nSection++; // add a stump section lines.Add(new SplitScriptLine()); // this is a bit dirty - but the next item is the item number that we are being given item.ItemAdditionalData = (int)GetScriptItem(i + 1).Command; // add the item as-is to the new section lines[nSection].AddScriptItem(item); i++; forceSplitNext = true; } else if (item.Command == TalkCommand.Gold) { // advance to next section nSection++; // the next three characters are a 3 digit string that describes how much gold we are giving the NPC item.ItemAdditionalData = int.Parse(GetScriptItem(i + 1).Str.Substring(0, 3)); i++; forceSplitNext = true; } // if there is a default message then it is the definition of a new label else if (item.Command == TalkCommand.StartLabelDefinition) { // advance to next section nSection++; Debug.Assert(GetScriptItem(i + 1).Command == TalkCommand.DefineLabel); // StartLabelDefinition must ALWYAYS be followed with a DefineLabel // add the StartLabelDefintion to the new section lines[nSection].AddScriptItem(item); // add the next item - which is a DefineLabel to the section lines[nSection].AddScriptItem(GetScriptItem(i + 1)); // skip by the DefineLabel section since we just added i++; // we need to tell the loop to force yet another split next time around // basically - these items need to part of a single item SplitScriptLine forceSplitNext = true; } else // it is any other kind of TalkCommand { // welp - I really can't recall why I did this, but I need it. if (first) { nSection = 0; } // if we are forcing a new section from a previous run, then we increment the section number if (forceSplitNext) { forceSplitNext = false; nSection++; lines.Add(new SplitScriptLine()); } if (nSection < 0) { throw new Ultima5ReduxException("Section number fell below zero in conversation."); } lines[nSection].AddScriptItem(item); } first = false; } return(lines); }
public QueryWindowHeader(ScriptItem scriptItem) : this(ObjectFactory.Get<ISscOperations>(), scriptItem) { InitializeComponent(); }
/// <summary> /// After adding all elements, this will process the script into a more readable format /// </summary> public void InitScript() { // we keep track of the index into the ScriptLines all the way through the entire method int nIndex = END_BASE_INDEXES + 1; // have we encountered a label yet? //bool labelEncountered = false; string question; // we are going to add name, job and bye to all scripts by default. We use the QuestionAnswer objects to make it seamless List <string> nameQuestion = new List <string>(1) { "name" }; _scriptQuestionAnswers.Add(new ScriptQuestionAnswer(nameQuestion, _scriptLines[(int)TalkConstants.Name])); List <string> jobQuestion = new List <string>(2) { "job", "work" }; _scriptQuestionAnswers.Add(new ScriptQuestionAnswer(jobQuestion, _scriptLines[(int)TalkConstants.Job])); List <string> byeQuestion = new List <string>(1) { "bye" }; _scriptQuestionAnswers.Add(new ScriptQuestionAnswer(byeQuestion, _scriptLines[(int)TalkConstants.Bye])); // repeat through the question/answer components until we hit a label - then we know to move onto the label section do { List <string> currQuestions = new List <string>(); ScriptLine line = _scriptLines[nIndex]; // if we just hit a label, then it's time to jump out of this loop and move onto the label reading loop if (line.GetScriptItem(0).Command == TalkCommand.StartLabelDefinition) { //labelEncountered = true; break; } // first time around we KNOW there is a first question, all NPCs have at least one question question = line.GetScriptItem(0).Str; // dumb little thing - there are some scripts that have the same keyword multiple times // the game favours the one it sees first (see "Camile" in West Brittany as an example) if (!_scriptQuestionAnswers.QuestionAnswers.ContainsKey(question)) { currQuestions.Add(question); } // if we peek ahead and the next command is an <or> then we will just skip it and continue to add to the questions list while (_scriptLines[nIndex + 1].ContainsCommand(TalkCommand.Or)) { nIndex += 2; line = _scriptLines[nIndex]; question = line.GetScriptItem(0).Str; // just in case they try to add the same question twice - this is kind of a bug in the data since the game just favours the first question it sees if (!_scriptQuestionAnswers.QuestionAnswers.ContainsKey(question)) { currQuestions.Add(question); } } ScriptLine nextLine = _scriptLines[nIndex + 1]; _scriptQuestionAnswers.Add(new ScriptQuestionAnswer(currQuestions, nextLine)); nIndex += 2; } while (true); // a little hack - it's easy to end the conversation if it always ends with the end conversation tag _scriptLines[(int)TalkConstants.Bye].AddScriptItem(new ScriptItem(TalkCommand.EndCoversation)); // time to process labels!! the nIndex that the previous routine left with is the beginning of the label section int count = 0; do // begin the label processing loop - pretty sure this is dumb and doesn't do anything - but everything messes up when I remove it { // this is technically a loop, but it should never actually loop. Kind of dumb, but fragile Debug.Assert(count++ == 0); ScriptLine line = _scriptLines[nIndex]; ScriptLine nextLine; // if there are two script items, and those two script items identify an end of label section then let's break out // this should only actually occur if there are no labels at all if (line.NumberOfScriptItems == 2 && line.IsEndOfLabelSection) { // all done. we either had no labels or reached the end of them // assert that we are on the last line of the script Debug.Assert(nIndex == _scriptLines.Count - 1); break; } // i expect that this line will always indicate a new label is being defined Debug.Assert(line.GetScriptItem(0).Command == TalkCommand.StartLabelDefinition); // I don't like this, it's inelegant, but it works... // at this point we know: // This is a multi line message bool nextCommandDefaultMessage = false; do // called for each label # { // Debug code for narrowing down to a single NPC //if (scriptLines[0].GetScriptItem(0).Str.ToLower().Trim() == "sutek".ToLower()) //if (scriptLines[0].GetScriptItem(0).Str.ToLower().Trim() == "sir arbuthnot") //{ // Console.WriteLine("AH"); //} line = _scriptLines[nIndex]; // let's make sure there are actually labels to look at if (line.IsEndOfLabelSection) { nextCommandDefaultMessage = true; break; } // create the shell for the label ScriptTalkLabel scriptTalkLabel = new ScriptTalkLabel(line.GetScriptItem(1).LabelNum, line); // save the new label to the label collection _scriptTalkLabels.AddLabel(scriptTalkLabel); // it's a single line only, so we skip this tom foolery below if (_scriptLines[nIndex + 1].GetScriptItem(0).Command == TalkCommand.StartLabelDefinition) { // do nothing, the ScriptTalkLabel will simply have no DefaultAnswer indicating that only the primary label line is read nIndex++; continue; } // with a single answer below the label, we will always use the default answer ScriptLine defaultAnswer = _scriptLines[++nIndex]; scriptTalkLabel.DefaultAnswers.Add(defaultAnswer); // it's a default only answer, and no additional line of dialog, then we skip this tom foolery below if (_scriptLines[nIndex + 1].GetScriptItem(0).Command == TalkCommand.StartLabelDefinition) { nIndex++; continue; } do // go through the question/answer and <or> { // Debug code to stop at given index //if (nIndex == 22) { Console.WriteLine(""); } List <string> currQuestions = new List <string>(); // if the next line is an <or> then process the <or> if (_scriptLines[nIndex + 2].ContainsCommand(TalkCommand.Or)) { while (_scriptLines[nIndex + 2].ContainsCommand(TalkCommand.Or)) { line = _scriptLines[nIndex + 1]; Debug.Assert(line.IsQuestion); question = line.GetScriptItem(0).Str; // just in case they try to add the same question twice - this is kind of a bug in the data since the game just favours the first question it sees if (!_scriptQuestionAnswers.QuestionAnswers.ContainsKey(question)) { currQuestions.Add(question); } nIndex += 2; } line = _scriptLines[++nIndex]; Debug.Assert(line.IsQuestion); question = line.GetScriptItem(0).Str; // just in case they try to add the same question twice - this is kind of a bug in the data since the game just favours the first question it sees if (!_scriptQuestionAnswers.QuestionAnswers.ContainsKey(question)) { currQuestions.Add(question); } } // is this a question that the player would ask an NPC? else if (_scriptLines[nIndex + 1].GetScriptItem(0).IsQuestion()) { // get the Avatar's response line line = _scriptLines[++nIndex]; question = line.GetScriptItem(0).Str; Debug.Assert(ScriptItem.IsQuestion(question)); currQuestions.Add(question); } // the NPC has tricked me - this is a second line of dialog for the given // that dastardly LB has put an extra response line in.... else //if (scriptLines[nIndex + 1].GetScriptItem(0).Str.Trim().Length > 4) { line = _scriptLines[++nIndex]; Debug.Assert(!line.IsQuestion); scriptTalkLabel.DefaultAnswers.Add(line); nIndex++; // let's make double sure that we only have a single additional line of text Debug.Assert(_scriptLines[nIndex].GetScriptItem(0).Command == TalkCommand.StartLabelDefinition); nextLine = _scriptLines[nIndex]; continue; } // get your answer and store it ScriptLine npcResponse = _scriptLines[++nIndex]; // we are ready to create a Q&A object and add it the label specific Q&A script scriptTalkLabel.AddScriptQuestionAnswer(new ScriptQuestionAnswer(currQuestions, npcResponse)); // we are at the end of the label section of the file, so we are done. nextLine = _scriptLines[++nIndex]; // does the next line indicate end of all of the label sections, then let's get out of this loop if (nextLine.IsEndOfLabelSection) { nIndex--; nextCommandDefaultMessage = true; break; } // is the next line a label definition? is so, let's exit this label and move on if (!nextLine.IsLabelDefinition()) { nIndex--; continue; } // while we know the next line is not a new label or end of label, then let's keep reading by moving to our next loop } while (nextLine.GetScriptItem(0).Command != TalkCommand.StartLabelDefinition); // while we haven't encountered an end of label section } while (!nextCommandDefaultMessage); nIndex++; // while we haven't read every last line, then let's keep reading } while (nIndex < (_scriptLines.Count - 1)); }
private void GridOnUserHitCell(object sender, MouseEventArgs mouseEventArgs, int rowIndex, FastColumn col) { selectedScript = (ScriptItem)grid.rows[rowIndex].ValueObject; DialogResult = DialogResult.OK; }
// This shows the info public void ShowInfo(Thing t) { // Show/hide stuff depending on format bool hasArgs = General.Map.FormatInterface.HasActionArgs; arglbl1.Visible = hasArgs; arglbl2.Visible = hasArgs; arglbl3.Visible = hasArgs; arglbl4.Visible = hasArgs; arglbl5.Visible = hasArgs; arg1.Visible = hasArgs; arg2.Visible = hasArgs; arg3.Visible = hasArgs; arg4.Visible = hasArgs; arg5.Visible = hasArgs; infopanel.Width = (hasArgs ? hexenformatwidth : doomformatwidth); //mxd action.Visible = General.Map.FormatInterface.HasThingAction; labelaction.Visible = General.Map.FormatInterface.HasThingAction; // Move panel spritepanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + spritepanel.Margin.Left; flagsPanel.Left = spritepanel.Left + spritepanel.Width + spritepanel.Margin.Right + flagsPanel.Margin.Left; //mxd // Lookup thing info ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type); // Get thing action information LinedefActionInfo act; if (General.Map.Config.LinedefActions.ContainsKey(t.Action)) { act = General.Map.Config.LinedefActions[t.Action]; } else if (t.Action == 0) { act = new LinedefActionInfo(0, "None", true, false); } else { act = new LinedefActionInfo(t.Action, "Unknown", false, false); } string actioninfo = act.ToString(); // Determine z info to show t.DetermineSector(); string zinfo; if (ti.AbsoluteZ || t.Sector == null) { zinfo = t.Position.z.ToString(CultureInfo.InvariantCulture) + " (abs.)"; //mxd } else { // Hangs from ceiling? if (ti.Hangs) { zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetCeilingPlane(t.Sector).GetZ(t.Position) - t.Position.z - ti.Height, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")"; //mxd } else { zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")"; //mxd } } // Thing info infopanel.Text = " Thing " + t.Index + " "; type.Text = t.Type + " - " + ti.Title; if (ti.IsObsolete) { type.Text += " - OBSOLETE"; //mxd } action.Text = actioninfo; bool displayclassname = !string.IsNullOrEmpty(ti.ClassName) && !ti.ClassName.StartsWith("$"); //mxd labelclass.Enabled = displayclassname; //mxd classname.Enabled = displayclassname; //mxd classname.Text = (displayclassname ? ti.ClassName : "--"); //mxd position.Text = t.Position.x.ToString(CultureInfo.InvariantCulture) + ", " + t.Position.y.ToString(CultureInfo.InvariantCulture) + ", " + zinfo; tag.Text = t.Tag + (General.Map.Options.TagLabels.ContainsKey(t.Tag) ? " - " + General.Map.Options.TagLabels[t.Tag] : string.Empty); angle.Text = t.AngleDoom + "\u00B0"; anglecontrol.Angle = t.AngleDoom; anglecontrol.Left = angle.Right + 1; // Sprite if (ti.Sprite.ToLowerInvariant().StartsWith(DataManager.INTERNAL_PREFIX) && (ti.Sprite.Length > DataManager.INTERNAL_PREFIX.Length)) { spritename.Text = ""; spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetSpritePreview(); } else if ((ti.Sprite.Length <= 8) && (ti.Sprite.Length > 0)) { spritename.Text = ti.Sprite; spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetPreview(); } else { spritename.Text = ""; spritetex.Image = null; } // Arguments ArgumentInfo[] arginfo = ((t.Action == 0 && ti.Args[0] != null) ? ti.Args : act.Args); //mxd //mxd. ACS script argument names bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1); bool isarg0str = (General.Map.UDMF && t.Fields.ContainsKey("arg0str")); string arg0str = isarg0str ? t.Fields.GetValue("arg0str", string.Empty) : string.Empty; ScriptItem scriptitem = null; //mxd. Set default label colors arg1.ForeColor = SystemColors.ControlText; arglbl1.ForeColor = SystemColors.ControlText; // Named script? if (isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant())) { scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()]; } // Script number? else if (isacsscript && General.Map.NumberedScripts.ContainsKey(t.Args[0])) { scriptitem = General.Map.NumberedScripts[t.Args[0]]; arg0str = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString()); } // Apply script args? Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 }; Label[] args = { arg1, arg2, arg3, arg4, arg5 }; if (scriptitem != null) { int first; string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action, out first); for (int i = 0; i < first; i++) { arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":"; arglabels[i].Enabled = arginfo[i].Used; args[i].Enabled = arginfo[i].Used; } for (int i = first; i < argnames.Length; i++) { if (!string.IsNullOrEmpty(argnames[i])) { arglabels[i].Text = argnames[i] + ":"; arglabels[i].Enabled = true; args[i].Enabled = true; } else { arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":"; arglabels[i].Enabled = arginfo[i].Used; args[i].Enabled = arginfo[i].Used; } } } else { for (int i = 0; i < arginfo.Length; i++) { arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":"; arglabels[i].Enabled = arginfo[i].Used; args[i].Enabled = arginfo[i].Used; } // Special cases: unknown script name/index if (isacsscript) { arglbl1.Text = "Unknown script " + (isarg0str ? "name" : "number") + ":"; arg1.ForeColor = Color.DarkRed; arglbl1.ForeColor = Color.DarkRed; } } //mxd. Set argument value and label if (isarg0str) { arg1.Text = arg0str; } else { SetArgumentText(act.Args[0], arg1, t.Args[0]); } SetArgumentText(arginfo[1], arg2, t.Args[1]); SetArgumentText(arginfo[2], arg3, t.Args[2]); SetArgumentText(arginfo[3], arg4, t.Args[3]); SetArgumentText(arginfo[4], arg5, t.Args[4]); //mxd. Flags flags.Items.Clear(); Dictionary <string, string> flagsrename = ti.FlagsRename; foreach (KeyValuePair <string, string> group in General.Map.Config.ThingFlags) { if (t.Flags.ContainsKey(group.Key) && t.Flags[group.Key]) { ListViewItem lvi = (flagsrename != null && flagsrename.ContainsKey(group.Key)) ? new ListViewItem(flagsrename[group.Key]) { ForeColor = SystemColors.HotTrack } : new ListViewItem(group.Value); lvi.Checked = true; flags.Items.Add(lvi); } } //mxd. Flags panel visibility and size flagsPanel.Visible = (flags.Items.Count > 0); if (flags.Items.Count > 0) { Rectangle rect = flags.GetItemRect(0); int itemspercolumn = 1; // Check how many items per column we have... for (int i = 1; i < flags.Items.Count; i++) { if (flags.GetItemRect(i).X != rect.X) { break; } itemspercolumn++; } flags.Width = rect.Width * (int)Math.Ceiling(flags.Items.Count / (float)itemspercolumn); flagsPanel.Width = flags.Width + flags.Left * 2; } // Show the whole thing this.Show(); //this.Update(); // ano - don't think this is needed, and is slow }
private void DrawValueSetMode(ScriptItem item, FieldType fieldType) { if (fieldType == FieldType.Number) { item.valueSetMode = (ValueSetMode) EditorGUILayout.EnumPopup(item.valueSetMode, GUILayout.Width(40)); } else { EditorGUILayout.LabelField("to", GUILayout.Width(22)); } }
private void DrawScriptItem(ScriptItem item, ref ScriptItem itemToDelete) { EditorGUILayout.BeginHorizontal(); #if USE_UNET if (item.resourceType == ScriptWizardResourceType.Quest || item.resourceType == ScriptWizardResourceType.QuestEntry || item.resourceType == ScriptWizardResourceType.Variable) { item.netSetMode = (NetSetMode)EditorGUILayout.EnumPopup(item.netSetMode, GUILayout.Width(36)); } else { item.netSetMode = NetSetMode.Set; EditorGUILayout.LabelField("Set", GUILayout.Width(32)); } #else EditorGUILayout.LabelField("Set", GUILayout.Width(32)); #endif ScriptWizardResourceType newResourceType = (ScriptWizardResourceType)EditorGUILayout.EnumPopup(item.resourceType, GUILayout.Width(96)); if (newResourceType != item.resourceType) { item.resourceType = newResourceType; item.scriptQuestEntryNames = new string[0]; } if (item.resourceType == ScriptWizardResourceType.Quest) { // Quest: item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames); EditorGUILayout.LabelField("to", GUILayout.Width(22)); //---Was: item.questState = (QuestState) EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96); } else if (item.resourceType == ScriptWizardResourceType.QuestEntry) { // Quest Entry: int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; item.scriptQuestEntryNames = new string[0]; } if ((item.scriptQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { item.scriptQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, item.scriptQuestEntryNames); EditorGUILayout.LabelField("to", GUILayout.Width(22)); //---Was: item.questState = (QuestState) EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96); } else if (item.resourceType == ScriptWizardResourceType.Variable) { // Variable: item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variableNames); var variableType = GetWizardVariableType(item.variableNamesIndex); DrawValueSetMode(item, variableType); switch (variableType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.Actor) { // Actor: item.actorNamesIndex = EditorGUILayout.Popup(item.actorNamesIndex, actorNames); item.actorFieldIndex = EditorGUILayout.Popup(item.actorFieldIndex, actorFieldNames); var actorFieldType = GetWizardActorFieldType(item.actorFieldIndex); DrawValueSetMode(item, actorFieldType); switch (actorFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.Item) { // Item: item.itemNamesIndex = EditorGUILayout.Popup(item.itemNamesIndex, itemNames); item.itemFieldIndex = EditorGUILayout.Popup(item.itemFieldIndex, itemFieldNames); var itemFieldType = GetWizardItemFieldType(item.itemFieldIndex); DrawValueSetMode(item, itemFieldType); switch (itemFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.Location) { // Location: item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames); item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames); var locationFieldType = GetWizardLocationFieldType(item.locationFieldIndex); DrawValueSetMode(item, locationFieldType); switch (locationFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUILayout.FloatField(item.floatValue); break; default: item.stringValue = EditorGUILayout.TextField(item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.SimStatus) { // SimStatus: item.simStatusID = EditorGUILayout.IntField(item.simStatusID, GUILayout.Width(50)); item.simStatusType = (SimStatusType)EditorGUILayout.EnumPopup(item.simStatusType); } else if (item.resourceType == ScriptWizardResourceType.Alert) { // Alert: item.stringValue = EditorGUILayout.TextField(item.stringValue); } else if (item.resourceType == ScriptWizardResourceType.Custom) { // Custom: item.stringValue = EditorGUILayout.TextField(item.stringValue); } if (GUILayout.Button(new GUIContent("-", "Delete this script action."), EditorStyles.miniButton, GUILayout.Width(22))) { itemToDelete = item; } EditorGUILayout.EndHorizontal(); }
public QueryWindowHeader(ScriptItem scriptItem) : this(ObjectFactory.Get <ISscOperations>(), scriptItem) { InitializeComponent(); }