Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ coverage/
# Backup files
*.bak
*.backup

# CMake compilation database
compile_commands.json
75 changes: 75 additions & 0 deletions addons/goethe_dialog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

cmake_minimum_required(VERSION 3.20)

project(goethe_dialog_extension)

# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find yaml-cpp (required)
find_package(yaml-cpp REQUIRED)

# Find zstd (optional)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(ZSTD QUIET libzstd)
endif()

if(ZSTD_FOUND)
message(STATUS "Found zstd: ${ZSTD_VERSION}")
add_compile_definitions(GOETHE_ZSTD_AVAILABLE)
else()
message(STATUS "zstd not found - compression will use null backend only")
endif()

# Include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/../../include
${CMAKE_CURRENT_SOURCE_DIR}/../../src/engine
)

# Source files from the main library
set(LIBRARY_SOURCES
../../src/engine/core/dialog.cpp
../../src/engine/core/compression/backend.cpp
../../src/engine/core/compression/factory.cpp
../../src/engine/core/compression/manager.cpp
../../src/engine/core/compression/register_backends.cpp
../../src/engine/core/compression/implementations/null.cpp
../../src/engine/core/statistics.cpp
)

# Add zstd implementation if available
if(ZSTD_FOUND)
list(APPEND LIBRARY_SOURCES ../../src/engine/core/compression/implementations/zstd.cpp)
endif()

# Create a static library
add_library(goethe_lib STATIC ${LIBRARY_SOURCES})

# Link libraries
target_link_libraries(goethe_lib
PRIVATE
yaml-cpp
)

if(ZSTD_FOUND)
target_link_libraries(goethe_lib PRIVATE ${ZSTD_LIBRARIES})
target_include_directories(goethe_lib PRIVATE ${ZSTD_INCLUDE_DIRS})
endif()

# Compiler-specific settings
if(MSVC)
target_compile_definitions(goethe_lib PRIVATE _CRT_SECURE_NO_WARNINGS)
else()
target_compile_options(goethe_lib PRIVATE -fvisibility=hidden)
endif()

# Create a simple test program
add_executable(goethe_test test_main.cpp)
target_link_libraries(goethe_test goethe_lib)

message(STATUS "Building basic Goethe library and test executable")
message(STATUS "Godot extension will be added once godot-cpp is properly set up")
185 changes: 185 additions & 0 deletions addons/goethe_dialog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Goethe Dialog Plugin for Godot

A Godot plugin that integrates the Goethe Dialog System library to provide powerful dialog management capabilities for visual novels and interactive narratives.

## Features

- **YAML Dialog Support**: Load and save dialogs in both simple and advanced GOETHE formats
- **Character Management**: Support for character names, expressions, moods, portraits, and voice
- **Conditional Logic**: Advanced condition system with flags, variables, and quest states
- **Effect System**: Comprehensive effect system for game state changes
- **Compression**: Built-in compression support for efficient dialog storage
- **Statistics**: Real-time performance monitoring and analysis
- **Editor Tools**: Custom dialog editor with visual interface
- **GDScript Integration**: Native GDScript classes for easy integration

## Installation

1. Copy the `addons/goethe_dialog` folder to your Godot project's `addons` directory
2. Enable the plugin in Project Settings → Plugins
3. Build the extension (see Building section below)

## Building the Extension

### Prerequisites

- Godot 4.0 or later
- CMake 3.20 or later
- C++20 compatible compiler (Clang preferred, GCC fallback)
- yaml-cpp library
- zstd library (optional, for compression)

### Build Steps

1. Navigate to the plugin directory:
```bash
cd addons/goethe_dialog
```

2. Run the build script:
```bash
chmod +x build.sh
./build.sh
```

3. The extension will be built and placed in the appropriate `bin` directory.

## Usage

### Basic Usage

```gdscript
# Create a dialog manager
var dialog_manager = GoetheDialogManager.new()
add_child(dialog_manager)

# Load a dialog from file
dialog_manager.load_dialog_from_file("res://dialogs/chapter1.yaml")

# Start the dialog
dialog_manager.start_dialog()

# Connect to signals
dialog_manager.dialog_node_changed.connect(_on_dialog_node_changed)
dialog_manager.choice_made.connect(_on_choice_made)
```

### Dialog YAML Format

#### Simple Format
```yaml
id: chapter1_intro
nodes:
- id: greeting
speaker: alice
text: Hello, welcome to our story!
- id: response
speaker: bob
text: Thank you, I'm excited to begin!
```

