mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
If you click on a chatline in the normal chat widget while the text input bar is open, the chatline will be added to the text input bar.
This commit is contained in:
parent
70a2fc868f
commit
4f546b80d5
@ -282,6 +282,18 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||||
if( !HandlesAllInput ) return false;
|
if( !HandlesAllInput ) return false;
|
||||||
|
if( normalChat.Bounds.Contains( mouseX, mouseY ) ) {
|
||||||
|
int height = normalChat.GetUsedHeight();
|
||||||
|
int y = normalChat.Y + normalChat.Height - height;
|
||||||
|
if( new Rectangle( normalChat.X, y, normalChat.Width, height ).Contains( mouseX, mouseY ) ) {
|
||||||
|
string text = normalChat.GetSelected( mouseX, mouseY );
|
||||||
|
if( text != null ) {
|
||||||
|
textInput.AppendText(text);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return textInput.HandlesMouseClick( mouseX, mouseY, button );
|
return textInput.HandlesMouseClick( mouseX, mouseY, button );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,14 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Texture[] Textures;
|
public Texture[] Textures;
|
||||||
|
string[] lines;
|
||||||
int ElementsCount, defaultHeight;
|
int ElementsCount, defaultHeight;
|
||||||
public int XOffset = 0, YOffset = 0;
|
public int XOffset = 0, YOffset = 0;
|
||||||
readonly Font font;
|
readonly Font font;
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
Textures = new Texture[ElementsCount];
|
Textures = new Texture[ElementsCount];
|
||||||
|
lines = new string[ElementsCount];
|
||||||
DrawTextArgs args = new DrawTextArgs( "I", font, true );
|
DrawTextArgs args = new DrawTextArgs( "I", font, true );
|
||||||
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
|
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
|
||||||
|
|
||||||
@ -38,8 +40,10 @@ namespace ClassicalSharp {
|
|||||||
tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor );
|
tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor );
|
||||||
tex.Y1 = CalcY( index, tex.Height );
|
tex.Y1 = CalcY( index, tex.Height );
|
||||||
Textures[index] = tex;
|
Textures[index] = tex;
|
||||||
|
lines[index] = text;
|
||||||
} else {
|
} else {
|
||||||
Textures[index] = new Texture( -1, 0, 0, 0, defaultHeight, 0, 0 );
|
Textures[index] = new Texture( -1, 0, 0, 0, defaultHeight, 0, 0 );
|
||||||
|
lines[index] = null;
|
||||||
}
|
}
|
||||||
UpdateDimensions();
|
UpdateDimensions();
|
||||||
}
|
}
|
||||||
@ -49,6 +53,7 @@ namespace ClassicalSharp {
|
|||||||
graphicsApi.DeleteTexture( ref Textures[0] );
|
graphicsApi.DeleteTexture( ref Textures[0] );
|
||||||
for( int i = 0; i < Textures.Length - 1; i++ ) {
|
for( int i = 0; i < Textures.Length - 1; i++ ) {
|
||||||
Textures[i] = Textures[i + 1];
|
Textures[i] = Textures[i + 1];
|
||||||
|
lines[i] = lines[i + 1];
|
||||||
Textures[i].Y1 = y;
|
Textures[i].Y1 = y;
|
||||||
y += Textures[i].Height;
|
y += Textures[i].Height;
|
||||||
}
|
}
|
||||||
@ -123,5 +128,14 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
X = newX; Y = newY;
|
X = newX; Y = newY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetSelected( int mouseX, int mouseY ) {
|
||||||
|
for( int i = 0; i < Textures.Length; i++ ) {
|
||||||
|
if( Textures[i].IsValid &&
|
||||||
|
Textures[i].Bounds.Contains( mouseX, mouseY ) )
|
||||||
|
return lines[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user