int WinGetPicStringWidth (char *string, OSPictContext context) { SIZE sz; if (!GetTextExtentPoint32 (context->hDC, string, strlen(string), &sz)) rMessageBox (NULL,MB_APPLMODAL,"WinGetPicStringWidth","GetTextExtentPoint32 failed"); return sz.cx; } /* WinGetPicStringWidth */
/* PA: new routine to scroll part of the content of a window. It is assumed that scrolling happens in one direction only (dx<>0 && dy==0 || dx==0 && dy<>0). The result rect (oleft,otop,oright,obottom) is the bounding box of the update area that remains to be updated. If all are zero, then nothing needs to be updated. */ void WinScrollRectangle (int left, int top, int right, int bottom, int dx, int dy, OSPictContext context, int * oleft, int * otop, int * oright, int * obottom ) { RECT scrollRect; HRGN hrgnUpdate, hrgnRect; scrollRect.left = left; scrollRect.top = top; scrollRect.right = right; scrollRect.bottom = bottom; if (dx<0) { hrgnRect = CreateRectRgn (right+dx-1,top-1,right+1,bottom+1); } else if (dx>0) { hrgnRect = CreateRectRgn (left-1,top-1,left+dx+1,bottom+1); } else if (dy<0) { hrgnRect = CreateRectRgn (left-1,bottom+dy-1,right+1,bottom+1); } else if (dy>0) { hrgnRect = CreateRectRgn (left-1,top-1,right+1,top+dy+1); } else { hrgnRect = CreateRectRgn (0,0,0,0); } hrgnUpdate = CreateRectRgn (0,0,1,1); if (!ScrollDC (context->hDC, dx,dy, &scrollRect, &scrollRect, hrgnUpdate, NULL)) { rMessageBox (NULL,MB_APPLMODAL,"WinScrollRectangle","ScrollDC failed"); } else { if (CombineRgn (hrgnUpdate, hrgnUpdate, hrgnRect, RGN_DIFF) == NULLREGION) { *oleft = 0; *otop = 0; *oright = 0; *obottom = 0; } else { RECT box; GetRgnBox (hrgnUpdate,&box); *oleft = box.left; *otop = box.top; *oright = box.right; *obottom = box.bottom; } } DeleteObject (hrgnUpdate); DeleteObject (hrgnRect); } /* WinScrollRectangle */
/* WinDrawBitmap must be used for drawing bitmaps on screen. For reasons of efficiency it uses memory device context, BitBlt, and bitmap handle. */ void WinDrawBitmap (int w, int h, int destx, int desty, HBITMAP hbmp, OSPictContext context ) { HDC compatibleDC; POINT size, origin, dest; HGDIOBJ prevObj; size.x = w; size.y = h; origin.x = 0; origin.y = 0; dest.x = destx; dest.y = desty; // Create a compatible device context compatibleDC = CreateCompatibleDC (context->hDC); if (compatibleDC == NULL) rMessageBox (NULL,MB_APPLMODAL,"WinDrawBitmap","CreateCompatibleDC failed"); // Select bitmap into compatible device context prevObj = SelectObject (compatibleDC, hbmp); SetMapMode (compatibleDC, GetMapMode (context->hDC)); DPtoLP (context->hDC, &size, 1); DPtoLP (context->hDC, &dest, 1); DPtoLP (compatibleDC, &origin, 1); BitBlt (context->hDC, dest.x, dest.y, size.x, size.y, compatibleDC, origin.x, origin.y, SRCCOPY); SelectObject (compatibleDC, prevObj); DeleteDC (compatibleDC); } /* WinDrawBitmap */
int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::ptr<const char> dirName) { cellGame->Warning("cellGameContentErrorDialog(type=%d, errNeedSizeKB=%d, dirName_addr=0x%x)", type, errNeedSizeKB, dirName.addr()); std::string errorName; switch (type) { case CELL_GAME_ERRDIALOG_BROKEN_GAMEDATA: errorName = "Game data is corrupted (can be continued)."; break; case CELL_GAME_ERRDIALOG_BROKEN_HDDGAME: errorName = "HDD boot game is corrupted (can be continued)."; break; case CELL_GAME_ERRDIALOG_NOSPACE: errorName = "Not enough available space (can be continued)."; break; case CELL_GAME_ERRDIALOG_BROKEN_EXIT_GAMEDATA: errorName = "Game data is corrupted (terminate application)."; break; case CELL_GAME_ERRDIALOG_BROKEN_EXIT_HDDGAME: errorName = "HDD boot game is corrupted (terminate application)."; break; case CELL_GAME_ERRDIALOG_NOSPACE_EXIT: errorName = "Not enough available space (terminate application)."; break; default: return CELL_GAME_ERROR_PARAM; } std::string errorMsg; if (type == CELL_GAME_ERRDIALOG_NOSPACE || type == CELL_GAME_ERRDIALOG_NOSPACE_EXIT) { errorMsg = fmt::Format("ERROR: %s\nSpace needed: %d KB", errorName.c_str(), errNeedSizeKB, dirName); } else { errorMsg = fmt::Format("ERROR: %s", errorName.c_str()); } if (dirName) { errorMsg += fmt::Format("\nDirectory name: %s", dirName.get_ptr()); } rMessageBox(errorMsg, "Error", rICON_ERROR | rOK); return CELL_OK; }
LogWriter::LogWriter() { if (!m_logfile.Open(_PRGNAME_ ".log", rFile::write)) { rMessageBox("Can't create log file! (" _PRGNAME_ ".log)", rMessageBoxCaptionStr, rICON_ERROR); } }
static int GetMessageQuickly (BOOL gIdleTimerOn, int gSleeptime, MSG * pmsg) { if (gSleeptime==0 && !PeekMessage (pmsg, NULL, 0, 0, PM_NOREMOVE)) { POINT p; GetCursorPos (&p); pmsg->hwnd = ghMainWindow; pmsg->message = WM_ENTERIDLE; pmsg->wParam = MSGF_USER; pmsg->lParam = (LPARAM) ghMainWindow; pmsg->time = GetTickCount (); pmsg->pt = p; return TRUE; } if (!gIdleTimerOn) { return GetMessage (pmsg, NULL, 0, 0); } else { if (PeekMessage (pmsg, NULL, 0, 0, PM_REMOVE)) return (pmsg->message != WM_QUIT); else { POINT p; /* The following code has been inserted to reduce the crosscall traffic. A timer is set to suspend this thread until atleast the timer interval has elapsed. */ if (SetTimer (ghMainWindow, (UINT) -2, (UINT)gSleeptime, &EndSuspendTimerProc)) { WaitMessage (); } else { rMessageBox (NULL,MB_APPLMODAL,"GetMessageQuickly","SetTimer failed to create timer"); } /* End of insertion. */ GetCursorPos (&p); pmsg->hwnd = ghMainWindow; pmsg->message = WM_ENTERIDLE; pmsg->wParam = MSGF_USER; pmsg->lParam = (LPARAM) ghMainWindow; pmsg->time = GetTickCount (); pmsg->pt = p; return TRUE; } } } /* GetMessageQuickly */
void WinCopyRectangle (int left, int top, int right, int bottom, int dx, int dy, OSPictContext context) { RECT scrollRect; scrollRect.left = left; scrollRect.top = top; scrollRect.right = right; scrollRect.bottom = bottom; if (!ScrollDC (context->hDC, dx,dy, &scrollRect, &scrollRect, NULL, NULL)) { rMessageBox (NULL,MB_APPLMODAL,"WinCopyRectangle","ScrollDC failed"); } } /* WinCopyRectangle */
int WinGetStringWidth (char *string, char *fontName, int style, int size, OSPictContext context) { LOGFONT lf; HDC screen; HFONT of,hf; int pixSize; SIZE sz; if (context != NULL) screen = context->hDC; else screen = CreateDC ("DISPLAY", NULL, NULL, NULL); pixSize = PointsToPix(screen,size); // end MW SetLogFontData (&lf, "", style, pixSize); strcpy (lf.lfFaceName, fontName); hf = CreateFontIndirect (&lf); // PA+++: hf added to test for NULL if (hf==NULL) rMessageBox (NULL,MB_APPLMODAL,"WinGetStringWidth","CreateFontIndirect returned NULL"); of = SelectObject (screen, hf); //CreateFontIndirect (&lf)); if (of==NULL) rMessageBox (NULL,MB_APPLMODAL,"WinGetStringWidth","SelectObject of HFONT returned NULL"); if (!GetTextExtentPoint32 (screen, string, strlen(string), &sz)) rMessageBox (NULL,MB_APPLMODAL,"WinGetPicStringWidth","GetTextExtentPoint32 failed"); DeleteObject (SelectObject (screen, of)); if (context == NULL) DeleteDC(screen); return sz.cx; } /* WinGetStringWidth */
int WinGetVertResolution (void) { static int res = 0; if (res == 0) { HDC screen; screen = CreateDC ("DISPLAY", NULL, NULL, NULL); if (screen==NULL) rMessageBox (NULL,MB_APPLMODAL,"WinGetVertResolution","CreateDC returned NULL."); res = GetDeviceCaps (screen, LOGPIXELSY); DeleteDC (screen); }; return res; } /* WinGetVertResolution */
void WinUndrawString (int x, int y, char *string, OSPictContext context) { int oldmode; StartUndrawing(context); oldmode = GetBkMode (context->hDC); if (context->penMode==iModeXor) /* Check if currently in XOR mode */ { SetBkMode (context->hDC, OPAQUE); /* in that case background should be OPAQUE. */ } else { SetBkMode (context->hDC, TRANSPARENT); /* otherwise it should be TRANSPARENT. */ } if (!TextOut (context->hDC, x, y, string, strlen(string))) rMessageBox (NULL,MB_APPLMODAL,"WinDrawString","TextOut failed."); SetBkMode (context->hDC, oldmode); } /* WinEraseString */
int cellMsgDialogOpenErrorCode(u32 errorCode, vm::ptr<CellMsgDialogCallback> callback, u32 userData, u32 extParam) { cellSysutil->Warning("cellMsgDialogOpenErrorCode(errorCode=0x%x, callback_addr=0x%x, userData=0x%x, extParam=%d)", errorCode, callback.addr(), userData, extParam); std::string errorMessage; switch (errorCode) { // Generic errors case 0x80010001: errorMessage = "The resource is temporarily unavailable."; break; case 0x80010002: errorMessage = "Invalid argument or flag."; break; case 0x80010003: errorMessage = "The feature is not yet implemented."; break; case 0x80010004: errorMessage = "Memory allocation failed."; break; case 0x80010005: errorMessage = "The resource with the specified identifier does not exist."; break; case 0x80010006: errorMessage = "The file does not exist."; break; case 0x80010007: errorMessage = "The file is in unrecognized format / The file is not a valid ELF file."; break; case 0x80010008: errorMessage = "Resource deadlock is avoided."; break; case 0x80010009: errorMessage = "Operation not permitted."; break; case 0x8001000A: errorMessage = "The device or resource is bus."; break; case 0x8001000B: errorMessage = "The operation is timed ou."; break; case 0x8001000C: errorMessage = "The operation is aborte."; break; case 0x8001000D: errorMessage = "Invalid memory access."; break; case 0x8001000F: errorMessage = "State of the target thread is invalid."; break; case 0x80010010: errorMessage = "Alignment is invalid."; break; case 0x80010011: errorMessage = "Shortage of the kernel resources."; break; case 0x80010012: errorMessage = "The file is a directory."; break; case 0x80010013: errorMessage = "Operation canceled."; break; case 0x80010014: errorMessage = "Entry already exists."; break; case 0x80010015: errorMessage = "Port is already connected."; break; case 0x80010016: errorMessage = "Port is not connected."; break; case 0x80010017: errorMessage = "Failure in authorizing SELF. Program authentication fail."; break; case 0x80010018: errorMessage = "The file is not MSELF."; break; case 0x80010019: errorMessage = "System version error."; break; case 0x8001001A: errorMessage = "Fatal system error occurred while authorizing SELF. SELF auth failure."; break; case 0x8001001B: errorMessage = "Math domain violation."; break; case 0x8001001C: errorMessage = "Math range violation."; break; case 0x8001001D: errorMessage = "Illegal multi-byte sequence in input."; break; case 0x8001001E: errorMessage = "File position error."; break; case 0x8001001F: errorMessage = "Syscall was interrupted."; break; case 0x80010020: errorMessage = "File too large."; break; case 0x80010021: errorMessage = "Too many links."; break; case 0x80010022: errorMessage = "File table overflow."; break; case 0x80010023: errorMessage = "No space left on device."; break; case 0x80010024: errorMessage = "Not a TTY."; break; case 0x80010025: errorMessage = "Broken pipe."; break; case 0x80010026: errorMessage = "Read-only filesystem."; break; case 0x80010027: errorMessage = "Illegal seek."; break; case 0x80010028: errorMessage = "Arg list too long."; break; case 0x80010029: errorMessage = "Access violation."; break; case 0x8001002A: errorMessage = "Invalid file descriptor."; break; case 0x8001002B: errorMessage = "Filesystem mounting failed."; break; case 0x8001002C: errorMessage = "Too many files open."; break; case 0x8001002D: errorMessage = "No device."; break; case 0x8001002E: errorMessage = "Not a directory."; break; case 0x8001002F: errorMessage = "No such device or IO."; break; case 0x80010030: errorMessage = "Cross-device link error."; break; case 0x80010031: errorMessage = "Bad Message."; break; case 0x80010032: errorMessage = "In progress."; break; case 0x80010033: errorMessage = "Message size error."; break; case 0x80010034: errorMessage = "Name too long."; break; case 0x80010035: errorMessage = "No lock."; break; case 0x80010036: errorMessage = "Not empty."; break; case 0x80010037: errorMessage = "Not supported."; break; case 0x80010038: errorMessage = "File-system specific error."; break; case 0x80010039: errorMessage = "Overflow occured."; break; case 0x8001003A: errorMessage = "Filesystem not mounted."; break; case 0x8001003B: errorMessage = "Not SData."; break; case 0x8001003C: errorMessage = "Incorrect version in sys_load_param."; break; case 0x8001003D: errorMessage = "Pointer is null."; break; case 0x8001003E: errorMessage = "Pointer is null."; break; default: errorMessage = "An error has occurred."; break; } char errorCodeHex[12]; sprintf(errorCodeHex, "\n(%08x)", errorCode); errorMessage.append(errorCodeHex); u64 status; int res = rMessageBox(errorMessage, "Error", rICON_ERROR | rOK); switch (res) { case rOK: status = CELL_MSGDIALOG_BUTTON_OK; break; default: if (res) { status = CELL_MSGDIALOG_BUTTON_INVALID; break; } status = CELL_MSGDIALOG_BUTTON_NONE; break; } if (callback) callback((s32)status, userData); return CELL_OK; }