Beispiel #1
0
        void OnItemClicked(int index, int _)
        {
            TopicWithResource clickedTopic;

            if (panel.ShowAll.Value)
            {
                clickedTopic = topics[index];
            }
            else
            {
                clickedTopic = topics
                               .Where(topic => topic.ResourceType != ModuleType.Invalid)
                               .ElementAtOrDefault(index);
            }

            if (clickedTopic.Topic == null)
            {
                return;
            }

            var moduleData = ModuleListPanel.CreateModuleForTopic(clickedTopic.Topic, clickedTopic.Type);

            Close();
            moduleData.ShowPanel();
        }
Beispiel #2
0
        void UpdateAliasesLink(int index)
        {
            string hostname = panel.HostNames[index].Value;
            string address  = panel.Addresses[index].Value;

            if (!string.IsNullOrWhiteSpace(hostname) && !string.IsNullOrWhiteSpace(address))
            {
                var newHostAlias = new HostAlias(hostname, address);
                if (HostAliases[index] == newHostAlias)
                {
                    return;
                }

                HostAliases[index] = newHostAlias;
                Logger.Info($"{this}: Adding pair {hostname} -> {address} to resolver list.");
                ConnectionUtils.GlobalResolver[hostname] = address;
                ModuleListPanel.UpdateSimpleConfigurationSettings();
            }
            else if (HostAliases[index] != default)
            {
                ConnectionUtils.GlobalResolver.Remove(HostAliases[index].Hostname);
                Logger.Info($"{this}: Removing {HostAliases[index].Hostname} from resolver list.");
                HostAliases[index] = default;
                ModuleListPanel.UpdateSimpleConfigurationSettings();
            }
        }
Beispiel #3
0
        void OnSaveClicked()
        {
            string name          = panel.Input.Value;
            string validatedName = name.HasSuffix(Suffix) ? name : name + Suffix;

            ModuleListPanel.SaveStateConfiguration(validatedName);
            Close();
        }
Beispiel #4
0
        void WritePanelToConfiguration()
        {
            var markers = new List <ARExecutableMarker>();

            for (int index = 0; index < panel.Types.Count; index++)
            {
                var type = (ARMarkerType)panel.Types[index].Index;
                if (type == ARMarkerType.Unset)
                {
                    continue;
                }

                if (!float.TryParse(panel.Sizes[index].Value, out float sizeInMm) || sizeInMm <= 0)
                {
                    Logger.Info($"{this}: Ignoring size for entry {index}, cannot parse '{panel.Sizes[index].Value}' " +
                                "into a positive number.");
                    continue;
                }

                string code = panel.Codes[index].Value.Trim();
                if (string.IsNullOrEmpty(code))
                {
                    Logger.Info($"{this}: Ignoring empty code for entry {index}.");
                    continue;
                }

                ARExecutableMarker marker = new ARExecutableMarker
                {
                    Type     = type,
                    Action   = (ARMarkerAction)panel.Actions[index].Index,
                    Code     = code,
                    SizeInMm = sizeInMm,
                };
                markers.Add(marker);
            }

            Configuration = new ARMarkersConfiguration
            {
                MaxMarkerDistanceInM = 0.5f,
                Markers = markers.ToArray(),
            };

            if (ARController.Instance != null)
            {
                ARController.Instance.MarkerExecutor.Configuration = Configuration;
            }

            ModuleListPanel.UpdateSimpleConfigurationSettings();
        }
Beispiel #5
0
        void OnItemClicked(int index, int subIndex)
        {
            switch (subIndex)
            {
            case 0:
                ModuleListPanel.LoadStateConfiguration(files[index].FileName);
                Close();
                break;

            case 1:
                string filename = files[index].FullPath;
                try
                {
                    File.Delete(filename);
                }
                catch (Exception e)
                {
                    Logger.Internal("Error deleting config file", e);
                }

                ReadAllFiles();
                break;
            }
        }
