Esempio n. 1
0
 def __init__(self,
              parent,
              name,
              star,
              value,
              is_orbit=False,
              is_complete_orbit=False,
              is_resonance=False):
     super().__init__(parent)
     self.f1 = self.crear_fuente(16)
     self.f2 = self.crear_fuente(16, bold=True)
     self.star = star
     self.name = name
     self._value = value
     if is_orbit:
         self.orbit = RawOrbit(self.parent.current, round(value, 3))
         self.text = '{:~}'.format(value)
         self.color = COLOR_SELECTED
     elif is_complete_orbit:
         self.orbit = value
         self.text = '{:~}'.format(value.a)
         self.color = COLOR_SELECTED
     else:
         self.color = COLOR_TEXTO
         self.text = '{:~}'.format(value)
     if is_resonance:
         pass
     self.update()
     self.image = self.img_uns
     self.rect = self.image.get_rect(x=3)
     EventHandler.register(self.key_to_mouse, 'Arrow')
Esempio n. 2
0
    def __init__(self, parent):
        rel_props = ['Mass', 'Radius', 'Surface gravity', 'Escape velocity']
        rel_args = ['mass', 'radius', 'gravity', 'escape_velocity']
        abs_args = [
            'density', 'volume', 'surface', 'circumference', 'tilt', 'spin',
            'albedo', 'greenhouse', 'clase'
        ]
        abs_props = [
            'Density', 'Volume', 'Surface area', 'Circumference', 'Axial tilt',
            'Spin', 'Albedo (bond)', 'Greenhouse effect', 'Class'
        ]
        super().__init__(parent, rel_props, abs_props, rel_args, abs_args)
        self.set_modifiables('relatives', 0, 1)
        self.set_modifiables('absolutes', 4, 6, 7)
        self.absolutes.widgets()[4].set_min_and_max(0, 100)
        f = self.crear_fuente(14)
        f.set_underline(True)
        render = f.render('Planets', True, COLOR_TEXTO, COLOR_AREA)
        render_rect = render.get_rect(y=420)
        self.parent.image.blit(render, render_rect)

        f = self.crear_fuente(16, bold=True)
        self.habitable = f.render('Habitable', True, (0, 255, 0), COLOR_BOX)
        self.hab_rect = self.habitable.get_rect(right=self.parent.rect.right -
                                                10,
                                                y=self.parent.rect.y + 50)

        EventHandler.register(self.load_planet, 'LoadData')
Esempio n. 3
0
    def __init__(self,
                 parent,
                 text,
                 x,
                 y,
                 fg=COLOR_TEXTO,
                 bg=COLOR_BOX,
                 kind='digits'):
        super().__init__(parent)
        self.text = text

        f1 = self.crear_fuente(16)
        f2 = self.crear_fuente(16, underline=True)

        self.img_uns = f1.render(text + ':', True, fg, bg)
        self.img_sel = f2.render(text + ':', True, fg, bg)

        self.image = self.img_uns
        self.rect = self.image.get_rect(topleft=(x, y))
        EventHandler.register(self.clear_selection, 'Clear')

        if kind == 'digits':
            self.text_area = NumberArea(self, text, self.rect.right + 3,
                                        self.rect.y, fg, bg)

        elif kind == 'letters':
            self.text_area = TextArea(self, text, self.rect.right + 3,
                                      self.rect.y, fg, bg)
Esempio n. 4
0
 def __init__(self, parent, x, centery):
     super().__init__(parent)
     self.f = self.crear_fuente(16)
     self.base = 'Pressure at Sea Level: '
     self.image = self.f.render(self.base, 1, COLOR_TEXTO, COLOR_BOX)
     self.rect = self.image.get_rect(x=x, centery=centery)
     EventHandler.register(self.on_keydown, 'Key', 'BackSpace', 'Fin')
Esempio n. 5
0
 def select(self):
     if self.enabled:
         self.selected = True
         self.image.fill((255, 255, 255))
         w, h = self.rect.size
         self.image.fill(COLOR_BOX, [1, 1, w - 2, h - 2])
         EventHandler.register(self.on_keydown, 'Key', 'BackSpace', 'Fin')
Esempio n. 6
0
 def deselect(self):
     if self.enabled:
         self.selected = False
         self.image.fill((0, 0, 0))
         w, h = self.rect.size
         self.image.fill(COLOR_BOX, [1, 1, w - 2, h - 2])
         EventHandler.deregister(self.on_keydown)
