Extending DVN

Project DVN

The following document describes some common ways to extend DVN.

Contents


Custom scenes

Creating custom scene types in DVN works the same way as extending any node in the scene graph.

If you haven't read the section on extending nodes, start here: Scripting Language -> Scene Graph or Scene System

Once you understand that system, a scene is just a specialized node that manages narrative flow and rendering order.

You can:

  • override update logic
  • register custom input patterns
  • attach custom render pipelines
  • add game-logic state
  • or bypass scripting entirely and handle behavior through code

Custom render pipelines

In DVN it is possible to capture the entire low-level rendering pipeline through events.

void preFrameLoop(Window[] windows) {}
void preRenderFrameLoop(Window[] windows) {}
void postRenderFrameLoop(Window[] windows) {}
void postFrameLoop(Window[] windows) {}
void preRenderContent(Window window) {}
void postRenderContent(Window window) {}

This allows you to

  • Render 3D objects into custom views.
  • Optimize rendering.
  • Add custom rendering functionality like shaders.
  • And much more...

It is also possible to capture the high-level rendering pipleline through events.

void loadingViews(Window window);
void onViewChange(View oldView, View newView, string oldViewName, string newViewName);

// Act View
void beginActView(string actName, string continueText, string background, string sceneName);

void renderActBackgroundImage(Image image);
void renderActTitleLabel(Label label);
void renderActBeginLabel(Label label);

void endActView();

// Game View
void renderGameViewOverplayBegin(Panel overlay);
void renderGameViewBackground(Image background);
void renderGameViewCharacter(SceneCharacter character, Image image);
void renderGameViewImage(SceneImage image, Image imageComponent);
void renderGameViewVideo(SceneVideo video, Video videoComponent);
void renderGameViewAnimation(SceneAnimation animation, Animation animationComponent);
void renderGameViewLabel(SceneLabel label, Label labelComponent);
void renderGameViewDialoguePanelImage(RawImage image);
void renderGameViewDialoguePanel(Panel panel);
void renderGameViewCharacterName(SceneCharacterName characterName, Label label, Panel panel, RawImage namePanelImage);
void renderGameViewOption(Label option);
void renderGameViewOption(Button option);
void renderGameViewOptionsStart();
void renderGameViewOptionsFinished();
void renderGameViewSaveButton(Button button);
void renderGameViewExitButton(Button button);
void renderGameViewSettingsButton(Button button);
void renderGameViewAutoButton(Button button);
void renderGameViewQuickSaveButton(Button button);
void renderGameViewOverplayEnd(Panel overlay);
void renderGameViewTextStart(SceneEntry scene);
void renderGameViewTextFinished(Label textLabel);

void endGameView();

// Settings View
void renderSettingsViewStart();
void renderSettingsDropDown(DropDown dropdown);
void renderSettingsCheckBox(CheckBox checkbox);
void renderSettingsButton(Button button);
void renderSettingsViewEnd();

// Main Menu View
void renderMainMenuView(Window window, Component titleLabel, Component playLabel, Component loadLabel, Component historyLabel, Component settingsLabel, Component galleryLabel, Component exitLabel);

// Video Loading View
void renderVideoLoadingView(Video video);

// Load Game View
void renderLoadGameViewPrevLabel(Label label);
void renderLoadGameViewNextLabel(Label label);
void renderLoadGameViewLoadEntry(SaveFile saveFile, RawImage image, Label saveLabel);

This allows you to

  • Control how each scene object is rendered.
  • Control how the UI behaves in every possible view.
  • Adding custom scene objects.
  • Or anything else your imagination can imagine.

Custom views

DVN allows custom views that can also be triggered from your scripts.

Custom views let you temporarily escape the standard VN flow. If you need a screen that behaves differently - that's a view.

