func EnableMenuItem(menuId MenuID, index int, enabled bool) { cEnabled := 0 if enabled { cEnabled = 1 } C.XPLMEnableMenuItem(C.XPLMMenuID(menuId), C.int(index), C.int(cEnabled)) }
func SetMenuItemName(menuId MenuID, index int, itemName string, forceEnglish bool) { cItemName := C.CString(itemName) cForceEnglish := 0 if forceEnglish { cForceEnglish = 1 } C.XPLMSetMenuItemName(C.XPLMMenuID(menuId), C.int(index), cItemName, C.int(cForceEnglish)) }
func AppendMenuItem(menuId MenuID, itemName string, itemRef interface{}, forceEnglish bool) int { cItemName := C.CString(itemName) cForceEnglish := 0 if forceEnglish { cForceEnglish = 1 } _, info := findMenu(menuId) if info == nil { return -1 } info.itemRefs[cItemName] = itemRef return int(C.XPLMAppendMenuItem(C.XPLMMenuID(menuId), cItemName, unsafe.Pointer(cItemName), C.int(cForceEnglish))) }
func CreateMenu(name string, parentMenu MenuID, parentItem int, handler MenuHandler, menuRef interface{}) MenuID { cName := C.CString(name) defer C.free(unsafe.Pointer(cName)) var cHandler C.XPLMMenuHandler_f var internalMenuRef *C.char if handler != nil { internalMenuRef = C.CString(goplane.IdGenerator()) cHandler = C.XPLMMenuHandler_f(unsafe.Pointer(C.menuHandler)) } id := MenuID(C.XPLMCreateMenu(cName, C.XPLMMenuID(parentMenu), C.int(parentItem), cHandler, unsafe.Pointer(internalMenuRef))) if handler != nil { handlers[internalMenuRef] = ®Info{handler, id, menuRef, make(map[*C.char]interface{})} } return id }
func AppendMenuSeparator(menuId MenuID) { C.XPLMAppendMenuSeparator(C.XPLMMenuID(menuId)) }
func ClearAllMenuItems(menuId MenuID) { C.XPLMClearAllMenuItems(C.XPLMMenuID(menuId)) }
func DestroyMenu(menuId MenuID) { C.XPLMDestroyMenu(C.XPLMMenuID(menuId)) id, _ := findMenu(menuId) delete(handlers, id) C.free(unsafe.Pointer(id)) }
func RemoveMenuItem(menuId MenuID, index int) { C.XPLMRemoveMenuItem(C.XPLMMenuID(menuId), C.int(index)) }
func CheckMenuItemState(menuId MenuID, index int) MenuCheck { var result MenuCheck C.XPLMCheckMenuItemState(C.XPLMMenuID(menuId), C.int(index), (*C.XPLMMenuCheck)(unsafe.Pointer(&result))) return result }
func CheckMenuItem(menuId MenuID, index int, check MenuCheck) { C.XPLMCheckMenuItem(C.XPLMMenuID(menuId), C.int(index), C.XPLMMenuCheck(check)) }