fs::path CGamePath::GetResourcePath( std::wstring fnStr, eGameResourceType type ) { // use type as an index, make sure it is not out of bounds Debug::Assert( type < CGamePath::MAX , "[error] array out of bound"); fs::path execPath = GetResourcesPath(); vector<std::wstring>& resPathStr = s_GameResourcePaths[type]; fs::path fullPath; for( int i=0; i < (int)resPathStr.size(); ++i) { fullPath = fs::path(execPath.wstring() + resPathStr[i] + fnStr); if(fs::is_regular_file(fullPath)) { Debug::Print((boost::wformat(TEXT("path found %s")) % fullPath.wstring()).str()); return fullPath; } } Debug::Print((boost::wformat(TEXT("path not found %s")) % fullPath.wstring()).str()); return fs::path(TEXT("")); }
CXlibToolkit::CXlibToolkit(void *parentWindow, CEditor *editor) { this->parentWindow = parentWindow; this->editor = editor; char *displayName = getenv("DISPLAY"); if (!displayName || !strlen(displayName)) { displayName = (char*)":0.0"; } if (!XInitThreads()) { fprintf(stderr, "Xlib threads support unavailable"); return; } this->display = XOpenDisplay(displayName); if (!parentWindow) { parentWindow = (void*)RootWindow(this->display, DefaultScreen(this->display)); } window = XCreateWindow(this->display, (Window)parentWindow, 0, 0, GUI_WIDTH, GUI_HEIGHT, 0, 24, InputOutput, CopyFromParent, 0, 0); gc = XCreateGC(this->display, window, 0, 0); XSelectInput(this->display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask); XMapWindow(this->display, window); XFlush(this->display); this->WM_TIMER = XInternAtom(this->display, "WM_TIMER" , false); this->WM_DELETE_WINDOW = XInternAtom(this->display, "WM_DELETE_WINDOW", false); XSetWMProtocols(this->display, window, &WM_DELETE_WINDOW, 1); offscreen = XCreatePixmap(this->display, window, GUI_WIDTH, GUI_HEIGHT, 24); memset(bmps, 0, sizeof(bmps)); char path[PATH_MAX]; GetResourcesPath(path, PATH_MAX); char fullPath[PATH_MAX]; snprintf(fullPath, PATH_MAX, "%s/%s", path, "chars.bmp" ); bmps[BMP_CHARS ] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "knob.bmp" ); bmps[BMP_KNOB ] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "knob2.bmp" ); bmps[BMP_KNOB2 ] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "knob3.bmp" ); bmps[BMP_KNOB3 ] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "key.bmp" ); bmps[BMP_KEY ] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "bg.bmp" ); bmps[BMP_BG ] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "buttons.bmp"); bmps[BMP_BUTTONS] = LoadImageFromFile(fullPath); snprintf(fullPath, PATH_MAX, "%s/%s", path, "ops.bmp" ); bmps[BMP_OPS ] = LoadImageFromFile(fullPath); if (!bmps[BMP_CHARS ]) bmps[BMP_CHARS ] = LoadImageFromBuffer(chars_bmp ); if (!bmps[BMP_KNOB ]) bmps[BMP_KNOB ] = LoadImageFromBuffer(knob_bmp ); if (!bmps[BMP_KNOB2 ]) bmps[BMP_KNOB2 ] = LoadImageFromBuffer(knob2_bmp ); if (!bmps[BMP_KNOB3 ]) bmps[BMP_KNOB3 ] = LoadImageFromBuffer(knob3_bmp ); if (!bmps[BMP_KEY ]) bmps[BMP_KEY ] = LoadImageFromBuffer(key_bmp ); if (!bmps[BMP_BG ]) bmps[BMP_BG ] = LoadImageFromBuffer(bg_bmp ); if (!bmps[BMP_BUTTONS]) bmps[BMP_BUTTONS] = LoadImageFromBuffer(buttons_bmp); if (!bmps[BMP_OPS ]) bmps[BMP_OPS ] = LoadImageFromBuffer(ops_bmp ); thread1Finished = true; thread2Finished = true; }
CWindowsToolkit::CWindowsToolkit(void *parentWindow, CEditor *editor) { this->parentWindow = parentWindow; this->editor = editor; g_useCount++; if (g_useCount == 1) { WNDCLASSW windowClass; windowClass.style = CS_DBLCLKS; windowClass.lpfnWndProc = WindowProc; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = (HINSTANCE)hInstance; windowClass.hIcon = LoadIcon((HINSTANCE)hInstance,MAKEINTRESOURCE(IDI_ICON)); windowClass.hCursor = LoadCursor( NULL, IDC_ARROW ); windowClass.hbrBackground = NULL; windowClass.lpszMenuName = 0; windowClass.lpszClassName = L"OxeVstEditorClass"; RegisterClassW(&windowClass); } if (!parentWindow) { RECT rect; rect.left = 100; rect.top = 100; rect.right = GUI_WIDTH; rect.bottom = GUI_HEIGHT; AdjustWindowRect(&rect, WS_SYSMENU | WS_CAPTION, FALSE); rect.bottom += GetSystemMetrics(SM_CYCAPTION); rect.bottom += GetSystemMetrics(SM_CYFIXEDFRAME); rect.right += GetSystemMetrics(SM_CXFIXEDFRAME); this->hWnd = CreateWindowW ( L"OxeVstEditorClass", L"", WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, rect.left, rect.top, rect.right, rect.bottom, 0, 0, (HINSTANCE)hInstance, NULL ); } else { this->hWnd = CreateWindowExW ( 0, L"OxeVstEditorClass", L"", WS_CHILD | WS_VISIBLE, 0, 0, GUI_WIDTH, GUI_HEIGHT, (HWND)parentWindow, NULL, (HINSTANCE)hInstance, NULL ); } #ifdef _WIN64 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)this); #else SetWindowLong(hWnd, GWL_USERDATA, (LONG)this); #endif // load resources char path[MAX_PATH]; GetResourcesPath(path, MAX_PATH); char fullPath[MAX_PATH]; StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "chars.bmp"); bmps[BMP_CHARS] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "knob.bmp"); bmps[BMP_KNOB] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "knob2.bmp"); bmps[BMP_KNOB2] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "knob3.bmp"); bmps[BMP_KNOB3] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "key.bmp"); bmps[BMP_KEY] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "bg.bmp"); bmps[BMP_BG] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "buttons.bmp"); bmps[BMP_BUTTONS] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); StringCchPrintf(fullPath, MAX_PATH, "%s\\%s", path, "ops.bmp"); bmps[BMP_OPS] = (HBITMAP)LoadImageA(NULL, fullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (!bmps[BMP_CHARS ]) bmps[BMP_CHARS ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_CHARS)); if (!bmps[BMP_KNOB ]) bmps[BMP_KNOB ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_KNOB)); if (!bmps[BMP_KNOB2 ]) bmps[BMP_KNOB2 ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_KNOB2)); if (!bmps[BMP_KNOB3 ]) bmps[BMP_KNOB3 ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_KNOB3)); if (!bmps[BMP_KEY ]) bmps[BMP_KEY ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_CHAVE)); if (!bmps[BMP_BG ]) bmps[BMP_BG ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_FUNDO)); if (!bmps[BMP_BUTTONS]) bmps[BMP_BUTTONS] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_BUTTONS)); if (!bmps[BMP_OPS ]) bmps[BMP_OPS ] = LoadBitmap((HINSTANCE)hInstance,MAKEINTRESOURCE(IDB_OPS)); // create offscreen buffer hdc = GetDC(hWnd); hdcMem = CreateCompatibleDC(hdc); hdcAux = CreateCompatibleDC(hdc); bitmap = CreateCompatibleBitmap(hdc, GUI_WIDTH, GUI_HEIGHT); SelectObject(hdcMem, bitmap); SetTimer(hWnd, 0, TIMER_RESOLUTION_MS, NULL); }