diff --git a/util.cpp b/util.cpp index f6496e3..cc416db 100755 --- a/util.cpp +++ b/util.cpp @@ -5,6 +5,19 @@ using namespace std; namespace vb01{ + double *x = nullptr, *y = nullptr; + + Vector2 getCursorPos() + { + if(!x) + x = new double; + + if(!y) + y = new double; + + return Vector2(*x, *y); + } + void readFile(string path, vector &lines, int firstLine, int lastLine){ string l; std::ifstream inFile(path); @@ -55,4 +68,23 @@ namespace vb01{ } return charId; } + + wstring stringToWstring(string str){ + wstring wstr = L""; + + for(char ch : str) + wstr += ch; + + return wstr; + } + + string wstringToString(wstring wstr){ + string str = ""; + + for(wchar_t ch : wstr) + if(ch < 256) + str += ch; + + return str; + } } diff --git a/util.h b/util.h index 81944d1..5e40d5d 100755 --- a/util.h +++ b/util.h @@ -6,6 +6,8 @@ #include #include +#include "vector.h" + namespace vb01{ typedef char s8; typedef short s16; @@ -22,7 +24,9 @@ namespace vb01{ void readFile(std::string, std::vector&, int = 0, int = -1); void getLineData(std::string, std::string[], int, int = 0); int getCharId(std::string, char, bool = false); - + std::wstring stringToWstring(std::string str); + std::string wstringToString(std::wstring wstr); + Vector2 getCursorPos(); inline s64 getTime(){return s64(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1));} }