ui.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // All rights reserved.
  5. //
  6. // This file is part of SDLPAL.
  7. //
  8. // SDLPAL is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. #include "main.h"
  22. LPSPRITE gpSpriteUI = NULL;
  23. INT
  24. PAL_InitUI(
  25. VOID
  26. )
  27. /*++
  28. Purpose:
  29. Initialze the UI subsystem.
  30. Parameters:
  31. None.
  32. Return value:
  33. 0 = success, -1 = fail.
  34. --*/
  35. {
  36. int iSize;
  37. //
  38. // Load the UI sprite.
  39. //
  40. iSize = PAL_MKFGetChunkSize(CHUNKNUM_SPRITEUI, gpGlobals->f.fpDATA);
  41. if (iSize < 0)
  42. {
  43. return -1;
  44. }
  45. gpSpriteUI = (LPSPRITE)calloc(1, iSize);
  46. if (gpSpriteUI == NULL)
  47. {
  48. return -1;
  49. }
  50. PAL_MKFReadChunk(gpSpriteUI, iSize, CHUNKNUM_SPRITEUI, gpGlobals->f.fpDATA);
  51. return 0;
  52. }
  53. VOID
  54. PAL_FreeUI(
  55. VOID
  56. )
  57. /*++
  58. Purpose:
  59. Shutdown the UI subsystem.
  60. Parameters:
  61. None.
  62. Return value:
  63. None.
  64. --*/
  65. {
  66. if (gpSpriteUI != NULL)
  67. {
  68. free(gpSpriteUI);
  69. gpSpriteUI = NULL;
  70. }
  71. }
  72. LPBOX
  73. PAL_CreateBox(
  74. PAL_POS pos,
  75. INT nRows,
  76. INT nColumns,
  77. INT iStyle,
  78. BOOL fSaveScreen
  79. )
  80. /*++
  81. Purpose:
  82. Create a box on the screen.
  83. Parameters:
  84. [IN] pos - position of the box.
  85. [IN] nRows - number of rows of the box.
  86. [IN] nColumns - number of columns of the box.
  87. [IN] iStyle - style of the box (0 or 1).
  88. [IN] fSaveScreen - whether save the used screen area or not.
  89. Return value:
  90. Pointer to a BOX structure. NULL if failed.
  91. If fSaveScreen is false, then always returns NULL.
  92. --*/
  93. {
  94. int i, j, x, m, n;
  95. LPCBITMAPRLE rglpBorderBitmap[3][3];
  96. LPBOX lpBox = NULL;
  97. SDL_Surface *save;
  98. SDL_Rect rect;
  99. //
  100. // Get the bitmaps
  101. //
  102. for (i = 0; i < 3; i++)
  103. {
  104. for (j = 0; j < 3; j++)
  105. {
  106. rglpBorderBitmap[i][j] = PAL_SpriteGetFrame(gpSpriteUI, i * 3 + j + iStyle * 9);
  107. }
  108. }
  109. rect.x = PAL_X(pos);
  110. rect.y = PAL_Y(pos);
  111. rect.w = 0;
  112. rect.h = 0;
  113. //
  114. // Get the total width and total height of the box
  115. //
  116. for (i = 0; i < 3; i++)
  117. {
  118. if (i == 1)
  119. {
  120. rect.w += PAL_RLEGetWidth(rglpBorderBitmap[0][i]) * nColumns;
  121. rect.h += PAL_RLEGetHeight(rglpBorderBitmap[i][0]) * nRows;
  122. }
  123. else
  124. {
  125. rect.w += PAL_RLEGetWidth(rglpBorderBitmap[0][i]);
  126. rect.h += PAL_RLEGetHeight(rglpBorderBitmap[i][0]);
  127. }
  128. }
  129. if (fSaveScreen)
  130. {
  131. //
  132. // Save the used part of the screen
  133. //
  134. save = SDL_CreateRGBSurface(gpScreen->flags, rect.w, rect.h, 8,
  135. gpScreen->format->Rmask, gpScreen->format->Gmask,
  136. gpScreen->format->Bmask, gpScreen->format->Amask);
  137. if (save == NULL)
  138. {
  139. return NULL;
  140. }
  141. lpBox = (LPBOX)calloc(1, sizeof(BOX));
  142. if (lpBox == NULL)
  143. {
  144. SDL_FreeSurface(save);
  145. return NULL;
  146. }
  147. #if SDL_VERSION_ATLEAST(2,0,0)
  148. SDL_SetSurfacePalette(save, gpScreen->format->palette);
  149. #endif
  150. SDL_BlitSurface(gpScreen, &rect, save, NULL);
  151. lpBox->lpSavedArea = save;
  152. lpBox->pos = pos;
  153. lpBox->wWidth = rect.w;
  154. lpBox->wHeight = rect.h;
  155. }
  156. //
  157. // Border takes 2 additional rows and columns...
  158. //
  159. nRows += 2;
  160. nColumns += 2;
  161. //
  162. // Draw the box
  163. //
  164. for (i = 0; i < nRows; i++)
  165. {
  166. x = rect.x;
  167. m = (i == 0) ? 0 : ((i == nRows - 1) ? 2 : 1);
  168. for (j = 0; j < nColumns; j++)
  169. {
  170. n = (j == 0) ? 0 : ((j == nColumns - 1) ? 2 : 1);
  171. PAL_RLEBlitToSurface(rglpBorderBitmap[m][n], gpScreen, PAL_XY(x, rect.y));
  172. x += PAL_RLEGetWidth(rglpBorderBitmap[m][n]);
  173. }
  174. rect.y += PAL_RLEGetHeight(rglpBorderBitmap[m][0]);
  175. }
  176. return lpBox;
  177. }
  178. LPBOX
  179. PAL_CreateSingleLineBox(
  180. PAL_POS pos,
  181. INT nLen,
  182. BOOL fSaveScreen
  183. )
  184. /*++
  185. Purpose:
  186. Create a single-line box on the screen.
  187. Parameters:
  188. [IN] pos - position of the box.
  189. [IN] nLen - length of the box.
  190. [IN] fSaveScreen - whether save the used screen area or not.
  191. Return value:
  192. Pointer to a BOX structure. NULL if failed.
  193. If fSaveScreen is false, then always returns NULL.
  194. --*/
  195. {
  196. static const int iNumLeftSprite = 44;
  197. static const int iNumMidSprite = 45;
  198. static const int iNumRightSprite = 46;
  199. LPCBITMAPRLE lpBitmapLeft;
  200. LPCBITMAPRLE lpBitmapMid;
  201. LPCBITMAPRLE lpBitmapRight;
  202. SDL_Surface *save;
  203. SDL_Rect rect;
  204. LPBOX lpBox = NULL;
  205. int i;
  206. //
  207. // Get the bitmaps
  208. //
  209. lpBitmapLeft = PAL_SpriteGetFrame(gpSpriteUI, iNumLeftSprite);
  210. lpBitmapMid = PAL_SpriteGetFrame(gpSpriteUI, iNumMidSprite);
  211. lpBitmapRight = PAL_SpriteGetFrame(gpSpriteUI, iNumRightSprite);
  212. rect.x = PAL_X(pos);
  213. rect.y = PAL_Y(pos);
  214. //
  215. // Get the total width and total height of the box
  216. //
  217. rect.w = PAL_RLEGetWidth(lpBitmapLeft) + PAL_RLEGetWidth(lpBitmapRight);
  218. rect.w += PAL_RLEGetWidth(lpBitmapMid) * nLen;
  219. rect.h = PAL_RLEGetHeight(lpBitmapLeft);
  220. if (fSaveScreen)
  221. {
  222. //
  223. // Save the used part of the screen
  224. //
  225. save = SDL_CreateRGBSurface(gpScreen->flags, rect.w, rect.h, 8,
  226. gpScreen->format->Rmask, gpScreen->format->Gmask,
  227. gpScreen->format->Bmask, gpScreen->format->Amask);
  228. if (save == NULL)
  229. {
  230. return NULL;
  231. }
  232. lpBox = (LPBOX)calloc(1, sizeof(BOX));
  233. if (lpBox == NULL)
  234. {
  235. SDL_FreeSurface(gpScreen);
  236. return NULL;
  237. }
  238. #if SDL_VERSION_ATLEAST(2,0,0)
  239. SDL_SetSurfacePalette(save, gpScreen->format->palette);
  240. #endif
  241. SDL_BlitSurface(gpScreen, &rect, save, NULL);
  242. lpBox->pos = pos;
  243. lpBox->lpSavedArea = save;
  244. lpBox->wHeight = (WORD)rect.w;
  245. lpBox->wWidth = (WORD)rect.h;
  246. }
  247. //
  248. // Draw the box
  249. //
  250. PAL_RLEBlitToSurface(lpBitmapLeft, gpScreen, pos);
  251. rect.x += PAL_RLEGetWidth(lpBitmapLeft);
  252. for (i = 0; i < nLen; i++)
  253. {
  254. PAL_RLEBlitToSurface(lpBitmapMid, gpScreen, PAL_XY(rect.x, rect.y));
  255. rect.x += PAL_RLEGetWidth(lpBitmapMid);
  256. }
  257. PAL_RLEBlitToSurface(lpBitmapRight, gpScreen, PAL_XY(rect.x, rect.y));
  258. return lpBox;
  259. }
  260. VOID
  261. PAL_DeleteBox(
  262. LPBOX lpBox
  263. )
  264. /*++
  265. Purpose:
  266. Delete a box and restore the saved part of the screen.
  267. Parameters:
  268. [IN] lpBox - pointer to the BOX struct.
  269. Return value:
  270. None.
  271. --*/
  272. {
  273. SDL_Rect rect;
  274. //
  275. // Check for NULL pointer.
  276. //
  277. if (lpBox == NULL)
  278. {
  279. return;
  280. }
  281. //
  282. // Restore the saved screen part
  283. //
  284. rect.x = PAL_X(lpBox->pos);
  285. rect.y = PAL_Y(lpBox->pos);
  286. rect.w = lpBox->wWidth;
  287. rect.h = lpBox->wHeight;
  288. SDL_BlitSurface(lpBox->lpSavedArea, NULL, gpScreen, &rect);
  289. //
  290. // Free the memory used by the box
  291. //
  292. SDL_FreeSurface(lpBox->lpSavedArea);
  293. free(lpBox);
  294. }
  295. WORD
  296. PAL_ReadMenu(
  297. LPITEMCHANGED_CALLBACK lpfnMenuItemChanged,
  298. LPMENUITEM rgMenuItem,
  299. INT nMenuItem,
  300. WORD wDefaultItem,
  301. BYTE bLabelColor
  302. )
  303. /*++
  304. Purpose:
  305. Execute a menu.
  306. Parameters:
  307. [IN] lpfnMenuItemChanged - Callback function which is called when user
  308. changed the current menu item.
  309. [IN] rgMenuItem - Array of the menu items.
  310. [IN] nMenuItem - Number of menu items.
  311. [IN] wDefaultItem - default item index.
  312. [IN] bLabelColor - color of the labels.
  313. Return value:
  314. Return value of the selected menu item. MENUITEM_VALUE_CANCELLED if cancelled.
  315. --*/
  316. {
  317. int i;
  318. WORD wCurrentItem = (wDefaultItem < nMenuItem) ? wDefaultItem : 0;
  319. //
  320. // Draw all the menu texts.
  321. //
  322. for (i = 0; i < nMenuItem; i++)
  323. {
  324. BYTE bColor = bLabelColor;
  325. if (!rgMenuItem[i].fEnabled)
  326. {
  327. if (i == wCurrentItem)
  328. {
  329. bColor = MENUITEM_COLOR_SELECTED_INACTIVE;
  330. }
  331. else
  332. {
  333. bColor = MENUITEM_COLOR_INACTIVE;
  334. }
  335. }
  336. PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos,
  337. bColor, TRUE, TRUE);
  338. }
  339. if (lpfnMenuItemChanged != NULL)
  340. {
  341. (*lpfnMenuItemChanged)(rgMenuItem[wDefaultItem].wValue);
  342. }
  343. while (TRUE)
  344. {
  345. PAL_ClearKeyState();
  346. //
  347. // Redraw the selected item if needed.
  348. //
  349. if (rgMenuItem[wCurrentItem].fEnabled)
  350. {
  351. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  352. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  353. }
  354. PAL_ProcessEvent();
  355. if (g_InputState.dwKeyPress & (kKeyDown | kKeyRight))
  356. {
  357. //
  358. // User pressed the down or right arrow key
  359. //
  360. if (rgMenuItem[wCurrentItem].fEnabled)
  361. {
  362. //
  363. // Dehighlight the unselected item.
  364. //
  365. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  366. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  367. }
  368. else
  369. {
  370. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  371. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  372. }
  373. wCurrentItem++;
  374. if (wCurrentItem >= nMenuItem)
  375. {
  376. wCurrentItem = 0;
  377. }
  378. //
  379. // Highlight the selected item.
  380. //
  381. if (rgMenuItem[wCurrentItem].fEnabled)
  382. {
  383. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  384. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  385. }
  386. else
  387. {
  388. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  389. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
  390. }
  391. if (lpfnMenuItemChanged != NULL)
  392. {
  393. (*lpfnMenuItemChanged)(rgMenuItem[wCurrentItem].wValue);
  394. }
  395. }
  396. else if (g_InputState.dwKeyPress & (kKeyUp | kKeyLeft))
  397. {
  398. //
  399. // User pressed the up or left arrow key
  400. //
  401. if (rgMenuItem[wCurrentItem].fEnabled)
  402. {
  403. //
  404. // Dehighlight the unselected item.
  405. //
  406. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  407. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  408. }
  409. else
  410. {
  411. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  412. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  413. }
  414. if (wCurrentItem > 0)
  415. {
  416. wCurrentItem--;
  417. }
  418. else
  419. {
  420. wCurrentItem = nMenuItem - 1;
  421. }
  422. //
  423. // Highlight the selected item.
  424. //
  425. if (rgMenuItem[wCurrentItem].fEnabled)
  426. {
  427. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  428. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  429. }
  430. else
  431. {
  432. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  433. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
  434. }
  435. if (lpfnMenuItemChanged != NULL)
  436. {
  437. (*lpfnMenuItemChanged)(rgMenuItem[wCurrentItem].wValue);
  438. }
  439. }
  440. else if (g_InputState.dwKeyPress & kKeyMenu)
  441. {
  442. //
  443. // User cancelled
  444. //
  445. if (rgMenuItem[wCurrentItem].fEnabled)
  446. {
  447. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  448. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  449. }
  450. else
  451. {
  452. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  453. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  454. }
  455. break;
  456. }
  457. else if (g_InputState.dwKeyPress & kKeySearch)
  458. {
  459. //
  460. // User pressed Enter
  461. //
  462. if (rgMenuItem[wCurrentItem].fEnabled)
  463. {
  464. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  465. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_CONFIRMED, FALSE, TRUE);
  466. return rgMenuItem[wCurrentItem].wValue;
  467. }
  468. }
  469. //
  470. // Use delay function to avoid high CPU usage.
  471. //
  472. SDL_Delay(50);
  473. }
  474. return MENUITEM_VALUE_CANCELLED;
  475. }
  476. VOID
  477. PAL_DrawNumber(
  478. UINT iNum,
  479. UINT nLength,
  480. PAL_POS pos,
  481. NUMCOLOR color,
  482. NUMALIGN align
  483. )
  484. /*++
  485. Purpose:
  486. Draw the specified number with the bitmaps in the UI sprite.
  487. Parameters:
  488. [IN] iNum - the number to be drawn.
  489. [IN] nLength - max. length of the number.
  490. [IN] pos - position on the screen.
  491. [IN] color - color of the number (yellow or blue).
  492. [IN] align - align mode of the number.
  493. Return value:
  494. None.
  495. --*/
  496. {
  497. UINT nActualLength, i;
  498. int x, y;
  499. LPCBITMAPRLE rglpBitmap[10];
  500. //
  501. // Get the bitmaps. Blue starts from 29, Cyan from 56, Yellow from 19.
  502. //
  503. x = (color == kNumColorBlue) ? 29 : ((color == kNumColorCyan) ? 56 : 19);
  504. for (i = 0; i < 10; i++)
  505. {
  506. rglpBitmap[i] = PAL_SpriteGetFrame(gpSpriteUI, (UINT)x + i);
  507. }
  508. i = iNum;
  509. nActualLength = 0;
  510. //
  511. // Calculate the actual length of the number.
  512. //
  513. while (i > 0)
  514. {
  515. i /= 10;
  516. nActualLength++;
  517. }
  518. if (nActualLength > nLength)
  519. {
  520. nActualLength = nLength;
  521. }
  522. else if (nActualLength == 0)
  523. {
  524. nActualLength = 1;
  525. }
  526. x = PAL_X(pos) - 6;
  527. y = PAL_Y(pos);
  528. switch (align)
  529. {
  530. case kNumAlignLeft:
  531. x += 6 * nActualLength;
  532. break;
  533. case kNumAlignMid:
  534. x += 3 * (nLength + nActualLength);
  535. break;
  536. case kNumAlignRight:
  537. x += 6 * nLength;
  538. break;
  539. }
  540. //
  541. // Draw the number.
  542. //
  543. while (nActualLength-- > 0)
  544. {
  545. PAL_RLEBlitToSurface(rglpBitmap[iNum % 10], gpScreen, PAL_XY(x, y));
  546. x -= 6;
  547. iNum /= 10;
  548. }
  549. }
  550. LPOBJECTDESC
  551. PAL_LoadObjectDesc(
  552. LPCSTR lpszFileName
  553. )
  554. /*++
  555. Purpose:
  556. Load the object description strings from file.
  557. Parameters:
  558. [IN] lpszFileName - the filename to be loaded.
  559. Return value:
  560. Pointer to loaded data, in linked list form. NULL if unable to load.
  561. --*/
  562. {
  563. FILE *fp;
  564. PAL_LARGE char buf[512];
  565. char *p;
  566. LPOBJECTDESC lpDesc = NULL, pNew = NULL;
  567. unsigned int i;
  568. fp = fopen(lpszFileName, "r");
  569. if (fp == NULL)
  570. {
  571. return NULL;
  572. }
  573. //
  574. // Load the description data
  575. //
  576. while (fgets(buf, 512, fp) != NULL)
  577. {
  578. p = strchr(buf, '=');
  579. if (p == NULL)
  580. {
  581. continue;
  582. }
  583. *p = '\0';
  584. p++;
  585. pNew = UTIL_calloc(1, sizeof(OBJECTDESC));
  586. sscanf(buf, "%x", &i);
  587. pNew->wObjectID = i;
  588. pNew->lpDesc = strdup(p);
  589. pNew->next = lpDesc;
  590. lpDesc = pNew;
  591. }
  592. fclose(fp);
  593. return lpDesc;
  594. }
  595. VOID
  596. PAL_FreeObjectDesc(
  597. LPOBJECTDESC lpObjectDesc
  598. )
  599. /*++
  600. Purpose:
  601. Free the object description data.
  602. Parameters:
  603. [IN] lpObjectDesc - the description data to be freed.
  604. Return value:
  605. None.
  606. --*/
  607. {
  608. LPOBJECTDESC p;
  609. while (lpObjectDesc != NULL)
  610. {
  611. p = lpObjectDesc->next;
  612. free(lpObjectDesc->lpDesc);
  613. free(lpObjectDesc);
  614. lpObjectDesc = p;
  615. }
  616. }
  617. LPCSTR
  618. PAL_GetObjectDesc(
  619. LPOBJECTDESC lpObjectDesc,
  620. WORD wObjectID
  621. )
  622. /*++
  623. Purpose:
  624. Get the object description string from the linked list.
  625. Parameters:
  626. [IN] lpObjectDesc - the description data linked list.
  627. [IN] wObjectID - the object ID.
  628. Return value:
  629. The description string. NULL if the specified object ID
  630. is not found.
  631. --*/
  632. {
  633. while (lpObjectDesc != NULL)
  634. {
  635. if (lpObjectDesc->wObjectID == wObjectID)
  636. {
  637. return lpObjectDesc->lpDesc;
  638. }
  639. lpObjectDesc = lpObjectDesc->next;
  640. }
  641. return NULL;
  642. }