-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
690 additions
and
1,383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
default_texture ./examples/default.txt | ||
default_map ./examples/Mountain_512.png |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace Program; | ||
|
||
internal class ExceptionDialog | ||
{ | ||
public static DialogResult Show(IWin32Window owner, Exception e) | ||
{ | ||
return MessageBox.Show(owner, e.Message, e.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; | ||
|
||
namespace Program; | ||
|
||
internal class ImageFileDialog | ||
{ | ||
public const string ImageFilter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF)|*.bmp;*.jpg;*.gif;*.png;*.tiff|All files (*.*)|*.*"; | ||
|
||
public static string DirectoryExport; | ||
public static string DirectoryImport; | ||
|
||
public static bool TryOpenImage(IWin32Window owner, out string path) | ||
{ | ||
var dialog = new OpenFileDialog(); | ||
dialog.InitialDirectory = Path.GetFullPath(DirectoryImport); | ||
dialog.Filter = ImageFilter; | ||
|
||
if (dialog.ShowDialog(owner) == DialogResult.OK) | ||
{ | ||
path = dialog.FileName; | ||
DirectoryImport = Path.GetDirectoryName(path); | ||
|
||
return true; | ||
} | ||
|
||
path = null!; | ||
return false; | ||
} | ||
|
||
public static bool TrySaveImage(IWin32Window owner, Bitmap bitmap) | ||
{ | ||
var dialog = new SaveFileDialog(); | ||
dialog.InitialDirectory = Path.GetFullPath(DirectoryExport); | ||
dialog.AddExtension = true; | ||
dialog.Filter = ImageFilter; | ||
dialog.DefaultExt = ".png"; | ||
|
||
if (dialog.ShowDialog(owner) == DialogResult.OK) | ||
{ | ||
var path = dialog.FileName; | ||
var format = GetImageFormat(path); | ||
|
||
bitmap.Save(dialog.FileName, format); | ||
DirectoryExport = Path.GetDirectoryName(path); | ||
|
||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static void SaveImage(IWin32Window owner, Bitmap bitmap) | ||
{ | ||
try | ||
{ | ||
TrySaveImage(owner, bitmap); | ||
} | ||
catch (Exception e) | ||
{ | ||
ExceptionDialog.Show(owner, e); | ||
} | ||
} | ||
|
||
public static ImageFormat GetImageFormat(string path) | ||
{ | ||
var extension = Path.GetExtension(path).ToLower(); | ||
return extension switch | ||
{ | ||
".bmp" => ImageFormat.Bmp, | ||
".jpg" => ImageFormat.Jpeg, | ||
".jpeg" => ImageFormat.Jpeg, | ||
".gif" => ImageFormat.Gif, | ||
".png" => ImageFormat.Png, | ||
".tiff" => ImageFormat.Tiff, | ||
_ => throw new ArgumentOutOfRangeException(), | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.