public EventObject(Layer layer, BinaryReader reader, Editor e) : base(layer, e) { nameBox.VerticalAlign = TextBox.VerticalAlignment.Center; nameBox.HorizontalAlign = TextBox.HorizontalAlignment.Center; paramBox.VerticalAlign = TextBox.VerticalAlignment.Top; paramBox.HorizontalAlign = TextBox.HorizontalAlignment.Center; int tempID = reader.ReadInt32(); if (tempID != -1) { SetTemplate(EventTemplate.GetEvent(tempID)); } int paramNmbr = reader.ReadInt32(); int[] parList = new int[paramNmbr]; for (int i = 0; i < paramNmbr; i++) { parList[i] = reader.ReadInt32(); } SetParameters(parList); foreach (Vertex v in vertices) { v.Position = new Vector2(reader.ReadSingle(), reader.ReadSingle()); } }
private void textBoxID_TextChanged(object sender, EventArgs e) { int.TryParse(textBoxID.Text, out id); CheckIfFinished(); textBoxID.BackColor = System.Drawing.Color.FromArgb((int)(EventTemplate.EventExists(id) ? 0xFFFF0000 : 0xFFFFFFFF)); }
public EventForm(EventObject[] objects) { InitializeComponent(); eventObjects = objects; UpdateEventList(); UpdateButtons(); if (objects.Length > 0) { string str = ""; for (int i = 0; i < objects[0].parameters.Count; i++) { str += objects[0].parameters[i]; if (i < objects[0].parameters.Count - 1) { str += ", "; } } if (objects[0].Template.ID != -1) { eventList.SelectedIndices.Clear(); eventList.SelectedIndices.Add(EventTemplate.GetEventIndex(objects[0].Template.ID)); } textBoxParams.Text = str; } }
public void SaveMap(string path) { saveFlag = false; fileName = path; using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create))) { writer.Write(mapName == null ? "Untitled" : mapName); writer.Write(gameModeID); background.WriteToFile(writer); tilesetList.WriteToFile(writer); writer.Write(templateList.Count); foreach (Template t in templateList) { t.WriteToFile(writer); } EventTemplate.SaveTo(writer); writer.Write(layerList.Count); foreach (Layer l in layerList) { l.WriteToFile(writer); } templateMenu.WriteToFile(writer); } }
private void eventList_SelectedIndexChanged(object sender, EventArgs e) { if (eventList.SelectedItems.Count > 0) { selectedTemplate = EventTemplate.eventList[eventList.SelectedItems[0].Index]; } else { selectedTemplate = null; } UpdateButtons(); }
private void buttonOK_Click(object sender, EventArgs e) { if (editTemplate == null) { EventTemplate.CreateEvent(name, id, color.Value); } else { editTemplate.Edit(id, name, color.Value); } eventForm.UpdateEventList(); Close(); }
public EventCreator(EventForm eventForm, EventTemplate t) : this(eventForm) { editTemplate = t; textBoxID.Text = editTemplate.ID.ToString(); textBoxName.Text = editTemplate.Name; colorButton.BackColor = System.Drawing.Color.FromArgb((int)(255 * t.Color.R), (int)(255 * t.Color.G), (int)(255 * t.Color.B)); id = editTemplate.ID; name = editTemplate.Name; color = editTemplate.Color; CheckIfFinished(); }
public void LoadMap(string path) { fileName = path; using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open))) { mapName = reader.ReadString(); gameModeID = reader.ReadInt32(); background.ReadFromFile(reader); tilesetList.ReadFromFile(reader); int templateNmbr = reader.ReadInt32(); for (int i = 0; i < templateNmbr; i++) { CreateTemplate(reader); } EventTemplate.LoadFrom(reader); int layerNmbr = reader.ReadInt32(); for (int i = 0; i < layerNmbr; i++) { if (i == 0) { layerList.Add(new SolidLayer(this)); } else { layerList.Add(new Layer(i, reader.ReadSingle(), this)); } layerList[i].ReadFromFile(reader); } templateMenu.ReadFromFile(reader); } }
public void SetTemplate(EventTemplate temp) { eventTemplate = temp; }
public static EventTemplate GetEvent(int id) { EventTemplate t = eventList.Find((x) => x.ID == id); return(t); }
void CheckIfFinished() { buttonOK.Enabled = ((name != null || name != "") && (id >= 0 && !EventTemplate.EventExists(id)) && color != null); }