예제 #1
0
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))
}
예제 #2
0
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))
}
예제 #3
0
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)))
}
예제 #4
0
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] = &regInfo{handler, id, menuRef, make(map[*C.char]interface{})}
	}
	return id
}
예제 #5
0
func AppendMenuSeparator(menuId MenuID) {
	C.XPLMAppendMenuSeparator(C.XPLMMenuID(menuId))
}
예제 #6
0
func ClearAllMenuItems(menuId MenuID) {
	C.XPLMClearAllMenuItems(C.XPLMMenuID(menuId))
}
예제 #7
0
func DestroyMenu(menuId MenuID) {
	C.XPLMDestroyMenu(C.XPLMMenuID(menuId))
	id, _ := findMenu(menuId)
	delete(handlers, id)
	C.free(unsafe.Pointer(id))
}
예제 #8
0
func RemoveMenuItem(menuId MenuID, index int) {
	C.XPLMRemoveMenuItem(C.XPLMMenuID(menuId), C.int(index))
}
예제 #9
0
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
}
예제 #10
0
func CheckMenuItem(menuId MenuID, index int, check MenuCheck) {
	C.XPLMCheckMenuItem(C.XPLMMenuID(menuId), C.int(index), C.XPLMMenuCheck(check))
}