コード例 #1
0
ファイル: MarsMinerWindow.cs プロジェクト: vashage/MarsMiner
        protected override void OnLoad( System.EventArgs e )
        {
            Plugin.Register( "MarsMiner.Shared.CorePlugin", true, true );
            Plugin.Register( "MarsMiner.Shared.MarsMinerPlugin", true, true );

            ServerBuilder sb = new ServerBuilder
            {
                Name = "Local Server",
                Password = null,
                SlotCount = 1
            };

            myLocalServer = new GameServer( sb );
            myServerThread = new Thread( myLocalServer.Run );
            myServerThread.Start();

            myLocalClient = new GameClient();
            myLocalClient.ConnectLocal();
            myClientThread = new Thread( myLocalClient.Run );
            myClientThread.Start();

            mySpriteShader = new SpriteShader( Width, Height );
            myUIRoot = new UIObject( new Vector2( Width, Height ) );

            myFPSText = new UILabel( Font.Large, new Vector2( 4.0f, 4.0f ) );
            myFPSText.Text = "FT: ??ms FPS: ?? MEM: ??";
            myUIRoot.AddChild( myFPSText );

            Mouse.Move += OnMouseMove;
            Mouse.ButtonUp += OnMouseButtonEvent;
            Mouse.ButtonDown += OnMouseButtonEvent;

            /*
            myTestWorld = new World();

            myGeoShader = new GeometryShader( Width, Height );
            myGeoShader.UpdateTileMap( 16 );

            myGeoRenderers = new List<ChunkRenderer>();

            myTestWorld.ChunkLoaded += OnChunkEvent;
            myTestWorld.ChunkUnloaded += OnChunkEvent;
            myTestWorld.ChunkChanged += OnChunkEvent;

            myTestWorld.Generate( 1024, 1024, 4 );

            myGeoShader.CameraPosition = new Vector3( 0.0f, 1024.0f, 0.0f );
            */

            GL.ClearColor( new Color4( 223, 186, 168, 255 ) );

            myFrameTimer.Start();
        }
コード例 #2
0
ファイル: UIObject.cs プロジェクト: vashage/MarsMiner
        public void AddChild( UIObject child )
        {
            if ( child.myParent != null )
                child.myParent.RemoveChild( child );

            myChildren.Add( child );
            child.myParent = this;

            if ( child is UIWindow )
            {
                ( child as UIWindow ).Closed += delegate( object sender, EventArgs e )
                {
                    RemoveChild( sender as UIWindow );
                };
            }
        }
コード例 #3
0
ファイル: UIObject.cs プロジェクト: vashage/MarsMiner
 public void RemoveChild( UIObject child )
 {
     if ( myChildren.Contains( child ) )
     {
         myChildren.Remove( child );
         child.myParent = null;
     }
 }
コード例 #4
0
        public void SendMouseButtonEvent(Vector2 mousePos, OpenTK.Input.MouseButtonEventArgs e)
        {
            if (e.IsPressed)
            {
                if (myChildren.Count > 0)
                {
                    UIObject intersector = null;

                    for (int i = myChildren.Count - 1; i >= 0; --i)
                    {
                        UIObject child = myChildren[i];

                        Vector2 relativePos = mousePos - myPaddingTopLeft - child.Position;

                        if (child.IsVisible && (intersector = child.GetFirstIntersector(relativePos)) != null)
                        {
                            if (child.IsEnabled)
                            {
                                if (child.CanBringToFront)
                                {
                                    myChildren.Remove(child);
                                    myChildren.Add(child);
                                }

                                child.SendMouseButtonEvent(relativePos, e);
                            }

                            if (IsEnabled)
                            {
                                Focus();

                                if (!child.IsEnabled)
                                {
                                    foreach (UIObject ch in myChildren)
                                    {
                                        if (ch.IsFocused)
                                        {
                                            ch.UnFocus();
                                        }
                                    }

                                    myMouseDown = true;
                                    OnMouseDown(mousePos, e.Button);
                                    if (MouseDown != null)
                                    {
                                        MouseDown(this, e);
                                    }
                                }
                            }
                            return;
                        }
                    }
                }

                if (CheckPositionWithinBounds(mousePos))
                {
                    if (IsEnabled)
                    {
                        Focus();

                        foreach (UIObject ch in myChildren)
                        {
                            if (ch.IsFocused)
                            {
                                ch.UnFocus();
                            }
                        }

                        myMouseDown = true;
                        OnMouseDown(mousePos, e.Button);
                        if (MouseDown != null)
                        {
                            MouseDown(this, e);
                        }
                    }
                }
            }
            else
            {
                UIObject intersector = null;

                if (IsVisible && (intersector = GetFirstIntersector(mousePos)) != null)
                {
                    OnMouseUp(mousePos, e.Button);
                    if (MouseUp != null)
                    {
                        MouseUp(this, e);
                    }
                }

                if (myMouseDown)
                {
                    myMouseDown = false;

                    if (IsVisible && intersector != null)
                    {
                        OnClick(mousePos, e.Button);

                        if (Click != null)
                        {
                            Click(this, e);
                        }
                    }
                }
                else
                {
                    if (myChildren.Count > 0)
                    {
                        for (int i = myChildren.Count - 1; i >= 0 && i < myChildren.Count; --i)
                        {
                            UIObject child = myChildren[i];

                            Vector2 relativePos = mousePos - myPaddingTopLeft - child.Position;

                            if (child.IsEnabled)
                            {
                                child.SendMouseButtonEvent(relativePos, e);
                            }
                        }
                    }
                }
            }
        }