API Question How do I open the select vessel dialog?

StevoPistolero

Addon Developer
Addon Developer
Donator
Joined
Nov 29, 2009
Messages
116
Reaction score
0
Points
0
I am trying to change the focus to a target vessel. I found this "define" OAPI_LKEY_DlgSelectVessel. I'm not sure how to activate it. It isn't a method but a definition. I have ConsumeKeyBuffered with switches to handle button presses. Maybe something goes in there, but I don't know how to activate it. Any help would be appreciated. Thanks.
 
in order to change the focus on another vessel you have to define an object handle, place the target vessel into it and then command orbiter to switch the focus to that object, here's how I would do it for object name Tgt:

Code:
OBJHANDLE htarget=oapiGetObjectByName("Tgt");
if(oapiIsVessel(htarget) //to be on the safe side
{
oapiSetFocusObject(htarget);
}

hope this helps!
 
in order to change the focus on another vessel you have to define an object handle, place the target vessel into it and then command orbiter to switch the focus to that object, here's how I would do it for object name Tgt:

Code:
OBJHANDLE htarget=oapiGetObjectByName("Tgt");
if(oapiIsVessel(htarget) //to be on the safe side
{
oapiSetFocusObject(htarget);
}
hope this helps!

While that code will certainly be helpful, I am still looking for a way for the user to enter the target name. I could have them type it in (I was able to make that work), but I would prefer a dialog box listing the vessel names in the scenario.
 
I think you can build a dialog box and play with oapiGetObjectCount, oapiGetObjectType, oapiGetObjectByIndex to obtain the list, something like

Code:
for(int i=0;i<oapiGetObjectCount();i++)
{
   if(oapiGetObjectType(oapiGetObjectByIndex(i))==OBJTP_VESSEL)
  {
  /// GET THE HANDLE AND ADD TO THE LIST TO SHOW IN THE DIALOG 
  }
}
 
Back
Top