File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ public class ScriptWidgetApi(ScriptContainer source): ApiBase(source) { // TODO:
2222
2323 public CollapsableWidget CollapsableSection ( string title , IDisplayWidget content ) => new ( title , content ) ;
2424 public CollapsableWidget CollapsableSection ( string title , string content ) => new ( title , new TextWidget ( content ) ) ;
25+ public CollapsableWidget Section ( string title , IDisplayWidget content ) => this . CollapsableSection ( title , content ) ;
26+ public CollapsableWidget Section ( string title , string content ) => this . CollapsableSection ( title , content ) ;
2527
2628 public static IDisplayWidget FromLuaValue ( DynValue dv ) => dv . Type switch {
2729 DataType . Boolean => new SeparatorWidget ( ) . SetBar ( dv . Boolean ) ,
Original file line number Diff line number Diff line change @@ -63,9 +63,21 @@ public bool AutoResize {
6363
6464 public bool Empty => this . ScriptWindow . Empty ;
6565
66+ public void ClearContent ( ) {
67+ this . ScriptWindow . content = [ ] ;
68+ this . Owner . Log ( $ "Cleared window contents", LogTag . ScriptWindow ) ;
69+ }
6670 public void SetContent ( List < DynValue > contents ) {
6771 this . ScriptWindow . content = contents . Select ( ScriptWidgetApi . FromLuaValue ) . ToArray ( ) ;
6872 this . Owner . Log ( $ "Set window content list to { this . ScriptWindow . content . Length } elements", LogTag . ScriptWindow ) ;
6973 }
74+ public void AddContent ( List < DynValue > contents ) {
75+ this . ScriptWindow . content = this . ScriptWindow . content . Concat ( contents . Select ( ScriptWidgetApi . FromLuaValue ) ) . ToArray ( ) ;
76+ this . Owner . Log ( $ "Set window content list to { this . ScriptWindow . content . Length } elements", LogTag . ScriptWindow ) ;
77+ }
78+ public void PushContent ( DynValue item ) {
79+ this . ScriptWindow . content = this . ScriptWindow . content . Append ( ScriptWidgetApi . FromLuaValue ( item ) ) . ToArray ( ) ;
80+ this . Owner . Log ( $ "Set window content list to { this . ScriptWindow . content . Length } elements", LogTag . ScriptWindow ) ;
81+ }
7082
7183}
Original file line number Diff line number Diff line change 11using System . Collections . Generic ;
2+ using System . Linq ;
23
34using MoonSharp . Interpreter ;
45
56namespace VariableVixen . WoLua . Lua . Api . Script . Ui . Widget ;
67
78[ MoonSharpUserData ]
89public class ContentGroup : IDisplayWidget { // TODO: luadocs
9- private readonly List < IDisplayWidget > content = [ ] ;
10+ private List < IDisplayWidget > content = [ ] ;
1011
11- public ContentGroup Add ( DynValue content ) {
12+ public ContentGroup Clear ( ) {
13+ this . content . Clear ( ) ;
14+ return this ;
15+ }
16+ public ContentGroup Push ( DynValue content ) {
1217 this . content . Add ( ScriptWidgetApi . FromLuaValue ( content ) ) ;
1318 return this ;
1419 }
20+ public ContentGroup Add ( List < DynValue > content ) {
21+ this . content . AddRange ( content . Select ( ScriptWidgetApi . FromLuaValue ) ) ;
22+ return this ;
23+ }
24+ public ContentGroup Set ( List < DynValue > content ) {
25+ this . content = content . Select ( ScriptWidgetApi . FromLuaValue ) . ToList ( ) ;
26+ return this ;
27+ }
1528
1629 [ MoonSharpHidden ]
1730 public void Render ( ScriptContainer script ) {
You can’t perform that action at this time.
0 commit comments