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 ); } }
public override bool HandlesKeyUp( Key key ) { if( key == game.Mapping( KeyBinding.PlayerList ) ) { if( playerList != null ) { playerList.Dispose(); playerList = null; return true; } } return false; }
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; }
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 ); }
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; }
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(); } }
protected abstract void TextButtonClick( Game game, Widget widget );
void TextButtonClick( Game game, Widget widget ) { LostFocus(); ButtonWidget button = (ButtonWidget)widget; curHotkey = (Hotkey)button.Metadata; origHotkey = curHotkey; CreateEditingWidgets(); }
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(); }
protected override void TextButtonClick( Game game, Widget widget ) { string path = ((ButtonWidget)widget).Text; if( File.Exists( path ) ) LoadMap( path ); }
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(); } }
void BaseKeyClick( Game game, Widget widget ) { focusWidget = buttons[8]; focusWidget.SetText( "Key: press a key.." ); supressNextPress = true; }
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 ); }
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 ); }
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 ); }
protected virtual void WidgetSelected( Widget widget ) { }
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; } }
void LeaveOpenClick( Game game, Widget widget ) { LostFocus(); curHotkey.MoreInput = !curHotkey.MoreInput; buttons[10].SetText( curHotkey.MoreInput ? "yes" : "no" ); }
void OnNoClick( Game g, Widget w ) { if( noClick != null ) noClick( this ); Dispose(); CloseScreen(); }
void ModifiersClick( Game game, Widget widget ) { focusWidget = buttons[9]; focusWidget.SetText( "Modifiers: press a key.." ); supressNextPress = true; }
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(); }
void OnYesClick( Game g, Widget w ) { if( yesClick != null ) yesClick( this ); Dispose(); CloseScreen(); }
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(); } }