From 62985e31863ae13f2e4a421e3b53e284dea0d2fc Mon Sep 17 00:00:00 2001 From: giuliaghirardini <giuliaghirardini2001@gmail.com> Date: Sat, 8 Jun 2024 08:45:58 +0200 Subject: [PATCH] [refactoring-missions][mission] Implemented drop down menu to choose mission during design --- classes/Mission.m | 25 ++++++++++++++++++++----- missions/missionConfig.m | 1 + 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/classes/Mission.m b/classes/Mission.m index f505cd8..3b5cb60 100644 --- a/classes/Mission.m +++ b/classes/Mission.m @@ -48,12 +48,27 @@ classdef Mission < Config end function set.name(obj, name) - if ~isempty(obj.currentPath) && ... - ~isfolder(fullfile(obj.currentPath, name)) %#ok<MCSUP> - error('Invalid mission: %s', name) - end + if strcmp(name,'design') + filePath = fullfile(fileparts(mfilename("fullpath")), '..', 'missions'); + filePath = trimPath(filePath); + files = dir(filePath); + files = files(3:end); + isFolder = arrayfun(@(f) isfolder(fullfile(f.folder, f.name)), files); + + names = {files(isFolder).name}; - obj.name = name; + [indx,~] = listdlg('PromptString',{'Select a file.', ... + 'Only one file can be selected at a time.',''}, ... + 'SelectionMode','single','ListSize', [250,150], ... + 'ListString',names); + obj.name = names{indx}; + else + if ~isempty(obj.currentPath) && ... + ~isfolder(fullfile(obj.currentPath, name)) %#ok<MCSUP> + error('Invalid mission: %s', name) + end + obj.name = name; + end obj.updatePath(); end end diff --git a/missions/missionConfig.m b/missions/missionConfig.m index a41a0e4..dc15caf 100644 --- a/missions/missionConfig.m +++ b/missions/missionConfig.m @@ -3,5 +3,6 @@ % Use this file to store relevant, universally true settings, % such as the current mission. The config "BIOS" mission = Mission(); + mission.name = '2023_Gemini_Roccaraso_September'; % mission.name = '2024_Lyra_Portugal_October'; \ No newline at end of file -- GitLab