Esempio n. 7
0
    def __init__(self, parent):
        super().__init__(parent)
        self.name = 'Planetary Orbit'
        self.image = Surface((ANCHO, ALTO - 32))
        self.image.fill(COLOR_BOX)
        self.rect = self.image.get_rect()
        self.properties = WidgetGroup()
        self.buttons = WidgetGroup()
        self.orbit_descriptions = WidgetGroup()
        self._markers = {}
        self.markers = []
        self.added = []
        self.objects = []
        self.satellites = {}
        self._loaded_orbits = []
        self.area_buttons = self.image.fill(COLOR_AREA,
                                            [0, 420, self.rect.w, 200])
        self.area_markers = Rect(3, 58, 380, 20 * 16)
        self.curr_x = self.area_buttons.x + 3
        self.curr_y = self.area_buttons.y + 21
        self.planet_area = AvailablePlanets(self, ANCHO - 200, 32, 200, 340)
        self.add_orbits_button = SetOrbitButton(self, ANCHO - 94, 394)
        self.area_modify = ModifyArea(self, ANCHO - 201, 374)
        self.show_markers_button = ToggleableButton(self, 'Satellites',
                                                    self.toggle_stellar_orbits,
                                                    3, 421)
        self.show_markers_button.disable()
        self.resonances_button = AddResonanceButton(self, ANCHO - 140, 416)
        self.order_f = self.crear_fuente(14)
        self.write(self.name + ' Panel',
                   self.crear_fuente(16, underline=True),
                   centerx=(ANCHO // 4) * 1.5,
                   y=0)
        self.digit_x = RatioDigit(self, 'x',
                                  self.resonances_button.rect.left - 60,
                                  self.resonances_button.rect.y)
        self.write(':',
                   self.crear_fuente(16),
                   topleft=[
                       self.digit_x.rect.right + 1,
                       self.resonances_button.rect.y - 1
                   ])
        self.digit_y = RatioDigit(self, 'y', self.digit_x.rect.right + 9,
                                  self.resonances_button.rect.y)
        self.ratios = [self.digit_x, self.digit_y]
        self.cycler = cycle(self.ratios)
        next(self.cycler)

        self.properties.add(self.area_modify,
                            self.show_markers_button,
                            self.digit_x,
                            self.digit_y,
                            self.planet_area,
                            self.add_orbits_button,
                            self.resonances_button,
                            layer=2)

        EventHandler.register(self.save_orbits, 'Save')
        EventHandler.register(self.load_orbits, 'LoadData')
Esempio n. 8
0
    def __init__(self, parent, x, y):
        super().__init__(parent)

        self.image = Surface(graph.get_size())
        self.image.blit(graph, (0, 0))
        self.canvas = Surface(graph.get_size(), SRCALPHA)
        self.rect = self.image.get_rect(topleft=(x, y))
        self.name = 'atmograph'
        EventHandler.register(self.on_keydown, 'Fin', 'Arrow')
Esempio n. 9
0
 def __init__(self, parent):
     super().__init__(parent)
     self.properties = WidgetGroup()
     self.primary = None
     self.secondary = None
     self.separation = None
     self.ecc_p = None
     self.ecc_s = None
     self.create()
     EventHandler.register(self.clear, 'ClearData')
Esempio n. 10
0
    def save_orbits(self, event):
        orbits = self._loaded_orbits
        for planet_obj in self.planet_area.listed_objects.widgets():
            planet = planet_obj.object_data
            for marker in self._markers.get(planet.id, []):
                if marker.orbit is not None:
                    d = self.create_save_data(marker.orbit)
                    orbits.append(d)

        EventHandler.trigger(event.tipo + 'Data', 'Orbit',
                             {'Planetary Orbits': orbits})
Esempio n. 11
0
 def save_stars(self, event):
     data = []
     for star_button in self.star_buttons:
         star = star_button.object_data
         star_data = {
             'name': star.name,
             'mass': star.mass.m,
             'id': star.id,
             'spin': star.spin
         }
         data.append(star_data)
     EventHandler.trigger(event.tipo + 'Data', 'Star', {"Stars": data})
Esempio n. 12
0
 def save_satellites(self, event):
     data = []
     for moon_button in self.satellites.widgets():
         moon = moon_button.object_data
         moon_data = {
             'name': moon.name,
             'radius': moon.radius.m,
             'composition': moon.composition,
             'id': moon.id,
             'system': moon.system_id
         }
         data.append(moon_data)
         EventHandler.trigger(event.tipo + 'Data', 'Planet',
                              {"Satellites": data})
Esempio n. 13
0
    def save_systems(self, event):
        data = []
        for button in self.system_buttons.widgets():
            current = button.object_data
            d = {
                'primary': current.primary.id,
                'secondary': current.secondary.id,
                'avg_s': current.average_separation.m,
                'ecc_p': current.ecc_p.m,
                "ecc_s": current.ecc_s.m,
                "id": current.id,
                "name": current.name
            }
            data.append(d)

        EventHandler.trigger(event.tipo + 'Data', 'Systems', {'Systems': data})
Esempio n. 14
0
    def save_orbits(self, event):
        orbits = self._loaded_orbits
        for system in Systems.get_systems():
            if system.star_system.letter == 'S':
                for star in system:
                    for marker in self._orbits.get(star, []):
                        d = self.create_save_data(marker.orbit)
                        orbits.append(d)
            else:
                star = system.star_system
                for marker in self._orbits.get(star, []):
                    d = self.create_save_data(marker.orbit)
                    orbits.append(d)

        EventHandler.trigger(event.tipo + 'Data', 'Orbit',
                             {'Stellar Orbits': orbits})
Esempio n. 15
0
 def save_satellites(self, event):
     data = []
     for moon_button in self.asteroids.widgets():
         moon = moon_button.object_data
         moon_data = {
             'name': moon.name,
             'a axis': moon.a_axis.m,
             'b axis': moon.b_axis.m,
             'c axis': moon.c_axis.m,
             'composition': moon.composition,
             'id': moon.id,
             'system': moon.system_id
         }
         data.append(moon_data)
         EventHandler.trigger(event.tipo + 'Data', 'Planet',
                              {"Asteroids": data})
Esempio n. 16
0
    def __init__(self, parent):
        super().__init__('Planet', parent)
        self.area_buttons = self.image.fill(COLOR_AREA,
                                            [0, 420, self.rect.w, 200])
        self.current = PlanetType(self)
        self.properties = WidgetGroup()

        self.unit = Unit(self, 0, 416)
        self.properties.add(self.unit)

        self.button_add = AddPlanetButton(self, ANCHO - 13, 398)
        self.button_del = DelPlanetButton(self, ANCHO - 13, 416)
        self.properties.add(self.button_add, self.button_del)
        self.planet_buttons = WidgetGroup()
        self.planets = []
        EventHandler.register(self.save_planets, 'Save')
        EventHandler.register(self.name_current, 'NameObject')
Esempio n. 17
0
 def save_planets(self, event):
     data = self.current.loaded_data if self.current.loaded_data is not None else []
     for system in Systems.get_systems():
         for planet in self.planets:
             if planet in system.planets:
                 planet_data = {
                     'name': planet.name,
                     'mass': planet.mass.m,
                     'radius': planet.radius.m,
                     'unit': planet.unit,
                     'atmosphere': planet.atmosphere,
                     'composition': planet.composition,
                     'clase': planet.clase,
                     'system': system.id,
                     'id': planet.id,
                     'albedo': planet.albedo.m,
                     'tilt': planet.tilt.m
                 }
                 data.append(planet_data)
     EventHandler.trigger(event.tipo + 'Data', 'Planet', {"Planets": data})
Esempio n. 18
0
 def __init__(self, parent):
     super().__init__('Asteroid', parent)
     self.properties = WidgetGroup()
     self.current = AsteroidType(self)
     f1 = self.crear_fuente(16, underline=True)
     f2 = self.crear_fuente(13, underline=True)
     r = self.image.fill(COLOR_AREA, [0, 420, (self.rect.w // 4) + 32, 200])
     self.write('Composition', f1, COLOR_AREA, topleft=(0, 420))
     self.area_asteroids = self.image.fill(COLOR_AREA,
                                           (r.right + 10, r.y, 400, 200))
     self.write('Asteroids',
                f2,
                COLOR_AREA,
                x=self.area_asteroids.x + 3,
                y=self.area_asteroids.y)
     self.curr_x = self.area_asteroids.x + 3
     self.curr_y = self.area_asteroids.y + 21
     self.properties.add(self.current)
     self.button_add = AddAsteroidButton(self, ANCHO - 13, 398)
     self.button_del = DelAsteroidButton(self, ANCHO - 13, 416)
     self.properties.add(self.button_add, self.button_del)
     self.asteroids = WidgetGroup()
     self.moons = []
     EventHandler.register(self.load_satellites, 'LoadData')
     EventHandler.register(self.save_satellites, 'Save')
     EventHandler.register(self.name_current, 'NameObject')
Esempio n. 19
0
    def __init__(self, parent):
        super().__init__(parent)
        self.name = 'Star System'
        self.image = Surface((ANCHO, ALTO - 32))
        self.image.fill(COLOR_BOX)
        self.rect = self.image.get_rect()
        self.area_buttons = self.image.fill(COLOR_AREA,
                                            [0, 420, self.rect.w, 200])
        self.f2 = self.crear_fuente(14, underline=True)
        self.write('Star Systems', self.f2, COLOR_AREA, x=3, y=420)
        self.properties = WidgetGroup()
        self.f1 = self.crear_fuente(16, underline=True)
        self.write(self.name + ' Panel',
                   self.f1,
                   centerx=(ANCHO // 4) * 1.5,
                   y=0)
        self.stars_area = AvailableStars(self, ANCHO - 200, 32, 200, 340)

        self.current = SystemType(self)

        self.systems = []
        self.setup_button = SetupButton(self, 484, 416)
        self.undo_button = DissolveButton(self, 334, 416)
        self.restore_button = UndoButton(self, 234, 416)
        self.properties.add(self.setup_button, self.undo_button,
                            self.restore_button, self.stars_area, self.current)
        self.system_buttons = WidgetGroup()
        EventHandler.register(self.save_systems, 'Save')
        EventHandler.register(self.load_systems, 'LoadData')
        EventHandler.register(self.name_current, 'NameObject')
    def init(cls):
        cls._systems = []
        cls.loose_stars = []
        cls._current_idx = 0

        EventHandler.register(cls.save, "SaveDataFile")
        EventHandler.register(cls.compound_save_data, "SaveData")
        EventHandler.register(cls.load_data, 'LoadData')
Esempio n. 21
0
 def __init__(self, parent):
     super().__init__('Star', parent)
     self.properties = WidgetGroup()
     self.current = StarType(self)
     self.area_buttons = self.image.fill(COLOR_AREA,
                                         [0, 420, self.rect.w, 200])
     f = self.crear_fuente(14, underline=True)
     render = f.render('Stars', True, COLOR_TEXTO, COLOR_AREA)
     self.image.blit(render, self.area_buttons.topleft)
     self.button_add = AddStarButton(self, ANCHO - 13, 398)
     self.button_del = DelStarButton(self, ANCHO - 13, 416)
     self.properties.add(self.button_add, self.button_del, layer=1)
     self.stars = []
     EventHandler.register(self.save_stars, 'Save')
     EventHandler.register(self.load_stars, 'LoadData')
     EventHandler.register(self.name_current, 'NameObject')
Esempio n. 22
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     EventHandler.register(self.input, 'Typed', 'BackSpace', 'Fin', 'Key')
Esempio n. 23
0
from engine.frontend.globales import WidgetHandler, Renderer
from engine.frontend.widgets.message import PopUpMessage
from engine.backend.eventhandler import EventHandler

while True:
    try:
        EventHandler.process()
        WidgetHandler.update()
        Renderer.update()
    except AssertionError as error:
        assertion = PopUpMessage(str(error))
        WidgetHandler.lock_and_set(assertion)
Esempio n. 24
0
 def show(self):
     super().show()
     EventHandler.register(self.input, 'Key', 'BackSpace', 'Fin')
Esempio n. 25
0
 def hide(self):
     super().hide()
     EventHandler.deregister(self.input, 'Key', 'BackSpace', 'Fin')
Esempio n. 26
0
 def disable(self):
     self.enabled = False
     WidgetHandler.del_widget(self)
     EventHandler.deregister(self.input, 'Key')
 def compound_save_data(cls, event):
     cls.save_data.update(event.data)
     if not EventHandler.is_quequed('SaveDataFile'):
         EventHandler.trigger('SaveDataFile', 'EngineData', cls.save_data)
Esempio n. 28
0
 def on_mousebuttonup(self, event):
     if event.button == 1:
         EventHandler.trigger('Clear', self)
Esempio n. 29
0
 def on_mousebuttondown(self, event):
     if event.button == 1 and self.enabled:
         EventHandler.trigger('ClearData', 'NewButton',
                              {'panel': self.parent.current})
Esempio n. 30
0
 def __init__(self, parent):
     super().__init__(parent)
     self.properties = WidgetGroup()
     self.create()
     EventHandler.register(self.clear, 'ClearData')
     self.relative_args = ['density', 'mass', 'volume']