Skip to content

Instantly share code, notes, and snippets.

View Atlinx's full-sized avatar
💻
Game development

Atlinx Atlinx

💻
Game development
View GitHub Profile
@Atlinx
Atlinx / README.md
Last active June 7, 2023 23:02
Godot C# 3.x Marshalling for Editor Plugins

Godot C# 3.x Marshalling for Editor Plugins

In Godot, C# is integrated with the engine using marshaling. Marshalling is the process of converting a C# type to a Godot type. However, not all types can be converted, leading to marshalling problems. This is primarily an issue for editor plugins, because they must be able to persist across solution rebuilds. When you build the C# solution (either through the build button in the top right of Godot or from your IDE), Godot attempts to serialize all C# tool scripts, replace those scripts with the new ones after the rebuild, and then deserialize the data back into the new scripts. However, this requires marshalling the fields and properties of the C# tool scripts.

The Issue

@Atlinx
Atlinx / root_viewport.gd
Last active February 17, 2023 19:14
Allows you to set stretch, aspect, and other window settings for a viewport. Tested on Godot 3.x.
extends Viewport
enum STRETCH_MODE { DISABLED, TWO_D, VIEWPORT }
enum STRETCH_ASPECT { IGNORE, KEEP, KEEP_WIDTH, KEEP_HEIGHT, EXPAND }
export(STRETCH_MODE) var stretch_mode = STRETCH_MODE.DISABLED
export(STRETCH_ASPECT) var stretch_aspect = STRETCH_MODE.DISABLED
export var stretch_scale: float = 1
export var override_project_settings: bool = false
export var stretch_min: Vector2
@Atlinx
Atlinx / security.middleware.ts
Created May 31, 2022 22:56
Attempt at security middleware for Typetta. Currently doesn't work.
import { Permission } from "@src/generated/model.types";
export type SecurityParams = {
[entity: string]: {
[field: string]: ((newValue: any) => Promise<Error | void>)[]
}
}
export function mergeSecurityParams(... params: SecurityParams[]) {
return mergeUnionArraysMany(...params) as SecurityParams;
@Atlinx
Atlinx / validation.middleware.ts
Last active May 31, 2022 00:06
Validation middleware for the Typetta ORM.
import { HttpError } from "@src/utils/utils";
export type ValidationOptions = {
[entity: string]: {
[field: string]: ((newValue: any) => Promise<Error | void>)[]
}
}
export function mergeValidationOptions(... options: ValidationOptions[]) {
return mergeUnionArraysMany(...options) as ValidationOptions;
@Atlinx
Atlinx / index.html
Created April 26, 2021 18:55
MathJax example // source https://jsbin.com/cufexef
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>MathJax example</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>