{"id":16203226,"url":"https://github.com/pardeike/magictutor","last_synced_at":"2025-04-07T19:18:14.510Z","repository":{"id":46199324,"uuid":"425612178","full_name":"pardeike/MagicTutor","owner":"pardeike","description":"A framework for RimWorld mods that show hints for new features in a mod","archived":false,"fork":false,"pushed_at":"2023-07-17T10:14:32.000Z","size":1710,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T20:43:32.711Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pardeike.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-07T20:46:48.000Z","updated_at":"2023-08-14T10:04:51.000Z","dependencies_parsed_at":"2024-11-05T23:15:59.353Z","dependency_job_id":null,"html_url":"https://github.com/pardeike/MagicTutor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardeike%2FMagicTutor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardeike%2FMagicTutor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardeike%2FMagicTutor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardeike%2FMagicTutor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pardeike","download_url":"https://codeload.github.com/pardeike/MagicTutor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713258,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T09:53:07.576Z","updated_at":"2025-04-07T19:18:14.484Z","avatar_url":"https://github.com/pardeike.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MagicTutor\nA framework for RimWorld mods that show hints for new features in a mod\n\nMake your mods features discoverable with this framework! A lot of mod users have \nnever seen your workshop page or have read your documentation. They install a modlist \nand suddenly have access to a new feature that they don't understand:\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"Originals/standardhint-example.png\" alt=\"StandardHint in Achtung\" /\u003e\n   \u003cbr/\u003e\u003cb\u003eExample: Standard hint in the mod Achtung\u003c/b\u003e\n\u003c/p\u003e\n\nTo solve this, this framework makes it easy for you to present hints to the user \nwhenever some observable effect is produced by your code. All you have to do is to\nfollow the steps below.\n\n## Installation\n\nAdd the nuget package [MagicTutor](https://www.nuget.org/packages/MagicTutor/) to your project or download the latest release from this repository.\n\n## Basic usage\n\n#### Create a context for a feature\n1) Define a context name that groups all occurances of a feature. For example \n   `\"turbo-button\"` for your new widget button or `\"ultra weapon\"` for your new weapon.\n\n2) Register this context at the start of your mod inside the class that extends `Mod`:\n   ```cs\n   using BrrainzTools;\n   \n   public class MyMod : Mod\n   {\n      public static MagicTutor tutor;\n      \n      public MyMod(ModContentPack content) : base(content)\n      {\n         // ...\n\n         tutor = new MagicTutor(this);\n         tutor.RegisterContext(\"turbo-button\", new StandardHint() { message = \"...hint text here...\" });\n         tutor.RegisterContext(\"ultra weapon\", new StandardHint() { message = \"...hint text here...\" });\n         // more registrations\n         tutor.Start();\n      }\n   ```\n\n3) Once you defined the contexts, you can wrap your existing code with a tutor call. \n   So if you render something, you can simply surround that code with\n   ```cs\n   // someRect is the area on screen you want the hint displayed for\n   MyMod.tutor.DoHintableAction(\"turbo-button\", someRect, (hintUsed) =\u003e\n   {\n      // original code\n      \n      // optionally mark hint used so it disappears\n      if (selected)\n         hintUsed();\n   });\n   ```\n\nJust by registering a context and wrapping some of your code with that context, you get \nall the features of MagicTutor for free:\n- only one hint is ever presented to the user regardless of how many times your or some \n  other mod calls `DoHintableAction`\n- hints are displayed close to the area they are explaining\n- hints are positioned so they are not clipped by the screen bounds\n- dismissed hints will never be shown again even if you reinstall all mods\n\n## Advanced uses\n\nFor even more control you can create your own hints by either customizing the `StandardHint`\nclass or even create your own hint by implementing the abstract class `Hint`.\n\nOverride StandardHint:\n\n```cs\n// if you don't want the hint to cover content left of your area of interest\n// override ShouldAvoidScreenPosition and return false for the positions that\n// you don't like\n\npublic class NotFromRightHint : StandardHint\n{\n   public override bool ShouldAvoidScreenPosition(ScreenPosition position)\n   {\n      // if SmartTutor thinks the area of interest is on the right side of\n      // the screen (thus displaying the hint left of the area of interest)\n      // make it skip it\n      return position == ScreenPosition.right;\n   }\n}\n```\n\nCreate your own hint by implementing the `Hint` class of MagicTutor:\n\n```cs\n// for an example of an implementation, check out how MagicTutor implements\n// StandardHint: https://github.com/pardeike/MagicTutor/blob/master/StandardHint.cs\npublic abstract class Hint\n{\n   public bool acknowledged;\n\n   public abstract Vector2 WindowSize(Rect areaOfInterest);\n   public abstract Vector2 WindowOffset(Rect areaOfInterest);\n   public abstract void DoWindowContents(Rect canvas);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardeike%2Fmagictutor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpardeike%2Fmagictutor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardeike%2Fmagictutor/lists"}