Exemplo n.º 1
0
        private void LoadSpecialList(List <PresetMacroEntry> specialList, bool useFilter)
        {
            List <ushort> presetsTaken = new List <ushort>();

            foreach (PresetMacroEntry entry in specialList)
            {
                if (!presetsTaken.Contains(entry.PresetID))
                {
                    if (level.ModelIDs.ContainsKey(entry.ModelID))
                    {
                        uint             modelAddress = level.ModelIDs[entry.ModelID].GeoDataSegAddress;
                        int              oce_index    = -1;
                        ObjectComboEntry oce          = level.getObjectComboFromData(entry.ModelID, modelAddress, entry.Behavior, out oce_index);
                        if (oce_index > -1)
                        {
                            string displayName = "(" + entry.PresetID + ") " + oce.Name;
                            if (!useFilter)
                            {
                                listView1.Items.Add(displayName);
                            }
                            else
                            {
                                if (displayName.ToUpper().Contains(textBox_filter.Text.ToUpper()))
                                {
                                    listView1.Items.Add(displayName);
                                }
                            }
                            //int index = listView1.Items.Count - 1;
                        }
                    }
                    presetsTaken.Add(entry.PresetID);
                }
            }
            col2 = Color.FromArgb(95, 100, 100);
        }
Exemplo n.º 2
0
        public string getObjectComboName()
        {
            uint behaviorAddr        = getBehaviorAddress();
            uint modelSegmentAddress = 0;

            for (int i = 0; i < Globals.objectComboEntries.Count; i++)
            {
                ObjectComboEntry entry = Globals.objectComboEntries[i];
                modelSegmentAddress = 0;
                if (level.ModelIDs.ContainsKey(ModelID))
                {
                    modelSegmentAddress = level.ModelIDs[ModelID].GeoDataSegAddress;
                }
                if (entry.ModelID == ModelID && entry.Behavior == behaviorAddr &&
                    entry.ModelSegmentAddress == modelSegmentAddress)
                {
                    objectComboEntry = entry;
                    Title            = entry.Name;
                    return(entry.Name);
                }
            }

            objectComboEntry = null;
            Title            = "Undefined Combo (0x" + modelID.ToString("X2") + ", 0x" + behaviorAddr.ToString("X8") + ")";
            return(Title);
        }
Exemplo n.º 3
0
        public void renameObjectCombo(string newName)
        {
            string oldComboName = Title;

            Title = newName;
            bool undefinedToDefined = oldComboName.StartsWith("Undefined Combo (") &&
                                      !newName.StartsWith("Undefined Combo (");

            if (!undefinedToDefined) // simple re-define
            {
                if (objectComboEntry != null)
                {
                    objectComboEntry.Name = newName;
                }
            }
            else
            {
                uint modelAddress = 0;
                if (level.ModelIDs.ContainsKey(ModelID))
                {
                    modelAddress = level.ModelIDs[ModelID].GeoDataSegAddress;
                }
                ObjectComboEntry newOCE = new ObjectComboEntry(newName, ModelID, modelAddress, getBehaviorAddress());
                objectComboEntry = newOCE;
                Globals.objectComboEntries.Add(newOCE);
                level.LevelObjectCombos.Add(newOCE);
            }

            ModelComboFile.writeObjectCombosFile(Globals.getDefaultObjectComboPath());
        }
Exemplo n.º 4
0
        private void initObjectList()
        {
            // get shallow copy of 'level.LevelObjectCombos'
            objectCombos = level.LevelObjectCombos.GetRange(0, level.LevelObjectCombos.Count);

            List <string> undefined_names = new List <string>();

            for (int i = 0; i < level.Areas.Count; i++)
            {
                for (int j = 0; j < level.Areas[i].Objects.Count; j++)
                {
                    string combo_name = level.Areas[i].Objects[j].getObjectComboName();
                    if (combo_name.StartsWith("Undefined Combo (") && !undefined_names.Contains(combo_name))
                    {
                        undefined_names.Add(combo_name);
                        string[] combo        = combo_name.Substring(17, 16).Split(',');
                        byte     modelID      = Convert.ToByte(combo[0].Substring(2), 16);
                        uint     modelAddress = 0;
                        if (level.ModelIDs.ContainsKey(modelID))
                        {
                            modelAddress = level.ModelIDs[modelID].GeoDataSegAddress;
                        }
                        uint             behavior = Convert.ToUInt32(combo[1].Substring(3), 16);
                        ObjectComboEntry newOCE   = new ObjectComboEntry(combo_name, modelID, modelAddress, behavior);
                        objectCombos.Add(newOCE);
                        Console.WriteLine("Found undefined combo! " + combo_name);
                    }
                }
            }
            comboBoxObjectSort.SelectedIndex = 0;
            updateObjectList();
        }
