Integration Guide for Unsupported Map Mods
If you're using a map mod that isn't natively supported by NinjinsPvPPvE, you can integrate it yourself to enable zone drawing and callbacks.
Step 1: Find the Map Menu Class
Identify the class name of your map mod's menu. Common patterns:
*MapMenu*MapForm*MapUI
Step 2: Create Integration File
Create a new file in your mod (or modify the map mod if you have access):
// Example: MyCustomMap.c
modded class MyCustomMapMenu // Replace with your map menu class name
{
private ref MapDrawer m_MapDrawer;
private CanvasWidget m_DrawCanvas;
private MapWidget m_MapWidget;
private float m_LastZoneRequestTime = 0;
private const float ZONE_REQUEST_COOLDOWN = 10.0;
override Widget Init() // Or OnInit(), or whatever initialization method exists
{
super.Init(); // Call parent initialization
// Find the MapWidget - adjust widget name as needed
m_MapWidget = MapWidget.Cast(layoutRoot.FindAnyWidget("Map"));
// Alternative widget names to try:
// - "Map_Widget"
// - "map_widget"
// - "MapWidget"
if (!m_MapWidget)
{
NinjinsPvPPvE.LogWarning("[MyCustomMap] ERROR: MapWidget not found.");
return layoutRoot;
}
// Clean up any existing canvas
CanvasWidget oldCanvas = CanvasWidget.Cast(m_MapWidget.FindAnyWidget("ninjindrawCanvas"));
if (oldCanvas)
{
oldCanvas.Unlink();
oldCanvas = null;
}
// Reset any existing MapDrawer instance
MapDrawer.ResetInstance(m_MapWidget);
// Create the drawing canvas
Widget canvasLayout = GetGame().GetWorkspace().CreateWidgets(
"NinjinsPvPPvE/gui/layouts/NinjinsMapCanvasOnly.layout",
m_MapWidget
);
if (!canvasLayout)
{
NinjinsPvPPvE.LogWarning("[MyCustomMap] ERROR: Failed to load canvas layout.");
return layoutRoot;
}
// Get the canvas widget
m_DrawCanvas = CanvasWidget.Cast(canvasLayout.FindAnyWidget("ninjindrawCanvas"));
if (!m_DrawCanvas)
{
NinjinsPvPPvE.LogWarning("[MyCustomMap] ERROR: drawCanvas not found in layout.");
return layoutRoot;
}
// Initialize MapDrawer
m_MapDrawer = MapDrawer.GetInstance(m_MapWidget, m_DrawCanvas);
if (!m_MapDrawer)
{
NinjinsPvPPvE.LogWarning("[MyCustomMap] ERROR: Failed to initialize MapDrawer.");
}
return layoutRoot;
}
override void OnShow() // Or whatever method is called when map opens
{
super.OnShow();
// Request zones from server (with cooldown)
float currentTime = GetGame().GetTickTime();
float timeSinceLastRequest = currentTime - m_LastZoneRequestTime;
if (timeSinceLastRequest > ZONE_REQUEST_COOLDOWN)
{
GetRPCManager().SendRPC("NinjinsPvPPvE", "RequestZones", NULL, true, null);
m_LastZoneRequestTime = currentTime;
}
// Update zones on map
if (!m_MapDrawer)
return;
MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
if (!mission)
return;
array zones = mission.GetCachedZones();
if (zones && zones.Count() > 0)
{
bool drawLabels = g_MainConfig && g_MainConfig.DrawNamesOnZones;
m_MapDrawer.UpdateZones(zones, drawLabels);
}
}
override void Update(float timeslice) // Or OnUpdate(), etc.
{
super.Update(timeslice);
// Trigger map updates
if (m_MapDrawer && m_MapDrawer.HasValidWidget())
{
m_MapDrawer.TriggerUpdate();
}
}
override void OnHide() // Or OnClose(), etc.
{
super.OnHide();
// Clean up
MapDrawer.ResetInstance(m_MapWidget);
m_MapDrawer = null;
m_DrawCanvas = null;
}
}
Step 3: Key Points
- Widget Name: The MapWidget name may vary. Common names:
"Map""Map_Widget""map_widget""MapWidget"
- Method Names: The method names may differ:
Init()vsOnInit()OnShow()vsShow()Update()vsOnUpdate()OnHide()vsOnClose()vsClose()
- Layout Path: The canvas layout path is always:
"NinjinsPvPPvE/gui/layouts/NinjinsMapCanvasOnly.layout" - RPC Call: To request zones from server:
GetRPCManager().SendRPC("NinjinsPvPPvE", "RequestZones", NULL, true, null);
Step 4: Testing
- Open your map mod
- Check the RPT log for any errors
- Zones should appear on the map
- Your drawing callbacks should fire
Troubleshooting
Problem: MapWidget not found
- Solution: Check the widget hierarchy in your map mod's layout file
- Use
FindAnyWidget()with different widget names - Check if the widget is created dynamically
Problem: Canvas not drawing
- Solution: Ensure the canvas layout is loaded correctly
- Check that
m_DrawCanvasis not null - Verify
UpdateZones()is being called
Problem: Zones not appearing
- Solution: Ensure
RequestZonesRPC is being sent - Check that
mission.GetCachedZones()returns zones - Verify
UpdateZones()is called after zones are received