change name Sprite -> Sprite_rs

This commit is contained in:
shenjack 2023-03-25 20:13:17 +08:00
parent 7800f0009b
commit f95d7f96ec
2 changed files with 24 additions and 3 deletions

View File

@ -11,5 +11,13 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pyglet.event import EventDispatcher
class Sprite(EventDispatcher):
def get_version_str() -> str: ...
class Sprite_rs(EventDispatcher):
...
def patch_sprite():
from pyglet import sprite
sprite.Sprite = Sprite_rs

View File

@ -11,7 +11,7 @@ use pyo3::prelude::*;
/// Instance of an on-screen image
/// See the module documentation for usage.
#[pyclass(name = "Sprite", subclass)]
#[pyclass(name = "Sprite_rs", subclass)]
#[pyo3(text_signature = "(img, x=0.0, y=0.0, z=0.0, \
batch=None, group=None, \
subpixel=False, program=None)")]
@ -75,7 +75,7 @@ impl Sprite {
x: f64,
y: f64,
z: f64,
batch: &PyAny,
batch_: &PyAny,
group: &PyAny,
subpixel: bool,
program_: &PyAny,
@ -85,6 +85,7 @@ impl Sprite {
.getattr("Animation")
.unwrap();
let texture;
let batch;
let mut next_dt = 0.0;
let mut animation = None;
let mut program = program_;
@ -137,6 +138,18 @@ impl Sprite {
program = get_default_shader.call0().unwrap();
}
}
// 383
if !batch_.is_none() {
batch = PyModule::import(py_, "pyglet.graphics")
.unwrap()
.getattr("get_default_batch")
.unwrap()
.call0()
.unwrap();
} else {
batch = batch_;
}
Sprite {
subpixel,
batch: batch.into(),