BsBuiltinEditorResources.cpp 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642
  1. #include "BsBuiltinEditorResources.h"
  2. #include "BsGUIElementStyle.h"
  3. #include "BsGUILabel.h"
  4. #include "BsGUIButton.h"
  5. #include "BsGUIInputBox.h"
  6. #include "BsGUIToggle.h"
  7. #include "BsGUIColor.h"
  8. #include "BsTextSprite.h"
  9. #include "BsSpriteTexture.h"
  10. #include "BsGUITreeViewEditBox.h"
  11. #include "BsGUIIntField.h"
  12. #include "BsGUIFloatField.h"
  13. #include "BsGUIColorField.h"
  14. #include "BsGUITextField.h"
  15. #include "BsGUIToggleField.h"
  16. #include "BsGUIVector2Field.h"
  17. #include "BsGUIVector3Field.h"
  18. #include "BsGUIVector4Field.h"
  19. #include "BsGUIComponentFoldout.h"
  20. #include "BsGUIFoldout.h"
  21. #include "BsFont.h"
  22. #include "BsFontImportOptions.h"
  23. #include "BsImporter.h"
  24. #include "BsGpuProgram.h"
  25. #include "BsShader.h"
  26. #include "BsTechnique.h"
  27. #include "BsPass.h"
  28. #include "BsMaterial.h"
  29. #include "BsBlendState.h"
  30. #include "BsDepthStencilState.h"
  31. #include "BsRasterizerState.h"
  32. #include "BsGpuProgramImportOptions.h"
  33. #include "BsResources.h"
  34. #include "BsRTTIType.h"
  35. #include "BsFileSystem.h"
  36. namespace BansheeEngine
  37. {
  38. const String BuiltinEditorResources::ObjectFieldStyleName = "GUIObjectField";
  39. const String BuiltinEditorResources::ObjectFieldLabelStyleName = "EditorFieldLabel";
  40. const String BuiltinEditorResources::ObjectFieldDropBtnStyleName = "DropButton";
  41. const String BuiltinEditorResources::ObjectFieldClearBtnStyleName = "ObjectClearButton";
  42. const Path BuiltinEditorResources::DefaultSkinFolderRaw = L"..\\..\\..\\..\\Data\\Raw\\Editor\\Skin\\";
  43. const Path BuiltinEditorResources::DefaultShaderFolderRaw = L"..\\..\\..\\..\\Data\\Raw\\Editor\\Shaders\\";
  44. const Path BuiltinEditorResources::DefaultSkinFolder = L"..\\..\\..\\..\\Data\\Editor\\Skin\\";
  45. const Path BuiltinEditorResources::DefaultShaderFolder = L"..\\..\\..\\..\\Data\\Editor\\Shaders\\";
  46. const WString BuiltinEditorResources::HLSL11ShaderSubFolder = L"HLSL11/";
  47. const WString BuiltinEditorResources::HLSL9ShaderSubFolder = L"HLSL9/";
  48. const WString BuiltinEditorResources::GLSLShaderSubFolder = L"GLSL/";
  49. const WString BuiltinEditorResources::DefaultFontFilename = L"arial.ttf";
  50. const UINT32 BuiltinEditorResources::DefaultFontSize = 10;
  51. const WString BuiltinEditorResources::WindowBackgroundTexture = L"WindowBgTile.psd";
  52. const WString BuiltinEditorResources::ButtonNormalTex = L"ButtonNormal.psd";
  53. const WString BuiltinEditorResources::ButtonHoverTex = L"ButtonHover.psd";
  54. const WString BuiltinEditorResources::ButtonActiveTex = L"ButtonActive.psd";
  55. const WString BuiltinEditorResources::ToggleNormalTex = L"ToggleNormal.psd";
  56. const WString BuiltinEditorResources::ToggleHoverTex = L"ToggleHover.psd";
  57. const WString BuiltinEditorResources::ToggleActiveTex = L"ToggleActive.psd";
  58. const WString BuiltinEditorResources::ToggleNormalOnTex = L"ToggleOnNormal.psd";
  59. const WString BuiltinEditorResources::ToggleHoverOnTex = L"ToggleOnHover.psd";
  60. const WString BuiltinEditorResources::ToggleActiveOnTex = L"ToggleOnActive.psd";
  61. const WString BuiltinEditorResources::ObjectDropBtnNormalTex = L"ObjectFieldDropNormal.psd";
  62. const WString BuiltinEditorResources::ObjectDropBtnNormalOnTex = L"ObjectFieldDropOnNormal.psd";
  63. const WString BuiltinEditorResources::ObjectClearBtnNormalTex = L"ObjectFieldBtnNormal.psd";
  64. const WString BuiltinEditorResources::ObjectClearBtnHoverTex = L"ObjectFieldBtnHover.psd";
  65. const WString BuiltinEditorResources::ObjectClearBtnActiveTex = L"ObjectFieldBtnActive.psd";
  66. const WString BuiltinEditorResources::FoldoutOpenNormalTex = L"FoldoutOpenNormal.psd";
  67. const WString BuiltinEditorResources::FoldoutOpenHoverTex = L"FoldoutOpenHover.psd";
  68. const WString BuiltinEditorResources::FoldoutClosedNormalTex = L"FoldoutClosedNormal.psd";
  69. const WString BuiltinEditorResources::FoldoutClosedHoverTex = L"FoldoutClosedHover.psd";
  70. const WString BuiltinEditorResources::CmpFoldoutOpenNormalTex = L"CmpFoldoutOpenNormal.psd";
  71. const WString BuiltinEditorResources::CmpFoldoutOpenHoverTex = L"CmpFoldoutOpenHover.psd";
  72. const WString BuiltinEditorResources::CmpFoldoutOpenActiveTex = L"CmpFoldoutOpenActive.psd";
  73. const WString BuiltinEditorResources::CmpFoldoutClosedNormalTex = L"CmpFoldoutClosedNormal.psd";
  74. const WString BuiltinEditorResources::CmpFoldoutClosedHoverTex = L"CmpFoldoutClosedHover.psd";
  75. const WString BuiltinEditorResources::CmpFoldoutClosedActiveTex = L"CmpFoldoutClosedActive.psd";
  76. const WString BuiltinEditorResources::WindowFrameNormal = L"WindowFrameNormal.psd";
  77. const WString BuiltinEditorResources::WindowFrameFocused = L"WindowFrameFocused.psd";
  78. const WString BuiltinEditorResources::WindowTitleBarBg = L"WindowTitleBarBg.psd";
  79. const WString BuiltinEditorResources::WindowCloseButtonNormal = L"WindowCloseBtnNormal.psd";
  80. const WString BuiltinEditorResources::WindowCloseButtonHover = L"WindowCloseBtnHover.psd";
  81. const WString BuiltinEditorResources::WindowMinButtonNormal = L"WindowMinBtnNormal.psd";
  82. const WString BuiltinEditorResources::WindowMinButtonHover = L"WindowMinBtnHover.psd";
  83. const WString BuiltinEditorResources::WindowMaxButtonNormal = L"WindowMaxBtnNormal.psd";
  84. const WString BuiltinEditorResources::WindowMaxButtonHover = L"WindowMaxBtnHover.psd";
  85. const WString BuiltinEditorResources::TabbedBarBtnNormal = L"TabbedButtonNormal.psd";
  86. const WString BuiltinEditorResources::TabbedBarBtnActive = L"TabbedButtonActive.psd";
  87. const WString BuiltinEditorResources::InputBoxNormalTex = L"InputBoxNormal.psd";
  88. const WString BuiltinEditorResources::InputBoxHoverTex = L"InputBoxHover.psd";
  89. const WString BuiltinEditorResources::InputBoxFocusedTex = L"InputBoxFocused.psd";
  90. const WString BuiltinEditorResources::ScrollBarUpNormalTex = L"ScrollBarUpNormal.psd";
  91. const WString BuiltinEditorResources::ScrollBarUpHoverTex = L"ScrollBarUpHover.psd";
  92. const WString BuiltinEditorResources::ScrollBarUpActiveTex = L"ScrollBarUpActive.psd";
  93. const WString BuiltinEditorResources::ScrollBarDownNormalTex = L"ScrollBarDownNormal.psd";
  94. const WString BuiltinEditorResources::ScrollBarDownHoverTex = L"ScrollBarDownHover.psd";
  95. const WString BuiltinEditorResources::ScrollBarDownActiveTex = L"ScrollBarDownActive.psd";
  96. const WString BuiltinEditorResources::ScrollBarLeftNormalTex = L"ScrollBarLeftNormal.psd";
  97. const WString BuiltinEditorResources::ScrollBarLeftHoverTex = L"ScrollBarLeftHover.psd";
  98. const WString BuiltinEditorResources::ScrollBarLeftActiveTex = L"ScrollBarLeftActive.psd";
  99. const WString BuiltinEditorResources::ScrollBarRightNormalTex = L"ScrollBarRightNormal.psd";
  100. const WString BuiltinEditorResources::ScrollBarRightHoverTex = L"ScrollBarRightHover.psd";
  101. const WString BuiltinEditorResources::ScrollBarRightActiveTex = L"ScrollBarRightActive.psd";
  102. const WString BuiltinEditorResources::ScrollBarHandleHorzNormalTex = L"ScrollBarHorzHandleNormal.psd";
  103. const WString BuiltinEditorResources::ScrollBarHandleHorzHoverTex = L"ScrollBarHorzHandleHover.psd";
  104. const WString BuiltinEditorResources::ScrollBarHandleHorzActiveTex = L"ScrollBarHorzHandleActive.psd";
  105. const WString BuiltinEditorResources::ScrollBarHandleVertNormalTex = L"ScrollBarVertHandleNormal.psd";
  106. const WString BuiltinEditorResources::ScrollBarHandleVertHoverTex = L"ScrollBarVertHandleHover.psd";
  107. const WString BuiltinEditorResources::ScrollBarHandleVertActiveTex = L"ScrollBarVertHandleActive.psd";
  108. const WString BuiltinEditorResources::DropDownBtnNormalTex = L"DropDownNormal.psd";
  109. const WString BuiltinEditorResources::DropDownBtnHoverTex = L"DropDownHover.psd";
  110. const WString BuiltinEditorResources::DropDownBoxBgTex = L"DropDownBoxBg.psd";
  111. const WString BuiltinEditorResources::DropDownBoxEntryNormalTex = L"DropDownButtonNormal.psd";
  112. const WString BuiltinEditorResources::DropDownBoxEntryHoverTex = L"DropDownButtonHover.psd";
  113. const WString BuiltinEditorResources::DropDownBoxBtnUpNormalTex = L"DropDownBoxBtnUpNormal.psd";
  114. const WString BuiltinEditorResources::DropDownBoxBtnUpHoverTex = L"DropDownBoxBtnUpHover.psd";
  115. const WString BuiltinEditorResources::DropDownBoxBtnDownNormalTex = L"DropDownBoxBtnDownNormal.psd";
  116. const WString BuiltinEditorResources::DropDownBoxBtnDownHoverTex = L"DropDownBoxBtnDownHover.psd";
  117. const WString BuiltinEditorResources::DropDownBoxEntryExpNormalTex = L"DropDownExpNormal.psd";
  118. const WString BuiltinEditorResources::DropDownBoxEntryExpHoverTex = L"DropDownExpHover.psd";
  119. const WString BuiltinEditorResources::DropDownSeparatorTex = L"DropDownSeparator.psd";
  120. const WString BuiltinEditorResources::DropDownBoxBtnUpArrowTex = L"DropDownBoxBtnUpArrow.psd";
  121. const WString BuiltinEditorResources::DropDownBoxBtnDownArrowTex = L"DropDownBoxBtnDownArrow.psd";
  122. const WString BuiltinEditorResources::ScrollBarBgTex = L"ScrollBarBg.psd";
  123. const WString BuiltinEditorResources::MenuBarBgTex = L"MenuBarBg.psd";
  124. const WString BuiltinEditorResources::MenuBarBtnNormalTex = L"MenuBarButtonNormal.psd";
  125. const WString BuiltinEditorResources::MenuBarBtnHoverTex = L"MenuBarButtonHover.psd";
  126. const WString BuiltinEditorResources::MenuBarBansheeLogoTex = L"MenuBarBansheeLogo.psd";
  127. const WString BuiltinEditorResources::DockSliderNormalTex = L"DockSliderBtn.psd";
  128. const WString BuiltinEditorResources::TreeViewExpandButtonOffNormal = L"TreeViewExpandButtonOffNormal.psd";
  129. const WString BuiltinEditorResources::TreeViewExpandButtonOffHover = L"TreeViewExpandButtonOffHover.psd";
  130. const WString BuiltinEditorResources::TreeViewExpandButtonOnNormal = L"TreeViewExpandButtonOnNormal.psd";
  131. const WString BuiltinEditorResources::TreeViewExpandButtonOnHover = L"TreeViewExpandButtonOnHover.psd";
  132. const WString BuiltinEditorResources::TreeViewSelectionBackground = L"TreeViewSelectionBackground.psd";
  133. const WString BuiltinEditorResources::TreeViewEditBox = L"TreeViewEditBox.psd";
  134. const WString BuiltinEditorResources::TreeViewElementHighlight = L"TreeViewElementHighlight.psd";
  135. const WString BuiltinEditorResources::TreeViewElementSepHighlight = L"TreeViewElementSepHighlight.psd";
  136. /************************************************************************/
  137. /* SHADERS */
  138. /************************************************************************/
  139. struct GpuProgramImportData
  140. {
  141. WString filename;
  142. String entryPoint;
  143. GpuProgramType type;
  144. GpuProgramProfile profile;
  145. String language;
  146. WString folder;
  147. };
  148. const WString BuiltinEditorResources::ShaderDockOverlayVSFile = L"dockDropOverlayVS.gpuprog";
  149. const WString BuiltinEditorResources::ShaderDockOverlayPSFile = L"dockDropOverlayPS.gpuprog";
  150. const WString BuiltinEditorResources::SceneGridVSFile = L"sceneGridVS.gpuprog";
  151. const WString BuiltinEditorResources::SceneGridPSFile = L"sceneGridPS.gpuprog";
  152. const WString BuiltinEditorResources::PickingVSFile = L"pickingVS.gpuprog";
  153. const WString BuiltinEditorResources::PickingPSFile = L"pickingPS.gpuprog";
  154. const WString BuiltinEditorResources::PickingAlphaVSFile = L"pickingAlphaVS.gpuprog";
  155. const WString BuiltinEditorResources::PickingAlphaPSFile = L"pickingAlphaPS.gpuprog";
  156. const WString BuiltinEditorResources::ShaderWireGizmoVSFile = L"wireGizmoVS.gpuprog";
  157. const WString BuiltinEditorResources::ShaderWireGizmoPSFile = L"wireGizmoPS.gpuprog";
  158. const WString BuiltinEditorResources::ShaderSolidGizmoVSFile = L"solidGizmoVS.gpuprog";
  159. const WString BuiltinEditorResources::ShaderSolidGizmoPSFile = L"solidGizmoPS.gpuprog";
  160. const WString BuiltinEditorResources::ShaderIconGizmo0VSFile = L"iconGizmo0VS.gpuprog";
  161. const WString BuiltinEditorResources::ShaderIconGizmo0PSFile = L"iconGizmo0PS.gpuprog";
  162. const WString BuiltinEditorResources::ShaderIconGizmo1VSFile = L"iconGizmo1VS.gpuprog";
  163. const WString BuiltinEditorResources::ShaderIconGizmo1PSFile = L"iconGizmo1PS.gpuprog";
  164. const WString BuiltinEditorResources::GizmoPickingVSFile = L"pickingGizmoVS.gpuprog";
  165. const WString BuiltinEditorResources::GizmoPickingPSFile = L"pickingGizmoPS.gpuprog";
  166. const WString BuiltinEditorResources::GizmoPickingAlphaVSFile = L"pickingGizmoAlphaVS.gpuprog";
  167. const WString BuiltinEditorResources::GizmoPickingAlphaPSFile = L"pickingGizmoAlphaPS.gpuprog";
  168. BuiltinEditorResources::BuiltinEditorResources(RenderSystemPlugin activeRSPlugin)
  169. :mRenderSystemPlugin(activeRSPlugin)
  170. {
  171. switch (activeRSPlugin)
  172. {
  173. case RenderSystemPlugin::DX11:
  174. mActiveShaderSubFolder = HLSL11ShaderSubFolder;
  175. mActiveRenderSystem = RenderAPIDX11;
  176. break;
  177. case RenderSystemPlugin::DX9:
  178. mActiveShaderSubFolder = HLSL9ShaderSubFolder;
  179. mActiveRenderSystem = RenderAPIDX9;
  180. break;
  181. case RenderSystemPlugin::OpenGL:
  182. mActiveShaderSubFolder = GLSLShaderSubFolder;
  183. mActiveRenderSystem = RenderAPIOpenGL;
  184. break;
  185. }
  186. preprocess();
  187. initDockDropOverlayShader();
  188. initSceneGridShader();
  189. initPickingShader(CULL_NONE);
  190. initPickingShader(CULL_CLOCKWISE);
  191. initPickingShader(CULL_COUNTERCLOCKWISE);
  192. initPickingAlphaShader(CULL_NONE);
  193. initPickingAlphaShader(CULL_CLOCKWISE);
  194. initPickingAlphaShader(CULL_COUNTERCLOCKWISE);
  195. initWireGizmoShader();
  196. initSolidGizmoShader();
  197. initIconGizmoShader();
  198. initGizmoPickingShader();
  199. initGizmoPickingAlphaShader();
  200. initWireHandleShader();
  201. initSolidHandleShader();
  202. Path fontPath = FileSystem::getWorkingDirectoryPath();
  203. fontPath.append(DefaultSkinFolder);
  204. fontPath.append(DefaultFontFilename + L".asset");
  205. HFont font = Resources::instance().load<Font>(fontPath);
  206. // Label
  207. GUIElementStyle labelStyle;
  208. labelStyle.font = font;
  209. labelStyle.fontSize = DefaultFontSize;
  210. labelStyle.fixedWidth = false;
  211. labelStyle.fixedHeight = true;
  212. labelStyle.height = 11;
  213. labelStyle.minWidth = 10;
  214. mSkin.setStyle(GUILabel::getGUITypeName(), labelStyle);
  215. // Window frame
  216. GUIElementStyle windowFrameStyle;
  217. windowFrameStyle.normal.texture = getGUITexture(WindowFrameNormal);
  218. windowFrameStyle.focused.texture = getGUITexture(WindowFrameFocused);
  219. windowFrameStyle.border.left = 1;
  220. windowFrameStyle.border.right = 1;
  221. windowFrameStyle.border.top = 1;
  222. windowFrameStyle.border.bottom = 1;
  223. mSkin.setStyle("WindowFrame", windowFrameStyle);
  224. // Button
  225. GUIElementStyle buttonStyle;
  226. buttonStyle.normal.texture = getGUITexture(ButtonNormalTex);
  227. buttonStyle.hover.texture = getGUITexture(ButtonHoverTex);
  228. buttonStyle.active.texture = getGUITexture(ButtonActiveTex);
  229. buttonStyle.border.left = 6;
  230. buttonStyle.border.right = 6;
  231. buttonStyle.border.top = 6;
  232. buttonStyle.border.bottom = 6;
  233. buttonStyle.contentOffset.left = 3;
  234. buttonStyle.contentOffset.right = 3;
  235. buttonStyle.fixedHeight = true;
  236. buttonStyle.height = 15;
  237. buttonStyle.minWidth = 50;
  238. buttonStyle.font = font;
  239. buttonStyle.fontSize = DefaultFontSize;
  240. buttonStyle.textHorzAlign = THA_Center;
  241. buttonStyle.textVertAlign = TVA_Center;
  242. mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
  243. // Toggle
  244. GUIElementStyle toggleStyle;
  245. toggleStyle.normal.texture = getGUITexture(ToggleNormalTex);
  246. toggleStyle.hover.texture = getGUITexture(ToggleHoverTex);
  247. toggleStyle.active.texture = getGUITexture(ToggleActiveTex);
  248. toggleStyle.normalOn.texture = getGUITexture(ToggleNormalOnTex);
  249. toggleStyle.hoverOn.texture = getGUITexture(ToggleHoverOnTex);
  250. toggleStyle.activeOn.texture = getGUITexture(ToggleActiveOnTex);
  251. toggleStyle.fixedHeight = true;
  252. toggleStyle.fixedWidth = true;
  253. toggleStyle.height = 15;
  254. toggleStyle.width = 15;
  255. mSkin.setStyle(GUIToggle::getGUITypeName(), toggleStyle);
  256. // Color
  257. GUIElementStyle colorStyle;
  258. colorStyle.margins.left = 2;
  259. colorStyle.margins.right = 2;
  260. colorStyle.margins.top = 2;
  261. colorStyle.margins.bottom = 2;
  262. colorStyle.fixedHeight = true;
  263. colorStyle.height = 10;
  264. colorStyle.minWidth = 10;
  265. mSkin.setStyle(GUIColor::getGUITypeName(), colorStyle);
  266. // Window background texture
  267. GUIElementStyle windowBgStyle;
  268. windowBgStyle.normal.texture = getGUITexture(WindowBackgroundTexture);
  269. mSkin.setStyle("WindowBackground", windowBgStyle);
  270. // Window title bar background
  271. GUIElementStyle titleBarBgStyle;
  272. titleBarBgStyle.normal.texture = getGUITexture(WindowTitleBarBg);
  273. titleBarBgStyle.fixedHeight = true;
  274. titleBarBgStyle.height = 13;
  275. mSkin.setStyle("TitleBarBackground", titleBarBgStyle);
  276. // Tabbed title bar tab button
  277. GUIElementStyle tabbedBarButton;
  278. tabbedBarButton.normal.texture = getGUITexture(TabbedBarBtnNormal);
  279. tabbedBarButton.hover.texture = getGUITexture(TabbedBarBtnActive);
  280. tabbedBarButton.active.texture = tabbedBarButton.hover.texture;
  281. tabbedBarButton.normalOn.texture = tabbedBarButton.hover.texture;
  282. tabbedBarButton.hoverOn.texture = tabbedBarButton.hover.texture;
  283. tabbedBarButton.activeOn.texture = tabbedBarButton.hover.texture;
  284. tabbedBarButton.fixedHeight = true;
  285. tabbedBarButton.height = 13;
  286. tabbedBarButton.minWidth = 10;
  287. tabbedBarButton.maxWidth = 110;
  288. tabbedBarButton.font = font;
  289. tabbedBarButton.fontSize = DefaultFontSize;
  290. tabbedBarButton.textHorzAlign = THA_Center;
  291. tabbedBarButton.textVertAlign = TVA_Center;
  292. mSkin.setStyle("TabbedBarBtn", tabbedBarButton);
  293. // Tabbed title bar drag/drop button
  294. GUIElementStyle tabbedBarDropButton;
  295. tabbedBarDropButton.fixedHeight = true;
  296. tabbedBarDropButton.fixedWidth = true;
  297. tabbedBarDropButton.height = 13;
  298. tabbedBarDropButton.width = 6;
  299. mSkin.setStyle("TabbedBarDropArea", tabbedBarDropButton);
  300. // Window minimize button
  301. GUIElementStyle winMinButtonStyle;
  302. winMinButtonStyle.normal.texture = getGUITexture(WindowMinButtonNormal);
  303. winMinButtonStyle.hover.texture = getGUITexture(WindowMinButtonHover);
  304. winMinButtonStyle.active.texture = winMinButtonStyle.hover.texture;
  305. winMinButtonStyle.fixedHeight = true;
  306. winMinButtonStyle.fixedWidth = true;
  307. winMinButtonStyle.height = 7;
  308. winMinButtonStyle.width = 8;
  309. mSkin.setStyle("WinMinimizeBtn", winMinButtonStyle);
  310. // Window maximize button
  311. GUIElementStyle winMaxButtonStyle;
  312. winMaxButtonStyle.normal.texture = getGUITexture(WindowMaxButtonNormal);
  313. winMaxButtonStyle.hover.texture = getGUITexture(WindowMaxButtonHover);
  314. winMaxButtonStyle.active.texture = winMaxButtonStyle.hover.texture;
  315. winMaxButtonStyle.fixedHeight = true;
  316. winMaxButtonStyle.fixedWidth = true;
  317. winMaxButtonStyle.height = 8;
  318. winMaxButtonStyle.width = 8;
  319. mSkin.setStyle("WinMaximizeBtn", winMaxButtonStyle);
  320. // Window close button
  321. GUIElementStyle winCloseButtonStyle;
  322. winCloseButtonStyle.normal.texture = getGUITexture(WindowCloseButtonNormal);
  323. winCloseButtonStyle.hover.texture = getGUITexture(WindowCloseButtonHover);
  324. winCloseButtonStyle.active.texture = winCloseButtonStyle.hover.texture;
  325. winCloseButtonStyle.fixedHeight = true;
  326. winCloseButtonStyle.fixedWidth = true;
  327. winCloseButtonStyle.height = 7;
  328. winCloseButtonStyle.width = 8;
  329. mSkin.setStyle("WinCloseBtn", winCloseButtonStyle);
  330. // Input box
  331. GUIElementStyle inputBoxStyle;
  332. inputBoxStyle.normal.texture = getGUITexture(InputBoxNormalTex);
  333. inputBoxStyle.hover.texture = getGUITexture(InputBoxHoverTex);
  334. inputBoxStyle.focused.texture = getGUITexture(InputBoxFocusedTex);
  335. inputBoxStyle.active.texture = inputBoxStyle.normal.texture;
  336. inputBoxStyle.border.left = 1;
  337. inputBoxStyle.border.right = 1;
  338. inputBoxStyle.border.top = 1;
  339. inputBoxStyle.border.bottom = 1;
  340. inputBoxStyle.contentOffset.left = 3;
  341. inputBoxStyle.contentOffset.right = 3;
  342. inputBoxStyle.contentOffset.top = 2;
  343. inputBoxStyle.contentOffset.bottom = 2;
  344. inputBoxStyle.fixedHeight = true;
  345. inputBoxStyle.height = 15;
  346. inputBoxStyle.minWidth = 10;
  347. inputBoxStyle.font = font;
  348. inputBoxStyle.fontSize = DefaultFontSize;
  349. inputBoxStyle.textHorzAlign = THA_Left;
  350. inputBoxStyle.textVertAlign = TVA_Top;
  351. mSkin.setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
  352. /************************************************************************/
  353. /* SCROLL BAR */
  354. /************************************************************************/
  355. // Up button
  356. GUIElementStyle scrollUpBtnStyle;
  357. scrollUpBtnStyle.normal.texture = getGUITexture(ScrollBarUpNormalTex);
  358. scrollUpBtnStyle.hover.texture = getGUITexture(ScrollBarUpHoverTex);
  359. scrollUpBtnStyle.active.texture = getGUITexture(ScrollBarUpActiveTex);
  360. scrollUpBtnStyle.fixedHeight = true;
  361. scrollUpBtnStyle.fixedWidth = true;
  362. scrollUpBtnStyle.height = 4;
  363. scrollUpBtnStyle.width = 8;
  364. mSkin.setStyle("ScrollUpBtn", scrollUpBtnStyle);
  365. // Down button
  366. GUIElementStyle scrollDownBtnStyle;
  367. scrollDownBtnStyle.normal.texture = getGUITexture(ScrollBarDownNormalTex);
  368. scrollDownBtnStyle.hover.texture = getGUITexture(ScrollBarDownHoverTex);
  369. scrollDownBtnStyle.active.texture = getGUITexture(ScrollBarDownActiveTex);
  370. scrollDownBtnStyle.fixedHeight = true;
  371. scrollDownBtnStyle.fixedWidth = true;
  372. scrollDownBtnStyle.height = 4;
  373. scrollDownBtnStyle.width = 8;
  374. mSkin.setStyle("ScrollDownBtn", scrollDownBtnStyle);
  375. // Left button
  376. GUIElementStyle scrollLeftBtnStyle;
  377. scrollLeftBtnStyle.normal.texture = getGUITexture(ScrollBarLeftNormalTex);
  378. scrollLeftBtnStyle.hover.texture = getGUITexture(ScrollBarLeftHoverTex);
  379. scrollLeftBtnStyle.active.texture = getGUITexture(ScrollBarLeftActiveTex);
  380. scrollLeftBtnStyle.fixedHeight = true;
  381. scrollLeftBtnStyle.fixedWidth = true;
  382. scrollLeftBtnStyle.height = 8;
  383. scrollLeftBtnStyle.width = 4;
  384. mSkin.setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
  385. // Right button
  386. GUIElementStyle scrollRightBtnStyle;
  387. scrollRightBtnStyle.normal.texture = getGUITexture(ScrollBarRightNormalTex);
  388. scrollRightBtnStyle.hover.texture = getGUITexture(ScrollBarRightHoverTex);
  389. scrollRightBtnStyle.active.texture = getGUITexture(ScrollBarRightActiveTex);
  390. scrollRightBtnStyle.fixedHeight = true;
  391. scrollRightBtnStyle.fixedWidth = true;
  392. scrollRightBtnStyle.height = 8;
  393. scrollRightBtnStyle.width = 4;
  394. mSkin.setStyle("ScrollRightBtn", scrollRightBtnStyle);
  395. // Horizontal handle
  396. GUIElementStyle scrollBarHorzBtnStyle;
  397. scrollBarHorzBtnStyle.normal.texture = getGUITexture(ScrollBarHandleHorzNormalTex);
  398. scrollBarHorzBtnStyle.hover.texture = getGUITexture(ScrollBarHandleHorzHoverTex);
  399. scrollBarHorzBtnStyle.active.texture = getGUITexture(ScrollBarHandleHorzActiveTex);
  400. scrollBarHorzBtnStyle.fixedHeight = true;
  401. scrollBarHorzBtnStyle.fixedWidth = true;
  402. scrollBarHorzBtnStyle.height = 6;
  403. scrollBarHorzBtnStyle.width = 4;
  404. mSkin.setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
  405. // Vertical handle
  406. GUIElementStyle scrollBarVertBtnStyle;
  407. scrollBarVertBtnStyle.normal.texture = getGUITexture(ScrollBarHandleVertNormalTex);
  408. scrollBarVertBtnStyle.hover.texture = getGUITexture(ScrollBarHandleVertHoverTex);
  409. scrollBarVertBtnStyle.active.texture = getGUITexture(ScrollBarHandleVertActiveTex);
  410. scrollBarVertBtnStyle.fixedHeight = true;
  411. scrollBarVertBtnStyle.fixedWidth = true;
  412. scrollBarVertBtnStyle.height = 4;
  413. scrollBarVertBtnStyle.width = 6;
  414. mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
  415. HSpriteTexture scrollBarBgPtr = getGUITexture(ScrollBarBgTex);
  416. // Vertical scroll bar
  417. GUIElementStyle vertScrollBarStyle;
  418. vertScrollBarStyle.normal.texture = scrollBarBgPtr;
  419. vertScrollBarStyle.hover.texture = scrollBarBgPtr;
  420. vertScrollBarStyle.active.texture = scrollBarBgPtr;
  421. vertScrollBarStyle.fixedHeight = false;
  422. vertScrollBarStyle.fixedWidth = true;
  423. vertScrollBarStyle.minHeight = 16;
  424. vertScrollBarStyle.width = 8;
  425. mSkin.setStyle("ScrollBarVert", vertScrollBarStyle);
  426. // Horizontal scroll bar
  427. GUIElementStyle horzScrollBarStyle;
  428. horzScrollBarStyle.normal.texture = scrollBarBgPtr;
  429. horzScrollBarStyle.hover.texture = scrollBarBgPtr;
  430. horzScrollBarStyle.active.texture = scrollBarBgPtr;
  431. horzScrollBarStyle.fixedHeight = true;
  432. horzScrollBarStyle.fixedWidth = false;
  433. horzScrollBarStyle.minWidth = 16;
  434. horzScrollBarStyle.height = 8;
  435. mSkin.setStyle("ScrollBarHorz", horzScrollBarStyle);
  436. /************************************************************************/
  437. /* DROP DOWN BOX */
  438. /************************************************************************/
  439. // ListBox button
  440. GUIElementStyle dropDownListStyle;
  441. dropDownListStyle.normal.texture = getGUITexture(DropDownBtnNormalTex);
  442. dropDownListStyle.hover.texture = getGUITexture(DropDownBtnHoverTex);
  443. dropDownListStyle.active.texture = dropDownListStyle.hover.texture;
  444. dropDownListStyle.normalOn.texture = dropDownListStyle.hover.texture;
  445. dropDownListStyle.hoverOn.texture = dropDownListStyle.hover.texture;
  446. dropDownListStyle.activeOn.texture = dropDownListStyle.hover.texture;
  447. dropDownListStyle.fixedHeight = true;
  448. dropDownListStyle.fixedWidth = false;
  449. dropDownListStyle.height = 13;
  450. dropDownListStyle.width = 30;
  451. dropDownListStyle.contentOffset.left = 3;
  452. dropDownListStyle.contentOffset.right = 11;
  453. dropDownListStyle.contentOffset.top = 1;
  454. dropDownListStyle.contentOffset.bottom = 1;
  455. dropDownListStyle.border.left = 1;
  456. dropDownListStyle.border.right = 10;
  457. dropDownListStyle.border.top = 1;
  458. dropDownListStyle.border.bottom = 1;
  459. dropDownListStyle.font = font;
  460. dropDownListStyle.fontSize = DefaultFontSize;
  461. dropDownListStyle.textHorzAlign = THA_Left;
  462. dropDownListStyle.textVertAlign = TVA_Top;
  463. mSkin.setStyle("ListBox", dropDownListStyle);
  464. // DropDown scroll up button arrow
  465. HSpriteTexture dropDownBtnScrollUpArrow = getGUITexture(DropDownBoxBtnUpArrowTex);
  466. GUIElementStyle dropDownScrollUpBtnArrowStyle;
  467. dropDownScrollUpBtnArrowStyle.normal.texture = getGUITexture(DropDownBoxBtnUpArrowTex);
  468. dropDownScrollUpBtnArrowStyle.hover.texture = dropDownScrollUpBtnArrowStyle.normal.texture;
  469. dropDownScrollUpBtnArrowStyle.active.texture = dropDownScrollUpBtnArrowStyle.hover.texture;
  470. dropDownScrollUpBtnArrowStyle.fixedHeight = true;
  471. dropDownScrollUpBtnArrowStyle.fixedWidth = false;
  472. dropDownScrollUpBtnArrowStyle.height = 7;
  473. dropDownScrollUpBtnArrowStyle.width = 30;
  474. dropDownScrollUpBtnArrowStyle.border.left = 1;
  475. dropDownScrollUpBtnArrowStyle.border.right = 1;
  476. dropDownScrollUpBtnArrowStyle.border.top = 1;
  477. dropDownScrollUpBtnArrowStyle.border.bottom = 1;
  478. mSkin.setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  479. mSkin.setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  480. mSkin.setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  481. // DropDown scroll up button
  482. GUIElementStyle dropDownScrollUpBtnStyle;
  483. dropDownScrollUpBtnStyle.normal.texture = getGUITexture(DropDownBoxBtnUpNormalTex);
  484. dropDownScrollUpBtnStyle.hover.texture = getGUITexture(DropDownBoxBtnUpHoverTex);
  485. dropDownScrollUpBtnStyle.active.texture = dropDownScrollUpBtnStyle.hover.texture;
  486. dropDownScrollUpBtnStyle.fixedHeight = true;
  487. dropDownScrollUpBtnStyle.fixedWidth = false;
  488. dropDownScrollUpBtnStyle.height = 7;
  489. dropDownScrollUpBtnStyle.width = 30;
  490. dropDownScrollUpBtnStyle.border.left = 1;
  491. dropDownScrollUpBtnStyle.border.right = 1;
  492. dropDownScrollUpBtnStyle.border.top = 1;
  493. dropDownScrollUpBtnStyle.border.bottom = 1;
  494. mSkin.setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
  495. mSkin.setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
  496. mSkin.setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
  497. // DropDown scroll down button arrow
  498. GUIElementStyle dropDownScrollDownBtnArrowStyle;
  499. dropDownScrollDownBtnArrowStyle.normal.texture = getGUITexture(DropDownBoxBtnDownArrowTex);
  500. dropDownScrollDownBtnArrowStyle.hover.texture = dropDownScrollDownBtnArrowStyle.normal.texture;
  501. dropDownScrollDownBtnArrowStyle.active.texture = dropDownScrollDownBtnArrowStyle.hover.texture;
  502. dropDownScrollDownBtnArrowStyle.fixedHeight = true;
  503. dropDownScrollDownBtnArrowStyle.fixedWidth = false;
  504. dropDownScrollDownBtnArrowStyle.height = 7;
  505. dropDownScrollDownBtnArrowStyle.width = 30;
  506. dropDownScrollDownBtnArrowStyle.border.left = 1;
  507. dropDownScrollDownBtnArrowStyle.border.right = 1;
  508. dropDownScrollDownBtnArrowStyle.border.top = 1;
  509. dropDownScrollDownBtnArrowStyle.border.bottom = 1;
  510. mSkin.setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  511. mSkin.setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  512. mSkin.setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  513. // DropDown scroll down button
  514. GUIElementStyle dropDownScrollDownBtnStyle;
  515. dropDownScrollDownBtnStyle.normal.texture = getGUITexture(DropDownBoxBtnDownNormalTex);
  516. dropDownScrollDownBtnStyle.hover.texture = getGUITexture(DropDownBoxBtnDownHoverTex);
  517. dropDownScrollDownBtnStyle.active.texture = dropDownScrollDownBtnStyle.hover.texture;
  518. dropDownScrollDownBtnStyle.fixedHeight = true;
  519. dropDownScrollDownBtnStyle.fixedWidth = false;
  520. dropDownScrollDownBtnStyle.height = 7;
  521. dropDownScrollDownBtnStyle.width = 30;
  522. dropDownScrollDownBtnStyle.border.left = 1;
  523. dropDownScrollDownBtnStyle.border.right = 1;
  524. dropDownScrollDownBtnStyle.border.top = 1;
  525. dropDownScrollDownBtnStyle.border.bottom = 1;
  526. mSkin.setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
  527. mSkin.setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
  528. mSkin.setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
  529. // DropDown entry button
  530. GUIElementStyle dropDownEntryBtnStyle;
  531. dropDownEntryBtnStyle.normal.texture = getGUITexture(DropDownBoxEntryNormalTex);
  532. dropDownEntryBtnStyle.hover.texture = getGUITexture(DropDownBoxEntryHoverTex);
  533. dropDownEntryBtnStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
  534. dropDownEntryBtnStyle.fixedHeight = true;
  535. dropDownEntryBtnStyle.fixedWidth = false;
  536. dropDownEntryBtnStyle.height = 14;
  537. dropDownEntryBtnStyle.width = 30;
  538. dropDownEntryBtnStyle.border.left = 1;
  539. dropDownEntryBtnStyle.border.right = 1;
  540. dropDownEntryBtnStyle.border.top = 1;
  541. dropDownEntryBtnStyle.border.bottom = 1;
  542. dropDownEntryBtnStyle.font = font;
  543. dropDownEntryBtnStyle.fontSize = DefaultFontSize;
  544. dropDownEntryBtnStyle.textHorzAlign = THA_Left;
  545. dropDownEntryBtnStyle.textVertAlign = TVA_Top;
  546. mSkin.setStyle("ListBoxEntryBtn", dropDownEntryBtnStyle);
  547. mSkin.setStyle("MenuBarEntryBtn", dropDownEntryBtnStyle);
  548. mSkin.setStyle("ContextMenuEntryBtn", dropDownEntryBtnStyle);
  549. // DropDown entry button with expand
  550. GUIElementStyle dropDownEntryExpBtnStyle;
  551. dropDownEntryExpBtnStyle.normal.texture = getGUITexture(DropDownBoxEntryExpNormalTex);
  552. dropDownEntryExpBtnStyle.hover.texture = getGUITexture(DropDownBoxEntryExpHoverTex);
  553. dropDownEntryExpBtnStyle.active.texture = dropDownEntryExpBtnStyle.hover.texture;
  554. dropDownEntryExpBtnStyle.fixedHeight = true;
  555. dropDownEntryExpBtnStyle.fixedWidth = false;
  556. dropDownEntryExpBtnStyle.height = 14;
  557. dropDownEntryExpBtnStyle.width = 30;
  558. dropDownEntryExpBtnStyle.border.left = 1;
  559. dropDownEntryExpBtnStyle.border.right = 6;
  560. dropDownEntryExpBtnStyle.border.top = 1;
  561. dropDownEntryExpBtnStyle.border.bottom = 1;
  562. dropDownEntryExpBtnStyle.font = font;
  563. dropDownEntryExpBtnStyle.fontSize = DefaultFontSize;
  564. dropDownEntryExpBtnStyle.textHorzAlign = THA_Left;
  565. dropDownEntryExpBtnStyle.textVertAlign = TVA_Top;
  566. mSkin.setStyle("ListBoxEntryExpBtn", dropDownEntryExpBtnStyle);
  567. mSkin.setStyle("MenuBarEntryExpBtn", dropDownEntryExpBtnStyle);
  568. mSkin.setStyle("ContextMenuEntryExpBtn", dropDownEntryExpBtnStyle);
  569. // DropDown box frame
  570. GUIElementStyle dropDownBoxStyle;
  571. dropDownBoxStyle.normal.texture = getGUITexture(DropDownBoxBgTex);
  572. dropDownBoxStyle.hover.texture = dropDownEntryBtnStyle.normal.texture;
  573. dropDownBoxStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
  574. dropDownBoxStyle.fixedHeight = false;
  575. dropDownBoxStyle.fixedWidth = false;
  576. dropDownBoxStyle.border.left = 1;
  577. dropDownBoxStyle.border.right = 1;
  578. dropDownBoxStyle.border.top = 1;
  579. dropDownBoxStyle.border.bottom = 1;
  580. dropDownBoxStyle.margins.left = 1;
  581. dropDownBoxStyle.margins.right = 1;
  582. dropDownBoxStyle.margins.top = 1;
  583. dropDownBoxStyle.margins.bottom = 1;
  584. mSkin.setStyle("ListBoxFrame", dropDownBoxStyle);
  585. mSkin.setStyle("MenuBarFrame", dropDownBoxStyle);
  586. mSkin.setStyle("ContextMenuFrame", dropDownBoxStyle);
  587. // Drop down separator
  588. GUIElementStyle dropDownSeparatorStyle;
  589. dropDownSeparatorStyle.normal.texture = getGUITexture(DropDownSeparatorTex);
  590. dropDownSeparatorStyle.fixedHeight = true;
  591. dropDownSeparatorStyle.fixedWidth = false;
  592. dropDownSeparatorStyle.height = 3;
  593. dropDownSeparatorStyle.width = 30;
  594. dropDownSeparatorStyle.border.left = 1;
  595. dropDownSeparatorStyle.border.right = 1;
  596. dropDownSeparatorStyle.border.top = 1;
  597. dropDownSeparatorStyle.border.bottom = 1;
  598. mSkin.setStyle("ListBoxSeparator", dropDownSeparatorStyle);
  599. mSkin.setStyle("MenuBarSeparator", dropDownSeparatorStyle);
  600. mSkin.setStyle("ContextMenuSeparator", dropDownSeparatorStyle);
  601. /************************************************************************/
  602. /* MENU BAR */
  603. /************************************************************************/
  604. // MenuBar background
  605. GUIElementStyle menuBarBgStyle;
  606. menuBarBgStyle.normal.texture = getGUITexture(MenuBarBgTex);
  607. menuBarBgStyle.fixedHeight = false;
  608. menuBarBgStyle.fixedWidth = false;
  609. menuBarBgStyle.height = 4;
  610. menuBarBgStyle.width = 4;
  611. mSkin.setStyle("MenuBarBg", menuBarBgStyle);
  612. // MenuBar Banshee logo
  613. GUIElementStyle menuBarBansheeLogoStyle;
  614. menuBarBansheeLogoStyle.normal.texture = getGUITexture(MenuBarBansheeLogoTex);
  615. menuBarBansheeLogoStyle.fixedHeight = true;
  616. menuBarBansheeLogoStyle.fixedWidth = true;
  617. menuBarBansheeLogoStyle.height = 7;
  618. menuBarBansheeLogoStyle.width = 51;
  619. mSkin.setStyle("MenuBarBansheeLogo", menuBarBansheeLogoStyle);
  620. // MenuBar button
  621. GUIElementStyle menuBarBtnStyle;
  622. menuBarBtnStyle.normal.texture = getGUITexture(MenuBarBtnNormalTex);
  623. menuBarBtnStyle.hover.texture = getGUITexture(MenuBarBtnHoverTex);
  624. menuBarBtnStyle.active.texture = menuBarBtnStyle.hover.texture;
  625. menuBarBtnStyle.normalOn.texture = menuBarBtnStyle.hover.texture;
  626. menuBarBtnStyle.hoverOn.texture = menuBarBtnStyle.hover.texture;
  627. menuBarBtnStyle.activeOn.texture = menuBarBtnStyle.hover.texture;
  628. menuBarBtnStyle.fixedHeight = true;
  629. menuBarBtnStyle.fixedWidth = false;
  630. menuBarBtnStyle.height = 15;
  631. menuBarBtnStyle.width = 4;
  632. menuBarBtnStyle.margins.left = 2;
  633. menuBarBtnStyle.margins.right = 2;
  634. menuBarBtnStyle.margins.top = 2;
  635. menuBarBtnStyle.margins.bottom = 2;
  636. menuBarBtnStyle.font = font;
  637. menuBarBtnStyle.fontSize = DefaultFontSize;
  638. menuBarBtnStyle.textHorzAlign = THA_Left;
  639. menuBarBtnStyle.textVertAlign = TVA_Top;
  640. mSkin.setStyle("MenuBarBtn", menuBarBtnStyle);
  641. /************************************************************************/
  642. /* DOCK SLIDER */
  643. /************************************************************************/
  644. GUIElementStyle dockSliderBtnStyle;
  645. dockSliderBtnStyle.normal.texture = getGUITexture(DockSliderNormalTex);
  646. dockSliderBtnStyle.fixedHeight = false;
  647. dockSliderBtnStyle.fixedWidth = false;
  648. dockSliderBtnStyle.height = 2;
  649. dockSliderBtnStyle.width = 2;
  650. mSkin.setStyle("DockSliderBtn", dockSliderBtnStyle);
  651. /************************************************************************/
  652. /* TREE VIEW */
  653. /************************************************************************/
  654. // Expand button
  655. GUIElementStyle treeViewExpandButtonStyle;
  656. treeViewExpandButtonStyle.normal.texture = getGUITexture(TreeViewExpandButtonOffNormal);
  657. treeViewExpandButtonStyle.hover.texture = getGUITexture(TreeViewExpandButtonOffHover);
  658. treeViewExpandButtonStyle.active.texture = treeViewExpandButtonStyle.hover.texture;
  659. treeViewExpandButtonStyle.normalOn.texture = getGUITexture(TreeViewExpandButtonOnNormal);
  660. treeViewExpandButtonStyle.hoverOn.texture = getGUITexture(TreeViewExpandButtonOnHover);
  661. treeViewExpandButtonStyle.activeOn.texture = treeViewExpandButtonStyle.hoverOn.texture;
  662. treeViewExpandButtonStyle.margins.left = 4;
  663. treeViewExpandButtonStyle.margins.right = 4;
  664. treeViewExpandButtonStyle.margins.top = 5;
  665. treeViewExpandButtonStyle.margins.bottom = 4;
  666. treeViewExpandButtonStyle.fixedHeight = true;
  667. treeViewExpandButtonStyle.fixedWidth = true;
  668. treeViewExpandButtonStyle.height = 16;
  669. treeViewExpandButtonStyle.width = 16;
  670. mSkin.setStyle("TreeViewFoldoutBtn", treeViewExpandButtonStyle);
  671. // Entry
  672. GUIElementStyle treeViewEntryStyle;
  673. treeViewEntryStyle.font = font;
  674. treeViewEntryStyle.fontSize = DefaultFontSize;
  675. treeViewEntryStyle.fixedWidth = false;
  676. treeViewEntryStyle.fixedHeight = true;
  677. treeViewEntryStyle.height = 16;
  678. treeViewEntryStyle.minWidth = 10;
  679. mSkin.setStyle("TreeViewElementBtn", treeViewEntryStyle);
  680. // Selection background
  681. GUIElementStyle treeViewSelBackgroundStyle;
  682. treeViewSelBackgroundStyle.normal.texture = getGUITexture(TreeViewSelectionBackground);
  683. treeViewSelBackgroundStyle.fixedHeight = false;
  684. treeViewSelBackgroundStyle.fixedWidth = false;
  685. treeViewSelBackgroundStyle.height = 2;
  686. treeViewSelBackgroundStyle.width = 2;
  687. mSkin.setStyle("TreeViewSelectionBackground", treeViewSelBackgroundStyle);
  688. // Edit box
  689. GUIElementStyle treeViewEditBox;
  690. treeViewEditBox.normal.texture = getGUITexture(TreeViewEditBox);
  691. treeViewEditBox.hover.texture = treeViewEditBox.normal.texture;
  692. treeViewEditBox.focused.texture = treeViewEditBox.normal.texture;
  693. treeViewEditBox.active.texture = treeViewEditBox.normal.texture;
  694. treeViewEditBox.border.left = 1;
  695. treeViewEditBox.border.right = 1;
  696. treeViewEditBox.border.top = 1;
  697. treeViewEditBox.border.bottom = 1;
  698. treeViewEditBox.margins.left = 1;
  699. treeViewEditBox.margins.right = 1;
  700. treeViewEditBox.margins.top = 1;
  701. treeViewEditBox.margins.bottom = 1;
  702. treeViewEditBox.fixedHeight = true;
  703. treeViewEditBox.height = 13;
  704. treeViewEditBox.minWidth = 10;
  705. treeViewEditBox.font = font;
  706. treeViewEditBox.fontSize = DefaultFontSize;
  707. treeViewEditBox.textHorzAlign = THA_Left;
  708. treeViewEditBox.textVertAlign = TVA_Top;
  709. mSkin.setStyle(GUITreeViewEditBox::getGUITypeName(), treeViewEditBox);
  710. // Element highlight
  711. GUIElementStyle treeViewElementHighlight;
  712. treeViewElementHighlight.normal.texture = getGUITexture(TreeViewElementHighlight);
  713. treeViewElementHighlight.border.left = 1;
  714. treeViewElementHighlight.border.right = 1;
  715. treeViewElementHighlight.border.top = 1;
  716. treeViewElementHighlight.border.bottom = 1;
  717. mSkin.setStyle("TreeViewElementHighlight", treeViewElementHighlight);
  718. // Element separator highlight
  719. GUIElementStyle treeViewElementSepHighlight;
  720. treeViewElementSepHighlight.normal.texture = getGUITexture(TreeViewElementSepHighlight);
  721. treeViewElementSepHighlight.border.left = 1;
  722. treeViewElementSepHighlight.border.right = 1;
  723. treeViewElementSepHighlight.border.top = 1;
  724. treeViewElementSepHighlight.border.bottom = 1;
  725. mSkin.setStyle("TreeViewElementSepHighlight", treeViewElementSepHighlight);
  726. /************************************************************************/
  727. /* OBJECT DROP FIELD */
  728. /************************************************************************/
  729. GUIElementStyle objectDropStyle;
  730. objectDropStyle.normal.texture = getGUITexture(ObjectDropBtnNormalTex);
  731. objectDropStyle.normalOn.texture = getGUITexture(ObjectDropBtnNormalOnTex);
  732. objectDropStyle.fixedHeight = true;
  733. objectDropStyle.height = 15;
  734. objectDropStyle.minWidth = 50;
  735. objectDropStyle.font = font;
  736. objectDropStyle.fontSize = DefaultFontSize;
  737. objectDropStyle.textHorzAlign = THA_Center;
  738. objectDropStyle.textVertAlign = TVA_Center;
  739. mSkin.setStyle(ObjectFieldDropBtnStyleName, objectDropStyle);
  740. GUIElementStyle objectClearBtnStyle;
  741. objectClearBtnStyle.normal.texture = getGUITexture(ObjectClearBtnNormalTex);
  742. objectClearBtnStyle.hover.texture = getGUITexture(ObjectClearBtnHoverTex);
  743. objectClearBtnStyle.active.texture = getGUITexture(ObjectClearBtnActiveTex);
  744. objectClearBtnStyle.fixedHeight = true;
  745. objectClearBtnStyle.fixedWidth = true;
  746. objectClearBtnStyle.height = 15;
  747. objectClearBtnStyle.width = 13;
  748. mSkin.setStyle(ObjectFieldClearBtnStyleName, objectClearBtnStyle);
  749. GUIElementStyle editorObjectFieldStyle;
  750. editorObjectFieldStyle.fixedHeight = true;
  751. editorObjectFieldStyle.height = 15;
  752. editorObjectFieldStyle.minWidth = 30;
  753. editorObjectFieldStyle.subStyles[ObjectFieldLabelStyleName] = GUITextField::getLabelStyleType();
  754. editorObjectFieldStyle.subStyles[ObjectFieldDropBtnStyleName] = ObjectFieldDropBtnStyleName;
  755. editorObjectFieldStyle.subStyles[ObjectFieldClearBtnStyleName] = ObjectFieldClearBtnStyleName;
  756. mSkin.setStyle(ObjectFieldStyleName, editorObjectFieldStyle);
  757. /************************************************************************/
  758. /* EDITOR FIELDS */
  759. /************************************************************************/
  760. GUIElementStyle editorFieldLabelStyle;
  761. editorFieldLabelStyle.font = font;
  762. editorFieldLabelStyle.fontSize = DefaultFontSize;
  763. editorFieldLabelStyle.fixedWidth = false;
  764. editorFieldLabelStyle.fixedHeight = true;
  765. editorFieldLabelStyle.height = 11;
  766. editorFieldLabelStyle.minWidth = 10;
  767. editorFieldLabelStyle.textHorzAlign = THA_Left;
  768. mSkin.setStyle(GUITextField::getLabelStyleType(), editorFieldLabelStyle);
  769. GUIElementStyle editorIntFieldStyle;
  770. editorIntFieldStyle.fixedHeight = true;
  771. editorIntFieldStyle.height = 15;
  772. editorIntFieldStyle.minWidth = 30;
  773. editorIntFieldStyle.subStyles[GUIIntField::getLabelStyleType()] = GUITextField::getLabelStyleType();
  774. editorIntFieldStyle.subStyles[GUIIntField::getInputStyleType()] = GUIInputBox::getGUITypeName();
  775. mSkin.setStyle(GUIIntField::getGUITypeName(), editorIntFieldStyle);
  776. GUIElementStyle editorFloatFieldStyle;
  777. editorFloatFieldStyle.fixedHeight = true;
  778. editorFloatFieldStyle.height = 15;
  779. editorFloatFieldStyle.minWidth = 30;
  780. editorFloatFieldStyle.subStyles[GUIFloatField::getLabelStyleType()] = GUITextField::getLabelStyleType();
  781. editorFloatFieldStyle.subStyles[GUIFloatField::getInputStyleType()] = GUIInputBox::getGUITypeName();
  782. mSkin.setStyle(GUIFloatField::getGUITypeName(), editorFloatFieldStyle);
  783. GUIElementStyle editorTextFieldStyle;
  784. editorTextFieldStyle.fixedHeight = true;
  785. editorTextFieldStyle.height = 15;
  786. editorTextFieldStyle.minWidth = 30;
  787. editorTextFieldStyle.subStyles[GUITextField::getLabelStyleType()] = GUITextField::getLabelStyleType();
  788. editorTextFieldStyle.subStyles[GUITextField::getInputStyleType()] = GUIInputBox::getGUITypeName();
  789. mSkin.setStyle(GUITextField::getGUITypeName(), editorTextFieldStyle);
  790. GUIElementStyle editorColorFieldStyle;
  791. editorColorFieldStyle.fixedHeight = true;
  792. editorColorFieldStyle.height = 15;
  793. editorColorFieldStyle.minWidth = 30;
  794. editorColorFieldStyle.subStyles[GUIColorField::getLabelStyleType()] = GUITextField::getLabelStyleType();
  795. editorColorFieldStyle.subStyles[GUIColorField::getColorInputStyleType()] = GUIColor::getGUITypeName();
  796. mSkin.setStyle(GUIColorField::getGUITypeName(), editorColorFieldStyle);
  797. GUIElementStyle editorToggleFieldStyle;
  798. editorToggleFieldStyle.fixedHeight = true;
  799. editorToggleFieldStyle.height = 15;
  800. editorToggleFieldStyle.minWidth = 30;
  801. editorToggleFieldStyle.subStyles[GUIToggleField::getLabelStyleType()] = GUITextField::getLabelStyleType();
  802. editorToggleFieldStyle.subStyles[GUIToggleField::getToggleStyleType()] = GUIToggle::getGUITypeName();
  803. mSkin.setStyle(GUIToggleField::getGUITypeName(), editorToggleFieldStyle);
  804. GUIElementStyle editorVector2FieldStyle;
  805. editorVector2FieldStyle.fixedHeight = true;
  806. editorVector2FieldStyle.height = 30;
  807. editorVector2FieldStyle.minWidth = 30;
  808. editorVector2FieldStyle.subStyles[GUIVector2Field::getLabelStyleType()] = GUITextField::getLabelStyleType();
  809. editorVector2FieldStyle.subStyles[GUIVector2Field::getFloatFieldStyleType()] = GUIFloatField::getGUITypeName();
  810. mSkin.setStyle(GUIVector2Field::getGUITypeName(), editorVector2FieldStyle);
  811. GUIElementStyle editorVector3FieldStyle;
  812. editorVector3FieldStyle.fixedHeight = true;
  813. editorVector3FieldStyle.height = 30;
  814. editorVector3FieldStyle.minWidth = 30;
  815. editorVector3FieldStyle.subStyles[GUIVector3Field::getLabelStyleType()] = GUITextField::getLabelStyleType();
  816. editorVector3FieldStyle.subStyles[GUIVector3Field::getFloatFieldStyleType()] = GUIFloatField::getGUITypeName();
  817. mSkin.setStyle(GUIVector3Field::getGUITypeName(), editorVector3FieldStyle);
  818. GUIElementStyle editorVector4FieldStyle;
  819. editorVector4FieldStyle.fixedHeight = true;
  820. editorVector4FieldStyle.height = 30;
  821. editorVector4FieldStyle.minWidth = 30;
  822. editorVector4FieldStyle.subStyles[GUIVector4Field::getLabelStyleType()] = GUITextField::getLabelStyleType();
  823. editorVector4FieldStyle.subStyles[GUIVector4Field::getFloatFieldStyleType()] = GUIFloatField::getGUITypeName();
  824. mSkin.setStyle(GUIVector4Field::getGUITypeName(), editorVector4FieldStyle);
  825. /************************************************************************/
  826. /* COMPONENT FOLDOUT */
  827. /************************************************************************/
  828. GUIElementStyle cmpFoldoutBtnStyle;
  829. cmpFoldoutBtnStyle.normal.texture = getGUITexture(CmpFoldoutClosedNormalTex);
  830. cmpFoldoutBtnStyle.hover.texture = getGUITexture(CmpFoldoutClosedHoverTex);
  831. cmpFoldoutBtnStyle.active.texture = getGUITexture(CmpFoldoutOpenActiveTex);
  832. cmpFoldoutBtnStyle.normalOn.texture = getGUITexture(CmpFoldoutOpenNormalTex);
  833. cmpFoldoutBtnStyle.hoverOn.texture = getGUITexture(CmpFoldoutOpenHoverTex);
  834. cmpFoldoutBtnStyle.activeOn.texture = getGUITexture(CmpFoldoutOpenActiveTex);
  835. cmpFoldoutBtnStyle.fixedHeight = true;
  836. cmpFoldoutBtnStyle.fixedWidth = false;
  837. cmpFoldoutBtnStyle.height = 10;
  838. cmpFoldoutBtnStyle.minWidth = 10;
  839. cmpFoldoutBtnStyle.font = font;
  840. cmpFoldoutBtnStyle.fontSize = DefaultFontSize;
  841. cmpFoldoutBtnStyle.textHorzAlign = THA_Left;
  842. cmpFoldoutBtnStyle.textVertAlign = TVA_Center;
  843. cmpFoldoutBtnStyle.contentOffset = RectOffset(12, 0, 0, 0);
  844. cmpFoldoutBtnStyle.border.left = 8;
  845. mSkin.setStyle(GUIComponentFoldout::getFoldoutButtonStyleType(), cmpFoldoutBtnStyle);
  846. GUIElementStyle cmpFoldoutStyle;
  847. cmpFoldoutStyle.fixedHeight = true;
  848. cmpFoldoutStyle.height = 12;
  849. cmpFoldoutStyle.minWidth = 30;
  850. cmpFoldoutStyle.subStyles[GUIComponentFoldout::getFoldoutButtonStyleType()] = GUIComponentFoldout::getFoldoutButtonStyleType();
  851. mSkin.setStyle(GUIComponentFoldout::getGUITypeName(), cmpFoldoutStyle);
  852. /************************************************************************/
  853. /* FOLDOUT */
  854. /************************************************************************/
  855. GUIElementStyle foldoutBtnStyle;
  856. foldoutBtnStyle.normal.texture = getGUITexture(FoldoutClosedNormalTex);
  857. foldoutBtnStyle.hover.texture = getGUITexture(FoldoutClosedHoverTex);
  858. foldoutBtnStyle.active.texture = foldoutBtnStyle.hover.texture;
  859. foldoutBtnStyle.normalOn.texture = getGUITexture(FoldoutOpenNormalTex);
  860. foldoutBtnStyle.hoverOn.texture = getGUITexture(FoldoutOpenHoverTex);
  861. foldoutBtnStyle.activeOn.texture = foldoutBtnStyle.hoverOn.texture;
  862. foldoutBtnStyle.fixedHeight = true;
  863. foldoutBtnStyle.fixedWidth = true;
  864. foldoutBtnStyle.height = 10;
  865. foldoutBtnStyle.width = 8;
  866. mSkin.setStyle(GUIFoldout::getFoldoutButtonStyleType(), foldoutBtnStyle);
  867. GUIElementStyle foldoutStyle;
  868. foldoutStyle.fixedHeight = true;
  869. foldoutStyle.height = 12;
  870. foldoutStyle.minWidth = 30;
  871. foldoutStyle.subStyles[GUIFoldout::getLabelStyleType()] = GUIFoldout::getLabelStyleType();
  872. foldoutStyle.subStyles[GUIFoldout::getFoldoutButtonStyleType()] = GUIFoldout::getFoldoutButtonStyleType();
  873. mSkin.setStyle(GUIFoldout::getGUITypeName(), foldoutStyle);
  874. }
  875. void BuiltinEditorResources::preprocess()
  876. {
  877. static const WString GUI_TEXTURES[] =
  878. { WindowBackgroundTexture, ButtonNormalTex, ButtonHoverTex, ButtonActiveTex, ToggleNormalTex,
  879. ToggleHoverTex, ToggleActiveTex, ToggleNormalOnTex, ToggleHoverOnTex, ToggleActiveOnTex,
  880. ObjectDropBtnNormalTex, ObjectDropBtnNormalOnTex, ObjectClearBtnNormalTex, ObjectClearBtnHoverTex,
  881. ObjectClearBtnActiveTex, FoldoutOpenNormalTex, FoldoutOpenHoverTex, FoldoutClosedNormalTex,
  882. FoldoutClosedHoverTex, CmpFoldoutOpenNormalTex, CmpFoldoutOpenHoverTex, CmpFoldoutOpenActiveTex,
  883. CmpFoldoutClosedNormalTex, CmpFoldoutClosedHoverTex, CmpFoldoutClosedActiveTex, WindowFrameNormal,
  884. WindowFrameFocused, WindowTitleBarBg, WindowCloseButtonNormal, WindowCloseButtonHover, WindowMinButtonNormal,
  885. WindowMinButtonHover, WindowMaxButtonNormal, WindowMaxButtonHover, TabbedBarBtnNormal, TabbedBarBtnActive,
  886. InputBoxNormalTex, InputBoxHoverTex, InputBoxFocusedTex, ScrollBarUpNormalTex, ScrollBarUpHoverTex,
  887. ScrollBarUpActiveTex, ScrollBarDownNormalTex, ScrollBarDownHoverTex, ScrollBarDownActiveTex, ScrollBarLeftNormalTex,
  888. ScrollBarLeftHoverTex, ScrollBarLeftActiveTex, ScrollBarRightNormalTex, ScrollBarRightHoverTex, ScrollBarRightActiveTex,
  889. ScrollBarHandleHorzNormalTex, ScrollBarHandleHorzHoverTex, ScrollBarHandleHorzActiveTex, ScrollBarHandleVertNormalTex,
  890. ScrollBarHandleVertHoverTex, ScrollBarHandleVertActiveTex, DropDownBtnNormalTex, DropDownBtnHoverTex,
  891. DropDownBoxBgTex, DropDownBoxEntryNormalTex, DropDownBoxEntryHoverTex, DropDownBoxBtnUpNormalTex,
  892. DropDownBoxBtnUpHoverTex, DropDownBoxBtnDownNormalTex, DropDownBoxBtnDownHoverTex, DropDownBoxEntryExpNormalTex,
  893. DropDownBoxEntryExpHoverTex, DropDownSeparatorTex, DropDownBoxBtnUpArrowTex, DropDownBoxBtnDownArrowTex,
  894. ScrollBarBgTex, MenuBarBgTex, MenuBarBtnNormalTex, MenuBarBtnHoverTex, MenuBarBansheeLogoTex, DockSliderNormalTex,
  895. TreeViewExpandButtonOffNormal, TreeViewExpandButtonOffHover, TreeViewExpandButtonOnNormal, TreeViewExpandButtonOnHover,
  896. TreeViewSelectionBackground, TreeViewEditBox, TreeViewElementHighlight, TreeViewElementSepHighlight };
  897. static const GpuProgramImportData GPU_PROGRAM_IMPORT_DATA[] =
  898. {
  899. { SceneGridVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  900. { SceneGridPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  901. { ShaderDockOverlayVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  902. { ShaderDockOverlayPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  903. { PickingVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  904. { PickingPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  905. { PickingAlphaVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  906. { PickingAlphaPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  907. { ShaderWireGizmoVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  908. { ShaderWireGizmoPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  909. { ShaderSolidGizmoVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  910. { ShaderSolidGizmoPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  911. { ShaderIconGizmo0VSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  912. { ShaderIconGizmo0PSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  913. { ShaderIconGizmo1VSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  914. { ShaderIconGizmo1PSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  915. { GizmoPickingVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  916. { GizmoPickingPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  917. { GizmoPickingAlphaVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
  918. { GizmoPickingAlphaPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
  919. { SceneGridVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_2_0, "hlsl", HLSL9ShaderSubFolder },
  920. { SceneGridPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_2_0, "hlsl", HLSL9ShaderSubFolder },
  921. { ShaderDockOverlayVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_2_0, "hlsl", HLSL9ShaderSubFolder },
  922. { ShaderDockOverlayPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_2_0, "hlsl", HLSL9ShaderSubFolder },
  923. { PickingVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  924. { PickingPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  925. { PickingAlphaVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  926. { PickingAlphaPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  927. { ShaderWireGizmoVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  928. { ShaderWireGizmoPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  929. { ShaderSolidGizmoVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  930. { ShaderSolidGizmoPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  931. { ShaderIconGizmo0VSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  932. { ShaderIconGizmo0PSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  933. { ShaderIconGizmo1VSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  934. { ShaderIconGizmo1PSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  935. { GizmoPickingVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  936. { GizmoPickingPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  937. { GizmoPickingAlphaVSFile, "vs_main", GPT_VERTEX_PROGRAM, GPP_VS_3_0, "hlsl", HLSL9ShaderSubFolder },
  938. { GizmoPickingAlphaPSFile, "ps_main", GPT_FRAGMENT_PROGRAM, GPP_FS_3_0, "hlsl", HLSL9ShaderSubFolder },
  939. { SceneGridVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  940. { SceneGridPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  941. { ShaderDockOverlayVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  942. { ShaderDockOverlayPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  943. { PickingVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  944. { PickingPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  945. { PickingAlphaVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  946. { PickingAlphaPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  947. { ShaderWireGizmoVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  948. { ShaderWireGizmoPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  949. { ShaderSolidGizmoVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  950. { ShaderSolidGizmoPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  951. { ShaderIconGizmo0VSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  952. { ShaderIconGizmo0PSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  953. { ShaderIconGizmo1VSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  954. { ShaderIconGizmo1PSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  955. { GizmoPickingVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  956. { GizmoPickingPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  957. { GizmoPickingAlphaVSFile, "main", GPT_VERTEX_PROGRAM, GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
  958. { GizmoPickingAlphaPSFile, "main", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
  959. };
  960. if (FileSystem::exists(DefaultSkinFolderRaw))
  961. {
  962. FileSystem::remove(DefaultSkinFolder);
  963. for (auto& tex : GUI_TEXTURES)
  964. importGUITexture(tex);
  965. {
  966. Path fontPath = FileSystem::getWorkingDirectoryPath();
  967. fontPath.append(DefaultSkinFolderRaw);
  968. fontPath.append(DefaultFontFilename);
  969. ImportOptionsPtr fontImportOptions = Importer::instance().createImportOptions(fontPath);
  970. if (rtti_is_of_type<FontImportOptions>(fontImportOptions))
  971. {
  972. FontImportOptions* importOptions = static_cast<FontImportOptions*>(fontImportOptions.get());
  973. Vector<UINT32> fontSizes;
  974. fontSizes.push_back(DefaultFontSize);
  975. importOptions->setFontSizes(fontSizes);
  976. importOptions->setAntialiasing(false);
  977. }
  978. HFont font = Importer::instance().import<Font>(fontPath, fontImportOptions);
  979. Path outputPath = FileSystem::getWorkingDirectoryPath();
  980. outputPath.append(DefaultSkinFolder);
  981. outputPath.append(DefaultFontFilename + L".asset");
  982. Resources::instance().save(font, outputPath, true);
  983. // Save font texture pages as well. TODO - Later maybe figure out a more automatic way to do this
  984. const FontData* fontData = font->getFontDataForSize(DefaultFontSize);
  985. Path texPageOutputPath = FileSystem::getWorkingDirectoryPath();
  986. texPageOutputPath.append(DefaultSkinFolder);
  987. UINT32 pageIdx = 0;
  988. for (auto tex : fontData->texturePages)
  989. {
  990. texPageOutputPath.setFilename(DefaultFontFilename + L"_texpage_" + toWString(pageIdx) + L".asset");
  991. Resources::instance().save(tex, texPageOutputPath, true);
  992. }
  993. }
  994. }
  995. if (FileSystem::exists(DefaultShaderFolderRaw))
  996. {
  997. Path shaderFolder = DefaultShaderFolder;
  998. shaderFolder.append(mActiveShaderSubFolder);
  999. FileSystem::remove(shaderFolder);
  1000. for (auto& importData : GPU_PROGRAM_IMPORT_DATA)
  1001. {
  1002. if (importData.folder != mActiveShaderSubFolder)
  1003. continue;
  1004. Path gpuProgInputLoc = DefaultShaderFolderRaw;
  1005. gpuProgInputLoc.append(importData.folder);
  1006. gpuProgInputLoc.append(importData.filename);
  1007. Path gpuProgOutputLoc = DefaultShaderFolder;
  1008. gpuProgOutputLoc.append(importData.folder);
  1009. gpuProgOutputLoc.append(importData.filename + L".asset");
  1010. ImportOptionsPtr gpuProgImportOptions = Importer::instance().createImportOptions(gpuProgInputLoc);
  1011. if (rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
  1012. {
  1013. GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
  1014. importOptions->setEntryPoint(importData.entryPoint);
  1015. importOptions->setLanguage(importData.language);
  1016. importOptions->setProfile(importData.profile);
  1017. importOptions->setType(importData.type);
  1018. }
  1019. HGpuProgram gpuProgram = Importer::instance().import<GpuProgram>(gpuProgInputLoc, gpuProgImportOptions);
  1020. Resources::instance().save(gpuProgram, gpuProgOutputLoc, true);
  1021. }
  1022. }
  1023. Resources::instance().unloadAllUnused();
  1024. }
  1025. void BuiltinEditorResources::importGUITexture(const WString& name)
  1026. {
  1027. Path texturePath = FileSystem::getWorkingDirectoryPath();
  1028. texturePath.append(DefaultSkinFolderRaw);
  1029. texturePath.append(name);
  1030. Path texOutputPath = FileSystem::getWorkingDirectoryPath();
  1031. texOutputPath.append(DefaultSkinFolder);
  1032. Path spriteTexOutputPath = texOutputPath;
  1033. texOutputPath.append(name + L".asset");
  1034. spriteTexOutputPath.append(L"sprite_" + name + L".asset");
  1035. HTexture tex = Importer::instance().import<Texture>(texturePath);
  1036. Resources::instance().save(tex, texOutputPath, true);
  1037. HSpriteTexture spriteTex = SpriteTexture::create(tex);
  1038. Resources::instance().save(spriteTex, spriteTexOutputPath, true);
  1039. }
  1040. HSpriteTexture BuiltinEditorResources::getGUITexture(const WString& name)
  1041. {
  1042. Path texturePath = FileSystem::getWorkingDirectoryPath();
  1043. texturePath.append(DefaultSkinFolder);
  1044. texturePath.append(L"sprite_" + name + L".asset");
  1045. return Resources::instance().load<SpriteTexture>(texturePath);
  1046. }
  1047. HGpuProgram BuiltinEditorResources::getGpuProgram(const WString& name)
  1048. {
  1049. Path programPath = DefaultShaderFolder;
  1050. programPath.append(mActiveShaderSubFolder);
  1051. programPath.append(name + L".asset");
  1052. return gResources().load<GpuProgram>(programPath);
  1053. }
  1054. void BuiltinEditorResources::initDockDropOverlayShader()
  1055. {
  1056. HGpuProgram vsProgram = getGpuProgram(ShaderDockOverlayVSFile);
  1057. HGpuProgram psProgram = getGpuProgram(ShaderDockOverlayPSFile);
  1058. BLEND_STATE_DESC desc;
  1059. desc.renderTargetDesc[0].blendEnable = true;
  1060. desc.renderTargetDesc[0].srcBlend = BF_SOURCE_ALPHA;
  1061. desc.renderTargetDesc[0].dstBlend = BF_INV_SOURCE_ALPHA;
  1062. desc.renderTargetDesc[0].blendOp = BO_ADD;
  1063. HBlendState blendState = BlendState::create(desc);
  1064. DEPTH_STENCIL_STATE_DESC depthStateDesc;
  1065. depthStateDesc.depthReadEnable = false;
  1066. depthStateDesc.depthWriteEnable = false;
  1067. HDepthStencilState depthState = DepthStencilState::create(depthStateDesc);
  1068. PASS_DESC passDesc;
  1069. passDesc.vertexProgram = vsProgram;
  1070. passDesc.fragmentProgram = psProgram;
  1071. passDesc.blendState = blendState;
  1072. passDesc.depthStencilState = depthState;
  1073. PassPtr newPass = Pass::create(passDesc);
  1074. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1075. SHADER_DESC shaderDesc;
  1076. shaderDesc.addParameter("invViewportWidth", "invViewportWidth", GPDT_FLOAT1);
  1077. shaderDesc.addParameter("invViewportHeight", "invViewportHeight", GPDT_FLOAT1);
  1078. shaderDesc.addParameter("tintColor", "tintColor", GPDT_FLOAT4);
  1079. shaderDesc.addParameter("highlightColor", "highlightColor", GPDT_FLOAT4);
  1080. shaderDesc.addParameter("highlightActive", "highlightActive", GPDT_FLOAT4);
  1081. mShaderDockOverlay = Shader::create("DockDropOverlayShader", shaderDesc, { newTechnique });
  1082. }
  1083. void BuiltinEditorResources::initSceneGridShader()
  1084. {
  1085. HGpuProgram vsProgram = getGpuProgram(SceneGridVSFile);
  1086. HGpuProgram psProgram = getGpuProgram(SceneGridPSFile);
  1087. BLEND_STATE_DESC blendDesc;
  1088. blendDesc.renderTargetDesc[0].blendEnable = true;
  1089. blendDesc.renderTargetDesc[0].srcBlend = BF_SOURCE_ALPHA;
  1090. blendDesc.renderTargetDesc[0].dstBlend = BF_INV_SOURCE_ALPHA;
  1091. blendDesc.renderTargetDesc[0].blendOp = BO_ADD;
  1092. blendDesc.renderTargetDesc[0].renderTargetWriteMask = 0x7; // Don't write to alpha
  1093. HBlendState blendState = BlendState::create(blendDesc);
  1094. RASTERIZER_STATE_DESC rasterizerDesc;
  1095. rasterizerDesc.cullMode = CULL_NONE;
  1096. HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);
  1097. PASS_DESC passDesc;
  1098. passDesc.vertexProgram = vsProgram;
  1099. passDesc.fragmentProgram = psProgram;
  1100. passDesc.blendState = blendState;
  1101. passDesc.rasterizerState = rasterizerState;
  1102. PassPtr newPass = Pass::create(passDesc);
  1103. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1104. SHADER_DESC shaderDesc;
  1105. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1106. mShaderSceneGrid = Shader::create("SceneGridShader", shaderDesc, { newTechnique });
  1107. }
  1108. void BuiltinEditorResources::initPickingShader(CullingMode cullMode)
  1109. {
  1110. UINT32 modeIdx = (UINT32)cullMode;
  1111. HGpuProgram vsProgram = getGpuProgram(PickingVSFile);
  1112. HGpuProgram psProgram = getGpuProgram(PickingPSFile);
  1113. RASTERIZER_STATE_DESC rasterizerDesc;
  1114. rasterizerDesc.scissorEnable = true;
  1115. rasterizerDesc.cullMode = cullMode;
  1116. HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);
  1117. PASS_DESC passDesc;
  1118. passDesc.vertexProgram = vsProgram;
  1119. passDesc.fragmentProgram = psProgram;
  1120. passDesc.rasterizerState = rasterizerState;
  1121. PassPtr newPass = Pass::create(passDesc);
  1122. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1123. SHADER_DESC shaderDesc;
  1124. shaderDesc.addParameter("colorIndex", "colorIndex", GPDT_FLOAT4);
  1125. shaderDesc.addParameter("matWorldViewProj", "matWorldViewProj", GPDT_MATRIX_4X4);
  1126. mShaderPicking[modeIdx] = Shader::create("PickingShader", shaderDesc, { newTechnique });
  1127. }
  1128. void BuiltinEditorResources::initPickingAlphaShader(CullingMode cullMode)
  1129. {
  1130. UINT32 modeIdx = (UINT32)cullMode;
  1131. HGpuProgram vsProgram = getGpuProgram(PickingAlphaVSFile);
  1132. HGpuProgram psProgram = getGpuProgram(PickingAlphaPSFile);
  1133. RASTERIZER_STATE_DESC rasterizerDesc;
  1134. rasterizerDesc.scissorEnable = true;
  1135. rasterizerDesc.cullMode = cullMode;
  1136. HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);
  1137. PASS_DESC passDesc;
  1138. passDesc.vertexProgram = vsProgram;
  1139. passDesc.fragmentProgram = psProgram;
  1140. passDesc.rasterizerState = rasterizerState;
  1141. PassPtr newPass = Pass::create(passDesc);
  1142. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1143. SHADER_DESC shaderDesc;
  1144. shaderDesc.addParameter("mainTexSamp", "mainTexSamp", GPOT_SAMPLER2D);
  1145. shaderDesc.addParameter("mainTexSamp", "mainTexture", GPOT_SAMPLER2D);
  1146. shaderDesc.addParameter("mainTexture", "mainTexture", GPOT_TEXTURE2D);
  1147. shaderDesc.addParameter("alphaCutoff", "alphaCutoff", GPDT_FLOAT1);
  1148. shaderDesc.addParameter("colorIndex", "colorIndex", GPDT_FLOAT4);
  1149. shaderDesc.addParameter("matWorldViewProj", "matWorldViewProj", GPDT_MATRIX_4X4);
  1150. mShaderPickingAlpha[modeIdx] = Shader::create("PickingAlphaShader", shaderDesc, { newTechnique });
  1151. }
  1152. void BuiltinEditorResources::initWireGizmoShader()
  1153. {
  1154. HGpuProgram vsProgram = getGpuProgram(ShaderWireGizmoVSFile);
  1155. HGpuProgram psProgram = getGpuProgram(ShaderWireGizmoPSFile);
  1156. PASS_DESC passDesc;
  1157. passDesc.vertexProgram = vsProgram;
  1158. passDesc.fragmentProgram = psProgram;
  1159. PassPtr newPass = Pass::create(passDesc);
  1160. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1161. SHADER_DESC shaderDesc;
  1162. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1163. mShaderGizmoWire = Shader::create("GizmoWire", shaderDesc, { newTechnique });
  1164. }
  1165. void BuiltinEditorResources::initSolidGizmoShader()
  1166. {
  1167. HGpuProgram vsProgram = getGpuProgram(ShaderSolidGizmoVSFile);
  1168. HGpuProgram psProgram = getGpuProgram(ShaderSolidGizmoPSFile);
  1169. PASS_DESC passDesc;
  1170. passDesc.vertexProgram = vsProgram;
  1171. passDesc.fragmentProgram = psProgram;
  1172. PassPtr newPass = Pass::create(passDesc);
  1173. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1174. SHADER_DESC shaderDesc;
  1175. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1176. mShaderGizmoSolid = Shader::create("GizmoSolid", shaderDesc, { newTechnique });
  1177. }
  1178. void BuiltinEditorResources::initWireHandleShader()
  1179. {
  1180. HGpuProgram vsProgram = getGpuProgram(ShaderWireGizmoVSFile);
  1181. HGpuProgram psProgram = getGpuProgram(ShaderWireGizmoPSFile);
  1182. DEPTH_STENCIL_STATE_DESC depthStencilStateDesc;
  1183. depthStencilStateDesc.depthWriteEnable = false;
  1184. depthStencilStateDesc.depthReadEnable = false;
  1185. HDepthStencilState depthStencilState = DepthStencilState::create(depthStencilStateDesc);
  1186. PASS_DESC passDesc;
  1187. passDesc.vertexProgram = vsProgram;
  1188. passDesc.fragmentProgram = psProgram;
  1189. passDesc.depthStencilState = depthStencilState;
  1190. PassPtr newPass = Pass::create(passDesc);
  1191. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1192. SHADER_DESC shaderDesc;
  1193. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1194. mShaderHandleWire = Shader::create("HandleWire", shaderDesc, { newTechnique });
  1195. }
  1196. void BuiltinEditorResources::initSolidHandleShader()
  1197. {
  1198. HGpuProgram vsProgram = getGpuProgram(ShaderSolidGizmoVSFile);
  1199. HGpuProgram psProgram = getGpuProgram(ShaderSolidGizmoPSFile);
  1200. DEPTH_STENCIL_STATE_DESC depthStencilStateDesc;
  1201. depthStencilStateDesc.depthWriteEnable = false;
  1202. depthStencilStateDesc.depthReadEnable = false;
  1203. HDepthStencilState depthStencilState = DepthStencilState::create(depthStencilStateDesc);
  1204. PASS_DESC passDesc;
  1205. passDesc.vertexProgram = vsProgram;
  1206. passDesc.fragmentProgram = psProgram;
  1207. passDesc.depthStencilState = depthStencilState;
  1208. PassPtr newPass = Pass::create(passDesc);
  1209. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1210. SHADER_DESC shaderDesc;
  1211. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1212. mShaderHandleSolid = Shader::create("HandleSolid", shaderDesc, { newTechnique });
  1213. }
  1214. void BuiltinEditorResources::initIconGizmoShader()
  1215. {
  1216. HGpuProgram vsProgram0 = getGpuProgram(ShaderIconGizmo0VSFile);
  1217. HGpuProgram psProgram0 = getGpuProgram(ShaderIconGizmo0PSFile);
  1218. HGpuProgram vsProgram1 = getGpuProgram(ShaderIconGizmo1VSFile);
  1219. HGpuProgram psProgram1 = getGpuProgram(ShaderIconGizmo1PSFile);
  1220. BLEND_STATE_DESC blendDesc;
  1221. blendDesc.renderTargetDesc[0].blendEnable = true;
  1222. blendDesc.renderTargetDesc[0].srcBlend = BF_SOURCE_ALPHA;
  1223. blendDesc.renderTargetDesc[0].dstBlend = BF_INV_SOURCE_ALPHA;
  1224. blendDesc.renderTargetDesc[0].blendOp = BO_ADD;
  1225. HBlendState blendState = BlendState::create(blendDesc);
  1226. DEPTH_STENCIL_STATE_DESC depthStencilState0Desc;
  1227. depthStencilState0Desc.depthWriteEnable = false;
  1228. depthStencilState0Desc.depthComparisonFunc = CMPF_LESS_EQUAL;
  1229. HDepthStencilState depthStencilState0 = DepthStencilState::create(depthStencilState0Desc);
  1230. DEPTH_STENCIL_STATE_DESC depthStencilState1Desc;
  1231. depthStencilState1Desc.depthWriteEnable = false;
  1232. depthStencilState1Desc.depthComparisonFunc = CMPF_GREATER;
  1233. HDepthStencilState depthStencilState1 = DepthStencilState::create(depthStencilState1Desc);
  1234. PASS_DESC pass0Desc;
  1235. pass0Desc.vertexProgram = vsProgram0;
  1236. pass0Desc.fragmentProgram = psProgram0;
  1237. pass0Desc.blendState = blendState;
  1238. pass0Desc.depthStencilState = depthStencilState0;
  1239. PassPtr newPass0 = Pass::create(pass0Desc);
  1240. PASS_DESC pass1Desc;
  1241. pass1Desc.vertexProgram = vsProgram1;
  1242. pass1Desc.fragmentProgram = psProgram1;
  1243. pass1Desc.blendState = blendState;
  1244. pass1Desc.depthStencilState = depthStencilState1;
  1245. PassPtr newPass1 = Pass::create(pass1Desc);
  1246. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass0, newPass1 });
  1247. SHADER_DESC shaderDesc;
  1248. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1249. shaderDesc.addParameter("mainTexSamp", "mainTexSamp", GPOT_SAMPLER2D);
  1250. shaderDesc.addParameter("mainTexSamp", "mainTexture", GPOT_SAMPLER2D);
  1251. shaderDesc.addParameter("mainTexture", "mainTexture", GPOT_TEXTURE2D);
  1252. mShaderGizmoIcon = Shader::create("GizmoIcon", shaderDesc, { newTechnique });
  1253. }
  1254. void BuiltinEditorResources::initGizmoPickingShader()
  1255. {
  1256. HGpuProgram vsProgram = getGpuProgram(GizmoPickingVSFile);
  1257. HGpuProgram psProgram = getGpuProgram(GizmoPickingPSFile);
  1258. RASTERIZER_STATE_DESC rasterizerDesc;
  1259. rasterizerDesc.scissorEnable = true;
  1260. HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);
  1261. PASS_DESC passDesc;
  1262. passDesc.vertexProgram = vsProgram;
  1263. passDesc.fragmentProgram = psProgram;
  1264. passDesc.rasterizerState = rasterizerState;
  1265. PassPtr newPass = Pass::create(passDesc);
  1266. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1267. SHADER_DESC shaderDesc;
  1268. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1269. mShaderGizmoPicking = Shader::create("GizmoPickingShader", shaderDesc, { newTechnique });
  1270. }
  1271. void BuiltinEditorResources::initGizmoPickingAlphaShader()
  1272. {
  1273. HGpuProgram vsProgram = getGpuProgram(GizmoPickingAlphaVSFile);
  1274. HGpuProgram psProgram = getGpuProgram(GizmoPickingAlphaPSFile);
  1275. RASTERIZER_STATE_DESC rasterizerDesc;
  1276. rasterizerDesc.scissorEnable = true;
  1277. HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);
  1278. PASS_DESC passDesc;
  1279. passDesc.vertexProgram = vsProgram;
  1280. passDesc.fragmentProgram = psProgram;
  1281. passDesc.rasterizerState = rasterizerState;
  1282. PassPtr newPass = Pass::create(passDesc);
  1283. TechniquePtr newTechnique = Technique::create(mActiveRenderSystem, RendererInvariant, { newPass });
  1284. SHADER_DESC shaderDesc;
  1285. shaderDesc.addParameter("mainTexSamp", "mainTexSamp", GPOT_SAMPLER2D);
  1286. shaderDesc.addParameter("mainTexSamp", "mainTexture", GPOT_SAMPLER2D);
  1287. shaderDesc.addParameter("mainTexture", "mainTexture", GPOT_TEXTURE2D);
  1288. shaderDesc.addParameter("alphaCutoff", "alphaCutoff", GPDT_FLOAT1);
  1289. shaderDesc.addParameter("matViewProj", "matViewProj", GPDT_MATRIX_4X4);
  1290. mShaderGizmoAlphaPicking = Shader::create("GizmoPickingAlphaShader", shaderDesc, { newTechnique });
  1291. }
  1292. HMaterial BuiltinEditorResources::createDockDropOverlayMaterial() const
  1293. {
  1294. return Material::create(mShaderDockOverlay);
  1295. }
  1296. HMaterial BuiltinEditorResources::createSceneGridMaterial() const
  1297. {
  1298. return Material::create(mShaderSceneGrid);
  1299. }
  1300. HMaterial BuiltinEditorResources::createPicking(CullingMode cullMode) const
  1301. {
  1302. UINT32 modeIdx = (UINT32)cullMode;
  1303. return Material::create(mShaderPicking[modeIdx]);
  1304. }
  1305. HMaterial BuiltinEditorResources::createPickingAlpha(CullingMode cullMode) const
  1306. {
  1307. UINT32 modeIdx = (UINT32)cullMode;
  1308. return Material::create(mShaderPickingAlpha[modeIdx]);
  1309. }
  1310. HMaterial BuiltinEditorResources::createWireGizmoMat() const
  1311. {
  1312. return Material::create(mShaderGizmoWire);
  1313. }
  1314. HMaterial BuiltinEditorResources::createSolidGizmoMat() const
  1315. {
  1316. return Material::create(mShaderGizmoSolid);
  1317. }
  1318. HMaterial BuiltinEditorResources::createIconGizmoMat() const
  1319. {
  1320. return Material::create(mShaderGizmoIcon);
  1321. }
  1322. HMaterial BuiltinEditorResources::createGizmoPickingMat() const
  1323. {
  1324. return Material::create(mShaderGizmoPicking);
  1325. }
  1326. HMaterial BuiltinEditorResources::createAlphaGizmoPickingMat() const
  1327. {
  1328. return Material::create(mShaderGizmoAlphaPicking);
  1329. }
  1330. HMaterial BuiltinEditorResources::createWireHandleMat() const
  1331. {
  1332. return Material::create(mShaderHandleWire);
  1333. }
  1334. HMaterial BuiltinEditorResources::createSolidHandleMat() const
  1335. {
  1336. return Material::create(mShaderHandleSolid);
  1337. }
  1338. }