BsBuiltinResources.cpp 27 KB

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