Skip to content

Instantly share code, notes, and snippets.

View PsichiX's full-sized avatar
👨‍🔬
For the Symmetry! [mental health vacation]

Patryk Budzyński PsichiX

👨‍🔬
For the Symmetry! [mental health vacation]
View GitHub Profile
@PsichiX
PsichiX / tests.rs
Last active November 25, 2024 23:03
Transaction interface for editable data
#[test]
fn test_editable() {
let mut editable = Editable::new(0usize);
assert_eq!(editable.done_count(), 0);
assert_eq!(editable.undone_count(), 0);
editable
.edit_snapshot("set 42", |data| {
*data = 42;
Ok(())
@PsichiX
PsichiX / 0_test_library.rs
Last active October 24, 2024 20:29
FFI support for Intuicio scripting platform
let registry = Registry::default().with_basic_types();
let mut context = Context::new(10240, 10240);
let mut lib = FfiLibrary::new("../../target/debug/ffi").unwrap();
let ffi_add = lib
.function(function_signature!(&registry => fn add(a: i32, b: i32) -> (result: i32)))
.unwrap();
let ffi_ensure = lib
.function(function_signature!(&registry => fn ensure_42(v: i32) -> ()))
.unwrap();
context.stack().push(2i32);
@PsichiX
PsichiX / 0_test.rs
Last active August 12, 2024 23:34
NEAT - XOR
#[test]
fn test_neat_xor() {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Input {
A,
B,
Control,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@PsichiX
PsichiX / test.rs
Last active March 15, 2024 02:55
Intuicio - Name and Text framework
use intuicio_core::prelude::*;
use intuicio_data::prelude::*;
use intuicio_derive::*;
use intuicio_framework_text::{Name, Text};
use std::collections::HashMap;
#[derive(IntuicioStruct, Debug, Default)]
#[intuicio(module_name = "test")]
struct Loc {
#[intuicio(ignore)]
@PsichiX
PsichiX / ecs.rs
Created February 24, 2024 00:06
Intuicio with hecs example
use hecs::World;
use intuicio_core::prelude::*;
use intuicio_data::{
lifetime::Lifetime,
managed::{ManagedRef, ManagedRefMut},
};
use intuicio_derive::*;
#[derive(IntuicioStruct, Default)]
struct Health {
@PsichiX
PsichiX / immediate_mode_access_and_tests.rs
Last active October 23, 2023 23:53
RAUI's immediate mode `use_access` allows GUI testing with mock data
#[allow(unused_imports)]
use raui_app::prelude::*;
use raui_immediate::*;
mod gui {
use raui_immediate::*;
use raui_immediate_widgets::prelude::*;
pub fn app() {
nav_content_box((), || {
@PsichiX
PsichiX / immediate_mode_states_and_effects.rs
Created October 15, 2023 01:31
RAUI immediate mode - states and effects
// Make sure you have seen `immediate_mode` code example first, because this is a continuation of that.
use raui_immediate::{make_widgets, ImmediateContext};
use raui_quick_start::RauiQuickStartBuilder;
const FONT: &str = "./demos/hello-world/resources/verdana.ttf";
mod gui {
use raui_immediate::*;
use raui_immediate_widgets::prelude::*;
@PsichiX
PsichiX / immediate_mode.rs
Last active October 14, 2023 21:41
RAUI immediate mode experiments
// Example of immediate mode UI on top of RAUI.
// It's goal is to bring more ergonomics to RAUI by hiding
// declarative interface under simple nested function calls.
// As with retained mode, immediate mode UI can be mixed with
// declarative mode and retained mode widgets.
use raui_immediate::{make_widgets, ImmediateContext};
use raui_quick_start::RauiQuickStartBuilder;
const FONT: &str = "./demos/hello-world/resources/verdana.ttf";
@PsichiX
PsichiX / retained_mode.rs
Last active October 12, 2023 23:52
RAUI retained mode experiments
// Example of retained mode UI on top of RAUI.
// It's goals are very similar to Unreal's UMG on top of Slate.
// Evolution of this approach allows to use retained mode views
// within declarative mode widgets and vice versa - they
// interleave quite seamingly.
use raui::prelude::*;
use raui_quick_start::RauiQuickStartBuilder;
use raui_retained::*;
use std::any::Any;
@PsichiX
PsichiX / retained_mode.rs
Created October 12, 2023 02:26
RAUI retained mode experiments
use raui::prelude::*;
use raui_quick_start::RauiQuickStartBuilder;
use std::any::Any;
#[derive(Default)]
struct AppView {
pub icons: View<ListView<IconView>>,
}
impl ViewState for AppView {