Exemplo n.º 1
0
        //Start new EVT from scratch
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Re-initialize some things that may have changed if you already opened a PAK
            evtPath               = "";
            pakPath               = "";
            bmdPath               = "";
            bmd                   = "";
            this.Text             = "EVTEditor";
            txt_MsgEditor.Enabled = false;
            evt                   = new EvtFile();
            //Add field command to EVT to start with
            var command = new Command();

            command.Type     = "Fd__";
            command.Time     = trackBar.Value;
            command.DataSize = 64;
            command.Data     = CommandDataFactory.Create(command.Type);
            evt.Commands.Add(command);
            //Add field object to EVT to start with
            var obj = new EvtObject();

            obj.Type = EvtObjectType.Field;
            evt.Objects.Add(obj);

            //Enable controls
            AddCommandToolStripMenuItem.Visible = true;
            trackBar.Enabled = true;

            //Enable datagridviews
            EVTSetup();
        }
Exemplo n.º 2
0
        //Add a command at the selected Time
        private void AddNewCommandTypeClickHandler(object sender, EventArgs e)
        {
            ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
            var command = new Command();

            command.Type = clickedItem.Name;
            command.Time = trackBar.Value;
            command.Data = CommandDataFactory.Create(clickedItem.Name);

            evt.Commands.Add(command);
            RefreshEVT();
        }
Exemplo n.º 3
0
        //Update tabs based on currently selected Command
        private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl.TabPages.Count != 0)
            {
                TabPage tp = tabControl.SelectedTab;
                GridViewRefresh(dgv);
                GridViewRefresh(dgv2);
                tp.Controls.Add(dgv);
                tp.Controls.Add(dgv2);

                foreach (Command command in evt.Commands.Where(cmd => Convert.ToInt32(GetSubstringByString("[", "]", tabControl.SelectedTab.Text)) == evt.Commands.IndexOf(cmd)))
                {
                    //Update datagridview with command and command data properties
                    foreach (PropertyInfo prop in typeof(Command).GetProperties())
                    {
                        if (prop.Name != "Data")
                        {
                            dgv.Rows.Add(new string[] { $"{prop.Name}", $"{prop.GetValue(command, null)}" });
                        }
                        else
                        {
                            var cmdData = CommandDataFactory.Create(GetSubstringByString("[", "]", tabControl.SelectedTab.Text));
                            cmdData = command.Data;
                            var cmdDataType = cmdData.GetType();
                            foreach (PropertyInfo cmdDataProp in cmdDataType.GetProperties())
                            {
                                if (prop.Name != "Entries")
                                {
                                    dgv2.Rows.Add(new string[] { $"{cmdDataProp.Name}", $"{cmdDataProp.GetValue(cmdData, null)}" });
                                }
                            }
                        }
                    }

                    //Decompile and show BMD text if possible
                    if (File.Exists(bmdPath) && command.Type == "Msg_")
                    {
                        txt_MsgEditor.Enabled = true;
                        txt_MsgEditor.Text    = bmd;
                    }
                    else
                    {
                        txt_MsgEditor.Enabled = false;
                        txt_MsgEditor.Clear();
                    }
                }
            }
        }
Exemplo n.º 4
0
        //Update CommandData's property value in EVT to the changed cell's value
        private void UpdateEVTCommandData(object sender, DataGridViewCellEventArgs e)
        {
            //Narrow down the selected property in the evt so we can update it
            Command command = evt.Commands.Find(cmd => Convert.ToInt32(GetSubstringByString("[", "]", tabControl.SelectedTab.Text)) == evt.Commands.IndexOf(cmd));
            var     cmdData = CommandDataFactory.Create(GetSubstringByString("[", "]", tabControl.SelectedTab.Text));

            cmdData = command.Data;

            //Try to update value using the proper type
            PropertyInfo prop      = cmdData.GetType().GetProperty(dgv2.CurrentCell.OwningRow.Cells[0].Value.ToString());
            var          cellValue = dgv2.CurrentCell.Value;

            UpdateProperty(prop, cmdData, cellValue);

            //Update tabs and datagridview with new data
            BeginInvoke(new MethodInvoker(RefreshEVT));
        }