Beispiel #6
0
        public override void SetupPanel()
        {
            panel.QualityInView.Options      = SettingsManager.QualityLevelsInView;
            panel.QualityInView.Index        = (int)SettingsManager.QualityInView;
            panel.QualityInView.Interactable = SettingsManager.SupportsView;

            panel.QualityInAr.Options      = SettingsManager.QualityLevelsInAR;
            panel.QualityInAr.Index        = (int)SettingsManager.QualityInAr;
            panel.QualityInAr.Interactable = SettingsManager.SupportsAR;

            panel.TargetFps.Options         = TargetFpsOptions;
            panel.NetworkProcessing.Options = NetworkProcessingOptions;
            panel.SunDirection.SetMinValue(-60).SetMaxValue(60).SetIntegerOnly(true);

            panel.BackgroundColor.Value        = SettingsManager.BackgroundColor.WithAlpha(1);
            panel.BackgroundColor.Interactable = SettingsManager.SupportsView;

            panel.SunDirection.Value = SettingsManager.SunDirection;

            if (SettingsManager.TargetFps == Settings.DefaultFps)
            {
                panel.TargetFps.Index = 0;
            }
            else if (SettingsManager.TargetFps <= 15)
            {
                panel.TargetFps.Index = 3;
            }
            else if (SettingsManager.TargetFps <= 30)
            {
                panel.TargetFps.Index = 2;
            }
            else if (SettingsManager.TargetFps <= 60)
            {
                panel.TargetFps.Index = 1;
            }
            else
            {
                panel.TargetFps.Index = 0;
            }

            switch (SettingsManager.NetworkFrameSkip)
            {
            case 1:
                panel.NetworkProcessing.Index = 0;
                break;

            case 2:
                panel.NetworkProcessing.Index = 1;
                break;

            default:
                panel.NetworkProcessing.Index = 2;
                break;
            }

            panel.ModelCacheLabel.text  = $"<b>Model Cache:</b> {Resource.External.ResourceCount} files";
            panel.SavedFilesLabel.text  = $"<b>Saved Files:</b> {ModuleListPanel.NumSavedFiles} files";
            panel.HostHistoryLabel.text = $"<b>Host History:</b> {ModuleListPanel.Instance.NumMastersInCache} entries";

            panel.ModelService.Options      = ModelServerModesNames;
            panel.ModelService.Label        = UpdateModelServiceLabel();
            panel.ModelService.Interactable = !Settings.IsMobile;

            panel.QualityInView.ValueChanged += (f, _) =>
            {
                SettingsManager.QualityInView = (QualityType)f;
                ModuleListPanel.UpdateSettings();
            };
            panel.QualityInAr.ValueChanged += (f, _) =>
            {
                SettingsManager.QualityInAr = (QualityType)f;
                ModuleListPanel.UpdateSettings();
            };

            panel.BackgroundColor.ValueChanged += c =>
            {
                SettingsManager.BackgroundColor = c;
                ModuleListPanel.UpdateSettings();
            };

            panel.TargetFps.ValueChanged += (i, _) =>
            {
                switch (i)
                {
                case 0:
                    SettingsManager.TargetFps = Settings.DefaultFps;
                    break;

                case 1:
                    SettingsManager.TargetFps = 60;
                    break;

                case 2:
                    SettingsManager.TargetFps = 30;
                    break;

                case 3:
                    SettingsManager.TargetFps = 15;
                    break;
                }

                ModuleListPanel.UpdateSettings();
            };

            panel.NetworkProcessing.ValueChanged += (i, _) =>
            {
                switch (i)
                {
                case 0:
                    SettingsManager.NetworkFrameSkip = 1;
                    break;

                case 1:
                    SettingsManager.NetworkFrameSkip = 2;
                    break;

                case 2:
                    SettingsManager.NetworkFrameSkip = 4;
                    break;
                }

                ModuleListPanel.UpdateSettings();
            };

            panel.SunDirection.ValueChanged += f =>
            {
                SettingsManager.SunDirection = (int)f;
                ModuleListPanel.UpdateSettings();
            };

            panel.Close.Clicked += Close;

            panel.ClearModelCacheClicked += async() =>
            {
                Logger.Info("Settings: Clearing model cache.");
                await Resource.External.ClearModelCacheAsync();

                panel.ModelCacheLabel.text = $"<b>Model Cache:</b> {Resource.External.ResourceCount} files";
            };

            panel.ClearHostHistoryClicked += async() =>
            {
                Logger.Info("Settings: Clearing cache of master uris.");
                await ModuleListPanel.Instance.ClearMastersCacheAsync();

                panel.HostHistoryLabel.text =
                    $"<b>Host History:</b> {ModuleListPanel.Instance.NumMastersInCache} entries";
            };

            panel.ClearSavedFilesClicked += () =>
            {
                Logger.Info("Settings: Clearing saved files.");
                ModuleListPanel.ClearSavedFiles();
                panel.SavedFilesLabel.text = $"<b>Saved:</b> {ModuleListPanel.NumSavedFiles} files";
            };

            panel.ModelService.ValueChanged += async(i, s) =>
            {
                switch ((ModelServerModes)i)
                {
                case ModelServerModes.Off:
                    ModuleListPanel.ModelService.Dispose();
                    break;

                case ModelServerModes.On:
                    await ModuleListPanel.ModelService.Restart(false);

                    break;

                case ModelServerModes.OnWithFile:
                    await ModuleListPanel.ModelService.Restart(true);

                    break;

                default:
                    break;
                }

                panel.ModelService.Label = UpdateModelServiceLabel();
            };
        }
Beispiel #7
0
 protected ListenerModuleData([NotNull] string topic, [NotNull] string type) : base(topic, type)
 {
     ModuleListPanel.RegisterDisplayedTopic(Topic);
 }