Inheritance: IDisposable
コード例 #1
0
ファイル: LEScreen.cs プロジェクト: Antr0py/VoxelRTS
        private void CreateTools()
        {
            tools = new LETool[] {
                new LETSingle(),
                new LETCluster(),
                new LETPaint(),
                new LETRect()
            };
            curTool = tools[0];

            // Create Menu
            toolMenu = new ScrollMenu(wr, 180, 30, 5, 12, 30);
            toolMenu.Build((from tool in tools select tool.Name).ToArray());
            toolMenu.BaseColor          = Color.LightCoral;
            toolMenu.HighlightColor     = Color.Red;
            toolMenu.TextColor          = Color.Black;
            toolMenu.ScrollBarBaseColor = Color.Green;
            toolMenu.Widget.AlignY      = Alignment.BOTTOM;
            toolMenu.Parent             = voxMenu.Widget;
            toolMenu.Hook();

            // Set The Textures
            foreach (var tool in tools)
            {
                tool.LoadMouseTexture(G, @"LevelEditor\Mouse\" + tool.Name + ".png");
            }
            game.mRenderer.Texture = curTool.MouseTexture;
        }
コード例 #2
0
ファイル: LEScreen.cs プロジェクト: Antr0py/VoxelRTS
 private void DestroyTools()
 {
     foreach (var tool in tools)
     {
         tool.Dispose();
     }
     tools   = null;
     curTool = null;
 }
コード例 #3
0
ファイル: LEScreen.cs プロジェクト: Antr0py/VoxelRTS
        public void OnMP(Vector2 sPos, MouseButton button)
        {
            Point mPos = new Point((int)sPos.X, (int)sPos.Y);

            if (leMenu.IsActive && !leMenu.WidgetBase.Inside(mPos.X, mPos.Y))
            {
                HideLEMenu();
            }

            // Check For New Voxel Selection
            if (voxMenu.Inside(mPos.X, mPos.Y))
            {
                string vt = voxMenu.GetSelection(mPos.X, mPos.Y);
                if (string.IsNullOrWhiteSpace(vt))
                {
                    return;
                }
                VoxData vd;
                if (dVox.TryGetValue(vt, out vd))
                {
                    foreach (var tool in tools)
                    {
                        tool.CurVoxID = vd.ID;
                    }
                }
                HideToolMenu();
                return;
            }
            else if (toolMenu.Inside(mPos.X, mPos.Y))
            {
                string vt = toolMenu.GetSelection(mPos.X, mPos.Y);
                curTool = (from tool in tools where tool.Name.Equals(vt) select tool).FirstOrDefault();
                if (curTool != null)
                {
                    game.mRenderer.Texture = curTool.MouseTexture;
                    HideToolMenu();
                }
                return;
            }
            else
            {
                HideToolMenu();
            }

            if (curTool != null)
            {
                curTool.OnMouseClick(state, camera, sPos, button, G.Viewport);
            }
        }