mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Bug fixed in sf.String
Code clean up git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1037 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
e28a89f902
commit
870d049bc8
@ -234,14 +234,9 @@ class Main:
|
|||||||
while self.win.GetEvent(event): # Event Handler
|
while self.win.GetEvent(event): # Event Handler
|
||||||
if event.Type == sf.Event.Closed:
|
if event.Type == sf.Event.Closed:
|
||||||
self.win.Close()
|
self.win.Close()
|
||||||
elif event.Type == sf.Event.KeyPressed:
|
elif event.Type == sf.Event.KeyPressed or event.Type == sf.Event.KeyReleased:
|
||||||
for key in self.keys:
|
if event.Key.Code in self.keys:
|
||||||
if event.Key.Code == key:
|
self.keys[event.Key.Code](event.Type == sf.Event.KeyPressed)
|
||||||
self.keys[key](True)
|
|
||||||
elif event.Type == sf.Event.KeyReleased:
|
|
||||||
for key in self.keys:
|
|
||||||
if event.Key.Code == key:
|
|
||||||
self.keys[key](False)
|
|
||||||
self.win.Display()
|
self.win.Display()
|
||||||
self.win.Clear(background_color)
|
self.win.Clear(background_color)
|
||||||
self.next_frame(self.win)
|
self.next_frame(self.win)
|
||||||
|
@ -63,7 +63,7 @@ PySfFont_LoadFromFile(PySfFont* self, PyObject *args, PyObject *kwds)
|
|||||||
int Length;
|
int Length;
|
||||||
bool result;
|
bool result;
|
||||||
std::string Encoding;
|
std::string Encoding;
|
||||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "s|I:Font.LoadFromFile", (char **)kwlist, &Filename, &Charsize))
|
if (PyArg_ParseTuple(args, "s|I:Font.LoadFromFile", &Filename, &Charsize))
|
||||||
result = self->obj->LoadFromFile(Filename, Charsize);
|
result = self->obj->LoadFromFile(Filename, Charsize);
|
||||||
else if (PyArg_ParseTupleAndKeywords(args, kwds, "s|Iu:Font.LoadFromFile", (char **)kwlist, &Filename, &Charsize, &Charset))
|
else if (PyArg_ParseTupleAndKeywords(args, kwds, "s|Iu:Font.LoadFromFile", (char **)kwlist, &Filename, &Charsize, &Charset))
|
||||||
{
|
{
|
||||||
@ -113,7 +113,7 @@ PySfFont_LoadFromMemory(PySfFont* self, PyObject *args, PyObject *kwds)
|
|||||||
int Length;
|
int Length;
|
||||||
bool result;
|
bool result;
|
||||||
std::string Encoding;
|
std::string Encoding;
|
||||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "s#|I:Font.LoadFromMemory", (char **)kwlist, &Data, &Size, &Charsize))
|
if (PyArg_ParseTuple(args, "s#|I:Font.LoadFromMemory", &Data, &Size, &Charsize))
|
||||||
result = self->obj->LoadFromMemory(Data, Size, Charsize);
|
result = self->obj->LoadFromMemory(Data, Size, Charsize);
|
||||||
else if (PyArg_ParseTupleAndKeywords(args, kwds, "s#|Iu:Font.LoadFromMemory", (char **)kwlist, &Data, &Size, &Charsize, &Charset))
|
else if (PyArg_ParseTupleAndKeywords(args, kwds, "s#|Iu:Font.LoadFromMemory", (char **)kwlist, &Data, &Size, &Charsize, &Charset))
|
||||||
{
|
{
|
||||||
|
@ -38,19 +38,22 @@ bool CustomSoundStream::OnStart()
|
|||||||
Py_DECREF(OnStart);
|
Py_DECREF(OnStart);
|
||||||
Py_DECREF(Result);
|
Py_DECREF(Result);
|
||||||
}
|
}
|
||||||
|
if (PyErr_Occurred())
|
||||||
|
{
|
||||||
|
PyErr_Print();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomSoundStream::OnGetData(Chunk& Data)
|
bool CustomSoundStream::OnGetData(Chunk& Data)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (PyData != NULL) {
|
Py_XDECREF(PyData);
|
||||||
Py_DECREF(PyData);
|
PyData = NULL;
|
||||||
}
|
|
||||||
if (PyObject_HasAttrString(SoundStream, "OnGetData"))
|
if (PyObject_HasAttrString(SoundStream, "OnGetData"))
|
||||||
{
|
{
|
||||||
PyObject *Function = PyObject_GetAttrString(SoundStream, "OnGetData");
|
PyObject *Function = PyObject_GetAttrString(SoundStream, "OnGetData");
|
||||||
Data.NbSamples = 0;
|
|
||||||
PyData = PyObject_CallFunction(Function, NULL);
|
PyData = PyObject_CallFunction(Function, NULL);
|
||||||
if (PyData != NULL)
|
if (PyData != NULL)
|
||||||
{
|
{
|
||||||
@ -63,6 +66,13 @@ bool CustomSoundStream::OnGetData(Chunk& Data)
|
|||||||
}
|
}
|
||||||
Py_DECREF(Function);
|
Py_DECREF(Function);
|
||||||
}
|
}
|
||||||
|
if (PyErr_Occurred())
|
||||||
|
{
|
||||||
|
PyErr_Print();
|
||||||
|
Py_XDECREF(PyData);
|
||||||
|
PyData = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,10 @@ PySfString_SetFont(PySfString* self, PyObject *args)
|
|||||||
{
|
{
|
||||||
PySfFont *Font = (PySfFont *)args;
|
PySfFont *Font = (PySfFont *)args;
|
||||||
if (!PyObject_TypeCheck(Font, &PySfFontType))
|
if (!PyObject_TypeCheck(Font, &PySfFontType))
|
||||||
|
{
|
||||||
PyErr_SetString(PyExc_ValueError, "String.SetFont() Argument must be a sf.Font");
|
PyErr_SetString(PyExc_ValueError, "String.SetFont() Argument must be a sf.Font");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
self->obj->SetFont(*(Font->obj));
|
self->obj->SetFont(*(Font->obj));
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user