コード例 #1
0
ファイル: Integration.cs プロジェクト: daviscook477/ONIMods-1
        public static void OnLoad()
        {
            PUtil.InitLibrary(false);

            Assembly currentAssembly          = Assembly.GetExecutingAssembly();
            string   currentAssemblyDirectory = Path.GetDirectoryName(currentAssembly.Location);

            PliersAssets.PLIERS_PATH_CONFIGFOLDER = Path.Combine(currentAssemblyDirectory, "config");
            PliersAssets.PLIERS_PATH_CONFIGFILE   = Path.Combine(PliersAssets.PLIERS_PATH_CONFIGFOLDER, "config.json");
            PliersAssets.PLIERS_PATH_KEYCODESFILE = Path.Combine(PliersAssets.PLIERS_PATH_CONFIGFOLDER, "keycodes.txt");

            PliersAssets.PLIERS_ICON_SPRITE       = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pliers.image_wirecutter_button.dds"), 32, 32);
            PliersAssets.PLIERS_ICON_SPRITE.name  = PliersAssets.PLIERS_ICON_NAME;
            PliersAssets.PLIERS_VISUALIZER_SPRITE = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pliers.image_wirecutter_visualizer.dds"), 256, 256);

            PliersAssets.PLIERS_OPENTOOL = PAction.Register("Pliers.opentool", "Pliers", new PKeyBinding(KKeyCode.None, Modifier.None));

            ModLocalization.LocalizationCompleteEvent += ModLocalizedHandler;
            ModLocalization.DefaultLocalization        = new string[] {
                PliersStrings.STRING_PLIERS_NAME, "Pliers",
                PliersStrings.STRING_PLIERS_TOOLTIP, "Disconnect utility networks {0}",
                PliersStrings.STRING_PLIERS_TOOLTIP_TITLE, "PLIERS",
                PliersStrings.STRING_PLIERS_ACTION_DRAG, "DRAG",
                PliersStrings.STRING_PLIERS_ACTION_BACK, "BACK"
            };

            Debug.Log("Pliers Loaded: Version " + currentAssembly.GetName().Version);
        }
コード例 #2
0
 /// <summary>
 /// Logs when the mod is loaded.
 /// </summary>
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     BulkChangeAction = PAction.Register(BulkChangeStrings.ACTION_KEY,
                                         BulkChangeStrings.ACTION_TITLE, new PKeyBinding(KKeyCode.Q));
 }
コード例 #3
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     LocString.CreateLocStringKeys(typeof(ToastControlStrings.UI));
     POptions.RegisterOptions(typeof(ToastControlOptions));
     PUtil.RegisterPatchClass(typeof(ToastControlPopups));
     ToastControlPopups.ReloadOptions();
     // No default key bind
     inGameSettings = PAction.Register(ToastControlStrings.ACTION_KEY,
                                       ToastControlStrings.ACTION_TITLE);
 }
コード例 #4
0
        public static void OnLoad(string path)
        {
            var inst = ModDebugRegistry.Instance;

            RunningPLibAssembly = typeof(PUtil).Assembly;
            PUtil.InitLibrary();
            if (DebugNotIncludedOptions.Instance?.DetailedBacktrace ?? true)
            {
                DebugLogger.InstallExceptionLogger();
            }
            POptions.RegisterOptions(typeof(DebugNotIncludedOptions));
            if (DebugNotIncludedOptions.Instance?.LogAsserts ?? true)
            {
                LogAllFailedAsserts();
            }
            // Patch the exception logger for state machines
            var logException = typeof(DebugUtil).GetMethodSafe("LogException", true,
                                                               PPatchTools.AnyArguments);

            if (logException != null)
            {
                inst.DebugInstance.Patch(logException, prefix: new HarmonyMethod(typeof(
                                                                                     DebugLogger), nameof(DebugLogger.LogException)));
            }
            foreach (var mod in Global.Instance.modManager?.mods)
            {
                if (mod.label.install_path == path)
                {
                    ThisMod = mod;
                    break;
                }
            }
            if (ThisMod == null)
            {
                DebugLogger.LogWarning("Unable to determine KMod instance!");
            }
            else
            {
                inst.RegisterModAssembly(Assembly.GetExecutingAssembly(), inst.GetDebugInfo(
                                             ThisMod));
            }
            // Default UI debug key is ALT+U
            UIDebugAction = PAction.Register("DebugNotIncluded.UIDebugAction",
                                             DebugNotIncludedStrings.KEY_SNAPSHOT, new PKeyBinding(KKeyCode.U,
                                                                                                   Modifier.Alt));
            // Must postload the mods dialog to come out after aki's mods, ony's mods, PLib
            // options, and so forth
            PUtil.RegisterPostload(PostloadHandler);
        }
