Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Text below exists in [project_name]/game/art/gui/playgui.gui
- 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.
- 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.
- The gui widget code starts at the line "new GuiBitmapCtrl(HexGeneratorTool)"
- //--- OBJECT WRITE BEGIN ---
- %guiContent = new GameTSCtrl(PlayGui) {
- cameraZRot = "0";
- forceFOV = "0";
- reflectPriority = "1";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 0";
- extent = "1024 768";
- minExtent = "8 8";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiContentProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "1";
- enabled = "1";
- helpTag = "0";
- noCursor = "1";
- new GuiShapeNameHud() {
- fillColor = "0 0 0 0.25";
- frameColor = "0 1 0 1";
- textColor = "0 1 0 1";
- showFill = "0";
- showFrame = "0";
- verticalOffset = "0.2";
- distanceFade = "0.1";
- position = "0 0";
- extent = "1024 768";
- minExtent = "8 8";
- horizSizing = "width";
- vertSizing = "height";
- profile = "GuiModelessDialogProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiBitmapCtrl(centerPrintDlg) {
- bitmap = "art/gui/hudfill.png";
- wrap = "0";
- position = "237 374";
- extent = "550 20";
- minExtent = "8 8";
- horizSizing = "center";
- vertSizing = "center";
- profile = "CenterPrintProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiMLTextCtrl(CenterPrintText) {
- lineSpacing = "2";
- allowColorChars = "0";
- maxChars = "-1";
- useURLMouseCursor = "0";
- position = "0 0";
- extent = "546 12";
- minExtent = "8 8";
- horizSizing = "center";
- vertSizing = "center";
- profile = "CenterPrintTextProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- new GuiBitmapCtrl(bottomPrintDlg) {
- bitmap = "art/gui/hudfill.png";
- wrap = "0";
- position = "237 719";
- extent = "550 20";
- minExtent = "8 8";
- horizSizing = "center";
- vertSizing = "top";
- profile = "CenterPrintProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiMLTextCtrl(bottomPrintText) {
- lineSpacing = "2";
- allowColorChars = "0";
- maxChars = "-1";
- useURLMouseCursor = "0";
- position = "0 0";
- extent = "546 12";
- minExtent = "8 8";
- horizSizing = "center";
- vertSizing = "center";
- profile = "CenterPrintTextProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- new GuiBitmapCtrl(LagIcon) {
- bitmap = "art/gui/lagIcon.png";
- wrap = "0";
- position = "572 3";
- extent = "32 32";
- minExtent = "8 8";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiDefaultProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiCrossHairHud(Reticle) {
- damageFillColor = "0 1 0 1";
- damageFrameColor = "1 0.6 0 1";
- damageRect = "50 4";
- damageOffset = "0 10";
- bitmap = "art/gui/weaponHud/blank.png";
- wrap = "0";
- position = "496 368";
- extent = "32 32";
- minExtent = "8 8";
- horizSizing = "center";
- vertSizing = "center";
- profile = "GuiModelessDialogProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiCrossHairHud(ZoomReticle) {
- damageFillColor = "0 1 0 1";
- damageFrameColor = "1 0.6 0 1";
- damageRect = "50 4";
- damageOffset = "0 10";
- wrap = "0";
- position = "0 0";
- extent = "1024 768";
- minExtent = "8 8";
- horizSizing = "width";
- vertSizing = "height";
- profile = "GuiModelessDialogProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiBitmapBorderCtrl(WeaponHUD) {
- position = "78 693";
- extent = "124 72";
- minExtent = "8 8";
- horizSizing = "right";
- vertSizing = "top";
- profile = "ChatHudBorderProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiBitmapCtrl() {
- bitmap = "core/art/gui/images/hudfill.png";
- wrap = "0";
- position = "8 8";
- extent = "108 56";
- minExtent = "8 8";
- horizSizing = "width";
- vertSizing = "height";
- profile = "GuiDefaultProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiBitmapCtrl(PreviewImage) {
- bitmap = "art/gui/weaponHud/blank.png";
- wrap = "0";
- position = "8 8";
- extent = "108 56";
- minExtent = "8 2";
- horizSizing = "width";
- vertSizing = "height";
- profile = "GuiDefaultProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(AmmoAmount) {
- text = "Ammo: 995";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "0";
- anchorBottom = "0";
- anchorLeft = "0";
- anchorRight = "0";
- position = "50 8";
- extent = "64 16";
- minExtent = "8 8";
- horizSizing = "right";
- vertSizing = "top";
- profile = "HudTextItalicProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- new GuiBitmapBorderCtrl(HealthHUD) {
- position = "6 693";
- extent = "72 72";
- minExtent = "8 8";
- horizSizing = "right";
- vertSizing = "top";
- profile = "ChatHudBorderProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiBitmapCtrl() {
- bitmap = "core/art/gui/images/hudfill.png";
- wrap = "0";
- position = "8 8";
- extent = "56 56";
- minExtent = "8 8";
- horizSizing = "width";
- vertSizing = "height";
- profile = "GuiDefaultProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(numericalHealthHUD) {
- text = "100";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "0";
- anchorBottom = "0";
- anchorLeft = "0";
- anchorRight = "0";
- position = "0 22";
- extent = "72 32";
- minExtent = "8 8";
- horizSizing = "center";
- vertSizing = "center";
- profile = "NumericHealthProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- // HEX GRID GENERATOR TOOL HERE
- new GuiBitmapCtrl(HexGeneratorTool) {
- bitmap = "art/gui/PlainWhiteBG.png";
- wrap = "0";
- position = "10 600";
- extent = "140 100";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiDefaultProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiTextCtrl() {
- text = "X:";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "20 10";
- extent = "20 20";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl(xPosTextField) {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "6";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "40 11";
- extent = "20 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Y:";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "80 10";
- extent = "20 20";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl(yPosTextField) {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "6";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "100 11";
- extent = "20 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiBitmapButtonCtrl(CreateHexGridBtn) {
- bitmapMode = "Stretched";
- autoFitExtents = "0";
- useModifiers = "0";
- useStates = "1";
- text = "HexGrid Generate ON.";
- groupNum = "-1";
- buttonType = "PushButton";
- useMouseEvents = "0";
- position = "10 60";
- extent = "120 30";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiButtonProfile";
- visible = "1";
- active = "1";
- command = "ToggleHexCreationMode();";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl(CombatHexGridNameTextField) {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "NewGrid";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "40 35";
- extent = "80 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Name:";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "10 34";
- extent = "28 20";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- new GuiBitmapCtrl(OOBSign) {
- bitmap = "art/gui/playHud/missionAreaWarning.png";
- wrap = "0";
- position = "512 693";
- extent = "64 64";
- minExtent = "8 8";
- horizSizing = "right";
- vertSizing = "top";
- profile = "GuiDefaultProfile";
- visible = "0";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- hidden = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- //--- OBJECT WRITE END ---
- exec("./HexGridGeneration.cs");
- $HexCreationMode = true;
- function ToggleHexCreationMode()
- {
- if($HexCreationMode)
- {
- CreateHexGridBtn.text = "HexGrid Generate OFF";
- $HexCreationMode = false;
- }
- else
- {
- CreateHexGridBtn.text = "HexGrid Generate ON";
- $HexCreationMode = true;
- }
- }
- function CombatHexGridNameTextField::onEnter(%this)
- {
- %val = %this.getValue();
- echo("hey! User pressed return with value = " @ %val);
- }
- //MODES - $HexCreationMode, $AdventuringMode, $CombatMode, $ConversationMode, $ShopMode, $InventoryMode
- //$HexCreationMode is only used in editing
- //$AdventuringMode goes third (first?) person and allows you to run around in the world and begin interactions or hit combat triggers
- //$CombatMode involves clicking to select nodes, either containing party members to select them, or empty/enemy nodes to move/attack.
- //$ConversationMode allows you to accept challenges, hand in completed challenges and find out about events in the game world
- //$ShopMode allows you to buy and sell objects in your inventory
- //$InventoryMode allows you to equip weapons, armour, etc.
- // SIX GAMEPLAY MODES PLUS ONE EDITOR MODE
- // onMouseDown is called when the left mouse button is clicked in the scene
- // onRightMouseDown is called when the right mouse button is clicked in the scene
- // %pos is the screen (pixel) coordinates of the mouse click
- // %start is the world coordinates of the camera
- // %ray is a vector through the viewing
- // frustum corresponding to the clicked pixel
- function PlayGui::onMouseDown(%this, %pos, %start, %ray)
- {
- // find end of search vector
- %ray = VectorScale(%ray, 2000);
- %end = VectorAdd(%start, %ray);
- echo(%start);
- echo(%end);
- // only care about terrain objects
- if($HexCreationMode)
- {
- %searchMasks = $TypeMasks::TerrainObjectType;
- }
- if($currentlyInBattle)
- {
- %searchMasks = $TypeMasks::StaticObjectType;
- // We'll grab the objectID, then grab the name and check shapeName
- // checking the shapeName will tell use whether it's a combat node or not
- }
- // search!
- %scanTarg = ContainerRayCast( %start, %end, %searchMasks );
- echo ("Position Source Info: ", %scanTarg);
- // If the terrain object was found in the scan
- if( %scanTarg )
- {
- // using getWord(source, index); we acquire the x & y positions
- %foundObjID = getWord(%scanTarg, 0);
- %xPosition = getWord(%scanTarg, 1);
- %yPosition = getWord(%scanTarg, 2);
- %zPosition = getWord(%scanTarg, 3);
- %combinedPosition = %xPosition SPC %yPosition SPC %zPosition;
- echo ("Clicked: ", %combinedPosition);
- }
- if($HexCreationMode)
- {
- BeginHexCreation(%xPosition, %yPosition, %zPosition);
- }
- if($currentlyInBattle)
- {
- //WE GOT SOME KIND OF BOT CLASS HERE???
- echo("Found: ", %foundObjID, " with name ", %foundObjID.name);
- // Stuff on vectors http://www.garagegames.com/community/forums/viewthread/73490
- // which might be useful for getting a position that is 0.25 beyond target node.
- // TO DO TO DO TO DO TO DO TO DO
- // Get a vector/direction and distance from AIPlayer to target position
- // Add 0.25 to the vector distance
- // Derive goToPosition from vector and distance +0.25
- // That should fix the problem of AIPlayer stopping too soon on each hex
- if(%foundObjID.shapeName $= "art/shapes/Hexagon.dae")
- {
- playerCombatant1.SetMoveDestination(%foundObjID.position);
- }
- //echo(%combinedPosition);
- //commandToServer('ViewpointChangeCombatBegins', %start, %end);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment