Skip to content
Open
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
4 changes: 2 additions & 2 deletions .run/Build & Run Debug.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration default="false" name="Build &amp; Run Debug" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="kaiju" />
<working_directory value="$PROJECT_DIR$/src" />
<go_parameters value="-tags=&quot;debug,editor&quot;" />
<go_parameters value="-tags=&quot;debug,editor,filedrop,filedialog&quot;" />
<useCustomBuildTags value="true" />
<kind value="DIRECTORY" />
<package value="kaijuengine.com" />
Expand All @@ -11,4 +11,4 @@
<output_directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
</component>
</component>
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"mode": "auto",
"program": "${workspaceFolder}/src",
"cwd": "${workspaceFolder}",
"buildFlags": "-tags=debug,editor,filedrop,rawsrc",
"buildFlags": "-tags=debug,editor,filedrop,filedialog,rawsrc",
"env": {
"CGO_ENABLED": "1",
}
Expand All @@ -23,7 +23,7 @@
"program": "${workspaceFolder}/src",
"cwd": "${workspaceFolder}",
"args": ["-trace"],
"buildFlags": "-tags=debug,editor,filedrop,rawsrc",
"buildFlags": "-tags=debug,editor,filedrop,filedialog,rawsrc",
"env": {
"CGO_ENABLED": "1",
}
Expand All @@ -34,7 +34,7 @@
"mode": "auto",
"program": "${workspaceFolder}/src",
"cwd": "${workspaceFolder}",
"buildFlags": "-tags=editor,filedrop",
"buildFlags": "-tags=editor,filedrop,filedialog",
"env": {
"CGO_ENABLED": "1",
}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"args": [
"-C",
"${workspaceFolder}/src",
"-tags=editor,filedrop",
"-tags=editor,filedrop,filedialog",
"-o=../kaiju.exe",
"main.go"
],
Expand Down
6 changes: 4 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Kaiju Engine is a 2D/3D game engine written in Go (Golang) backed by Vulkan. It

- **Module**: `kaijuengine.com`
- **Go Version**: 1.25.0+
- **Build Tags**: `debug`, `editor`, platform-specific (`.windows.go`, `.darwin.go`, `.linux.go`, `.android.go`)
- **Build Tags**: `debug`, `editor`, optional `filedrop`, optional `filedialog`, platform-specific (`.windows.go`, `.darwin.go`, `.linux.go`, `.android.go`)

## Integration testing
If you want to test visuals or non-unit testable behavior, you can use the integration testing framework. In the `src/integration_testing` folder is where integration tests should be placed. In the `init` function of your integration testing file, you should register your test launch function to the `tests` package map. Review `integration_testing_helpers.go` to see what functions are already available, and also put any generic testing functions into this file.
Expand Down Expand Up @@ -994,13 +994,15 @@ uiCamera := host.Cameras.UI

```bash
cd src
go build -tags="debug,editor,filedrop" -o ../ ./
go build -tags="debug,editor,filedrop,filedialog" -o ../ ./
```

### Build Tags

- `debug`: Include debug information
- `editor`: Build with editor support
- `filedrop`: Enable file drop integrations
- `filedialog`: Enable native file dialog integrations
- Platform-specific: `.windows.go`, `.darwin.go`, `.linux.go`, `.android.go`

### Content
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If you have Go, C build tools, platform libs, and Vulkan setup, you can start by
```sh
mkdir bin/
cd src
go build -tags="debug,editor,filedrop" -o ../bin/ ./
go build -tags="debug,editor,filedrop,filedialog" -o ../bin/ ./
```

*Or just open the repository in VSCode (or other IDE) and begin debugging it.*
Expand Down
132 changes: 132 additions & 0 deletions docs/editor/native_dialog_demo_windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Windows Native Dialog

The editor currently includes Windows-only native dialog when built with the `filedialog` tag (for example: `-tags="editor,filedialog"`).

## Summary

- Dialog requests execute on a worker thread
- Completed dialog results are queued and processed on the window polling thread
- Callback processing is driven by `Window.Poll()` through `filesystem.ProcessDialogCallbacks()`
- If `Root` is set, folder navigation is blocked outside that root and accepted selections are revalidated before results are returned
- Start folder rule:
`CurrentDirectory` is used only when it is inside `Root`; otherwise the dialog starts from `Root`

## Usage Snippets

Use these snippets from game/editor code where you already have `host *engine.Host`.

### Open File Dialog

`ok` callback is required for wrapper helpers; `cancel` is optional.

```go
import "kaijuengine.com/platform/filesystem"

err := host.Window.OpenFileDialog(
"", // startPath: initial directory (empty lets OS choose a default)
[]filesystem.DialogExtension{
{Name: "Go Files", Extension: ".go"},
{Name: "All Files", Extension: ".*"}, // maps to *.*
},
func(path string) { // required ok callback - called when user confirms selection
println("selected file:", path)
},
nil, // optional cancel callback
)
if err != nil {
// Immediate setup/launch failure (not a user cancel)
println("open file dialog failed:", err.Error())
}
```

### Save File Dialog

`ok` callback is required; `cancel` is optional.

```go
import "kaijuengine.com/platform/filesystem"

err := host.Window.SaveFileDialog(
"", // startPath: initial directory
"output.txt", // default save file name
[]filesystem.DialogExtension{
{Name: "Text Files", Extension: ".txt"},
{Name: "All Files", Extension: ".*"},
},
func(path string) { // required ok callback
println("save path:", path)
},
func() { // optional cancel callback
println("save canceled or failed")
},
)
if err != nil {
println("save file dialog failed:", err.Error())
}
```

