BsBuiltinResources.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. #include "BsBuiltinResources.h"
  2. #include "BsGUIElementStyle.h"
  3. #include "BsGUILabel.h"
  4. #include "BsGUIButton.h"
  5. #include "BsGUIInputBox.h"
  6. #include "BsGUIToggle.h"
  7. #include "BsTextSprite.h"
  8. #include "BsSpriteTexture.h"
  9. #include "CmFont.h"
  10. #include "CmFontImportOptions.h"
  11. #include "CmImporter.h"
  12. #include "CmRTTIType.h"
  13. #include "CmFileSystem.h"
  14. #include "CmApplication.h"
  15. using namespace CamelotFramework;
  16. namespace BansheeEngine
  17. {
  18. const WString BuiltinResources::DefaultFontPath = L"arial.ttf";
  19. const UINT32 BuiltinResources::DefaultFontSize = 10;
  20. const WString BuiltinResources::DefaultSkinFolder = L"..\\..\\..\\..\\Data\\Engine\\Skin\\";
  21. const WString BuiltinResources::DefaultCursorFolder = L"..\\..\\..\\..\\Data\\Engine\\Cursors\\";
  22. const WString BuiltinResources::WhiteTex = L"White.psd";
  23. const WString BuiltinResources::ButtonNormalTex = L"ButtonNormal.psd";
  24. const WString BuiltinResources::ButtonHoverTex = L"ButtonHover.psd";
  25. const WString BuiltinResources::ToggleNormalTex = L"ToggleNormal.psd";
  26. const WString BuiltinResources::ToggleHoverTex = L"ToggleHover.psd";
  27. const WString BuiltinResources::ToggleActiveTex = L"ToggleActive.psd";
  28. const WString BuiltinResources::ToggleNormalOnTex = L"ToggleOnNormal.psd";
  29. const WString BuiltinResources::ToggleHoverOnTex = L"ToggleOnHover.psd";
  30. const WString BuiltinResources::ToggleActiveOnTex = L"ToggleOnActive.psd";
  31. const WString BuiltinResources::InputBoxNormalTex = L"InputBoxNormal.psd";
  32. const WString BuiltinResources::InputBoxHoverTex = L"InputBoxHover.psd";
  33. const WString BuiltinResources::InputBoxFocusedTex = L"InputBoxFocused.psd";
  34. const WString BuiltinResources::ScrollBarUpNormalTex = L"ScrollBarUpNormal.psd";
  35. const WString BuiltinResources::ScrollBarUpHoverTex = L"ScrollBarUpHover.psd";
  36. const WString BuiltinResources::ScrollBarUpActiveTex = L"ScrollBarUpActive.psd";
  37. const WString BuiltinResources::ScrollBarDownNormalTex = L"ScrollBarDownNormal.psd";
  38. const WString BuiltinResources::ScrollBarDownHoverTex = L"ScrollBarDownHover.psd";
  39. const WString BuiltinResources::ScrollBarDownActiveTex = L"ScrollBarDownActive.psd";
  40. const WString BuiltinResources::ScrollBarLeftNormalTex = L"ScrollBarLeftNormal.psd";
  41. const WString BuiltinResources::ScrollBarLeftHoverTex = L"ScrollBarLeftHover.psd";
  42. const WString BuiltinResources::ScrollBarLeftActiveTex = L"ScrollBarLeftActive.psd";
  43. const WString BuiltinResources::ScrollBarRightNormalTex = L"ScrollBarRightNormal.psd";
  44. const WString BuiltinResources::ScrollBarRightHoverTex = L"ScrollBarRightHover.psd";
  45. const WString BuiltinResources::ScrollBarRightActiveTex = L"ScrollBarRightActive.psd";
  46. const WString BuiltinResources::ScrollBarHandleHorzNormalTex = L"ScrollBarHorzHandleNormal.psd";
  47. const WString BuiltinResources::ScrollBarHandleHorzHoverTex = L"ScrollBarHorzHandleHover.psd";
  48. const WString BuiltinResources::ScrollBarHandleHorzActiveTex = L"ScrollBarHorzHandleActive.psd";
  49. const WString BuiltinResources::ScrollBarHandleVertNormalTex = L"ScrollBarVertHandleNormal.psd";
  50. const WString BuiltinResources::ScrollBarHandleVertHoverTex = L"ScrollBarVertHandleHover.psd";
  51. const WString BuiltinResources::ScrollBarHandleVertActiveTex = L"ScrollBarVertHandleActive.psd";
  52. const WString BuiltinResources::DropDownBtnNormalTex = L"DropDownNormal.psd";
  53. const WString BuiltinResources::DropDownBtnHoverTex = L"DropDownHover.psd";
  54. const WString BuiltinResources::DropDownBoxBgTex = L"DropDownBoxBg.psd";
  55. const WString BuiltinResources::DropDownBoxEntryNormalTex = L"DropDownButtonNormal.psd";
  56. const WString BuiltinResources::DropDownBoxEntryHoverTex = L"DropDownButtonHover.psd";
  57. const WString BuiltinResources::DropDownBoxBtnUpNormalTex = L"DropDownBoxBtnUpNormal.psd";
  58. const WString BuiltinResources::DropDownBoxBtnUpHoverTex = L"DropDownBoxBtnUpHover.psd";
  59. const WString BuiltinResources::DropDownBoxBtnDownNormalTex = L"DropDownBoxBtnDownNormal.psd";
  60. const WString BuiltinResources::DropDownBoxBtnDownHoverTex = L"DropDownBoxBtnDownHover.psd";
  61. const WString BuiltinResources::DropDownBoxEntryExpNormalTex = L"DropDownExpNormal.psd";
  62. const WString BuiltinResources::DropDownBoxEntryExpHoverTex = L"DropDownExpHover.psd";
  63. const WString BuiltinResources::DropDownSeparatorTex = L"DropDownSeparator.psd";
  64. const WString BuiltinResources::DropDownBoxBtnUpArrowTex = L"DropDownBoxBtnUpArrow.psd";
  65. const WString BuiltinResources::DropDownBoxBtnDownArrowTex = L"DropDownBoxBtnDownArrow.psd";
  66. const WString BuiltinResources::ScrollBarBgTex = L"ScrollBarBg.psd";
  67. const WString BuiltinResources::CursorArrowTex = L"Arrow.psd";
  68. const WString BuiltinResources::CursorArrowDragTex = L"ArrowDrag.psd";
  69. const WString BuiltinResources::CursorArrowLeftRightTex = L"ArrowLeftRight.psd";
  70. const WString BuiltinResources::CursorIBeamTex = L"IBeam.psd";
  71. const WString BuiltinResources::CursorDenyTex = L"Deny.psd";
  72. const WString BuiltinResources::CursorWaitTex = L"Wait.psd";
  73. const WString BuiltinResources::CursorSizeNESWTex = L"SizeNESW.psd";
  74. const WString BuiltinResources::CursorSizeNSTex = L"SizeNS.psd";
  75. const WString BuiltinResources::CursorSizeNWSETex = L"SizeNWSE.psd";
  76. const WString BuiltinResources::CursorSizeWETex = L"SizeWE.psd";
  77. const Vector2I BuiltinResources::CursorArrowHotspot = Vector2I(11, 8);
  78. const Vector2I BuiltinResources::CursorArrowDragHotspot = Vector2I(11, 8);
  79. const Vector2I BuiltinResources::CursorArrowLeftRightHotspot = Vector2I(9, 4);
  80. const Vector2I BuiltinResources::CursorIBeamHotspot = Vector2I(15, 15);
  81. const Vector2I BuiltinResources::CursorDenyHotspot = Vector2I(15, 15);
  82. const Vector2I BuiltinResources::CursorWaitHotspot = Vector2I(15, 15);
  83. const Vector2I BuiltinResources::CursorSizeNESWHotspot = Vector2I(15, 15);
  84. const Vector2I BuiltinResources::CursorSizeNSHotspot = Vector2I(15, 15);
  85. const Vector2I BuiltinResources::CursorSizeNWSEHotspot = Vector2I(15, 15);
  86. const Vector2I BuiltinResources::CursorSizeWEHotspot = Vector2I(15, 15);
  87. BuiltinResources::BuiltinResources()
  88. {
  89. // TODO - Normally I want to load this from some file
  90. mWhiteSpriteTexture = getSkinTexture(WhiteTex);
  91. /************************************************************************/
  92. /* CURSOR */
  93. /************************************************************************/
  94. HTexture cursorArrowTex = getCursorTexture(CursorArrowTex);
  95. HTexture cursorArrowDragTex = getCursorTexture(CursorArrowDragTex);
  96. HTexture cursorArrowLeftRightTex = getCursorTexture(CursorArrowLeftRightTex);
  97. HTexture cursorIBeamTex = getCursorTexture(CursorIBeamTex);
  98. HTexture cursorDenyTex = getCursorTexture(CursorDenyTex);
  99. HTexture cursorWaitTex = getCursorTexture(CursorWaitTex);
  100. HTexture cursorSizeNESWTex = getCursorTexture(CursorSizeNESWTex);
  101. HTexture cursorSizeNSTex = getCursorTexture(CursorSizeNSTex);
  102. HTexture cursorSizeNWSETex = getCursorTexture(CursorSizeNWSETex);
  103. HTexture cursorSizeWETex = getCursorTexture(CursorSizeWETex);
  104. mCursorArrow = cursorArrowTex->allocateSubresourceBuffer(0);
  105. gCoreAccessor().readSubresource(cursorArrowTex.getInternalPtr(), 0, mCursorArrow);
  106. mCursorArrowDrag = cursorArrowDragTex->allocateSubresourceBuffer(0);
  107. gCoreAccessor().readSubresource(cursorArrowDragTex.getInternalPtr(), 0, mCursorArrowDrag);
  108. mCursorArrowLeftRight = cursorArrowLeftRightTex->allocateSubresourceBuffer(0);
  109. gCoreAccessor().readSubresource(cursorArrowLeftRightTex.getInternalPtr(), 0, mCursorArrowLeftRight);
  110. mCursorIBeam = cursorIBeamTex->allocateSubresourceBuffer(0);
  111. gCoreAccessor().readSubresource(cursorIBeamTex.getInternalPtr(), 0, mCursorIBeam);
  112. mCursorDeny = cursorDenyTex->allocateSubresourceBuffer(0);
  113. gCoreAccessor().readSubresource(cursorDenyTex.getInternalPtr(), 0, mCursorDeny);
  114. mCursorWait = cursorWaitTex->allocateSubresourceBuffer(0);
  115. gCoreAccessor().readSubresource(cursorWaitTex.getInternalPtr(), 0, mCursorWait);
  116. mCursorSizeNESW = cursorSizeNESWTex->allocateSubresourceBuffer(0);
  117. gCoreAccessor().readSubresource(cursorSizeNESWTex.getInternalPtr(), 0, mCursorSizeNESW);
  118. mCursorSizeNS = cursorSizeNSTex->allocateSubresourceBuffer(0);
  119. gCoreAccessor().readSubresource(cursorSizeNSTex.getInternalPtr(), 0, mCursorSizeNS);
  120. mCursorSizeNWSE = cursorSizeNWSETex->allocateSubresourceBuffer(0);
  121. gCoreAccessor().readSubresource(cursorSizeNWSETex.getInternalPtr(), 0, mCursorSizeNWSE);
  122. mCursorSizeWE = cursorSizeWETex->allocateSubresourceBuffer(0);
  123. gCoreAccessor().readSubresource(cursorSizeWETex.getInternalPtr(), 0, mCursorSizeWE);
  124. gCoreAccessor().submitToCoreThread(true);
  125. // Label
  126. // TODO - Instead of importing font every time, try to save a resource and then just load it?
  127. HFont font;
  128. {
  129. WString fontPath = DefaultSkinFolder + DefaultFontPath;
  130. ImportOptionsPtr fontImportOptions = Importer::instance().createImportOptions(fontPath);
  131. if(rtti_is_of_type<FontImportOptions>(fontImportOptions))
  132. {
  133. FontImportOptions* importOptions = static_cast<FontImportOptions*>(fontImportOptions.get());
  134. Vector<CamelotFramework::UINT32>::type fontSizes;
  135. fontSizes.push_back(DefaultFontSize);
  136. importOptions->setFontSizes(fontSizes);
  137. importOptions->setAntialiasing(false);
  138. }
  139. font = Importer::instance().import(fontPath, fontImportOptions);
  140. }
  141. GUIElementStyle labelStyle;
  142. labelStyle.font = font;
  143. labelStyle.fontSize = DefaultFontSize;
  144. labelStyle.fixedWidth = false;
  145. labelStyle.fixedHeight = true;
  146. labelStyle.height = 16;
  147. labelStyle.minWidth = 10;
  148. mSkin.setStyle(GUILabel::getGUITypeName(), labelStyle);
  149. // Button
  150. GUIElementStyle buttonStyle;
  151. buttonStyle.normal.texture = getSkinTexture(ButtonNormalTex);
  152. buttonStyle.hover.texture = getSkinTexture(ButtonHoverTex);
  153. buttonStyle.active.texture = buttonStyle.hover.texture;
  154. buttonStyle.border.left = 5;
  155. buttonStyle.border.right = 5;
  156. buttonStyle.border.top = 5;
  157. buttonStyle.border.bottom = 5;
  158. buttonStyle.margins.left = 4;
  159. buttonStyle.margins.right = 4;
  160. buttonStyle.margins.top = 4;
  161. buttonStyle.margins.bottom = 4;
  162. buttonStyle.contentOffset.left = 2;
  163. buttonStyle.contentOffset.right = 2;
  164. buttonStyle.fixedHeight = true;
  165. buttonStyle.height = 21;
  166. buttonStyle.minWidth = 50;
  167. buttonStyle.font = font;
  168. buttonStyle.fontSize = DefaultFontSize;
  169. buttonStyle.textHorzAlign = THA_Center;
  170. buttonStyle.textVertAlign = TVA_Center;
  171. mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
  172. // Toggle
  173. GUIElementStyle toggleStyle;
  174. toggleStyle.normal.texture = getSkinTexture(ToggleNormalTex);
  175. toggleStyle.hover.texture = getSkinTexture(ToggleHoverTex);
  176. toggleStyle.active.texture = getSkinTexture(ToggleActiveTex);
  177. toggleStyle.normalOn.texture = getSkinTexture(ToggleNormalOnTex);
  178. toggleStyle.hoverOn.texture = getSkinTexture(ToggleHoverOnTex);
  179. toggleStyle.activeOn.texture = getSkinTexture(ToggleActiveOnTex);
  180. toggleStyle.fixedHeight = true;
  181. toggleStyle.fixedWidth = true;
  182. toggleStyle.height = 15;
  183. toggleStyle.width = 15;
  184. mSkin.setStyle(GUIToggle::getGUITypeName(), toggleStyle);
  185. // Input box
  186. GUIElementStyle inputBoxStyle;
  187. inputBoxStyle.normal.texture = getSkinTexture(InputBoxNormalTex);
  188. inputBoxStyle.hover.texture = getSkinTexture(InputBoxHoverTex);
  189. inputBoxStyle.focused.texture = getSkinTexture(InputBoxFocusedTex);
  190. inputBoxStyle.active.texture = inputBoxStyle.normal.texture;
  191. inputBoxStyle.border.left = 5;
  192. inputBoxStyle.border.right = 5;
  193. inputBoxStyle.border.top = 5;
  194. inputBoxStyle.border.bottom = 5;
  195. inputBoxStyle.margins.left = 4;
  196. inputBoxStyle.margins.right = 4;
  197. inputBoxStyle.margins.top = 4;
  198. inputBoxStyle.margins.bottom = 4;
  199. inputBoxStyle.contentOffset.left = 2;
  200. inputBoxStyle.contentOffset.right = 2;
  201. inputBoxStyle.fixedHeight = true;
  202. inputBoxStyle.height = 21;
  203. inputBoxStyle.minWidth = 10;
  204. inputBoxStyle.font = font;
  205. inputBoxStyle.fontSize = DefaultFontSize;
  206. inputBoxStyle.textHorzAlign = THA_Left;
  207. inputBoxStyle.textVertAlign = TVA_Top;
  208. mSkin.setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
  209. /************************************************************************/
  210. /* SCROLL BAR */
  211. /************************************************************************/
  212. // Up button
  213. GUIElementStyle scrollUpBtnStyle;
  214. scrollUpBtnStyle.normal.texture = getSkinTexture(ScrollBarUpNormalTex);
  215. scrollUpBtnStyle.hover.texture = getSkinTexture(ScrollBarUpHoverTex);
  216. scrollUpBtnStyle.active.texture = getSkinTexture(ScrollBarUpActiveTex);
  217. scrollUpBtnStyle.fixedHeight = true;
  218. scrollUpBtnStyle.fixedWidth = true;
  219. scrollUpBtnStyle.height = 4;
  220. scrollUpBtnStyle.width = 8;
  221. mSkin.setStyle("ScrollUpBtn", scrollUpBtnStyle);
  222. // Down button
  223. GUIElementStyle scrollDownBtnStyle;
  224. scrollDownBtnStyle.normal.texture = getSkinTexture(ScrollBarDownNormalTex);
  225. scrollDownBtnStyle.hover.texture = getSkinTexture(ScrollBarDownHoverTex);
  226. scrollDownBtnStyle.active.texture = getSkinTexture(ScrollBarDownActiveTex);
  227. scrollDownBtnStyle.fixedHeight = true;
  228. scrollDownBtnStyle.fixedWidth = true;
  229. scrollDownBtnStyle.height = 4;
  230. scrollDownBtnStyle.width = 8;
  231. mSkin.setStyle("ScrollDownBtn", scrollDownBtnStyle);
  232. // Left button
  233. GUIElementStyle scrollLeftBtnStyle;
  234. scrollLeftBtnStyle.normal.texture = getSkinTexture(ScrollBarLeftNormalTex);
  235. scrollLeftBtnStyle.hover.texture = getSkinTexture(ScrollBarLeftHoverTex);
  236. scrollLeftBtnStyle.active.texture = getSkinTexture(ScrollBarLeftActiveTex);
  237. scrollLeftBtnStyle.fixedHeight = true;
  238. scrollLeftBtnStyle.fixedWidth = true;
  239. scrollLeftBtnStyle.height = 8;
  240. scrollLeftBtnStyle.width = 4;
  241. mSkin.setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
  242. // Right button
  243. GUIElementStyle scrollRightBtnStyle;
  244. scrollRightBtnStyle.normal.texture = getSkinTexture(ScrollBarRightNormalTex);
  245. scrollRightBtnStyle.hover.texture = getSkinTexture(ScrollBarRightHoverTex);
  246. scrollRightBtnStyle.active.texture = getSkinTexture(ScrollBarRightActiveTex);
  247. scrollRightBtnStyle.fixedHeight = true;
  248. scrollRightBtnStyle.fixedWidth = true;
  249. scrollRightBtnStyle.height = 8;
  250. scrollRightBtnStyle.width = 4;
  251. mSkin.setStyle("ScrollRightBtn", scrollRightBtnStyle);
  252. // Horizontal handle
  253. GUIElementStyle scrollBarHorzBtnStyle;
  254. scrollBarHorzBtnStyle.normal.texture = getSkinTexture(ScrollBarHandleHorzNormalTex);
  255. scrollBarHorzBtnStyle.hover.texture = getSkinTexture(ScrollBarHandleHorzHoverTex);
  256. scrollBarHorzBtnStyle.active.texture = getSkinTexture(ScrollBarHandleHorzActiveTex);
  257. scrollBarHorzBtnStyle.fixedHeight = true;
  258. scrollBarHorzBtnStyle.fixedWidth = true;
  259. scrollBarHorzBtnStyle.height = 6;
  260. scrollBarHorzBtnStyle.width = 4;
  261. mSkin.setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
  262. // Vertical handle
  263. GUIElementStyle scrollBarVertBtnStyle;
  264. scrollBarVertBtnStyle.normal.texture = getSkinTexture(ScrollBarHandleVertNormalTex);
  265. scrollBarVertBtnStyle.hover.texture = getSkinTexture(ScrollBarHandleVertHoverTex);
  266. scrollBarVertBtnStyle.active.texture = getSkinTexture(ScrollBarHandleVertActiveTex);
  267. scrollBarVertBtnStyle.fixedHeight = true;
  268. scrollBarVertBtnStyle.fixedWidth = true;
  269. scrollBarVertBtnStyle.height = 4;
  270. scrollBarVertBtnStyle.width = 6;
  271. mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
  272. HSpriteTexture scrollBarBgPtr = getSkinTexture(ScrollBarBgTex);
  273. // Vertical scroll bar
  274. GUIElementStyle vertScrollBarStyle;
  275. vertScrollBarStyle.normal.texture = scrollBarBgPtr;
  276. vertScrollBarStyle.hover.texture = scrollBarBgPtr;
  277. vertScrollBarStyle.active.texture = scrollBarBgPtr;
  278. vertScrollBarStyle.fixedHeight = false;
  279. vertScrollBarStyle.fixedWidth = true;
  280. vertScrollBarStyle.minHeight = 16;
  281. vertScrollBarStyle.width = 8;
  282. mSkin.setStyle("ScrollBarVert", vertScrollBarStyle);
  283. // Horizontal scroll bar
  284. GUIElementStyle horzScrollBarStyle;
  285. horzScrollBarStyle.normal.texture = scrollBarBgPtr;
  286. horzScrollBarStyle.hover.texture = scrollBarBgPtr;
  287. horzScrollBarStyle.active.texture = scrollBarBgPtr;
  288. horzScrollBarStyle.fixedHeight = true;
  289. horzScrollBarStyle.fixedWidth = false;
  290. horzScrollBarStyle.minWidth = 16;
  291. horzScrollBarStyle.height = 8;
  292. mSkin.setStyle("ScrollBarHorz", horzScrollBarStyle);
  293. /************************************************************************/
  294. /* DROP DOWN BOX */
  295. /************************************************************************/
  296. // ListBox button
  297. GUIElementStyle dropDownListStyle;
  298. dropDownListStyle.normal.texture = getSkinTexture(DropDownBtnNormalTex);
  299. dropDownListStyle.hover.texture = getSkinTexture(DropDownBtnHoverTex);
  300. dropDownListStyle.active.texture = dropDownListStyle.hover.texture;
  301. dropDownListStyle.normalOn.texture = dropDownListStyle.hover.texture;
  302. dropDownListStyle.hoverOn.texture = dropDownListStyle.hover.texture;
  303. dropDownListStyle.activeOn.texture = dropDownListStyle.hover.texture;
  304. dropDownListStyle.fixedHeight = true;
  305. dropDownListStyle.fixedWidth = false;
  306. dropDownListStyle.height = 13;
  307. dropDownListStyle.width = 30;
  308. dropDownListStyle.contentOffset.left = 3;
  309. dropDownListStyle.contentOffset.right = 11;
  310. dropDownListStyle.contentOffset.top = 1;
  311. dropDownListStyle.contentOffset.bottom = 1;
  312. dropDownListStyle.border.left = 1;
  313. dropDownListStyle.border.right = 10;
  314. dropDownListStyle.border.top = 1;
  315. dropDownListStyle.border.bottom = 1;
  316. dropDownListStyle.font = font;
  317. dropDownListStyle.fontSize = DefaultFontSize;
  318. dropDownListStyle.textHorzAlign = THA_Left;
  319. dropDownListStyle.textVertAlign = TVA_Top;
  320. mSkin.setStyle("ListBox", dropDownListStyle);
  321. // DropDown scroll up button arrow
  322. GUIElementStyle dropDownScrollUpBtnArrowStyle;
  323. dropDownScrollUpBtnArrowStyle.normal.texture = getSkinTexture(DropDownBoxBtnUpArrowTex);
  324. dropDownScrollUpBtnArrowStyle.hover.texture = dropDownScrollUpBtnArrowStyle.normal.texture;
  325. dropDownScrollUpBtnArrowStyle.active.texture = dropDownScrollUpBtnArrowStyle.hover.texture;
  326. dropDownScrollUpBtnArrowStyle.fixedHeight = true;
  327. dropDownScrollUpBtnArrowStyle.fixedWidth = false;
  328. dropDownScrollUpBtnArrowStyle.height = 7;
  329. dropDownScrollUpBtnArrowStyle.width = 30;
  330. dropDownScrollUpBtnArrowStyle.border.left = 1;
  331. dropDownScrollUpBtnArrowStyle.border.right = 1;
  332. dropDownScrollUpBtnArrowStyle.border.top = 1;
  333. dropDownScrollUpBtnArrowStyle.border.bottom = 1;
  334. mSkin.setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  335. mSkin.setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  336. mSkin.setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  337. // DropDown scroll up button
  338. GUIElementStyle dropDownScrollUpBtnStyle;
  339. dropDownScrollUpBtnStyle.normal.texture = getSkinTexture(DropDownBoxBtnUpNormalTex);
  340. dropDownScrollUpBtnStyle.hover.texture = getSkinTexture(DropDownBoxBtnUpHoverTex);
  341. dropDownScrollUpBtnStyle.active.texture = dropDownScrollUpBtnStyle.hover.texture;
  342. dropDownScrollUpBtnStyle.fixedHeight = true;
  343. dropDownScrollUpBtnStyle.fixedWidth = false;
  344. dropDownScrollUpBtnStyle.height = 7;
  345. dropDownScrollUpBtnStyle.width = 30;
  346. dropDownScrollUpBtnStyle.border.left = 1;
  347. dropDownScrollUpBtnStyle.border.right = 1;
  348. dropDownScrollUpBtnStyle.border.top = 1;
  349. dropDownScrollUpBtnStyle.border.bottom = 1;
  350. mSkin.setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
  351. mSkin.setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
  352. mSkin.setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
  353. // DropDown scroll down button arrow
  354. GUIElementStyle dropDownScrollDownBtnArrowStyle;
  355. dropDownScrollDownBtnArrowStyle.normal.texture = getSkinTexture(DropDownBoxBtnDownArrowTex);
  356. dropDownScrollDownBtnArrowStyle.hover.texture = dropDownScrollDownBtnArrowStyle.normal.texture;
  357. dropDownScrollDownBtnArrowStyle.active.texture = dropDownScrollDownBtnArrowStyle.hover.texture;
  358. dropDownScrollDownBtnArrowStyle.fixedHeight = true;
  359. dropDownScrollDownBtnArrowStyle.fixedWidth = false;
  360. dropDownScrollDownBtnArrowStyle.height = 7;
  361. dropDownScrollDownBtnArrowStyle.width = 30;
  362. dropDownScrollDownBtnArrowStyle.border.left = 1;
  363. dropDownScrollDownBtnArrowStyle.border.right = 1;
  364. dropDownScrollDownBtnArrowStyle.border.top = 1;
  365. dropDownScrollDownBtnArrowStyle.border.bottom = 1;
  366. mSkin.setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  367. mSkin.setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  368. mSkin.setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  369. // DropDown scroll down button
  370. GUIElementStyle dropDownScrollDownBtnStyle;
  371. dropDownScrollDownBtnStyle.normal.texture = getSkinTexture(DropDownBoxBtnDownNormalTex);
  372. dropDownScrollDownBtnStyle.hover.texture = getSkinTexture(DropDownBoxBtnDownHoverTex);
  373. dropDownScrollDownBtnStyle.active.texture = dropDownScrollDownBtnStyle.hover.texture;
  374. dropDownScrollDownBtnStyle.fixedHeight = true;
  375. dropDownScrollDownBtnStyle.fixedWidth = false;
  376. dropDownScrollDownBtnStyle.height = 7;
  377. dropDownScrollDownBtnStyle.width = 30;
  378. dropDownScrollDownBtnStyle.border.left = 1;
  379. dropDownScrollDownBtnStyle.border.right = 1;
  380. dropDownScrollDownBtnStyle.border.top = 1;
  381. dropDownScrollDownBtnStyle.border.bottom = 1;
  382. mSkin.setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
  383. mSkin.setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
  384. mSkin.setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
  385. // DropDown entry button
  386. GUIElementStyle dropDownEntryBtnStyle;
  387. dropDownEntryBtnStyle.normal.texture = getSkinTexture(DropDownBoxEntryNormalTex);
  388. dropDownEntryBtnStyle.hover.texture = getSkinTexture(DropDownBoxEntryHoverTex);
  389. dropDownEntryBtnStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
  390. dropDownEntryBtnStyle.fixedHeight = true;
  391. dropDownEntryBtnStyle.fixedWidth = false;
  392. dropDownEntryBtnStyle.height = 14;
  393. dropDownEntryBtnStyle.width = 30;
  394. dropDownEntryBtnStyle.border.left = 1;
  395. dropDownEntryBtnStyle.border.right = 1;
  396. dropDownEntryBtnStyle.border.top = 1;
  397. dropDownEntryBtnStyle.border.bottom = 1;
  398. dropDownEntryBtnStyle.font = font;
  399. dropDownEntryBtnStyle.fontSize = DefaultFontSize;
  400. dropDownEntryBtnStyle.textHorzAlign = THA_Left;
  401. dropDownEntryBtnStyle.textVertAlign = TVA_Top;
  402. mSkin.setStyle("ListBoxEntryBtn", dropDownEntryBtnStyle);
  403. mSkin.setStyle("MenuBarEntryBtn", dropDownEntryBtnStyle);
  404. mSkin.setStyle("ContextMenuEntryBtn", dropDownEntryBtnStyle);
  405. // DropDown entry button with expand
  406. GUIElementStyle dropDownEntryExpBtnStyle;
  407. dropDownEntryExpBtnStyle.normal.texture = getSkinTexture(DropDownBoxEntryExpNormalTex);
  408. dropDownEntryExpBtnStyle.hover.texture = getSkinTexture(DropDownBoxEntryExpHoverTex);
  409. dropDownEntryExpBtnStyle.active.texture = dropDownEntryExpBtnStyle.hover.texture;
  410. dropDownEntryExpBtnStyle.fixedHeight = true;
  411. dropDownEntryExpBtnStyle.fixedWidth = false;
  412. dropDownEntryExpBtnStyle.height = 14;
  413. dropDownEntryExpBtnStyle.width = 30;
  414. dropDownEntryExpBtnStyle.border.left = 1;
  415. dropDownEntryExpBtnStyle.border.right = 6;
  416. dropDownEntryExpBtnStyle.border.top = 1;
  417. dropDownEntryExpBtnStyle.border.bottom = 1;
  418. dropDownEntryExpBtnStyle.font = font;
  419. dropDownEntryExpBtnStyle.fontSize = DefaultFontSize;
  420. dropDownEntryExpBtnStyle.textHorzAlign = THA_Left;
  421. dropDownEntryExpBtnStyle.textVertAlign = TVA_Top;
  422. mSkin.setStyle("ListBoxEntryExpBtn", dropDownEntryExpBtnStyle);
  423. mSkin.setStyle("MenuBarEntryExpBtn", dropDownEntryExpBtnStyle);
  424. mSkin.setStyle("ContextMenuEntryExpBtn", dropDownEntryExpBtnStyle);
  425. // DropDown box frame
  426. GUIElementStyle dropDownBoxStyle;
  427. dropDownBoxStyle.normal.texture = getSkinTexture(DropDownBoxBgTex);
  428. dropDownBoxStyle.hover.texture = dropDownEntryBtnStyle.normal.texture;
  429. dropDownBoxStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
  430. dropDownBoxStyle.fixedHeight = false;
  431. dropDownBoxStyle.fixedWidth = false;
  432. dropDownBoxStyle.border.left = 1;
  433. dropDownBoxStyle.border.right = 1;
  434. dropDownBoxStyle.border.top = 1;
  435. dropDownBoxStyle.border.bottom = 1;
  436. dropDownBoxStyle.margins.left = 1;
  437. dropDownBoxStyle.margins.right = 1;
  438. dropDownBoxStyle.margins.top = 1;
  439. dropDownBoxStyle.margins.bottom = 1;
  440. mSkin.setStyle("ListBoxFrame", dropDownBoxStyle);
  441. mSkin.setStyle("MenuBarFrame", dropDownBoxStyle);
  442. mSkin.setStyle("ContextMenuFrame", dropDownBoxStyle);
  443. // Drop down separator
  444. GUIElementStyle dropDownSeparatorStyle;
  445. dropDownSeparatorStyle.normal.texture = getSkinTexture(DropDownSeparatorTex);
  446. dropDownSeparatorStyle.fixedHeight = true;
  447. dropDownSeparatorStyle.fixedWidth = false;
  448. dropDownSeparatorStyle.height = 3;
  449. dropDownSeparatorStyle.width = 30;
  450. dropDownSeparatorStyle.border.left = 1;
  451. dropDownSeparatorStyle.border.right = 1;
  452. dropDownSeparatorStyle.border.top = 1;
  453. dropDownSeparatorStyle.border.bottom = 1;
  454. mSkin.setStyle("ListBoxSeparator", dropDownSeparatorStyle);
  455. mSkin.setStyle("MenuBarSeparator", dropDownSeparatorStyle);
  456. mSkin.setStyle("ContextMenuSeparator", dropDownSeparatorStyle);
  457. }
  458. HSpriteTexture BuiltinResources::getSkinTexture(const CM::WString& name)
  459. {
  460. return SpriteTexture::create(static_resource_cast<Texture>(Importer::instance().import(FileSystem::getWorkingDirectoryPath() + L"\\" + DefaultSkinFolder + name)));
  461. }
  462. HTexture BuiltinResources::getCursorTexture(const CM::WString& name)
  463. {
  464. return static_resource_cast<Texture>(Importer::instance().import(FileSystem::getWorkingDirectoryPath() + L"\\" + DefaultCursorFolder + name));
  465. }
  466. const CM::PixelData& BuiltinResources::getCursorArrow(Vector2I& hotSpot)
  467. {
  468. hotSpot = CursorArrowHotspot;
  469. return *mCursorArrow.get();
  470. }
  471. const CM::PixelData& BuiltinResources::getCursorArrowDrag(Vector2I& hotSpot)
  472. {
  473. hotSpot = CursorArrowDragHotspot;
  474. return *mCursorArrowDrag.get();
  475. }
  476. const CM::PixelData& BuiltinResources::getCursorWait(Vector2I& hotSpot)
  477. {
  478. hotSpot = CursorWaitHotspot;
  479. return *mCursorWait.get();
  480. }
  481. const CM::PixelData& BuiltinResources::getCursorIBeam(Vector2I& hotSpot)
  482. {
  483. hotSpot = CursorIBeamHotspot;
  484. return *mCursorIBeam.get();
  485. }
  486. const CM::PixelData& BuiltinResources::getCursorSizeNESW(Vector2I& hotSpot)
  487. {
  488. hotSpot = CursorSizeNESWHotspot;
  489. return *mCursorSizeNESW.get();
  490. }
  491. const CM::PixelData& BuiltinResources::getCursorSizeNS(Vector2I& hotSpot)
  492. {
  493. hotSpot = CursorSizeNSHotspot;
  494. return *mCursorSizeNS.get();
  495. }
  496. const CM::PixelData& BuiltinResources::getCursorSizeNWSE(Vector2I& hotSpot)
  497. {
  498. hotSpot = CursorSizeNWSEHotspot;
  499. return *mCursorSizeNWSE.get();
  500. }
  501. const CM::PixelData& BuiltinResources::getCursorSizeWE(Vector2I& hotSpot)
  502. {
  503. hotSpot = CursorSizeWEHotspot;
  504. return *mCursorSizeWE.get();
  505. }
  506. const CM::PixelData& BuiltinResources::getCursorDeny(Vector2I& hotSpot)
  507. {
  508. hotSpot = CursorDenyHotspot;
  509. return *mCursorDeny.get();
  510. }
  511. const CM::PixelData& BuiltinResources::getCursorMoveLeftRight(Vector2I& hotSpot)
  512. {
  513. hotSpot = CursorArrowLeftRightHotspot;
  514. return *mCursorArrowLeftRight.get();
  515. }
  516. }