How james7132/danmakufu-ph3 works
Project Type and Purpose
• This is a Windows‐based game scripting framework (Touhou Danmakufu ph3) plus three companion GUI tools:
• DnhConfig – a configuration editor for scripts
• DnhExecutor – the runtime “engine” that loads scripts and runs the game
• DnhViewer – a scene/script previewer and debugger
• FileArchiver – a utility to package/unpackage script/resource bundles
• All components are written in C++/Win32 using DirectX 9 (graphics, input, sound) and share common libraries (GcLib and the Danmakufu “Common” core).
High-Level File/Directory Structure
• root
– DirectX9c/{Include,Lib}
– source/
· GcLib/… (Graphics, Input, Sound, Script manager, utility classes)
· TouhouDanmakufu/
· Common/… (engine core: script interpreter, stage/item/player logic)
· DnhConfig/… (UI layer for configuration)
· DnhExecutor/… (UI + game loop + scene management)
· DnhViewer/… (UI + preview scenes)
· FileArchiver/… (UI + archive library implementation)
– bin_th_dnh/… (packaged scripts & resources)
– bin_ext/… (compiled FileArchiver executable)
– *.vcxproj & GcProject.sln
Key Components and Their Interactions
A. Applications (executables)
1. DnhConfig.exe
2. DnhExecutor.exe (th_dnh.exe)
3. DnhViewer.exe
4. FileArchiver.exe
B. Shared Libraries
1. GcLib
• DirectX wrappers (DirectGraphics, DirectInput, DirectSound)
• ScriptManager, Texture, Shader, Effect, Window, Utility, etc.
2. Danmakufu Common
• Script execution engine (DnhScript, StgSystem, StgEnemy, StgPlayer, StgShot, etc.)
C. External Dependencies
– DirectX9c SDK (headers + .lib)
– Ogg/Vorbis static libs
– Win32 (user32, gdi32, kernel32)
Architectural Patterns & Design Principles
• Modular layering:
• UI Layer (WinMain + MainWindow/Scene panels)
• Engine Layer (Common script engine + GcLib)
• External platform layer (DirectX, OS APIs)
• Shared-library reuse: each executable links against GcLib + Common → avoids code duplication
• Data‐driven scripting: script files drive stage, enemy, item, effect definitions
– Rectangles for executables (Config, Executor, Viewer, Archiver)
– Rounded rectangles for shared libraries (GcLib, Common, ext libs)
– Clouds for external systems (DirectX9 runtime, OS)
b. Relationships & Data Flows
– Config ↔ (reads/writes) Script files
– Executor → Script files (load at runtime)
– Viewer → Script files (load preview)
– Archiver ↔ Script+Resource folders (package/unpackage)
– All executables → GcLib + Common (link‐time dependency)
– GcLib → DirectX9, Ogg/Vorbis libs, Win32 APIs
c. Important Patterns
– Layered architecture: UI → Engine → Platform
– Shared libraries for core logic
– Data/script‐driven design
d. Technologies & Frameworks
– C++/Win32 application framework
– DirectX9 (d3d9, d3dx9, dinput8, dsound)
– HLSL shaders (in GcLib)
– Metasequoia mesh loader, Ogg/Vorbis audio