Author Topic: Need Help With NavPoints  (Read 2119 times)

Offline jayce

  • Posts: 20
  • Cookies: 2
Need Help With NavPoints
« on: June 24, 2008, 05:20:36 AM »
I am looking for links to useful infomation on how to create an in-game:

1. window
2. button
3. object, specifically a navpoint

I want to be able to do this using only the stock installing of BC_1.1 if possible. Other things that may prove useful is:

1. information on how placement (coordinates) using the x,y,z axis work
2. character (numbers) input using the keyboard
3. determining your current position using the x,y,z axis

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Need Help With NavPoints
« Reply #1 on: June 24, 2008, 09:01:25 AM »
Before I begin, all of the things described here is stock BC, so far, only Immersion has a dedicated GUI framework that uses the stock abilities as building blocks for it's own, higher level, uses.



There are various window-ish objects in BC.

The simplest is a TGPane, in which you can add various other UI elements and place them exactly the way you want to, which you need to do.

Then you have the STSubPane, wich is a vertically orderd TGPane (meaning you don't get to chose the exact locations of each element). And all elements are horizontally maximized.

Then you get to the STStylizedWindow of which there are various variants, but all include a frame around the content (which usually is a STSubPane, but you can specify your own) and it's even possible to create your own style for it (I'd rate this very advanced, it's not hard, but I only found out about this ability one or two months ago).

And lastly, the STTopLevelWindow, which is what the common elements between all Crew menu's is made of (the menu with the name), which is what you want to use (I think).

There is also the STMenu, which is a cross between a button and an STSubPane.



Of the buttons there are 3 or 4 variants, a Button Base (never used, atleast not that I know of, you can make an icon clickable), a TextButton (clickable text), then you have the STButton, which is very stuborn to use, since it has a fixed height and a fixed width (which is the maximum width of the parent at the time it's created, the last part is very important). But you can change various other aspects of it (such as the end caps).

Then there is the STRoundedButton, which you have to set the width and height explicitly of.

STButtons are used in nearly every menu, STRoundedButtons are used for the Main Menu (the top buttons) and for the top Quick Battle Setup menu (most likely some other places as well, but those are the most prominently).



Objects, well, there are quite a lot of different objects in BC that can be added to a Set (for example, a Bridge, StarBase 12, Vesuvius 1, 2 and 3 are all examples of a Set).
Most objects are either directly added to a set (ships, characters, other models), or through specialized methods on a set (lights, backdrops). But navpoints are added on creation, where you need to specify the set name.

For examples on how to do this, look at the various (stock) sets, for example, the Alioth1 system has one or two navpoints.



Coordinates on BC are simple x,y,z coordinates where 0,0,0 is the centre of the map, if you go far away, without provisions in the set, then it's possible to encounter the "camera shake bug", where the floating point precision is insufficient to place the ship correctly on the map (Lookup the Wikipedia article "Floating Point" and more specificly, the "Accuracy Problems" section).

There is a conversion rate for what the real coordinates are, and what you see on screen (the km between ships).



There is a UI element called a TGParagraph which features a character blacklist, but you need to add a PythonFuncHandlerForInstance (for a App.ET_KEYBOARD) to verify that you don't enter too many . (dots). For examples, look in QBR (where you can specify where on the map you want ships to appear) or in NanoFXv2 Config Panel where I (potentially wrong if you have an old version) handle this case (blocking the extra dot).



Assuming for a ship, then it's either 0,0,0 (each object, not sure about nav points though, has it's own "space" so if you attach another object to it, then it will live in there) for it's own space, or you can get the GetWorldLocation() from (nearly) any object you see. Or you can try your hand at GetTranslate(), both return a so called TGPoint3, which has x, y and z coordinates (and a couple of extra utility methods).



If you have any other questions, do ask.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline jayce

  • Posts: 20
  • Cookies: 2
Re: Need Help With NavPoints
« Reply #2 on: June 24, 2008, 02:02:48 PM »
There are various window-ish objects in BC.

The simplest is a TGPane, in which you can add various other UI elements and place them exactly the way you want to, which you need to do.

Then you have the STSubPane, wich is a vertically orderd TGPane (meaning you don't get to chose the exact locations of each element). And all elements are horizontally maximized.

Then you get to the STStylizedWindow of which there are various variants, but all include a frame around the content (which usually is a STSubPane, but you can specify your own) and it's even possible to create your own style for it (I'd rate this very advanced, it's not hard, but I only found out about this ability one or two months ago).

And lastly, the STTopLevelWindow, which is what the common elements between all Crew menu's is made of (the menu with the name), which is what you want to use (I think).

There is also the STMenu, which is a cross between a button and an STSubPane.

The TGPane or the STTopLevelWindow sound like they would be the best choice. I'll explain later what I want to do, then you can tell me which of these two is the better choice.

Of the buttons there are 3 or 4 variants, a Button Base (never used, atleast not that I know of, you can make an icon clickable), a TextButton (clickable text), then you have the STButton, which is very stuborn to use, since it has a fixed height and a fixed width (which is the maximum width of the parent at the time it's created, the last part is very important). But you can change various other aspects of it (such as the end caps).

Then there is the STRoundedButton, which you have to set the width and height explicitly of.

STButtons are used in nearly every menu, STRoundedButtons are used for the Main Menu (the top buttons) and for the top Quick Battle Setup menu (most likely some other places as well, but those are the most prominently).

Of the buttons, Im looking for one that is very similar to what's in QBR, where you can actually enter in numbers for the placement of objects. The other button Im thinking should be something that can open up the window that Im going to create, and one to close it of course. Since Im working with Navpoints, I was thinking of tying this in the Helm menu option.

Objects, well, there are quite a lot of different objects in BC that can be added to a Set (for example, a Bridge, StarBase 12, Vesuvius 1, 2 and 3 are all examples of a Set).
Most objects are either directly added to a set (ships, characters, other models), or through specialized methods on a set (lights, backdrops). But navpoints are added on creation, where you need to specify the set name.

For examples on how to do this, look at the various (stock) sets, for example, the Alioth1 system has one or two navpoints.

Although it was a rather crude way, I was able to add a navpoint in-game using the in-game interpeter. I started the quickbattle game, but never actually set up a game. I think by default, the game starts you out on the galaxy class in deep space (QuickBattleRegion). I had to add a placement object, move it to where I wanted it, then recalled that placement object as a navpoint before it showed up in the Helm menu. Im looking to streamline this process so that a script can do everything short of choosing the placement or coordinates (x,y,z) while in-game. Now when you say that navpoints are added on creation, do you mean creation of the mission?

There is a UI element called a TGParagraph which features a character blacklist, but you need to add a PythonFuncHandlerForInstance (for a App.ET_KEYBOARD) to verify that you don't enter too many . (dots). For examples, look in QBR (where you can specify where on the map you want ships to appear) or in NanoFXv2 Config Panel where I (potentially wrong if you have an old version) handle this case (blocking the extra dot).



Assuming for a ship, then it's either 0,0,0 (each object, not sure about nav points though, has it's own "space" so if you attach another object to it, then it will live in there) for it's own space, or you can get the GetWorldLocation() from (nearly) any object you see. Or you can try your hand at GetTranslate(), both return a so called TGPoint3, which has x, y and z coordinates (and a couple of extra utility methods).

Now that I think about it, I guess you really could end up with too many dots when dealing with coordinates. Thanks for the tip. I also think that GetWorldLocation() option sounds like the better choice.

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Need Help With NavPoints
« Reply #3 on: June 24, 2008, 03:49:50 PM »
Added to the set on creation of a navpoint (regardless of the time).

Anything you do in the Console can be done in a script (they are the same).

About the QBR text entry, those are sort of custom made, based on the code found in MainMenu (for the captain name entry).

TBH, I don't know the difference between getWorldCoordinates and getTranslate, but I can imagine that the difference would be based on the "true", relative, coordinates.
getWorldCoordinates mostlikely mean from the sets 0,0,0, and getTranslate means based from the nearest parent (either set or some other object, such as a ship or a planet, or a torpedo even).

TGPane has no other purpose but to group a set of UI elements together, STTopLevelMenu has a border and a name (TGPane doesn't).
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.