#![allow(non_snake_case)]
mod app;
mod assets;
mod engine;
mod godot;
mod runtime;
mod shader;
mod ui;
mod window;
pub use app::GodoruApp;
pub use assets::{AssetKind, AssetLoader, FontHandle, ImageHandle};
pub use engine::{EngineBackend, EnginePaths, GodotInstance, LibGodotDesktop};
pub use runtime::{Antialiasing, AppSettings, FrameLimit, Msaa, Renderer, TextureFilter, VSync};
pub use shader::{IntoShaderValue, Shader, ShaderParam, ShaderSource, ShaderValue};
pub use ui::{
Align, AppTheme, Border, Button, ButtonBuilder, Checkbox, CheckboxBuilder, Color, Component,
Container, ContainerBuilder, ContainerDirection, ContainerWrap, CursorIcon, FontWeight, Image,
ImageBuilder, ImageFit, InteractionEvents, IntoSpacing, Justify, NoAction, Scroll,
ScrollBuilder, Shadow, SizeMode, Spacing, Style, Text, TextBuilder, TextInput,
TextInputBuilder, ThemeClass, Ui, UiNode, VisualState,
};
pub use window::{WindowOptions, WindowSize};
use std::fmt;
use std::path::PathBuf;
pub type GodoruResult<T> = Result<T, GodoruError>;
#[derive(Debug)]
pub enum GodoruError {
UnsupportedBackend(String),
MissingEnginePath(PathBuf),
EngineLoad {
path: PathBuf,
message: String,
},
SymbolLoad {
symbol: &'static str,
message: String,
},
InstanceCreateFailed,
InstanceStartFailed,
EngineMethodUnavailable(String),
GodotBridgeUnavailable,
GodotMethodUnavailable(String),
GodotObjectCreate(String),
GodotRuntime(String),
AssetPath(String),
InvalidCString(String),
WindowCreate(String),
MissingWindow,
TooManyWindows,
ProjectCreate {
path: PathBuf,
message: String,
},
}
impl fmt::Display for GodoruError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GodoruError::UnsupportedBackend(message) => write!(formatter, "{message}"),
GodoruError::MissingEnginePath(path) => {
write!(
formatter,
"missing Godoru engine artifact at {}",
path.display()
)
}
GodoruError::EngineLoad { path, message } => {
write!(formatter, "failed to load {}: {message}", path.display())
}
GodoruError::SymbolLoad { symbol, message } => {
write!(formatter, "failed to load symbol {symbol}: {message}")
}
GodoruError::InstanceCreateFailed => {
write!(formatter, "failed to create Godot instance")
}
GodoruError::InstanceStartFailed => {
write!(formatter, "failed to start Godot instance")
}
GodoruError::EngineMethodUnavailable(method) => {
write!(formatter, "GodotInstance method is unavailable: {method}")
}
GodoruError::GodotBridgeUnavailable => {
write!(formatter, "Godot GDExtension bridge is unavailable")
}
GodoruError::GodotMethodUnavailable(method) => {
write!(formatter, "Godot method is unavailable: {method}")
}
GodoruError::GodotObjectCreate(class) => {
write!(formatter, "failed to create Godot object: {class}")
}
GodoruError::GodotRuntime(message) => {
write!(formatter, "Godot runtime error: {message}")
}
GodoruError::AssetPath(message) => {
write!(formatter, "invalid Godoru asset path: {message}")
}
GodoruError::InvalidCString(value) => {
write!(formatter, "string contains interior nul byte: {value:?}")
}
GodoruError::WindowCreate(message) => {
write!(formatter, "failed to create window: {message}")
}
GodoruError::MissingWindow => write!(formatter, "GodoruApp::run requires one window"),
GodoruError::TooManyWindows => {
write!(formatter, "Godoru phase 2 supports a single window")
}
GodoruError::ProjectCreate { path, message } => {
write!(
formatter,
"failed to create Godoru project file {}: {message}",
path.display()
)
}
}
}
}
impl std::error::Error for GodoruError {}