Last change
on this file since 490 was 463, checked in by alloc, 15 months ago |
21.1.16.0 release
Completed OpenAPI specs
Add support to path handlers to register OpenAPI specs
Fixed ItemIconHandler throwing error when requested path contains no dot
|
File size:
1.1 KB
|
Rev | Line | |
---|
[391] | 1 | using JetBrains.Annotations;
|
---|
[402] | 2 | using Webserver;
|
---|
| 3 | using Webserver.UrlHandlers;
|
---|
[224] | 4 |
|
---|
[391] | 5 | namespace MapRendering {
|
---|
| 6 | [UsedImplicitly]
|
---|
| 7 | public class ModApi : IModApi {
|
---|
[463] | 8 | private const string mapTilesBaseUrl = "/map/";
|
---|
| 9 |
|
---|
[369] | 10 | public void InitMod (Mod _modInstance) {
|
---|
[423] | 11 | ModEvents.GameStartDone.RegisterHandler (GameStartDone);
|
---|
| 12 |
|
---|
[402] | 13 | Web.ServerInitialized += _web => {
|
---|
[425] | 14 | if (!MapRenderer.Enabled) {
|
---|
[423] | 15 | return;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
[463] | 18 | _web.RegisterPathHandler (mapTilesBaseUrl, new StaticHandler (
|
---|
[402] | 19 | $"{GameIO.GetSaveGameDir ()}/map",
|
---|
| 20 | MapRenderer.GetTileCache (),
|
---|
| 21 | false,
|
---|
| 22 | "web.map")
|
---|
| 23 | );
|
---|
[463] | 24 |
|
---|
| 25 | _web.OpenApiHelpers.RegisterCustomSpec (GetType ().Assembly, "MapTileHandler", mapTilesBaseUrl);
|
---|
[402] | 26 | };
|
---|
[325] | 27 | }
|
---|
| 28 |
|
---|
[423] | 29 | private void GameStartDone () {
|
---|
[425] | 30 | if (!MapRenderer.Enabled) {
|
---|
[423] | 31 | return;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | ModEvents.GameShutdown.RegisterHandler (GameShutdown);
|
---|
| 35 | ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone);
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[324] | 38 | private void GameShutdown () {
|
---|
[391] | 39 | MapRenderer.Shutdown ();
|
---|
[299] | 40 | }
|
---|
| 41 |
|
---|
[324] | 42 | private void CalcChunkColorsDone (Chunk _chunk) {
|
---|
[391] | 43 | MapRenderer.RenderSingleChunk (_chunk);
|
---|
[224] | 44 | }
|
---|
| 45 | }
|
---|
[423] | 46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.