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