Skip to content

Instantly share code, notes, and snippets.

View Clancey's full-sized avatar

James Clancey Clancey

View GitHub Profile
#!/bin/bash -ex
MODULE_OPTS=""; # "disable_advanced_gui=yes module_enet_enabled=no module_openxr_enabled=yes module_text_server_adv_enabled=no module_text_server_fb_enabled=yes module_jsonrpc_enabled=no module_mbedtls_enabled=no module_mobile_vr_enabled=yes module_regex_enabled=no module_svg_enabled=no module_tga_enabled=no module_webrtc_enabled=no module_websocket_enabled=no module_multiplayer_enabled=no module_upnp_enabled=no module_webp_enabled=no module_webxr_enabled=no module_zip_enabled=no module_vorbis_enabled=no module_vhacd_enabled=no module_tinyexr_enabled=no module_theora_enabled=no"
MODE=$1
shift;
PLATFORM=$1
shift;
@Clancey
Clancey / CometMvuNoState.cs
Created February 9, 2022 21:16
Comet with pure MVU, without any state.
public class RideTheComet : View
{
public record CometRide
{
public int Rides { get; init; } = 0;
public string CometTrain => "☄️".Repeat(Rides);
}
CometRide state = new CometRide();
@Clancey
Clancey / CometPureMvu.cs
Created February 9, 2022 21:14
Comet without any INPC/Bindings
public class RideTheComet : View
{
public record CometRide
{
public int Rides { get; init; } = 0;
public string CometTrain => "☄️".Repeat(Rides);
}
State<CometRide> state = new CometRide();
@Clancey
Clancey / Reorder_Buttons.cs
Created December 17, 2021 07:10
Added re-order buttons to the images
new ScrollView(Orientation.Horizontal){
new HStack{
Enumerable.Range(0,images.Value.Count).Select(x=> new VStack{
new Image(()=> images.Value[x].Path).Frame(width:100,height:100),
new Button("Remove", ()=>{
images.Value.RemoveAt(x);
Reload();
}),
(x >0 && x < images.Value.Count - 1) ? new HStack{
new Button("<--", ()=>{
@Clancey
Clancey / imagepicker.cs
Last active December 17, 2021 06:27
Comet ImagePicker
public class MainPage : View
{
readonly State<int> ImageCount = new State<int>();
readonly State<List<(string Path, string Name)>> images = new List<(string Path, string Name)>();
Task<FileResult> currentPickerTask;
[Body]
View body()
=> new VStack {
new HStack(Comet.VerticalAlignment.Center){
@Clancey
Clancey / ArtistPlayableGroup.cs
Last active June 3, 2021 22:29
gMusic CarPlay
using System;
using System.Threading.Tasks;
using System.Linq;
namespace gMusic
{
public class ArtistPlayableGroup : PlayableGroup
{
ArtistViewModel model;
ArtistViewModel Model {get{ return model?? (model = new ArtistViewModel()); }}
public abstract class StatefulView<TMessage,TModel> : View
{
public StatefulView() { }
public StatefulView(TModel initialModel)
{
state = initialModel;
}
readonly State<TModel> state = new State<TModel>();
public void Dispatch(TMessage message)
{
public class CounterView : View
{
readonly State<int> count = 0;
readonly State<int> step = 1;
readonly State<bool> timerOn = false;
void init()
{
count.Value = 1;
step.Value = 0;
timerOn.Value = false;
//This uses Records to make the code smaller, even though it doesnt come out until C# 9
//IT also uses a new abstract class, that shouldnt count against it's line count: https://gist.github.com/Clancey/1df421c93ee20832d793a96b30fec997
public data class Model
{
public int Count { get; set; }
public int Step { get; set; }
public bool TimerOn { get; set; }
}
public enum Msg
{
public class Testclass {
Action<bool> MyAction { get; set; }
Func<Task<bool>> MyAwaitedAction { get; set; }
public async Task AsyncTestMethod()
{
MyAction += (result) => {
Console.WriteLine(result);
};
MyAwaitedAction += () => {