Larington

Untitled

Jan 17th, 2012
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.40 KB | None | 0 0
  1. Text below exists in [project_name]/game/art/gui/playgui.gui
  2.  
  3. In playgui I've placed the hexgrid creation code at the bottom, the gui widget first part of this file defines the look of the gui in gameplay, and contains the code for a widget that creates the hex grid.
  4.  
  5. Do not delete "//--- OBJECT WRITE END ---" from the end of the GUI widget creation code, as T3D can sometimes delete any functions you've placed below that point (Like I have in this file) when you re-save the GUI file whilst making edits in T3D itself.
  6.  
  7. The gui widget code starts at the line "new GuiBitmapCtrl(HexGeneratorTool)"
  8.  
  9. //--- OBJECT WRITE BEGIN ---
  10. %guiContent = new GameTSCtrl(PlayGui) {
  11. cameraZRot = "0";
  12. forceFOV = "0";
  13. reflectPriority = "1";
  14. margin = "0 0 0 0";
  15. padding = "0 0 0 0";
  16. anchorTop = "1";
  17. anchorBottom = "0";
  18. anchorLeft = "1";
  19. anchorRight = "0";
  20. position = "0 0";
  21. extent = "1024 768";
  22. minExtent = "8 8";
  23. horizSizing = "right";
  24. vertSizing = "bottom";
  25. profile = "GuiContentProfile";
  26. visible = "1";
  27. active = "1";
  28. tooltipProfile = "GuiToolTipProfile";
  29. hovertime = "1000";
  30. isContainer = "1";
  31. canSave = "1";
  32. canSaveDynamicFields = "1";
  33. enabled = "1";
  34. helpTag = "0";
  35. noCursor = "1";
  36.  
  37. new GuiShapeNameHud() {
  38. fillColor = "0 0 0 0.25";
  39. frameColor = "0 1 0 1";
  40. textColor = "0 1 0 1";
  41. showFill = "0";
  42. showFrame = "0";
  43. verticalOffset = "0.2";
  44. distanceFade = "0.1";
  45. position = "0 0";
  46. extent = "1024 768";
  47. minExtent = "8 8";
  48. horizSizing = "width";
  49. vertSizing = "height";
  50. profile = "GuiModelessDialogProfile";
  51. visible = "1";
  52. active = "1";
  53. tooltipProfile = "GuiToolTipProfile";
  54. hovertime = "1000";
  55. isContainer = "0";
  56. canSave = "1";
  57. canSaveDynamicFields = "0";
  58. };
  59. new GuiBitmapCtrl(centerPrintDlg) {
  60. bitmap = "art/gui/hudfill.png";
  61. wrap = "0";
  62. position = "237 374";
  63. extent = "550 20";
  64. minExtent = "8 8";
  65. horizSizing = "center";
  66. vertSizing = "center";
  67. profile = "CenterPrintProfile";
  68. visible = "0";
  69. active = "1";
  70. tooltipProfile = "GuiToolTipProfile";
  71. hovertime = "1000";
  72. isContainer = "0";
  73. hidden = "1";
  74. canSave = "1";
  75. canSaveDynamicFields = "0";
  76.  
  77. new GuiMLTextCtrl(CenterPrintText) {
  78. lineSpacing = "2";
  79. allowColorChars = "0";
  80. maxChars = "-1";
  81. useURLMouseCursor = "0";
  82. position = "0 0";
  83. extent = "546 12";
  84. minExtent = "8 8";
  85. horizSizing = "center";
  86. vertSizing = "center";
  87. profile = "CenterPrintTextProfile";
  88. visible = "1";
  89. active = "1";
  90. tooltipProfile = "GuiToolTipProfile";
  91. hovertime = "1000";
  92. isContainer = "0";
  93. canSave = "1";
  94. canSaveDynamicFields = "0";
  95. };
  96. };
  97. new GuiBitmapCtrl(bottomPrintDlg) {
  98. bitmap = "art/gui/hudfill.png";
  99. wrap = "0";
  100. position = "237 719";
  101. extent = "550 20";
  102. minExtent = "8 8";
  103. horizSizing = "center";
  104. vertSizing = "top";
  105. profile = "CenterPrintProfile";
  106. visible = "0";
  107. active = "1";
  108. tooltipProfile = "GuiToolTipProfile";
  109. hovertime = "1000";
  110. isContainer = "0";
  111. hidden = "1";
  112. canSave = "1";
  113. canSaveDynamicFields = "0";
  114.  
  115. new GuiMLTextCtrl(bottomPrintText) {
  116. lineSpacing = "2";
  117. allowColorChars = "0";
  118. maxChars = "-1";
  119. useURLMouseCursor = "0";
  120. position = "0 0";
  121. extent = "546 12";
  122. minExtent = "8 8";
  123. horizSizing = "center";
  124. vertSizing = "center";
  125. profile = "CenterPrintTextProfile";
  126. visible = "1";
  127. active = "1";
  128. tooltipProfile = "GuiToolTipProfile";
  129. hovertime = "1000";
  130. isContainer = "0";
  131. canSave = "1";
  132. canSaveDynamicFields = "0";
  133. };
  134. };
  135. new GuiBitmapCtrl(LagIcon) {
  136. bitmap = "art/gui/lagIcon.png";
  137. wrap = "0";
  138. position = "572 3";
  139. extent = "32 32";
  140. minExtent = "8 8";
  141. horizSizing = "right";
  142. vertSizing = "bottom";
  143. profile = "GuiDefaultProfile";
  144. visible = "0";
  145. active = "1";
  146. tooltipProfile = "GuiToolTipProfile";
  147. hovertime = "1000";
  148. isContainer = "0";
  149. hidden = "1";
  150. canSave = "1";
  151. canSaveDynamicFields = "0";
  152. };
  153. new GuiCrossHairHud(Reticle) {
  154. damageFillColor = "0 1 0 1";
  155. damageFrameColor = "1 0.6 0 1";
  156. damageRect = "50 4";
  157. damageOffset = "0 10";
  158. bitmap = "art/gui/weaponHud/blank.png";
  159. wrap = "0";
  160. position = "496 368";
  161. extent = "32 32";
  162. minExtent = "8 8";
  163. horizSizing = "center";
  164. vertSizing = "center";
  165. profile = "GuiModelessDialogProfile";
  166. visible = "0";
  167. active = "1";
  168. tooltipProfile = "GuiToolTipProfile";
  169. hovertime = "1000";
  170. isContainer = "0";
  171. hidden = "1";
  172. canSave = "1";
  173. canSaveDynamicFields = "0";
  174. };
  175. new GuiCrossHairHud(ZoomReticle) {
  176. damageFillColor = "0 1 0 1";
  177. damageFrameColor = "1 0.6 0 1";
  178. damageRect = "50 4";
  179. damageOffset = "0 10";
  180. wrap = "0";
  181. position = "0 0";
  182. extent = "1024 768";
  183. minExtent = "8 8";
  184. horizSizing = "width";
  185. vertSizing = "height";
  186. profile = "GuiModelessDialogProfile";
  187. visible = "0";
  188. active = "1";
  189. tooltipProfile = "GuiToolTipProfile";
  190. hovertime = "1000";
  191. isContainer = "0";
  192. hidden = "1";
  193. canSave = "1";
  194. canSaveDynamicFields = "0";
  195. };
  196. new GuiBitmapBorderCtrl(WeaponHUD) {
  197. position = "78 693";
  198. extent = "124 72";
  199. minExtent = "8 8";
  200. horizSizing = "right";
  201. vertSizing = "top";
  202. profile = "ChatHudBorderProfile";
  203. visible = "0";
  204. active = "1";
  205. tooltipProfile = "GuiToolTipProfile";
  206. hovertime = "1000";
  207. isContainer = "0";
  208. hidden = "1";
  209. canSave = "1";
  210. canSaveDynamicFields = "0";
  211.  
  212. new GuiBitmapCtrl() {
  213. bitmap = "core/art/gui/images/hudfill.png";
  214. wrap = "0";
  215. position = "8 8";
  216. extent = "108 56";
  217. minExtent = "8 8";
  218. horizSizing = "width";
  219. vertSizing = "height";
  220. profile = "GuiDefaultProfile";
  221. visible = "1";
  222. active = "1";
  223. tooltipProfile = "GuiToolTipProfile";
  224. hovertime = "1000";
  225. isContainer = "0";
  226. canSave = "1";
  227. canSaveDynamicFields = "0";
  228. };
  229. new GuiBitmapCtrl(PreviewImage) {
  230. bitmap = "art/gui/weaponHud/blank.png";
  231. wrap = "0";
  232. position = "8 8";
  233. extent = "108 56";
  234. minExtent = "8 2";
  235. horizSizing = "width";
  236. vertSizing = "height";
  237. profile = "GuiDefaultProfile";
  238. visible = "1";
  239. active = "1";
  240. tooltipProfile = "GuiToolTipProfile";
  241. hovertime = "1000";
  242. isContainer = "0";
  243. canSave = "1";
  244. canSaveDynamicFields = "0";
  245. };
  246. new GuiTextCtrl(AmmoAmount) {
  247. text = "Ammo: 995";
  248. maxLength = "255";
  249. margin = "0 0 0 0";
  250. padding = "0 0 0 0";
  251. anchorTop = "0";
  252. anchorBottom = "0";
  253. anchorLeft = "0";
  254. anchorRight = "0";
  255. position = "50 8";
  256. extent = "64 16";
  257. minExtent = "8 8";
  258. horizSizing = "right";
  259. vertSizing = "top";
  260. profile = "HudTextItalicProfile";
  261. visible = "1";
  262. active = "1";
  263. tooltipProfile = "GuiToolTipProfile";
  264. hovertime = "1000";
  265. isContainer = "0";
  266. canSave = "1";
  267. canSaveDynamicFields = "0";
  268. };
  269. };
  270. new GuiBitmapBorderCtrl(HealthHUD) {
  271. position = "6 693";
  272. extent = "72 72";
  273. minExtent = "8 8";
  274. horizSizing = "right";
  275. vertSizing = "top";
  276. profile = "ChatHudBorderProfile";
  277. visible = "1";
  278. active = "1";
  279. tooltipProfile = "GuiToolTipProfile";
  280. hovertime = "1000";
  281. isContainer = "0";
  282. canSave = "1";
  283. canSaveDynamicFields = "0";
  284.  
  285. new GuiBitmapCtrl() {
  286. bitmap = "core/art/gui/images/hudfill.png";
  287. wrap = "0";
  288. position = "8 8";
  289. extent = "56 56";
  290. minExtent = "8 8";
  291. horizSizing = "width";
  292. vertSizing = "height";
  293. profile = "GuiDefaultProfile";
  294. visible = "1";
  295. active = "1";
  296. tooltipProfile = "GuiToolTipProfile";
  297. hovertime = "1000";
  298. isContainer = "0";
  299. canSave = "1";
  300. canSaveDynamicFields = "0";
  301. };
  302. new GuiTextCtrl(numericalHealthHUD) {
  303. text = "100";
  304. maxLength = "255";
  305. margin = "0 0 0 0";
  306. padding = "0 0 0 0";
  307. anchorTop = "0";
  308. anchorBottom = "0";
  309. anchorLeft = "0";
  310. anchorRight = "0";
  311. position = "0 22";
  312. extent = "72 32";
  313. minExtent = "8 8";
  314. horizSizing = "center";
  315. vertSizing = "center";
  316. profile = "NumericHealthProfile";
  317. visible = "1";
  318. active = "1";
  319. tooltipProfile = "GuiToolTipProfile";
  320. hovertime = "1000";
  321. isContainer = "0";
  322. canSave = "1";
  323. canSaveDynamicFields = "0";
  324. };
  325. };
  326.  
  327. // HEX GRID GENERATOR TOOL HERE
  328.  
  329. new GuiBitmapCtrl(HexGeneratorTool) {
  330. bitmap = "art/gui/PlainWhiteBG.png";
  331. wrap = "0";
  332. position = "10 600";
  333. extent = "140 100";
  334. minExtent = "8 2";
  335. horizSizing = "right";
  336. vertSizing = "bottom";
  337. profile = "GuiDefaultProfile";
  338. visible = "1";
  339. active = "1";
  340. tooltipProfile = "GuiToolTipProfile";
  341. hovertime = "1000";
  342. isContainer = "1";
  343. canSave = "1";
  344. canSaveDynamicFields = "0";
  345.  
  346. new GuiTextCtrl() {
  347. text = "X:";
  348. maxLength = "1024";
  349. margin = "0 0 0 0";
  350. padding = "0 0 0 0";
  351. anchorTop = "1";
  352. anchorBottom = "0";
  353. anchorLeft = "1";
  354. anchorRight = "0";
  355. position = "20 10";
  356. extent = "20 20";
  357. minExtent = "8 2";
  358. horizSizing = "right";
  359. vertSizing = "bottom";
  360. profile = "GuiTextProfile";
  361. visible = "1";
  362. active = "1";
  363. tooltipProfile = "GuiToolTipProfile";
  364. hovertime = "1000";
  365. isContainer = "1";
  366. canSave = "1";
  367. canSaveDynamicFields = "0";
  368. };
  369. new GuiTextEditCtrl(xPosTextField) {
  370. historySize = "0";
  371. tabComplete = "0";
  372. sinkAllKeyEvents = "0";
  373. password = "0";
  374. passwordMask = "*";
  375. text = "6";
  376. maxLength = "1024";
  377. margin = "0 0 0 0";
  378. padding = "0 0 0 0";
  379. anchorTop = "1";
  380. anchorBottom = "0";
  381. anchorLeft = "1";
  382. anchorRight = "0";
  383. position = "40 11";
  384. extent = "20 18";
  385. minExtent = "8 2";
  386. horizSizing = "right";
  387. vertSizing = "bottom";
  388. profile = "GuiTextEditProfile";
  389. visible = "1";
  390. active = "1";
  391. tooltipProfile = "GuiToolTipProfile";
  392. hovertime = "1000";
  393. isContainer = "1";
  394. canSave = "1";
  395. canSaveDynamicFields = "0";
  396. };
  397. new GuiTextCtrl() {
  398. text = "Y:";
  399. maxLength = "1024";
  400. margin = "0 0 0 0";
  401. padding = "0 0 0 0";
  402. anchorTop = "1";
  403. anchorBottom = "0";
  404. anchorLeft = "1";
  405. anchorRight = "0";
  406. position = "80 10";
  407. extent = "20 20";
  408. minExtent = "8 2";
  409. horizSizing = "right";
  410. vertSizing = "bottom";
  411. profile = "GuiTextProfile";
  412. visible = "1";
  413. active = "1";
  414. tooltipProfile = "GuiToolTipProfile";
  415. hovertime = "1000";
  416. isContainer = "1";
  417. canSave = "1";
  418. canSaveDynamicFields = "0";
  419. };
  420. new GuiTextEditCtrl(yPosTextField) {
  421. historySize = "0";
  422. tabComplete = "0";
  423. sinkAllKeyEvents = "0";
  424. password = "0";
  425. passwordMask = "*";
  426. text = "6";
  427. maxLength = "1024";
  428. margin = "0 0 0 0";
  429. padding = "0 0 0 0";
  430. anchorTop = "1";
  431. anchorBottom = "0";
  432. anchorLeft = "1";
  433. anchorRight = "0";
  434. position = "100 11";
  435. extent = "20 18";
  436. minExtent = "8 2";
  437. horizSizing = "right";
  438. vertSizing = "bottom";
  439. profile = "GuiTextEditProfile";
  440. visible = "1";
  441. active = "1";
  442. tooltipProfile = "GuiToolTipProfile";
  443. hovertime = "1000";
  444. isContainer = "1";
  445. canSave = "1";
  446. canSaveDynamicFields = "0";
  447. };
  448. new GuiBitmapButtonCtrl(CreateHexGridBtn) {
  449. bitmapMode = "Stretched";
  450. autoFitExtents = "0";
  451. useModifiers = "0";
  452. useStates = "1";
  453. text = "HexGrid Generate ON.";
  454. groupNum = "-1";
  455. buttonType = "PushButton";
  456. useMouseEvents = "0";
  457. position = "10 60";
  458. extent = "120 30";
  459. minExtent = "8 2";
  460. horizSizing = "right";
  461. vertSizing = "bottom";
  462. profile = "GuiButtonProfile";
  463. visible = "1";
  464. active = "1";
  465. command = "ToggleHexCreationMode();";
  466. tooltipProfile = "GuiToolTipProfile";
  467. hovertime = "1000";
  468. isContainer = "0";
  469. canSave = "1";
  470. canSaveDynamicFields = "0";
  471. };
  472. new GuiTextEditCtrl(CombatHexGridNameTextField) {
  473. historySize = "0";
  474. tabComplete = "0";
  475. sinkAllKeyEvents = "0";
  476. password = "0";
  477. passwordMask = "*";
  478. text = "NewGrid";
  479. maxLength = "1024";
  480. margin = "0 0 0 0";
  481. padding = "0 0 0 0";
  482. anchorTop = "1";
  483. anchorBottom = "0";
  484. anchorLeft = "1";
  485. anchorRight = "0";
  486. position = "40 35";
  487. extent = "80 18";
  488. minExtent = "8 2";
  489. horizSizing = "right";
  490. vertSizing = "bottom";
  491. profile = "GuiTextEditProfile";
  492. visible = "1";
  493. active = "1";
  494. tooltipProfile = "GuiToolTipProfile";
  495. hovertime = "1000";
  496. isContainer = "1";
  497. canSave = "1";
  498. canSaveDynamicFields = "0";
  499. };
  500. new GuiTextCtrl() {
  501. text = "Name:";
  502. maxLength = "1024";
  503. margin = "0 0 0 0";
  504. padding = "0 0 0 0";
  505. anchorTop = "1";
  506. anchorBottom = "0";
  507. anchorLeft = "1";
  508. anchorRight = "0";
  509. position = "10 34";
  510. extent = "28 20";
  511. minExtent = "8 2";
  512. horizSizing = "right";
  513. vertSizing = "bottom";
  514. profile = "GuiTextProfile";
  515. visible = "1";
  516. active = "1";
  517. tooltipProfile = "GuiToolTipProfile";
  518. hovertime = "1000";
  519. isContainer = "1";
  520. canSave = "1";
  521. canSaveDynamicFields = "0";
  522. };
  523. };
  524. new GuiBitmapCtrl(OOBSign) {
  525. bitmap = "art/gui/playHud/missionAreaWarning.png";
  526. wrap = "0";
  527. position = "512 693";
  528. extent = "64 64";
  529. minExtent = "8 8";
  530. horizSizing = "right";
  531. vertSizing = "top";
  532. profile = "GuiDefaultProfile";
  533. visible = "0";
  534. active = "1";
  535. tooltipProfile = "GuiToolTipProfile";
  536. hovertime = "1000";
  537. isContainer = "0";
  538. hidden = "1";
  539. canSave = "1";
  540. canSaveDynamicFields = "0";
  541. };
  542. };
  543. //--- OBJECT WRITE END ---
  544.  
  545.  
  546.  
  547. exec("./HexGridGeneration.cs");
  548.  
  549. $HexCreationMode = true;
  550. function ToggleHexCreationMode()
  551. {
  552. if($HexCreationMode)
  553. {
  554. CreateHexGridBtn.text = "HexGrid Generate OFF";
  555. $HexCreationMode = false;
  556. }
  557. else
  558. {
  559. CreateHexGridBtn.text = "HexGrid Generate ON";
  560. $HexCreationMode = true;
  561. }
  562. }
  563.  
  564. function CombatHexGridNameTextField::onEnter(%this)
  565. {
  566. %val = %this.getValue();
  567. echo("hey! User pressed return with value = " @ %val);
  568. }
  569.  
  570. //MODES - $HexCreationMode, $AdventuringMode, $CombatMode, $ConversationMode, $ShopMode, $InventoryMode
  571. //$HexCreationMode is only used in editing
  572. //$AdventuringMode goes third (first?) person and allows you to run around in the world and begin interactions or hit combat triggers
  573. //$CombatMode involves clicking to select nodes, either containing party members to select them, or empty/enemy nodes to move/attack.
  574. //$ConversationMode allows you to accept challenges, hand in completed challenges and find out about events in the game world
  575. //$ShopMode allows you to buy and sell objects in your inventory
  576. //$InventoryMode allows you to equip weapons, armour, etc.
  577. // SIX GAMEPLAY MODES PLUS ONE EDITOR MODE
  578.  
  579. // onMouseDown is called when the left mouse button is clicked in the scene
  580. // onRightMouseDown is called when the right mouse button is clicked in the scene
  581. // %pos is the screen (pixel) coordinates of the mouse click
  582. // %start is the world coordinates of the camera
  583. // %ray is a vector through the viewing
  584. // frustum corresponding to the clicked pixel
  585. function PlayGui::onMouseDown(%this, %pos, %start, %ray)
  586. {
  587. // find end of search vector
  588. %ray = VectorScale(%ray, 2000);
  589. %end = VectorAdd(%start, %ray);
  590. echo(%start);
  591. echo(%end);
  592. // only care about terrain objects
  593. if($HexCreationMode)
  594. {
  595. %searchMasks = $TypeMasks::TerrainObjectType;
  596. }
  597. if($currentlyInBattle)
  598. {
  599. %searchMasks = $TypeMasks::StaticObjectType;
  600. // We'll grab the objectID, then grab the name and check shapeName
  601. // checking the shapeName will tell use whether it's a combat node or not
  602. }
  603.  
  604. // search!
  605. %scanTarg = ContainerRayCast( %start, %end, %searchMasks );
  606. echo ("Position Source Info: ", %scanTarg);
  607. // If the terrain object was found in the scan
  608. if( %scanTarg )
  609. {
  610. // using getWord(source, index); we acquire the x & y positions
  611. %foundObjID = getWord(%scanTarg, 0);
  612. %xPosition = getWord(%scanTarg, 1);
  613. %yPosition = getWord(%scanTarg, 2);
  614. %zPosition = getWord(%scanTarg, 3);
  615. %combinedPosition = %xPosition SPC %yPosition SPC %zPosition;
  616. echo ("Clicked: ", %combinedPosition);
  617. }
  618. if($HexCreationMode)
  619. {
  620. BeginHexCreation(%xPosition, %yPosition, %zPosition);
  621. }
  622. if($currentlyInBattle)
  623. {
  624. //WE GOT SOME KIND OF BOT CLASS HERE???
  625. echo("Found: ", %foundObjID, " with name ", %foundObjID.name);
  626.  
  627. // Stuff on vectors http://www.garagegames.com/community/forums/viewthread/73490
  628. // which might be useful for getting a position that is 0.25 beyond target node.
  629.  
  630. // TO DO TO DO TO DO TO DO TO DO
  631. // Get a vector/direction and distance from AIPlayer to target position
  632. // Add 0.25 to the vector distance
  633. // Derive goToPosition from vector and distance +0.25
  634. // That should fix the problem of AIPlayer stopping too soon on each hex
  635.  
  636. if(%foundObjID.shapeName $= "art/shapes/Hexagon.dae")
  637. {
  638. playerCombatant1.SetMoveDestination(%foundObjID.position);
  639. }
  640. //echo(%combinedPosition);
  641. //commandToServer('ViewpointChangeCombatBegins', %start, %end);
  642. }
  643. }
Advertisement
Add Comment
Please, Sign In to add comment