Beispiel #1
0
        private void Factory_InitializeAddOn(AddOnFactory factory, string assemblyName, string typeFullName, IHost host)
        {
            //Create
            IAddOn addOn = factory.CreateInstance <IAddOn>(assemblyName, typeFullName);

            addOn.Initialize(host);

            //Add
            addOns.Add(addOn);
        }
Beispiel #2
0
        public object Request(IAddOn sender, string request, params object[] args)
        {
            switch (request)
            {
            case "SelectedEntry": return(selectedEntry);

            case "Map": return(map);

            default: return(null);
            }
        }
Beispiel #3
0
        protected override void LoadAddOn(IAddOn addOn)
        {
            switch (addOn)
            {
            case IFileEditor fileEditor:
                FileEditors.Add(fileEditor);
                break;

            case IProjectEditor projectEditor:
                ProjectEditors.Add(projectEditor);
                break;
            }
        }
Beispiel #4
0
        protected override void LoadAddOn(IAddOn addOn)
        {
            switch (addOn)
            {
            case ITool tool:
                ToolAddOns.Add(tool);
                HaloAddOns.Add(tool);
                break;

            case IToolButton toolButton:
                ToolButtonAddOns.Add(toolButton);
                HaloAddOns.Add(toolButton);
                break;
            }
        }
Beispiel #5
0
        public object Request(IAddOn sender, string request, params object[] args)
        {
            switch (request)
            {
            case "Map": return(Map);

            case "SelectedEntry": return(Map.IndexEntries[(TagId)Editors[sender]]);

            case "Xbox": return(new Xbox(Application.StartupPath));

            default:
                System.Diagnostics.Debugger.Break();
                return(null);
            }
        }
Beispiel #6
0
        public static TagId BrowseTag(this IHost host, IAddOn sender, TagId id)
        {
            //Prepare
            TagId selectedId = id;

            //Check
            if (host.InvokeRequired)
            {
                host.Invoke(new TagIdInvoker(BrowseTag), new object[] { host, sender, id });
            }
            else
            {
                object response = host.Request(sender, "TagBrowserDialog", selectedId);
                if (response != null && response is TagId)
                {
                    selectedId = (TagId)response;
                }
            }

            //Return
            return(selectedId);
        }
Beispiel #7
0
 object IHost.Request(IAddOn sender, string request, params object[] args)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
 public static void printToConsole(this IAddOn obj)
 {
     Console.WriteLine(obj.GetResult());
 }
Beispiel #9
0
        object IHost.Request(IAddOn sender, string request, params object[] args)
        {
            //Prepare
            int        value      = 0;
            RawSection section    = 0;
            StringId   stringId   = StringId.Zero;
            TagId      tagId      = TagId.Null;
            Stream     dataStream = null;
            IndexEntry entry      = null;

            //Handle Request
            switch (request)
            {
            case "Map": return(map);

            case "SelectedEntry": return(selectedEntry);

            case "Xbox": return(DebugXbox);

            case "StringBrowserDialog":
                //Prepare
                if (args.Length > 0 && args[0] is StringId)
                {
                    stringId = (StringId)args[0];
                }

                //Initialize Tag Browser Dialog
                using (StringSelectDialog stringDlg = new StringSelectDialog(map.Strings.ToList()))
                {
                    //Set
                    stringDlg.SelectedString = stringId;

                    //Show
                    if (stringDlg.ShowDialog() == DialogResult.OK)
                    {
                        stringId = stringDlg.SelectedString;
                    }
                }

                //Return
                return(stringId);

            case "TagBrowserDialog":
                //Prepare
                if (args.Length > 0 && args[0] is TagId)
                {
                    tagId = (TagId)args[0];
                }

                //Initialize Tag Browser Dialog
                using (TagBrowserDialog tagDlg = new TagBrowserDialog(map.IndexEntries, map.Name))
                {
                    //Set
                    tagDlg.SelectedID = tagId;

                    //Show
                    if (tagDlg.ShowDialog() == DialogResult.OK)
                    {
                        tagId = tagDlg.SelectedID;
                    }
                }

                //Return
                return(tagId);

            case "SelectEntry":
                //Prepare
                if (args.Length > 0 && args[0] is TagId)
                {
                    tagId = (TagId)args[0];
                }

                //Check ID...
                if (!tagId.IsNull && entries.ContainsKey(tagId))
                {
                    //Select
                    var                wrapper = entries[tagId];
                    string[]           parts = $"{wrapper.Filename}.{wrapper.Root}".Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                    TreeNodeCollection collection = tagTreeView.Nodes; TreeNode node = null;
                    for (int i = 0; i < parts.Length; i++)
                    {
                        //Get Node
                        node = collection[parts[i]];

                        //Check
                        if (node != null)
                        {
                            collection = node.Nodes;
                        }
                    }

                    //Check
                    if (node != null)
                    {
                        //Select and goto
                        tagTreeView.SelectedNode = node;
                        node.EnsureVisible();
                    }
                }
                return(selectedEntry);

            case "RawDataStream":
                //Check Parameters
                if (args.Length > 2 && (args[0] is IndexEntry || args[0] is TagId) && args[1] is RawSection && args[2] is int)
                {
                    //Get Parameters
                    if (args[0] is IndexEntry)
                    {
                        entry = (IndexEntry)args[0];
                    }
                    else
                    {
                        entry = map.IndexEntries[(TagId)args[0]];
                    }
                    section = (RawSection)args[1];
                    value   = (int)args[2];

                    //Check
                    if (entry != null)
                    {
                        switch (value & 0xC0000000 >> 29)
                        {
                        case 0: if (entry.Raws[section].ContainsRawOffset(value))
                            {
                                dataStream = (Stream)entry.Raws[section][value].Clone();
                            }
                            break;

                        case 1: break;

                        case 2: break;

                        case 3: break;
                        }
                    }
                }
                return(dataStream);

            default: return(null);
            }
        }
Beispiel #10
0
 private void StopAddOn(IAddOn iAddOn)
 {
     iAddOn.Stop();
 }
Beispiel #11
0
 private void StartAddOn(IAddOn iAddOn)
 {
     iAddOn.Start();
 }
        // -------------------------------------------
        //  IPLUGIN HOST (called by addon)
        // -------------------------------------------

        public void Log(IAddOn addon, string msg)
        {
            SARAH.GetInstance().Log("AddOnManager][" + addon.Name, msg);
        }
    // -------------------------------------------
    //  IPLUGIN HOST (called by addon)
    // -------------------------------------------

    public void Log(IAddOn addon, string msg) {
      SARAH.GetInstance().Log("AddOnManager]["+addon.Name, msg);
    }