mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Optimise drawing of the button backgrounds in the launcher.
This commit is contained in:
parent
6b89bc0019
commit
09f0a04efa
@ -89,6 +89,7 @@ namespace Launcher2 {
|
||||
if( table != null )
|
||||
table.ClampIndex();
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
|
@ -19,6 +19,8 @@ namespace Launcher2 {
|
||||
|
||||
public override void Resize() {
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
RedrawAll();
|
||||
|
@ -19,15 +19,21 @@ namespace Launcher2 {
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
Resize();
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
RedrawAll();
|
||||
LoadSavedInfo();
|
||||
}
|
||||
Dirty = true;
|
||||
}
|
||||
|
||||
public override void Resize() {
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
RedrawAll();
|
||||
|
@ -87,6 +87,24 @@ namespace Launcher2 {
|
||||
}
|
||||
}
|
||||
|
||||
protected void RedrawAllButtonBackgrounds() {
|
||||
int buttons = 0;
|
||||
for( int i = 0; i < widgets.Length; i++ ) {
|
||||
if( widgets[i] == null || !(widgets[i] is LauncherButtonWidget) ) continue;
|
||||
buttons++;
|
||||
}
|
||||
if( buttons == 0 ) return;
|
||||
|
||||
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) ) {
|
||||
for( int i = 0; i < widgets.Length; i++ ) {
|
||||
if( widgets[i] == null ) continue;
|
||||
LauncherButtonWidget button = widgets[i] as LauncherButtonWidget;
|
||||
if( button != null )
|
||||
button.RedrawBackground( dst );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void RedrawAll() {
|
||||
for( int i = 0; i < widgets.Length; i++ ) {
|
||||
if( widgets[i] == null ) continue;
|
||||
|
@ -16,6 +16,8 @@ namespace Launcher2 {
|
||||
|
||||
public override void Resize() {
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
RedrawAll();
|
||||
|
@ -42,6 +42,8 @@ namespace Launcher2 {
|
||||
|
||||
public override void Resize() {
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
drawer.Clear( clearCol );
|
||||
|
@ -67,6 +67,8 @@ namespace Launcher2 {
|
||||
|
||||
public override void Resize() {
|
||||
MakeWidgets();
|
||||
RedrawAllButtonBackgrounds();
|
||||
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
RedrawAll();
|
||||
|
@ -32,7 +32,6 @@ namespace Launcher2 {
|
||||
int xOffset = Width - textSize.Width, yOffset = Height - textSize.Height;
|
||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||
|
||||
RedrawBackground();
|
||||
DrawBorder( drawer );
|
||||
if( Window.ClassicMode )
|
||||
DrawClassic( drawer, xOffset, yOffset );
|
||||
@ -63,14 +62,17 @@ namespace Launcher2 {
|
||||
}
|
||||
|
||||
public void RedrawBackground() {
|
||||
using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true ) )
|
||||
RedrawBackground( dst );
|
||||
}
|
||||
|
||||
public void RedrawBackground( FastBitmap dst ) {
|
||||
Rectangle rect = new Rectangle( X + border, Y + border, Width - border * 2, Height - border * 2 );
|
||||
if( Window.ClassicMode ) {
|
||||
FastColour foreCol = Active ? new FastColour( 126, 136, 191 ) : new FastColour( 111, 111, 111 );
|
||||
using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true ) )
|
||||
Drawer2DExt.DrawNoise( dst, rect, foreCol, 8 );
|
||||
} else {
|
||||
FastColour foreCol = Active ? LauncherSkin.ButtonForeActiveCol : LauncherSkin.ButtonForeCol;
|
||||
using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true ) )
|
||||
Drawer2DExt.FastClear( dst, rect, foreCol );
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user