-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
48 lines (40 loc) · 945 Bytes
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Godot;
using System;
using System.Collections.Generic;
public partial class Main : Control
{
[Export]
VirtualScrollList ScrollList, ScrollGrid;
List<object> items = new List<object>();
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
ScrollGrid.Items = ScrollList.Items = items;
}
void AddItem()
{
ScrollList.Items.Add(CreateRandomItem());
ScrollList.QueueRedraw();
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
ListItem CreateRandomItem()
{
string[] names = {"Apple", "Milk", "Beans", "Water"};
Random r = new ();
ListItem i = new()
{
Name = names[r.NextInt64(names.Length-1)],
Price = r.NextInt64(10,45)/10f
};
return i;
}
}
class ListItem
{
static string StaticField = "Some satic value";
public string Name = "abcddawdawd";
public float Price = 1.0f;
}