Exemplo n.º 5
0
        private void textBox_filter_TextChanged(object sender, EventArgs e)
        {
            BeginUpdate(listView1);
            listView1.Items.Clear();
            switch (listType)
            {
            case 0:
                foreach (ObjectComboEntry entry in level.LevelObjectCombos)
                {
                    if (entry.Name.ToUpper().Contains(textBox_filter.Text.ToUpper()))
                    {
                        listView1.Items.Add(entry.Name);
                        listView1.Items[listView1.Items.Count - 1].Tag = new object[]
                        {
                            entry.ModelID,
                            entry.Behavior
                        };
                    }
                }
                col2 = Color.FromArgb(75, 100, 100);
                break;

            case 1:
                foreach (PresetMacroEntry entry in level.MacroObjectPresets)
                {
                    if (level.ModelIDs.ContainsKey(entry.ModelID))
                    {
                        uint             modelAddress = level.ModelIDs[entry.ModelID].GeoDataSegAddress;
                        int              oce_index    = -1;
                        ObjectComboEntry oce          = level.getObjectComboFromData(entry.ModelID, modelAddress, entry.Behavior, out oce_index);
                        if (oce_index > -1)
                        {
                            string displayName = "(" + entry.PresetID.ToString() + ") " + oce.Name;
                            if (displayName.ToUpper().Contains(textBox_filter.Text.ToUpper()))
                            {
                                displayName += " {" + entry.BehaviorParameter1;
                                displayName += ", " + entry.BehaviorParameter2 + "}";
                                listView1.Items.Add(displayName);
                            }
                        }
                    }
                }
                col2 = Color.FromArgb(75, 100, 100);
                break;

            case 2:
                LoadSpecialList(level.SpecialObjectPresets_8, true);
                break;

            case 3:
                LoadSpecialList(level.SpecialObjectPresets_10, true);
                break;

            case 4:
                LoadSpecialList(level.SpecialObjectPresets_12, true);
                break;
            }
            EndUpdate(listView1);
        }
Exemplo n.º 6
0
        private void SelectComboPreset_Load(object sender, EventArgs e)
        {
            switch (listType)
            {
            case 0:
                foreach (ObjectComboEntry entry in level.LevelObjectCombos)
                {
                    listView1.Items.Add(entry.Name);
                    listView1.Items[listView1.Items.Count - 1].Tag = new object[]
                    {
                        entry.ModelID,
                        entry.Behavior
                    };
                    int index = listView1.Items.Count - 1;
                }
                col2 = Color.FromArgb(95, 100, 100);
                break;

            case 1:
                foreach (PresetMacroEntry entry in level.MacroObjectPresets)
                {
                    if (level.ModelIDs.ContainsKey(entry.ModelID))
                    {
                        uint             modelAddress = level.ModelIDs[entry.ModelID].GeoDataSegAddress;
                        int              oce_index    = -1;
                        ObjectComboEntry oce          = level.getObjectComboFromData(entry.ModelID, modelAddress, entry.Behavior, out oce_index);
                        if (oce_index > -1)
                        {
                            string displayName = "(" + entry.PresetID.ToString() + ") " + oce.Name;
                            displayName += " {" + entry.BehaviorParameter1;
                            displayName += ", " + entry.BehaviorParameter2 + "}";
                            listView1.Items.Add(displayName);
                            int index = listView1.Items.Count - 1;
                        }
                    }
                }
                col2 = Color.FromArgb(75, 100, 100);
                break;

            case 2:
                LoadSpecialList(level.SpecialObjectPresets_8, false);
                break;

            case 3:
                LoadSpecialList(level.SpecialObjectPresets_10, false);
                break;

            case 4:
                LoadSpecialList(level.SpecialObjectPresets_12, false);
                break;
            }

            if (listView1.Items.Count > 0)
            {
                listView1.Items[0].Selected = true;
                listView1.Select();
            }
        }
Exemplo n.º 7
0
 public void AddObjectCombos(byte modelId, uint modelSegAddress)
 {
     for (int i = 0; i < Globals.objectComboEntries.Count; i++)
     {
         ObjectComboEntry oce = Globals.objectComboEntries[i];
         if (oce.ModelID == modelId && oce.ModelSegmentAddress == modelSegAddress)
         {
             LevelObjectCombos.Add(oce);
         }
     }
 }
Exemplo n.º 8
0
 public void sortAndAddNoModelEntries()
 {
     for (int i = 0; i < Globals.objectComboEntries.Count; i++)
     {
         ObjectComboEntry oce = Globals.objectComboEntries[i];
         if (oce.ModelID == 0x00)
         {
             LevelObjectCombos.Add(oce);
         }
     }
     LevelObjectCombos.Sort((x, y) => string.Compare(x.Name, y.Name));
 }
Exemplo n.º 9
0
 public static void insertNewEntry(ObjectComboEntry newEntry)
 {
     for (int i = 0; i < objectComboEntries.Count; i++)
     {
         if (newEntry.ModelID == objectComboEntries[i].ModelID &&
             newEntry.ModelSegmentAddress == objectComboEntries[i].ModelSegmentAddress &&
             newEntry.Behavior == objectComboEntries[i].Behavior)
         {
             objectComboEntries[i].Name = newEntry.Name; // Update name if it already exists
             return;
         }
     }
     // Add new entry if it doesn't exist
     objectComboEntries.Add(newEntry);
 }
Exemplo n.º 10
0
 public ObjectComboEntry getObjectComboFromData(byte modelID, uint modelAddress, uint behavior, out int index)
 {
     for (int i = 0; i < LevelObjectCombos.Count; i++)
     {
         ObjectComboEntry oce = LevelObjectCombos[i];
         if (oce.ModelID == modelID && oce.ModelSegmentAddress == modelAddress &&
             oce.Behavior == behavior)
         {
             index = i;
             return(oce);
         }
     }
     index = -1;
     return(null);
 }
Exemplo n.º 11
0
        public string getObjectComboName()
        {
            uint behaviorAddr = getBehaviorAddress();

            for (int i = 0; i < Globals.objectComboEntries.Count; i++)
            {
                ObjectComboEntry entry = Globals.objectComboEntries[i];
                uint             modelSegmentAddress = 0;
                if (level.ModelIDs.ContainsKey(ModelID))
                {
                    modelSegmentAddress = level.ModelIDs[ModelID].GeoDataSegAddress;
                }
                if (entry.ModelID == ModelID && entry.Behavior == behaviorAddr && entry.ModelSegmentAddress == modelSegmentAddress)
                {
                    objectComboEntry = entry;
                    return(entry.Name);
                }
            }
            return("Unknown Combo");
        }
Exemplo n.º 12
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.P:
                if (Globals.list_selected != -1 && Globals.item_selected != -1)
                {
                    int      listSel = Globals.list_selected;
                    int      objSel  = Globals.item_selected;
                    Object3D obj     = getSelectedObject();
                    if (obj == null)
                    {
                        return;
                    }
                    string newName = Prompts.ShowInputDialog("Type the new combo name", "New combo name");
                    if (newName.Length > 0)
                    {
                        obj.Title = newName;
                        uint segmentAddress = 0;
                        if (level.ModelIDs.ContainsKey(obj.ModelID))
                        {
                            segmentAddress = level.ModelIDs[obj.ModelID].GeoDataSegAddress;
                        }
                        ObjectComboEntry oce = new ObjectComboEntry(newName, obj.ModelID,
                                                                    segmentAddress, obj.getBehaviorAddress());
                        Globals.insertNewEntry(oce);
                        refreshObjectsInList();
                        treeView1.SelectedNode = treeView1.Nodes[listSel].Nodes[objSel];
                        Globals.list_selected  = listSel;
                        Globals.item_selected  = objSel;
                        propertyGrid1.Refresh();
                    }
                    ModelComboFile.writeObjectCombosFile(Globals.getDefaultObjectComboPath());
                    Console.WriteLine("Saved Object Combos!");
                }
                break;

            case Keys.D1:
                trySwitchArea(1);
                break;

            case Keys.D2:
                trySwitchArea(2);
                break;

            case Keys.D3:
                trySwitchArea(3);
                break;

            case Keys.D4:
                trySwitchArea(4);
                break;

            case Keys.D5:
                trySwitchArea(5);
                break;

            case Keys.D6:
                trySwitchArea(6);
                break;

            case Keys.D7:
                trySwitchArea(7);
                break;

            case Keys.D0:
                trySwitchArea(0);
                break;
            }
        }