コード例 #1
0
 private void menuItem_Copy_Click(object sender, EventArgs e)
 {
     if (menuItem_Edit.Enabled)
     {
         if (tabControl.SelectedTab == tabPage_BattleConditionals)
         {
             _battleConditionalSetCopy = battleConditionalSetsEditor.CopyConditionalSet();
         }
         else if (tabControl.SelectedTab == tabPage_WorldConditionals)
         {
             _worldConditionalSetCopy = worldConditionalSetsEditor.CopyConditionalSet();
         }
         else if (tabControl.SelectedTab == tabPage_Events)
         {
             _eventCopy = eventsEditor.CopyEvent();
         }
     }
 }
コード例 #2
0
        private void menuItem_CheckSize_Click(object sender, EventArgs e)
        {
            if (menuItem_View.Enabled)
            {
                if (tabControl.SelectedTab == tabPage_BattleConditionals)
                {
                    battleConditionalSetsEditor.SaveBlock();
                    byte[]         bytes = _dataHelper.ConditionalSetsToByteArray(CommandType.BattleConditional, _entryData.BattleConditionals);
                    ConditionalSet selectedConditionalSet = battleConditionalSetsEditor.CopyConditionalSet();
                    int            maxCommands            = _dataHelper.BattleConditionalSetMaxCommands;

                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("All Battle Conditionals Size: {0} / {1} bytes{2}", bytes.Length, Settings.BattleConditionalsSize, Environment.NewLine);
                    sb.AppendFormat("{0} {1}: {2} / {3} commands{4}", selectedConditionalSet.Index.ToString("X2"), selectedConditionalSet.Name, selectedConditionalSet.GetNumCommands(),
                                    maxCommands, Environment.NewLine);

                    bool hasInvalidSets      = false;
                    int  highestCommandTotal = 0;
                    int  highestCommandIndex = 0;
                    for (int index = 0; index < _entryData.BattleConditionals.Count; index++)
                    {
                        ConditionalSet conditionalSet = _entryData.BattleConditionals[index];
                        int            numSetCommands = conditionalSet.GetNumCommands();

                        if (highestCommandTotal < numSetCommands)
                        {
                            highestCommandTotal = numSetCommands;
                            highestCommandIndex = index;
                        }

                        if (numSetCommands > maxCommands)
                        {
                            hasInvalidSets = true;
                            sb.AppendFormat("{0} {1}: {2} / {3} commands{4}", conditionalSet.Index.ToString("X2"), conditionalSet.Name, numSetCommands, maxCommands, Environment.NewLine);
                        }
                    }

                    if (!hasInvalidSets)
                    {
                        ConditionalSet conditionalSet = _entryData.BattleConditionals[highestCommandIndex];
                        sb.AppendFormat("Largest set: {0} {1}: {2} / {3} commands{4}", conditionalSet.Index.ToString("X2"), conditionalSet.Name, highestCommandTotal, maxCommands, Environment.NewLine);
                    }

                    PatcherLib.MyMessageBox.Show(this, sb.ToString(), "Size", MessageBoxButtons.OK);
                }
                else if (tabControl.SelectedTab == tabPage_WorldConditionals)
                {
                    worldConditionalSetsEditor.SaveBlock();
                    byte[] bytes = _dataHelper.ConditionalSetsToByteArray(CommandType.WorldConditional, _entryData.WorldConditionals);
                    PatcherLib.MyMessageBox.Show(this, string.Format("All World Conditionals Size: {0} / {1} bytes", bytes.Length, Settings.WorldConditionalsSize), "Size", MessageBoxButtons.OK);
                }
                else if (tabControl.SelectedTab == tabPage_Events)
                {
                    eventsEditor.SavePage();
                    Event  selectedEvent = eventsEditor.CopyEvent();
                    byte[] bytes         = _dataHelper.EventToByteArray(selectedEvent, false);
                    int    maxEventBytes = _dataHelper.EventSize;

                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("{0} {1}: {2} / {3} bytes{4}", selectedEvent.Index.ToString("X4"), selectedEvent.Name, bytes.Length, Settings.EventSize, Environment.NewLine);

                    bool hasInvalidEvents = false;
                    int  highestByteTotal = 0;
                    int  highestByteIndex = 0;
                    for (int index = 0; index < _entryData.Events.Count; index++)
                    {
                        Event  ev            = _entryData.Events[index];
                        byte[] eventBytes    = _dataHelper.EventToByteArray(ev, false);
                        int    numEventBytes = eventBytes.Length;

                        if (highestByteTotal < numEventBytes)
                        {
                            highestByteTotal = numEventBytes;
                            highestByteIndex = index;
                        }

                        if (numEventBytes > maxEventBytes)
                        {
                            hasInvalidEvents = true;
                            sb.AppendFormat("{0} {1}: {2} / {3} bytes{4}", ev.Index.ToString("X4"), ev.Name, numEventBytes, maxEventBytes, Environment.NewLine);
                        }
                    }

                    if (!hasInvalidEvents)
                    {
                        Event ev = _entryData.Events[highestByteIndex];
                        sb.AppendFormat("Largest event: {0} {1}: {2} / {3} bytes{4}", ev.Index.ToString("X4"), ev.Name, highestByteTotal, maxEventBytes, Environment.NewLine);
                    }

                    PatcherLib.MyMessageBox.Show(this, sb.ToString(), "Size", MessageBoxButtons.OK);
                }
            }
        }