Skip to content

Commit

Permalink
Introduce a tiny logo in run-time interface (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
PENG Zhenghao committed Sep 16, 2021
1 parent c72fa56 commit 7df3d14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Binary file added metadrive/assets/logo-tiny.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions metadrive/engine/asset_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,9 @@ def randomize_cover():
selected = get_np_random().choice(files)
selected_file = AssetLoader.file_path("{}/{}".format(background_folder_name, selected))
return selected_file


def get_logo_file():
file = AssetLoader.file_path("logo-tiny.png")
assert os.path.exists(file)
return file
14 changes: 13 additions & 1 deletion metadrive/engine/core/engine_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from metadrive.constants import RENDER_MODE_OFFSCREEN, RENDER_MODE_NONE, RENDER_MODE_ONSCREEN, EDITION, CamMask, \
BKG_COLOR
from metadrive.engine.asset_loader import initialize_asset_loader, close_asset_loader, randomize_cover
from metadrive.engine.asset_loader import initialize_asset_loader, close_asset_loader, randomize_cover, get_logo_file
from metadrive.engine.core.collision_callback import collision_callback
from metadrive.engine.core.force_fps import ForceFPS
from metadrive.engine.core.light import Light
Expand Down Expand Up @@ -48,6 +48,17 @@ def attach_cover_image(window_width, window_height):
return image


def attach_logo(engine):
cover_file_path = get_logo_file()
image = OnscreenImage(image=cover_file_path)
scale = 0.075
image.set_scale((scale * 3, 1, scale))
image.set_pos((0.8325 * engine.w_scale, 0, -0.94 * engine.h_scale))
image.set_antialias(AntialiasAttrib.MMultisample)
image.setTransparency(True)
return image


class EngineCore(ShowBase.ShowBase):
DEBUG = False
loadPrcFileData("", "window-title {}".format(EDITION))
Expand Down Expand Up @@ -163,6 +174,7 @@ def __init__(self, global_config):

# Display logo
if self.mode == RENDER_MODE_ONSCREEN and (not self.global_config["debug"]):
self._window_logo = attach_logo(self)
self._loading_logo = attach_cover_image(
window_width=self.get_size()[0], window_height=self.get_size()[1]
)
Expand Down

0 comments on commit 7df3d14

Please sign in to comment.