Browse Source

Added a bit of demo code for start-dev

4.0.0-beta
Anairkoen Schno 4 years ago
parent
commit
c50cd3aaab
8 changed files with 186 additions and 2 deletions
  1. +3
    -0
      docs/.markdownlint.json
  2. +16
    -0
      docs/articles/dev-resources/Demo.csproj
  3. +61
    -0
      docs/articles/dev-resources/Plugin.cs
  4. +55
    -0
      docs/articles/dev-resources/PluginConfig.cs
  5. +7
    -0
      docs/articles/dev-resources/description.md
  6. +23
    -0
      docs/articles/dev-resources/manifest.json
  7. +19
    -1
      docs/articles/start-dev.md
  8. +2
    -1
      docs/docfx.json

+ 3
- 0
docs/.markdownlint.json View File

@ -6,5 +6,8 @@
}, },
"single-h1": { "single-h1": {
"front_matter_title": "" "front_matter_title": ""
},
"no-trailing-punctuation": {
"punctuation": ",;:!?。,;:!?"
} }
} }

+ 16
- 0
docs/articles/dev-resources/Demo.csproj View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\..\IPA.Loader\IPA.Loader.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<RootNamespace>Demo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="manifest.json" />
<EmbeddedResource Include="description.md" />
</ItemGroup>
</Project>

+ 61
- 0
docs/articles/dev-resources/Plugin.cs View File

@ -0,0 +1,61 @@
using System;
using IPA;
using IPA.Logging;
using IPA.Config;
using IPA.Config.Stores;
namespace Demo
{
/*
[Plugin(RuntimeOptions.DynamicInit)]
*/
[Plugin(RuntimeOptions.SingleStartInit)]
internal class Plugin
{
public static Logger log { get; private set; }
[Init]
public Plugin(Logger logger, Config conf)
{
log = logger;
PluginConfig.Instance = conf.Generated<PluginConfig>();
log.Debug("Config loaded");
// setup that does not require game code
// this is only called once ever, so do once-ever initialization
}
/*
[Init]
public Plugin(Logger logger)
{
log = logger;
log.Debug("Basic plugin running!");
// setup that does not require game code
// this is only called once ever, so do once-ever initialization
}
*/
/*
[OnEnable]
public void OnEnable()
*/
[OnStart]
public void OnStart()
{
// setup that requires game code
}
/*
[OnDisable]
public void OnDisable()
*/
[OnExit]
public void OnExit()
{
// teardown
// this may be called mid-game if you are using RuntimeOptions.DynamicInit
}
}
}

+ 55
- 0
docs/articles/dev-resources/PluginConfig.cs View File

@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using IPA.Config.Stores;
using IPA.Config.Stores.Attributes;
using IPA.Config.Stores.Converters;
[assembly: InternalsVisibleTo(GeneratedExtension.AssemblyVisibilityTarget)]
namespace Demo
{
/*
public class PluginConfig
*/
internal class PluginConfig
{
public static PluginConfig Instance { get; set; }
/*
public int IntValue { get; set; } = 42;
public float FloatValue { get; set; } = 3.14159f;
[UseConverter(typeof(ListConverter<string>))]
public List<string> ListValue { get; set; } = new List<string>();
[UseConverter(typeof(CollectionConverter<string, HashSet<string>>))]
public HashSet<string> SetValue { get; set; } = new HashSet<string>();
*/
public virtual int IntValue { get; set; } = 42;
public virtual float FloatValue { get; set; } = 3.14159f;
[UseConverter(typeof(ListConverter<string>))]
public virtual List<string> ListValue { get; set; } = new List<string>();
[UseConverter(typeof(CollectionConverter<string, HashSet<string>>))]
public virtual HashSet<string> SetValue { get; set; } = new HashSet<string>();
public virtual void Changed()
{
// this is called whenever one of the virtual properties is changed
// can be called to signal that the content has been changed
}
public virtual void OnReload()
{
// this is called whenever the config file is reloaded from disk
// use it to tell all of your systems that something has changed
// this is called off of the main thread, and is not safe to interact
// with Unity in
}
}
}

+ 7
- 0
docs/articles/dev-resources/description.md View File

@ -0,0 +1,7 @@
# Demo Plugin
A little demo for the BSIPA modding introduction.
---
WE CAN USE MARKDOWN!!!

+ 23
- 0
docs/articles/dev-resources/manifest.json View File

@ -0,0 +1,23 @@
{
"$schema": "https://raw.githubusercontent.com/beat-saber-modding-group/BSIPA-MetadataFileSchema/master/Schema.json",
"author": "ExampleMan",
"description": [
"#![Demo.description.md]",
"A demo plugin written for the BSIPA basic tutorial."
],
"gameVersion": "1.6.0",
"id": null,
"name": "Demo Plugin",
"version": "0.0.1",
"features": [
],
"links": {
"project-home": "https://example.com/demo-plugin",
"project-source": "https://github.com/exampleman/demo-plugin/",
"donate": "https://ko-fi.com/exampleman"
},
"misc": {
"plugin-hint": "Demo.Plugin"
}
}

+ 19
- 1
docs/articles/start-dev.md View File

@ -3,5 +3,23 @@ uid: articles.start.dev
title: Making your own mod title: Making your own mod
--- ---
# Overview
# Making a mod
## Overview
What follows is a *very* barebones, and frankly not very useful plugin class, even as a starting point,
but it should be enough to give a decent idea of how to do quick upgrades of existing mods for those who want to.
[!code-cs[Plugin.cs](./dev-resources/Plugin.cs?range=1-3,6-8,12-16,29-37,39,44-45,46-49,54-57,59-)]
There are basically 4 major concepts here:
1. <xref:IPA.Logging.Logger>, the logging system.
2. <xref:IPA.PluginAttribute>, which declares that this class is a plugin and how it should behave.
3. <xref:IPA.InitAttribute>, which declares the constructor (and optionally other methods) as being
used for initialization.
4. The lifecycle event attributes <xref:IPA.OnStartAttribute> and <xref:IPA.OnExitAttribute>.
Read the docs at those links for a better idea of what they do.
TODO: expand this to explain more, and expand on the base example

+ 2
- 1
docs/docfx.json View File

@ -12,7 +12,8 @@
"TMP Exporter/**.csproj", "TMP Exporter/**.csproj",
"BuildTools/**.csproj", "BuildTools/**.csproj",
"Doorstop/**.csproj", "Doorstop/**.csproj",
"Net3-Proxy/**.csproj"
"Net3-Proxy/**.csproj",
"docs/**.csproj"
] ]
}], }],
"dest": "api", "dest": "api",


Loading…
Cancel
Save