0 Members and 1 Guest are viewing this topic.
// --------------------------------------------------------------// Keyboard interface handler (buffered key events)// --------------------------------------------------------------int SDmodule1::clbkConsumeBufferedKey (DWORD key, bool down, char *kstate){ if (!down) return 0; // only process keydown events //if (KEYMOD_CONTROL (kstate)) { else { switch (key) { //case OAPI_KEY_1: // deploy/retract antenna // RevertAntenna(); // return 1; //case OAPI_KEY_2: // open/close hatch // RevertHatch(); // return 1; case OAPI_KEY_K: // open/fold solar arrays RevertArray(); return 1; } } return 0; //--------------------------------------------------------------------------- // Ummu Key "E" perform the EVA of the selected member // // ADD REALISM: It's your responsabilities also to set ship's control accordingly to crew aboard. // If you want to disable control if no one is aboard have a look at "SetADCtrlMode()" // and "SetAttitudeMode()" functions of Orbiter. To disable thrusters set their fuel // ressource to NULL. if(key==OAPI_KEY_E&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate)) { // PERFORM THE EVA, first we get is name with "GetCrewNameBySlotNumber" then we perform EVA with "EvaCrewMember" int Returned=Crew.EvaCrewMember(Crew.GetCrewNameBySlotNumber(SelectedUmmuMember)); //we provide feedback to user (You can display a message on panel or wathewer) //here below all the return code possible: switch(Returned) { case TRANSFER_TO_DOCKED_SHIP_OK: sprintf(SendHudMessage(),"Transfer to docked ship Ok - %s transfered", Crew.GetLastEvaedCrewName());SelectedUmmuMember=0; break; case EVA_OK: sprintf(SendHudMessage(),"EVA OK - %s left the ship", Crew.GetLastEvaedCrewName());SelectedUmmuMember=0; break; case ERROR_NO_ONE_ON_BOARD: strcpy(SendHudMessage(),"Error, no one on board, unable to EVA"); break; case ERROR_AIRLOCK_CLOSED: strcpy(SendHudMessage(),"Error, airlock is closed, unable to EVA"); break; case ERROR_DOCKED_SHIP_HAVE_AIRLOCK_CLOSED: strcpy(SendHudMessage(),"Error, docked ship's airlock is closed, unable to transfer"); break; case ERROR_DOCKED_SHIP_IS_FULL: strcpy(SendHudMessage(),"Error, docked ship is already full transfer failed"); break; case ERROR_CREW_MEMBER_NOT_FOUND: strcpy(SendHudMessage(),"Error, no crew by this name in ship"); break; case ERROR_DOCKEDSHIP_DONOT_USE_UMMU: strcpy(SendHudMessage(),"Error, docked ship do not use UMmu 2.0, ask author to add it"); break; case ERROR_MISC_ERROR_EVAFAILED: strcpy(SendHudMessage(),"Misc error with UMMU install it again"); break; } return TRUE; } //--------------------------------------------------------------------------- // Ummu Key "1" Select next member This is just internal to the demo // you may do your own selection system by panel button, name etc etc //if(key==OAPI_KEY_1&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate)) //{ if(key==OAPI_KEY_1) { // we test there is someone aboard if(Crew.GetCrewTotalNumber()==0) { strcpy(SendHudMessage(),"Sorry no one aboard unable to select"); return 1; } //we test that we select existing member if(SelectedUmmuMember SelectedUmmuMember++; char * Name=Crew.GetCrewNameBySlotNumber(SelectedUmmuMember); sprintf(SendHudMessage(),"Slot %i %s \"%s\" aged %i Selected for EVA or Transfer, please press \"E\" to EVA", SelectedUmmuMember,Crew.GetCrewMiscIdBySlotNumber(SelectedUmmuMember), Name,Crew.GetCrewAgeBySlotNumber(SelectedUmmuMember)); return 1; } //--------------------------------------------------------------------------- // Ummu Key "2" Select previous member This is just internal to the demo //you may do your own selection system by panel button //if(key==OAPI_KEY_2&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate)) //{ if(key==OAPI_KEY_2) { // we test there is someone aboard if(Crew.GetCrewTotalNumber()==0) { strcpy(SendHudMessage(),"Sorry no one aboard unable to select"); return 1; } if(SelectedUmmuMember>0) SelectedUmmuMember--; char * Name=Crew.GetCrewNameBySlotNumber(SelectedUmmuMember); sprintf(SendHudMessage(),"Slot %i %s \"%s\" aged %i Selected for EVA or Transfer" ", please press \"E\" to EVA",SelectedUmmuMember, Crew.GetCrewMiscIdBySlotNumber(SelectedUmmuMember),Name, Crew.GetCrewAgeBySlotNumber(SelectedUmmuMember)); return 1; } //--------------------------------------------------------------------------- //Ummu Key "A" Switch the virtual UMMU airlock door on/off //if(key==OAPI_KEY_A&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate)) //{ if(key==OAPI_KEY_A) { //switch state Crew.SetAirlockDoorState(!Crew.GetAirlockDoorState()); //display state if(Crew.GetAirlockDoorState()==TRUE) strcpy(SendHudMessage(),"Airlock is now open"); else strcpy(SendHudMessage(),"Airlock is now closed"); return 1; } //--------------------------------------------------------------------------- //Get some infos Name of ship and total soul aboard if(key==OAPI_KEY_S) { sprintf(SendHudMessage(),"%i souls aboard ship %s, %i seats available", Crew.GetCrewTotalNumber(),GetName(),4-Crew.GetCrewTotalNumber()); return 1; } //--------------------------------------------------------------------------- //ADD some Fun, Eject the guy, No check of all return code here to keep listing small and clear. //Notice eject function doesn't check airlock state at all. //GOOD IDEA: Get the Object's handle after ejection with function "GetObjHandleOfLastEVACrew" //and add to it one very small tank, thruster and smoke, then fire thruster (see pilot ejection of DGIV) //BAD IDEA: Not testing the handle returned by "GetObjHandleOfLastEVACrew" before using may //cause a CTD if by any bad luck the pointer is invalid (handle==NULL) if(key==OAPI_KEY_ESCAPE&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate)) { if(Crew.EjectCrewMember(Crew.GetCrewNameBySlotNumber(SelectedUmmuMember))==EVA_OK) sprintf(SendHudMessage(),"%s EJECTED",Crew.GetLastEvaedCrewName()); SelectedUmmuMember=0; return 1; } //--------------------------------------------------------------------------- //Use a different Mesh (type "C" then EVA someone) //better idea is to use the new UMMU Id definition //look readme.txt in folder "config/UMMUIdConfig" if(key==OAPI_KEY_C) { Crew.SetAlternateMeshToUseForEVASpacesuit("mmu"); // the stock mmu of orbiter located in "meshes/mmu.msh" strcpy(SendHudMessage(),"Mesh changed"); return 1; } //THIS IS FOR ADDING CREW SEE PDF doc "Allow user to add crew to your ship //without scenery editor" //if(key==OAPI_KEY_M&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate)) //{ if(key==OAPI_KEY_5) { AddUMmuToVessel(TRUE); } return 0; }
Car sinon je pense que les autre définitions de touche qu'il y a après sont ignorer (ou pas compiler).