guiGameListMenuCtrl.cpp 55 KB

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