guiGameListMenuCtrl.cpp 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "guiGameListMenuCtrl.h"
  23. #include "console/consoleTypes.h"
  24. #include "console/engineAPI.h"
  25. #include "gfx/gfxDrawUtil.h"
  26. #include "gui/containers/guiScrollCtrl.h"
  27. #include "sim/actionMap.h"
  28. #include "core/strings/stringUnit.h"
  29. //-----------------------------------------------------------------------------
  30. // GuiGameListMenuCtrl
  31. //-----------------------------------------------------------------------------
  32. GuiGameListMenuCtrl::GuiGameListMenuCtrl()
  33. : mSelected(NO_ROW),
  34. mDebugRender(false),
  35. mHighlighted(NO_ROW),
  36. mCallbackOnInputs(false),
  37. mConsumeKeyInputEvents(false)
  38. {
  39. VECTOR_SET_ASSOCIATION(mRows);
  40. // initialize the control callbacks
  41. mCallbackOnA = StringTable->EmptyString();
  42. mCallbackOnB = mCallbackOnA;
  43. mCallbackOnX = mCallbackOnA;
  44. mCallbackOnY = mCallbackOnA;
  45. }
  46. GuiGameListMenuCtrl::~GuiGameListMenuCtrl()
  47. {
  48. for (S32 i = 0; i < mRows.size(); ++i)
  49. {
  50. delete mRows[i];
  51. }
  52. }
  53. void GuiGameListMenuCtrl::onRender(Point2I offset, const RectI &updateRect)
  54. {
  55. GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
  56. GFXDrawUtil* drawUtil = GFX->getDrawUtil();
  57. F32 xScale = (float) getWidth() / profile->getRowWidth();
  58. bool profileHasIcons = profile->hasArrows();
  59. S32 rowHeight = profile->getRowHeight();
  60. Point2I currentOffset = offset;
  61. Point2I extent = getExtent();
  62. Point2I rowExtent(extent.x, rowHeight);
  63. Point2I textOffset(profile->mTextOffset.x * xScale, profile->mTextOffset.y);
  64. Point2I textExtent(extent.x - textOffset.x, rowHeight);
  65. Point2I iconExtent, iconOffset(0.0f, 0.0f);
  66. if (profileHasIcons)
  67. {
  68. iconExtent = profile->getIconExtent();
  69. // icon is centered vertically plus any specified offset
  70. S32 iconOffsetY = (rowHeight - iconExtent.y) >> 1;
  71. iconOffsetY += profile->mIconOffset.y;
  72. iconOffset = Point2I(profile->mIconOffset.x * xScale, iconOffsetY);
  73. }
  74. for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
  75. {
  76. if (row != mRows.begin())
  77. {
  78. // rows other than the first can have padding above them
  79. currentOffset.y += (*row)->mHeightPad;
  80. currentOffset.y += rowHeight;
  81. }
  82. // select appropriate colors and textures
  83. ColorI fontColor;
  84. U32 buttonTextureIndex;
  85. S32 iconIndex = (*row)->mIconIndex;
  86. bool useHighlightIcon = (*row)->mUseHighlightIcon;
  87. if (!(*row)->mEnabled)
  88. {
  89. buttonTextureIndex = Profile::TEX_DISABLED;
  90. fontColor = profile->mFontColorNA;
  91. }
  92. else if (row == &mRows[mSelected])
  93. {
  94. if (iconIndex != NO_ICON)
  95. {
  96. iconIndex++;
  97. }
  98. buttonTextureIndex = Profile::TEX_SELECTED;
  99. fontColor = profile->mFontColorSEL;
  100. }
  101. else if ((mHighlighted != NO_ROW) && (row == &mRows[mHighlighted]))
  102. {
  103. if (iconIndex != NO_ICON && useHighlightIcon)
  104. {
  105. iconIndex++;
  106. }
  107. buttonTextureIndex = Profile::TEX_HIGHLIGHT;
  108. fontColor = profile->mFontColorHL;
  109. }
  110. else
  111. {
  112. buttonTextureIndex = Profile::TEX_NORMAL;
  113. fontColor = profile->mFontColor;
  114. }
  115. // render the row bitmap
  116. drawUtil->clearBitmapModulation();
  117. drawUtil->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));
  118. // render the row icon if it has one
  119. if ((iconIndex != NO_ICON) && profileHasIcons && (!profile->getBitmapArrayRect((U32)iconIndex).extent.isZero()))
  120. {
  121. iconIndex += Profile::TEX_FIRST_ICON;
  122. drawUtil->clearBitmapModulation();
  123. drawUtil->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
  124. }
  125. // render the row text
  126. drawUtil->setBitmapModulation(fontColor);
  127. renderJustifiedText(currentOffset + textOffset, textExtent, (*row)->mLabel);
  128. if ((*row)->mMode == Row::Mode::OptionList)
  129. {
  130. onRenderListOption((*row), currentOffset);
  131. }
  132. else if ((*row)->mMode == Row::Mode::Slider)
  133. {
  134. onRenderSliderOption((*row), currentOffset);
  135. }
  136. else if ((*row)->mMode == Row::Mode::Keybind)
  137. {
  138. onRenderKeybindOption((*row), currentOffset);
  139. }
  140. }
  141. if (mDebugRender)
  142. {
  143. onDebugRender(offset);
  144. }
  145. renderChildControls(offset, updateRect);
  146. }
  147. void GuiGameListMenuCtrl::onRenderListOption(Row* row, Point2I currentOffset)
  148. {
  149. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  150. F32 xScale = (float)getWidth() / profile->getRowWidth();
  151. S32 rowHeight = profile->getRowHeight();
  152. bool profileHasArrows = profile->hasArrows();
  153. Point2I arrowExtent;
  154. S32 arrowOffsetY(0);
  155. if (profileHasArrows)
  156. {
  157. arrowExtent = profile->getArrowExtent();
  158. // icon is centered vertically
  159. arrowOffsetY = (rowHeight - arrowExtent.y) >> 1;
  160. }
  161. GFXDrawUtil* drawer = GFX->getDrawUtil();
  162. Point2I arrowOffset;
  163. S32 columnSplit = profile->mColumnSplit * xScale;
  164. S32 iconIndex;
  165. bool hasOptions = (row->mOptions.size() > 0) && row->mSelectedOption > -1;
  166. if (hasOptions)
  167. {
  168. bool isRowSelected = (getSelected() != NO_ROW) && (row == mRows[getSelected()]);
  169. bool isRowHighlighted = (getHighlighted() != NO_ROW) ? ((row == mRows[getHighlighted()]) && (row->mEnabled)) : false;
  170. if (profileHasArrows)
  171. {
  172. // render the left arrow
  173. bool arrowOnL = (isRowSelected || isRowHighlighted) && (row->mWrapOptions || (row->mSelectedOption > 0));
  174. iconIndex = (arrowOnL) ? Profile::TEX_L_ARROW_ON : Profile::TEX_L_ARROW_OFF;
  175. arrowOffset.x = currentOffset.x + columnSplit;
  176. arrowOffset.y = currentOffset.y + arrowOffsetY;
  177. drawer->clearBitmapModulation();
  178. drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
  179. // render the right arrow
  180. bool arrowOnR = (isRowSelected || isRowHighlighted) && (row->mWrapOptions || (row->mSelectedOption < row->mOptions.size() - 1));
  181. iconIndex = (arrowOnR) ? Profile::TEX_R_ARROW_ON : Profile::TEX_R_ARROW_OFF;
  182. arrowOffset.x = currentOffset.x + (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale - arrowExtent.x;
  183. arrowOffset.y = currentOffset.y + arrowOffsetY;
  184. drawer->clearBitmapModulation();
  185. drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
  186. }
  187. // get the appropriate font color
  188. ColorI fontColor;
  189. if (!row->mEnabled)
  190. {
  191. fontColor = profile->mFontColorNA;
  192. }
  193. else if (isRowSelected)
  194. {
  195. fontColor = profile->mFontColorSEL;
  196. }
  197. else if (isRowHighlighted)
  198. {
  199. fontColor = profile->mFontColorHL;
  200. }
  201. else
  202. {
  203. fontColor = profile->mFontColor;
  204. }
  205. // calculate text to be at the center between the arrows
  206. GFont* font = profile->mFont;
  207. StringTableEntry text = row->mOptions[row->mSelectedOption];
  208. S32 textWidth = font->getStrWidth(text);
  209. S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
  210. S32 columnCenter = columnSplit + (columnWidth >> 1);
  211. S32 textStartX = columnCenter - (textWidth >> 1);
  212. Point2I textOffset(textStartX, 0);
  213. // render the option text itself
  214. Point2I textExtent(columnWidth, rowHeight);
  215. drawer->setBitmapModulation(fontColor);
  216. renderJustifiedText(currentOffset + textOffset, textExtent, text);
  217. }
  218. }
  219. void GuiGameListMenuCtrl::onRenderSliderOption(Row* row, Point2I currentOffset)
  220. {
  221. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  222. F32 xScale = (float)getWidth() / profile->getRowWidth();
  223. S32 rowHeight = profile->getRowHeight();
  224. bool profileHasArrows = profile->hasArrows();
  225. Point2I arrowExtent;
  226. S32 arrowOffsetY(0);
  227. if (profileHasArrows)
  228. {
  229. arrowExtent = profile->getArrowExtent();
  230. // icon is centered vertically
  231. arrowOffsetY = (rowHeight - arrowExtent.y) >> 1;
  232. }
  233. GFXDrawUtil* drawer = GFX->getDrawUtil();
  234. Point2I arrowOffset;
  235. S32 columnSplit = profile->mColumnSplit * xScale;
  236. S32 iconIndex;
  237. bool isRowSelected = (getSelected() != NO_ROW) && (row == mRows[getSelected()]);
  238. bool isRowHighlighted = (getHighlighted() != NO_ROW) ? ((row == mRows[getHighlighted()]) && (row->mEnabled)) : false;
  239. /*if (profileHasArrows)
  240. {
  241. // render the left arrow
  242. bool arrowOnL = (isRowSelected || isRowHighlighted) && (row->mValue > row->mRange.x);
  243. iconIndex = (arrowOnL) ? Profile::TEX_L_ARROW_ON : Profile::TEX_L_ARROW_OFF;
  244. arrowOffset.x = currentOffset.x + columnSplit;
  245. arrowOffset.y = currentOffset.y + arrowOffsetY;
  246. drawer->clearBitmapModulation();
  247. drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
  248. // render the right arrow
  249. bool arrowOnR = (isRowSelected || isRowHighlighted) && (row->mValue < row->mRange.y);
  250. iconIndex = (arrowOnR) ? Profile::TEX_R_ARROW_ON : Profile::TEX_R_ARROW_OFF;
  251. arrowOffset.x = currentOffset.x + (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale - arrowExtent.x;
  252. arrowOffset.y = currentOffset.y + arrowOffsetY;
  253. drawer->clearBitmapModulation();
  254. drawer->drawBitmapStretchSR(profile->mTextureObject, RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
  255. }*/
  256. //Draw the slider bar
  257. if (row->mEnabled)
  258. {
  259. RectI sliderRect;
  260. sliderRect.point.x = currentOffset.x + columnSplit + arrowExtent.x;
  261. sliderRect.point.y = currentOffset.y + arrowOffsetY;
  262. sliderRect.extent.x = (currentOffset.x + (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale - arrowExtent.x) - sliderRect.point.x;
  263. sliderRect.extent.y = arrowExtent.y;
  264. //Now adjust the bar to match-to our value
  265. S32 barStart = sliderRect.point.x;
  266. S32 barEnd = sliderRect.point.x + sliderRect.extent.x;
  267. S32 xPosFill = (((row->mValue - row->mRange.x) * (barEnd - barStart)) / (row->mRange.y - row->mRange.x)) + barStart;
  268. RectI fillRect = sliderRect;
  269. fillRect.extent.x = xPosFill - sliderRect.point.x;
  270. ColorI barColor;
  271. ColorI barOutlineColor;
  272. if (isRowSelected)
  273. {
  274. barColor = profile->mFillColor;
  275. barOutlineColor = profile->mFillColorSEL;
  276. }
  277. else
  278. {
  279. barColor = profile->mFillColor;
  280. barOutlineColor = profile->mFillColorHL;
  281. }
  282. drawer->drawRectFill(fillRect, barColor);
  283. drawer->drawRect(sliderRect, barOutlineColor);
  284. }
  285. // get the appropriate font color
  286. ColorI fontColor;
  287. if (!row->mEnabled)
  288. {
  289. fontColor = profile->mFontColorNA;
  290. }
  291. else if (isRowSelected)
  292. {
  293. fontColor = profile->mFontColorSEL;
  294. }
  295. else if (isRowHighlighted)
  296. {
  297. fontColor = profile->mFontColorHL;
  298. }
  299. else
  300. {
  301. fontColor = profile->mFontColor;
  302. }
  303. // calculate text to be at the center between the arrows
  304. GFont* font = profile->mFont;
  305. ConsoleValue val;
  306. val.setFloatValue(row->mValue);
  307. const char* stringVal = val.getStringValue();
  308. S32 textWidth = font->getStrWidth(stringVal);
  309. S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
  310. S32 columnCenter = columnSplit + (columnWidth >> 1);
  311. S32 textStartX = columnCenter - (textWidth >> 1);
  312. Point2I textOffset(textStartX, 0);
  313. // render the option text itself
  314. Point2I textExtent(columnWidth, rowHeight);
  315. drawer->setBitmapModulation(fontColor);
  316. renderJustifiedText(currentOffset + textOffset, textExtent, stringVal);
  317. }
  318. void GuiGameListMenuCtrl::onRenderKeybindOption(Row* row, Point2I currentOffset)
  319. {
  320. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  321. F32 xScale = (float)getWidth() / profile->getRowWidth();
  322. S32 columnSplit = profile->mColumnSplit * xScale;
  323. S32 rowHeight = profile->getRowHeight();
  324. S32 optionWidth = xScale - columnSplit;
  325. GFXDrawUtil* drawer = GFX->getDrawUtil();
  326. //drawer->drawBitmap(row->mBitmap, )
  327. Point2I button;
  328. button.x = currentOffset.x + columnSplit + (columnSplit / 2.5)/* + (optionWidth / 2)*/;
  329. button.y = currentOffset.y + (rowHeight / 4);
  330. Point2I buttonSize;
  331. buttonSize.x = rowHeight / 2;
  332. buttonSize.y = rowHeight / 2;
  333. if (row->mBitmapTex.isValid())
  334. {
  335. GFXTextureObject* texture = row->mBitmapTex;
  336. RectI rect(button, buttonSize);
  337. drawer->clearBitmapModulation();
  338. drawer->drawBitmapStretch(texture, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
  339. }
  340. //drawer->drawRectFill(button, ColorI::BLUE);
  341. }
  342. void GuiGameListMenuCtrl::onDebugRender(Point2I offset)
  343. {
  344. GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
  345. F32 xScale = (float) getWidth() / profile->getRowWidth();
  346. ColorI controlBorderColor(200, 200, 200); // gray
  347. ColorI rowBorderColor(255, 127, 255); // magenta
  348. ColorI hitBorderColor(255, 0, 0); // red
  349. Point2I shrinker(-1, -1);
  350. Point2I extent = getExtent();
  351. // render a border around the entire control
  352. RectI borderRect(offset, extent + shrinker);
  353. GFX->getDrawUtil()->drawRect(borderRect, controlBorderColor);
  354. S32 rowHeight = profile->getRowHeight();
  355. Point2I currentOffset(offset);
  356. Point2I rowExtent(extent.x, rowHeight);
  357. rowExtent += shrinker;
  358. Point2I hitAreaExtent(profile->getHitAreaExtent());
  359. hitAreaExtent.x *= xScale;
  360. hitAreaExtent += shrinker;
  361. Point2I hitAreaOffset = profile->mHitAreaUpperLeft;
  362. hitAreaOffset.x *= xScale;
  363. Point2I upperLeft;
  364. for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
  365. {
  366. // set the top of the current row
  367. if (row != mRows.begin())
  368. {
  369. // rows other than the first can have padding above them
  370. currentOffset.y += (*row)->mHeightPad;
  371. currentOffset.y += rowHeight;
  372. }
  373. // draw the box around the whole row's extent
  374. upperLeft = currentOffset;
  375. borderRect.point = upperLeft;
  376. borderRect.extent = rowExtent;
  377. GFX->getDrawUtil()->drawRect(borderRect, rowBorderColor);
  378. // draw the box around the hit area of the row
  379. upperLeft = currentOffset + hitAreaOffset;
  380. borderRect.point = upperLeft;
  381. borderRect.extent = hitAreaExtent;
  382. GFX->getDrawUtil()->drawRect(borderRect, hitBorderColor);
  383. }
  384. }
  385. void GuiGameListMenuCtrl::addRow(const char* label, const char* callback, S32 icon, S32 yPad, bool useHighlightIcon, bool enabled, S32 mode, const char* tooltip)
  386. {
  387. Row * row = new Row();
  388. addRow(row, label, callback, icon, yPad, useHighlightIcon, enabled, mode, tooltip);
  389. }
  390. void GuiGameListMenuCtrl::addRow(Row * row, const char* label, const char* callback, S32 icon, S32 yPad, bool useHighlightIcon, bool enabled, S32 mode, const char* tooltip)
  391. {
  392. row->mLabel = StringTable->insert(label, true);
  393. row->mScriptCallback = (dStrlen(callback) > 0) ? StringTable->insert(callback, true) : NULL;
  394. row->mIconIndex = (icon < 0) ? NO_ICON : icon;
  395. row->mHeightPad = yPad;
  396. row->mUseHighlightIcon = useHighlightIcon;
  397. row->mEnabled = enabled;
  398. row->mMode = (Row::Mode)mode;
  399. row->mTooltip = StringTable->insert(tooltip);
  400. mRows.push_back(row);
  401. updateHeight();
  402. if (mSelected == NO_ROW)
  403. {
  404. selectFirstEnabledRow();
  405. }
  406. }
  407. void GuiGameListMenuCtrl::addRow(const char* label, const char* optionsList, bool wrapOptions, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip, const char* defaultValue)
  408. {
  409. static StringTableEntry DELIM = StringTable->insert("\t", true);
  410. Row* row = new Row();
  411. Vector<StringTableEntry> options(__FILE__, __LINE__);
  412. S32 defaultOption = 0;
  413. S32 count = StringUnit::getUnitCount(optionsList, DELIM);
  414. for (S32 i = 0; i < count; ++i)
  415. {
  416. const char* option = StringUnit::getUnit(optionsList, i, DELIM);
  417. options.push_back(StringTable->insert(option, true));
  418. if (String::compare(option, defaultValue) == 0)
  419. defaultOption = options.size() - 1;
  420. }
  421. row->mOptions = options;
  422. bool hasOptions = row->mOptions.size() > 0;
  423. row->mSelectedOption = (hasOptions) ? defaultOption : NO_OPTION;
  424. row->mWrapOptions = wrapOptions;
  425. addRow(row, label, callback, icon, yPad, true, (hasOptions) ? enabled : false, Row::Mode::OptionList, tooltip);
  426. }
  427. void GuiGameListMenuCtrl::addRow(const char* label, F32 defaultValue, F32 increments, Point2F range, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip)
  428. {
  429. static StringTableEntry DELIM = StringTable->insert("\t", true);
  430. Row* row = new Row();
  431. row->mValue = defaultValue;
  432. row->mStepSize = increments;
  433. row->mRange = range;
  434. addRow(row, label, callback, icon, yPad, true, enabled, Row::Mode::Slider, tooltip);
  435. }
  436. void GuiGameListMenuCtrl::addRow(const char* label, const char* bitmapName, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip)
  437. {
  438. static StringTableEntry DELIM = StringTable->insert("\t", true);
  439. Row* row = new Row();
  440. row->mBitmap = StringTable->insert(bitmapName);
  441. if(row->mBitmap != StringTable->EmptyString())
  442. row->mBitmapTex.set(row->mBitmap, &GFXDefaultGUIProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
  443. addRow(row, label, callback, icon, yPad, true, enabled, Row::Mode::Keybind, tooltip);
  444. }
  445. void GuiGameListMenuCtrl::removeRow(const S32& row)
  446. {
  447. if (row == -1 || row >= mRows.size())
  448. return;
  449. mRows.erase(row);
  450. }
  451. Point2I GuiGameListMenuCtrl::getMinExtent() const
  452. {
  453. Point2I parentMin = Parent::getMinExtent();
  454. GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
  455. S32 minHeight = 0;
  456. S32 rowHeight = profile->getRowHeight();
  457. for (Vector<Row *>::const_iterator row = mRows.begin(); row < mRows.end(); ++row)
  458. {
  459. minHeight += rowHeight;
  460. if (row != mRows.begin())
  461. {
  462. minHeight += (*row)->mHeightPad;
  463. }
  464. }
  465. if (minHeight > parentMin.y)
  466. parentMin.y = minHeight;
  467. return parentMin;
  468. }
  469. bool GuiGameListMenuCtrl::onAdd()
  470. {
  471. if( !Parent::onAdd() )
  472. return false;
  473. // If we have a non-GuiGameListMenuProfile profile, try to
  474. // substitute it for DefaultListMenuProfile.
  475. if( !hasValidProfile() )
  476. {
  477. GuiGameListMenuProfile* profile;
  478. if( !Sim::findObject( "DefaultListMenuProfile", profile ) )
  479. {
  480. Con::errorf( "GuiGameListMenuCtrl: %s can't be created with a profile of type %s. Please create it with a profile of type GuiGameListMenuProfile.",
  481. getName(), mProfile->getClassName() );
  482. return false;
  483. }
  484. else
  485. Con::warnf( "GuiGameListMenuCtrl: substituted non-GuiGameListMenuProfile in %s for DefaultListMenuProfile", getName() );
  486. setControlProfile( profile );
  487. }
  488. return true;
  489. }
  490. bool GuiGameListMenuCtrl::onWake()
  491. {
  492. if( !Parent::onWake() )
  493. return false;
  494. if( !hasValidProfile() )
  495. return false;
  496. /*if( mRows.empty() )
  497. {
  498. Con::errorf( "GuiGameListMenuCtrl: %s can't be woken up without any rows. Please use \"addRow\" to add at least one row to the control before pushing it to the canvas.",
  499. getName() );
  500. return false;
  501. }*/
  502. enforceConstraints();
  503. selectFirstEnabledRow();
  504. setFirstResponder();
  505. mHighlighted = NO_ROW;
  506. return true;
  507. }
  508. bool GuiGameListMenuCtrl::hasValidProfile() const
  509. {
  510. GuiGameListMenuProfile * profile = dynamic_cast<GuiGameListMenuProfile *>(mProfile);
  511. return profile;
  512. }
  513. void GuiGameListMenuCtrl::enforceConstraints()
  514. {
  515. if( hasValidProfile() )
  516. {
  517. ((GuiGameListMenuProfile *)mProfile)->enforceConstraints();
  518. }
  519. updateHeight();
  520. }
  521. void GuiGameListMenuCtrl::updateHeight()
  522. {
  523. S32 minHeight = getMinExtent().y;
  524. if (getHeight() < minHeight)
  525. {
  526. setHeight(minHeight);
  527. }
  528. }
  529. void GuiGameListMenuCtrl::onMouseDown(const GuiEvent &event)
  530. {
  531. S32 hitRow = getRow(event.mousePoint);
  532. if (hitRow != NO_ROW)
  533. {
  534. S32 delta = (mSelected != NO_ROW) ? (hitRow - mSelected) : (mSelected + 1);
  535. changeRow(delta);
  536. }
  537. }
  538. void GuiGameListMenuCtrl::onMouseLeave(const GuiEvent &event)
  539. {
  540. mHighlighted = NO_ROW;
  541. }
  542. void GuiGameListMenuCtrl::onMouseMove(const GuiEvent &event)
  543. {
  544. S32 hitRow = getRow(event.mousePoint);
  545. // allow mHighligetd to be set to NO_ROW so rows can be unhighlighted
  546. mHighlighted = hitRow;
  547. }
  548. void GuiGameListMenuCtrl::onMouseUp(const GuiEvent &event)
  549. {
  550. S32 hitRow = getRow(event.mousePoint);
  551. if ((hitRow != NO_ROW) && isRowEnabled(hitRow) && (hitRow == getSelected()))
  552. {
  553. if (mRows[hitRow]->mMode == Row::Mode::Default)
  554. {
  555. activateRow();
  556. }
  557. else if (mRows[hitRow]->mMode == Row::Mode::OptionList)
  558. {
  559. S32 xPos = globalToLocalCoord(event.mousePoint).x;
  560. clickOption((Row*)mRows[getSelected()], xPos);
  561. }
  562. else if (mRows[hitRow]->mMode == Row::Mode::Slider)
  563. {
  564. S32 xPos = globalToLocalCoord(event.mousePoint).x;
  565. clickSlider((Row*)mRows[getSelected()], xPos);
  566. }
  567. else if (mRows[hitRow]->mMode == Row::Mode::Keybind)
  568. {
  569. S32 xPos = globalToLocalCoord(event.mousePoint).x;
  570. clickKeybind((Row*)mRows[getSelected()], xPos);
  571. }
  572. }
  573. }
  574. void GuiGameListMenuCtrl::activateRow()
  575. {
  576. S32 row = getSelected();
  577. if ((row != NO_ROW) && isRowEnabled(row) && (mRows[row]->mScriptCallback != NULL))
  578. {
  579. setThisControl();
  580. if (Con::isFunction(mRows[row]->mScriptCallback))
  581. {
  582. Con::executef(mRows[row]->mScriptCallback);
  583. }
  584. }
  585. }
  586. S32 GuiGameListMenuCtrl::getRow(Point2I globalPoint)
  587. {
  588. Point2I localPoint = globalToLocalCoord(globalPoint);
  589. GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
  590. F32 xScale = (float) getWidth() / profile->getRowWidth();
  591. S32 rowHeight = profile->getRowHeight();
  592. Point2I currentOffset(0, 0);
  593. Point2I hitAreaUpperLeft = profile->mHitAreaUpperLeft;
  594. hitAreaUpperLeft.x *= xScale;
  595. Point2I hitAreaLowerRight = profile->mHitAreaLowerRight;
  596. hitAreaLowerRight.x *= xScale;
  597. Point2I upperLeft, lowerRight;
  598. for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
  599. {
  600. if (row != mRows.begin())
  601. {
  602. // rows other than the first can have padding above them
  603. currentOffset.y += (*row)->mHeightPad;
  604. }
  605. upperLeft = currentOffset + hitAreaUpperLeft;
  606. lowerRight = currentOffset + hitAreaLowerRight;
  607. if ((upperLeft.x <= localPoint.x) && (localPoint.x < lowerRight.x) &&
  608. (upperLeft.y <= localPoint.y) && (localPoint.y < lowerRight.y))
  609. {
  610. return row - mRows.begin();
  611. }
  612. currentOffset.y += rowHeight;
  613. }
  614. return NO_ROW;
  615. }
  616. void GuiGameListMenuCtrl::setSelected(S32 index)
  617. {
  618. if (index == NO_ROW)
  619. {
  620. // deselection
  621. mSelected = NO_ROW;
  622. return;
  623. }
  624. if (! isValidRowIndex(index))
  625. {
  626. return;
  627. }
  628. if (! isRowEnabled(index))
  629. {
  630. // row is disabled, it can't be selected
  631. return;
  632. }
  633. mSelected = mClamp(index, 0, mRows.size() - 1);
  634. //If we're childed to a scroll container, make sure us changing rows has our new position visible
  635. GuiScrollCtrl* scroll = dynamic_cast<GuiScrollCtrl*>(getParent());
  636. if (scroll)
  637. {
  638. scroll->scrollRectVisible(getRowBounds(mSelected));
  639. }
  640. }
  641. bool GuiGameListMenuCtrl::isRowEnabled(S32 index) const
  642. {
  643. if (! isValidRowIndex(index))
  644. {
  645. return false;
  646. }
  647. return mRows[index]->mEnabled;
  648. }
  649. void GuiGameListMenuCtrl::setRowEnabled(S32 index, bool enabled)
  650. {
  651. if (! isValidRowIndex(index))
  652. {
  653. return;
  654. }
  655. mRows[index]->mEnabled = enabled;
  656. if (getSelected() == index)
  657. {
  658. selectFirstEnabledRow();
  659. }
  660. }
  661. bool GuiGameListMenuCtrl::isValidRowIndex(S32 index) const
  662. {
  663. return ((0 <= index) && (index < mRows.size()));
  664. }
  665. void GuiGameListMenuCtrl::selectFirstEnabledRow()
  666. {
  667. setSelected(NO_ROW);
  668. for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
  669. {
  670. if ((*row)->mEnabled)
  671. {
  672. setSelected(row - mRows.begin());
  673. return;
  674. }
  675. }
  676. }
  677. bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
  678. {
  679. if (mCallbackOnInputs)
  680. {
  681. char deviceStr[32];
  682. if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceStr))
  683. return false;
  684. String deviceString = deviceStr;
  685. if (event.action == SI_MAKE || event.action == SI_BREAK)
  686. {
  687. bool isModifier = false;
  688. bool state = event.action == SI_MAKE;
  689. switch (event.objInst)
  690. {
  691. case KEY_LCONTROL:
  692. case KEY_RCONTROL:
  693. case KEY_LALT:
  694. case KEY_RALT:
  695. case KEY_LSHIFT:
  696. case KEY_RSHIFT:
  697. case KEY_MAC_LOPT:
  698. case KEY_MAC_ROPT:
  699. isModifier = true;
  700. }
  701. if ((event.objType == SI_KEY) && isModifier)
  702. {
  703. char keyString[32];
  704. if (!ActionMap::getKeyString(event.objInst, keyString))
  705. return false;
  706. onInputEvent_callback(deviceString.c_str(), keyString, state);
  707. if (mConsumeKeyInputEvents)
  708. {
  709. if(deviceString.startsWith("keyboard"))
  710. return true;
  711. }
  712. }
  713. else
  714. {
  715. const char* actionString = ActionMap::buildActionString(&event);
  716. onInputEvent_callback(deviceString.c_str(), actionString, state);
  717. if (mConsumeKeyInputEvents)
  718. {
  719. if (deviceString.startsWith("keyboard") || deviceString.startsWith("gamepad"))
  720. return true;
  721. }
  722. }
  723. }
  724. else if (event.objType == SI_AXIS || event.objType == SI_INT || event.objType == SI_FLOAT)
  725. {
  726. F32 fValue = event.fValue;
  727. if (event.objType == SI_INT)
  728. fValue = (F32)event.iValue;
  729. if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceStr))
  730. return false;
  731. const char* actionString = ActionMap::buildActionString(&event);
  732. onAxisEvent_callback(deviceStr, actionString, fValue);
  733. }
  734. }
  735. return false;
  736. }
  737. bool GuiGameListMenuCtrl::onKeyDown(const GuiEvent &event)
  738. {
  739. switch (event.keyCode)
  740. {
  741. case KEY_UP:
  742. changeRow(-1);
  743. return true;
  744. case KEY_DOWN:
  745. changeRow(1);
  746. return true;
  747. case KEY_LEFT:
  748. changeOption(-1);
  749. return true;
  750. case KEY_RIGHT:
  751. changeOption(1);
  752. return true;
  753. case KEY_A:
  754. case KEY_RETURN:
  755. case KEY_NUMPADENTER:
  756. case KEY_SPACE:
  757. case XI_A:
  758. case XI_START:
  759. doScriptCommand(mCallbackOnA);
  760. return true;
  761. case KEY_B:
  762. case KEY_ESCAPE:
  763. case KEY_BACKSPACE:
  764. case KEY_DELETE:
  765. case XI_B:
  766. case XI_BACK:
  767. doScriptCommand(mCallbackOnB);
  768. return true;
  769. case KEY_X:
  770. case XI_X:
  771. doScriptCommand(mCallbackOnX);
  772. return true;
  773. case KEY_Y:
  774. case XI_Y:
  775. doScriptCommand(mCallbackOnY);
  776. return true;
  777. default:
  778. break;
  779. }
  780. return Parent::onKeyDown(event);
  781. }
  782. bool GuiGameListMenuCtrl::onGamepadAxisUp(const GuiEvent &event)
  783. {
  784. changeRow(-1);
  785. return true;
  786. }
  787. bool GuiGameListMenuCtrl::onGamepadAxisDown(const GuiEvent &event)
  788. {
  789. changeRow(1);
  790. return true;
  791. }
  792. bool GuiGameListMenuCtrl::onGamepadAxisLeft(const GuiEvent& event)
  793. {
  794. changeOption(-1);
  795. return true;
  796. }
  797. bool GuiGameListMenuCtrl::onGamepadAxisRight(const GuiEvent& event)
  798. {
  799. changeOption(1);
  800. return true;
  801. }
  802. void GuiGameListMenuCtrl::doScriptCommand(StringTableEntry command)
  803. {
  804. if (command && command[0])
  805. {
  806. setThisControl();
  807. Con::evaluate(command, false, __FILE__);
  808. }
  809. }
  810. void GuiGameListMenuCtrl::changeRow(S32 delta)
  811. {
  812. S32 oldRowIndex = getSelected();
  813. S32 newRowIndex = oldRowIndex;
  814. do
  815. {
  816. newRowIndex += delta;
  817. if (newRowIndex >= mRows.size())
  818. {
  819. newRowIndex = 0;
  820. }
  821. else if (newRowIndex < 0)
  822. {
  823. newRowIndex = mRows.size() - 1;
  824. }
  825. }
  826. while ((! mRows[newRowIndex]->mEnabled) && (newRowIndex != oldRowIndex));
  827. setSelected(newRowIndex);
  828. // do the callback
  829. onChange_callback();
  830. }
  831. void GuiGameListMenuCtrl::setThisControl()
  832. {
  833. smThisControl = this;
  834. }
  835. StringTableEntry GuiGameListMenuCtrl::getRowLabel(S32 rowIndex) const
  836. {
  837. if (! isValidRowIndex(rowIndex))
  838. {
  839. // not a valid row index, don't do anything
  840. return StringTable->EmptyString();
  841. }
  842. return mRows[rowIndex]->mLabel;
  843. }
  844. void GuiGameListMenuCtrl::setRowLabel(S32 rowIndex, const char * label)
  845. {
  846. if (! isValidRowIndex(rowIndex))
  847. {
  848. // not a valid row index, don't do anything
  849. return;
  850. }
  851. mRows[rowIndex]->mLabel = StringTable->insert(label, true);
  852. }
  853. void GuiGameListMenuCtrl::clearRows()
  854. {
  855. for (U32 i = 0; i < mRows.size(); i++)
  856. {
  857. if (mRows[i]->mBitmap != StringTable->EmptyString())
  858. mRows[i]->mBitmapTex = nullptr;
  859. }
  860. mRows.clear();
  861. setSelected(-1);
  862. setHeight(mMinExtent.y);
  863. }
  864. void GuiGameListMenuCtrl::refresh()
  865. {
  866. enforceConstraints();
  867. }
  868. RectI GuiGameListMenuCtrl::getRowBounds(S32 rowIndex)
  869. {
  870. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  871. F32 xScale = (float)getWidth() / profile->getRowWidth();
  872. S32 rowHeight = profile->getRowHeight();
  873. Point2I currentOffset = Point2I::Zero;
  874. Point2I extent = getExtent();
  875. Point2I rowExtent(extent.x, rowHeight);
  876. for (U32 i = 1; i <= rowIndex; i++)
  877. {
  878. //the top row can't pad, so we'll ignore it
  879. GuiGameListMenuCtrl::Row* row = mRows[i];
  880. // rows other than the first can have padding above them
  881. currentOffset.y += row->mHeightPad;
  882. currentOffset.y += rowHeight;
  883. }
  884. return RectI(currentOffset, rowExtent);
  885. }
  886. //-----------------------------------------------------------------------------
  887. // Console stuff (GuiGameListMenuCtrl)
  888. //-----------------------------------------------------------------------------
  889. StringTableEntry GuiGameListMenuCtrl::getCurrentOption(S32 rowIndex) const
  890. {
  891. if (isValidRowIndex(rowIndex))
  892. {
  893. Row* row = (Row*)mRows[rowIndex];
  894. if (row->mSelectedOption != NO_OPTION)
  895. {
  896. return row->mOptions[row->mSelectedOption];
  897. }
  898. }
  899. return StringTable->insert("", false);
  900. }
  901. bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
  902. {
  903. if (!isValidRowIndex(rowIndex))
  904. {
  905. return false;
  906. }
  907. Row* row = (Row*)mRows[rowIndex];
  908. for (Vector<StringTableEntry>::iterator anOption = row->mOptions.begin(); anOption < row->mOptions.end(); ++anOption)
  909. {
  910. if (String::compare(*anOption, theOption) == 0)
  911. {
  912. S32 newIndex = anOption - row->mOptions.begin();
  913. row->mSelectedOption = newIndex;
  914. return true;
  915. }
  916. }
  917. return false;
  918. }
  919. void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
  920. {
  921. static StringTableEntry DELIM = StringTable->insert("\t", true);
  922. if (!isValidRowIndex(rowIndex))
  923. {
  924. return;
  925. }
  926. Row* row = (Row*)mRows[rowIndex];
  927. S32 count = StringUnit::getUnitCount(optionsList, DELIM);
  928. row->mOptions.setSize(count);
  929. for (S32 i = 0; i < count; ++i)
  930. {
  931. const char* option = StringUnit::getUnit(optionsList, i, DELIM);
  932. row->mOptions[i] = StringTable->insert(option, true);
  933. }
  934. if (row->mSelectedOption >= row->mOptions.size())
  935. {
  936. row->mSelectedOption = row->mOptions.size() - 1;
  937. }
  938. }
  939. void GuiGameListMenuCtrl::clickOption(Row* row, S32 xPos)
  940. {
  941. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  942. if (!profile->hasArrows())
  943. {
  944. return;
  945. }
  946. F32 xScale = (float)getWidth() / profile->getRowWidth();
  947. S32 bitmapArrowWidth = mProfile->getBitmapArrayRect(Profile::TEX_FIRST_ARROW).extent.x;
  948. S32 leftArrowX1 = profile->mColumnSplit * xScale;
  949. S32 leftArrowX2 = leftArrowX1 + bitmapArrowWidth;
  950. S32 rightArrowX2 = (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale;
  951. S32 rightArrowX1 = rightArrowX2 - bitmapArrowWidth;
  952. if ((leftArrowX1 <= xPos) && (xPos <= leftArrowX2))
  953. {
  954. changeOption(row, -1);
  955. }
  956. else if ((rightArrowX1 <= xPos) && (xPos <= rightArrowX2))
  957. {
  958. changeOption(row, 1);
  959. }
  960. }
  961. void GuiGameListMenuCtrl::changeOption(S32 delta)
  962. {
  963. if (getSelected() != NO_ROW)
  964. {
  965. Row* row = (Row*)mRows[getSelected()];
  966. changeOption(row, delta);
  967. }
  968. }
  969. void GuiGameListMenuCtrl::changeOption(Row* row, S32 delta)
  970. {
  971. S32 optionCount = row->mOptions.size();
  972. S32 newSelection = row->mSelectedOption + delta;
  973. if (optionCount == 0)
  974. {
  975. newSelection = NO_OPTION;
  976. }
  977. else if (!row->mWrapOptions)
  978. {
  979. newSelection = mClamp(newSelection, 0, optionCount - 1);
  980. }
  981. else if (newSelection < 0)
  982. {
  983. newSelection = optionCount - 1;
  984. }
  985. else if (newSelection >= optionCount)
  986. {
  987. newSelection = 0;
  988. }
  989. row->mSelectedOption = newSelection;
  990. if (row->mMode == GuiGameListMenuCtrl::Row::Slider)
  991. {
  992. row->mValue += row->mStepSize * delta;
  993. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  994. if (row->mValue < row->mRange.x)
  995. row->mValue = row->mRange.x;
  996. if (row->mValue > row->mRange.y)
  997. row->mValue = row->mRange.y;
  998. }
  999. static StringTableEntry LEFT = StringTable->insert("LEFT", true);
  1000. static StringTableEntry RIGHT = StringTable->insert("RIGHT", true);
  1001. if (row->mScriptCallback != NULL && (row->mSelectedOption != NO_OPTION && row->mMode != GuiGameListMenuCtrl::Row::Slider))
  1002. {
  1003. setThisControl();
  1004. StringTableEntry direction = NULL;
  1005. if (delta < 0)
  1006. {
  1007. direction = LEFT;
  1008. }
  1009. else if (delta > 0)
  1010. {
  1011. direction = RIGHT;
  1012. }
  1013. if ((direction != NULL) && (Con::isFunction(row->mScriptCallback)))
  1014. {
  1015. Con::executef(row->mScriptCallback, direction);
  1016. }
  1017. }
  1018. }
  1019. IMPLEMENT_CONOBJECT(GuiGameListMenuCtrl);
  1020. void GuiGameListMenuCtrl::clickSlider(Row* row, S32 xPos)
  1021. {
  1022. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  1023. if (!profile->hasArrows())
  1024. {
  1025. return;
  1026. }
  1027. F32 xScale = (float)getWidth() / profile->getRowWidth();
  1028. S32 bitmapArrowWidth = mProfile->getBitmapArrayRect(Profile::TEX_FIRST_ARROW).extent.x;
  1029. S32 leftArrowX1 = profile->mColumnSplit * xScale;
  1030. S32 leftArrowX2 = leftArrowX1 + bitmapArrowWidth;
  1031. S32 rightArrowX2 = (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale;
  1032. S32 rightArrowX1 = rightArrowX2 - bitmapArrowWidth;
  1033. if ((leftArrowX1 <= xPos) && (xPos <= leftArrowX2))
  1034. {
  1035. row->mValue -= row->mStepSize;
  1036. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  1037. if (row->mValue < row->mRange.x)
  1038. row->mValue = row->mRange.x;
  1039. }
  1040. else if ((rightArrowX1 <= xPos) && (xPos <= rightArrowX2))
  1041. {
  1042. //F32 snap = row->mValue % row->mStepSize;
  1043. //row->mValue.y -= snap;
  1044. row->mValue += row->mStepSize;
  1045. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  1046. if (row->mValue > row->mRange.y)
  1047. row->mValue = row->mRange.y;
  1048. }
  1049. else
  1050. {
  1051. //see if we clicked on the sliderbar itself
  1052. S32 barStart = leftArrowX2;
  1053. S32 barEnd = rightArrowX1;
  1054. if (xPos >= barStart && xPos <= barEnd)
  1055. {
  1056. //find the position
  1057. F32 newValue = (((xPos - barStart) * (row->mRange.y - row->mRange.x)) / (barEnd - barStart)) + row->mRange.x;
  1058. newValue = mRound(newValue / row->mStepSize) * row->mStepSize;
  1059. row->mValue = newValue;
  1060. }
  1061. }
  1062. }
  1063. void GuiGameListMenuCtrl::clickKeybind(Row* row, S32 xPos)
  1064. {
  1065. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  1066. F32 xScale = (float)getWidth() / profile->getRowWidth();
  1067. S32 columnSplit = profile->mColumnSplit * xScale;
  1068. S32 rowHeight = profile->getRowHeight();
  1069. S32 optionWidth = xScale - columnSplit;
  1070. GFXDrawUtil* drawer = GFX->getDrawUtil();
  1071. //drawer->drawBitmap(row->mBitmap, )
  1072. Point2I button;
  1073. button.x = columnSplit + (columnSplit / 2)/* + (optionWidth / 2)*/;
  1074. button.y = rowHeight / 4;
  1075. Point2I buttonSize;
  1076. buttonSize.x = rowHeight / 2;
  1077. buttonSize.y = rowHeight / 2;
  1078. GFXTextureObject* texture = row->mBitmapTex;
  1079. RectI rect(button, buttonSize);
  1080. if (rect.pointInRect(Point2I(xPos, rowHeight / 2)))
  1081. {
  1082. if (row->mScriptCallback != StringTable->EmptyString())
  1083. {
  1084. S32 rowId = getSelected();
  1085. Con::executef(row->mScriptCallback, rowId);
  1086. }
  1087. }
  1088. }
  1089. F32 GuiGameListMenuCtrl::getValue(S32 rowIndex)
  1090. {
  1091. if (!isValidRowIndex(rowIndex))
  1092. {
  1093. return 0;
  1094. }
  1095. Row* row = (Row*)mRows[rowIndex];
  1096. return row->mValue;
  1097. }
  1098. void GuiGameListMenuCtrl::setValue(S32 rowIndex, F32 value)
  1099. {
  1100. if (!isValidRowIndex(rowIndex))
  1101. {
  1102. return;
  1103. }
  1104. Row* row = (Row*)mRows[rowIndex];
  1105. row->mValue = value;
  1106. }
  1107. const char* GuiGameListMenuCtrl::getTooltip(S32 rowIndex)
  1108. {
  1109. if (!isValidRowIndex(rowIndex))
  1110. {
  1111. return "";
  1112. }
  1113. Row* row = (Row*)mRows[rowIndex];
  1114. return row->mTooltip;
  1115. }
  1116. ConsoleDocClass( GuiGameListMenuCtrl,
  1117. "@brief A base class for cross platform menu controls that are gamepad friendly.\n\n"
  1118. "This class is used to build row-based menu GUIs that can be easily navigated "
  1119. "using the keyboard, mouse or gamepad. The desired row can be selected using "
  1120. "the mouse, or by navigating using the Up and Down buttons.\n\n"
  1121. "@tsexample\n\n"
  1122. "new GuiGameListMenuCtrl()\n"
  1123. "{\n"
  1124. " debugRender = \"0\";\n"
  1125. " callbackOnA = \"applyOptions();\";\n"
  1126. " callbackOnB = \"Canvas.setContent(MainMenuGui);\";\n"
  1127. " callbackOnX = \"\";\n"
  1128. " callbackOnY = \"revertOptions();\";\n"
  1129. " //Properties not specific to this control have been omitted from this example.\n"
  1130. "};\n"
  1131. "@endtsexample\n\n"
  1132. "@see GuiGameListMenuProfile\n\n"
  1133. "@ingroup GuiGame"
  1134. );
  1135. IMPLEMENT_CALLBACK( GuiGameListMenuCtrl, onChange, void, (), (),
  1136. "Called when the selected row changes." );
  1137. IMPLEMENT_CALLBACK(GuiGameListMenuCtrl, onInputEvent, void, (const char* device, const char* action, bool state),
  1138. (device, action, state),
  1139. "@brief Callback that occurs when an input is triggered on this control\n\n"
  1140. "@param device The device type triggering the input, such as keyboard, mouse, etc\n"
  1141. "@param action The actual event occuring, such as a key or button\n"
  1142. "@param state True if the action is being pressed, false if it is being release\n\n");
  1143. IMPLEMENT_CALLBACK(GuiGameListMenuCtrl, onAxisEvent, void, (const char* device, const char* action, F32 axisValue),
  1144. (device, action, axisValue),
  1145. "@brief Callback that occurs when an axis event is triggered on this control\n\n"
  1146. "@param device The device type triggering the input, such as mouse, joystick, gamepad, etc\n"
  1147. "@param action The ActionMap code for the axis\n"
  1148. "@param axisValue The current value of the axis\n\n");
  1149. void GuiGameListMenuCtrl::initPersistFields()
  1150. {
  1151. addField("debugRender", TypeBool, Offset(mDebugRender, GuiGameListMenuCtrl),
  1152. "Enable debug rendering" );
  1153. addField("callbackOnA", TypeString, Offset(mCallbackOnA, GuiGameListMenuCtrl),
  1154. "Script callback when the 'A' button is pressed. 'A' inputs are Keyboard: A, Return, Space; Gamepad: A, Start" );
  1155. addField("callbackOnB", TypeString, Offset(mCallbackOnB, GuiGameListMenuCtrl),
  1156. "Script callback when the 'B' button is pressed. 'B' inputs are Keyboard: B, Esc, Backspace, Delete; Gamepad: B, Back" );
  1157. addField("callbackOnX", TypeString, Offset(mCallbackOnX, GuiGameListMenuCtrl),
  1158. "Script callback when the 'X' button is pressed. 'X' inputs are Keyboard: X; Gamepad: X" );
  1159. addField("callbackOnY", TypeString, Offset(mCallbackOnY, GuiGameListMenuCtrl),
  1160. "Script callback when the 'Y' button is pressed. 'Y' inputs are Keyboard: Y; Gamepad: Y" );
  1161. addField("callbackOnInputs", TypeBool, Offset(mCallbackOnInputs, GuiGameListMenuCtrl),
  1162. "Script callback when any inputs are detected, even if they aren't the regular 4 face buttons. Useful for secondary/speciality handling of menu navigation.");
  1163. addField("consumeKeyInputEvents", TypeBool, Offset(mConsumeKeyInputEvents, GuiGameListMenuCtrl),
  1164. "When callbackOnInputs is active, this indicates if the input event should be consumed, or allowed 'through' to let other things respond to the event as well.");
  1165. Parent::initPersistFields();
  1166. }
  1167. DefineEngineMethod( GuiGameListMenuCtrl, addRow, void,
  1168. ( const char* label, const char* callback, S32 icon, S32 yPad, bool useHighlightIcon, bool enabled, int mode ),
  1169. ( -1, 0, true, true, 0 ),
  1170. "Add a row to the list control.\n\n"
  1171. "@param label The text to display on the row as a label.\n"
  1172. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1173. "@param icon [optional] Index of the icon to use as a marker.\n"
  1174. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1175. "@param useHighlightIcon [optional] Does this row use the highlight icon?.\n"
  1176. "@param enabled [optional] If this row is initially enabled.\n"
  1177. "@param mode [optional] What option mode the row is in. 0 = Default, 1 = OptionList, 2 == Keybind")
  1178. {
  1179. object->addRow( label, callback, icon, yPad, useHighlightIcon, enabled, mode);
  1180. }
  1181. DefineEngineMethod( GuiGameListMenuCtrl, isRowEnabled, bool, ( S32 row ),,
  1182. "Determines if the specified row is enabled or disabled.\n\n"
  1183. "@param row The row to set the enabled status of.\n"
  1184. "@return True if the specified row is enabled. False if the row is not enabled or the given index was not valid." )
  1185. {
  1186. return object->isRowEnabled( row );
  1187. }
  1188. DefineEngineMethod( GuiGameListMenuCtrl, setRowEnabled, void, ( S32 row, bool enabled ),,
  1189. "Sets a row's enabled status according to the given parameters.\n\n"
  1190. "@param row The index to check for validity.\n"
  1191. "@param enabled Indicate true to enable the row or false to disable it." )
  1192. {
  1193. object->setRowEnabled( row, enabled );
  1194. }
  1195. DefineEngineMethod( GuiGameListMenuCtrl, activateRow, void, (),,
  1196. "Activates the current row. The script callback of the current row will be called (if it has one)." )
  1197. {
  1198. object->activateRow();
  1199. }
  1200. DefineEngineMethod( GuiGameListMenuCtrl, getRowCount, S32, (),,
  1201. "Gets the number of rows on the control.\n\n"
  1202. "@return (int) The number of rows on the control." )
  1203. {
  1204. return object->getRowCount();
  1205. }
  1206. DefineEngineMethod( GuiGameListMenuCtrl, getRowLabel, const char *, ( S32 row ),,
  1207. "Gets the label displayed on the specified row.\n\n"
  1208. "@param row Index of the row to get the label of.\n"
  1209. "@return The label for the row." )
  1210. {
  1211. return object->getRowLabel( row );
  1212. }
  1213. DefineEngineMethod( GuiGameListMenuCtrl, setRowLabel, void, ( S32 row, const char* label ),,
  1214. "Sets the label on the given row.\n\n"
  1215. "@param row Index of the row to set the label on.\n"
  1216. "@param label Text to set as the label of the row.\n" )
  1217. {
  1218. object->setRowLabel( row, label );
  1219. }
  1220. DefineEngineMethod( GuiGameListMenuCtrl, setSelected, void, ( S32 row ),,
  1221. "Sets the selected row. Only rows that are enabled can be selected.\n\n"
  1222. "@param row Index of the row to set as selected." )
  1223. {
  1224. object->setSelected( row );
  1225. }
  1226. DefineEngineMethod( GuiGameListMenuCtrl, getSelectedRow, S32, (),,
  1227. "Gets the index of the currently selected row.\n\n"
  1228. "@return Index of the selected row." )
  1229. {
  1230. return object->getSelected();
  1231. }
  1232. DefineEngineMethod(GuiGameListMenuCtrl, clearRows, void, (), ,
  1233. "Gets the index of the currently selected row.\n\n"
  1234. "@return Index of the selected row.")
  1235. {
  1236. return object->clearRows();
  1237. }
  1238. DefineEngineMethod(GuiGameListMenuCtrl, refresh, void, (), ,
  1239. "Gets the index of the currently selected row.\n\n"
  1240. "@return Index of the selected row.")
  1241. {
  1242. return object->refresh();
  1243. }
  1244. DefineEngineMethod(GuiGameListMenuCtrl, addOptionRow, void,
  1245. (const char* label, const char* options, bool wrapOptions, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip, const char* defaultValue),
  1246. (-1, 0, true, "", ""),
  1247. "Add a row to the list control.\n\n"
  1248. "@param label The text to display on the row as a label.\n"
  1249. "@param options A tab separated list of options.\n"
  1250. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1251. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1252. "@param icon [optional] Index of the icon to use as a marker.\n"
  1253. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1254. "@param enabled [optional] If this row is initially enabled.")
  1255. {
  1256. object->addRow(label, options, wrapOptions, callback, icon, yPad, enabled, tooltip, defaultValue);
  1257. }
  1258. DefineEngineMethod(GuiGameListMenuCtrl, addSliderRow, void,
  1259. (const char* label, F32 defaultValue, F32 increment, Point2F range, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip),
  1260. (-1, 0, true, ""),
  1261. "Add a row to the list control.\n\n"
  1262. "@param label The text to display on the row as a label.\n"
  1263. "@param options A tab separated list of options.\n"
  1264. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1265. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1266. "@param icon [optional] Index of the icon to use as a marker.\n"
  1267. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1268. "@param enabled [optional] If this row is initially enabled.")
  1269. {
  1270. object->addRow(label, defaultValue, increment, range, callback, icon, yPad, enabled, tooltip);
  1271. }
  1272. DefineEngineMethod(GuiGameListMenuCtrl, addKeybindRow, void,
  1273. (const char* label, const char* bitmapName, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip),
  1274. (-1, 0, true, ""),
  1275. "Add a row to the list control.\n\n"
  1276. "@param label The text to display on the row as a label.\n"
  1277. "@param options A tab separated list of options.\n"
  1278. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1279. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1280. "@param icon [optional] Index of the icon to use as a marker.\n"
  1281. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1282. "@param enabled [optional] If this row is initially enabled.")
  1283. {
  1284. object->addRow(label, bitmapName, callback, icon, yPad, enabled, tooltip);
  1285. }
  1286. DefineEngineMethod(GuiGameListMenuCtrl, removeRow, void, (S32 row),,
  1287. "Removes the row at the provided index")
  1288. {
  1289. object->removeRow(row);
  1290. }
  1291. DefineEngineMethod(GuiGameListMenuCtrl, getCurrentOption, const char*, (S32 row), ,
  1292. "Gets the text for the currently selected option of the given row.\n\n"
  1293. "@param row Index of the row to get the option from.\n"
  1294. "@return A string representing the text currently displayed as the selected option on the given row. If there is no such displayed text then the empty string is returned.")
  1295. {
  1296. return object->getCurrentOption(row);
  1297. }
  1298. DefineEngineMethod(GuiGameListMenuCtrl, selectOption, bool, (S32 row, const char* option), ,
  1299. "Set the row's current option to the one specified\n\n"
  1300. "@param row Index of the row to set an option on.\n"
  1301. "@param option The option to be made active.\n"
  1302. "@return True if the row contained the option and was set, false otherwise.")
  1303. {
  1304. return object->selectOption(row, option);
  1305. }
  1306. DefineEngineMethod(GuiGameListMenuCtrl, setOptions, void, (S32 row, const char* optionsList), ,
  1307. "Sets the list of options on the given row.\n\n"
  1308. "@param row Index of the row to set options on."
  1309. "@param optionsList A tab separated list of options for the control.")
  1310. {
  1311. object->setOptions(row, optionsList);
  1312. }
  1313. DefineEngineMethod(GuiGameListMenuCtrl, getValue, F32, (S32 row), ,
  1314. "Sets the list of options on the given row.\n\n"
  1315. "@param row Index of the row to set options on."
  1316. "@param optionsList A tab separated list of options for the control.")
  1317. {
  1318. return object->getValue(row);
  1319. }
  1320. DefineEngineMethod(GuiGameListMenuCtrl, setValue, void, (S32 row, F32 value), ,
  1321. "Sets the list of options on the given row.\n\n"
  1322. "@param row Index of the row to set options on."
  1323. "@param optionsList A tab separated list of options for the control.")
  1324. {
  1325. object->setValue(row, value);
  1326. }
  1327. DefineEngineMethod(GuiGameListMenuCtrl, getTooltip, const char*, (S32 row), ,
  1328. "Sets the list of options on the given row.\n\n"
  1329. "@param row Index of the row to set options on."
  1330. "@param optionsList A tab separated list of options for the control.")
  1331. {
  1332. return object->getTooltip(row);
  1333. }
  1334. //-----------------------------------------------------------------------------
  1335. // GuiGameListMenuProfile
  1336. //-----------------------------------------------------------------------------
  1337. GuiGameListMenuProfile::GuiGameListMenuProfile()
  1338. : mHitAreaUpperLeft(0, 0),
  1339. mHitAreaLowerRight(0, 0),
  1340. mIconOffset(0, 0),
  1341. mRowSize(0, 0),
  1342. mRowScale(1.0f, 1.0f),
  1343. mColumnSplit(0),
  1344. mRightPad(0)
  1345. {
  1346. }
  1347. bool GuiGameListMenuProfile::onAdd()
  1348. {
  1349. if (! Parent::onAdd())
  1350. {
  1351. return false;
  1352. }
  1353. // We can't call enforceConstraints() here because incRefCount initializes
  1354. // some of the things to enforce. Do a basic sanity check here instead.
  1355. if( !mBitmapName || !dStrlen(mBitmapName) )
  1356. {
  1357. Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
  1358. return false;
  1359. }
  1360. if( mRowSize.x < 0 )
  1361. {
  1362. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row width. Please change the row width to be non-negative.", getName() );
  1363. return false;
  1364. }
  1365. if( mRowSize.y < 0 )
  1366. {
  1367. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row height. Please change the row height to be non-negative.", getName() );
  1368. return false;
  1369. }
  1370. return true;
  1371. }
  1372. void GuiGameListMenuProfile::enforceConstraints()
  1373. {
  1374. if( getBitmapArrayRect(0).extent.isZero() )
  1375. Con::errorf( "GuiGameListMenuCtrl: %s can't be created without a bitmap. Please add a bitmap to the profile's definition.", getName() );
  1376. if( mRowSize.x < 0 )
  1377. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row width. Please change the row width to be non-negative.", getName() );
  1378. mRowSize.x = getMax(mRowSize.x, 0);
  1379. if( mRowSize.y < 0 )
  1380. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row height. Please change the row height to be non-negative.", getName() );
  1381. mRowSize.y = getMax(mRowSize.y, 0);
  1382. Point2I rowTexExtent = getBitmapArrayRect(TEX_NORMAL).extent;
  1383. mRowScale.x = (float) getRowWidth() / rowTexExtent.x;
  1384. mRowScale.y = (float) getRowHeight() / rowTexExtent.y;
  1385. if (mHitAreaUpperLeft.x > mColumnSplit || mColumnSplit > mHitAreaLowerRight.x)
  1386. Con::errorf("GuiGameListOptionsProfile: You can't create %s with a ColumnSplit outside the hit area. You set the split to %d. Please change the ColumnSplit to be in the range [%d, %d].",
  1387. getName(), mColumnSplit, mHitAreaUpperLeft.x, mHitAreaLowerRight.x);
  1388. mColumnSplit = mClamp(mColumnSplit, mHitAreaUpperLeft.x, mHitAreaLowerRight.x);
  1389. }
  1390. Point2I GuiGameListMenuProfile::getIconExtent()
  1391. {
  1392. Point2I iconExtent = getBitmapArrayRect(TEX_FIRST_ICON).extent;
  1393. // scale both by y to keep the aspect ratio
  1394. iconExtent.x *= mRowScale.y;
  1395. iconExtent.y *= mRowScale.y;
  1396. return iconExtent;
  1397. }
  1398. Point2I GuiGameListMenuProfile::getArrowExtent()
  1399. {
  1400. Point2I arrowExtent = getBitmapArrayRect(TEX_FIRST_ARROW).extent;
  1401. // scale both by y to keep the aspect ratio
  1402. arrowExtent.x *= mRowScale.y;
  1403. arrowExtent.y *= mRowScale.y;
  1404. return arrowExtent;
  1405. }
  1406. Point2I GuiGameListMenuProfile::getHitAreaExtent()
  1407. {
  1408. if (mHitAreaLowerRight == mHitAreaUpperLeft)
  1409. {
  1410. return mRowSize;
  1411. }
  1412. else
  1413. {
  1414. return mHitAreaLowerRight - mHitAreaUpperLeft;
  1415. }
  1416. }
  1417. //-----------------------------------------------------------------------------
  1418. // Console stuff (GuiGameListMenuProfile)
  1419. //-----------------------------------------------------------------------------
  1420. IMPLEMENT_CONOBJECT(GuiGameListMenuProfile);
  1421. ConsoleDocClass( GuiGameListMenuProfile,
  1422. "@brief A GuiControlProfile with additional fields specific to GuiGameListMenuCtrl.\n\n"
  1423. "@tsexample\n"
  1424. "new GuiGameListMenuProfile()\n"
  1425. "{\n"
  1426. " hitAreaUpperLeft = \"10 2\";\n"
  1427. " hitAreaLowerRight = \"190 18\";\n"
  1428. " iconOffset = \"10 2\";\n"
  1429. " rowSize = \"200 20\";\n"
  1430. " columnSplit = \"100\";\n"
  1431. " rightPad = \"4\";\n"
  1432. " //Properties not specific to this control have been omitted from this example.\n"
  1433. "};\n"
  1434. "@endtsexample\n\n"
  1435. "@ingroup GuiGame"
  1436. );
  1437. void GuiGameListMenuProfile::initPersistFields()
  1438. {
  1439. addField( "hitAreaUpperLeft", TypePoint2I, Offset(mHitAreaUpperLeft, GuiGameListMenuProfile),
  1440. "Position of the upper left corner of the row hit area (relative to row's top left corner)" );
  1441. addField( "hitAreaLowerRight", TypePoint2I, Offset(mHitAreaLowerRight, GuiGameListMenuProfile),
  1442. "Position of the lower right corner of the row hit area (relative to row's top left corner)" );
  1443. addField( "iconOffset", TypePoint2I, Offset(mIconOffset, GuiGameListMenuProfile),
  1444. "Offset from the row's top left corner at which to render the row icon" );
  1445. addField( "rowSize", TypePoint2I, Offset(mRowSize, GuiGameListMenuProfile),
  1446. "The base size (\"width height\") of a row" );
  1447. addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListMenuProfile),
  1448. "Padding between the leftmost edge of the control, and the row's left arrow.");
  1449. addField("rightPad", TypeS32, Offset(mRightPad, GuiGameListMenuProfile),
  1450. "Padding between the rightmost edge of the control and the row's right arrow.");
  1451. Parent::initPersistFields();
  1452. removeField("tab");
  1453. removeField("mouseOverSelected");
  1454. removeField("modal");
  1455. removeField("opaque");
  1456. removeField("border");
  1457. removeField("borderThickness");
  1458. removeField("borderColor");
  1459. removeField("borderColorHL");
  1460. removeField("borderColorNA");
  1461. removeField("bevelColorHL");
  1462. removeField("bevelColorLL");
  1463. removeField("fontColorLink");
  1464. removeField("fontColorLinkHL");
  1465. removeField("justify");
  1466. removeField("returnTab");
  1467. removeField("numbersOnly");
  1468. removeField("cursorColor");
  1469. removeField("profileForChildren");
  1470. }