guiGameListMenuCtrl.cpp 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747
  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 (dStrcmp(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. Point2I GuiGameListMenuCtrl::getMinExtent() const
  445. {
  446. Point2I parentMin = Parent::getMinExtent();
  447. GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
  448. S32 minHeight = 0;
  449. S32 rowHeight = profile->getRowHeight();
  450. for (Vector<Row *>::const_iterator row = mRows.begin(); row < mRows.end(); ++row)
  451. {
  452. minHeight += rowHeight;
  453. if (row != mRows.begin())
  454. {
  455. minHeight += (*row)->mHeightPad;
  456. }
  457. }
  458. if (minHeight > parentMin.y)
  459. parentMin.y = minHeight;
  460. return parentMin;
  461. }
  462. bool GuiGameListMenuCtrl::onAdd()
  463. {
  464. if( !Parent::onAdd() )
  465. return false;
  466. // If we have a non-GuiGameListMenuProfile profile, try to
  467. // substitute it for DefaultListMenuProfile.
  468. if( !hasValidProfile() )
  469. {
  470. GuiGameListMenuProfile* profile;
  471. if( !Sim::findObject( "DefaultListMenuProfile", profile ) )
  472. {
  473. Con::errorf( "GuiGameListMenuCtrl: %s can't be created with a profile of type %s. Please create it with a profile of type GuiGameListMenuProfile.",
  474. getName(), mProfile->getClassName() );
  475. return false;
  476. }
  477. else
  478. Con::warnf( "GuiGameListMenuCtrl: substituted non-GuiGameListMenuProfile in %s for DefaultListMenuProfile", getName() );
  479. setControlProfile( profile );
  480. }
  481. return true;
  482. }
  483. bool GuiGameListMenuCtrl::onWake()
  484. {
  485. if( !Parent::onWake() )
  486. return false;
  487. if( !hasValidProfile() )
  488. return false;
  489. /*if( mRows.empty() )
  490. {
  491. 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.",
  492. getName() );
  493. return false;
  494. }*/
  495. enforceConstraints();
  496. selectFirstEnabledRow();
  497. setFirstResponder();
  498. mHighlighted = NO_ROW;
  499. return true;
  500. }
  501. bool GuiGameListMenuCtrl::hasValidProfile() const
  502. {
  503. GuiGameListMenuProfile * profile = dynamic_cast<GuiGameListMenuProfile *>(mProfile);
  504. return profile;
  505. }
  506. void GuiGameListMenuCtrl::enforceConstraints()
  507. {
  508. if( hasValidProfile() )
  509. {
  510. ((GuiGameListMenuProfile *)mProfile)->enforceConstraints();
  511. }
  512. updateHeight();
  513. }
  514. void GuiGameListMenuCtrl::updateHeight()
  515. {
  516. S32 minHeight = getMinExtent().y;
  517. if (getHeight() < minHeight)
  518. {
  519. setHeight(minHeight);
  520. }
  521. }
  522. void GuiGameListMenuCtrl::onMouseDown(const GuiEvent &event)
  523. {
  524. S32 hitRow = getRow(event.mousePoint);
  525. if (hitRow != NO_ROW)
  526. {
  527. S32 delta = (mSelected != NO_ROW) ? (hitRow - mSelected) : (mSelected + 1);
  528. changeRow(delta);
  529. }
  530. }
  531. void GuiGameListMenuCtrl::onMouseLeave(const GuiEvent &event)
  532. {
  533. mHighlighted = NO_ROW;
  534. }
  535. void GuiGameListMenuCtrl::onMouseMove(const GuiEvent &event)
  536. {
  537. S32 hitRow = getRow(event.mousePoint);
  538. // allow mHighligetd to be set to NO_ROW so rows can be unhighlighted
  539. mHighlighted = hitRow;
  540. }
  541. void GuiGameListMenuCtrl::onMouseUp(const GuiEvent &event)
  542. {
  543. S32 hitRow = getRow(event.mousePoint);
  544. if ((hitRow != NO_ROW) && isRowEnabled(hitRow) && (hitRow == getSelected()))
  545. {
  546. if (mRows[hitRow]->mMode == Row::Mode::Default)
  547. {
  548. activateRow();
  549. }
  550. else if (mRows[hitRow]->mMode == Row::Mode::OptionList)
  551. {
  552. S32 xPos = globalToLocalCoord(event.mousePoint).x;
  553. clickOption((Row*)mRows[getSelected()], xPos);
  554. }
  555. else if (mRows[hitRow]->mMode == Row::Mode::Slider)
  556. {
  557. S32 xPos = globalToLocalCoord(event.mousePoint).x;
  558. clickSlider((Row*)mRows[getSelected()], xPos);
  559. }
  560. else if (mRows[hitRow]->mMode == Row::Mode::Keybind)
  561. {
  562. S32 xPos = globalToLocalCoord(event.mousePoint).x;
  563. clickKeybind((Row*)mRows[getSelected()], xPos);
  564. }
  565. }
  566. }
  567. void GuiGameListMenuCtrl::activateRow()
  568. {
  569. S32 row = getSelected();
  570. if ((row != NO_ROW) && isRowEnabled(row) && (mRows[row]->mScriptCallback != NULL))
  571. {
  572. setThisControl();
  573. if (Con::isFunction(mRows[row]->mScriptCallback))
  574. {
  575. Con::executef(mRows[row]->mScriptCallback);
  576. }
  577. }
  578. }
  579. S32 GuiGameListMenuCtrl::getRow(Point2I globalPoint)
  580. {
  581. Point2I localPoint = globalToLocalCoord(globalPoint);
  582. GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
  583. F32 xScale = (float) getWidth() / profile->getRowWidth();
  584. S32 rowHeight = profile->getRowHeight();
  585. Point2I currentOffset(0, 0);
  586. Point2I hitAreaUpperLeft = profile->mHitAreaUpperLeft;
  587. hitAreaUpperLeft.x *= xScale;
  588. Point2I hitAreaLowerRight = profile->mHitAreaLowerRight;
  589. hitAreaLowerRight.x *= xScale;
  590. Point2I upperLeft, lowerRight;
  591. for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
  592. {
  593. if (row != mRows.begin())
  594. {
  595. // rows other than the first can have padding above them
  596. currentOffset.y += (*row)->mHeightPad;
  597. }
  598. upperLeft = currentOffset + hitAreaUpperLeft;
  599. lowerRight = currentOffset + hitAreaLowerRight;
  600. if ((upperLeft.x <= localPoint.x) && (localPoint.x < lowerRight.x) &&
  601. (upperLeft.y <= localPoint.y) && (localPoint.y < lowerRight.y))
  602. {
  603. return row - mRows.begin();
  604. }
  605. currentOffset.y += rowHeight;
  606. }
  607. return NO_ROW;
  608. }
  609. void GuiGameListMenuCtrl::setSelected(S32 index)
  610. {
  611. if (index == NO_ROW)
  612. {
  613. // deselection
  614. mSelected = NO_ROW;
  615. return;
  616. }
  617. if (! isValidRowIndex(index))
  618. {
  619. return;
  620. }
  621. if (! isRowEnabled(index))
  622. {
  623. // row is disabled, it can't be selected
  624. return;
  625. }
  626. mSelected = mClamp(index, 0, mRows.size() - 1);
  627. //If we're childed to a scroll container, make sure us changing rows has our new position visible
  628. GuiScrollCtrl* scroll = dynamic_cast<GuiScrollCtrl*>(getParent());
  629. if (scroll)
  630. {
  631. scroll->scrollRectVisible(getRowBounds(mSelected));
  632. }
  633. }
  634. bool GuiGameListMenuCtrl::isRowEnabled(S32 index) const
  635. {
  636. if (! isValidRowIndex(index))
  637. {
  638. return false;
  639. }
  640. return mRows[index]->mEnabled;
  641. }
  642. void GuiGameListMenuCtrl::setRowEnabled(S32 index, bool enabled)
  643. {
  644. if (! isValidRowIndex(index))
  645. {
  646. return;
  647. }
  648. mRows[index]->mEnabled = enabled;
  649. if (getSelected() == index)
  650. {
  651. selectFirstEnabledRow();
  652. }
  653. }
  654. bool GuiGameListMenuCtrl::isValidRowIndex(S32 index) const
  655. {
  656. return ((0 <= index) && (index < mRows.size()));
  657. }
  658. void GuiGameListMenuCtrl::selectFirstEnabledRow()
  659. {
  660. setSelected(NO_ROW);
  661. for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
  662. {
  663. if ((*row)->mEnabled)
  664. {
  665. setSelected(row - mRows.begin());
  666. return;
  667. }
  668. }
  669. }
  670. bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
  671. {
  672. if (mCallbackOnInputs)
  673. {
  674. char deviceString[32];
  675. if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
  676. return false;
  677. if (event.action == SI_MAKE || event.action == SI_BREAK)
  678. {
  679. bool isModifier = false;
  680. bool state = event.action == SI_MAKE;
  681. switch (event.objInst)
  682. {
  683. case KEY_LCONTROL:
  684. case KEY_RCONTROL:
  685. case KEY_LALT:
  686. case KEY_RALT:
  687. case KEY_LSHIFT:
  688. case KEY_RSHIFT:
  689. case KEY_MAC_LOPT:
  690. case KEY_MAC_ROPT:
  691. isModifier = true;
  692. }
  693. if ((event.objType == SI_KEY) && isModifier)
  694. {
  695. char keyString[32];
  696. if (!ActionMap::getKeyString(event.objInst, keyString))
  697. return false;
  698. onInputEvent_callback(deviceString, keyString, state);
  699. }
  700. else
  701. {
  702. const char* actionString = ActionMap::buildActionString(&event);
  703. onInputEvent_callback(deviceString, actionString, state);
  704. }
  705. }
  706. else if (event.objType == SI_AXIS || event.objType == SI_INT || event.objType == SI_FLOAT)
  707. {
  708. F32 fValue = event.fValue;
  709. if (event.objType == SI_INT)
  710. fValue = (F32)event.iValue;
  711. if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
  712. return false;
  713. const char* actionString = ActionMap::buildActionString(&event);
  714. onAxisEvent_callback(deviceString, actionString, fValue);
  715. }
  716. }
  717. return false;
  718. }
  719. bool GuiGameListMenuCtrl::onKeyDown(const GuiEvent &event)
  720. {
  721. switch (event.keyCode)
  722. {
  723. case KEY_UP:
  724. changeRow(-1);
  725. return true;
  726. case KEY_DOWN:
  727. changeRow(1);
  728. return true;
  729. case KEY_A:
  730. case KEY_RETURN:
  731. case KEY_NUMPADENTER:
  732. case KEY_SPACE:
  733. case XI_A:
  734. case XI_START:
  735. doScriptCommand(mCallbackOnA);
  736. return true;
  737. case KEY_B:
  738. case KEY_ESCAPE:
  739. case KEY_BACKSPACE:
  740. case KEY_DELETE:
  741. case XI_B:
  742. case XI_BACK:
  743. doScriptCommand(mCallbackOnB);
  744. return true;
  745. case KEY_X:
  746. case XI_X:
  747. doScriptCommand(mCallbackOnX);
  748. return true;
  749. case KEY_Y:
  750. case XI_Y:
  751. doScriptCommand(mCallbackOnY);
  752. return true;
  753. default:
  754. break;
  755. }
  756. return Parent::onKeyDown(event);
  757. }
  758. bool GuiGameListMenuCtrl::onGamepadAxisUp(const GuiEvent &event)
  759. {
  760. changeRow(-1);
  761. return true;
  762. }
  763. bool GuiGameListMenuCtrl::onGamepadAxisDown(const GuiEvent &event)
  764. {
  765. changeRow(1);
  766. return true;
  767. }
  768. bool GuiGameListMenuCtrl::onGamepadAxisLeft(const GuiEvent& event)
  769. {
  770. changeOption(-1);
  771. return true;
  772. }
  773. bool GuiGameListMenuCtrl::onGamepadAxisRight(const GuiEvent& event)
  774. {
  775. changeOption(1);
  776. return true;
  777. }
  778. void GuiGameListMenuCtrl::doScriptCommand(StringTableEntry command)
  779. {
  780. if (command && command[0])
  781. {
  782. setThisControl();
  783. Con::evaluate(command, false, __FILE__);
  784. }
  785. }
  786. void GuiGameListMenuCtrl::changeRow(S32 delta)
  787. {
  788. S32 oldRowIndex = getSelected();
  789. S32 newRowIndex = oldRowIndex;
  790. do
  791. {
  792. newRowIndex += delta;
  793. if (newRowIndex >= mRows.size())
  794. {
  795. newRowIndex = 0;
  796. }
  797. else if (newRowIndex < 0)
  798. {
  799. newRowIndex = mRows.size() - 1;
  800. }
  801. }
  802. while ((! mRows[newRowIndex]->mEnabled) && (newRowIndex != oldRowIndex));
  803. setSelected(newRowIndex);
  804. // do the callback
  805. onChange_callback();
  806. }
  807. void GuiGameListMenuCtrl::setThisControl()
  808. {
  809. smThisControl = this;
  810. }
  811. StringTableEntry GuiGameListMenuCtrl::getRowLabel(S32 rowIndex) const
  812. {
  813. 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()));
  814. if (! isValidRowIndex(rowIndex))
  815. {
  816. // not a valid row index, don't do anything
  817. return StringTable->EmptyString();
  818. }
  819. return mRows[rowIndex]->mLabel;
  820. }
  821. void GuiGameListMenuCtrl::setRowLabel(S32 rowIndex, const char * label)
  822. {
  823. 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()));
  824. if (! isValidRowIndex(rowIndex))
  825. {
  826. // not a valid row index, don't do anything
  827. return;
  828. }
  829. mRows[rowIndex]->mLabel = StringTable->insert(label, true);
  830. }
  831. void GuiGameListMenuCtrl::clearRows()
  832. {
  833. for (U32 i = 0; i < mRows.size(); i++)
  834. {
  835. if (mRows[i]->mBitmap != StringTable->EmptyString())
  836. mRows[i]->mBitmapTex = nullptr;
  837. }
  838. mRows.clear();
  839. setSelected(-1);
  840. setHeight(mMinExtent.y);
  841. }
  842. void GuiGameListMenuCtrl::refresh()
  843. {
  844. enforceConstraints();
  845. }
  846. RectI GuiGameListMenuCtrl::getRowBounds(S32 rowIndex)
  847. {
  848. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  849. F32 xScale = (float)getWidth() / profile->getRowWidth();
  850. S32 rowHeight = profile->getRowHeight();
  851. Point2I currentOffset = Point2I::Zero;
  852. Point2I extent = getExtent();
  853. Point2I rowExtent(extent.x, rowHeight);
  854. for (U32 i = 1; i <= rowIndex; i++)
  855. {
  856. //the top row can't pad, so we'll ignore it
  857. GuiGameListMenuCtrl::Row* row = mRows[i];
  858. // rows other than the first can have padding above them
  859. currentOffset.y += row->mHeightPad;
  860. currentOffset.y += rowHeight;
  861. }
  862. return RectI(currentOffset, rowExtent);
  863. }
  864. //-----------------------------------------------------------------------------
  865. // Console stuff (GuiGameListMenuCtrl)
  866. //-----------------------------------------------------------------------------
  867. StringTableEntry GuiGameListMenuCtrl::getCurrentOption(S32 rowIndex) const
  868. {
  869. if (isValidRowIndex(rowIndex))
  870. {
  871. Row* row = (Row*)mRows[rowIndex];
  872. if (row->mSelectedOption != NO_OPTION)
  873. {
  874. return row->mOptions[row->mSelectedOption];
  875. }
  876. }
  877. return StringTable->insert("", false);
  878. }
  879. bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
  880. {
  881. if (!isValidRowIndex(rowIndex))
  882. {
  883. return false;
  884. }
  885. Row* row = (Row*)mRows[rowIndex];
  886. for (Vector<StringTableEntry>::iterator anOption = row->mOptions.begin(); anOption < row->mOptions.end(); ++anOption)
  887. {
  888. if (dStrcmp(*anOption, theOption) == 0)
  889. {
  890. S32 newIndex = anOption - row->mOptions.begin();
  891. row->mSelectedOption = newIndex;
  892. return true;
  893. }
  894. }
  895. return false;
  896. }
  897. void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
  898. {
  899. static StringTableEntry DELIM = StringTable->insert("\t", true);
  900. if (!isValidRowIndex(rowIndex))
  901. {
  902. return;
  903. }
  904. Row* row = (Row*)mRows[rowIndex];
  905. S32 count = StringUnit::getUnitCount(optionsList, DELIM);
  906. row->mOptions.setSize(count);
  907. for (S32 i = 0; i < count; ++i)
  908. {
  909. const char* option = StringUnit::getUnit(optionsList, i, DELIM);
  910. row->mOptions[i] = StringTable->insert(option, true);
  911. }
  912. if (row->mSelectedOption >= row->mOptions.size())
  913. {
  914. row->mSelectedOption = row->mOptions.size() - 1;
  915. }
  916. }
  917. void GuiGameListMenuCtrl::clickOption(Row* row, S32 xPos)
  918. {
  919. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  920. if (!profile->hasArrows())
  921. {
  922. return;
  923. }
  924. F32 xScale = (float)getWidth() / profile->getRowWidth();
  925. S32 bitmapArrowWidth = mProfile->getBitmapArrayRect(Profile::TEX_FIRST_ARROW).extent.x;
  926. S32 leftArrowX1 = profile->mColumnSplit * xScale;
  927. S32 leftArrowX2 = leftArrowX1 + bitmapArrowWidth;
  928. S32 rightArrowX2 = (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale;
  929. S32 rightArrowX1 = rightArrowX2 - bitmapArrowWidth;
  930. if ((leftArrowX1 <= xPos) && (xPos <= leftArrowX2))
  931. {
  932. changeOption(row, -1);
  933. }
  934. else if ((rightArrowX1 <= xPos) && (xPos <= rightArrowX2))
  935. {
  936. changeOption(row, 1);
  937. }
  938. }
  939. void GuiGameListMenuCtrl::changeOption(S32 delta)
  940. {
  941. if (getSelected() != NO_ROW)
  942. {
  943. Row* row = (Row*)mRows[getSelected()];
  944. changeOption(row, delta);
  945. }
  946. }
  947. void GuiGameListMenuCtrl::changeOption(Row* row, S32 delta)
  948. {
  949. S32 optionCount = row->mOptions.size();
  950. S32 newSelection = row->mSelectedOption + delta;
  951. if (optionCount == 0)
  952. {
  953. newSelection = NO_OPTION;
  954. }
  955. else if (!row->mWrapOptions)
  956. {
  957. newSelection = mClamp(newSelection, 0, optionCount - 1);
  958. }
  959. else if (newSelection < 0)
  960. {
  961. newSelection = optionCount - 1;
  962. }
  963. else if (newSelection >= optionCount)
  964. {
  965. newSelection = 0;
  966. }
  967. row->mSelectedOption = newSelection;
  968. if (row->mMode == GuiGameListMenuCtrl::Row::Slider)
  969. {
  970. row->mValue += row->mStepSize * delta;
  971. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  972. if (row->mValue < row->mRange.x)
  973. row->mValue = row->mRange.x;
  974. if (row->mValue > row->mRange.y)
  975. row->mValue = row->mRange.y;
  976. }
  977. static StringTableEntry LEFT = StringTable->insert("LEFT", true);
  978. static StringTableEntry RIGHT = StringTable->insert("RIGHT", true);
  979. if (row->mScriptCallback != NULL && (row->mSelectedOption != NO_OPTION && row->mMode != GuiGameListMenuCtrl::Row::Slider))
  980. {
  981. setThisControl();
  982. StringTableEntry direction = NULL;
  983. if (delta < 0)
  984. {
  985. direction = LEFT;
  986. }
  987. else if (delta > 0)
  988. {
  989. direction = RIGHT;
  990. }
  991. if ((direction != NULL) && (Con::isFunction(row->mScriptCallback)))
  992. {
  993. Con::executef(row->mScriptCallback, direction);
  994. }
  995. }
  996. }
  997. IMPLEMENT_CONOBJECT(GuiGameListMenuCtrl);
  998. void GuiGameListMenuCtrl::clickSlider(Row* row, S32 xPos)
  999. {
  1000. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  1001. if (!profile->hasArrows())
  1002. {
  1003. return;
  1004. }
  1005. F32 xScale = (float)getWidth() / profile->getRowWidth();
  1006. S32 bitmapArrowWidth = mProfile->getBitmapArrayRect(Profile::TEX_FIRST_ARROW).extent.x;
  1007. S32 leftArrowX1 = profile->mColumnSplit * xScale;
  1008. S32 leftArrowX2 = leftArrowX1 + bitmapArrowWidth;
  1009. S32 rightArrowX2 = (profile->mHitAreaLowerRight.x - profile->mRightPad) * xScale;
  1010. S32 rightArrowX1 = rightArrowX2 - bitmapArrowWidth;
  1011. if ((leftArrowX1 <= xPos) && (xPos <= leftArrowX2))
  1012. {
  1013. row->mValue -= row->mStepSize;
  1014. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  1015. if (row->mValue < row->mRange.x)
  1016. row->mValue = row->mRange.x;
  1017. }
  1018. else if ((rightArrowX1 <= xPos) && (xPos <= rightArrowX2))
  1019. {
  1020. //F32 snap = row->mValue % row->mStepSize;
  1021. //row->mValue.y -= snap;
  1022. row->mValue += row->mStepSize;
  1023. row->mValue = mRound(row->mValue / row->mStepSize) * row->mStepSize;
  1024. if (row->mValue > row->mRange.y)
  1025. row->mValue = row->mRange.y;
  1026. }
  1027. else
  1028. {
  1029. //see if we clicked on the sliderbar itself
  1030. S32 barStart = leftArrowX2;
  1031. S32 barEnd = rightArrowX1;
  1032. if (xPos >= barStart && xPos <= barEnd)
  1033. {
  1034. //find the position
  1035. F32 newValue = (((xPos - barStart) * (row->mRange.y - row->mRange.x)) / (barEnd - barStart)) + row->mRange.x;
  1036. newValue = mRound(newValue / row->mStepSize) * row->mStepSize;
  1037. row->mValue = newValue;
  1038. }
  1039. }
  1040. }
  1041. void GuiGameListMenuCtrl::clickKeybind(Row* row, S32 xPos)
  1042. {
  1043. GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
  1044. F32 xScale = (float)getWidth() / profile->getRowWidth();
  1045. S32 columnSplit = profile->mColumnSplit * xScale;
  1046. S32 rowHeight = profile->getRowHeight();
  1047. S32 optionWidth = xScale - columnSplit;
  1048. GFXDrawUtil* drawer = GFX->getDrawUtil();
  1049. //drawer->drawBitmap(row->mBitmap, )
  1050. Point2I button;
  1051. button.x = columnSplit + (columnSplit / 2)/* + (optionWidth / 2)*/;
  1052. button.y = rowHeight / 4;
  1053. Point2I buttonSize;
  1054. buttonSize.x = rowHeight / 2;
  1055. buttonSize.y = rowHeight / 2;
  1056. GFXTextureObject* texture = row->mBitmapTex;
  1057. RectI rect(button, buttonSize);
  1058. if (rect.pointInRect(Point2I(xPos, rowHeight / 2)))
  1059. {
  1060. if (row->mScriptCallback != StringTable->EmptyString())
  1061. {
  1062. S32 rowId = getSelected();
  1063. Con::executef(row->mScriptCallback, rowId);
  1064. }
  1065. }
  1066. }
  1067. F32 GuiGameListMenuCtrl::getValue(S32 rowIndex)
  1068. {
  1069. if (!isValidRowIndex(rowIndex))
  1070. {
  1071. return 0;
  1072. }
  1073. Row* row = (Row*)mRows[rowIndex];
  1074. return row->mValue;
  1075. }
  1076. void GuiGameListMenuCtrl::setValue(S32 rowIndex, F32 value)
  1077. {
  1078. if (!isValidRowIndex(rowIndex))
  1079. {
  1080. return;
  1081. }
  1082. Row* row = (Row*)mRows[rowIndex];
  1083. row->mValue = value;
  1084. }
  1085. const char* GuiGameListMenuCtrl::getTooltip(S32 rowIndex)
  1086. {
  1087. if (!isValidRowIndex(rowIndex))
  1088. {
  1089. return "";
  1090. }
  1091. Row* row = (Row*)mRows[rowIndex];
  1092. return row->mTooltip;
  1093. }
  1094. ConsoleDocClass( GuiGameListMenuCtrl,
  1095. "@brief A base class for cross platform menu controls that are gamepad friendly.\n\n"
  1096. "This class is used to build row-based menu GUIs that can be easily navigated "
  1097. "using the keyboard, mouse or gamepad. The desired row can be selected using "
  1098. "the mouse, or by navigating using the Up and Down buttons.\n\n"
  1099. "@tsexample\n\n"
  1100. "new GuiGameListMenuCtrl()\n"
  1101. "{\n"
  1102. " debugRender = \"0\";\n"
  1103. " callbackOnA = \"applyOptions();\";\n"
  1104. " callbackOnB = \"Canvas.setContent(MainMenuGui);\";\n"
  1105. " callbackOnX = \"\";\n"
  1106. " callbackOnY = \"revertOptions();\";\n"
  1107. " //Properties not specific to this control have been omitted from this example.\n"
  1108. "};\n"
  1109. "@endtsexample\n\n"
  1110. "@see GuiGameListMenuProfile\n\n"
  1111. "@ingroup GuiGame"
  1112. );
  1113. IMPLEMENT_CALLBACK( GuiGameListMenuCtrl, onChange, void, (), (),
  1114. "Called when the selected row changes." );
  1115. IMPLEMENT_CALLBACK(GuiGameListMenuCtrl, onInputEvent, void, (const char* device, const char* action, bool state),
  1116. (device, action, state),
  1117. "@brief Callback that occurs when an input is triggered on this control\n\n"
  1118. "@param device The device type triggering the input, such as keyboard, mouse, etc\n"
  1119. "@param action The actual event occuring, such as a key or button\n"
  1120. "@param state True if the action is being pressed, false if it is being release\n\n");
  1121. IMPLEMENT_CALLBACK(GuiGameListMenuCtrl, onAxisEvent, void, (const char* device, const char* action, F32 axisValue),
  1122. (device, action, axisValue),
  1123. "@brief Callback that occurs when an axis event is triggered on this control\n\n"
  1124. "@param device The device type triggering the input, such as mouse, joystick, gamepad, etc\n"
  1125. "@param action The ActionMap code for the axis\n"
  1126. "@param axisValue The current value of the axis\n\n");
  1127. void GuiGameListMenuCtrl::initPersistFields()
  1128. {
  1129. addField("debugRender", TypeBool, Offset(mDebugRender, GuiGameListMenuCtrl),
  1130. "Enable debug rendering" );
  1131. addField("callbackOnA", TypeString, Offset(mCallbackOnA, GuiGameListMenuCtrl),
  1132. "Script callback when the 'A' button is pressed. 'A' inputs are Keyboard: A, Return, Space; Gamepad: A, Start" );
  1133. addField("callbackOnB", TypeString, Offset(mCallbackOnB, GuiGameListMenuCtrl),
  1134. "Script callback when the 'B' button is pressed. 'B' inputs are Keyboard: B, Esc, Backspace, Delete; Gamepad: B, Back" );
  1135. addField("callbackOnX", TypeString, Offset(mCallbackOnX, GuiGameListMenuCtrl),
  1136. "Script callback when the 'X' button is pressed. 'X' inputs are Keyboard: X; Gamepad: X" );
  1137. addField("callbackOnY", TypeString, Offset(mCallbackOnY, GuiGameListMenuCtrl),
  1138. "Script callback when the 'Y' button is pressed. 'Y' inputs are Keyboard: Y; Gamepad: Y" );
  1139. addField("callbackOnInputs", TypeBool, Offset(mCallbackOnInputs, GuiGameListMenuCtrl),
  1140. "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.");
  1141. Parent::initPersistFields();
  1142. }
  1143. DefineEngineMethod( GuiGameListMenuCtrl, addRow, void,
  1144. ( const char* label, const char* callback, S32 icon, S32 yPad, bool useHighlightIcon, bool enabled, int mode ),
  1145. ( -1, 0, true, true, 0 ),
  1146. "Add a row to the list control.\n\n"
  1147. "@param label The text to display on the row as a label.\n"
  1148. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1149. "@param icon [optional] Index of the icon to use as a marker.\n"
  1150. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1151. "@param useHighlightIcon [optional] Does this row use the highlight icon?.\n"
  1152. "@param enabled [optional] If this row is initially enabled.\n"
  1153. "@param mode [optional] What option mode the row is in. 0 = Default, 1 = OptionList, 2 == Keybind")
  1154. {
  1155. object->addRow( label, callback, icon, yPad, useHighlightIcon, enabled, mode);
  1156. }
  1157. DefineEngineMethod( GuiGameListMenuCtrl, isRowEnabled, bool, ( S32 row ),,
  1158. "Determines if the specified row is enabled or disabled.\n\n"
  1159. "@param row The row to set the enabled status of.\n"
  1160. "@return True if the specified row is enabled. False if the row is not enabled or the given index was not valid." )
  1161. {
  1162. return object->isRowEnabled( row );
  1163. }
  1164. DefineEngineMethod( GuiGameListMenuCtrl, setRowEnabled, void, ( S32 row, bool enabled ),,
  1165. "Sets a row's enabled status according to the given parameters.\n\n"
  1166. "@param row The index to check for validity.\n"
  1167. "@param enabled Indicate true to enable the row or false to disable it." )
  1168. {
  1169. object->setRowEnabled( row, enabled );
  1170. }
  1171. DefineEngineMethod( GuiGameListMenuCtrl, activateRow, void, (),,
  1172. "Activates the current row. The script callback of the current row will be called (if it has one)." )
  1173. {
  1174. object->activateRow();
  1175. }
  1176. DefineEngineMethod( GuiGameListMenuCtrl, getRowCount, S32, (),,
  1177. "Gets the number of rows on the control.\n\n"
  1178. "@return (int) The number of rows on the control." )
  1179. {
  1180. return object->getRowCount();
  1181. }
  1182. DefineEngineMethod( GuiGameListMenuCtrl, getRowLabel, const char *, ( S32 row ),,
  1183. "Gets the label displayed on the specified row.\n\n"
  1184. "@param row Index of the row to get the label of.\n"
  1185. "@return The label for the row." )
  1186. {
  1187. return object->getRowLabel( row );
  1188. }
  1189. DefineEngineMethod( GuiGameListMenuCtrl, setRowLabel, void, ( S32 row, const char* label ),,
  1190. "Sets the label on the given row.\n\n"
  1191. "@param row Index of the row to set the label on.\n"
  1192. "@param label Text to set as the label of the row.\n" )
  1193. {
  1194. object->setRowLabel( row, label );
  1195. }
  1196. DefineEngineMethod( GuiGameListMenuCtrl, setSelected, void, ( S32 row ),,
  1197. "Sets the selected row. Only rows that are enabled can be selected.\n\n"
  1198. "@param row Index of the row to set as selected." )
  1199. {
  1200. object->setSelected( row );
  1201. }
  1202. DefineEngineMethod( GuiGameListMenuCtrl, getSelectedRow, S32, (),,
  1203. "Gets the index of the currently selected row.\n\n"
  1204. "@return Index of the selected row." )
  1205. {
  1206. return object->getSelected();
  1207. }
  1208. DefineEngineMethod(GuiGameListMenuCtrl, clearRows, void, (), ,
  1209. "Gets the index of the currently selected row.\n\n"
  1210. "@return Index of the selected row.")
  1211. {
  1212. return object->clearRows();
  1213. }
  1214. DefineEngineMethod(GuiGameListMenuCtrl, refresh, void, (), ,
  1215. "Gets the index of the currently selected row.\n\n"
  1216. "@return Index of the selected row.")
  1217. {
  1218. return object->refresh();
  1219. }
  1220. DefineEngineMethod(GuiGameListMenuCtrl, addOptionRow, void,
  1221. (const char* label, const char* options, bool wrapOptions, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip, const char* defaultValue),
  1222. (-1, 0, true, "", ""),
  1223. "Add a row to the list control.\n\n"
  1224. "@param label The text to display on the row as a label.\n"
  1225. "@param options A tab separated list of options.\n"
  1226. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1227. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1228. "@param icon [optional] Index of the icon to use as a marker.\n"
  1229. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1230. "@param enabled [optional] If this row is initially enabled.")
  1231. {
  1232. object->addRow(label, options, wrapOptions, callback, icon, yPad, enabled, tooltip, defaultValue);
  1233. }
  1234. DefineEngineMethod(GuiGameListMenuCtrl, addSliderRow, void,
  1235. (const char* label, F32 defaultValue, F32 increment, Point2F range, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip),
  1236. (-1, 0, true, ""),
  1237. "Add a row to the list control.\n\n"
  1238. "@param label The text to display on the row as a label.\n"
  1239. "@param options A tab separated list of options.\n"
  1240. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1241. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1242. "@param icon [optional] Index of the icon to use as a marker.\n"
  1243. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1244. "@param enabled [optional] If this row is initially enabled.")
  1245. {
  1246. object->addRow(label, defaultValue, increment, range, callback, icon, yPad, enabled, tooltip);
  1247. }
  1248. DefineEngineMethod(GuiGameListMenuCtrl, addKeybindRow, void,
  1249. (const char* label, const char* bitmapName, const char* callback, S32 icon, S32 yPad, bool enabled, const char* tooltip),
  1250. (-1, 0, true, ""),
  1251. "Add a row to the list control.\n\n"
  1252. "@param label The text to display on the row as a label.\n"
  1253. "@param options A tab separated list of options.\n"
  1254. "@param wrapOptions Specify true to allow options to wrap at each end or false to prevent wrapping.\n"
  1255. "@param callback Name of a script function to use as a callback when this row is activated.\n"
  1256. "@param icon [optional] Index of the icon to use as a marker.\n"
  1257. "@param yPad [optional] An extra amount of height padding before the row. Does nothing on the first row.\n"
  1258. "@param enabled [optional] If this row is initially enabled.")
  1259. {
  1260. object->addRow(label, bitmapName, callback, icon, yPad, enabled, tooltip);
  1261. }
  1262. DefineEngineMethod(GuiGameListMenuCtrl, getCurrentOption, const char*, (S32 row), ,
  1263. "Gets the text for the currently selected option of the given row.\n\n"
  1264. "@param row Index of the row to get the option from.\n"
  1265. "@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.")
  1266. {
  1267. return object->getCurrentOption(row);
  1268. }
  1269. DefineEngineMethod(GuiGameListMenuCtrl, selectOption, bool, (S32 row, const char* option), ,
  1270. "Set the row's current option to the one specified\n\n"
  1271. "@param row Index of the row to set an option on.\n"
  1272. "@param option The option to be made active.\n"
  1273. "@return True if the row contained the option and was set, false otherwise.")
  1274. {
  1275. return object->selectOption(row, option);
  1276. }
  1277. DefineEngineMethod(GuiGameListMenuCtrl, setOptions, void, (S32 row, const char* optionsList), ,
  1278. "Sets the list of options on the given row.\n\n"
  1279. "@param row Index of the row to set options on."
  1280. "@param optionsList A tab separated list of options for the control.")
  1281. {
  1282. object->setOptions(row, optionsList);
  1283. }
  1284. DefineEngineMethod(GuiGameListMenuCtrl, getValue, F32, (S32 row), ,
  1285. "Sets the list of options on the given row.\n\n"
  1286. "@param row Index of the row to set options on."
  1287. "@param optionsList A tab separated list of options for the control.")
  1288. {
  1289. return object->getValue(row);
  1290. }
  1291. DefineEngineMethod(GuiGameListMenuCtrl, setValue, void, (S32 row, F32 value), ,
  1292. "Sets the list of options on the given row.\n\n"
  1293. "@param row Index of the row to set options on."
  1294. "@param optionsList A tab separated list of options for the control.")
  1295. {
  1296. object->setValue(row, value);
  1297. }
  1298. DefineEngineMethod(GuiGameListMenuCtrl, getTooltip, const char*, (S32 row), ,
  1299. "Sets the list of options on the given row.\n\n"
  1300. "@param row Index of the row to set options on."
  1301. "@param optionsList A tab separated list of options for the control.")
  1302. {
  1303. return object->getTooltip(row);
  1304. }
  1305. //-----------------------------------------------------------------------------
  1306. // GuiGameListMenuProfile
  1307. //-----------------------------------------------------------------------------
  1308. GuiGameListMenuProfile::GuiGameListMenuProfile()
  1309. : mHitAreaUpperLeft(0, 0),
  1310. mHitAreaLowerRight(0, 0),
  1311. mIconOffset(0, 0),
  1312. mRowSize(0, 0),
  1313. mRowScale(1.0f, 1.0f),
  1314. mColumnSplit(0),
  1315. mRightPad(0)
  1316. {
  1317. }
  1318. bool GuiGameListMenuProfile::onAdd()
  1319. {
  1320. if (! Parent::onAdd())
  1321. {
  1322. return false;
  1323. }
  1324. // We can't call enforceConstraints() here because incRefCount initializes
  1325. // some of the things to enforce. Do a basic sanity check here instead.
  1326. if( !mBitmapName || !dStrlen(mBitmapName) )
  1327. {
  1328. Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
  1329. return false;
  1330. }
  1331. if( mRowSize.x < 0 )
  1332. {
  1333. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row width. Please change the row width to be non-negative.", getName() );
  1334. return false;
  1335. }
  1336. if( mRowSize.y < 0 )
  1337. {
  1338. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row height. Please change the row height to be non-negative.", getName() );
  1339. return false;
  1340. }
  1341. return true;
  1342. }
  1343. void GuiGameListMenuProfile::enforceConstraints()
  1344. {
  1345. if( getBitmapArrayRect(0).extent.isZero() )
  1346. Con::errorf( "GuiGameListMenuCtrl: %s can't be created without a bitmap. Please add a bitmap to the profile's definition.", getName() );
  1347. if( mRowSize.x < 0 )
  1348. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row width. Please change the row width to be non-negative.", getName() );
  1349. mRowSize.x = getMax(mRowSize.x, 0);
  1350. if( mRowSize.y < 0 )
  1351. Con::errorf( "GuiGameListMenuProfile: %s can't have a negative row height. Please change the row height to be non-negative.", getName() );
  1352. mRowSize.y = getMax(mRowSize.y, 0);
  1353. Point2I rowTexExtent = getBitmapArrayRect(TEX_NORMAL).extent;
  1354. mRowScale.x = (float) getRowWidth() / rowTexExtent.x;
  1355. mRowScale.y = (float) getRowHeight() / rowTexExtent.y;
  1356. if (mHitAreaUpperLeft.x > mColumnSplit || mColumnSplit > mHitAreaLowerRight.x)
  1357. 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].",
  1358. getName(), mColumnSplit, mHitAreaUpperLeft.x, mHitAreaLowerRight.x);
  1359. mColumnSplit = mClamp(mColumnSplit, mHitAreaUpperLeft.x, mHitAreaLowerRight.x);
  1360. }
  1361. Point2I GuiGameListMenuProfile::getIconExtent()
  1362. {
  1363. Point2I iconExtent = getBitmapArrayRect(TEX_FIRST_ICON).extent;
  1364. // scale both by y to keep the aspect ratio
  1365. iconExtent.x *= mRowScale.y;
  1366. iconExtent.y *= mRowScale.y;
  1367. return iconExtent;
  1368. }
  1369. Point2I GuiGameListMenuProfile::getArrowExtent()
  1370. {
  1371. Point2I arrowExtent = getBitmapArrayRect(TEX_FIRST_ARROW).extent;
  1372. // scale both by y to keep the aspect ratio
  1373. arrowExtent.x *= mRowScale.y;
  1374. arrowExtent.y *= mRowScale.y;
  1375. return arrowExtent;
  1376. }
  1377. Point2I GuiGameListMenuProfile::getHitAreaExtent()
  1378. {
  1379. if (mHitAreaLowerRight == mHitAreaUpperLeft)
  1380. {
  1381. return mRowSize;
  1382. }
  1383. else
  1384. {
  1385. return mHitAreaLowerRight - mHitAreaUpperLeft;
  1386. }
  1387. }
  1388. //-----------------------------------------------------------------------------
  1389. // Console stuff (GuiGameListMenuProfile)
  1390. //-----------------------------------------------------------------------------
  1391. IMPLEMENT_CONOBJECT(GuiGameListMenuProfile);
  1392. ConsoleDocClass( GuiGameListMenuProfile,
  1393. "@brief A GuiControlProfile with additional fields specific to GuiGameListMenuCtrl.\n\n"
  1394. "@tsexample\n"
  1395. "new GuiGameListMenuProfile()\n"
  1396. "{\n"
  1397. " hitAreaUpperLeft = \"10 2\";\n"
  1398. " hitAreaLowerRight = \"190 18\";\n"
  1399. " iconOffset = \"10 2\";\n"
  1400. " rowSize = \"200 20\";\n"
  1401. " columnSplit = \"100\";\n"
  1402. " rightPad = \"4\";\n"
  1403. " //Properties not specific to this control have been omitted from this example.\n"
  1404. "};\n"
  1405. "@endtsexample\n\n"
  1406. "@ingroup GuiGame"
  1407. );
  1408. void GuiGameListMenuProfile::initPersistFields()
  1409. {
  1410. addField( "hitAreaUpperLeft", TypePoint2I, Offset(mHitAreaUpperLeft, GuiGameListMenuProfile),
  1411. "Position of the upper left corner of the row hit area (relative to row's top left corner)" );
  1412. addField( "hitAreaLowerRight", TypePoint2I, Offset(mHitAreaLowerRight, GuiGameListMenuProfile),
  1413. "Position of the lower right corner of the row hit area (relative to row's top left corner)" );
  1414. addField( "iconOffset", TypePoint2I, Offset(mIconOffset, GuiGameListMenuProfile),
  1415. "Offset from the row's top left corner at which to render the row icon" );
  1416. addField( "rowSize", TypePoint2I, Offset(mRowSize, GuiGameListMenuProfile),
  1417. "The base size (\"width height\") of a row" );
  1418. addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListMenuProfile),
  1419. "Padding between the leftmost edge of the control, and the row's left arrow.");
  1420. addField("rightPad", TypeS32, Offset(mRightPad, GuiGameListMenuProfile),
  1421. "Padding between the rightmost edge of the control and the row's right arrow.");
  1422. Parent::initPersistFields();
  1423. removeField("tab");
  1424. removeField("mouseOverSelected");
  1425. removeField("modal");
  1426. removeField("opaque");
  1427. removeField("border");
  1428. removeField("borderThickness");
  1429. removeField("borderColor");
  1430. removeField("borderColorHL");
  1431. removeField("borderColorNA");
  1432. removeField("bevelColorHL");
  1433. removeField("bevelColorLL");
  1434. removeField("fontColorLink");
  1435. removeField("fontColorLinkHL");
  1436. removeField("justify");
  1437. removeField("returnTab");
  1438. removeField("numbersOnly");
  1439. removeField("cursorColor");
  1440. removeField("profileForChildren");
  1441. }