mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Make TexturePackExtractor less hardcoded.
This commit is contained in:
parent
7432413a77
commit
3fdda6ab92
3 changed files with 21 additions and 14 deletions
|
@ -412,8 +412,8 @@ namespace ClassicalSharp {
|
|||
}
|
||||
|
||||
internal void OnResize() {
|
||||
int oWidth = window.Width, oHeight = window.Height;
|
||||
Width = window.Width; Height = window.Height;
|
||||
int oWidth = Width, oHeight = Height;
|
||||
Width = window.Width; Height = window.Height;
|
||||
Graphics.OnWindowResize( this );
|
||||
UpdateProjection();
|
||||
Gui.OnResize( oWidth, oHeight );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ClassicalSharp.Events;
|
||||
using ClassicalSharp.GraphicsAPI;
|
||||
using ClassicalSharp.Gui;
|
||||
using ClassicalSharp.Renderers;
|
||||
|
@ -35,6 +36,7 @@ namespace ClassicalSharp {
|
|||
public void Init( Game game ) {
|
||||
this.game = game;
|
||||
api = game.Graphics;
|
||||
game.Events.TextureChanged += TextureChanged;
|
||||
}
|
||||
|
||||
public void Reset( Game game ) {
|
||||
|
@ -44,6 +46,7 @@ namespace ClassicalSharp {
|
|||
}
|
||||
|
||||
public void Dispose() {
|
||||
game.Events.TextureChanged -= TextureChanged;
|
||||
SetNewScreen( null );
|
||||
fpsScreen.Dispose();
|
||||
|
||||
|
@ -57,6 +60,16 @@ namespace ClassicalSharp {
|
|||
screen.Dispose();
|
||||
}
|
||||
|
||||
void TextureChanged( object sender, TextureEventArgs e ) {
|
||||
if( e.Name == "gui.png" )
|
||||
game.UpdateTexture( ref GuiTex, e.Name, e.Data, false );
|
||||
else if( e.Name == "gui_classic.png" )
|
||||
game.UpdateTexture( ref GuiClassicTex, e.Name, e.Data, false );
|
||||
else if( e.Name == "icons.png" )
|
||||
game.UpdateTexture( ref IconsTex, e.Name, e.Data, false );
|
||||
}
|
||||
|
||||
|
||||
public void SetNewScreen( Screen screen ) { SetNewScreen( screen, true ); }
|
||||
|
||||
public void SetNewScreen( Screen screen, bool disposeOld ) {
|
||||
|
@ -104,7 +117,7 @@ namespace ClassicalSharp {
|
|||
api.Mode3D( game.EnvRenderer is StandardEnvRenderer );
|
||||
}
|
||||
|
||||
internal void OnResize( int oWidth, int oHeight ) {
|
||||
internal void OnResize( int oWidth, int oHeight ) {
|
||||
if( activeScreen != null )
|
||||
activeScreen.OnResize( oWidth, oHeight, game.Width, game.Height );
|
||||
hudScreen.OnResize( oWidth, oHeight, game.Width, game.Height );
|
||||
|
|
|
@ -39,9 +39,6 @@ namespace ClassicalSharp.TexturePack {
|
|||
}
|
||||
|
||||
void ProcessZipEntry( string filename, byte[] data, ZipEntry entry ) {
|
||||
MemoryStream stream = new MemoryStream( data );
|
||||
ModelCache cache = game.ModelCache;
|
||||
|
||||
// Ignore directories: convert x/name to name and x\name to name.
|
||||
string name = filename.ToLower();
|
||||
int i = name.LastIndexOf( '\\' );
|
||||
|
@ -51,28 +48,25 @@ namespace ClassicalSharp.TexturePack {
|
|||
|
||||
switch( name ) {
|
||||
case "terrain.png":
|
||||
MemoryStream stream = new MemoryStream( data );
|
||||
Bitmap atlas = Platform.ReadBmp( stream );
|
||||
if( !game.ChangeTerrainAtlas( atlas ) ) atlas.Dispose();
|
||||
break;
|
||||
case "clouds.png":
|
||||
case "cloud.png":
|
||||
game.UpdateTexture( ref game.CloudsTex, name, data, false ); break;
|
||||
case "gui.png":
|
||||
game.UpdateTexture( ref game.Gui.GuiTex, name, data, false ); break;
|
||||
case "gui_classic.png":
|
||||
game.UpdateTexture( ref game.Gui.GuiClassicTex, name, data, false ); break;
|
||||
case "icons.png":
|
||||
game.UpdateTexture( ref game.Gui.IconsTex, name, data, false ); break;
|
||||
case "default.png":
|
||||
SetFontBitmap( game, stream ); break;
|
||||
SetFontBitmap( game, data ); break;
|
||||
}
|
||||
game.Events.RaiseTextureChanged( name, data );
|
||||
}
|
||||
|
||||
void SetFontBitmap( Game game, Stream stream ) {
|
||||
void SetFontBitmap( Game game, byte[] data ) {
|
||||
MemoryStream stream = new MemoryStream( data );
|
||||
Bitmap bmp = Platform.ReadBmp( stream );
|
||||
if( !Platform.Is32Bpp( bmp ) )
|
||||
game.Drawer2D.ConvertTo32Bpp( ref bmp );
|
||||
|
||||
game.Drawer2D.SetFontBitmap( bmp );
|
||||
game.Events.RaiseChatFontChanged();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue