helpers added
This commit is contained in:
@@ -73,4 +73,64 @@ namespace wiHelper
|
||||
ss << std::put_time(&time_info, "%d-%m-%Y %H-%M-%S");
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
string GetWorkingDirectory()
|
||||
{
|
||||
char result[MAX_PATH];
|
||||
return std::string(result, GetModuleFileNameA(NULL, result, MAX_PATH));
|
||||
}
|
||||
|
||||
void GetFilesInDirectory(vector<string>& out, const string& directory)
|
||||
{
|
||||
#ifndef WINSTORE_SUPPORT
|
||||
// WINDOWS
|
||||
wstring wdirectory = wstring(directory.begin(), directory.end());
|
||||
HANDLE dir;
|
||||
WIN32_FIND_DATA file_data;
|
||||
|
||||
if ((dir = FindFirstFile((wdirectory + L"/*").c_str(), &file_data)) == INVALID_HANDLE_VALUE)
|
||||
return; /* No files found */
|
||||
|
||||
do {
|
||||
const wstring file_name = file_data.cFileName;
|
||||
const wstring full_file_name = wdirectory + L"/" + file_name;
|
||||
const bool is_directory = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
|
||||
//if (file_name[0] == '.')
|
||||
// continue;
|
||||
|
||||
//if (is_directory)
|
||||
// continue;
|
||||
|
||||
out.push_back(string(full_file_name.begin(), full_file_name.end()));
|
||||
} while (FindNextFile(dir, &file_data));
|
||||
|
||||
FindClose(dir);
|
||||
#endif
|
||||
|
||||
// UNIX
|
||||
//DIR *dir;
|
||||
//class dirent *ent;
|
||||
//class stat st;
|
||||
|
||||
//dir = opendir(directory);
|
||||
//while ((ent = readdir(dir)) != NULL) {
|
||||
// const string file_name = ent->d_name;
|
||||
// const string full_file_name = directory + "/" + file_name;
|
||||
|
||||
// if (file_name[0] == '.')
|
||||
// continue;
|
||||
|
||||
// if (stat(full_file_name.c_str(), &st) == -1)
|
||||
// continue;
|
||||
|
||||
// const bool is_directory = (st.st_mode & S_IFDIR) != 0;
|
||||
|
||||
// if (is_directory)
|
||||
// continue;
|
||||
|
||||
// out.push_back(full_file_name);
|
||||
//}
|
||||
//closedir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace wiHelper
|
||||
void screenshot(const string& name = "");
|
||||
|
||||
string getCurrentDateTimeAsString();
|
||||
|
||||
string GetWorkingDirectory();
|
||||
|
||||
void GetFilesInDirectory(vector<string> &out, const string &directory);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "wiTextureHelper.h"
|
||||
#include "wiFont.h"
|
||||
#include "wiMath.h"
|
||||
#include "wiHelper.h"
|
||||
|
||||
|
||||
wiWidget::wiWidget():Transform()
|
||||
@@ -704,7 +705,7 @@ void wiWindow::AddWidget(wiWidget* widget)
|
||||
|
||||
childrenWidgets.push_back(widget);
|
||||
}
|
||||
void wiWindow::RemoveWidget(wiWidget* widget)
|
||||
void wiWindow::RemoveWidget(wiWidget* widget, bool alsoDelete)
|
||||
{
|
||||
assert(gui != nullptr && "Ivalid GUI!");
|
||||
|
||||
@@ -712,15 +713,24 @@ void wiWindow::RemoveWidget(wiWidget* widget)
|
||||
widget->detach();
|
||||
|
||||
childrenWidgets.remove(widget);
|
||||
|
||||
if (alsoDelete)
|
||||
{
|
||||
SAFE_DELETE(widget);
|
||||
}
|
||||
}
|
||||
void wiWindow::RemoveWidgets()
|
||||
void wiWindow::RemoveWidgets(bool alsoDelete)
|
||||
{
|
||||
assert(gui != nullptr && "Ivalid GUI!");
|
||||
|
||||
for (auto& x : childrenWidgets)
|
||||
{
|
||||
gui->RemoveWidget(x);
|
||||
x->detach();
|
||||
gui->RemoveWidget(x);
|
||||
if (alsoDelete)
|
||||
{
|
||||
SAFE_DELETE(x);
|
||||
}
|
||||
}
|
||||
|
||||
childrenWidgets.clear();
|
||||
|
||||
@@ -170,8 +170,8 @@ public:
|
||||
virtual ~wiWindow();
|
||||
|
||||
void AddWidget(wiWidget* widget);
|
||||
void RemoveWidget(wiWidget* widget);
|
||||
void RemoveWidgets();
|
||||
void RemoveWidget(wiWidget* widget, bool alsoDelete = false);
|
||||
void RemoveWidgets(bool alsoDelete = false);
|
||||
|
||||
virtual void Update(wiGUI* gui) override;
|
||||
virtual void Render(wiGUI* gui) override;
|
||||
|
||||
Reference in New Issue
Block a user