コード例 #1
0
 protected override void TextButtonClick( Game game, Widget widget )
 {
     string path = ((ButtonWidget)widget).Text;
     if( File.Exists( path ) ) {
         TexturePackExtractor extractor = new TexturePackExtractor();
         extractor.Extract( path, game );
     }
 }
コード例 #2
0
 public override bool HandlesKeyUp( Key key )
 {
     if( key == game.Mapping( KeyBinding.PlayerList ) ) {
         if( playerList != null ) {
             playerList.Dispose();
             playerList = null;
             return true;
         }
     }
     return false;
 }
コード例 #3
0
        protected bool HandleMouseClick( Widget[] widgets, int mouseX, int mouseY, MouseButton button )
        {
            if( button != MouseButton.Left ) return false;

            // iterate backwards (because last elements rendered are shown over others)
            for( int i = widgets.Length - 1; i >= 0; i-- ) {
                Widget widget = widgets[i];
                if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
                    if( widget.OnClick != null )
                        widget.OnClick( game, widget );
                    return true;
                }
            }
            return false;
        }
コード例 #4
0
 public override bool HandlesKeyDown( Key key )
 {
     if( key == game.Keys[KeyMapping.PlayerList] ) {
         if( playerList == null ) {
             if( game.Network.UsingExtPlayerList ) {
                 playerList = new ExtPlayerListWidget( game, playerFont );
             } else {
                 playerList = new NormalPlayerListWidget( game, playerFont );
             }
             playerList.Init();
         }
     }
     if( chat.HandlesKeyDown( key ) ) {
         return true;
     }
     return hotbar.HandlesKeyDown( key );
 }
コード例 #5
0
        protected bool HandleMouseMove( Widget[] widgets, int mouseX, int mouseY )
        {
            for( int i = 0; i < widgets.Length; i++ ) {
                if( widgets[i] == null ) continue;
                widgets[i].Active = false;
            }

            for( int i = widgets.Length - 1; i >= 0; i-- ) {
                Widget widget = widgets[i];
                if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
                    widget.Active = true;
                    WidgetSelected( widget );
                    return true;
                }
            }
            WidgetSelected( null );
            return false;
        }
コード例 #6
0
 public override void Render( double delta )
 {
     if( game.HideGui ) return;
     graphicsApi.Texturing = true;
     chat.Render( delta );
     hotbar.Render( delta );
     if( playerList != null ) {
         playerList.Render( delta );
         // NOTE: Should usually be caught by KeyUp, but just in case.
         if( !game.IsKeyDown( KeyMapping.PlayerList ) ) {
             playerList.Dispose();
             playerList = null;
         }
         graphicsApi.Texturing = false;
     } else {
         graphicsApi.Texturing = false;
         DrawCrosshairs();
     }
 }
コード例 #7
0
ファイル: FilesScreen.cs プロジェクト: Daribon/ClassicalSharp
 protected abstract void TextButtonClick( Game game, Widget widget );
コード例 #8
0
        void TextButtonClick( Game game, Widget widget )
        {
            LostFocus();
            ButtonWidget button = (ButtonWidget)widget;

            curHotkey = (Hotkey)button.Metadata;
            origHotkey = curHotkey;
            CreateEditingWidgets();
        }
コード例 #9
0
        void SaveChangesClick( Game game, Widget widget )
        {
            if( origHotkey.BaseKey != Key.Unknown ) {
                hotkeys.RemoveHotkey( origHotkey.BaseKey, origHotkey.Flags );
                hotkeys.UserRemovedHotkey( origHotkey.BaseKey, origHotkey.Flags );
            }

            if( curHotkey.BaseKey != Key.Unknown ) {
                hotkeys.AddHotkey( curHotkey.BaseKey, curHotkey.Flags,
                                  currentAction.GetText(), curHotkey.MoreInput );
                hotkeys.UserAddedHotkey( curHotkey.BaseKey, curHotkey.Flags,
                                        curHotkey.MoreInput, currentAction.GetText() );
            }

            for( int i = 0; i < numButtons; i++ )
                Set( i );
            DisposeEditingWidgets();
        }
コード例 #10
0
 protected override void TextButtonClick( Game game, Widget widget )
 {
     string path = ((ButtonWidget)widget).Text;
     if( File.Exists( path ) )
         LoadMap( path );
 }
コード例 #11
0
        public override void Render( double delta )
        {
            if( game.HideGui ) return;

            if( chat.HandlesAllInput )
                chat.RenderBackground();
            graphicsApi.Texturing = true;
            chat.Render( delta );
            hotbar.Render( delta );

            //graphicsApi.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
            //graphicsApi.BindTexture( game.TerrainAtlas.TexId );
            //IsometricBlockDrawer.Draw( game, (byte)Block.Brick, 30, game.Width - 50, game.Height - 20 );

            if( playerList != null ) {
                playerList.Render( delta );
                // NOTE: Should usually be caught by KeyUp, but just in case.
                if( !game.IsKeyDown( KeyBinding.PlayerList ) ) {
                    playerList.Dispose();
                    playerList = null;
                }
                graphicsApi.Texturing = false;
            } else {
                graphicsApi.Texturing = false;
                DrawCrosshairs();
            }
        }
