Skip to content

Commit 61bd144

Browse files
committed
update
1 parent 63ccf72 commit 61bd144

4 files changed

Lines changed: 38 additions & 13 deletions

File tree

Editor/ProjectCreatorWindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void ProjectCreatorWindow::Create(EditorComponent* _editor)
9494
wi::helper::messageBox("Application name must be provided first!");
9595
return;
9696
}
97-
std::string folder = wi::helper::FolderDialog();
97+
std::string folder = wi::helper::FolderDialog("Select location where project folder will be created.");
9898
if (folder.empty())
9999
return;
100100
std::string name = projectNameInput.GetText();
@@ -117,6 +117,7 @@ backlog_post("Hello World!")
117117
if (iconResource.IsValid())
118118
{
119119
wi::helper::saveTextureToFile(iconResource.GetTexture(), directory + "icon.png");
120+
wi::helper::saveTextureToFile(iconResource.GetTexture(), directory + "icon.h");
120121
}
121122
if (thumbnailResource.IsValid())
122123
{
@@ -217,6 +218,7 @@ backlog_post("Hello World!")
217218
wi::helper::FileWrite(exepath_dst, exedata.data(), exedata.size());
218219
}
219220
}
221+
editor->RegisterRecentlyUsed(directory + scriptfilename);
220222
wi::helper::OpenUrl(directory);
221223
});
222224
AddWidget(&createButton);

Editor/main_SDL2.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "sdl2.h"
55
#include <fstream>
66

7-
#include "icon.c"
7+
#include "icon.h"
88

99
#ifdef __linux__
1010
# include <execinfo.h>
@@ -95,7 +95,7 @@ void set_window_icon(SDL_Window *window) {
9595
// to assume the data it gets is byte-wise RGB(A) data
9696
Uint32 rmask, gmask, bmask, amask;
9797
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
98-
int shift = (gimp_image.bytes_per_pixel == 3) ? 8 : 0;
98+
int shift = (embedded_image.bytes_per_pixel == 3) ? 8 : 0;
9999
rmask = 0xff000000 >> shift;
100100
gmask = 0x00ff0000 >> shift;
101101
bmask = 0x0000ff00 >> shift;
@@ -104,10 +104,10 @@ void set_window_icon(SDL_Window *window) {
104104
rmask = 0x000000ff;
105105
gmask = 0x0000ff00;
106106
bmask = 0x00ff0000;
107-
amask = (gimp_image.bytes_per_pixel == 3) ? 0 : 0xff000000;
107+
amask = (embedded_image.bytes_per_pixel == 3) ? 0 : 0xff000000;
108108
#endif
109-
SDL_Surface* icon = SDL_CreateRGBSurfaceFrom((void*)gimp_image.pixel_data, gimp_image.width,
110-
gimp_image.height, gimp_image.bytes_per_pixel*8, gimp_image.bytes_per_pixel*gimp_image.width,
109+
SDL_Surface* icon = SDL_CreateRGBSurfaceFrom((void*)embedded_image.pixel_data, embedded_image.width,
110+
embedded_image.height, embedded_image.bytes_per_pixel*8, embedded_image.bytes_per_pixel* embedded_image.width,
111111
rmask, gmask, bmask, amask);
112112

113113
SDL_SetWindowIcon(window, icon);

WickedEngine/wiHelper.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,29 @@ namespace wi::helper
824824

825825
return true;
826826
}
827+
else if (!extension.compare("H"))
828+
{
829+
const size_t datasize = mip.width * mip.height * sizeof(wi::Color);
830+
std::string ss;
831+
ss += "struct EmbeddedImage {\n";
832+
ss += "const unsigned int width = " + std::to_string(mip.width) + ";\n";
833+
ss += "const unsigned int height = " + std::to_string(mip.height) + ";\n";
834+
ss += "const unsigned int bytes_per_pixel = 4;\n";
835+
ss += "const char comment[] = \"RGBA Image Header Generated By Wicked Engine\";\n";
836+
ss += "const unsigned char pixel_data[] = {";
837+
for (size_t i = 0; i < datasize; ++i)
838+
{
839+
if (i % 32 == 0)
840+
{
841+
ss += "\n";
842+
}
843+
ss += std::to_string((uint32_t)mip.address[i]) + ",";
844+
}
845+
ss += "\n};\n};\n";
846+
filedata.resize(ss.size());
847+
std::memcpy(filedata.data(), ss.c_str(), ss.length());
848+
return true;
849+
}
827850
else
828851
{
829852
assert(0 && "Unsupported extension");
@@ -1330,14 +1353,14 @@ namespace wi::helper
13301353
#endif // PLATFORM_LINUX
13311354
}
13321355

1333-
std::string FolderDialog()
1356+
std::string FolderDialog(const std::string& description)
13341357
{
13351358
if (!pfd::settings::available())
13361359
{
13371360
messageBox("No dialog backend available!", "Error!");
13381361
return "";
13391362
}
1340-
return pfd::select_folder("Select folder").result();
1363+
return pfd::select_folder(description).result();
13411364
}
13421365

13431366
void GetFileNamesInDirectory(const std::string& directory, std::function<void(std::string fileName)> onSuccess, const std::string& filter_extension)

WickedEngine/wiHelper.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ namespace wi::helper
5151
// Save raw pixel data from the texture to memory
5252
bool saveTextureToMemory(const wi::graphics::Texture& texture, wi::vector<uint8_t>& texturedata);
5353

54-
// Save texture to memory as a file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico)
54+
// Save texture to memory as a file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico, .h)
5555
bool saveTextureToMemoryFile(const wi::graphics::Texture& texture, const std::string& fileExtension, wi::vector<uint8_t>& filedata);
5656

57-
// Save raw texture data to memory as file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico)
57+
// Save raw texture data to memory as file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico, .h)
5858
bool saveTextureToMemoryFile(const wi::vector<uint8_t>& textureData, const wi::graphics::TextureDesc& desc, const std::string& fileExtension, wi::vector<uint8_t>& filedata);
5959

60-
// Save texture to file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico)
60+
// Save texture to file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico, .h)
6161
bool saveTextureToFile(const wi::graphics::Texture& texture, const std::string& fileName);
6262

63-
// Save raw texture data to file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico)
63+
// Save raw texture data to file format (file format is determined by extension, supported extensions: .png, .jpg, .jpeg, .tga, .bmp, .dds, .ico, .h)
6464
bool saveTextureToFile(const wi::vector<uint8_t>& texturedata, const wi::graphics::TextureDesc& desc, const std::string& fileName);
6565

6666
// Download buffer from GPU into CPU memory
@@ -128,7 +128,7 @@ namespace wi::helper
128128
};
129129
void FileDialog(const FileDialogParams& params, std::function<void(std::string fileName)> onSuccess);
130130

131-
std::string FolderDialog();
131+
std::string FolderDialog(const std::string& description = "Select folder");
132132

133133
void GetFileNamesInDirectory(const std::string& directory, std::function<void(std::string fileName)> onSuccess, const std::string& filter_extension = "");
134134

0 commit comments

Comments
 (0)