public void Main(string argument, UpdateType updateSource) { Dictionary <string, object> inputs = Me.GetProperty("ControlModule.Inputs")?.As <Dictionary <string, object> >()?.GetValue(Me); if (inputs != null) { blocks.Clear(); foreach (long key in spritesPreviewers.Keys) { missingSpritePreviewers.Add(key); } GridTerminalSystem.GetBlocks(blocks); foreach (IMyTerminalBlock block in blocks) { if (block is IMyTextPanel) { IMyTextPanel text_panel = (IMyTextPanel)block; if (text_panel.CustomData.Trim() == "previewSprites") { if (!(spritesPreviewers.ContainsKey(text_panel.EntityId))) { List <string> sprites = new List <string>(); text_panel.GetSprites(sprites); spritesPreviewers.Add(text_panel.EntityId, new SpritesPreviewer(text_panel, sprites)); } missingSpritePreviewers.Remove(text_panel.EntityId); } } } foreach (long key in missingSpritePreviewers) { spritesPreviewers.Remove(key); } missingSpritePreviewers.Clear(); foreach (string input in inputs.Keys) { if (spritesPreviewersKeyInputActions.ContainsKey(input)) { SpritesPreviewerKeyInputActionDelegate sprites_previewers_key_input_action = spritesPreviewersKeyInputActions[input]; foreach (SpritesPreviewer sprite_previewer in spritesPreviewers.Values) { sprites_previewers_key_input_action(sprite_previewer); } } } foreach (SpritesPreviewer sprite_previewer in spritesPreviewers.Values) { string selected_sprite = sprite_previewer.SelectedSprite; if (selected_sprite != null) { sprite_previewer.TextPanel.ContentType = ContentType.SCRIPT; using (MySpriteDrawFrame sprite_draw_frame = sprite_previewer.TextPanel.DrawFrame()) { sprite_draw_frame.Add(MySprite.CreateSprite(selected_sprite, sprite_previewer.TextPanel.SurfaceSize * 0.5f, sprite_previewer.TextPanel.SurfaceSize * sprite_previewer.ZoomFactor)); sprite_draw_frame.Add(MySprite.CreateText(selected_sprite, "DEBUG", Color.White, 1.0f, TextAlignment.CENTER)); } } } } }