mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Allow changing of all colours of buttons in launcher.
This commit is contained in:
parent
5c90c62395
commit
81689a65d9
@ -6,19 +6,15 @@ namespace Launcher2 {
|
||||
|
||||
public sealed class LauncherButtonWidget : LauncherWidget {
|
||||
|
||||
public int ButtonWidth, ButtonHeight;
|
||||
public bool Shadow = true;
|
||||
public bool Active = false;
|
||||
|
||||
public LauncherButtonWidget( LauncherWindow window ) : base( window ) {
|
||||
}
|
||||
|
||||
static FastColour backCol = new FastColour( 97, 81, 110 ), lineCol = new FastColour( 182, 158, 201 );
|
||||
static FastColour colActive = new FastColour( 185, 162, 204 ), col = new FastColour( 164, 138, 186 );
|
||||
public void DrawAt( IDrawer2D drawer, string text, Font font, Anchor horAnchor,
|
||||
Anchor verAnchor, int width, int height, int x, int y ) {
|
||||
ButtonWidth = width; ButtonHeight = height;
|
||||
Width = width + 2; Height = height + 2; // adjust for border size of 2
|
||||
Width = width; Height = height;
|
||||
CalculateOffset( x, y, horAnchor, verAnchor );
|
||||
Redraw( drawer, text, font );
|
||||
}
|
||||
@ -29,21 +25,22 @@ namespace Launcher2 {
|
||||
text = "&7" + Text;
|
||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||
Size size = drawer.MeasureSize( ref args );
|
||||
int width = ButtonWidth, height = ButtonHeight;
|
||||
int xOffset = width - size.Width, yOffset = height - size.Height;
|
||||
int xOffset = Width - size.Width, yOffset = Height - size.Height;
|
||||
|
||||
// draw box bounds first
|
||||
drawer.Clear( backCol, X + 1, Y, width - 2, border );
|
||||
drawer.Clear( backCol, X + 1, Y + height - border, width - 2, border );
|
||||
drawer.Clear( backCol, X, Y + 1, border, height - 2 );
|
||||
drawer.Clear( backCol, X + width - border, Y + 1, border, height - 2 );
|
||||
FastColour backCol = LauncherSkin.ButtonBackCol;
|
||||
drawer.Clear( backCol, X + 1, Y, Width - 2, border );
|
||||
drawer.Clear( backCol, X + 1, Y + Height - border, Width - 2, border );
|
||||
drawer.Clear( backCol, X, Y + 1, border, Height - 2 );
|
||||
drawer.Clear( backCol, X + Width - border, Y + 1, border, Height - 2 );
|
||||
|
||||
FastColour foreCol = Active ? colActive : col;
|
||||
drawer.Clear( foreCol, X + border, Y + border, width - border * 2, height - border * 2 );
|
||||
FastColour foreCol = Active ? LauncherSkin.ButtonForeActiveCol : LauncherSkin.ButtonForeCol;
|
||||
drawer.Clear( foreCol, X + border, Y + border, Width - border * 2, Height - border * 2 );
|
||||
args.SkipPartsCheck = true;
|
||||
drawer.DrawText( ref args, X + xOffset / 2, Y + yOffset / 2 );
|
||||
if( !Active )
|
||||
drawer.Clear( lineCol, X + border + 1, Y + border, width - (border * 2 + 1), border );
|
||||
if( !Active ) {
|
||||
FastColour lineCol = LauncherSkin.ButtonHighlightCol;
|
||||
drawer.Clear( lineCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,25 @@ namespace Launcher2 {
|
||||
public static FastColour BackgroundCol = new FastColour( 127, 107, 140 );
|
||||
//new FastColour( 104, 87, 119 );
|
||||
|
||||
public static FastColour ButtonBackCol = new FastColour( 97, 81, 110 );
|
||||
public static FastColour ButtonForeActiveCol = new FastColour( 185, 162, 204 );
|
||||
public static FastColour ButtonForeCol = new FastColour( 164, 138, 186 );
|
||||
public static FastColour ButtonHighlightCol = new FastColour( 182, 158, 201 );
|
||||
|
||||
public static void LoadFromOptions() {
|
||||
Get( "launcher-back-col", ref BackgroundCol );
|
||||
Get( "launcher-backcol", ref BackgroundCol );
|
||||
Get( "launcher-button-backcol", ref ButtonBackCol );
|
||||
Get( "launcher-button-foreactivecol", ref ButtonForeActiveCol );
|
||||
Get( "launcher-button-forecol", ref ButtonForeCol );
|
||||
Get( "launcher-button-highlightcol", ref ButtonHighlightCol );
|
||||
}
|
||||
|
||||
public static void SaveToOptions() {
|
||||
Options.Set( "launcher-backcol", BackgroundCol.ToRGBHexString() );
|
||||
Options.Set( "launcher-button-backcol", ButtonBackCol.ToRGBHexString() );
|
||||
Options.Set( "launcher-button-foreactivecol", ButtonForeActiveCol.ToRGBHexString() );
|
||||
Options.Set( "launcher-button-forecol", ButtonForeCol.ToRGBHexString() );
|
||||
Options.Set( "launcher-button-highlightcol", ButtonHighlightCol.ToRGBHexString() );
|
||||
}
|
||||
|
||||
static void Get( string key, ref FastColour col ) {
|
||||
@ -22,9 +38,5 @@ namespace Launcher2 {
|
||||
if( !FastColour.TryParse( value, out col ) )
|
||||
col = defaultCol;
|
||||
}
|
||||
|
||||
public static void SaveToOptions() {
|
||||
Options.Set( "launcher-back-col", BackgroundCol.ToRGBHexString() );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user