mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Separate launcher draw data setting from launcher widget redrawing.
This commit is contained in:
parent
b46f2cff5f
commit
7ff7386b6e
@ -113,7 +113,7 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
void DrawBackground() {
|
void DrawBackground() {
|
||||||
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) ) {
|
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) ) {
|
||||||
game.ClearArea( 0, 0, game.Width, tableY, dst );
|
game.ClearArea( 0, 0, game.Width, tableY, dst );
|
||||||
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
|
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
|
||||||
Rectangle rec = new Rectangle( tableX, tableY, game.Width - tableX, tableHeight );
|
Rectangle rec = new Rectangle( tableX, tableY, game.Width - tableX, tableHeight );
|
||||||
|
|
||||||
@ -128,24 +128,24 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
void MakeTableWidget() {
|
void MakeTableWidget() {
|
||||||
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
|
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
|
||||||
|
LauncherTableWidget widget;
|
||||||
if( widgets[tableIndex] != null ) {
|
if( widgets[tableIndex] != null ) {
|
||||||
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
widget = (LauncherTableWidget)widgets[tableIndex];
|
||||||
table.Height = tableHeight;
|
} else {
|
||||||
table.Redraw( drawer, tableFont, inputFont, inputFont );
|
widget = new LauncherTableWidget( game );
|
||||||
return;
|
widget.CurrentIndex = 0;
|
||||||
|
widget.SetEntries( game.Session.Servers );
|
||||||
|
|
||||||
|
widget.SetDrawData( drawer, tableFont, inputFont, inputFont,
|
||||||
|
Anchor.LeftOrTop, Anchor.LeftOrTop, tableX, tableY );
|
||||||
|
widget.NeedRedraw = Resize;
|
||||||
|
widget.SelectedChanged = SelectedChanged;
|
||||||
|
widgets[widgetIndex] = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherTableWidget widget = new LauncherTableWidget( game );
|
|
||||||
widget.CurrentIndex = 0;
|
|
||||||
widget.SetEntries( game.Session.Servers );
|
|
||||||
|
|
||||||
widget.Height = tableHeight;
|
widget.Height = tableHeight;
|
||||||
|
widget.Redraw( drawer );
|
||||||
widget.DrawAt( drawer, tableFont, inputFont, inputFont,
|
widgetIndex++;
|
||||||
Anchor.LeftOrTop, Anchor.LeftOrTop, tableX, tableY );
|
|
||||||
widget.NeedRedraw = Resize;
|
|
||||||
widget.SelectedChanged = SelectedChanged;
|
|
||||||
widgets[widgetIndex++] = widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterList() {
|
void FilterList() {
|
||||||
|
@ -55,8 +55,9 @@ namespace Launcher2 {
|
|||||||
game.ClearArea( widget.X, widget.Y, widget.Width, widget.Height );
|
game.ClearArea( widget.X, widget.Y, widget.Width, widget.Height );
|
||||||
|
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
widget.DrawAt( drawer, text, inputFont, Anchor.Centre, Anchor.Centre, 0, 100 );
|
widget.SetDrawData( drawer, text, inputFont, Anchor.Centre, Anchor.Centre, 0, 100 );
|
||||||
|
widget.Redraw( drawer );
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,8 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
lastInput.Redraw( drawer, lastInput.Text, inputFont, inputHintFont );
|
lastInput.SetDrawData( drawer, lastInput.Text );
|
||||||
|
lastInput.Redraw( drawer );
|
||||||
if( caretShow )
|
if( caretShow )
|
||||||
lastInput.DrawCaret( drawer, inputFont );
|
lastInput.DrawCaret( drawer, inputFont );
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
@ -114,11 +115,11 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
protected virtual void RedrawLastInput() {
|
protected virtual void RedrawLastInput() {
|
||||||
if( lastInput.Width > lastInput.ButtonWidth )
|
if( lastInput.Width > lastInput.ButtonWidth )
|
||||||
game.ClearArea( lastInput.X, lastInput.Y, lastInput.Width + 1, lastInput.Height + 1 );
|
game.ClearArea( lastInput.X, lastInput.Y, lastInput.Width, lastInput.Height );
|
||||||
|
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
lastInput.Redraw( drawer, lastInput.Text, inputFont, inputHintFont );
|
lastInput.Redraw( drawer );
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,8 +136,8 @@ namespace Launcher2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void Set( int index, string text ) {
|
protected void Set( int index, string text ) {
|
||||||
((LauncherInputWidget)widgets[index])
|
((LauncherInputWidget)widgets[index]).SetDrawData( drawer, text );
|
||||||
.Redraw( drawer, text, inputFont, inputHintFont );
|
((LauncherInputWidget)widgets[index]).Redraw( drawer );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
protected virtual void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
||||||
@ -149,14 +150,14 @@ namespace Launcher2 {
|
|||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
if( lastInput != null ) {
|
if( lastInput != null ) {
|
||||||
lastInput.Active = false;
|
lastInput.Active = false;
|
||||||
lastInput.Redraw( drawer, lastInput.Text, inputFont, inputHintFont );
|
lastInput.Redraw( drawer );
|
||||||
}
|
}
|
||||||
|
|
||||||
input.Active = true;
|
input.Active = true;
|
||||||
widgetOpenTime = DateTime.UtcNow;
|
widgetOpenTime = DateTime.UtcNow;
|
||||||
lastCaretFlash = false;
|
lastCaretFlash = false;
|
||||||
input.SetCaretToCursor( mouseX, mouseY, drawer, inputFont );
|
input.SetCaretToCursor( mouseX, mouseY, drawer, inputFont );
|
||||||
input.Redraw( drawer, input.Text, inputFont, inputHintFont );
|
input.Redraw( drawer );
|
||||||
}
|
}
|
||||||
lastInput = input;
|
lastInput = input;
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
@ -168,7 +169,7 @@ namespace Launcher2 {
|
|||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
input.Active = false;
|
input.Active = false;
|
||||||
input.Redraw( drawer, lastInput.Text, inputFont, inputHintFont );
|
input.Redraw( drawer );
|
||||||
}
|
}
|
||||||
lastInput = null;
|
lastInput = null;
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
@ -181,21 +182,21 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
protected void MakeInput( string text, int width, Anchor horAnchor, Anchor verAnchor,
|
protected void MakeInput( string text, int width, Anchor horAnchor, Anchor verAnchor,
|
||||||
bool password, int x, int y, int maxChars, string hint ) {
|
bool password, int x, int y, int maxChars, string hint ) {
|
||||||
|
LauncherInputWidget widget;
|
||||||
if( widgets[widgetIndex] != null ) {
|
if( widgets[widgetIndex] != null ) {
|
||||||
LauncherInputWidget input = (LauncherInputWidget)widgets[widgetIndex];
|
widget = (LauncherInputWidget)widgets[widgetIndex];
|
||||||
input.DrawAt( drawer, text, inputFont, inputHintFont, horAnchor, verAnchor, width, 30, x, y );
|
} else {
|
||||||
widgetIndex++;
|
widget = new LauncherInputWidget( game );
|
||||||
return;
|
widget.OnClick = InputClick;
|
||||||
|
widget.Password = password;
|
||||||
|
widget.MaxTextLength = maxChars;
|
||||||
|
widget.HintText = hint;
|
||||||
|
widgets[widgetIndex] = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherInputWidget widget = new LauncherInputWidget( game );
|
widget.SetDrawData( drawer, text, inputFont, inputHintFont, horAnchor, verAnchor, width, 30, x, y );
|
||||||
widget.OnClick = InputClick;
|
widget.Redraw( drawer );
|
||||||
widget.Password = password;
|
widgetIndex++;
|
||||||
widget.MaxTextLength = maxChars;
|
|
||||||
widget.HintText = hint;
|
|
||||||
|
|
||||||
widget.DrawAt( drawer, text, inputFont, inputHintFont, horAnchor, verAnchor, width, 30, x, y );
|
|
||||||
widgets[widgetIndex++] = widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
|
@ -67,7 +67,7 @@ namespace Launcher2 {
|
|||||||
button.RedrawBackground();
|
button.RedrawBackground();
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
button.Redraw( drawer, button.Text, buttonFont );
|
button.Redraw( drawer );
|
||||||
}
|
}
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ namespace Launcher2 {
|
|||||||
button.RedrawBackground();
|
button.RedrawBackground();
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
button.Redraw( drawer, button.Text, buttonFont );
|
button.Redraw( drawer );
|
||||||
}
|
}
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
@ -150,47 +150,50 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
protected void MakeButtonAt( string text, int width, int height, Font font, Anchor horAnchor,
|
protected void MakeButtonAt( string text, int width, int height, Font font, Anchor horAnchor,
|
||||||
Anchor verAnchor, int x, int y, Action<int, int> onClick ) {
|
Anchor verAnchor, int x, int y, Action<int, int> onClick ) {
|
||||||
|
LauncherButtonWidget widget;
|
||||||
if( widgets[widgetIndex] != null ) {
|
if( widgets[widgetIndex] != null ) {
|
||||||
LauncherButtonWidget button = (LauncherButtonWidget)widgets[widgetIndex];
|
widget = (LauncherButtonWidget)widgets[widgetIndex];
|
||||||
button.Active = false;
|
} else {
|
||||||
button.DrawAt( drawer, text, font, horAnchor, verAnchor, width, height, x, y );
|
widget = new LauncherButtonWidget( game );
|
||||||
widgetIndex++;
|
widget.Text = text;
|
||||||
return;
|
widget.OnClick = onClick;
|
||||||
|
widgets[widgetIndex] = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherButtonWidget widget = new LauncherButtonWidget( game );
|
|
||||||
widget.Text = text;
|
|
||||||
widget.OnClick = onClick;
|
|
||||||
|
|
||||||
widget.Active = false;
|
widget.Active = false;
|
||||||
widget.DrawAt( drawer, text, font, horAnchor, verAnchor, width, height, x, y );
|
widget.SetDrawData( drawer, text, font, horAnchor, verAnchor, width, height, x, y );
|
||||||
widgets[widgetIndex++] = widget;
|
widget.Redraw( drawer );
|
||||||
|
widgetIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MakeLabelAt( string text, Font font, Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
protected void MakeLabelAt( string text, Font font, Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
||||||
|
LauncherLabelWidget widget;
|
||||||
if( widgets[widgetIndex] != null ) {
|
if( widgets[widgetIndex] != null ) {
|
||||||
LauncherLabelWidget label = (LauncherLabelWidget)widgets[widgetIndex];
|
widget = (LauncherLabelWidget)widgets[widgetIndex];
|
||||||
label.DrawAt( drawer, text, font, horAnchor, verAnchor, x, y );
|
|
||||||
} else {
|
} else {
|
||||||
LauncherLabelWidget widget = new LauncherLabelWidget( game, text );
|
widget = new LauncherLabelWidget( game, text );
|
||||||
widget.DrawAt( drawer, text, font, horAnchor, verAnchor, x, y );
|
|
||||||
widgets[widgetIndex] = widget;
|
widgets[widgetIndex] = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.SetDrawData( drawer, text, font, horAnchor, verAnchor, x, y );
|
||||||
|
widget.Redraw( drawer );
|
||||||
widgetIndex++;
|
widgetIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MakeBooleanAt( Anchor horAnchor, Anchor verAnchor, Font font, bool initValue,
|
protected void MakeBooleanAt( Anchor horAnchor, Anchor verAnchor, Font font, bool initValue,
|
||||||
int width, int height, int x, int y, Action<int, int> onClick ) {
|
int width, int height, int x, int y, Action<int, int> onClick ) {
|
||||||
|
LauncherBooleanWidget widget;
|
||||||
if( widgets[widgetIndex] != null ) {
|
if( widgets[widgetIndex] != null ) {
|
||||||
LauncherBooleanWidget widget = (LauncherBooleanWidget)widgets[widgetIndex];
|
widget = (LauncherBooleanWidget)widgets[widgetIndex];
|
||||||
widget.DrawAt( drawer, horAnchor, verAnchor, x, y );
|
|
||||||
} else {
|
} else {
|
||||||
LauncherBooleanWidget widget = new LauncherBooleanWidget( game, font, width, height );
|
widget = new LauncherBooleanWidget( game, font, width, height );
|
||||||
widget.Value = initValue;
|
widget.Value = initValue;
|
||||||
widget.DrawAt( drawer, horAnchor, verAnchor, x, y );
|
|
||||||
widget.OnClick = onClick;
|
widget.OnClick = onClick;
|
||||||
widgets[widgetIndex] = widget;
|
widgets[widgetIndex] = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.SetDrawData( drawer, horAnchor, verAnchor, x, y );
|
||||||
|
widget.Redraw( drawer );
|
||||||
widgetIndex++;
|
widgetIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,8 @@ namespace Launcher2 {
|
|||||||
game.ClearArea( widget.X, widget.Y, widget.Width, widget.Height );
|
game.ClearArea( widget.X, widget.Y, widget.Width, widget.Height );
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
widget.DrawAt( drawer, text, inputFont, Anchor.Centre, Anchor.Centre, 0, 20 );
|
widget.SetDrawData( drawer, text, inputFont, Anchor.Centre, Anchor.Centre, 0, 20 );
|
||||||
|
widget.Redraw( drawer );
|
||||||
}
|
}
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,8 @@ namespace Launcher2 {
|
|||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
drawer.Clear( backCol, widget.X, widget.Y, widget.Width, widget.Height );
|
drawer.Clear( backCol, widget.X, widget.Y, widget.Width, widget.Height );
|
||||||
widget.Redraw( drawer, text, statusFont );
|
widget.SetDrawData( drawer, text, statusFont, Anchor.Centre, Anchor.Centre, 0, 5 );
|
||||||
|
widget.Redraw( drawer );
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ namespace Launcher2 {
|
|||||||
MakeLabelAt( "Update to dev build", titleFont, Anchor.Centre, Anchor.Centre, -120, 30 );
|
MakeLabelAt( "Update to dev build", titleFont, Anchor.Centre, Anchor.Centre, -120, 30 );
|
||||||
MakeLabelAt( "Latest dev:", infoFont, Anchor.Centre, Anchor.Centre, -100, 60 );
|
MakeLabelAt( "Latest dev:", infoFont, Anchor.Centre, Anchor.Centre, -100, 60 );
|
||||||
string latestDev = GetDateString( lastDev, validDev );
|
string latestDev = GetDateString( lastDev, validDev );
|
||||||
MakeLabelAt( latestDev, infoFont, Anchor.Centre, Anchor.Centre, 30, 60 );
|
MakeLabelAt( latestDev, infoFont, Anchor.Centre, Anchor.Centre, 50, 60 );
|
||||||
MakeButtonAt( "Direct3D 9", 130, 30, titleFont, Anchor.Centre, -80, 95,
|
MakeButtonAt( "Direct3D 9", 130, 30, titleFont, Anchor.Centre, -80, 95,
|
||||||
(x, y) => UpdateBuild( lastDev, validDev, false, true ) );
|
(x, y) => UpdateBuild( lastDev, validDev, false, true ) );
|
||||||
MakeButtonAt( "OpenGL", 130, 30, titleFont, Anchor.Centre, 80, 95,
|
MakeButtonAt( "OpenGL", 130, 30, titleFont, Anchor.Centre, 80, 95,
|
||||||
|
@ -67,13 +67,16 @@ namespace Launcher2 {
|
|||||||
public int Y, Height;
|
public int Y, Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawAt( IDrawer2D drawer, Font font, Font titleFont, Font boldFont,
|
Font font, titleFont, boldFont;
|
||||||
|
public void SetDrawData( IDrawer2D drawer, Font font, Font titleFont, Font boldFont,
|
||||||
Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
||||||
CalculateOffset( x, y, horAnchor, verAnchor );
|
CalculateOffset( x, y, horAnchor, verAnchor );
|
||||||
Redraw( drawer, font, titleFont, boldFont );
|
this.font = font;
|
||||||
|
this.titleFont = titleFont;
|
||||||
|
this.boldFont = boldFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Redraw( IDrawer2D drawer, Font font, Font titleFont, Font boldFont ) {
|
public override void Redraw( IDrawer2D drawer ) {
|
||||||
for( int i = 0; i < ColumnWidths.Length; i++ ) {
|
for( int i = 0; i < ColumnWidths.Length; i++ ) {
|
||||||
ColumnWidths[i] = DesiredColumnWidths[i];
|
ColumnWidths[i] = DesiredColumnWidths[i];
|
||||||
Utils.Clamp( ref ColumnWidths[i], 20, Window.Width - 20 );
|
Utils.Clamp( ref ColumnWidths[i], 20, Window.Width - 20 );
|
||||||
|
@ -17,12 +17,11 @@ namespace Launcher2 {
|
|||||||
this.font = font;
|
this.font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawAt( IDrawer2D drawer, Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
public void SetDrawData( IDrawer2D drawer, Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
||||||
CalculateOffset( x, y, horAnchor, verAnchor );
|
CalculateOffset( x, y, horAnchor, verAnchor );
|
||||||
Redraw( drawer );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Redraw( IDrawer2D drawer ) {
|
public override void Redraw( IDrawer2D drawer ) {
|
||||||
drawer.DrawRect( FastColour.Black, X, Y, Width, Height );
|
drawer.DrawRect( FastColour.Black, X, Y, Width, Height );
|
||||||
if( Value ) {
|
if( Value ) {
|
||||||
DrawTextArgs args = new DrawTextArgs( "X", font, false );
|
DrawTextArgs args = new DrawTextArgs( "X", font, false );
|
||||||
|
@ -9,33 +9,36 @@ namespace Launcher2 {
|
|||||||
public bool Shadow = true;
|
public bool Shadow = true;
|
||||||
public bool Active = false;
|
public bool Active = false;
|
||||||
const int border = 2;
|
const int border = 2;
|
||||||
|
Size textSize;
|
||||||
|
Font font;
|
||||||
|
|
||||||
public LauncherButtonWidget( LauncherWindow window ) : base( window ) {
|
public LauncherButtonWidget( LauncherWindow window ) : base( window ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawAt( IDrawer2D drawer, string text, Font font, Anchor horAnchor,
|
public void SetDrawData( IDrawer2D drawer, string text, Font font, Anchor horAnchor,
|
||||||
Anchor verAnchor, int width, int height, int x, int y ) {
|
Anchor verAnchor, int width, int height, int x, int y ) {
|
||||||
Width = width; Height = height;
|
Width = width; Height = height;
|
||||||
CalculateOffset( x, y, horAnchor, verAnchor );
|
CalculateOffset( x, y, horAnchor, verAnchor );
|
||||||
RedrawBackground();
|
this.font = font;
|
||||||
Redraw( drawer, text, font );
|
|
||||||
|
Text = text;
|
||||||
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
|
textSize = drawer.MeasureSize( ref args );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Redraw( IDrawer2D drawer, string text, Font font ) {
|
public override void Redraw( IDrawer2D drawer ) {
|
||||||
Text = text;
|
string text = Text;
|
||||||
if( !Active )
|
if( !Active ) text = "&7" + text;
|
||||||
text = "&7" + text;
|
int xOffset = Width - textSize.Width, yOffset = Height - textSize.Height;
|
||||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
Size size = drawer.MeasureSize( ref args );
|
|
||||||
int xOffset = Width - size.Width, yOffset = Height - size.Height;
|
|
||||||
|
|
||||||
|
RedrawBackground();
|
||||||
DrawBorder( drawer );
|
DrawBorder( drawer );
|
||||||
if( Window.ClassicMode )
|
if( Window.ClassicMode )
|
||||||
DrawClassic( drawer, ref args, xOffset, yOffset );
|
DrawClassic( drawer, xOffset, yOffset );
|
||||||
else
|
else
|
||||||
DrawNormal( drawer, ref args, xOffset, yOffset );
|
DrawNormal( drawer, xOffset, yOffset );
|
||||||
|
|
||||||
args.SkipPartsCheck = true;
|
|
||||||
drawer.DrawText( ref args, X + xOffset / 2, Y + yOffset / 2 );
|
drawer.DrawText( ref args, X + xOffset / 2, Y + yOffset / 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,13 +50,13 @@ namespace Launcher2 {
|
|||||||
drawer.Clear( backCol, X + Width - border, Y + 1, border, Height - 2 );
|
drawer.Clear( backCol, X + Width - border, Y + 1, border, Height - 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawNormal( IDrawer2D drawer, ref DrawTextArgs args, int xOffset, int yOffset ) {
|
void DrawNormal( IDrawer2D drawer, int xOffset, int yOffset ) {
|
||||||
if( Active ) return;
|
if( Active ) return;
|
||||||
FastColour lineCol = LauncherSkin.ButtonHighlightCol;
|
FastColour lineCol = LauncherSkin.ButtonHighlightCol;
|
||||||
drawer.Clear( lineCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
|
drawer.Clear( lineCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawClassic( IDrawer2D drawer, ref DrawTextArgs args, int xOffset, int yOffset ) {
|
void DrawClassic( IDrawer2D drawer, int xOffset, int yOffset ) {
|
||||||
FastColour highlightCol = Active ? new FastColour( 189, 198, 255 ) : new FastColour( 168, 168, 168 );
|
FastColour highlightCol = Active ? new FastColour( 189, 198, 255 ) : new FastColour( 168, 168, 168 );
|
||||||
drawer.Clear( highlightCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
|
drawer.Clear( highlightCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
|
||||||
drawer.Clear( highlightCol, X + border, Y + border + 1, border, Height - (border * 2 + 1) );
|
drawer.Clear( highlightCol, X + border, Y + border + 1, border, Height - (border * 2 + 1) );
|
||||||
|
@ -33,24 +33,42 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
public int CaretPos = -1;
|
public int CaretPos = -1;
|
||||||
|
|
||||||
|
Font font, hintFont;
|
||||||
|
int textHeight;
|
||||||
public LauncherInputWidget( LauncherWindow window ) : base( window ) {
|
public LauncherInputWidget( LauncherWindow window ) : base( window ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawAt( IDrawer2D drawer, string text, Font font, Font hintFont,
|
public void SetDrawData( IDrawer2D drawer, string text, Font font, Font hintFont,
|
||||||
Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y ) {
|
Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y ) {
|
||||||
ButtonWidth = width; ButtonHeight = height;
|
ButtonWidth = width; ButtonHeight = height;
|
||||||
Width = width; Height = height;
|
Width = width; Height = height;
|
||||||
CalculateOffset( x, y, horAnchor, verAnchor );
|
CalculateOffset( x, y, horAnchor, verAnchor );
|
||||||
Redraw( drawer, text, font, hintFont );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Redraw( IDrawer2D drawer, string text, Font font, Font hintFont ) {
|
|
||||||
Text = text;
|
Text = text;
|
||||||
if( Password )
|
if( Password ) text = new String( '*', text.Length );
|
||||||
text = new String( '*', text.Length );
|
this.font = font;
|
||||||
|
this.hintFont = hintFont;
|
||||||
|
|
||||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
Size size = drawer.MeasureSize( ref args );
|
Size size = drawer.MeasureSize( ref args );
|
||||||
Width = Math.Max( ButtonWidth, size.Width + 7 );
|
Width = Math.Max( ButtonWidth, size.Width + 15 );
|
||||||
|
textHeight = size.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDrawData( IDrawer2D drawer, string text ) {
|
||||||
|
Text = text;
|
||||||
|
if( Password ) text = new String( '*', text.Length );
|
||||||
|
|
||||||
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
|
Size size = drawer.MeasureSize( ref args );
|
||||||
|
Width = Math.Max( ButtonWidth, size.Width + 15 );
|
||||||
|
textHeight = size.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Redraw( IDrawer2D drawer ) {
|
||||||
|
string text = Text;
|
||||||
|
if( Password ) text = new String( '*', text.Length );
|
||||||
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
|
|
||||||
FastColour col = Active ? new FastColour( 240, 240, 240 ) : new FastColour( 180, 180, 180 );
|
FastColour col = Active ? new FastColour( 240, 240, 240 ) : new FastColour( 180, 180, 180 );
|
||||||
drawer.Clear( col, X + 1, Y, Width - 2, 2 );
|
drawer.Clear( col, X + 1, Y, Width - 2, 2 );
|
||||||
@ -59,9 +77,8 @@ namespace Launcher2 {
|
|||||||
drawer.Clear( col, X + Width - 2, Y + 1, 2, Height - 2 );
|
drawer.Clear( col, X + Width - 2, Y + 1, 2, Height - 2 );
|
||||||
drawer.Clear( FastColour.Black, X + 2, Y + 2, Width - 4, Height - 4 );
|
drawer.Clear( FastColour.Black, X + 2, Y + 2, Width - 4, Height - 4 );
|
||||||
|
|
||||||
args.SkipPartsCheck = true;
|
|
||||||
if( Text.Length != 0 || HintText == null ) {
|
if( Text.Length != 0 || HintText == null ) {
|
||||||
int y = Y + 2 + (Height - size.Height) / 2;
|
int y = Y + 2 + (Height - textHeight) / 2;
|
||||||
drawer.DrawText( ref args, X + 5, y );
|
drawer.DrawText( ref args, X + 5, y );
|
||||||
} else {
|
} else {
|
||||||
args.SkipPartsCheck = false;
|
args.SkipPartsCheck = false;
|
||||||
|
@ -7,28 +7,25 @@ namespace Launcher2 {
|
|||||||
/// <summary> Widget that represents text that cannot be modified by the user. </summary>
|
/// <summary> Widget that represents text that cannot be modified by the user. </summary>
|
||||||
public sealed class LauncherLabelWidget : LauncherWidget {
|
public sealed class LauncherLabelWidget : LauncherWidget {
|
||||||
|
|
||||||
|
Font font;
|
||||||
public LauncherLabelWidget( LauncherWindow window, string text ) : base( window ) {
|
public LauncherLabelWidget( LauncherWindow window, string text ) : base( window ) {
|
||||||
Text = text;
|
Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawAt( IDrawer2D drawer, string text, Font font,
|
public void SetDrawData( IDrawer2D drawer, string text, Font font,
|
||||||
Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
Anchor horAnchor, Anchor verAnchor, int x, int y ) {
|
||||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||||
Size size = drawer.MeasureSize( ref args );
|
Size size = drawer.MeasureSize( ref args );
|
||||||
Width = size.Width; Height = size.Height;
|
Width = size.Width; Height = size.Height;
|
||||||
|
|
||||||
CalculateOffset( x, y, horAnchor, verAnchor );
|
CalculateOffset( x, y, horAnchor, verAnchor );
|
||||||
Redraw( drawer, text, font );
|
Text = text;
|
||||||
|
this.font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Redraw( IDrawer2D drawer, string text, Font font ) {
|
public override void Redraw( IDrawer2D drawer ) {
|
||||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
DrawTextArgs args = new DrawTextArgs( Text, font, true );
|
||||||
Size size = drawer.MeasureSize( ref args );
|
|
||||||
Width = size.Width; Height = size.Height;
|
|
||||||
|
|
||||||
args.SkipPartsCheck = true;
|
|
||||||
drawer.DrawText( ref args, X, Y );
|
drawer.DrawText( ref args, X, Y );
|
||||||
Text = text;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,7 @@ namespace Launcher2 {
|
|||||||
else if( verAnchor == Anchor.Centre ) Y = y + Window.Height / 2 - Height / 2;
|
else if( verAnchor == Anchor.Centre ) Y = y + Window.Height / 2 - Height / 2;
|
||||||
else if( verAnchor == Anchor.BottomOrRight ) Y = y + Window.Height - Height;
|
else if( verAnchor == Anchor.BottomOrRight ) Y = y + Window.Height - Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void Redraw( IDrawer2D drawer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user