Skip to content

Instantly share code, notes, and snippets.

@lazalong
lazalong / sample_rework_filebrowser_component.v
Last active November 29, 2023 22:30
Test code to rework the V file browser component
/*
Test code to rework the file browser component.
NOTE:
- Some truct & fcts have '_LL' or '_ll' appended to differentiate them from existing ones.
They contain some changes to make the subwindow match the menubar style
- Multiple small changes to make the file browser more stylish
Issues in v.ui code IMO:
- The decoration is see subwindow.h in draw_device() is hard coded (ie gx.black) and can't be set
@lazalong
lazalong / on_draw.v
Last active November 26, 2023 01:14
Snippet to draw a 3D object in a v ui.CanvasLayout
// Interface `ui.GGApplication`
fn (mut app AppState) on_draw() {
window_size := app.gg.window_size()
mut cc := app.win.get_or_panic[ui.CanvasLayout](ui.component_id('canvaslayout', 'layout'))
sgl.viewport(cc.x, cc.y, cc.width, cc.height, true)
mut ctx := app.gg
// Draw a triangle
ctx.draw_triangle_filled(450, 142, 530, 280, 370, 280, gx.red)
@lazalong
lazalong / generics.v
Created December 2, 2022 08:07
Example of generics in V. Implements the V documentation skeleton about Generics
// Example of generics in V.
// Its taken from the quasi-complete code in the documentation
// https://github.com/vlang/v/blob/master/doc/docs.md#generics
// credit: lazalong@gmail.com
module main
interface IData {}
struct User {
id int
@lazalong
lazalong / GameEditorLayout.v
Last active April 21, 2022 07:11
Test to have menu item hidden by default and then toggle them from hidding
import ui
import gx
import ui.component as uic
const (
win_width = 800
win_height = 400
win_title = 'VOGEd'
win_resizable = true
)
/*
* C# Thread Helper
* Copyright (c) 2021 Steven 'lazalong' Gay
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
/****************************** Module Header ******************************\
* Module Name: NetDynamics_CS.cs
* Project: NetDynamics_CS
* Copyright (c) 2020 Steven 'lazalong' Gay
*
* C# version of https://github.com/nxrighthere/NetDynamics
*
* Data-oriented networking playground for the reliable UDP transports
*
* This source is subject to the Microsoft Public License.
/*
* Basic C Memory allocator with leak reporting
*
* Copyright (c) 2020 Steven 'lazalong' Gay
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
// ------------ test.v ---------------------
fn main() {
test()
}
fn test() {
print_backtrace() // Note 10 frames returned by CaptureStackBackTrace in a C program
}
// ------------------- os_windows.v line 40 -----------------------
@lazalong
lazalong / SimpleENetSpanTestCase.cs
Created January 27, 2019 22:07
Simple Test Case to Send messages with ENet-Sharp & ENetStack
//
// Simple Test Case to Send messages with ENet-Sharp & ENetStack
// -------------------------------------------------------------
// steven 'lazalong' 2019
//
// If all goes smoothly you should see the followign log line:
// [Server] LogindData= OpCode= 4 passHash= 70 username= username
// UnityEngine.Debug:Log(Object)
// You will need the dll from the reference below.
// Reference: