GUI question
by Charlie Higdon · in Torque Game Engine · 01/16/2009 (3:30 pm) · 8 replies
If the downloads were working in resources I could probably spare you all this post.
I'm trying to understand GUI, more specifically how you link the gui to an object. I see where you specify gui size, color, position, etc. I see where in the player.cs, car.cs, etc, you specify energy and health.
I feel a bit ignorant, but I don't understand where you specify use THIS or THAT gui with the object.
For example, if I wanted to use a new vehicle, I could replace
shapeFile = "~/data/shapes/buggy/buggy.dts";
with
shapeFile = "~/data/shapes/buggy/buggy2.dts";
or something similar.
What tells the GUI that it's used for the player, car, etc.?
Sorry if it's a stupid question, I can't get at the resource DL to look at the files (was hoping the info I needed was in that).
I'm trying to understand GUI, more specifically how you link the gui to an object. I see where you specify gui size, color, position, etc. I see where in the player.cs, car.cs, etc, you specify energy and health.
I feel a bit ignorant, but I don't understand where you specify use THIS or THAT gui with the object.
For example, if I wanted to use a new vehicle, I could replace
shapeFile = "~/data/shapes/buggy/buggy.dts";
with
shapeFile = "~/data/shapes/buggy/buggy2.dts";
or something similar.
What tells the GUI that it's used for the player, car, etc.?
Sorry if it's a stupid question, I can't get at the resource DL to look at the files (was hoping the info I needed was in that).
#2
example:
Now look in server/scripts/player.cs. This is the server side datablock for the player. It defines everything else about the player:
Now look at Server/Scripts/Game.cs:
When CreatePlayer is called (from SpawnPlayer), a new Player is created and assigned the datablock that was defined in server/scripts/player.cs.
From what I can see, When the client executes, it loads the shape from the TSShapeConstructor, loads the animations, and ties the animations to the shape. When the server loads, it defines the datablock for the player, including the shape file. Then when the player is connected to the server, a new player is created, assigned the datablock, and this is sent to the client, which then knows what shapes to use, and knows how to animate it because we previously defined the animations.
Does that help?
01/16/2009 (4:03 pm)
Take a look at data/player/player.cs. This file contains the Datablock for the TSShapeConstructor for the player. The TSShapeConstructor defines how the player animates on the client side.example:
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "./player.dts";
sequence0 = "./player_root.dsq root";
{rest removed for brevity}Now look in server/scripts/player.cs. This is the server side datablock for the player. It defines everything else about the player:
datablock PlayerData(PlayerBody)
{
renderFirstPerson = false;
emap = true;
className = Armor;
shapeFile = "~/data/shapes/player/player.dts";
{rest removed for brevity}Now look at Server/Scripts/Game.cs:
function GameConnection::createPlayer(%this, %spawnPoint)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
%player = new Player() {
dataBlock = PlayerBody;
client = %this;
};
MissionCleanup.add(%player);
{rest removed for brevity}When CreatePlayer is called (from SpawnPlayer), a new Player is created and assigned the datablock that was defined in server/scripts/player.cs.
From what I can see, When the client executes, it loads the shape from the TSShapeConstructor, loads the animations, and ties the animations to the shape. When the server loads, it defines the datablock for the player, including the shape file. Then when the player is connected to the server, a new player is created, assigned the datablock, and this is sent to the client, which then knows what shapes to use, and knows how to animate it because we previously defined the animations.
Does that help?
#3
I wanted to add this to my vehicle, but I don't see where within the player.cs it says anything about the GUI. I didnt see in the GUI file where it says anything about it being for the player.
Wish I could think of a better way to phrase the question.
When I look at my screen, I see the players health and energy.
I understand that the energy drain, health, max damage, and all that are specified in the player.cs. Where in player.cs does it say to load the GUI displaying energy/health? Or where in the GUI files does it say, this gui is for the player?
01/16/2009 (4:20 pm)
Somewhat, but I was trying to see where in the files it specifies what GUI the player is using. The red and blue health and energy bars.I wanted to add this to my vehicle, but I don't see where within the player.cs it says anything about the GUI. I didnt see in the GUI file where it says anything about it being for the player.
Wish I could think of a better way to phrase the question.
When I look at my screen, I see the players health and energy.
I understand that the energy drain, health, max damage, and all that are specified in the player.cs. Where in player.cs does it say to load the GUI displaying energy/health? Or where in the GUI files does it say, this gui is for the player?
#4
This runs on the client, and what this does (every time the scene is rendered), it gets the current control object, and if it is a "Player", then it gets the value of the energy or health from the control object and determines how big to draw the bar.
To display the energy for your vehicle, you would need to change the C++ code so it didn't filter out vehicles.
This:
would become something like this (just typed it in, but should work...)
01/16/2009 (5:37 pm)
Those are "GuiHealthBarHud" controls. Look in GuiHealthBarHud.cc, at the function void GuiHealthBarHud::onRender().void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
{
// Must have a connection and player control object
GameConnection* conn = GameConnection::getConnectionToServer();
if (!conn)
return;
ShapeBase* control = conn->getControlObject();
if (!control || !(control->getType() & PlayerObjectType))
return;
if(mDisplayEnergy)
{
mValue = control->getEnergyValue();
}
else
{
// We'll just grab the damage right off the control object.
// Damage value 0 = no damage.
mValue = 1 - control->getDamageValue();
}
{rest deleted}This runs on the client, and what this does (every time the scene is rendered), it gets the current control object, and if it is a "Player", then it gets the value of the energy or health from the control object and determines how big to draw the bar.
To display the energy for your vehicle, you would need to change the C++ code so it didn't filter out vehicles.
This:
if (!control || !(control->getType() & PlayerObjectType))
return;would become something like this (just typed it in, but should work...)
if (!control || !(control->getType() & (PlayerObjectType | VehicleObjectType)))
return;
#5
Was finally able to get a resource with a download in it, HAPPY THEY FIXED THAT!!!!!!
I've still been unable to get it to work. Thanks for explaining to me where it was, it makes a lot more sense now. I'm sure I'm probably compiling it incorrectly, as my A* resource didn't work either, or else when I changed the line of code I should maybe put the VehicleHealthHud.cc in another folder?
Anyways, thanks for clearing that up for me. I would have still been digging through .cs files scratching my head.
01/16/2009 (7:52 pm)
Ah, it's in a .cc file. I'm a retard, was thinking maybe in a .cs.Was finally able to get a resource with a download in it, HAPPY THEY FIXED THAT!!!!!!
I've still been unable to get it to work. Thanks for explaining to me where it was, it makes a lot more sense now. I'm sure I'm probably compiling it incorrectly, as my A* resource didn't work either, or else when I changed the line of code I should maybe put the VehicleHealthHud.cc in another folder?
Anyways, thanks for clearing that up for me. I would have still been digging through .cs files scratching my head.
#6
01/18/2009 (6:39 pm)
Never could get the vehicle health to display. Neither with the simple one word change in the .cc or with the resources listed. They show up on the gui menu, but don't render anything.
#7
01/18/2009 (7:39 pm)
Have you looked at the mDamage in the debugger to see if it's actually pulling data?
#8
01/23/2009 (11:55 am)
Not pulling damage either =(. Gotta be something stupid I'm doing.
Torque Owner Charlie Higdon