mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Fix level saving from last commit.
This commit is contained in:
parent
1bb4b9d99b
commit
b0b1afc617
@ -14,10 +14,8 @@ namespace ClassicalSharp {
|
|||||||
Array.Copy( cwFiles, 0, files, 0, cwFiles.Length );
|
Array.Copy( cwFiles, 0, files, 0, cwFiles.Length );
|
||||||
Array.Copy( datFiles, 0, files, cwFiles.Length, datFiles.Length );
|
Array.Copy( datFiles, 0, files, cwFiles.Length, datFiles.Length );
|
||||||
|
|
||||||
for( int i = 0; i < files.Length; i++ ) {
|
for( int i = 0; i < files.Length; i++ )
|
||||||
string absolutePath = files[i];
|
files[i] = Path.GetFileName( files[i] );
|
||||||
files[i] = absolutePath.Substring( dir.Length );
|
|
||||||
}
|
|
||||||
Array.Sort( files );
|
Array.Sort( files );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,31 +83,31 @@ namespace ClassicalSharp {
|
|||||||
MakeDescWidget( "Please enter a filename" );
|
MakeDescWidget( "Please enter a filename" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
text = Path.Combine( Program.AppDirectory, text );
|
string file = Path.ChangeExtension( text, ".cw" );
|
||||||
text = Path.ChangeExtension( text, ".cw" );
|
text = Path.Combine( Program.AppDirectory, "maps" );
|
||||||
|
text = Path.Combine( text, file );
|
||||||
|
|
||||||
if( File.Exists( text ) ) {
|
if( File.Exists( text ) ) {
|
||||||
buttons[1] = ButtonWidget.Create( game, 0, 90, 260, 30, "Overwrite existing?",
|
buttons[1] = ButtonWidget.Create( game, 0, 90, 260, 30, "Overwrite existing?",
|
||||||
Anchor.Centre, Anchor.Centre, titleFont, OverwriteButtonClick );
|
Anchor.Centre, Anchor.Centre, titleFont, OverwriteButtonClick );
|
||||||
} else {
|
} else {
|
||||||
SetPath( text );
|
// NOTE: We don't immediately save here, because otherwise the 'saving...'
|
||||||
|
// will not be rendered in time because saving is done on the main thread.
|
||||||
|
MakeDescWidget( "Saving.." );
|
||||||
|
textPath = text;
|
||||||
RemoveOverwriteButton();
|
RemoveOverwriteButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverwriteButtonClick( Game game, Widget widget ) {
|
void OverwriteButtonClick( Game game, Widget widget ) {
|
||||||
string text = inputWidget.GetText();
|
string text = inputWidget.GetText();
|
||||||
text = Path.ChangeExtension( text, ".cw" );
|
string file = Path.ChangeExtension( text, ".cw" );
|
||||||
|
text = Path.Combine( Program.AppDirectory, "maps" );
|
||||||
|
text = Path.Combine( text, file );
|
||||||
|
|
||||||
SetPath( text );
|
|
||||||
RemoveOverwriteButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetPath( string text ) {
|
|
||||||
// NOTE: We don't immediately save here, because otherwise the 'saving...'
|
|
||||||
// will not be rendered in time because saving is done on the main thread.
|
|
||||||
MakeDescWidget( "Saving.." );
|
MakeDescWidget( "Saving.." );
|
||||||
textPath = text;
|
textPath = text;
|
||||||
|
RemoveOverwriteButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveOverwriteButton() {
|
void RemoveOverwriteButton() {
|
||||||
@ -118,8 +118,6 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
string textPath;
|
string textPath;
|
||||||
void SaveMap( string path ) {
|
void SaveMap( string path ) {
|
||||||
path = Path.Combine( "maps", path );
|
|
||||||
path = Path.Combine( Program.AppDirectory, path );
|
|
||||||
try {
|
try {
|
||||||
if( File.Exists( path ) )
|
if( File.Exists( path ) )
|
||||||
File.Delete( path );
|
File.Delete( path );
|
||||||
@ -132,7 +130,7 @@ namespace ClassicalSharp {
|
|||||||
MakeDescWidget( "&cError while trying to save map" );
|
MakeDescWidget( "&cError while trying to save map" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
game.Chat.Add( "&eSaved map to: " + path );
|
game.Chat.Add( "&eSaved map to: " + Path.GetFileName( path ) );
|
||||||
game.SetNewScreen( new PauseScreen( game ) );
|
game.SetNewScreen( new PauseScreen( game ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,8 @@ namespace ClassicalSharp {
|
|||||||
string dir = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir );
|
string dir = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir );
|
||||||
files = Directory.GetFiles( dir, "*.zip" );
|
files = Directory.GetFiles( dir, "*.zip" );
|
||||||
|
|
||||||
for( int i = 0; i < files.Length; i++ ) {
|
for( int i = 0; i < files.Length; i++ )
|
||||||
string absolutePath = files[i];
|
files[i] = Path.GetFileName( files[i] );
|
||||||
files[i] = absolutePath.Substring( dir.Length );
|
|
||||||
}
|
|
||||||
Array.Sort( files );
|
Array.Sort( files );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user