Skip to content

Commit

Permalink
修复了目前的一些问题(就是懒得具体看了
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjackyuanjie committed Jul 26, 2024
1 parent 649cd4c commit d191a36
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Difficult_Rocket/api/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def on_deactivate(self, window: ClientWindow):
:event:
"""

def on_draw(self, dt: float, window: ClientWindow): # TODO: wait for pyglet 2.1
# def on_draw(self, window: ClientWindow):
# def on_draw(self, dt: float, window: ClientWindow): # TODO: wait for pyglet 2.1
def on_draw(self, window: ClientWindow):
"""The window contents must be redrawn.
The `EventLoop` will dispatch this event when the window
Expand Down
16 changes: 7 additions & 9 deletions Difficult_Rocket/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ def __init__(self, game: "Game", net_mode="local", *args, **kwargs):
self.push_handlers(self.input_box)
self.input_box.enabled = True
# 设置刷新率
# pyglet.clock.schedule_interval(self.draw_update, float(self.SPF))
# 完成设置后的信息输出
self.logger.info(tr().window.os.pid_is().format(os.getpid(), os.getppid()))
end_time = time.time_ns()
Expand All @@ -295,7 +294,7 @@ def __init__(self, game: "Game", net_mode="local", *args, **kwargs):
self.logger.debug(tr().window.setup.use_time_ns().format(self.use_time))

def setup(self):
self.set_icon(pyglet.image.load("assets/textures/icon.png"))
self.set_icon(pyglet.image.load("assets/textures/icon.ico"))
self.load_fonts()
self.screen_list["DR_debug"] = DRDEBUGScreen(self)
self.game.dispatch_mod_event("on_client_start", game=self.game, client=self)
Expand All @@ -307,10 +306,9 @@ def load_fonts(self) -> None:
pyglet_load_fonts_folder(fonts_folder_path)

def start_game(self) -> None:
self.set_icon(pyglet.image.load("assets/textures/icon.png"))
try:
pyglet.clock.schedule_interval(self.draw_call, float(self.SPF))
pyglet.app.run(None)
# pyglet.clock.schedule(self.draw_call)
pyglet.app.run(0)
except KeyboardInterrupt:
self.logger.warn(
"==========client stop. KeyboardInterrupt info==========", tag="starter"
Expand Down Expand Up @@ -356,17 +354,17 @@ def draw_update(self, tick: float):
now_FPS = pyglet.clock.get_frequency()
self.fps_log.update_tick(now_FPS, decimal_tick)

def draw_call(self, dt: float):
def draw_call(self):
self.switch_to()
self.on_draw(dt)
self.on_draw()
self.flip()

@_call_screen_after
def on_draw(self, dt: float):
def on_draw(self, *dt: float):
while (command := self.game.console.get_command()) is not None:
self.on_command(line.CommandText(command))
self.clear()
self.draw_update(dt)
self.draw_update(float(self.SPF))
self.draw_batch()

@_call_screen_after
Expand Down
10 changes: 8 additions & 2 deletions Difficult_Rocket/gui/widget/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
# All rights reserved
# -------------------------------

from __future__ import annotations
from typing import Optional, Tuple, Type

# from libs import pyglet
import pyglet
from pyglet.gl import GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA
from pyglet.graphics.shader import ShaderProgram
from pyglet.text import Label
from pyglet.gui import widgets
from pyglet.window import mouse

# from pyglet.sprite import Sprite
from pyglet.shapes import Rectangle, BorderedRectangle
from pyglet.shapes import Rectangle, BorderedRectangle, ShapeBase

# from pyglet.image import AbstractImage
from pyglet.graphics import Batch, Group
Expand All @@ -22,9 +25,12 @@

# from Difficult_Rocket import DR_status


RGBA = Tuple[int, int, int, int]

class 拐角(ShapeBase):
def __init__(self, vertex_count: int, blend_src: int = ..., blend_dest: int = ..., batch: Batch | None = None, group: Group | None = None, program: ShaderProgram | None = None) -> None:
super().__init__(vertex_count, blend_src, blend_dest, batch, group, program)


class BaseButtonTheme:
"""
Expand Down
3 changes: 2 additions & 1 deletion mods/dr_game/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,6 @@ def on_release(button: PressTextButton, x, y):
# main_window.push_handlers(self.button3)
main_window.push_handlers(self.enter_ship_editor_button)

def on_draw(self, dt: float, window: ClientWindow):
# def on_draw(self, dt: float, window: ClientWindow): # TODO: wait for pyglet 2.1
def on_draw(self, window: ClientWindow):
self.main_batch.draw()
4 changes: 2 additions & 2 deletions mods/dr_game/sr1_ship.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ def draw_batch(self, window: ClientWindow):
gl.glScissor(0, 0, self.window_pointer.width, self.window_pointer.height)
gl.glDisable(gl.GL_SCISSOR_TEST)

def on_draw(self, dt: float, window): # TODO: wait for pyglet 2.1
# def on_draw(self, window: ClientWindow):
# def on_draw(self, dt: float, window): # TODO: wait for pyglet 2.1
def on_draw(self, window: ClientWindow):
if self.status.draw_call:
self.render_ship()

Expand Down

0 comments on commit d191a36

Please sign in to comment.