import arcade
from desktop_aux import *

class desktop_Window(arcade.Window):
  def __init__(self, p):
    super().__init__(
      p.c.windowWidth,
      p.c.windowHeight,
      p.c.windowTitle,
    )
    self.antialiasing = p.c.windowAntialiasing
    self.background_color = arcade.color_from_hex_string(p.c.windowBackgroundColor)
    self.p = p

  def on_draw(self):
    arcade.start_render()
    self.p.deselectedSprites.draw()
    self.p.selectedSprites.draw()
    self.p.titleSprites.draw()

  def on_mouse_press(self, x, y, button, key_modifiers):
    id = desktop_aux_tileIdAt(self.p, x, y)
    if (
      id != None
    ):
      self.p.ctrl.set("selectedId", id)

  def on_update(self, delta):
    self.p.deselectedSprites.update_animation()
    self.p.sequentialTimer.update()
