CreateView
Overview
Section titled “Overview”Creates a PrismaView instance by loading an HTML file. This is the primary method for initializing UI components in your SKSE plugin.
Syntax
Section titled “Syntax”PrismaView CreateView( const char* htmlPath, OnDomReadyCallback onDomReadyCallback = nullptr);Parameters
Section titled “Parameters”htmlPath (required)
Section titled “htmlPath (required)”- Type:
const char* - Description: The path to the HTML file that will be loaded into the
PrismaView(or you can pass a website URL which should starts withhttp://orhttps://) - Base Directory:
Skyrim/Data/PrismaUI/views/
onDomReadyCallback (optional)
Section titled “onDomReadyCallback (optional)”- Type:
OnDomReadyCallback - Default:
nullptr - Description: An optional callback function that will be invoked when the DOM of this
PrismaViewis fully loaded - Parameters: Takes a single argument - the
PrismaViewinstance
Return Value
Section titled “Return Value”Returns a PrismaView instance representing the created UI component.
Usage Examples
Section titled “Usage Examples”// Simple view creation without callbackPrismaView view = PrismaUI->CreateView("MyPlugin/index.html");static PrismaView view;
// View creation with DOM ready callbackview = PrismaUI->CreateView("MyPlugin/index.html", [](PrismaView view) -> void { // The callback is executed after the DOM tree is fully initialized SKSE::log::info("View DOM is ready {}", view);
// You can now safely invoke JavaScript methods PrismaUI->Invoke(view, "initializeUI()");});#include "PrismaUI_API.h"
PRISMA_UI_API::IVPrismaUI1* PrismaUI;static PrismaView view;
static void SKSEMessageHandler(SKSE::MessagingInterface::Message* message){ switch (message->type) { case SKSE::MessagingInterface::kDataLoaded: // Initialize PrismaUI API PrismaUI = static_cast<PRISMA_UI_API::IVPrismaUI1*>( PRISMA_UI_API::RequestPluginAPI(PRISMA_UI_API::InterfaceVersion::V1) );
// Create view with comprehensive setup view = PrismaUI->CreateView("MyPlugin/index.html", [](PrismaView view) -> void { SKSE::log::info("View DOM is ready {}", view);
// Initialize UI state PrismaUI->Invoke(view, "setPlayerName('" + GetPlayerName() + "')"); PrismaUI->Invoke(view, "updateHealthBar(" + std::to_string(GetPlayerHealth()).c_str() + ")"); });
// Register JavaScript event listeners PrismaUI->RegisterJSListener(view, "onButtonClick", [](const char* data) -> void { SKSE::log::info("Button clicked with data: {}", data); });
break; }}File Structure
Section titled “File Structure”Your HTML file should be placed in the following directory structure:
Skyrim/└── Data/ └── PrismaUI/ └── views/ └── MyPlugin/ ├── index.html ├── styles.css └── script.jsBest Practices
Section titled “Best Practices”- Single Instance: Always create only one
PrismaViewper plugin - DOM Ready: Use the callback to initialize your UI state safely
- View Management: Store the returned
PrismaViewinstance for later use with other API methods