コード例 #5
0
        public static void OnLoad(string path)
        {
            var inst = ModDebugRegistry.Instance;

            RunningPLibAssembly = typeof(PUtil).Assembly;
            PUtil.InitLibrary();
            if (DebugNotIncludedOptions.Instance?.DetailedBacktrace ?? true)
            {
                DebugLogger.InstallExceptionLogger();
            }
            POptions.RegisterOptions(typeof(DebugNotIncludedOptions));
            // Set up strings
            LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.UI));
            LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.INPUT_BINDINGS));
            PLocalization.Register();
            if (DebugNotIncludedOptions.Instance?.LogAsserts ?? true)
            {
                LogAllFailedAsserts();
            }
            foreach (var mod in Global.Instance.modManager?.mods)
            {
                if (mod.GetModBasePath() == path)
                {
                    ThisMod = mod;
                    break;
                }
            }
            if (ThisMod == null)
            {
                DebugLogger.LogWarning("Unable to determine KMod instance!");
            }
            else
            {
                inst.RegisterModAssembly(Assembly.GetExecutingAssembly(), inst.GetDebugInfo(
                                             ThisMod));
            }
            // Default UI debug key is ALT+U
            UIDebugAction = PAction.Register("DebugNotIncluded.UIDebugAction",
                                             DebugNotIncludedStrings.INPUT_BINDINGS.DEBUG.SNAPSHOT, new PKeyBinding(
                                                 KKeyCode.U, Modifier.Alt));
            // Must postload the mods dialog to come out after aki's mods, ony's mods, PLib
            // options, and so forth
            PUtil.RegisterPatchClass(typeof(DebugNotIncludedPatches));
        }
コード例 #6
0
ファイル: Integration.cs プロジェクト: daviscook477/ONIMods-1
        public static void OnLoad()
        {
            PUtil.InitLibrary(false);
            POptions.RegisterOptions(typeof(BlueprintsOptions));

            Assembly currentAssembly          = Assembly.GetExecutingAssembly();
            string   currentAssemblyDirectory = Path.GetDirectoryName(currentAssembly.Location);

            BlueprintsAssets.BLUEPRINTS_CREATE_ICON_SPRITE       = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Blueprints.image_createblueprint_button.dds"), 32, 32);
            BlueprintsAssets.BLUEPRINTS_CREATE_ICON_SPRITE.name  = BlueprintsAssets.BLUEPRINTS_CREATE_ICON_NAME;
            BlueprintsAssets.BLUEPRINTS_CREATE_OPENTOOL          = PAction.Register("Blueprints.create.opentool", "Create Blueprint", new PKeyBinding(KKeyCode.None, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_CREATE_VISUALIZER_SPRITE = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Blueprints.image_createblueprint_visualizer.dds"), 256, 256);

            BlueprintsAssets.BLUEPRINTS_USE_ICON_SPRITE              = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Blueprints.image_useblueprint_button.dds"), 32, 32);
            BlueprintsAssets.BLUEPRINTS_USE_ICON_SPRITE.name         = BlueprintsAssets.BLUEPRINTS_USE_ICON_NAME;
            BlueprintsAssets.BLUEPRINTS_USE_OPENTOOL                 = PAction.Register("Blueprints.use.opentool", "Use Blueprint", new PKeyBinding(KKeyCode.None, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_CREATEFOLDER             = PAction.Register("Blueprints.use.assignfolder", "Assign Folder", new PKeyBinding(KKeyCode.Home, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_RENAME                   = PAction.Register("Blueprints.use.rename", "Rename Blueprint", new PKeyBinding(KKeyCode.End, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_CYCLEFOLDERS_NEXT        = PAction.Register("Blueprints.use.cyclefolders.next", "Next Folder", new PKeyBinding(KKeyCode.UpArrow, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_CYCLEFOLDERS_PREVIOUS    = PAction.Register("Blueprints.use.cyclefolders.previous", "Previous Folder", new PKeyBinding(KKeyCode.DownArrow, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_CYCLEBLUEPRINTS_NEXT     = PAction.Register("Blueprints.use.cycleblueprints.next", "Next Blueprint", new PKeyBinding(KKeyCode.RightArrow, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_CYCLEBLUEPRINTS_PREVIOUS = PAction.Register("Blueprints.use.cycleblueprints.previous", "Previous Blueprint", new PKeyBinding(KKeyCode.LeftArrow, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_USE_VISUALIZER_SPRITE        = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Blueprints.image_useblueprint_visualizer.dds"), 256, 256);

            BlueprintsAssets.BLUEPRINTS_SNAPSHOT_ICON_SPRITE       = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Blueprints.image_snapshot_button.dds"), 32, 32);
            BlueprintsAssets.BLUEPRINTS_SNAPSHOT_ICON_SPRITE.name  = BlueprintsAssets.BLUEPRINTS_SNAPSHOT_ICON_NAME;
            BlueprintsAssets.BLUEPRINTS_SNAPSHOT_OPENTOOL          = PAction.Register("Blueprints.snapshot.opentool", "Take Snapshot", new PKeyBinding(KKeyCode.None, Modifier.None));
            BlueprintsAssets.BLUEPRINTS_SNAPSHOT_VISUALIZER_SPRITE = Utilities.CreateSpriteDXT5(Assembly.GetExecutingAssembly().GetManifestResourceStream("Blueprints.image_snapshot_visualizer.dds"), 256, 256);

            BlueprintsAssets.BLUEPRINTS_MULTI_DELETE = PAction.Register("Blueprints.multi.delete", "Delete Blueprint/Snapshot", new PKeyBinding(KKeyCode.Delete, Modifier.None));

            ModLocalization.LocalizationCompleteEvent += ModLocalizedHandler;
            ModLocalization.DefaultLocalization        = new string[] {
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_NAME, "New Blueprint",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_TOOLTIP, "Create blueprint {0}",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_EMPTY, "Blueprint would have been empty!",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_CREATED, "Created blueprint!",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_CANCELLED, "Cancelled blueprint!",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_TOOLTIP_TITLE, "CREATE BLUEPRINT TOOL",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_ACTION_DRAG, "DRAG",
                BlueprintsStrings.STRING_BLUEPRINTS_CREATE_ACTION_BACK, "BACK",

                BlueprintsStrings.STRING_BLUEPRINTS_USE_NAME, "Use Blueprint",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_TOOLTIP, "Use blueprint {0}",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_LOADEDBLUEPRINTS, "Loaded {0} blueprints! ({1} total)",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_LOADEDBLUEPRINTS_ADDITIONAL, "additional",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_LOADEDBLUEPRINTS_FEWER, "fewer",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_TOOLTIP_TITLE, "USE BLUEPRINT TOOL",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_ACTION_CLICK, "CLICK",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_ACTION_BACK, "BACK",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_CYCLEFOLDERS, "Use {0} and {1} to cycle folders.",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_CYCLEBLUEPRINTS, "Use {0} and {1} to cycle blueprints.",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_FOLDERBLUEPRINT, "Press {0} to assign folder.",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_FOLDERBLUEPRINT_NA, "Same folder provided - no change made.",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_MOVEDBLUEPRINT, "Moved \"{0}\" to \"{1}\"",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_NAMEBLUEPRINT, "Press {0} to rename blueprint.",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_DELETEBLUEPRINT, "Press {0} to delete blueprint.",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_ERRORMESSAGE, "This blueprint contained {0} misconfigured or missing prefabs which have been omitted!",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_SELECTEDBLUEPRINT, "Selected \"{0}\" ({1}/{2}) from \"{3}\" ({4}/{5})",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_FOLDEREMPTY, "Selected folder \"{0}\" is empty!",
                BlueprintsStrings.STRING_BLUEPRINTS_USE_NOBLUEPRINTS, "No blueprints loaded!",

                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_NAME, "Take Snapshot",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_TOOLTIP, "Take snapshot {0} \n\nCreate a blueprint and quickly place it elsewhere while not cluttering your blueprint collection! \nSnapshots do not persist between games or worlds.",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_EMPTY, "Snapshot would have been empty!",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_TAKEN, "Snapshot taken!",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_TOOLTIP_TITLE, "SNAPSHOT TOOL",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_ACTION_CLICK, "CLICK",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_ACTION_DRAG, "DRAG",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_ACTION_BACK, "BACK",
                BlueprintsStrings.STRING_BLUEPRINTS_SNAPSHOT_NEWSNAPSHOT, "Press {0} to take new snapshot.",

                BlueprintsStrings.STRING_BLUEPRINTS_NAMEBLUEPRINT_TITLE, "NAME BLUEPRINT",
                BlueprintsStrings.STRING_BLUEPRINTS_FOLDERBLUEPRINT_TITLE, "ASSIGN FOLDER"
            };

            Debug.Log("Blueprints Loaded: Version " + currentAssembly.GetName().Version);
        }
コード例 #7
0
 /// <summary>
 /// Logs when the mod is loaded.
 /// </summary>
 public static void OnLoad()
 {
     PUtil.LogModInit();
     BulkChangeAction = PAction.Register(BulkChangeStrings.ACTION_KEY,
                                         BulkChangeStrings.ACTION_TITLE, new PKeyBinding(KKeyCode.Q));
 }
コード例 #8
0
 internal static void PrepareSpamHandler()
 {
     PUtil.RegisterPatchClass(typeof(SpamObjectsHandler));
     SpamObjectsAction = PAction.Register("NotEnoughTags.SpamObjectsAction",
                                          "Spam objects under cursor", new PKeyBinding(KKeyCode.Y, Modifier.Ctrl));
 }