/// <summary> /// Constructor /// </summary> /// <param name="square">Square handle</param> /// <param name="evt">Event square handle</param> public ScriptedDialog(Square square, EventSquare evt) { if (square == null) throw new ArgumentNullException("Square is null"); if (evt == null) throw new ArgumentNullException("EventSquare is null"); Event = evt; Square = square; Picture = new Texture2D(Event.PictureName); if (Event.DisplayBorder) { Border = new Texture2D("border.png"); } // HACK: Hard coded maximum button for ScriptDialog Choices = new ScriptChoice[MaxButtonCount]; Buttons = new GUIScriptButton[MaxButtonCount]; for (int i = 0 ; i < MaxButtonCount ; i++) { Buttons[i] = new GUIScriptButton(); Buttons[i].Click +=new EventHandler(ButtonClick); } }
/// <summary> /// Constructor /// </summary> /// <param name="choice">choice to edit</param> /// <param name="dungeon">Dungeon handle</param> public EventChoiceForm(ScriptChoice choice, Dungeon dungeon) { InitializeComponent(); if (choice == null) throw new ArgumentNullException("choice"); Dungeon = dungeon; NameBox.Text = choice.Name; // ActionBox.Actions = choice.Actions; ActionBox.Dungeon = dungeon; Choice = choice; }
/// <summary> /// Loads the door's definition from a bank /// </summary> /// <param name="xml">Xml handle</param> /// <returns></returns> public override bool Load(XmlNode xml) { if (xml == null || xml.Name != Tag) return false; MessageColor = xml.Attributes["color"] != null ? Color.FromArgb(int.Parse(xml.Attributes["color"].Value)) : Color.White; MustFace = xml.Attributes["mustface"] != null ? bool.Parse(xml.Attributes["mustface"].Value) : false; Direction = xml.Attributes["direction"] != null ? (CardinalPoint)Enum.Parse(typeof(CardinalPoint), xml.Attributes["direction"].Value) : CardinalPoint.North; SoundName = xml.Attributes["soundname"] != null ? xml.Attributes["soundname"].Value : string.Empty; LoopSound = xml.Attributes["loopsound"] != null ? bool.Parse(xml.Attributes["loopsound"].Value) : false; DisplayBorder = xml.Attributes["displayborder"] != null ? bool.Parse(xml.Attributes["displayborder"].Value) : false; Message = xml.Attributes["message"] != null ? xml.Attributes["message"].Value : string.Empty; PictureName = xml.Attributes["picturename"] != null ? xml.Attributes["picturename"].Value : string.Empty; Intelligence = xml.Attributes["intelligence"] != null ? int.Parse(xml.Attributes["intelligence"].Value) : 0; Remaining = xml.Attributes["remaining"] != null ? int.Parse(xml.Attributes["remaining"].Value) : 0; foreach (XmlNode node in xml) { if (node.NodeType == XmlNodeType.Comment) continue; switch (node.Name.ToLower()) { case "choice": { ScriptChoice choice = new ScriptChoice(""); choice.Load(node); Choices.Add(choice); } break; case "text": { Text = node.InnerText; } break; default: { base.Load(node); } break; } } return true; }
private void AddEditChoiceBox_Click(object sender, EventArgs e) { if (EventSquare == null) return; ScriptChoice choice = new ScriptChoice("Choice " + (EventSquare.Choices.Count + 1)); EventSquare.Choices.Add(choice); new EventChoiceForm(choice, Dungeon).ShowDialog(); RebuildChoices(); }
/// <summary> /// Set the choices /// </summary> /// <param name="choice1">First choice</param> /// <param name="choice2">Second choice</param> /// <param name="choice2">Third choice</param> public void SetChoice(ScriptChoice choice1, ScriptChoice choice2, ScriptChoice choice3) { Choices[0] = choice1; Choices[1] = choice2; Choices[2] = choice3; if (choice1 != null) { Buttons[0].Rectangle = DisplayCoordinates.ScriptedDialogChoices[6]; Buttons[0].Text = choice1.Name; Buttons[0].Tag = choice1; } if (choice2 != null) { Buttons[1].Rectangle = DisplayCoordinates.ScriptedDialogChoices[7]; Buttons[1].Text = choice2.Name; Buttons[1].Tag = choice2; } if (choice3 != null) { Buttons[2].Rectangle = DisplayCoordinates.ScriptedDialogChoices[8]; Buttons[2].Text = choice3.Name; Buttons[2].Tag = choice3; } }
/// <summary> /// Set the choices /// </summary> /// <param name="choice1">First choice</param> /// <param name="choice2">Second choice</param> public void SetChoices(ScriptChoice choice1, ScriptChoice choice2) { Choices[0] = choice1; Choices[1] = choice2; Choices[2] = null; Buttons[0].Rectangle = DisplayCoordinates.ScriptedDialogChoices[3]; Buttons[0].Text = choice1.Name; Buttons[0].Tag = choice1; Buttons[1].Rectangle = DisplayCoordinates.ScriptedDialogChoices[4]; Buttons[1].Text = choice2.Name; Buttons[1].Tag = choice2; }
/// <summary> /// Set the choice /// </summary> /// <param name="choice">choice</param> public void SetChoices(ScriptChoice choice) { Choices[0] = choice; Choices[1] = null; Choices[2] = null; Buttons[0].Rectangle = DisplayCoordinates.ScriptedDialogChoices[0]; Buttons[0].Text = choice.Name; Buttons[0].Tag = choice; }
/// <summary> /// Set the choice /// </summary> /// <param name="id">Choice id (from 1 to 3)</param> /// <param name="choice">choice</param> public void SetChoices(int id, ScriptChoice choice) { if (id < 1 || id > 3) return; Choices[id] = choice; Buttons[id].Rectangle = DisplayCoordinates.ScriptedDialogChoices[0]; Buttons[id].Text = choice.Name; Buttons[id].Tag = choice; }