66import com .jme3 .system .AppSettings ;
77import com .ss .editor .Editor ;
88import com .ss .editor .EditorContext ;
9+ import com .ss .editor .util .EditorUtil ;
910
1011import java .awt .*;
12+ import java .io .Serializable ;
1113import java .net .URI ;
1214import java .net .URISyntaxException ;
1315import java .nio .file .Files ;
1416import java .nio .file .Path ;
1517import java .nio .file .Paths ;
18+ import java .util .ArrayList ;
19+ import java .util .List ;
1620import java .util .prefs .BackingStoreException ;
1721import java .util .prefs .Preferences ;
1822
@@ -37,6 +41,7 @@ public final class EditorConfig implements AssetEventListener {
3741 public static final String PREF_GRAPHIC_FULLSCREEN = GRAPHICS_ALIAS + "." + "fullscreen" ;
3842
3943 public static final String PREF_CURRENT_ASSET = ASSET_ALIAS + "." + "currentAsset" ;
44+ public static final String PREF_LAST_OPENED_ASSETS = ASSET_ALIAS + "." + "lastOpenedAssets" ;
4045
4146 private static EditorConfig instance ;
4247
@@ -53,6 +58,11 @@ public static EditorConfig getInstance() {
5358 return instance ;
5459 }
5560
61+ /**
62+ * Список последних открываемых asset.
63+ */
64+ private final List <String > lastOpenedAssets ;
65+
5666 /**
5767 * Используемое разрешение экрана.
5868 */
@@ -78,6 +88,33 @@ public static EditorConfig getInstance() {
7888 */
7989 private volatile Path currentAsset ;
8090
91+ public EditorConfig () {
92+ this .lastOpenedAssets = new ArrayList <>();
93+ }
94+
95+ /**
96+ * @return список последних открываемых asset.
97+ */
98+ public List <String > getLastOpenedAssets () {
99+ return lastOpenedAssets ;
100+ }
101+
102+ /**
103+ * Запоминание открытияуказанного Asset.
104+ */
105+ public void addOpenedAsset (final Path currentAsset ) {
106+
107+ final String filePath = currentAsset .toString ();
108+
109+ final List <String > lastOpenedAssets = getLastOpenedAssets ();
110+ lastOpenedAssets .remove (filePath );
111+ lastOpenedAssets .add (0 , filePath );
112+
113+ if (lastOpenedAssets .size () > 10 ) {
114+ lastOpenedAssets .remove (lastOpenedAssets .size () - 1 );
115+ }
116+ }
117+
81118 @ Override
82119 public void assetDependencyNotFound (final AssetKey parentKey , final AssetKey dependentAssetKey ) {
83120 }
@@ -145,7 +182,7 @@ public Path getCurrentAsset() {
145182 /**
146183 * @param currentAsset текущий выбранный Asset.
147184 */
148- public void setCurrentAsset (Path currentAsset ) {
185+ public void setCurrentAsset (final Path currentAsset ) {
149186 this .currentAsset = currentAsset ;
150187 }
151188
@@ -205,6 +242,12 @@ private void init() {
205242 LOGGER .error (e );
206243 }
207244 }
245+
246+ final List <String > deserializeLastOpened = EditorUtil .deserialize (prefs .getByteArray (PREF_LAST_OPENED_ASSETS , null ));
247+
248+ if (deserializeLastOpened != null ) {
249+ getLastOpenedAssets ().addAll (deserializeLastOpened );
250+ }
208251 }
209252
210253 /**
@@ -229,6 +272,10 @@ public void save() {
229272 currentAsset = null ;
230273 }
231274
275+ final List <String > lastOpenedAssets = getLastOpenedAssets ();
276+
277+ prefs .putByteArray (PREF_LAST_OPENED_ASSETS , EditorUtil .serialize ((Serializable ) lastOpenedAssets ));
278+
232279 try {
233280 prefs .flush ();
234281 } catch (final BackingStoreException e ) {
0 commit comments