MapPreviewGenerator
Generates real map preview thumbnails for Bopl Battle — vanilla maps and BoplMapMaker custom maps — cached as PNG. Exposes a public API for other mods (used by NextMapVote).
模組介紹 作者原文
PMod Map Preview Generator
Generates real map preview thumbnails for Bopl Battle and exposes them to other mods through a small public API.
What it does
- Captures real in-game screenshots of every vanilla map (once per map, cached as PNG in BepInEx/plugins/PmodMapPreview)
- For BoplMapMaker custom maps: loads the map's biome scene, places the map on it and screenshots it — real thumbnails, not placeholders
- Installs the previews into the game's map selection UI automatically
- Re-generates a preview when a map is edited in the Map Maker
- Shows a progress panel at the top of the screen while previews are being generated
Matchmaking
This is a client-side mod: it only renders/creates preview thumbnails and never alters gameplay state. At load it increments the game's client-side-mod counter (CharacterSelectHandler_online.clientSideMods_..., via reflection), so matchmaking stays enabled — you can queue and play normally.
Reference the library
Two options:
Option A — compile-time reference (recommended)
Reference PMod.MapPreviewGenerator.dll from your project and add the dependency to your manifest.json:
"dependencies": ["BepInEx-BepInExPack_BoplBattle-5.4.2100", "PMod-MapPreviewGenerator-1.0.0"]
using PMod.MapPreviewGenerator;
Option B — runtime reflection (no compile-time dependency)
Resolve the type by name and call members via reflection. The type never causes a hard dependency, so your mod still works (without previews) if this one isn't installed.
static Type PreviewLib =
AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType("PMod.MapPreviewGenerator.PreviewLibrary", false)).FirstOrDefault(t => t!= null);
The vote mod NextMapVote ships a working example of this pattern (PreviewLibAdapter.cs).
API reference
All members are public static on the class PMod.MapPreviewGenerator.PreviewLibrary.
Lifecycle overview
The generator is fully automatic: when you enter a menu scene (buildIndex | Fired whenever a real preview becomes available — vanilla mapId in vanilla mode, custom customIndex in MapMaker mode. Subscribe to refresh your UI. |
Vanilla maps
| Member | Type | Description |
|---|---|---|
| VanillaMapCount | int | Number of vanilla maps in the build. |
| HasRealPreview(mapId) | bool | True when a real (captured or cached) preview exists for the map. |
| EnsurePrepared(mapId) | void | Makes sure a preview exists for the map. Async: loads the PNG cache, otherwise queues a background capture and shows a procedural placeholder until it lands. Safe to call every frame. |
| TryGetSprite(mapId, out Sprite sprite) | bool | Fetches the current preview sprite, if any. Returns false (with sprite == null) when there is none yet. |
| InstallTexturePreview(mapId, tex) | void | Replaces the preview of a map with your own Texture2D. The generator tracks it for cleanup. |
| EnsureRealPreviewSync(mapId) | void | Synchronous variant of EnsurePrepared for vote-result time: guarantees the real cached screenshot even if its async load has not finished. Blocks briefly (one small PNG read). |
| StartPreloadAll() | void | Re-arms the menu preload and queues anything missing. Normally called automatically when a menu is entered. |
| QueueAllMissing() | void | Queues every map that still lacks a real preview. |
BoplMapMaker custom maps
| Member | Type | Description |
|---|---|---|
| CustomMapsAvailable | bool | True when the BoplMapMaker mod is present with loaded maps. |
| CustomMapCount | int | Number of custom maps available. |
| CustomMapName(customIndex) | string | Display name of a custom map (from its MetaData.json). |
| CustomMapType(customIndex) | string | Biome of a custom map: "grass", "snow" or "space". |
| CustomMapBaseLevelId(customIndex) | int | Vanilla base level id a custom map plays on (derived from its biome). |
| CustomMapJson(customIndex) | string | Raw.boplmap JSON of a custom map. |
| EnsureCustomPrepared(customIndex) | void | Same async semantics as EnsurePrepared, for custom maps. |
| Try
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: