@@ -2,6 +2,7 @@ using Beefy.gfx;
22using Beefy . theme . dark ;
33using System ;
44using Beefy . widgets ;
5+ using System . IO ;
56
67namespace IDE . ui
78{
@@ -13,6 +14,9 @@ namespace IDE.ui
1314 public String mLabel ~ delete _;
1415 public Font mFont ;
1516 public String mPath ~ delete _;
17+ #if BF_PLATFORM_LINUX && LINUX_PACKAGE
18+ public String mUserPath ~ delete _;
19+ #endif
1620
1721 public override void Draw ( Graphics g )
1822 {
@@ -41,7 +45,21 @@ namespace IDE.ui
4145 base . MouseClicked ( x , y , origX , origY , btn ) ;
4246
4347 gApp . [ Friend ] mDeferredOpen = . Workspace ;
48+ #if BF_PLATFORM_LINUX && LINUX_PACKAGE
49+ String . NewOrSet ! ( gApp . [ Friend ] mDeferredOpenFileName , mUserPath) ;
50+
51+ if ( ! File . Exists ( mUserPath ) )
52+ {
53+ let installedSamplesDir = scope String ( ) ;
54+ let userSamplesDir = scope String ( ) ;
55+ if ( Path . GetDirectoryPath ( mPath , installedSamplesDir ) case . Ok && Path . GetDirectoryPath ( mUserPath , userSamplesDir ) case . Ok )
56+ {
57+ Directory . Copy ( installedSamplesDir , userSamplesDir ) . IgnoreError ( ) ;
58+ }
59+ }
60+ #else
4461 String . NewOrSet ! ( gApp . [ Friend ] mDeferredOpenFileName , mPath) ;
62+ #endif
4563 }
4664 }
4765
@@ -75,12 +93,18 @@ namespace IDE.ui
7593
7694 mSampleBtn0 = new . ( ) ;
7795 mSampleBtn0 . mPath = new String ( ) ..AppendF ( @"{}/../Samples/SpaceGame/BeefSpace.toml" , gApp . mInstallDir ) ;
96+ #if BF_PLATFORM_LINUX && LINUX_PACKAGE
97+ mSampleBtn0 . mUserPath = new $"{gApp.mUserDataDir}/Samples/SpaceGame/BeefSpace.toml" ;
98+ #endif
7899 mSampleBtn0 . mLabel = new String ( "Space Game" ) ;
79100 mSampleBtn0 . mImage = mSampleImg0 ;
80101 AddWidget ( mSampleBtn0 ) ;
81102
82103 mSampleBtn1 = new . ( ) ;
83104 mSampleBtn1 . mPath = new String ( ) ..AppendF ( @"{}/../Samples/HelloWorld/BeefSpace.toml" , gApp . mInstallDir ) ;
105+ #if BF_PLATFORM_LINUX && LINUX_PACKAGE
106+ mSampleBtn1 . mUserPath = new $"{gApp.mUserDataDir}/Samples/HelloWorld/BeefSpace.toml" ;
107+ #endif
84108 mSampleBtn1 . mLabel = new String ( "Hello World" ) ;
85109 mSampleBtn1 . mImage = mSampleImg1 ;
86110 AddWidget ( mSampleBtn1 ) ;
0 commit comments