mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Add middle clicking, cleanup held block setting.
This commit is contained in:
parent
cbb301fc06
commit
81ae1012ee
@ -186,11 +186,7 @@ namespace ClassicalSharp {
|
||||
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||
if( button == MouseButton.Left && selectedIndex != -1 ) {
|
||||
BlockDrawInfo info = blocksTable[selectedIndex];
|
||||
try {
|
||||
Window.HeldBlock = info.BlockId;
|
||||
} catch( InvalidOperationException ) {
|
||||
Window.AddChat( "&e/client: &cThe server has forbidden you from changing your held block." );
|
||||
}
|
||||
Window.HeldBlock = info.BlockId;
|
||||
Window.SetNewScreen( new NormalScreen( Window ) );
|
||||
}
|
||||
return true;
|
||||
|
@ -18,11 +18,7 @@ namespace ClassicalSharp {
|
||||
|
||||
public override bool HandlesKeyDown( Key key ) {
|
||||
if( key >= Key.Number1 && key <= Key.Number9 ) {
|
||||
try {
|
||||
Window.HeldBlockIndex = (int)key - (int)Key.Number1;
|
||||
} catch( InvalidOperationException ) {
|
||||
Window.AddChat( "&e/client: &cThe server has forbidden you from changing your held block." );
|
||||
}
|
||||
Window.HeldBlockIndex = (int)key - (int)Key.Number1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -38,9 +38,17 @@ namespace ClassicalSharp {
|
||||
|
||||
void MouseButtonDown( object sender, MouseButtonEventArgs e ) {
|
||||
if( activeScreen == null || !activeScreen.HandlesMouseClick( e.X, e.Y, e.Button ) ) {
|
||||
bool left = e.Button == MouseButton.Left;
|
||||
bool right = e.Button == MouseButton.Right;
|
||||
PickBlocks( false, left, right );
|
||||
if( e.Button == MouseButton.Middle ) {
|
||||
if( SelectedPos == null || !Map.IsValidPos( SelectedPos.BlockPos ) ) return;
|
||||
byte block = Map.GetBlock( SelectedPos.BlockPos );
|
||||
if( CanPlace[block] || CanDelete[block] ) {
|
||||
HeldBlock = (Block)block;
|
||||
}
|
||||
} else {
|
||||
bool left = e.Button == MouseButton.Left;
|
||||
bool right = e.Button == MouseButton.Right;
|
||||
PickBlocks( false, left, right );
|
||||
}
|
||||
} else {
|
||||
lastClick = DateTime.UtcNow;
|
||||
}
|
||||
|
12
Game/Game.cs
12
Game/Game.cs
@ -57,8 +57,10 @@ namespace ClassicalSharp {
|
||||
public int HeldBlockIndex {
|
||||
get { return hotbarIndex; }
|
||||
set {
|
||||
if( !CanChangeHeldBlock )
|
||||
throw new InvalidOperationException( "Server has forbidden changing held block." );
|
||||
if( !CanChangeHeldBlock ) {
|
||||
AddChat( "&e/client: &cThe server has forbidden you from changing your held block." );
|
||||
return;
|
||||
}
|
||||
hotbarIndex = value;
|
||||
RaiseHeldBlockChanged();
|
||||
}
|
||||
@ -67,8 +69,10 @@ namespace ClassicalSharp {
|
||||
public Block HeldBlock {
|
||||
get { return BlocksHotbar[hotbarIndex]; }
|
||||
set {
|
||||
if( !CanChangeHeldBlock )
|
||||
throw new InvalidOperationException( "Server has forbidden changing held block." );
|
||||
if( !CanChangeHeldBlock ) {
|
||||
AddChat( "&e/client: &cThe server has forbidden you from changing your held block." );
|
||||
return;
|
||||
}
|
||||
BlocksHotbar[hotbarIndex] = value;
|
||||
RaiseHeldBlockChanged();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user