Ejemplo n.º 1
0
def launch_intro_text2():
    S = parameters.W
    screen = thorpy.get_screen()
    title_text = "The beginning (2)"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    end_text = "... My only hope now is to become the greatest racer.."
    end_text = thorpy.pack_text(400, end_text)
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7 * S), INTRO2))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter], (w, S // 2))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    background = thorpy.load_image("PaulinaRiva.png")
    background = thorpy.get_resized_image(background,
                                          (parameters.W, parameters.H // 2),
                                          type_=max)
    ##    background = thorpy.Background.make(image=background)
    thorpy.get_screen().blit(background, (0, 0))
    pygame.display.flip()
    box = thorpy.make_ok_box([title, boxletter, end], "Ok")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    boxletter.set_main_color((200, 200, 200, 50))
    box.set_main_color((200, 200, 255, 100))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    launch(box)
Ejemplo n.º 2
0
def get_options_elements():
    efont = thorpy.make_font_options_setter("./metadata", "Font Options")
    tmemory = thorpy.make_text("Memory usage", thorpy.style.TITLE_FONT_SIZE,
                               thorpy.style.TITLE_FONT_COLOR)
    text2 = thorpy.make_text(
        "Set to 1 for no pre-loaded chunks (may work great on fast machines):")
    ememory = thorpy.SliderX.make(200, (1, 1000),
                                  "Max Mb used",
                                  type_=int,
                                  initial_value=parameters.MAX_MEMORY_USAGE)
    esound = thorpy.Checker.make("Music", parameters.MUSIC)
    ereflect = thorpy.Checker.make("Ship reflect", parameters.REFLECT)
    eclouds = thorpy.Checker.make("Clouds reflects", parameters.NCLOUDS > 0)
    eimpacts = thorpy.SliderX.make(200, (0, 50),
                                   "Rain impacts (0 for deactivated)",
                                   type_=int,
                                   initial_value=parameters.RAIN_IMPACTS)
    tgraphics = thorpy.make_text("Graphics", thorpy.style.TITLE_FONT_SIZE,
                                 thorpy.style.TITLE_FONT_COLOR)
    tmisc = thorpy.make_text("Misc. options", thorpy.style.TITLE_FONT_SIZE,
                             thorpy.style.TITLE_FONT_COLOR)
    return [
        tmisc, efont, esound,
        thorpy.Line.make(100, "h"), tmemory, text2, ememory,
        thorpy.Line.make(100, "h"), tgraphics, ereflect, eclouds, eimpacts
    ]
Ejemplo n.º 3
0
def read_treasure(treas):
    title = thorpy.make_text(treas.title,
                             font_size=thorpy.style.FONT_SIZE + 3,
                             font_color=TCOLOR)
    line = thorpy.Line.make(100, "h")
    text = thorpy.make_text(thorpy.pack_text(100, treas.text))
    elements = [title, line, text]

    class Choice:
        ok = False

    def func_cancel():
        Choice.ok = True
        thorpy.functions.quit_menu_func()

    box = thorpy.make_ok_cancel_box(elements, "No, let it there",
                                    "Yes, take it")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.e_cancel.user_func = func_cancel
    box.e_cancel.user_params = {}
    box.center()
    ##    box.add_reaction(thorpy.ConstantReaction(pygame.KEYDOWN,
    ##                                             thorpy.functions.quit_menu_func,
    ##                                             {"key":pygame.K_SPACE}))
    m = thorpy.Menu([box])
    m.play()
    return Choice.ok
Ejemplo n.º 4
0
def make_alert(title, text, font_size=None, font_color=None, ok_text="Ok"):
    from thorpy.miscgui.launchers.launcher import make_ok_box
    e_title = thorpy.make_text(title, thorpy.style.TITLE_FONT_SIZE,
                               (255, 0, 0))
    e_text = thorpy.make_text(text, font_size, font_color)
    box = make_ok_box([e_title, e_text], ok_text=ok_text)
    return box
Ejemplo n.º 5
0
def get_intro_text():
    image = thorpy.load_image("message_in_a_bottle_by_solid_pawn.png")
    image = pygame.transform.scale(image, (parameters.S,parameters.S))
    title_text = "Dear friend,\nA few years ago, I found a message in a bottle near the sea...\n"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    text = "At that time, I was working hard on that famous Topological Astronomy Problem and I began to inattentively read the message..."+\
            "But to my great surprise, it appeared that the author of the letter, a certain Gottfried Perigeo,"+\
            " was trying to complete a mad - though so brave! - travel around the world, following West-East axis, almost one century ago.\n\n"+\
            "    Except the fact that the poor explorer sent a desperate SOS message that was obviously received hundred year too late,"+\
            " my interest was peaked by the singular axis he was travelling. Here the story joins the Topological Astronomy Problem.\n\n"+\
            "    Indeed, my dear friend, I was - and I'm still - one of the rare physicists to believe that the world has the topology of a torus"+\
            " (explain uneducated people that it's like donut). Despite several celestial hints, most of my colleagues give no credit in this theory, and invest"+\
            "all their energy in proving that our planet is spherical. The situation was the same during Perigeo's life ; since the famous"+\
            "explorer Girato Settentrio completed the South-North around the world travel, it was clear that Gottfried Perigeo thought the planet"+\
            "is a torus , otherwise the travel he initiated was a suicide, because of the absolute extreme difficulty of the West-East round trip, if it exists.\n\n"+\
            "    I know you trust in my science, my friend, and I have to admit you are one of the few ones. Here is my demand:\n"+\
            "Take all my money. Buy ship, hire mens, prepare a big exploration trip. Find Perigeo's shipwreck, pursue his travel, and finish what he began. Bring back with you a keepsake of Perigeo. He deserves it.\n"+\
            "\n        You cannot let him in here."
    end_text = "Prove the world that our planet is toroidal!"
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7*parameters.S),text))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter],(w,parameters.S//2))
    boxletter.set_main_color((200,200,255,50))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    box = thorpy.make_ok_box([title,boxletter,end],"Accept")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.set_main_color((200,200,255,80))
    box.center()
    background = thorpy.Background(image=image,elements=[box])
    thorpy.style.BOX_RADIUS -= 10
    return background
Ejemplo n.º 6
0
 def __init__(self):
     self.hfull = thorpy.load_image("heart_full.png", (255, 255, 255))
     self.hempty = thorpy.load_image("heart_empty.png", (255, 255, 255))
     self.heart_size = self.hfull.get_size()
     self.heart_spacing = self.heart_size[0] + 5
     self.xlife = -self.heart_spacing + 5
     self.ylife = 5
     #
     self.e_speed = thorpy.make_text("0 km/h", thorpy.style.FONT_SIZE + 8,
                                     (255, 255, 0))
     self.e_speed.stick_to("screen", "top", "top")
     self.e_speed.stick_to("screen", "right", "right", False)
     self.e_speed.move((-50, 5))
     #
     self.e_fuel = LifeBar("Fuel",
                           text_color=(255, 0, 0),
                           font_size=thorpy.style.FONT_SIZE + 8)
     self.e_fuel.stick_to("screen", "top", "top")
     #
     self.e_pos = thorpy.make_text("Xth position",
                                   thorpy.style.FONT_SIZE + 8,
                                   (255, 255, 0))
     self.e_pos.stick_to("screen", "bottom", "bottom")
     #
     self.screen = thorpy.get_screen()
     self.scene = None
     self.hero = None
Ejemplo n.º 7
0
def launch_end():
    S = parameters.W
    screen = thorpy.get_screen()
    title_text = "The End"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    text = "You are the first of the Intergalatic Ranking."
    end_text = "... You are free now."
    end_text = thorpy.pack_text(400, end_text)
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7 * S), text))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter], (w, S // 2))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    background = thorpy.load_image("PaulinaRiva.png")
    background = thorpy.get_resized_image(background,
                                          (parameters.W, parameters.H // 2),
                                          type_=max)
    ##    background = thorpy.Background.make(image=background)
    thorpy.get_screen().blit(background, (0, 0))
    pygame.display.flip()
    box = thorpy.make_ok_box([title, boxletter, end], "Ok")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    boxletter.set_main_color((200, 200, 200, 50))
    box.set_main_color((200, 200, 255, 100))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    launch(box)
Ejemplo n.º 8
0
def get_object(img, oktext, funcok, name, skills, star):
    eimage = thorpy.Image.make(img)
    eok = thorpy.make_button(oktext, func=funcok)
    ename = thorpy.make_text(name)
    ##    sk1 = thorpy.make_text(s1)
    #
    star_full = thorpy.change_color_on_img(star, (255, 0, 255), (255, 201, 14),
                                           (255, 255, 255))
    star_empty = thorpy.change_color_on_img(star, (255, 0, 255),
                                            (255, 255, 255), (255, 255, 255))
    w, h = star.get_size()
    stars = thorpy.Element.make(size=(5 * w, 2 * h * len(skills)))
    skill_elements = []
    for skillname in skills:
        value = skills[skillname]
        sname = thorpy.make_text(skillname + ": ")
        nfill = int(value * 5)
        nempty = 5 - nfill
        elements = [sname]
        for i in range(nfill):
            elements.append(thorpy.Image.make(star_full))
        for i in range(nempty):
            elements.append(thorpy.Image.make(star_empty))
        skill_elements.append(thorpy.make_group(elements))
    eskill = thorpy.Box.make(skill_elements)
    #
    e = thorpy.Element.make(elements=[eimage, ename, eskill, eok])
    thorpy.store(e, mode="h")
    e.fit_children()
    return e
Ejemplo n.º 9
0
def get_line_info(pre, command, post, dsize=0, color=(0, 255, 0)):
    e1 = thorpy.make_text(pre, font_size=thorpy.style.FONT_SIZE + dsize)
    e2 = thorpy.make_text(command,
                          font_size=thorpy.style.FONT_SIZE + 3 + dsize,
                          font_color=color)
    e3 = thorpy.make_text(post, font_size=thorpy.style.FONT_SIZE + dsize)
    line = [e1, e2, e3]
    make_line(line)
    return line
Ejemplo n.º 10
0
 def fill_text_list(self):
     text_to_add = thorpy.make_text(self.text_info[0])
     text_to_add.set_font_size(20)
     text_to_add.set_font_color(colors["BUMBLEBEE"])
     self.texts.append(text_to_add)
     for text in self.text_info:
         info_text = thorpy.make_text("")
         info_text.set_font_size(20)
         info_text.set_font_color(colors["RED"])
         self.texts.append(info_text)
Ejemplo n.º 11
0
 def get_element(self, prename=""):
     fs = thorpy.style.FONT_SIZE
     ename = thorpy.make_text(prename + self.name, fs + 4, (255, 0, 0))
     emoney = thorpy.make_text("Money: " + str(self.money))
     eranking = thorpy.make_text("Intergalactic Ranking: " +
                                 str(self.ranking))
     eranking = thorpy.make_text("Intergalactic Points: " +
                                 str(self.points))
     box = thorpy.Box.make([ename, emoney, eranking])
     return box
Ejemplo n.º 12
0
 def get_stats(self):
     stats = self.game.stats.get()
     elements = [
         thorpy.make_text("Trip Statistics", thorpy.style.TITLE_FONT_SIZE,
                          TCOLOR),
         thorpy.Line.make(200, "h")
     ]
     for title, value, post in stats:
         value = " : " + str(round(value, 1))
         elements.append(thorpy.make_text(title + value + " " + post))
     box = thorpy.make_ok_box(elements)
     box.e_ok.user_func = thorpy.functions.quit_menu_func
     box.e_ok.user_params = {}
     box.center()
     return box
Ejemplo n.º 13
0
def get_journal(game):
    journal_title = thorpy.make_text("Journal",
                                     font_size=thorpy.style.FONT_SIZE + 3,
                                     font_color=TCOLOR)
    line = thorpy.Line.make(100, "h")
    elements = []
    #entries
    for name, day, coord, h, t, text in game.journal.entries:
        e_name = thorpy.make_text(name, font_color=(0, 0, 255))
        infos = thorpy.make_text(" ".join([
            "| Day",
            str(day), ", coord=", coord, ", alt=",
            str(round(h)), ", temp=",
            str(round(t))
        ]),
                                 font_color=(50, 50, 150))
        ##            e_title = thorpy.Element.make(elements=[e_name,infos])
        ##            thorpy.store(e_title, mode="h")
        e_title = thorpy.make_group([e_name, infos])
        e_title.fit_children()
        elements.append(e_title)
        elements.append(thorpy.make_text("    " + thorpy.pack_text(400, text)))
    subbox = thorpy.Element.make(elements=elements, size=(500, 300))
    thorpy.store(subbox, elements, x=3, y=0, align="left", gap=3)

    #
    def add_entry():
        add_journal_entry(game)
        thorpy.functions.quit_menu_func()

    ok = thorpy.make_button("Ok", func=thorpy.functions.quit_menu_func)
    add = thorpy.make_button("Add entry", func=add_entry)
    ok_add = thorpy.make_group([ok, add])
    #
    box = thorpy.Element.make(elements=[journal_title, subbox, ok_add])
    box.set_main_color((200, 200, 200, 100))
    thorpy.store(box)
    box.fit_children()
    box.set_size((None, int(1.3 * subbox.get_fus_rect().h)))
    #
    subbox.set_prison()
    subbox.refresh_lift()
    ##    box.add_reaction(thorpy.ConstantReaction(pygame.KEYDOWN,
    ##                                             thorpy.functions.quit_menu_func,
    ##                                             {"key":pygame.K_SPACE}))
    box.center()
    m = thorpy.Menu([box])
    m.play()
Ejemplo n.º 14
0
    def first_render(self, location):
        self.elements = []
        self.elements.append(thorpy.make_text("Smelter"))
        self.smelt_items = [thorpy.Clickable.make("None") for x in range(self.max_inv_size)]
        self.button = thorpy.make_button("Smelt", func=self.smelt)
        self.smelt_item_box = thorpy.Box.make(elements=self.smelt_items)
        self.elements.append(self.smelt_item_box)
        self.elements.append(self.button)

        self.smelted_item = thorpy.Clickable.make("None")
        self.smelted_item_box = thorpy.Box.make(elements=[self.smelted_item])
        self.elements.append(self.smelted_item_box)
        self.box = thorpy.Box.make(elements=self.elements)
        self.drag = thorpy.Draggable.make(elements=[self.box])

        reaction = thorpy.Reaction(reacts_to=thorpy.constants.THORPY_EVENT,
                            reac_func=self._pop_smelter,
                            params={"item": self.smelted_item},
                            event_args={"id":thorpy.constants.EVENT_PRESS})



        for item in self.elements:
            item.center(axis=(True, False), element=self.box)

        self.drag.add_reaction(reaction)
        self.drag.set_topleft(location)
        self.sub_menu = thorpy.Menu(self.drag)
        thorpy.functions.set_current_menu(self.sub_menu)
        self.sub_menu.blit_and_update()
Ejemplo n.º 15
0
def show_loading():
    thorpy.get_application().fill((0, 0, 0))
    loading = thorpy.make_text("Loading ...", thorpy.style.TITLE_FONT_SIZE + 5,
                               (0, 0, 200))
    loading.center()
    loading.blit()
    pygame.display.flip()
Ejemplo n.º 16
0
def launch_ingame_options():
    thorpy.set_theme("classic")

    def func():
        parameters.scene.refresh_display()
        box.blit()
        pygame.display.flip()

    e, varset = get_display_options()
    e2 = thorpy.make_button("Show help", scenario.launch_help, {"func": func})

    def leave():
        if thorpy.launch_binary_choice("Are you sure?"):
            parameters.scene.abandon = True
            thorpy.functions.quit_menu_func()
        func()

    q = thorpy.make_button("Abandon", leave)
    box = thorpy.make_ok_box(
        [thorpy.make_text("Pause"),
         thorpy.Line.make(100, "h"), e, e2, q])
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    ##    boxletter.set_main_color((200,200,200,50))
    box.set_main_color((200, 200, 255, 200))
    box.center()
    scenario.launch(box)
    parameters.scene.cam.set_aa(varset.get_value("aa"))
    parameters.VISIBILITY = varset.get_value("visibility")
    thorpy.set_theme(parameters.THEME)
Ejemplo n.º 17
0
 def __init__(self, imgs, duration, pos):
     if isinstance(imgs, str):
         imgs = [thorpy.make_text(imgs, 20, font_color=(0,0,255)).get_image()]
     self.imgs = imgs
     self.duration = duration
     self.pos = pos
     self.time = 0
Ejemplo n.º 18
0
 def __init__(self, player_name, min_val, max_val, trials):
     #init some parameters of the game ...
     self.player_name = player_name
     self.min_val = min_val  #the minimum value to guess
     self.max_val = max_val  #the maximum value to guess
     self.init_trials = trials  #keep the original trials amount in memory
     self.trials = trials  #remaining number of trials
     #the number to guess:
     self.number = random.randint(self.min_val, self.max_val)
     self.guess = None  #the current player guess
     self.e_quit = thorpy.make_button("Quit",
                                      func=thorpy.functions.quit_menu_func)
     self.e_restart = thorpy.make_button("Restart", func=self.restart)
     #a ghost for storing quit and restart:
     self.e_group_menu = thorpy.make_group([self.e_quit, self.e_restart])
     #a counter displaying the trials and some hint/infos about the game
     self.e_counter = thorpy.make_text(text=self.get_trials_text(),
                                       font_color=(0, 0, 255))
     #the inserter element in which player can insert his guess
     self.e_insert = thorpy.Inserter(name="Try:")
     self.e_background = thorpy.Background(
         color=(200, 200, 255),
         elements=[self.e_counter, self.e_insert, self.e_group_menu])
     thorpy.store(self.e_background, gap=20)
     #reaction called each time the player has inserted something
     reaction_insert = thorpy.ConstantReaction(
         reacts_to=thorpy.constants.THORPY_EVENT,
         reac_func=self.reac_insert_func,
         event_args={
             "id": thorpy.constants.EVENT_INSERT,
             "el": self.e_insert
         })
     self.e_background.add_reaction(reaction_insert)
Ejemplo n.º 19
0
    def first_render(self, location):
        self.elements = []
        self.elements.append(thorpy.make_text("Inventory"))
        self.item_clickables = [thorpy.Clickable.make("None") for x in range(self.max_inv_size)]
        self.item_box = thorpy.Box.make(elements=self.item_clickables)
        self.elements.append(self.item_box)
        self.button = thorpy.make_button("Inv", func=self._print_all)
        self.elements.append(self.button)
        self.inv_box = thorpy.Box.make(elements=self.elements)
        self.inv_drag = thorpy.Draggable.make(elements=[self.inv_box])


        for item in self.item_clickables:
            item.center(axis=(True, False), element=self.inv_box)
            
            # this reaction allows us to click the item we want to smelt
            # and transfer it into the smelter
            reaction = thorpy.Reaction(reacts_to=thorpy.constants.THORPY_EVENT,
                            reac_func=self._add_to_smelter,
                            params={"item": item},
                            event_args={"id":thorpy.constants.EVENT_PRESS})
            self.inv_drag.add_reaction(reaction)

        self.inv_drag.set_topleft(location)
        self.inv_menu = thorpy.Menu(self.inv_drag)
        thorpy.functions.set_current_menu(self.inv_menu)
        self.inv_menu.blit_and_update()
Ejemplo n.º 20
0
 def __init__(self, parent, screen, background, font):
     super().__init__(parent, screen, background, font)
     self.rows = 15
     self.columns = 15
     self.mine_count = (self.rows * self.columns) / 10
     self.gameboard = Minefield(self, screen, background, font, self.rows,
                                self.columns, self.mine_count)
     self.title = thorpy.make_text('Minesweeper',
                                   font_size=20,
                                   font_color=(0, 0, 150))
     self.start_button = thorpy.make_button(
         'New Game',
         func=MainMenu.activate_gameboard,
         params={'self': self})
     self.options_button = thorpy.make_button(
         'Options', func=MainMenu.activate_options, params={'self': self})
     self.quit_button = thorpy.make_button('Quit',
                                           func=MainMenu.quit,
                                           params={'self': self})
     self.box = thorpy.Box(elements=[
         self.title, self.start_button, self.options_button,
         self.quit_button
     ],
                           size=(screen.get_width(), screen.get_height()))
     thorpy.store(self.box)
     self.menu = thorpy.Menu(self.box)
     for element in self.menu.get_population():
         element.surface = self.screen
Ejemplo n.º 21
0
 def __init__(self,
              text,
              color=(255, 165, 0),
              text_color=(0, 0, 0),
              size=(200, 30),
              font_size=None,
              type_="h"):
     thorpy.Element.__init__(self)
     painter = thorpy.painterstyle.ClassicFrame(
         size, color=thorpy.style.DEF_COLOR, pressed=True)
     self.set_painter(painter)
     self.finish()
     if type_ == "v":
         self.set_life = self.set_life_v
     else:
         self.set_life = self.set_life_h
     #
     self.life_text = thorpy.make_text(text,
                                       font_color=text_color,
                                       font_size=font_size)
     self.life_text.center(element=self)
     self.life_color = color
     self.add_elements([self.life_text])
     self.life_width = size[0] - 2
     self.life_height = size[1] - 2
     self.life_rect = pygame.Rect(1, 1, self.life_width, self.life_height)
Ejemplo n.º 22
0
def make_instruction(text):
    splits = text.split(":")
    title, corpus = splits[0], "".join(splits[1:])
    corpus = thorpy.pack_text(int(0.6*parameters.S), corpus)
    etitle = thorpy.make_text(title, font_color=(255,0,0))
    ecorpus = thorpy.Element.make(corpus)
    return thorpy.make_group([etitle, ecorpus])
Ejemplo n.º 23
0
def get_imgs_alert(text, color=(255, 0, 0), size1=20, size2=40):
    imgs = []
    element = thorpy.make_text(text, size1, color)
    for s in range(size1, size2):
        element.set_font_size(s)
        imgs.append(element.get_image())
    return imgs  #+ imgs[::-1][]
Ejemplo n.º 24
0
def launch_blocking_choices(text,
                            choices,
                            parent=None,
                            title_fontsize=None,
                            title_fontcolor=None,
                            func=None):
    """choices are tuple (text,func)"""
    if title_fontsize is None: title_fontsize = thorpy.style.FONT_SIZE
    if title_fontcolor is None: title_fontcolor = thorpy.style.FONT_COLOR
    elements = [thorpy.make_button(t, f) for t, f in choices]
    ghost = thorpy.make_group(elements)
    e_text = thorpy.make_text(text, title_fontsize, title_fontcolor)
    box = thorpy.Box.make([e_text, ghost])
    box.center()
    from thorpy.miscgui.reaction import ConstantReaction
    for e in elements:
        reac = ConstantReaction(thorpy.constants.THORPY_EVENT,
                                thorpy.functions.quit_menu_func, {
                                    "id": thorpy.constants.EVENT_UNPRESS,
                                    "el": e
                                })
        box.add_reaction(reac)
    from thorpy.menus.tickedmenu import TickedMenu
    m = TickedMenu(box)
    m.play()
    box.unblit()
    if parent:
        parent.partial_blit(None, box.get_fus_rect())
        box.update()
    if func:
        func()
Ejemplo n.º 25
0
 def __init__(self, titulo="Selecciona:", opciones=[]):
     self.titulo = titulo
     self.checkers = {}
     for opcion in opciones:
         self.add_checker(opcion)
     self.last_checked = None
     self.titulo_element = thorpy.make_text(self.titulo, 12, (0, 0, 0))
Ejemplo n.º 26
0
def get_instructions():
    title = thorpy.make_text("Instructions", thorpy.style.TITLE_FONT_SIZE,
                                gui.TCOLOR)
    perig_coord = (Vector2(parameters.WRECK_COORD)*parameters.S)//10
    cordtext = "Coordinates of Gottfried Perigeo's wreckage: not far from"+str(perig_coord)
    ecoord = make_instruction(cordtext)
    #
    jtext = "Journal: Press J to open crew's logbook. It lists a lot of events, and allow you to add entries."
    ejournal = make_instruction(jtext)
    #
    ftext = "Flags: You have "+str(parameters.MAX_FLAGS)+" flags at your disposal to help you locate. Press F to plant a flag on the ground. You can remove flags. Flags automatically add entries in logbook."
    eflag = make_instruction(ftext)
    #
    stext = "Seasons: Seasons change the terrain and the temperatures. Season change are every "+str(parameters.SEASON_MOD_DAYS)+" day from day zero."
    eseason = make_instruction(stext)
    #
    foodtext = "Food: Crew has to eat in order to survive. Remaining food is schematized by a gauge on the right. Low temperature result in higher demand in food. "+\
                "Ship can carry a limited amount of food, as well as the crew when walking. You can store food from/into villages and camps. You can obtain food by hunting."
    efood = make_instruction(foodtext)
    #
    huntext = "Hunting: Crew members are able to hunt if there are arrows in your stock. Sucessful hunting refill your food bar. The chance to find food depends on the temperature and the skills of the best hunter in your crew."
    ehunt = make_instruction(huntext)
    #
    vtext = "Village: Villages contains and produce food along the year. You can exchange food with villages by pressing E. However, villages become more rare as you go far from civilization."
    evillage = make_instruction(vtext)
    #
    camptext = "Camp: You can camp/uncamp by pressing C. You have "+str(parameters.MAX_CAMPS)+" camps at your disposal. You need a camp to hunt and to wait. As for villages, you can exchange food with camps."
    ecamp = make_instruction(camptext)
    #
    wtext = "Weather: Altitude influe temperature. Wind is schematized by a line over the compass. Wind moves the ship. Sometimes, violent storms can appear."
    eweather = make_instruction(wtext)
    #
    #
    waitext = "Waiting: You can wait for a chosen duration (in days) if you are in a camp. Crew still consume food during waiting. Waiting will be stopped if food level reaches zero. Press P."
    ewait = make_instruction(waitext)
    #
    #
    cannibalismtext = "Cannibalism: In extreme situations, you may take serious decisions... If your food level is null, press X to choose a crew member to eat."
    ecannibal = make_instruction(cannibalismtext)
    #
    #
    oasistext = "Oasis: During summer, you can find food in oasises."
    eoasis = make_instruction(oasistext)
    #
    #
    foresttext = "Forest: hunting near a forest increases by 20 percent your chances of finding food, in any season." #not really true
    eforest = make_instruction(foresttext)
    #
    elements = [ecoord,efood,ehunt,eoasis,eforest,ejournal,evillage,ecamp,eflag,eseason,eweather,ecannibal,ewait,]
    thorpy.style.BOX_RADIUS += 10
    boxletter = thorpy.Box.make(elements,(int(0.9*parameters.S),int(0.8*parameters.S)))
    boxletter.refresh_lift()
    box = thorpy.make_ok_box([title,boxletter])
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.set_main_color((200,200,255))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    return box
Ejemplo n.º 27
0
def main():
    pygame.init()  # Iniciamos pygame.
    infoObject = pygame.display.Info()
    icon = pygame.image.load('images/ant.png')

    preferredSize = int(infoObject.current_h *
                        0.88)  # Obtenemos la altura de la pantalla.
    application = thorpy.Application((preferredSize, preferredSize),
                                     "Langton's Ant", "pygame")

    # Verifica si el tamaño ingresado es válido y si lo es, inicia la simulación.
    def start():
        if tamaño.get_value().isdigit() and iteraciones.get_value().isdigit():
            tam = int(tamaño.get_value())
            it = int(iteraciones.get_value())
            if tam > 0 and it > 0:
                if tam > int(0.65 * (preferredSize // 2)):
                    thorpy.launch_blocking_alert(
                        title="¡Tamaño no soportado!",
                        text=
                        "El tamaño actual generaría una grilla con celdas de tamaño cero.",
                        parent=background)
                    tamaño.set_value("")
                else:
                    simulation.simulate(tam, it, preferredSize)
            else:
                thorpy.launch_blocking_alert(title="¡Tamaño no soportado!",
                                             text="El tamaño no es válido.",
                                             parent=background)
        else:
            thorpy.launch_blocking_alert(
                title="¡Valores incorrectos!",
                text="Los valores introducidos no son válidos.",
                parent=background)
            tamaño.set_value("")
            iteraciones.set_value("")

    iteraciones = thorpy.Inserter(name="Iteraciones: ",
                                  value="1")  # Campo de número de iteraciones.
    tamaño = thorpy.Inserter(name="Tamaño: ", value="10")  # Campo de tamaño.
    boton = thorpy.make_button("Aceptar", start)  # Botón aceptar.

    title_element = thorpy.make_text("Configurar simulación", 22,
                                     (255, 255, 255))

    central_box = thorpy.Box(elements=[iteraciones, tamaño,
                                       boton])  # Contenedor central.
    central_box.fit_children(margins=(30, 30))
    central_box.center()  # center on screen
    central_box.set_main_color((220, 220, 220, 180))

    background = thorpy.Background((0, 0, 0),
                                   elements=[title_element, central_box])
    thorpy.store(background)

    menu = thorpy.Menu(background)
    menu.play()  # Lanzamos el menú.

    application.quit()
Ejemplo n.º 28
0
 def __init__(self, size, hints):  #faire pressed!
     thorpy.Element.__init__(self, elements=[thorpy.make_text("Rule:")])
     self.finish()
     self.set_size(size)
     self.add_elements([
         thorpy.Image.make(h.img, colorkey=(255, 255, 255)) for h in hints
     ])
     thorpy.store(self, mode="h")
Ejemplo n.º 29
0
 def set_projectionViewer(self,
                          projectionViewer,
                          name,
                          color=(255, 255, 255)):
     self.projectionViewer = projectionViewer
     self.color = color
     self.name = name
     self.titulo = thorpy.make_text(self.name, 12, (0, 0, 0))
Ejemplo n.º 30
0
    def displayLauncher():

        # Declare Variables
        index = None  #int
        game = None  #String
        application = None  #Application(thorpy)
        buttons = [None, None, None]  #Clickable(thorpy) Array
        scoreboardButton = None  #Clickable(thorpy)
        quitButton = None  #Clickable(thorpy)
        buttonGroup = None  #Group(thorpy)
        menu = None  #Menu(thorpy)
        background = None  #Background(thorpy)
        painter = None  #Painters(thorpy)
        title = None  #Text(thorpy)

        # Create GUI and set theme
        application = thorpy.Application(size=(1280, 800),
                                         caption="Mini-Arcade")
        thorpy.theme.set_theme("human")

        # Create title
        title = thorpy.make_text("Mini-Arcade\n", 35, (0, 0, 0))

        # Create buttons
        painter = thorpy.painters.roundrect.RoundRect(size=(150, 75),
                                                      color=(102, 204, 255),
                                                      radius=0.3)
        for index, game in enumerate(Launcher.gameTitle):
            buttons[index] = Launcher.createButton(game, index, painter)
        scoreboardButton = thorpy.Clickable("Scoreboard")
        scoreboardButton.user_func = Launcher.launchScoreboard
        scoreboardButton.set_painter(painter)
        scoreboardButton.finish()
        scoreboardButton.set_font_size(23)
        scoreboardButton.set_font_color_hover((255, 255, 255))
        quitButton = thorpy.Clickable("Exit")
        quitButton.user_func = thorpy.functions.quit_menu_func
        quitButton.set_painter(painter)
        quitButton.finish()
        quitButton.set_font_size(23)
        quitButton.set_font_color_hover((255, 255, 255))

        # Format the buttons
        buttonGroup = thorpy.make_group(buttons)

        # Set background
        background = thorpy.Background(
            color=(255, 255, 255),
            elements=[title, buttonGroup, scoreboardButton, quitButton])
        thorpy.store(background)

        # Create menu and display
        menu = thorpy.Menu(background)
        menu.play()

        # Exiting
        application.quit()
Ejemplo n.º 31
0
def run():
    import thorpy

    application = thorpy.Application((800, 600), "ThorPy Overview")

    #texts that summary the element's roles:
    text_element = "Element instance:\nMost simple graphical element."
    text_clickable = "Clickable instance:\nCan be hovered and pressed."
    text_draggable = "Draggable instance:\nYou can drag it."
    text_check = "Checker instance:\nHere it is of type 'checkbox'."
    text_radio = "Checker instance:\nHere it is of type 'radio'."
    text_browser = "Browser instance:\nFind a file or a folder on the computer."
    text_dropdownlist = "DropDownList:\nDisplay a list of choices."
    text_slider = "SliderX:\nA way for user to select a value.\n" +\
                    "Can be any type of number (int, float, bool, ..)"
    text_text = "Text:\nThis is just a raw element with a certain type of style."

    #actual declaration of the elements

    #this element has no effect : it contains nothing and it is a ghost
    ghost = thorpy.Ghost()
    ghost.finish()

    element = thorpy.Element("Element")
    element.finish()
    thorpy.makeup.add_basic_help(element, text_element)

    clickable = thorpy.Clickable("Clickable")
    clickable.finish()
    thorpy.makeup.add_basic_help(clickable, text_clickable)

    draggable = thorpy.Draggable("Draggable")
    draggable.finish()
    thorpy.makeup.add_basic_help(draggable, text_draggable)

    checker_check = thorpy.Checker("Checker")
    checker_check.finish()
    thorpy.makeup.add_basic_help(checker_check, text_check)

    checker_radio = thorpy.Checker("Radio", type_="radio")
    checker_radio.finish()
    thorpy.makeup.add_basic_help(checker_radio, text_radio)

    browser = thorpy.Browser("../../", text="Browser")
    browser.finish()

    browserlauncher = thorpy.BrowserLauncher(browser, name_txt="Browser",
                                           file_txt="Nothing selected",
                                           launcher_txt="...")
    browserlauncher.finish()
    browserlauncher.scale_to_title()
    thorpy.makeup.add_basic_help(browserlauncher, text_browser)

    dropdownlist = thorpy.DropDownListLauncher(text="DropDownListLauncher",
                                             file_txt="Nothing selected",
                                             titles=[str(i) for i in range(1, 9)])
    dropdownlist.finish()
    dropdownlist.scale_to_title()
    thorpy.makeup.add_basic_help(dropdownlist, text_dropdownlist)

    slider = thorpy.SliderX(120, (5, 12), "Slider: ", type_=float, initial_value=8.4)
    slider.finish()
    thorpy.makeup.add_basic_help(slider, text_slider)

    inserter = thorpy.Inserter(name="Inserter: ", value="Write here.")
    inserter.finish()
    thorpy.makeup.add_basic_help(inserter,
                               "Inserter:\nA way for user to insert a value.")


    title_element = thorpy.make_text("Overview example", 22, (255,255,0))
    thorpy.makeup.add_basic_help(title_element, text_text)

    central_box = thorpy.Box("", [ghost, element, clickable, draggable, checker_check,
                                checker_radio, dropdownlist, browserlauncher,
                                slider, inserter])
    central_box.finish()
    central_box.center()
    central_box.add_lift()
    central_box.set_main_color((220,220,220,180))

    background = thorpy.Background(image=thorpy.style.EXAMPLE_IMG,
                                   elements=[title_element, central_box])
    background.finish()
    thorpy.store(background)

    menu = thorpy.Menu(background)
    menu.play()

    application.quit()