示例#1
0
        // Constructors
        public LuaTerminal()
        {
            Owner = Program.MainForm;
            InitializeComponent();

            // Initialize everything
            if (Instance == null)
            {
                scriptThread = new Thread(new ThreadStart(() =>
                {
                    script = new LuaScript();
                }));

                scriptThread.Start();
            }

            Instance = this;
            UpdateLog();
        }
示例#2
0
        private void AssetsList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            // Get Clicked Item
            if (assetsList.SelectedItems.Count < 1)
            {
                return;
            }

            var item = assetsList.SelectedItems[0];

            // Folders
            if (item.ImageIndex == FolderImageIndex)
            {
                currentFolder         = (string)item.Tag;
                searchBox.ShowingHint = true;
                RefreshGUI();
            }

            // Templates
            else if (item.Tag is SetObjectType template)
            {
                // Generate Object
                if (Data.CurrentSetLayer == null)
                {
                    return;
                }

                var obj = new SetObject(template, template.Name,
                                        (uint)Data.CurrentSetLayer.Objects.Count);
                Data.CurrentSetLayer.Objects.Add(obj);

                var script = Stage.Script;
                if (script == null)
                {
                    return; // TODO: idk maybe throw an error??
                }
                try
                {
                    script.Call("InitSetObject", obj, template);
                }
                catch (Exception ex)
                {
                    LuaTerminal.LogError($"ERROR: {ex.Message}");
                }

                // Set Object Position
                var pos = Viewport.CameraPos + (Viewport.CameraForward * 10);
                pos /= Stage.GameType.UnitMultiplier;
                obj.Transform.Position = Types.ToHedgeLib(pos);

                // Load Object Resources (models, etc.) and Spawn Object
                Data.LoadObjectResources(Stage.GameType, obj);
                Viewport.SelectedInstances.Clear();
                Viewport.SelectObject(obj);

                // Refresh UI
                Program.MainForm.RefreshGUI();
                Program.MainForm.RefreshSceneView();
            }

            // Models
            else if (item.Tag is Dictionary <string, VPModel> group)
            {
                var pos = Viewport.CameraPos + (Viewport.CameraForward * 10);
                pos /= Stage.GameType.UnitMultiplier;

                // TODO: Set proper instance name
                var instance = new VPObjectInstance(pos, $"{item.Text}{group.Count}");
                Data.AddInstance(item.Text, instance, group);

                Viewport.SelectedInstances.Clear();
                Viewport.SelectObject(instance);

                // Refresh UI
                Program.MainForm.RefreshGUI();
                Program.MainForm.RefreshSceneView();
            }

            // Materials
            else if (item.Tag is Asset <GensMaterial> mat)
            {
                var matDialog = new MaterialEditor(mat.Data, item.Text,
                                                   $"{mat.Directory.FullPath}\\{item.Text}{Types.MaterialExtension}");

                matDialog.ShowDialog();
            }

            // TODO: Open other types of files
        }