Exemplo n.º 1
0
 def reapply_theme(self):
     Screen.reapply_theme(self)
     self.wrong_button.set_rect_color(Theme.get_color("bad"))
     self.good_button.set_rect_color(Theme.get_color("good"))
     self.bounding_box_color = Theme.get_color("foreground")
     self.cross_color = Theme.get_color("secondary")
     self.draw_color = Theme.get_color("draw")
Exemplo n.º 2
0
 def show_splash_screen(self):
     self.render_surface.fill(Theme.get_color("background"))
     Text(self.render_surface, (0, 200, 1920, 400),
          "Kanaraimasu").set_font_size(200).set_themed().render()
     Text(self.render_surface, (0, 700, 1920, 200),
          "Loading...").set_themed().render()
     self.render()
Exemplo n.º 3
0
 def __init__(
     self,
     surface,
     rect,
     text="",
     color=None,
     themed=None,
     width=10,
     align=Text.ALIGN_CENTER,
 ):
     Text.__init__(self, surface, rect, text, color, themed, width, align)
     color = Theme.get_color() if (themed or color is None) else color
     self.line_color = color
Exemplo n.º 4
0
 def __init__(
     self,
     surface,
     rect,
     text="",
     color=None,
     themed=None,
     width=10,
     align=ALIGN_CENTER,
 ):
     Widget.__init__(self, surface, rect, color, themed)
     color = Theme.get_color() if (themed or color is None) else color
     self.text = text
     self.text_color = color
     self.width = width
     self.font_size = 100
     self.font_name = None
     self.align = align
     self.fonts = {}
Exemplo n.º 5
0
    def __init__(
        self,
        surface,
        rect,
        text="",
        color=None,
        themed=None,
        width=10,
        align=Text.ALIGN_CENTER,
        box_only=False,
        bounding_box=False,
    ):
        self.full_rect = pygame.Rect(rect)
        if box_only:
            # render only a box over the full rect provided
            self.square_rect = self.full_rect
            Text.__init__(self, surface, rect, text, color, themed, width)
        else:
            # render a square box and the text behind that
            r = pygame.Rect(rect)
            # create rect for the checkbox itself
            self.square_rect = pygame.Rect(r.x, r.y, r.h, r.h)
            # subtract the square checkbox (and 25%) from the text rect
            rect = (r.x + r.h + r.h * 0.25, r.y, r.w - r.h, r.h)
            alignment = Text.ALIGN_LEFT_CENTER
            Text.__init__(
                self, surface, rect, text, color, themed, width, alignment
            )

        # the two lines that make a cross in the checkbox
        sr = self.square_rect  # use small variable name here
        self.cross = [
            ((sr.x, sr.y), (sr.x + sr.w, sr.y + sr.h)),
            ((sr.x + sr.w, sr.y), (sr.x, sr.y + sr.h)),
        ]
        color = Theme.get_color() if (themed or color is None) else color
        self.rect_color = color
        self.bounding_box = bounding_box
        self.selected = False
Exemplo n.º 6
0
    def __init__(self, render_surface, surface_size):
        Screen.__init__(self, render_surface, surface_size)

        # the surface where the user draws on
        self.drawing_surface = pygame.Surface(self.surface_size)

        self.stroke_width = Settings.get("stroke_width")
        self.bounding_box_color = Theme.get_color("foreground")
        self.cross_color = Theme.get_color("secondary")
        self.draw_color = Theme.get_color("draw")

        # ingame parameters
        self.pos = (0, 0)

        # widgets that are always present
        self.widgets = {
            "heading":
            Heading(self.render_surface, (0, 0, 1920, 100)).set_themed(),
            "button_menu":
            Button(self.render_surface, (10, 10, 230, 80),
                   "Menu").set_themed(),
            "progress_text":
            Text(self.render_surface, (10, 125, 1900, 100),
                 "Completed: X / Y").set_align(
                     Text.ALIGN_RIGHT_CENTER).set_themed(),
        }

        # widgets that are kanji related
        self.kanji_widgets = [
            # these are used to show up to 3 lines of kanji information
            Text(
                self.render_surface,
                (1160, i, 660, 100),
            ).set_font_size(65).set_align(Text.ALIGN_LEFT_TOP).set_themed()
            for i in [225, 285, 345]
        ]
        self.kanji_widgets.append(
            # this is the kanji character itself
            Text(self.render_surface,
                 (1160, 400, 660, 660)).set_font_size(500).set_font_name(
                     "assets/font/KanjiStrokeOrders_v2.016.ttf").set_themed())

        # widgets in draw state
        self.clear_button = (Button(self.render_surface, (860, 290, 200, 150),
                                    "Clear").set_font_size(90).set_themed())
        self.done_button = Button(self.render_surface, (860, 490, 200, 200),
                                  "Done").set_themed()

        # widgets in the verify state
        self.wrong_button = (Button(
            self.render_surface, (860, 290, 200, 150),
            "Wrong").set_font_size(80).set_themed().set_rect_color(
                Theme.get_color("bad")))
        self.good_button = (Button(self.render_surface, (860, 490, 200, 200),
                                   "Good").set_themed().set_rect_color(
                                       Theme.get_color("good")))

        # widgets in the done state
        self.score_widget = Text(
            self.render_surface,
            (0, 550, 1920, 200),
            "Learned x kana while making y mistakes",
        ).set_themed()
        done_widgets = [
            Text(self.render_surface, (0, 400, 1920, 200),
                 "Done!").set_font_size(200).set_themed(),
            self.score_widget,
            Text(
                self.render_surface,
                (0, 650, 1920, 200),
                "Go back to the menu to try again,",
            ).set_themed(),
            Text(
                self.render_surface,
                (0, 750, 1920, 200),
                "or change the kana you want to learn",
            ).set_themed(),
        ]

        self.state_widgets = {
            "draw": [self.clear_button, self.done_button],
            "verify": [self.wrong_button, self.good_button],
            "done": done_widgets,
        }
Exemplo n.º 7
0
 def reapply_theme(self):
     if self.themed:
         self.set_color(Theme.get_color())
Exemplo n.º 8
0
 def __init__(self, render_surface, surface_size):
     self.render_surface = render_surface
     self.surface_size = surface_size
     self.foreground_color = Theme.get_color()
     self.background_color = Theme.get_color("background")
     Collections.register("screen", self)
Exemplo n.º 9
0
 def reapply_theme(self):
     self.foreground_color = Theme.get_color("foreground")
     self.background_color = Theme.get_color("background")