Beispiel #1
0
    def populate(self, population):
        listed = []
        for i, obj in enumerate(population):
            x = self.rect.x + 3
            y = i * 16 + self.rect.y + 21
            listed.append(self.listed_type(self, obj, x, y))

        self.listed_objects.add(*listed, layer=Systems.get_current_idx())
Beispiel #2
0
    def populate(self, population):
        listed = []
        for i, planet in enumerate(population):
            listed.append(
                ListedPlanet(self, planet, self.rect.x + 3,
                             i * 16 + self.rect.y + 21))

        self.listed_objects.add(*listed, layer=Systems.get_current_idx())
Beispiel #3
0
 def show(self):
     system = Systems.get_current()
     if system is not None:
         planets = [i for i in system.planets if i.orbit is None]
         if not len(
                 self.listed_objects.get_widgets_from_layer(
                     Systems.get_current_idx())):
             self.populate(planets)
     super().show()
Beispiel #4
0
 def show(self):
     system = Systems.get_current()
     if system is not None:
         bodies = [
             body for body in system.astro_bodies if body.hill_sphere != 0
         ]
         if not len(
                 self.listed_objects.get_widgets_from_layer(
                     Systems.get_current_idx())):
             self.populate(bodies)
     super().show()
Beispiel #5
0
 def add_button(self, planet):
     button = CreatedPlanet(self.current, planet, self.curr_x, self.curr_y)
     if planet.system_id is not None:
         layer_number = Systems.get_system_idx_by_id(planet.system_id)
     else:
         layer_number = Systems.get_current_idx()
         planet.system_id = Systems.get_current().id
     self.planet_buttons.add(button, layer=layer_number)
     self.planets.append(planet)
     self.sort_buttons()
     self.properties.add(button, layer=3)
Beispiel #6
0
 def show(self):
     system = Systems.get_current()
     if system is not None:
         pop = [
             planet for planet in system.planets
             if not len(planet.atmosphere) and planet.orbit is not None
         ]
         if not len(
                 self.listed_objects.get_widgets_from_layer(
                     Systems.get_current_idx())):
             self.populate(pop)
     super().show()
Beispiel #7
0
 def sort_buttons(self):
     x, y = self.curr_x, self.curr_y
     for bt in self.asteroids.get_widgets_from_layer(
             Systems.get_current_idx()):
         bt.move(x, y)
         if not self.area_asteroids.contains(bt.rect):
             bt.hide()
         else:
             bt.show()
         if x + bt.rect.w + 10 < self.rect.w - bt.rect.w + 10:
             x += bt.rect.w + 10
         else:
             x = 3
             y += 32
Beispiel #8
0
 def add_button(self):
     button = AsteroidButton(self.current, self.current.current,
                             self.curr_x, self.curr_y)
     if self.current.current.system_id is not None:
         layer_number = Systems.get_system_idx_by_id(
             self.current.current.system_id)
     else:
         layer_number = Systems.get_current_idx()
         self.current.current.system_id = Systems.get_current().id
     self.moons.append(self.current.current)
     self.asteroids.add(button, layer=layer_number)
     self.properties.add(button)
     self.sort_buttons()
     self.current.erase()
     self.button_add.disable()
Beispiel #9
0
    def update(self):
        super().update()
        idx = Systems.get_current_idx()
        if idx != self.last_idx:
            self.set_current()
            self.last_idx = idx

        if not self.no_star_error:
            self.image.fill(COLOR_BOX, self.area_markers)
        else:
            f = self.crear_fuente(16)
            text = 'There is no star system set. Go back to the Star Panel and set a star first.'
            rect = Rect(50, 100, 200, 100)
            render = render_textrect(text, f, rect.w, (0, 0, 0), COLOR_BOX)
            self.image.blit(render, rect)
Beispiel #10
0
    def add_objects(self):
        system = Systems.get_current()
        if system is not None:
            for obj in system.satellites + system.asteroids:
                if obj not in self.objects:
                    self.objects.append(obj)
                    btn = ObjectButton(self, obj, self.curr_x, self.curr_y)
                    if obj.orbit is not None:
                        btn.update_text(obj.orbit.a)
                        markers = self._markers[obj.orbit.star.id]
                        marker_idx = [
                            i for i in range(len(markers))
                            if markers[i].obj == obj
                        ][0]
                        marker = markers[marker_idx]
                        btn.link_marker(marker)

                    self.buttons.add(btn, layer=Systems.get_current_idx())
                    self.properties.add(btn)
            self.sort_buttons()
Beispiel #11
0
    def check_values(self, composition):
        attrs = {}
        for button in self.properties.get_sprites_from_layer(1):
            attr = ''
            if button in self.relatives:
                idx = self.relatives.widgets().index(button)
                attr = self.relative_args[idx]
            elif button in self.absolutes:
                idx = self.absolutes.widgets().index(button)
                attr = self.absolute_args[idx]
            if button.text_area.value:  # not empty
                string = str(button.text_area.value).split(' ')[0]
                try:
                    setattr(self, attr, float(string))
                    attrs[attr] = float(string)
                except ValueError:
                    setattr(self, attr, button.text_area.value)
                    attrs[attr] = button.text_area.value

        if len(attrs) > 1:
            unit = self.parent.unit.name.lower()
            attrs['unit'] = 'jupiter' if unit == 'gas giant' else 'earth'
            attrs['idx'] = len(
                self.parent.planet_buttons.get_widgets_from_layer(
                    Systems.get_current_idx()))
            if composition is not None:
                attrs['composition'] = composition
            self.current = Planet(attrs)
            self.toggle_habitable()
            if self.current.mass <= Systems.get_current().body_mass:
                self.parent.button_add.enable()
                self.parent.mass_number.mass_color = COLOR_TEXTO
            else:
                self.parent.button_add.disable()
                self.parent.mass_number.mass_color = 200, 0, 0
            self.fill()
 def update(self):
     self.image.fill(COLOR_AREA, (0, 17, self.rect.w, self.rect.h - 17))
     self.show_current(Systems.get_current_idx())
Beispiel #13
0
 def update(self):
     idx = Systems.get_current_idx()
     if idx != self.last_idx:
         self.show_current(idx)
         self.last_idx = idx