#### Advanced Format
```yaml
kind: dialogue
id: chapter1_intro
startNode: intro

nodes:
- id: intro
speaker: marshal
text: Welcome to the adventure!
portrait: { id: marshal, mood: neutral }
voice: { clipId: vo_intro }
choices:
- id: accept
text: I accept the quest
to: quest_start
effects:
- type: SET_FLAG
target: quest_accepted
value: true
- id: refuse
text: I need time to think
to: farewell
```

### Character Management

```gdscript
# Create a character
var character = GoetheCharacter.new()
character.id = "alice"
character.name = "Alice"
character.add_portrait("happy", "neutral", "res://portraits/alice_happy.png")
character.add_voice_clip("greeting", "res://audio/alice_greeting.ogg")
```

### Condition System

```gdscript
# Set flags and variables
dialog_manager.set_flag("quest_completed", true)
dialog_manager.set_variable("player_level", 10)

# Conditions in YAML will automatically check these values
```

## Editor Tools

### Dialog Editor

The plugin includes a visual dialog editor that can be accessed from the Tools menu:

1. Go to Tools → Goethe Dialog Editor
2. Create new dialogs or load existing ones
3. Edit dialog nodes visually
4. Save your changes

### Custom Types

The plugin registers several custom types:

- **GoetheDialogManager**: Main dialog management node
- **GoetheDialogNode**: Individual dialog node resource
- **GoetheCharacter**: Character definition resource

## Examples

See the `examples` directory for complete examples:

- **Basic Dialog**: Simple dialog system implementation
- **Visual Novel**: Full visual novel example with characters and choices

## API Reference

### GoetheDialogManager

#### Properties
- `current_dialog: GoetheDialog` - The currently loaded dialog
- `current_node_index: int` - Index of the current node
- `flags: Dictionary` - Global flags for conditions
- `variables: Dictionary` - Global variables for conditions

#### Methods
- `load_dialog_from_file(file_path: String) -> bool`
- `load_dialog_from_yaml(yaml_content: String) -> bool`
- `start_dialog(dialog_id: String = "") -> bool`
- `next_node() -> bool`
- `previous_node() -> bool`
- `make_choice(choice_index: int) -> bool`
- `set_flag(flag_name: String, value: bool) -> void`
- `get_flag(flag_name: String) -> bool`
- `set_variable(var_name: String, value: Variant) -> void`
- `get_variable(var_name: String) -> Variant`

#### Signals
- `dialog_started(dialog_id: String)`
- `dialog_ended(dialog_id: String)`
- `dialog_node_changed(node: GoetheDialogNode)`
- `choice_made(choice_id: String, choice_text: String)`

### GoetheDialogNode

#### Properties
- `id: String` - Unique identifier for the node
- `speaker: String` - Charact
47 changes: 47 additions & 0 deletions addons/goethe_dialog/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Build script for Goethe Dialog Godot Extension

set -e

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo -e "${GREEN}Building Goethe Dialog Extension...${NC}"

# Check if we're in the right directory
if [ ! -f "CMakeLists.txt" ]; then
echo -e "${RED}Error: CMakeLists.txt not found. Please run this script from the addons/goethe_dialog directory.${NC}"
exit 1
fi

# Check if we're in the right project structure
if [ ! -d "../../src/engine" ]; then
echo -e "${RED}Error: Cannot find the main Goethe library source. Please ensure this plugin is in the correct location.${NC}"
echo -e "${YELLOW}Expected path: ../../src/engine${NC}"
echo -e "${YELLOW}Current directory: $(pwd)${NC}"
ls -la ../../
exit 1
fi

# Create build directory
mkdir -p build
cd build

# Configure with CMake
echo -e "${YELLOW}Configuring with CMake...${NC}"
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo

# Build
echo -e "${YELLOW}Building...${NC}"
make -j$(nproc)

echo -e "${GREEN}Build completed successfully!${NC}"
echo -e "${YELLOW}This builds a basic test executable for now.${NC}"
echo -e "${YELLOW}To build the full Godot extension, you need to:${NC}"
echo -e "${YELLOW}1. Install godot-cpp: git clone https://github.com/godotengine/godot-cpp.git ~/.local/share/godot/godot-cpp${NC}"
echo -e "${YELLOW}2. Build godot-cpp: cd ~/.local/share/godot/godot-cpp && scons platform=linux target=template_release${NC}"
echo -e "${YELLOW}3. Update CMakeLists.txt to include Godot bindings${NC}"
Loading
Loading