Skip to content

Commit 858fc4d

Browse files
author
Roberto De Ioris
committed
added player controller mouse configuration shortcuts
1 parent 59a724b commit 858fc4d

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,85 @@ static PyObject *py_ue_all_actors(ue_PyUObject * self, PyObject * args) {
839839
return ret;
840840
}
841841

842+
static PyObject *py_ue_show_mouse_cursor(ue_PyUObject * self, PyObject * args) {
843+
844+
ue_py_check(self);
845+
846+
bool enabled = true;
847+
848+
PyObject *is_true = NULL;
849+
if (!PyArg_ParseTuple(args, "|O:show_mouse_cursor", &is_true)) {
850+
return NULL;
851+
}
852+
853+
if (is_true && !PyObject_IsTrue(is_true))
854+
enabled = false;
855+
856+
UWorld *world = ue_get_uworld(self);
857+
if (!world)
858+
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
859+
860+
APlayerController *controller = world->GetFirstPlayerController();
861+
if (controller)
862+
controller->bShowMouseCursor = enabled;
863+
864+
Py_INCREF(Py_None);
865+
return Py_None;
866+
}
867+
868+
static PyObject *py_ue_enable_click_events(ue_PyUObject * self, PyObject * args) {
869+
870+
ue_py_check(self);
871+
872+
bool enabled = true;
873+
874+
PyObject *is_true = NULL;
875+
if (!PyArg_ParseTuple(args, "|O:enable_click_events", &is_true)) {
876+
return NULL;
877+
}
878+
879+
if (is_true && !PyObject_IsTrue(is_true))
880+
enabled = false;
881+
882+
UWorld *world = ue_get_uworld(self);
883+
if (!world)
884+
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
885+
886+
APlayerController *controller = world->GetFirstPlayerController();
887+
if (controller)
888+
controller->bEnableClickEvents = enabled;
889+
890+
Py_INCREF(Py_None);
891+
return Py_None;
892+
}
893+
894+
static PyObject *py_ue_enable_mouse_over_events(ue_PyUObject * self, PyObject * args) {
895+
896+
ue_py_check(self);
897+
898+
bool enabled = true;
899+
900+
PyObject *is_true = NULL;
901+
if (!PyArg_ParseTuple(args, "|O:enable_mouse_over_events", &is_true)) {
902+
return NULL;
903+
}
904+
905+
if (is_true && !PyObject_IsTrue(is_true))
906+
enabled = false;
907+
908+
UWorld *world = ue_get_uworld(self);
909+
if (!world)
910+
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
911+
912+
913+
APlayerController *controller = world->GetFirstPlayerController();
914+
if (controller)
915+
controller->bEnableMouseOverEvents = enabled;
916+
917+
Py_INCREF(Py_None);
918+
return Py_None;
919+
}
920+
842921
static PyObject *py_ue_actor_components(ue_PyUObject * self, PyObject * args) {
843922

844923
ue_py_check(self);
@@ -1038,6 +1117,9 @@ static PyMethodDef ue_PyUObject_methods[] = {
10381117
{ "get_actor_bounds", (PyCFunction)py_ue_get_actor_bounds, METH_VARARGS, "" },
10391118
{ "line_trace_single_by_channel", (PyCFunction)py_ue_line_trace_single_by_channel, METH_VARARGS, "" },
10401119
{ "line_trace_multi_by_channel", (PyCFunction)py_ue_line_trace_multi_by_channel, METH_VARARGS, "" },
1120+
{ "show_mouse_cursor", (PyCFunction)py_ue_show_mouse_cursor, METH_VARARGS, "" },
1121+
{ "enable_click_events", (PyCFunction)py_ue_enable_click_events, METH_VARARGS, "" },
1122+
{ "enable_mouse_over_events", (PyCFunction)py_ue_enable_mouse_over_events, METH_VARARGS, "" },
10411123
{ NULL } /* Sentinel */
10421124
};
10431125

0 commit comments

Comments
 (0)