### Open Folder Dialog

`ok` callback is required; `cancel` is optional.

```go
err := host.Window.OpenFolderDialog(
"", // startPath: initial folder
func(path string) { // required ok callback
println("selected folder:", path)
},
func() { // optional cancel callback
println("folder selection canceled or failed")
},
)
if err != nil {
println("open folder dialog failed:", err.Error())
}
```

### Advanced Native Dialog Request

```go
import "kaijuengine.com/platform/filesystem"

root, err := filesystem.GameDirectory()
if err != nil {
// Fallback: no explicit root/current directory constraints
root = ""
}

req := filesystem.NativeDialogRequest{
Mode: filesystem.NativeDialogModeOpenFiles, // multi-select files
Title: "Import Assets",
CurrentDirectory: root,
Root: root, // navigation + final-selection constraint
ShowHidden: true,
Filters: []filesystem.DialogFilter{
{Name: "Go and Text Files", Patterns: []string{"*.go", "*.txt"}},
{Name: "Images", Patterns: []string{"*.png", "*.jpg", "*.jpeg"}},
{Name: "All Files", Patterns: []string{"*.*"}},
},
Options: []filesystem.DialogCustomOption{
{Name: "Recursive import", Default: 1}, // checkbox option
{Name: "Import mode", Values: []string{"Copy", "Reference", "Link"}, Default: 0}, // combo option
},
WindowHandle: host.Window.PlatformWindow(),
}

err = filesystem.OpenNativeDialogWindow(req, func(result filesystem.NativeDialogResult) {
switch result.Status {
case filesystem.NativeDialogStatusAccepted:
println("accepted files:", len(result.Paths))
println("selected filter index:", result.SelectedFilterIndex)
// If selected options are not returned by the native layer, Kaiju fills defaults from req.Options.
println("selected options keys:", len(result.SelectedOptions))
case filesystem.NativeDialogStatusCancel:
println("dialog canceled")
case filesystem.NativeDialogStatusFailed:
println("dialog failed")
}
})
if err != nil {
println("advanced dialog failed:", err.Error())
}
```
6 changes: 3 additions & 3 deletions docs/engine/build_from_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Expected output: amd64
- Pull the repository
- Go into src `cd src`
- To build the exe in debug mode, run:
- `go build -tags="debug,editor,filedrop" -o ../ ./`
- `go build -tags="debug,editor,filedrop,filedialog" -o ../ ./`
- To build the exe, run:
- `go build -ldflags="-s -w" -tags="editor" -o ../ ./`

Expand All @@ -47,7 +47,7 @@ you'll need to install the [DirectX runtime from Microsoft](https://www.microsof
- Pull the repository
- Go into src `cd src`
- To build the exe in debug mode, run:
- `go build -tags="debug,editor,filedrop" -o ../ ./`
- `go build -tags="debug,editor,filedrop,filedialog" -o ../ ./`
- To build the exe, run:
- `go build -ldflags="-s -w" -tags="editor" -o ../ ./`

Expand All @@ -62,7 +62,7 @@ you'll need to install the [DirectX runtime from Microsoft](https://www.microsof
- Pull the repository
- Go into src: `cd src`
- To build the editor in debug mode, run:
- `CGO_ENABLED=1 CGO_CFLAGS="-I$VULKAN_SDK/include" CGO_LDFLAGS="-L$VULKAN_SDK/lib -lMoltenVK -Wl,-rpath,$VULKAN_SDK/lib" go build -tags="debug,editor,filedrop" -o ../bin/kaiju`
- `CGO_ENABLED=1 CGO_CFLAGS="-I$VULKAN_SDK/include" CGO_LDFLAGS="-L$VULKAN_SDK/lib -lMoltenVK -Wl,-rpath,$VULKAN_SDK/lib" go build -tags="debug,editor,filedrop,filedialog" -o ../bin/kaiju`
- To build the editor, run:
- `CGO_ENABLED=1 CGO_CFLAGS="-I$VULKAN_SDK/include" CGO_LDFLAGS="-L$VULKAN_SDK/lib -lMoltenVK -Wl,-rpath,$VULKAN_SDK/lib" go build -ldflags="-s -w" -tags="editor" -o ../bin/kaiju`

Expand Down
2 changes: 2 additions & 0 deletions docs/engine/build_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ but others will do debugging/runtime changes.
| ------------------ | ----------- |
| `editor` | Used to build the editor, otherwise the runtime will be built |
| `debug` | Used to enable various debug systems for the editor/runtime |
| `filedrop` | Enables file-drop handling integrations used by editor workflows |
| `filedialog` | Enables native file dialog integrations (optional package) |
2 changes: 1 addition & 1 deletion docs/getting_started/start_without_editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The file `src/main.test.go` contains the build constraint:
//go:build !editor
```

This means it is compiled **only** when the `editor` tag is **absent**. The default VS Code tasks in this repository build with `-tags=editor,filedrop`. To build a binary that runs the pure-code path, invoke `go build` **without** those flags:
This means it is compiled **only** when the `editor` tag is **absent**. The default VS Code tasks in this repository build with `-tags=editor,filedrop,filedialog`. To build a binary that runs the pure-code path, invoke `go build` **without** those flags:

```powershell
# Build from the src directory and output the executable one level up
Expand Down
2 changes: 1 addition & 1 deletion src/build/tag_generator/tag_generator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/build/zfiledialog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/build/zfiledialog_not.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading