guiGameListMenuCtrl.cpp 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761
  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)/* + (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_A:
  736. case KEY_RETURN:
  737. case KEY_NUMPADENTER:
  738. case KEY_SPACE:
  739. case XI_A:
  740. case XI_START:
  741. doScriptCommand(mCallbackOnA);
  742. return true;
  743. case KEY_B:
  744. case KEY_ESCAPE:
  745. case KEY_BACKSPACE:
  746. case KEY_DELETE:
  747. case XI_B:
  748. case XI_BACK:
  749. doScriptCommand(mCallbackOnB);
  750. return true;
  751. case KEY_X:
  752. case XI_X:
  753. doScriptCommand(mCallbackOnX);
  754. return true;
  755. case KEY_Y:
  756. case XI_Y:
  757. doScriptCommand(mCallbackOnY);
  758. return true;
  759. default:
  760. break;
  761. }
  762. return Parent::onKeyDown(event);
  763. }
  764. bool GuiGameListMenuCtrl::onGamepadAxisUp(const GuiEvent &event)
  765. {
  766. changeRow(-1);
  767. return true;
  768. }
  769. bool GuiGameListMenuCtrl::onGamepadAxisDown(const GuiEvent &event)
  770. {
  771. changeRow(1);
  772. return true;
  773. }
  774. bool GuiGameListMenuCtrl::onGamepadAxisLeft(const GuiEvent& event)
  775. {
  776. changeOption(-1);
  777. return true;
  778. }
  779. bool GuiGameListMenuCtrl::onGamepadAxisRight(const GuiEvent& event)
  780. {
  781. changeOption(1);
  782. return true;
  783. }
  784. void GuiGameListMenuCtrl::doScriptCommand(StringTableEntry command)
  785. {
  786. if (command && command[0])
  787. {
  788. setThisControl();
  789. Con::evaluate(command, false, __FILE__);
  790. }
  791. }
  792. void GuiGameListMenuCtrl::changeRow(S32 delta)
  793. {
  794. S32 oldRowIndex = getSelected();
  795. S32 newRowIndex = oldRowIndex;
  796. do
  797. {
  798. newRowIndex += delta;
  799. if (newRowIndex >= mRows.size())
  800. {
  801. newRowIndex = 0;
  802. }
  803. else if (newRowIndex < 0)
  804. {
  805. newRowIndex = mRows.size() - 1;
  806. }
  807. }
  808. while ((! mRows[newRowIndex]->mEnabled) && (newRowIndex != oldRowIndex));
  809. setSelected(newRowIndex);
  810. // do the callback
  811. onChange_callback();
  812. }
  813. void GuiGameListMenuCtrl::setThisControl()
  814. {
  815. smThisControl = this;
  816. }
  817. StringTableEntry GuiGameListMenuCtrl::getRowLabel(S32 rowIndex) const
  818. {
  819. 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()));
  820. if (! isValidRowIndex(rowIndex))
  821. {
  822. // not a valid row index, don't do anything
  823. return StringTable->EmptyString();
  824. }
  825. return mRows[rowIndex]->mLabel;
  826. }
  827. void GuiGameListMenuCtrl::setRowLabel(S32 rowIndex, const char * label)
  828. {
  829. 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()));
  830. if (! isValidRowIndex(rowIndex))
  831. {
  832. // not a valid row index, don't do anything
  833. return;
  834. }
  835. mRows[rowIndex]->mLabel = StringTable->insert(label, true);
  836. }
  837. void GuiGameListMenuCtrl::clearRows()
  838. {
  839. for (U32 i = 0; i < mRows.size(); i++)
  840. {
  841. if (mRows[i]->mBitmap != StringTable->EmptyString())
  842. mRows[i]->mBitmapTex = nullptr;
  843. }
  844. mRows.clear();
  845. setSelected(-1);
  846. setHeight(mMinExtent.y);
  847. }
  848. void GuiGameListMenuCtrl::refresh()
  849. {
  850. enforceConstraints();
  851. }
  852. RectI GuiGameListMenuCtrl::getRowBounds(S32 rowIndex)
  853. {
  854. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  855. F32 xScale = (float)getWidth() / profile->getRowWidth();
  856. S32 rowHeight = profile->getRowHeight();
  857. Point2I currentOffset = Point2I::Zero;
  858. Point2I extent = getExtent();
  859. Point2I rowExtent(extent.x, rowHeight);
  860. for (U32 i = 1; i <= rowIndex; i++)
  861. {
  862. //the top row can't pad, so we'll ignore it
  863. GuiGameListMenuCtrl::Row* row = mRows[i];
  864. // rows other than the first can have padding above them
  865. currentOffset.y += row->mHeightPad;
  866. currentOffset.y += rowHeight;
  867. }
  868. return RectI(currentOffset, rowExtent);
  869. }
  870. //-----------------------------------------------------------------------------
  871. // Console stuff (GuiGameListMenuCtrl)
  872. //-----------------------------------------------------------------------------
  873. StringTableEntry GuiGameListMenuCtrl::getCurrentOption(S32 rowIndex) const
  874. {
  875. if (isValidRowIndex(rowIndex))
  876. {
  877. Row* row = (Row*)mRows[rowIndex];
  878. if (row->mSelectedOption != NO_OPTION)
  879. {
  880. return row->mOptions[row->mSelectedOption];
  881. }
  882. }
  883. return StringTable->insert("", false);
  884. }
  885. bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
  886. {
  887. if (!isValidRowIndex(rowIndex))
  888. {
  889. return false;
  890. }
  891. Row* row = (Row*)mRows[rowIndex];
  892. for (Vector<StringTableEntry>::iterator anOption = row->mOptions.begin(); anOption < row->mOptions.end(); ++anOption)
  893. {
  894. if (String::compare(*anOption, theOption) == 0)
  895. {
  896. S32 newIndex = anOption - row->mOptions.begin();
  897. row->mSelectedOption = newIndex;
  898. return true;
  899. }
  900. }
  901. return false;
  902. }
  903. void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
  904. {
  905. static StringTableEntry DELIM = StringTable->insert("\t", true);
  906. if (!isValidRowIndex(rowIndex))
  907. {
  908. return;
  909. }
  910. Row* row = (Row*)mRows[rowIndex];
  911. S32 count = StringUnit::getUnitCount(optionsList, DELIM);
  912. row->mOptions.setSize(count);
  913. for (S32 i = 0; i < count; ++i)
  914. {
  915. const char* option = StringUnit::getUnit(optionsList, i, DELIM);
  916. row->mOptions[i] = StringTable->insert(option, true);
  917. }
  918. if (row->mSelectedOption >= row->mOptions.size())
  919. {
  920. row->mSelectedOption = row->mOptions.size() - 1;
  921. }
  922. }
  923. void GuiGameListMenuCtrl::clickOption(Row* row, S32 xPos)
  924. {
  925. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  926. if (!profile->hasArrows())
  927. {
  928. return;
  929. }
  930. F32 xScale = (float)getWidth() / profile->getRowWidth();
  931. S32 bitmapArrowWidth = mProfile->getBitmapArrayRect(Profile::TEX_FIRST_ARROW).extent.x;
  932. S32 leftArrowX1 = profile->mColumnSplit * xScale;
  933. S32 leftArrowX2 = leftArrowX1 + bitmapArrowWidth;
  934. S32 rightArrowX2 = (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale;
  935. S32 rightArrowX1 = rightArrowX2 - bitmapArrowWidth;
  936. if ((leftArrowX1 <= xPos) && (xPos <= leftArrowX2))
  937. {
  938. changeOption(row, -1);
  939. }
  940. else if ((rightArrowX1 <= xPos) && (xPos <= rightArrowX2))
  941. {
  942. changeOption(row, 1);
  943. }
  944. }
  945. void GuiGameListMenuCtrl::changeOption(S32 delta)
  946. {
  947. if (getSelected() != NO_ROW)
  948. {
  949. Row* row = (Row*)mRows[getSelected()];
  950. changeOption(row, delta);
  951. }
  952. }
  953. void GuiGameListMenuCtrl::changeOption(Row* row, S32 delta)
  954. {
  955. S32 optionCount = row->mOptions.size();
  956. S32 newSelection = row->mSelectedOption + delta;
  957. if (optionCount == 0)
  958. {
  959. newSelection = NO_OPTION;
  960. }
  961. else if (!row->mWrapOptions)
  962. {
  963. newSelection = mClamp(newSelection, 0, optionCount - 1);
  964. }
  965. else if (newSelection < 0)
  966. {
  967. newSelection = optionCount - 1;
  968. }
  969. else if (newSelection >= optionCount)
  970. {
  971. newSelection = 0;
  972. }
  973. row->mSelectedOption = newSelection;
  974. if (row->mMode == GuiGameListMenuCtrl::Row::Slider)
  975. {
  976. row->mValue += row->mStepSize * delta;
  977. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  978. if (row->mValue < row->mRange.x)
  979. row->mValue = row->mRange.x;
  980. if (row->mValue > row->mRange.y)
  981. row->mValue = row->mRange.y;
  982. }
  983. static StringTableEntry LEFT = StringTable->insert("LEFT", true);
  984. static StringTableEntry RIGHT = StringTable->insert("RIGHT", true);
  985. if (row->mScriptCallback != NULL && (row->mSelectedOption != NO_OPTION && row->mMode != GuiGameListMenuCtrl::Row::Slider))
  986. {
  987. setThisControl();
  988. StringTableEntry direction = NULL;
  989. if (delta < 0)
  990. {
  991. direction = LEFT;
  992. }
  993. else if (delta > 0)
  994. {
  995. direction = RIGHT;
  996. }
  997. if ((direction != NULL) && (Con::isFunction(row->mScriptCallback)))
  998. {
  999. Con::executef(row->mScriptCallback, direction);
  1000. }
  1001. }
  1002. }
  1003. IMPLEMENT_CONOBJECT(GuiGameListMenuCtrl);
  1004. void GuiGameListMenuCtrl::clickSlider(Row* row, S32 xPos)
  1005. {
  1006. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  1007. if (!profile->hasArrows())
  1008. {
  1009. return;
  1010. }
  1011. F32 xScale = (float)getWidth() / profile->getRowWidth();
  1012. S32 bitmapArrowWidth = mProfile->getBitmapArrayRect(Profile::TEX_FIRST_ARROW).extent.x;
  1013. S32 leftArrowX1 = profile->mColumnSplit * xScale;
  1014. S32 leftArrowX2 = leftArrowX1 + bitmapArrowWidth;
  1015. S32 rightArrowX2 = (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale;
  1016. S32 rightArrowX1 = rightArrowX2 - bitmapArrowWidth;
  1017. if ((leftArrowX1 <= xPos) && (xPos <= leftArrowX2))
  1018. {
  1019. row->mValue -= row->mStepSize;
  1020. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  1021. if (row->mValue < row->mRange.x)
  1022. row->mValue = row->mRange.x;
  1023. }
  1024. else if ((rightArrowX1 <= xPos) && (xPos <= rightArrowX2))
  1025. {
  1026. //F32 snap = row->mValue % row->mStepSize;
  1027. //row->mValue.y -= snap;
  1028. row->mValue += row->mStepSize;
  1029. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  1030. if (row->mValue > row->mRange.y)
  1031. row->mValue = row->mRange.y;
  1032. }
  1033. else
  1034. {
  1035. //see if we clicked on the sliderbar itself
  1036. S32 barStart = leftArrowX2;
  1037. S32 barEnd = rightArrowX1;
  1038. if (xPos >= barStart && xPos <= barEnd)
  1039. {
  1040. //find the position
  1041. F32 newValue = (((xPos - barStart) * (row->mRange.y - row->mRange.x)) / (barEnd - barStart)) + row->mRange.x;
  1042. newValue = mRound(newValue / row->mStepSize) * row->mStepSize;
  1043. row->mValue = newValue;
  1044. }
  1045. }
  1046. }
  1047. void GuiGameListMenuCtrl::clickKeybind(Row* row, S32 xPos)
  1048. {
  1049. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  1050. F32 xScale = (float)getWidth() / profile->getRowWidth();
  1051. S32 columnSplit = profile->mColumnSplit * xScale;
  1052. S32 rowHeight = profile->getRowHeight();
  1053. S32 optionWidth = xScale - columnSplit;
  1054. GFXDrawUtil* drawer = GFX->getDrawUtil();
  1055. //drawer->drawBitmap(row->mBitmap, )
  1056. Point2I button;
  1057. button.x = columnSplit + (columnSplit / 2)/* + (optionWidth / 2)*/;
  1058. button.y = rowHeight / 4;
  1059. Point2I buttonSize;
  1060. buttonSize.x = rowHeight / 2;
  1061. buttonSize.y = rowHeight / 2;
  1062. GFXTextureObject* texture = row->mBitmapTex;
  1063. RectI rect(button, buttonSize);
  1064. if (rect.pointInRect(Point2I(xPos, rowHeight / 2)))
  1065. {
  1066. if (row->mScriptCallback != StringTable->EmptyString())
  1067. {
  1068. S32 rowId = getSelected();
  1069. Con::executef(row->mScriptCallback, rowId);
  1070. }
  1071. }
  1072. }
  1073. F32 GuiGameListMenuCtrl::getValue(S32 rowIndex)
  1074. {
  1075. if (!isValidRowIndex(rowIndex))
  1076. {
  1077. return 0;
  1078. }
  1079. Row* row = (Row*)mRows[rowIndex];
  1080. return row->mValue;
  1081. }
  1082. void GuiGameListMenuCtrl::setValue(S32 rowIndex, F32 value)
  1083. {
  1084. if (!isValidRowIndex(rowIndex))
  1085. {
  1086. return;
  1087. }
  1088. Row* row = (Row*)mRows[rowIndex];
  1089. row->mValue = value;
  1090. }
  1091. const char* GuiGameListMenuCtrl::getTooltip(S32 rowIndex)
  1092. {
  1093. if (!isValidRowIndex(rowIndex))
  1094. {
  1095. return "";
  1096. }
  1097. Row* row = (Row*)mRows[rowIndex];
  1098. return row->mTooltip;
  1099. }
  1100. ConsoleDocClass( GuiGameListMenuCtrl,
  1101. "@brief A base class for cross platform menu controls that are gamepad friendly.\n\n"
  1102. "This class is used to build row-based menu GUIs that can be easily navigated "
  1103. "using the keyboard, mouse or gamepad. The desired row can be selected using "
  1104. "the mouse, or by navigating using the Up and Down buttons.\n\n"
  1105. "@tsexample\n\n"
  1106. "new GuiGameListMenuCtrl()\n"
  1107. "{\n"
  1108. " debugRender = \"0\";\n"
  1109. " callbackOnA = \"applyOptions();\";\n"
  1110. " callbackOnB = \"Canvas.setContent(MainMenuGui);\";\n"
  1111. " callbackOnX = \"\";\n"
  1112. " callbackOnY = \"revertOptions();\";\n"
  1113. " //Properties not specific to this control have been omitted from this example.\n"
  1114. "};\n"
  1115. "@endtsexample\n\n"
  1116. "@see GuiGameListMenuProfile\n\n"
  1117. "@ingroup GuiGame"
  1118. );
  1119. IMPLEMENT_CALLBACK( GuiGameListMenuCtrl, onChange, void, (), (),
  1120. "Called when the selected row changes." );
  1121. IMPLEMENT_CALLBACK(GuiGameListMenuCtrl, onInputEvent, void, (const char* device, const char* action, bool state),
  1122. (device, action, state),
  1123. "@brief Callback that occurs when an input is triggered on this control\n\n"
  1124. "@param device The device type triggering the input, such as keyboard, mouse, etc\n"
  1125. "@param action The actual event occuring, such as a key or button\n"
  1126. "@param state True if the action is being pressed, false if it is being release\n\n");
  1127. IMPLEMENT_CALLBACK(GuiGameListMenuCtrl, onAxisEvent, void, (const char* device, const char* action, F32 axisValue),
  1128. (device, action, axisValue),
  1129. "@brief Callback that occurs when an axis event is triggered on this control\n\n"
  1130. "@param device The device type triggering the input, such as mouse, joystick, gamepad, etc\n"
  1131. "@param action The ActionMap code for the axis\n"
  1132. "@param axisValue The current value of the axis\n\n");
  1133. void GuiGameListMenuCtrl::initPersistFields()
  1134. {
  1135. addField("debugRender", TypeBool, Offset(mDebugRender, GuiGameListMenuCtrl),
  1136. "Enable debug rendering" );
  1137. addField("callbackOnA", TypeString, Offset(mCallbackOnA, GuiGameListMenuCtrl),
  1138. "Script callback when the 'A' button is pressed. 'A' inputs are Keyboard: A, Return, Space; Gamepad: A, Start" );
  1139. addField("callbackOnB", TypeString, Offset(mCallbackOnB, GuiGameListMenuCtrl),
  1140. "Script callback when the 'B' button is pressed. 'B' inputs are Keyboard: B, Esc, Backspace, Delete; Gamepad: B, Back" );
  1141. addField("callbackOnX", TypeString, Offset(mCallbackOnX, GuiGameListMenuCtrl),
  1142. "Script callback when the 'X' button is pressed. 'X' inputs are Keyboard: X; Gamepad: X" );
  1143. addField("callbackOnY", TypeString, Offset(mCallbackOnY, GuiGameListMenuCtrl),
  1144. "Script callback when the 'Y' button is pressed. 'Y' inputs are Keyboard: Y; Gamepad: Y" );
  1145. addField("callbackOnInputs", TypeBool, Offset(mCallbackOnInputs, GuiGameListMenuCtrl),
  1146. "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.");
  1147. Parent::initPersistFields();
  1148. }
  1149. DefineEngineMethod( GuiGameListMenuCtrl, addRow, void,
  1150. ( const char* label, const char* callback, S32 icon, S32 yPad, bool useHighlightIcon, bool enabled, int mode ),
  1151. ( -1, 0, true, true, 0 ),
  1152. "Add a row to the list control.\n\n"
  1153. "@param label The text to display on the row as a label.\n"
  1154. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1155. "@param icon [optional] Index of the icon to use as a marker.\n"
  1156. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1157. "@param useHighlightIcon [optional] Does this row use the highlight icon?.\n"
  1158. "@param enabled [optional] If this row is initially enabled.\n"
  1159. "@param mode [optional] What option mode the row is in. 0 = Default, 1 = OptionList, 2 == Keybind")
  1160. {
  1161. object->addRow( label, callback, icon, yPad, useHighlightIcon, enabled, mode);
  1162. }
  1163. DefineEngineMethod( GuiGameListMenuCtrl, isRowEnabled, bool, ( S32 row ),,
  1164. "Determines if the specified row is enabled or disabled.\n\n"
  1165. "@param row The row to set the enabled status of.\n"
  1166. "@return True if the specified row is enabled. False if the row is not enabled or the given index was not valid." )
  1167. {
  1168. return object->isRowEnabled( row );
  1169. }
  1170. DefineEngineMethod( GuiGameListMenuCtrl, setRowEnabled, void, ( S32 row, bool enabled ),,
  1171. "Sets a row's enabled status according to the given parameters.\n\n"
  1172. "@param row The index to check for validity.\n"
  1173. "@param enabled Indicate true to enable the row or false to disable it." )
  1174. {
  1175. object->setRowEnabled( row, enabled );
  1176. }
  1177. DefineEngineMethod( GuiGameListMenuCtrl, activateRow, void, (),,
  1178. "Activates the current row. The script callback of the current row will be called (if it has one)." )
  1179. {
  1180. object->activateRow();
  1181. }
  1182. DefineEngineMethod( GuiGameListMenuCtrl, getRowCount, S32, (),,
  1183. "Gets the number of rows on the control.\n\n"
  1184. "@return (int) The number of rows on the control." )
  1185. {
  1186. return object->getRowCount();
  1187. }
  1188. DefineEngineMethod( GuiGameListMenuCtrl, getRowLabel, const char *, ( S32 row ),,
  1189. "Gets the label displayed on the specified row.\n\n"
  1190. "@param row Index of the row to get the label of.\n"
  1191. "@return The label for the row." )
  1192. {
  1193. return object->getRowLabel( row );
  1194. }
  1195. DefineEngineMethod( GuiGameListMenuCtrl, setRowLabel, void, ( S32 row, const char* label ),,
  1196. "Sets the label on the given row.\n\n"
  1197. "@param row Index of the row to set the label on.\n"
  1198. "@param label Text to set as the label of the row.\n" )
  1199. {
  1200. object->setRowLabel( row, label );
  1201. }
  1202. DefineEngineMethod( GuiGameListMenuCtrl, setSelected, void, ( S32 row ),,
  1203. "Sets the selected row. Only rows that are enabled can be selected.\n\n"
  1204. "@param row Index of the row to set as selected." )
  1205. {
  1206. object->setSelected( row );
  1207. }
  1208. DefineEngineMethod( GuiGameListMenuCtrl, getSelectedRow, S32, (),,
  1209. "Gets the index of the currently selected row.\n\n"
  1210. "@return Index of the selected row." )
  1211. {
  1212. return object->getSelected();
  1213. }
  1214. DefineEngineMethod(GuiGameListMenuCtrl, clearRows, void, (), ,
  1215. "Gets the index of the currently selected row.\n\n"
  1216. "@return Index of the selected row.")
  1217. {
  1218. return object->clearRows();
  1219. }
  1220. DefineEngineMethod(GuiGameListMenuCtrl, refresh, void, (), ,
  1221. "Gets the index of the currently selected row.\n\n"
  1222. "@return Index of the selected row.")
  1223. {
  1224. return object->refresh();
  1225. }
  1226. DefineEngineMethod(GuiGameListMenuCtrl, addOptionRow, void,
  1227. (const char* label, const char* options, bool wrapOptions, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip, const char* defaultValue),
  1228. (-1, 0, true, "", ""),
  1229. "Add a row to the list control.\n\n"
  1230. "@param label The text to display on the row as a label.\n"
  1231. "@param options A tab separated list of options.\n"
  1232. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1233. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1234. "@param icon [optional] Index of the icon to use as a marker.\n"
  1235. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1236. "@param enabled [optional] If this row is initially enabled.")
  1237. {
  1238. object->addRow(label, options, wrapOptions, callback, icon, yPad, enabled, tooltip, defaultValue);
  1239. }
  1240. DefineEngineMethod(GuiGameListMenuCtrl, addSliderRow, void,
  1241. (const char* label, F32 defaultValue, F32 increment, Point2F range, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip),
  1242. (-1, 0, true, ""),
  1243. "Add a row to the list control.\n\n"
  1244. "@param label The text to display on the row as a label.\n"
  1245. "@param options A tab separated list of options.\n"
  1246. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1247. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1248. "@param icon [optional] Index of the icon to use as a marker.\n"
  1249. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1250. "@param enabled [optional] If this row is initially enabled.")
  1251. {
  1252. object->addRow(label, defaultValue, increment, range, callback, icon, yPad, enabled, tooltip);
  1253. }
  1254. DefineEngineMethod(GuiGameListMenuCtrl, addKeybindRow, void,
  1255. (const char* label, const char* bitmapName, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip),
  1256. (-1, 0, true, ""),
  1257. "Add a row to the list control.\n\n"
  1258. "@param label The text to display on the row as a label.\n"
  1259. "@param options A tab separated list of options.\n"
  1260. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1261. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1262. "@param icon [optional] Index of the icon to use as a marker.\n"
  1263. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1264. "@param enabled [optional] If this row is initially enabled.")
  1265. {
  1266. object->addRow(label, bitmapName, callback, icon, yPad, enabled, tooltip);
  1267. }
  1268. DefineEngineMethod(GuiGameListMenuCtrl, removeRow, void, (S32 row),,
  1269. "Removes the row at the provided index")
  1270. {
  1271. object->removeRow(row);
  1272. }
  1273. DefineEngineMethod(GuiGameListMenuCtrl, getCurrentOption, const char*, (S32 row), ,
  1274. "Gets the text for the currently selected option of the given row.\n\n"
  1275. "@param row Index of the row to get the option from.\n"
  1276. "@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.")
  1277. {
  1278. return object->getCurrentOption(row);
  1279. }
  1280. DefineEngineMethod(GuiGameListMenuCtrl, selectOption, bool, (S32 row, const char* option), ,
  1281. "Set the row's current option to the one specified\n\n"
  1282. "@param row Index of the row to set an option on.\n"
  1283. "@param option The option to be made active.\n"
  1284. "@return True if the row contained the option and was set, false otherwise.")
  1285. {
  1286. return object->selectOption(row, option);
  1287. }
  1288. DefineEngineMethod(GuiGameListMenuCtrl, setOptions, void, (S32 row, const char* optionsList), ,
  1289. "Sets the list of options on the given row.\n\n"
  1290. "@param row Index of the row to set options on."
  1291. "@param optionsList A tab separated list of options for the control.")
  1292. {
  1293. object->setOptions(row, optionsList);
  1294. }
  1295. DefineEngineMethod(GuiGameListMenuCtrl, getValue, F32, (S32 row), ,
  1296. "Sets the list of options on the given row.\n\n"
  1297. "@param row Index of the row to set options on."
  1298. "@param optionsList A tab separated list of options for the control.")
  1299. {
  1300. return object->getValue(row);
  1301. }
  1302. DefineEngineMethod(GuiGameListMenuCtrl, setValue, void, (S32 row, F32 value), ,
  1303. "Sets the list of options on the given row.\n\n"
  1304. "@param row Index of the row to set options on."
  1305. "@param optionsList A tab separated list of options for the control.")
  1306. {
  1307. object->setValue(row, value);
  1308. }
  1309. DefineEngineMethod(GuiGameListMenuCtrl, getTooltip, const char*, (S32 row), ,
  1310. "Sets the list of options on the given row.\n\n"
  1311. "@param row Index of the row to set options on."
  1312. "@param optionsList A tab separated list of options for the control.")
  1313. {
  1314. return object->getTooltip(row);
  1315. }
  1316. //-----------------------------------------------------------------------------
  1317. // GuiGameListMenuProfile
  1318. //-----------------------------------------------------------------------------
  1319. GuiGameListMenuProfile::GuiGameListMenuProfile()
  1320. : mHitAreaUpperLeft(0, 0),
  1321. mHitAreaLowerRight(0, 0),
  1322. mIconOffset(0, 0),
  1323. mRowSize(0, 0),
  1324. mRowScale(1.0f, 1.0f),
  1325. mColumnSplit(0),
  1326. mRightPad(0)
  1327. {
  1328. }
  1329. bool GuiGameListMenuProfile::onAdd()
  1330. {
  1331. if (! Parent::onAdd())
  1332. {
  1333. return false;
  1334. }
  1335. // We can't call enforceConstraints() here because incRefCount initializes
  1336. // some of the things to enforce. Do a basic sanity check here instead.
  1337. if( !mBitmapName || !dStrlen(mBitmapName) )
  1338. {
  1339. Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
  1340. return false;
  1341. }
  1342. if( mRowSize.x < 0 )
  1343. {
  1344. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row width. Please change the row width to be non-negative.", getName() );
  1345. return false;
  1346. }
  1347. if( mRowSize.y < 0 )
  1348. {
  1349. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row height. Please change the row height to be non-negative.", getName() );
  1350. return false;
  1351. }
  1352. return true;
  1353. }
  1354. void GuiGameListMenuProfile::enforceConstraints()
  1355. {
  1356. if( getBitmapArrayRect(0).extent.isZero() )
  1357. Con::errorf( "GuiGameListMenuCtrl: %s can't be created without a bitmap. Please add a bitmap to the profile's definition.", getName() );
  1358. if( mRowSize.x < 0 )
  1359. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row width. Please change the row width to be non-negative.", getName() );
  1360. mRowSize.x = getMax(mRowSize.x, 0);
  1361. if( mRowSize.y < 0 )
  1362. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row height. Please change the row height to be non-negative.", getName() );
  1363. mRowSize.y = getMax(mRowSize.y, 0);
  1364. Point2I rowTexExtent = getBitmapArrayRect(TEX_NORMAL).extent;
  1365. mRowScale.x = (float) getRowWidth() / rowTexExtent.x;
  1366. mRowScale.y = (float) getRowHeight() / rowTexExtent.y;
  1367. if (mHitAreaUpperLeft.x > mColumnSplit || mColumnSplit > mHitAreaLowerRight.x)
  1368. 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].",
  1369. getName(), mColumnSplit, mHitAreaUpperLeft.x, mHitAreaLowerRight.x);
  1370. mColumnSplit = mClamp(mColumnSplit, mHitAreaUpperLeft.x, mHitAreaLowerRight.x);
  1371. }
  1372. Point2I GuiGameListMenuProfile::getIconExtent()
  1373. {
  1374. Point2I iconExtent = getBitmapArrayRect(TEX_FIRST_ICON).extent;
  1375. // scale both by y to keep the aspect ratio
  1376. iconExtent.x *= mRowScale.y;
  1377. iconExtent.y *= mRowScale.y;
  1378. return iconExtent;
  1379. }
  1380. Point2I GuiGameListMenuProfile::getArrowExtent()
  1381. {
  1382. Point2I arrowExtent = getBitmapArrayRect(TEX_FIRST_ARROW).extent;
  1383. // scale both by y to keep the aspect ratio
  1384. arrowExtent.x *= mRowScale.y;
  1385. arrowExtent.y *= mRowScale.y;
  1386. return arrowExtent;
  1387. }
  1388. Point2I GuiGameListMenuProfile::getHitAreaExtent()
  1389. {
  1390. if (mHitAreaLowerRight == mHitAreaUpperLeft)
  1391. {
  1392. return mRowSize;
  1393. }
  1394. else
  1395. {
  1396. return mHitAreaLowerRight - mHitAreaUpperLeft;
  1397. }
  1398. }
  1399. //-----------------------------------------------------------------------------
  1400. // Console stuff (GuiGameListMenuProfile)
  1401. //-----------------------------------------------------------------------------
  1402. IMPLEMENT_CONOBJECT(GuiGameListMenuProfile);
  1403. ConsoleDocClass( GuiGameListMenuProfile,
  1404. "@brief A GuiControlProfile with additional fields specific to GuiGameListMenuCtrl.\n\n"
  1405. "@tsexample\n"
  1406. "new GuiGameListMenuProfile()\n"
  1407. "{\n"
  1408. " hitAreaUpperLeft = \"10 2\";\n"
  1409. " hitAreaLowerRight = \"190 18\";\n"
  1410. " iconOffset = \"10 2\";\n"
  1411. " rowSize = \"200 20\";\n"
  1412. " columnSplit = \"100\";\n"
  1413. " rightPad = \"4\";\n"
  1414. " //Properties not specific to this control have been omitted from this example.\n"
  1415. "};\n"
  1416. "@endtsexample\n\n"
  1417. "@ingroup GuiGame"
  1418. );
  1419. void GuiGameListMenuProfile::initPersistFields()
  1420. {
  1421. addField( "hitAreaUpperLeft", TypePoint2I, Offset(mHitAreaUpperLeft, GuiGameListMenuProfile),
  1422. "Position of the upper left corner of the row hit area (relative to row's top left corner)" );
  1423. addField( "hitAreaLowerRight", TypePoint2I, Offset(mHitAreaLowerRight, GuiGameListMenuProfile),
  1424. "Position of the lower right corner of the row hit area (relative to row's top left corner)" );
  1425. addField( "iconOffset", TypePoint2I, Offset(mIconOffset, GuiGameListMenuProfile),
  1426. "Offset from the row's top left corner at which to render the row icon" );
  1427. addField( "rowSize", TypePoint2I, Offset(mRowSize, GuiGameListMenuProfile),
  1428. "The base size (\"width height\") of a row" );
  1429. addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListMenuProfile),
  1430. "Padding between the leftmost edge of the control, and the row's left arrow.");
  1431. addField("rightPad", TypeS32, Offset(mRightPad, GuiGameListMenuProfile),
  1432. "Padding between the rightmost edge of the control and the row's right arrow.");
  1433. Parent::initPersistFields();
  1434. removeField("tab");
  1435. removeField("mouseOverSelected");
  1436. removeField("modal");
  1437. removeField("opaque");
  1438. removeField("border");
  1439. removeField("borderThickness");
  1440. removeField("borderColor");
  1441. removeField("borderColorHL");
  1442. removeField("borderColorNA");
  1443. removeField("bevelColorHL");
  1444. removeField("bevelColorLL");
  1445. removeField("fontColorLink");
  1446. removeField("fontColorLinkHL");
  1447. removeField("justify");
  1448. removeField("returnTab");
  1449. removeField("numbersOnly");
  1450. removeField("cursorColor");
  1451. removeField("profileForChildren");
  1452. }