You can for example do the following:

  • Custom Application Views such as your own launcher, main menu, settings, debug overlays, replace the entire scene view.
  • Minigames such as rhythm game segments, puzzle screens, card/inventory management, battle UI for RPG-style gameplay.
  • Exploration & Navigation Views such as top-down map movement, side-scroll navigation, town map overview over places you've been in your story.
  • Experimental / Interactive Views such as physics-driven interactions, drawing canvas, camera simulation, OCR or typing-based interaction screens.
  • UI-Focused Views such as smartphone or messaging UI replicas (text, fake calls, social feed mechanic.), Browser-style view with scrolling, link navigation and embedded media or an intventory grid + tooltips + item interactions (hover, inspect etc.)
  • Networking / Online Views such as lobby or matchmakiing screen for multiplayer narrative formats, chat-based roleplay or asynchronous storytelling panel, Live data feeds for ARG-style systems (weather, server events, time gates etc.)

To create a custom view just inherit the View class.

public final class CustomView : View
{
    public:
    final:
    this(Window window)
    {
        super(window);
    }

    protected override void onInitialize(bool useCache)
    {
        EXT_DisableKeyboardState();

        auto window = super.window;

        // Add components to the view here
    }
}

Then in the loadingViews event handler simply register the view.

public override void loadingViews(Window window)
{
    window.addView!CustomView("CustomView");
}

To enter a custom view from your scripts just call the view command like below.

view=CustomView

Useful global functions for custom views:

void displayView(string name);
void displayLastSceneView();
void displayScene(string scene);

These allow you to go back to the last scene, a specific scene or another view (custom or not.)

Using DVN as a framework

DVN doesn't require you to adopt into its released application flow. You can use DVN as a framework module in almost any D application. DVN offers a lot of modules that are "standalone" such as:

  • A json parser.
  • A dom parser.
  • A networking layer for sockets and packet handling.
  • A UI system.
  • Localization & Unicode tools.
  • And much more.

To use DVN as a framework just import DVN or any of the given modules.

Example:

import dvn;

Or

import dvn.json;

Extensions

Extensions allow you to add new behavior, effects, systems, or custom runtime logic to DVN without changing the engine source. They are compiled into your game and enabled through a simple configuration file.

Importing Extensions

Step 1 - Place the extension module

Put the extension .d file (or multiple files) here:

source/extensions/

Example:

source/extensions/hello_world.d

Step 2 - Add it to extensions.txt

Create or edit the file:

source/extensions/extension.txt

Add the filename including the .d extension:

hello_world.d

Each line corresponds to one extension file DVN will import at compile time.

Step 3 - Install assets (if included)

If the extension comes with scripts, characters, images, or UI elements, place them manually into:

build/client/data/game/

using the same structure DVN normally uses:

build/client/data/game/scripts/
build/client/data/game/sfx/
build/client/data/game/backgrounds/
...

Step 4 - Build the project

Windows users may run:

build_win_x86_64.bat

Linux and macOS users: see Getting Started -> Building.

Once compiled, DVN will detect the extension and activate it automatically.

Creating an extension

Steo 1 - Create the asset folder (optional)

If your extension includes assets, create a folder named:

game/

Inside it, mirror DVN's asset structure:

game/scripts/
game/sfx/
game/characters/

These will later be copied manually into the user's project.

Step 2 - Create the extension D module

IMPORTANT: DO NOT CREATE A MODULE STATEMENT IN YOUR D FILE, DVN WILL AUTOMATICALLY HANDLE IT

Minimal example:

import dvn;

public final class HelloWorldEvents : DvnEvents
{
	public override void engineReady(Application app, Window[] windows)
	{
		import std.file : write;

		write("hello_world.txt", "Hello, DVN!");
	}
}

Any class in this module that inherits DvnEvents will be detected automatically.

Step 3 - Package the extension

Example package layout:

MyExtension.zip
|
|- hello_world.d
|- game/
   |- scripts/

This keeps the extension self-contained for distribution.

Best Practices

  • Keep it focused. - One extension = one feature or system.
  • Use unique filenames. - Avoid naming conflicts (ex: prefix assets like hw_ or extension name).
  • Scripts should demonstrate usage, not overwrite projects. - Treat them as examples or opt-in templates.
  • Avoid replacing core JSON files:
    • characters.json
    • backgrounds.json
    • music.json
    • etc.
  • Follow DVN naming conventions:
    • snake_case for assets and identifiers
    • PascalCase for classes