コード例 #12
0
 void BaseKeyClick( Game game, Widget widget )
 {
     focusWidget = buttons[8];
     focusWidget.SetText( "Key: press a key.." );
     supressNextPress = true;
 }
コード例 #13
0
        void OnWidgetClick( Game game, Widget realWidget )
        {
            this.curWidget = (ButtonWidget)realWidget;
            int index = Array.IndexOf<ButtonWidget>( buttons, curWidget );
            statusWidget.Dispose();

            string text = "&ePress new key binding for " + descriptions[index] + ":";
            statusWidget = TextWidget.Create( game, 0, 150, text, Anchor.Centre, Anchor.Centre, regularFont );
        }
コード例 #14
0
        protected void OnWidgetClick( Game game, Widget widget )
        {
            if( widget == buttons[okayIndex] ) {
                ChangeSetting();
                return;
            }
            ButtonWidget button = (ButtonWidget)widget;

            int index = Array.IndexOf<ButtonWidget>( buttons, button );
            MenuInputValidator validator = validators[index];
            if( validator is BooleanValidator ) {
                string value = button.GetValue( game );
                button.SetValue( game, value == "yes" ? "no" : "yes" );
                UpdateDescription( button );
                return;
            }

            if( inputWidget != null )
                inputWidget.Dispose();

            targetWidget = selectedWidget;
            inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, button.GetValue( game ),
                                                 Anchor.Centre, Anchor.Centre, regularFont, titleFont,
                                                 hintFont, validator );
            buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 30, 30, "OK",
                                                     Anchor.Centre, Anchor.Centre, titleFont, OnWidgetClick );
            UpdateDescription( targetWidget );
        }
コード例 #15
0
        protected override void WidgetSelected( Widget widget )
        {
            ButtonWidget button = (ButtonWidget)widget;
            if( selectedWidget == button || button == null ||
               button == buttons[buttons.Length - 2] ) return;

            selectedWidget = button;
            if( targetWidget != null ) return;
            UpdateDescription( selectedWidget );
        }
コード例 #16
0
 protected virtual void WidgetSelected( Widget widget )
 {
 }
コード例 #17
0
        void OkButtonClick( Game game, Widget widget )
        {
            string text = inputWidget.GetText();
            if( text.Length == 0 ) {
                MakeDescWidget( "Please enter a filename" );
                return;
            }
            text = Path.ChangeExtension( text, ".cw" );

            if( File.Exists( text ) ) {
                MakeDescWidget( "&eFilename already exists" );
            } else {
                // NOTE: We don't immediately save here, because otherwise the 'saving...'
                // will not be rendered in time because saving is done on the main thread.
                MakeDescWidget( "Saving.." );
                textPath = text;
            }
        }
コード例 #18
0
 void LeaveOpenClick( Game game, Widget widget )
 {
     LostFocus();
     curHotkey.MoreInput = !curHotkey.MoreInput;
     buttons[10].SetText( curHotkey.MoreInput ? "yes" : "no" );
 }
コード例 #19
0
 void OnNoClick( Game g, Widget w )
 {
     if( noClick != null )
         noClick( this );
     Dispose();
     CloseScreen();
 }
コード例 #20
0
 void ModifiersClick( Game game, Widget widget )
 {
     focusWidget = buttons[9];
     focusWidget.SetText( "Modifiers: press a key.." );
     supressNextPress = true;
 }
コード例 #21
0
        void RemoveHotkeyClick( Game game, Widget widget )
        {
            if( origHotkey.BaseKey != Key.Unknown ) {
                hotkeys.RemoveHotkey( origHotkey.BaseKey, origHotkey.Flags );
                hotkeys.UserRemovedHotkey( origHotkey.BaseKey, origHotkey.Flags );
            }

            for( int i = 0; i < numButtons; i++ )
                Set( i );
            DisposeEditingWidgets();
        }
コード例 #22
0
 void OnYesClick( Game g, Widget w )
 {
     if( yesClick != null )
         yesClick( this );
     Dispose();
     CloseScreen();
 }
コード例 #23
0
        void TextButtonClick( Game game, Widget widget )
        {
            LostFocus();
            ButtonWidget button = (ButtonWidget)widget;

            if( button.Metadata != null ) {
                curHotkey = (Hotkey)button.Metadata;
                origHotkey = curHotkey;
                // do stuff here
                CreateEditingWidgets();
            }
        }