@@ -50,6 +50,13 @@ cdef extern from "error.hpp":
5050 void restorePythonErrorBuffer()
5151 object getLastErrorMessage()
5252
53+ cdef extern from " hacks.h" :
54+ sf.Time Time_div_int(sf.Time left, Int64)
55+ sf.Time Time_div_float(sf.Time left, float )
56+ float Time_div_Time(sf.Time, sf.Time)
57+ void Time_idiv_int(sf.Time& , Int64)
58+ void Time_idiv_float(sf.Time& , float )
59+
5360__all__ = [' Time' , ' sleep' , ' Clock' , ' seconds' , ' milliseconds' , ' microseconds' ,
5461 ' Vector2' , ' Vector3' ]
5562
@@ -440,6 +447,38 @@ cdef public class Time[type PyTimeType, object PyTimeObject]:
440447 p[0 ] = x.p_this[0 ] - y.p_this[0 ]
441448 return wrap_time(p)
442449
450+ def __mul__ (Time self , other ):
451+ cdef sf.Time* p = new sf.Time()
452+
453+ if isinstance (other, (int , long )):
454+ p[0 ] = self .p_this[0 ] * < Int64> other
455+ elif isinstance (other, float ):
456+ p[0 ] = self .p_this[0 ] * < float > other
457+ else :
458+ return NotImplemented
459+
460+ return wrap_time(p)
461+
462+ def __truediv__ (Time self , other ):
463+ cdef sf.Time* p
464+
465+ if isinstance (other, Time):
466+ # return self.p_this[0] / (<Time>other).p_this[0]
467+ return Time_div_Time(self .p_this[0 ], (< Time> other).p_this[0 ])
468+ else :
469+ p = new sf.Time()
470+ if isinstance (other, (int , long )):
471+ # p[0] = self.p_this[0] / <Int64>other
472+ p[0 ] = Time_div_int(self .p_this[0 ], < Int64> other)
473+ elif isinstance (other, float ):
474+ # p[0] = self.p_this[0] / <float>other
475+ p[0 ] = Time_div_float(self .p_this[0 ], < float > other)
476+ else :
477+ del p
478+ return NotImplemented
479+
480+ return wrap_time(p)
481+
443482 def __mod__ (Time x , Time y ):
444483 cdef sf.Time* p = new sf.Time()
445484 p[0 ] = x.p_this[0 ] % y.p_this[0 ]
@@ -453,6 +492,28 @@ cdef public class Time[type PyTimeType, object PyTimeObject]:
453492 self .p_this[0 ] -= x.p_this[0 ]
454493 return self
455494
495+ def __imul__ (Time self , other ):
496+ if isinstance (other, (int , long )):
497+ self .p_this[0 ] *= < Int64> other
498+ elif isinstance (other, float ):
499+ self .p_this[0 ] *= < float > other
500+ else :
501+ return NotImplemented
502+
503+ return self
504+
505+ def __itruediv__ (Time self , other ):
506+ if isinstance (other, (int , long )):
507+ # self.p_this[0] /= <Int64>other
508+ Time_idiv_int(self .p_this[0 ], < Int64> other)
509+ elif isinstance (other, float ):
510+ # self.p_this[0] /= <float>other
511+ Time_idiv_float(self .p_this[0 ], < float > other)
512+ else :
513+ return NotImplemented
514+
515+ return self
516+
456517 def __imod__ (self , Time x ):
457518 self .p_this[0 ] %= x.p_this[0 ]
458519 return self
0 commit comments