Exemple #1
0
    def __init__(self, library=None):
        gui.gui_state.__init__(self)

        if library is None:
            library = cards.library("../dc-deck/pack1")

        self.library = library
        self.handle_quit = False
        self.pic_cards = []
        self.current_index = 0
        self.key_downs = []

        self.deck_start_x = 0

        self.card_offset = 15

        self.lbl_current_card = gui.label()
        self.lbl_cards_count = gui.label()
        self.lbl_deck_name = gui.label()

        self.deck_combo = gui.combobox(120, 20)
        self.deck_combo.items.append("Pack1")
        self.deck_combo.items.append("Pack2")
        self.deck_combo.items.append("Pack3")
        self.deck_combo.items.append("Pack4")

        self.btn_back = gui.button()
        self.btn_back.width = 120
        self.btn_back.height = 35
        self.btn_back.caption = "Back"
        self.btn_back.add_receivers(self.back)
        self.tick_id = 0
Exemple #2
0
    def __init__(self, library=None):
        gui.gui_state.__init__(self)

        if library is None:
            library = cards.library("../dc-deck/pack1")

        self.library = library
        self.handle_quit = False
        self.pic_cards = []
        self.current_index = 0
        self.key_downs = []

        self.deck_start_x = 0

        self.card_offset = 15

        self.lbl_current_card = gui.label()
        self.lbl_cards_count = gui.label()
        self.lbl_deck_name = gui.label()

        self.deck_combo = gui.combobox(120, 20)
        self.deck_combo.items.append("Pack1")
        self.deck_combo.items.append("Pack2")
        self.deck_combo.items.append("Pack3")
        self.deck_combo.items.append("Pack4")

        self.btn_back = gui.button()
        self.btn_back.width = 120
        self.btn_back.height = 35
        self.btn_back.caption = "Back"
        self.btn_back.add_receivers(self.back)
        self.tick_id = 0
Exemple #3
0
    def reinforcement(self):
        lf = gui.labelframe(self.t1, 2, 1, _('reinforcement'))

        self.l_as_sup = gui.label(lf, 1, 1, E, 'As_sup:')
        self.f_as_sup = gui.frame(lf, 1, 2, W)
        cmd = lambda event: self.update_d_inf()
        gui.cbb_input(self, self.f_as_sup, 1, 1, 3, '\u2300', 'dm_sup', 10, val_dm, cmd)
        gui.cbb_input(self, self.f_as_sup, 1, 2, 4, '-', 's_sup', 150, val_s, '')

        # As_inf
        self.l_as_inf = gui.label(lf, 3, 1, E, 'As_inf:')
        self.f_as_inf = gui.frame(lf, 3, 2, W)
        gui.cbb_input(self, self.f_as_inf, 1, 1, 3, '\u2300', 'dm_inf', 10, val_dm, lambda event: self.update_d_inf())
        gui.cbb_input(self, self.f_as_inf, 1, 2, 4, '-', 's_inf', 150, val_s, '')

        # Asw
        self.l_asw = gui.label(lf, 2, 1, E, 'Asw:')
        self.f_asw = gui.frame(lf, 2, 2, W)
        gui.cbb_input(self, self.f_asw, 1, 1, 3, '\u2300', 'dmw', 10, val_dm, '')
        self.f_sw = gui.cbb_input(self, self.f_asw, 1, 2, 4, '-', 'sw', 150, val_s, '')
        self.f_ew = gui.cbb_input(self, self.f_asw, 1, 3, 4, 'e', 'ew', 150, val_s, '')

        # Al
        self.l_al = gui.label(lf, 4, 1, E, 'Al_inf:')
        self.f_al = gui.frame(lf, 4, 2, E)
        gui.e_input(self, self.f_al, 1, 1, 'tl ', 'tl', 0, '')
        gui.e_input(self, self.f_al, 1, 2, 'bl ', 'bl', 0, '')
        gui.cbb_input(self, self.f_al, 1, 3, 4, 'e', 'el', 1000, val_s, '')
Exemple #4
0
 def aao2pywright(self):
     assets = self.assets
     sw,sh = self.sw,self.sh
     settings_menu.firstpane = "saves"
     self.base()
     line = gui.pane([0,30],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     line.children.append(gui.label("Autosave?"))
     class myb(gui.checkbox):
         def click_down_over(self,*args):
             super(myb,self).click_down_over(*args)
             if self.checked:
                 assets.autosave = 1
             else:
                 assets.autosave = 0
             wini(assets)
     line.children.append(myb("autosave"))
     cb = line.children[-1]
     if assets.autosave: cb.checked = True
         
     line = gui.pane([0,50],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     line.children.append(gui.label("Minutes between autosave"))
     class mymin(gui.editbox):
         def insert(self,val):
             if val not in u"0123456789":
                 return
             super(mymin,self).insert(val)
         def set(self,val):
             super(mymin,self).set(val)
             if not val:
                 val = 0
             assets.autosave_interval = int(val)
             wini(assets)
     self.autosave_interval = str(assets.autosave_interval)
     line.children.append(mymin(self,"autosave_interval"))
         
     line = gui.pane([0,70],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     line.children.append(gui.label("Autosave backups"))
     class mye(gui.editbox):
         def insert(self,val):
             if val not in u"0123456789":
                 return
             super(mye,self).insert(val)
         def set(self,val):
             super(mye,self).set(val)
             if not val:
                 val = 0
             assets.autosave_keep = int(val)
             wini(assets)
     self.autosave_keep = str(assets.autosave_keep)
     line.children.append(mye(self,"autosave_keep"))
Exemple #5
0
def build_gui():

    dialog = gui.dialog()
    dialog.set_title("Axle-Spinner")
    vbox = dialog.vbox()

    speed_l = gui.label("Speed (RPM): ")
    speedb = gui.spinbutton(min=1, max=10000)
    speedb.connect("value-changed", set_speed)
    speedb.set_value(speed)
    speed_box = gui.hbox()
    speed_box.pack_start(speed_l)
    speed_box.pack_start(speedb)

    start_l = gui.label("Start at frame: ")
    startb = gui.spinbutton(min=0, max=1000000)
    startb.connect("value-changed", set_start)
    startb.set_value(start)
    start_box = gui.hbox()
    start_box.pack_start(start_l)
    start_box.pack_start(startb)

    end_l = gui.label("End at frame: ")
    endb = gui.spinbutton(min=0, max=1000000)
    endb.connect("value-changed", set_end)
    endb.set_value(end)
    end_box = gui.hbox()
    end_box.pack_start(end_l)
    end_box.pack_start(endb)

    clockwise = gui.radiobox("Clockwise")
    cclockwise = gui.radiobox("Counter Clockwise", radio_pair=clockwise)
    clockwise.connect("clicked", set_direction, True)
    cclockwise.connect("clicked", set_direction, False)

    clear = gui.checkbox("Clear this range?")
    clear.connect("clicked", set_clear)

    vbox.pack_start(speed_box)
    vbox.pack_start(start_box)
    vbox.pack_start(end_box)
    vbox.pack_start(clear)
    vbox.pack_start(clockwise)
    vbox.pack_start(cclockwise)

    dialog.show_all()
    dialog.add_button("OK", True)
    dialog.add_button("Cancel", False)

    return dialog
Exemple #6
0
    def __init__(self):
        gui.gui_state.__init__(self)

        self.btn_width = 180
        self.btn_height = 35

        self.btn_offset = 15

        self.title = gui.label()
        self.btn_new_game = gui.button(self.btn_width, self.btn_height)
        self.btn_deck_view = gui.button(self.btn_width, self.btn_height)
        self.btn_quit = gui.button(self.btn_width, self.btn_height)
Exemple #7
0
 def __init__(self,m,assets):
     gui.pane.__init__(self)
     self.width = 256
     self.height = 100
     self.pri = -1001
     self.z = 11001
     self.rpos = [0,100]
     self.align = "vert"
     
     for line in textutil.wrap_text([m],assets.get_image_font("block_arial"),300):
         text = gui.label(line.fulltext())
         self.children.append(text)
Exemple #8
0
    def __init__(self, game):
        self.game = game
        GameStateScreen.__init__(self, game)
        self.stackpanel = StackPanel(game, (SCR_W / 2 - 200, 300), 400)

        txt_question = label(game, text='Are you sure you want to quit?')
        btn_yes = Button(game, text='Yes', action=self.game.quit)
        btn_no = Button(game, text='No', action=self.btn_no_action)

        self.stackpanel.add_widgets(txt_question, btn_yes, btn_no)

        self.prev_screen = None
Exemple #9
0
    def __init__(self):
        gui.gui_state.__init__(self)

        self.btn_width = 180
        self.btn_height = 35

        self.btn_offset = 15

        self.title = gui.label()
        self.btn_new_game = gui.button(self.btn_width, self.btn_height)
        self.btn_deck_view = gui.button(self.btn_width, self.btn_height)
        self.btn_quit = gui.button(self.btn_width, self.btn_height)
Exemple #10
0
    def __init__(self, game):
        self.game = game
        GameStateScreen.__init__(self, game)
        self.stackpanel = StackPanel(game, (SCR_W / 2 - 200, 300), 400)

        txt_question = label(game,
                             text='Are you sure you want to quit?')
        btn_yes = Button(game, text='Yes', action=self.game.quit)
        btn_no = Button(game, text='No', action=self.btn_no_action)

        self.stackpanel.add_widgets(txt_question, btn_yes, btn_no)

        self.prev_screen = None
Exemple #11
0
    def __init__(self, m, assets):
        gui.pane.__init__(self)
        self.width = 256
        self.height = 100
        self.pri = -1001
        self.z = 11001
        self.rpos = [0, 100]
        self.align = "vert"

        for line in textutil.wrap_text([m],
                                       assets.get_image_font("block_arial"),
                                       300):
            text = gui.label(line.fulltext())
            self.children.append(text)
Exemple #12
0
def build_gui():
	dialog = gui.dialog()
	dialog.set_title("Sugar MELT!")
	vbox = dialog.vbox()
	vbox.set_spacing(10)

	label1 = gui.label("Sugar MELT!")

	spin = gui.spinbutton(step = 0.1, max = 1000, page = 0.001)
	spin.set_value(speed)
	spin.set_digits(3)
	spin.connect("value-changed", set_speed)
	spin_label = gui.label("Speed: ")

	hbox = gui.hbox()
	hbox.pack_start(spin_label)
	hbox.pack_start(spin)

	spin2 = gui.spinbutton(step = 1, max = 100000, page = 10)
	spin2.set_value(start_frame)
	spin2.connect("value-changed", set_frame)
	spin2_label = gui.label("Start Frame: ")

	hbox2 = gui.hbox()
	hbox2.pack_start(spin2_label)
	hbox2.pack_start(spin2)

	vbox.pack_start(label1)
	vbox.pack_start(hbox)
	vbox.pack_start(hbox2)

	dialog.add_button("Cancel", 0)
	dialog.add_button("OK", 1)

	dialog.show_all()
	return dialog
Exemple #13
0
    def __init__(self, game, mode):
        GameStateScreen.__init__(self, game)
        self.mode = mode
        self.prev_state = None

        self.stack_panel = StackPanel(game, (515, 280), 250)

        lab_paused = label(game, text='Game paused')
        btn_resume = Button(game, text='Resume Game',
                            action=self.btn_resume_action)
        btn_opts = Button(game, text='Options',
                          action=self.btn_opts_action,
                          enabled=False)
        btn_menu = Button(game, text='Return to main menu',
                          action=self.btn_menu_action)
        btn_quit = Button(game, text='Quit',
                          action=self.btn_quit_action)

        self.stack_panel.add_widgets(lab_paused, btn_resume, btn_opts,
                                     btn_menu, btn_quit)
Exemple #14
0
    def __init__(self, game, mode):
        GameStateScreen.__init__(self, game)
        self.mode = mode
        self.prev_state = None

        self.stack_panel = StackPanel(game, (515, 280), 250)

        lab_paused = label(game, text='Game paused')
        btn_resume = Button(game,
                            text='Resume Game',
                            action=self.btn_resume_action)
        btn_opts = Button(game,
                          text='Options',
                          action=self.btn_opts_action,
                          enabled=False)
        btn_menu = Button(game,
                          text='Return to main menu',
                          action=self.btn_menu_action)
        btn_quit = Button(game, text='Quit', action=self.btn_quit_action)

        self.stack_panel.add_widgets(lab_paused, btn_resume, btn_opts,
                                     btn_menu, btn_quit)
def page(arg):
    ## Name of this Page
    #    print(arg.curpage)

    ## SAVE PROPERTIES
    arg.hprops = sn(**{})
    arg.hobjs = sn(**{})
    arg.hvars = sn(**{})
    arg.hprops.__dict__[arg.curpage] = sn(**{})
    arg.hobjs.__dict__[arg.curpage] = sn(**{})
    arg.hvars.__dict__[arg.curpage] = sn(**{})

    ####################### GUI ELEMENTS #########################
    h = sn(**{})

    ## Optional Variables for Guided Positioning
    margin = 30
    spacing = 10
    small = 150
    medium = 225
    large = 300
    height = 40

    h.bg = sn(
        **{  ## gui.image(arg,"imagename", "image.jpg", (w,h)))
            "obj":
            gui.image(arg, "pg_1-bg", "bg.jpg", (g.frameWidth, g.frameHeight)),
            "pos":
            sn(**{
                "x": 0,
                "y": 0,
                "w": g.frameWidth,
                "h": g.frameHeight,
            })
        })

    ### LABEL
    h.label1 = sn(
        **{  ## gui.label(arg,"style","align","text")
            "obj": gui.label(arg, "labelSmall", "center", "Hello There!"),
            "pos": sn(**{
                "x": margin,
                "y": 300,
                "w": medium,
                "h": height,
            })
        })

    ### ENTRY
    h.myEntry = sn(
        **
        {  ## gui.entry(arg,"style","align","text", name="entryName" ,password=True, keyboard=True, type=number),
            "obj":
            gui.entry(arg,
                      "entryMedium",
                      "center",
                      "Edit me!",
                      name="myEntry",
                      password=True,
                      keyboard=True),
            "pos":
            sn(**{
                "x": 10,
                "y": 10,
                "w": 150,
                "h": 30,
            })
        })

    h.btnTest1 = sn(
        **{  ## gui.button(arg,"style","unused","text",lambda: fcn(arg)),
            ## Function Wont Work on Quick View
            "obj":
            gui.button(arg, "btnBig", "center", "Push Me!",
                       lambda: arg.fcn_main.testFcn(arg)),
            "pos":
            sn(**{
                "x": margin,
                "y": 200,
                "w": medium,
                "h": height,
            })
        })

    h.btnTest2 = sn(
        **{  ## gui.button(arg,"style","unused","text",lambda: fcn(arg)),
            "obj":
            gui.button(arg, "btnBig", "center", "NEXT PAGE",
                       lambda: gui.showPage(arg, "pg_testing")),
            "pos":
            sn(
                **{
                    "x": margin,
                    "y": h.btnTest1.pos.y + h.btnTest1.pos.h + spacing,
                    "w": medium,
                    "h": height,
                })
        })
    #
    data = ["Entry1", "fsfs"]  ## ["Entry 1" , "Entry 2"]
    h.listbox1 = sn(
        **{
            "obj":
            gui.listbox(arg, data, "listbox1"),
            "pos":
            sn(
                **{
                    "x": margin + medium + spacing,
                    "y": margin,
                    "w": large,
                    "h": 300,
                })
        })

    data = ["Entry 1", "Entry 2"]
    h.dropdown1 = sn(
        **{
            "obj": gui.dropdown(arg, "ddstyle", "center", data, "dropdown1"),
            "pos": sn(**{
                "x": 600,
                "y": 20,
                "w": 180,
                "h": 35,
            })
        })

    rsp = db(arg, "getPathologist")
    data = []
    for dt in rsp:
        data.append([dt["name"], dt["status"]])

    h.table1 = sn(
        **{
            "obj":
            gui.ttk.Treeview(arg.master),
            "pos":
            sn(**{
                "x": 70,
                "y": 180,
                "w": 650,
                "h": 200,
            }),
            "table":
            sn(
                **{
                    "columns": [
                        sn(**{
                            "title": "Name",
                            "width": 500
                        }),
                        sn(**{
                            "title": "Status",
                            "width": 150
                        }),
                        # sn(**{"title" : "Brand", "width" : 150}),
                        # sn(**{"title" : "Equipment", "width" : 200}),
                        # sn(**{"title" : "Tag", "width" : 100}),
                    ],
                    "data": [[]],
                }),
        })

    # For Scrollbar
    h.table1Scroll = sn(
        **{
            "obj":
            gui.ttk.Scrollbar(
                arg.master, orient="vertical", command=h.table1.obj.yview),
            "pos":
            sn(**{
                "x": 725,
                "y": 180,
                "w": 25,
                "h": 200,
            })
        })

    h.table1.obj.configure(yscrollcommand=h.table1Scroll.obj.set)

    # self.canvas.bind('<Button-1>', self.clicked)
    # self.canvas.bind('<Double-1>', self.double_click)
    # self.canvas.bind('<ButtonRelease-1>', self.button_released)
    # self.canvas.bind('<B1-Motion>', self.moved)

    # Bind double click even on table1 data/row.
    h.table1.obj.bind(
        '<Double-1>',
        lambda event, t=h.table1.obj: arg.fcn_gui3.table1Double_ClickEven(arg))

    # "data" : [
    #             ["Felipe Templo Jr, MD","ON-DUTY"],
    #             ["Jeffrey S. So, MD, DPSP","OFF-DUTY"],
    #             ["Francis G. Moria, MD, MSc FPSP","OFF-DUTY"],
    #             ["Jose Maria C. Avila, MD","ON-DUTY"],
    #             ["Michelle Anne M. Latoy, MD","ON-DUTY"],
    #             ["Aida Isabel Mendoza, MD","OFF-DUTY"],
    #             ["Charles Harris, MD","OFF-DUTY"],
    #             ["Felipe Templo Jr, MD","ON-DUTY"],
    #             ["Jeffrey S. So, MD, DPSP","OFF-DUTY"],
    #             ["Francis G. Moria, MD, MSc FPSP","OFF-DUTY"],
    #             ["Jose Maria C. Avila, MD","ON-DUTY"],
    #             ["Michelle Anne M. Latoy, MD","ON-DUTY"],
    #             ["Aida Isabel Mendoza, MD","OFF-DUTY"],
    #             ["Charles Harris, MD","OFF-DUTY"],
    #         ],

    #    h.scrollAlone = sn(**{
    #        "obj": gui.scroll(arg,"scrollstyle","center"),
    #        "pos": sn(**{
    #            "x": h.listbox1.pos.x + h.listbox1.pos.w + spacing,
    #            "y": margin,
    #            "w": 50,
    #            "h": 300,
    #        })
    #    })

    # data = ["Entry1  -  ON-DUTY","fsfs  -  OFF-DUTY"] ## ["Entry 1" , "Entry 2"]

    # h.listbox1 = sn(**{
    #     "obj" : gui.listbox(arg,data,"listbox1"),
    #     "pos": sn(**{
    #         "x": 70,
    #         "y": 180,
    #         "w": 645,
    #         "h": 200,
    #     })
    # })

    # For Scrollbar
    # h.listScroll = sn(**{
    #     "obj" : ttk.Scrollbar(master, orient="vertical",
    #         # command=handle["listbox1"]["element"].yview),
    #         command=h.listbox1.obj.yview),
    #     "pos" : sn(**{
    #         "x": 200,
    #         "y": 50,
    #         "w": 40,
    #         "h": 720,
    #     })
    # })

    # ##### SUB PROPERTIES OF THE ABOVE HANDLES
    # h.listbox1.obj.configure(yscrollcommand=h.listScroll.obj.set);

    h.checkbox = sn(
        **{  ## gui.checkbox(arg,"yourText", lambda: test(arg)),
            "obj": gui.checkbox(arg, "yourText", lambda: test(arg)),
            "pos": sn(**{
                "x": 10,
                "y": 10,
                "w": 150,
                "h": 30,
            })
        })

    # array 0 is the default value.
    optionList1 = ('a', 'a', 'b', 'c')
    h.combobox = sn(
        **
        {  ## ttk.OptionMenu(arg.master,v1,*optionList1, command=lambda selected:test123123(selected))
            "obj":
            gui.combobox(arg, optionList1,
                         lambda selected_val: test(selected_val)),
            "pos":
            sn(**{
                "x": 50,
                "y": 10,
                "w": 150,
                "h": 30,
            })
        })

    h.progressbar = sn(
        **
        {  ## tttk.Progressbar(arg.master, orient = orient, length = length, mode = mode)
            "obj": gui.progressbar(arg),
            "pos": sn(**{
                "x": 100,
                "y": 10,
                "w": 150,
                "h": 30,
            })
        })

    gui.hpropsobjs(arg, h)
    return h
Exemple #16
0
    def saves(self):
        assets = self.assets
        sw, sh = self.sw, self.sh
        settings_menu.firstpane = "saves"
        self.base()
        line = gui.pane([0, 30], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        line.children.append(gui.label("Autosave?"))

        class myb(gui.checkbox):
            def click_down_over(self, *args):
                super(myb, self).click_down_over(*args)
                if self.checked:
                    assets.autosave = 1
                else:
                    assets.autosave = 0
                wini(assets)

        line.children.append(myb("autosave"))
        cb = line.children[-1]
        if assets.autosave: cb.checked = True

        line = gui.pane([0, 50], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        line.children.append(gui.label("Minutes between autosave"))

        class mymin(gui.editbox):
            def insert(self, val):
                if val not in u"0123456789":
                    return
                super(mymin, self).insert(val)

            def set(self, val):
                super(mymin, self).set(val)
                if not val:
                    val = 0
                assets.autosave_interval = int(val)
                wini(assets)

        self.autosave_interval = str(assets.autosave_interval)
        line.children.append(mymin(self, "autosave_interval"))

        line = gui.pane([0, 70], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        line.children.append(gui.label("Autosave backups"))

        class mye(gui.editbox):
            def insert(self, val):
                if val not in u"0123456789":
                    return
                super(mye, self).insert(val)

            def set(self, val):
                super(mye, self).set(val)
                if not val:
                    val = 0
                assets.autosave_keep = int(val)
                wini(assets)

        self.autosave_keep = str(assets.autosave_keep)
        line.children.append(mye(self, "autosave_keep"))

        line = gui.pane([0, 90], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        if not assets.variables.get("_allow_saveload", "true"):
            line.children.append(
                gui.label("Save/Load currently disabled by game"))
        else:
            line.children.append(gui.label("Save/Load"))
            line.children.append(gui.button(self, "save_game"))
            line.children.append(gui.button(self, "load_game"))
Exemple #17
0
    def debug(self):
        assets = self.assets
        sw, sh = self.sw, self.sh
        settings_menu.firstpane = "debug"
        self.base()

        #Create debug mode option if we aren't running a game
        if assets.game == "games":
            line = gui.pane([0, 90], [sw, 20])
            line.align = "horiz"
            self.children.append(line)
            line.children.append(gui.label("Debug mode?"))

            class myb(gui.checkbox):
                def click_down_over(self, *args):
                    super(myb, self).click_down_over(*args)
                    if self.checked:
                        assets.debug_mode = True
                    else:
                        assets.debug_mode = False

            line.children.append(myb("debug_mode"))
            cb = line.children[-1]
            if assets.debug_mode: cb.checked = True
            return

        line = gui.pane([0, 30], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        self.go_script = ""
        line.children.append(gui.editbox(self, "go_script"))

        class myb(gui.button):
            def click_down_over(s, *args):
                assets.cur_script.safe_exec(assets.cur_script.execute_line,
                                            self.go_script)
                self.close()

        line.children.append(myb(None, "execute"))

        line = gui.pane([0, 50], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class myb(gui.button):
            def click_down_over(s, *args):
                print "debugging game"
                s = assets.DebugScript()
                s.debug_game("current", "run")
                print "finished"

        line.children.append(myb(None, "Debug current script"))

        line = gui.pane([0, 70], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class myb(gui.button):
            def click_down_over(s, *args):
                print "debugging game"
                s = assets.DebugScript()
                s.debug_game("all", "run")
                print "finished"

        line.children.append(myb(None, "Debug entire game (slow)"))

        line = gui.pane([0, 90], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class myb(gui.button):
            def click_down_over(s, *args):
                print "debugging game"
                s = assets.DebugScript()
                s.debug_game("all", "quote")
                print "finished"

        line.children.append(myb(None, "Find quote errors"))

        line = gui.pane([0, 110], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class newr(gui.radiobutton):
            def click_down_over(s, *args):
                gui.radiobutton.click_down_over(s, *args)
                assets.game_speed = int(s.text)

        line.children.append(gui.label("Game speed"))
        line.children.append(newr("1", "gamespeed"))
        line.children.append(newr("2", "gamespeed"))
        line.children.append(newr("6", "gamespeed"))
        for t in line.children:
            if t.text == str(assets.game_speed):
                t.checked = True
Exemple #18
0
import gui
import engine


FPS_LIMIT = 30 # frames per second

# Init
pygame.mixer.init(engine.synths.SOUND_SAMPLERATE, -16, 1)
pygame.init()
pygame.display.set_caption("8BitTracker")
screen = gui.init_screen(gui.SCREEN_WIDTH, gui.SCREEN_HEIGHT)

# Testing beep. This one lasts for 100 milliseconds and is at 880Hz (A5).
sound = engine.synths.make_beep(880, .1)

labelFPS = gui.label(10, 24, "60 fps")

buttonAccept = gui.button(10, 15, "Accept", 0, 8, False)

gui.rect(screen.chars, 9, 9, 13, 3, 12, 4, 0)

lastRefresh = 0
currentFPS = 0
# Main Loop
while 1:
    # events
    for event in pygame.event.get():
        if event.type is pygame.KEYDOWN:

            # Press ESCAPE to exit the program
            if event.key is pygame.K_ESCAPE:
Exemple #19
0
    def sound(self):
        assets = self.assets
        sw, sh = self.sw, self.sh
        settings_menu.firstpane = "sound"
        self.base()
        ermsg = gui.label("")
        ermsg.rpos = [0, 140]
        ermsg.textcol = [255, 0, 0]

        line = gui.pane([0, 130], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class myb(gui.checkbox):
            def click_down_over(self, *args):
                super(myb, self).click_down_over(*args)
                if self.checked:
                    assets.set_mute_sound(True)
                else:
                    assets.set_mute_sound(False)

        line.children.append(myb("mute sound"))
        if assets.mute_sound:
            line.children[-1].checked = True

        if android:
            return
        line = gui.pane([0, 30], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class newr(gui.radiobutton):
            def click_down_over(s, *args):
                ermsg.text = ""
                gui.radiobutton.click_down_over(s, *args)
                assets.sound_format = int(s.text)
                if not assets.init_sound(True):
                    ermsg.text = "Sound not initialized"
                else:
                    assets.play_sound("phoenix/objection.ogg")
                    wini(assets)

        line.children.append(gui.label("Format:"))
        line.children.append(newr("11025", "formchoice"))
        line.children.append(newr("22050", "formchoice"))
        line.children.append(newr("44100", "formchoice"))
        for t in line.children:
            if t.text == str(assets.sound_format):
                t.checked = True

        line = gui.pane([0, 50], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class newr(gui.radiobutton):
            def click_down_over(s, *args):
                ermsg.text = ""
                gui.radiobutton.click_down_over(s, *args)
                assets.sound_bits = int(s.text)
                if not assets.init_sound(True):
                    ermsg.text = "Sound not initialized"
                else:
                    assets.play_sound("phoenix/objection.ogg")
                    wini(assets)

        line.children.append(gui.label("Bits:"))
        line.children.append(newr("8", "bitschoice"))
        line.children.append(newr("16", "bitschoice"))
        for t in line.children:
            if t.text == str(assets.sound_bits):
                t.checked = True

        line = gui.pane([0, 70], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        class newr(gui.radiobutton):
            def click_down_over(s, *args):
                ermsg.text = ""
                gui.radiobutton.click_down_over(s, *args)
                assets.sound_buffer = int(s.text)
                if not assets.init_sound(True):
                    ermsg.text = "Sound not initialized"
                else:
                    assets.play_sound("phoenix/objection.ogg")
                    wini(assets)

        line.children.append(gui.label("Buffer:"))
        line.children.append(newr("512", "bufchoice"))
        line.children.append(newr("1024", "bufchoice"))
        line.children.append(newr("2048", "bufchoice"))
        line.children.append(newr("4096", "bufchoice"))
        for t in line.children:
            if t.text == str(assets.sound_buffer):
                t.checked = True

        line = gui.pane([0, 90], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        self.snd_line = gui.label("SoundVolume: %d" % assets.sound_volume)

        def mod(amt, min, max, var, play):
            def modit():
                ermsg.text = ""
                if not assets.init_sound():
                    ermsg.text = "Sound not initialized"
                else:
                    n = getattr(assets, var) + amt
                    if n > max:
                        n = max
                    if n < min:
                        n = min
                    setattr(assets, var, n)
                    self.snd_line.text = "SoundVolume: %d" % assets.sound_volume
                    self.mv_line.text = "MusicVolume: %d" % assets.music_volume
                    play()
                    wini(assets)

            return modit

        line.children.append(self.snd_line)
        line.children.append(gui.button(None, "less"))
        line.children[-1].less = mod(
            -10, 0, 100, "sound_volume",
            lambda: assets.play_sound("phoenix/objection.ogg"))
        line.children.append(gui.button(None, "more"))
        line.children[-1].more = mod(
            10, 0, 100, "sound_volume",
            lambda: assets.play_sound("phoenix/objection.ogg"))

        line = gui.pane([0, 110], [sw, 20])
        line.align = "horiz"
        self.children.append(line)

        self.mv_line = gui.label("MusicVolume: %d" % assets.music_volume)
        line.children.append(self.mv_line)
        line.children.append(gui.button(None, "less"))
        line.children[-1].less = mod(
            -10, 0, 100, "music_volume", lambda: assets.play_music(
                "Ding.ogg", loop=1, pre="sfx/", reset_track=False))
        line.children.append(gui.button(None, "more"))
        line.children[-1].more = mod(
            10, 0, 100, "music_volume", lambda: assets.play_music(
                "Ding.ogg", loop=1, pre="sfx/", reset_track=False))

        self.children.append(ermsg)
def page(arg):

    ## SAVE PROPERTIES
    arg.hprops = sn(**{})
    arg.hobjs = sn(**{})
    arg.hvars = sn(**{})
    arg.hprops.__dict__[arg.curpage] = sn(**{})
    arg.hobjs.__dict__[arg.curpage] = sn(**{})
    arg.hvars.__dict__[arg.curpage] = sn(**{})

    h = sn(**{})
    ####################### GUI ELEMENTS START #########################

    h.myEntry = sn(
        **
        {  ## gui.entry(arg,"style","align","text", name="entryName" ,password=True, keyboard=True, type=number),
            "obj":
            gui.entry(arg,
                      "entryMedium",
                      "center",
                      "Edit me!",
                      name="myEntry",
                      password=True,
                      keyboard=True),
            "pos":
            sn(**{
                "x": 10,
                "y": 10,
                "w": 150,
                "h": 30,
            })
        })

    h.label1 = sn(
        **{  ## gui.label(arg,"style","align","text")
            "obj": gui.label(arg, "labelSmall", "center", "Hello There!"),
            "pos": sn(**{
                "x": 100,
                "y": 300,
                "w": 100,
                "h": 40,
            })
        })

    # h.checkbox = sn(**{ ## gui.checkbox(arg,"yourText", lambda: test(arg)),
    #     "obj": gui.checkbox(arg,"yourText", lambda: test(arg)),
    #     "pos": sn(**{
    #         "x": 10,
    #         "y": 10,
    #         "w": 150,
    #         "h": 30,
    #     })
    # })

    h.checkbox = sn(
        **{  ## gui.checkbox(arg,"yourText", lambda: test(arg)),
            "obj": gui.checkbox(arg, "yourText", lambda: test(arg, 1)),
            "pos": sn(**{
                "x": 10,
                "y": 40,
                "w": 150,
                "h": 30,
            })
        })

    optionList1 = ('a', 'a', 'b', 'c')
    h.combobox = sn(
        **
        {  ## ttk.OptionMenu(arg.master,v1,*optionList1, command=lambda selected:test123123(selected))
            "obj":
            gui.combobox(arg, optionList1,
                         lambda selected_val: test(arg, selected_val)),
            "pos":
            sn(**{
                "x": 10,
                "y": 80,
                "w": 150,
                "h": 30,
            })
        })

    h.progress = sn(
        **
        {  ## tttk.Progressbar(arg.master, orient = orient, length = length, mode = mode)
            "obj": gui.progressbar(arg),
            "pos": sn(**{
                "x": 10,
                "y": 120,
                "w": 150,
                "h": 30,
            })
        })

    h.radiobutton = sn(
        **
        {  ## Radiobutton(arg.master,text="t",padx = 20, variable=v, command=command,value=value).pack(anchor=tk.W)
            "obj":
            gui.radiobutton(arg,
                            text="option1",
                            variable=radiobutton_var,
                            value=1,
                            command=lambda: test(arg, 1)),
            "pos":
            sn(**{
                "x": 10,
                "y": 160,
                "w": 150,
                "h": 30,
            })
        })

    h.radiobutton2 = sn(
        **
        {  ## Radiobutton(arg.master,text="t",padx = 20, variable=v, command=command,value=value).pack(anchor=tk.W)
            "obj":
            gui.radiobutton(arg,
                            text="option1",
                            variable=radiobutton_var,
                            value=2,
                            command=lambda: test(arg, 1)),
            "pos":
            sn(**{
                "x": 10,
                "y": 200,
                "w": 150,
                "h": 30,
            })
        })

    ####################### GUI ELEMENTS END #########################
    gui.hpropsobjs(arg, h)
    return h
Exemple #21
0
    def run(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(
                    (event.size[0], event.size[1] - GRID_CELL_SIZE),
                    pygame.RESIZABLE)
                break
        pygame.init()

        self.screen = pygame.display.get_surface()
        if self.screen:
            self.screensize = self.screen.get_size()
        else:
            info = pygame.display.Info()
            self.screensize = (info.current_w, info.current_h)
            self.screen = pygame.display.set_mode(self.screensize)

        screensize = self.screensize

        decksel = False
        c8sheader = gui.label((100, 300), (200, 75), _('Crazy Eights'),
                              (0, 128, 0))
        c8s2p = gui.button((100, 400), (200, 35), _("Two players"))
        c8s3p = gui.button((100, 450), (200, 35), _("Three players"))
        c8s4p = gui.button((100, 500), (200, 35), _("Four players"))

        c8sframe = gui.frame((c8sheader, c8s2p, c8s3p, c8s4p), (75, 275),
                             (250, 275))

        maindeck = gui.button((50, screensize[1] - 75), (85, 35), _("Deck"))
        mainphoto = gui.button((screensize[0] - 200, screensize[1] - 75),
                               (160, 35), _("Photo deck"))
        mainheader = gui.image((50, 25), (screensize[0] - 100, 200),
                               'fiftytwo.png', -1)

        mainframe = gui.frame((mainheader, maindeck, mainphoto),
                              (25, screensize[1] - 100),
                              (screensize[0] - 50, 75))

        deckselexit = gui.button((screensize[0] - 215, screensize[1] - 145),
                                 (115, 35), _("Cancel"))
        deckfromjournal = gui.button(
            (screensize[0] - 445, screensize[1] - 145), (200, 35),
            _("from Journal"))
        deckselregular = gui.image(
            (115, 115), (crazyeights.card_width(), crazyeights.card_height()),
            'back.regular.png')
        deckselgnome = gui.image(
            (300, 115), (crazyeights.card_width(), crazyeights.card_height()),
            'back.gnome.png')
        deckselparis = gui.image(
            (485, 115), (crazyeights.card_width(), crazyeights.card_height()),
            'back.paris.png')
        deckselshapes = gui.image(
            (670, 115), (crazyeights.card_width(), crazyeights.card_height()),
            'back.shapes.png')
        self.deckseluser = gui.image(
            (855, 115), (crazyeights.card_width(), crazyeights.card_height()),
            'back.user.png')

        deckselpopup = gui.popup(
            (deckselexit, deckfromjournal, deckselregular, deckselgnome,
             deckselparis, deckselshapes, self.deckseluser), (100, 100),
            (screensize[0] - 200, screensize[1] - 200))

        mouseposition = [0, 0, 0]

        self.screen.fill((192, 64, 255))

        # Set the name of the players
        names = []
        names.append('l' + _('You'))
        names.append('a' + _('XO player #1'))
        names.append('a' + _('XO player #2'))
        names.append('a' + _('XO player #3'))
        names.append('a' + _('The XO'))

        fpslimiter = pygame.time.Clock()

        while True:
            fpslimiter.tick(20)

            while Gtk.events_pending():
                Gtk.main_iteration()

            for event in pygame.event.get():

                if event.type == pygame.MOUSEMOTION:
                    mouseposition[0] = event.pos[0]
                    mouseposition[1] = event.pos[1]
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    mouseposition[2] = 1
                elif event.type == pygame.MOUSEBUTTONUP:
                    mouseposition[2] = 0
                    if not decksel and c8s2p.detect_click(event.pos):
                        crazyeights.main((names[4], names[0]), screensize)
                        self.screen.fill(MMCOL)
                        pygame.event.set_allowed(pygame.MOUSEMOTION)
                    elif not decksel and c8s3p.detect_click(event.pos):
                        crazyeights.main((names[1], names[2], names[0]),
                                         screensize)
                        self.screen.fill(MMCOL)
                        pygame.event.set_allowed(pygame.MOUSEMOTION)
                    elif not decksel and c8s4p.detect_click(event.pos):
                        crazyeights.main(
                            (names[1], names[2], names[0], names[3]),
                            screensize)
                        self.screen.fill(MMCOL)
                        pygame.event.set_allowed(pygame.MOUSEMOTION)
                    elif not decksel and maindeck.detect_click(event.pos):
                        decksel = True
                    elif not decksel and mainphoto.detect_click(event.pos):
                        self.photo()
                        self.screen.fill(MMCOL)
                    elif decksel and deckselexit.detect_click(event.pos):
                        decksel = False
                        self.screen.fill(MMCOL)
                    elif decksel and deckfromjournal.detect_click(event.pos):
                        picture = self.parent.load_image_from_journal()
                        if picture:
                            self.update_user_deck(picture.file_path)
                        self.screen.fill(MMCOL)
                    elif decksel and deckselgnome.detect_click(event.pos):
                        deck.deck = 'gnome'
                        decksel = False
                        self.screen.fill(MMCOL)
                    elif decksel and deckselregular.detect_click(event.pos):
                        deck.deck = 'regular'
                        decksel = False
                        self.screen.fill(MMCOL)
                    elif decksel and deckselparis.detect_click(event.pos):
                        deck.deck = 'paris'
                        decksel = False
                        self.screen.fill(MMCOL)
                    elif decksel and deckselshapes.detect_click(event.pos):
                        deck.deck = 'shapes'
                        decksel = False
                        self.screen.fill(MMCOL)
                    elif decksel and self.deckseluser.detect_click(event.pos):
                        deck.deck = 'user'
                        decksel = False
                        self.screen.fill(MMCOL)

            if not decksel:
                c8sframe.update()
                c8sframe.draw(self.screen, mouseposition)

                mainframe.update()
                mainframe.draw(self.screen, mouseposition)
            else:
                deckselpopup.update()
                deckselpopup.draw(self.screen, mouseposition)

            pygame.display.flip()
Exemple #22
0
    def aao2pywright(self):
        assets = self.assets
        sw, sh = self.sw, self.sh
        settings_menu.firstpane = "saves"
        self.base()
        line = gui.pane([0, 30], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        line.children.append(gui.label("Autosave?"))

        class myb(gui.checkbox):
            def click_down_over(self, *args):
                super(myb, self).click_down_over(*args)
                if self.checked:
                    assets.autosave = 1
                else:
                    assets.autosave = 0
                wini(assets)

        line.children.append(myb("autosave"))
        cb = line.children[-1]
        if assets.autosave: cb.checked = True

        line = gui.pane([0, 50], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        line.children.append(gui.label("Minutes between autosave"))

        class mymin(gui.editbox):
            def insert(self, val):
                if val not in u"0123456789":
                    return
                super(mymin, self).insert(val)

            def set(self, val):
                super(mymin, self).set(val)
                if not val:
                    val = 0
                assets.autosave_interval = int(val)
                wini(assets)

        self.autosave_interval = str(assets.autosave_interval)
        line.children.append(mymin(self, "autosave_interval"))

        line = gui.pane([0, 70], [sw, 20])
        line.align = "horiz"
        self.children.append(line)
        line.children.append(gui.label("Autosave backups"))

        class mye(gui.editbox):
            def insert(self, val):
                if val not in u"0123456789":
                    return
                super(mye, self).insert(val)

            def set(self, val):
                super(mye, self).set(val)
                if not val:
                    val = 0
                assets.autosave_keep = int(val)
                wini(assets)

        self.autosave_keep = str(assets.autosave_keep)
        line.children.append(mye(self, "autosave_keep"))
Exemple #23
0
    def __init__(self):
        gui.gui_state.__init__(self)

        #loading superheroes

        self.library = cards.library("../dc-deck/pack1")

        self.lbl_title = gui.label()
        self.lbl_title.font = gui.get_big_font()
        self.lbl_title.text = "Game Setup"

        self.lbl_players_name = gui.label()
        self.lbl_players_name.text = "Players name"

        self.lbl_players_num = gui.label()
        self.lbl_players_num.text = "Number of players : "
        self.lbl_players_num.render()

        self.cb_players_num = gui.combobox(50, 22)
        self.cb_players_num.items.append("2")
        self.cb_players_num.items.append("3")
        self.cb_players_num.items.append("4")
        self.cb_players_num.items.append("5")
        self.cb_players_num.add_receiver(self.player_num_changed)

        self.lbl_cb_superhero_pick = gui.label()
        self.lbl_cb_superhero_pick.text = "Random superhero : "

        self.cb_superhero_pick = gui.checkbox()
        self.cb_superhero_pick.checked = True
        self.cb_superhero_pick.state_changed = self.pick_random_changed

        self.add(self.lbl_title)
        self.add(self.lbl_players_name)

        self.add(self.lbl_players_num)
        self.add(self.cb_players_num)

        self.add(self.lbl_cb_superhero_pick)
        self.add(self.cb_superhero_pick)

        self.tb_players = []
        self.lbl_players = []
        self.slider_player_superhero = []
        nb_players = int(self.cb_players_num.get_item())
        for i in range(5):
            tb = gui.textbox(180, 22)
            self.tb_players.append(tb)
            self.add(tb)
            lbl = gui.label(25, 22)
            lbl.text = str(i + 1) + " : "
            self.lbl_players.append(lbl)
            self.add(lbl)

            if i < nb_players:
                tb.visible = True
                lbl.visible = True
            else:
                tb.visible = False
                lbl.visible = False

            slider = gui.slider(100, 22)
            slider.visible = False

            for s in self.library.superheroes:
                slider.items.append(s.name)

            self.slider_player_superhero.append(slider)

            self.add(slider)

        self.btn_start = gui.button(180, 40)
        self.btn_start.caption = "Start !"
        self.btn_start.add_receivers(self.start_game)

        self.btn_back = gui.button(180, 40)
        self.btn_back.caption = "Back"
        self.btn_back.add_receivers(self.back)

        self.add(self.btn_start)
        self.add(self.btn_back)
Exemple #24
0
 def saves(self):
     assets = self.assets
     sw,sh = self.sw,self.sh
     settings_menu.firstpane = "saves"
     self.base()
     line = gui.pane([0,30],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     line.children.append(gui.label("Autosave?"))
     class myb(gui.checkbox):
         def click_down_over(self,*args):
             super(myb,self).click_down_over(*args)
             if self.checked:
                 assets.autosave = 1
             else:
                 assets.autosave = 0
             wini(assets)
     line.children.append(myb("autosave"))
     cb = line.children[-1]
     if assets.autosave: cb.checked = True
         
     line = gui.pane([0,50],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     line.children.append(gui.label("Minutes between autosave"))
     class mymin(gui.editbox):
         def insert(self,val):
             if val not in u"0123456789":
                 return
             super(mymin,self).insert(val)
         def set(self,val):
             super(mymin,self).set(val)
             if not val:
                 val = 0
             assets.autosave_interval = int(val)
             wini(assets)
     self.autosave_interval = str(assets.autosave_interval)
     line.children.append(mymin(self,"autosave_interval"))
         
     line = gui.pane([0,70],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     line.children.append(gui.label("Autosave backups"))
     class mye(gui.editbox):
         def insert(self,val):
             if val not in u"0123456789":
                 return
             super(mye,self).insert(val)
         def set(self,val):
             super(mye,self).set(val)
             if not val:
                 val = 0
             assets.autosave_keep = int(val)
             wini(assets)
     self.autosave_keep = str(assets.autosave_keep)
     line.children.append(mye(self,"autosave_keep"))
     
     line = gui.pane([0,90],[sw,20])
     line.align = "horiz"
     self.children.append(line)
     if not assets.variables.get("_allow_saveload","true"):
         line.children.append(gui.label("Save/Load currently disabled by game"))
     else:
         line.children.append(gui.label("Save/Load"))
         line.children.append(gui.button(self,"save_game"))
         line.children.append(gui.button(self,"load_game"))
Exemple #25
0
    def debug(self):
        assets = self.assets
        sw,sh = self.sw,self.sh
        settings_menu.firstpane = "debug"
        self.base()

        #Create debug mode option if we aren't running a game
        if assets.game == "games":
            line = gui.pane([0,90],[sw,20])
            line.align = "horiz"
            self.children.append(line)
            line.children.append(gui.label("Debug mode?"))
            class myb(gui.checkbox):
                def click_down_over(self,*args):
                    super(myb,self).click_down_over(*args)
                    if self.checked:
                        assets.debug_mode = True
                    else:
                        assets.debug_mode = False
            line.children.append(myb("debug_mode"))
            cb = line.children[-1]
            if assets.debug_mode: cb.checked = True
            return
        
        
        line = gui.pane([0,30],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        self.go_script = ""
        line.children.append(gui.editbox(self,"go_script"))
        class myb(gui.button):
            def click_down_over(s,*args):
                assets.cur_script.safe_exec(assets.cur_script.execute_line,self.go_script)
                self.close()
        line.children.append(myb(None,"execute"))
        
        line = gui.pane([0,50],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class myb(gui.button):
            def click_down_over(s,*args):
                print "debugging game"
                s = assets.DebugScript()
                s.debug_game("current","run")
                print "finished"
        line.children.append(myb(None,"Debug current script"))
        
        line = gui.pane([0,70],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class myb(gui.button):
            def click_down_over(s,*args):
                print "debugging game"
                s = assets.DebugScript()
                s.debug_game("all","run")
                print "finished"
        line.children.append(myb(None,"Debug entire game (slow)"))
        
        line = gui.pane([0,90],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class myb(gui.button):
            def click_down_over(s,*args):
                print "debugging game"
                s = assets.DebugScript()
                s.debug_game("all","quote")
                print "finished"
        line.children.append(myb(None,"Find quote errors"))
        
        line = gui.pane([0,110],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class newr(gui.radiobutton):
            def click_down_over(s,*args):
                gui.radiobutton.click_down_over(s,*args)
                assets.game_speed = int(s.text)
        line.children.append(gui.label("Game speed"))
        line.children.append(newr("1","gamespeed"))
        line.children.append(newr("2","gamespeed"))
        line.children.append(newr("6","gamespeed"))
        for t in line.children:
            if t.text==str(assets.game_speed):
                t.checked = True
Exemple #26
0
    def __init__(self, players, superhero_pick=RandomPick, players_pick={}):
        gui.gui_state.__init__(self)
        self.library = cards.library("../dc-deck/pack1")  # todo need to find a more elegant way, not to hardcode this!
        self.game = game_object(self.library)
        self.players_cards = []
        self.played_cards = []
        self.player_widgets = []
        self.supervilain_widget = None
        self.superhero_pick = superhero_pick
        self.players_pick = players_pick

        self.current_player = None

        self.lineup_width = 106
        self.lineup_height = 150

        self.zoom_width = 424
        self.zoom_height = 600
        self.choice_overlay = None

        for p in players:
            self.game.add_player(p)

        self.handle_quit = True

        self.card_zoomed = False
        self.zoomed_widget = None

        self.game.roll_players_start()

        if self.superhero_pick == self.RandomPick:
            self.game.pick_superhero()
        elif self.superhero_pick == self.ChosenPick:
            self.game.assign_superhero(players_pick)

        self.game.create_cards()

        self.supervilain_widget = card_widget(self, self.game.current_supervilain, 106, 150)
        self.supervilain_widget.zoom_width = 424
        self.supervilain_widget.zoom_height = 600
        self.add(self.supervilain_widget)

        current_y = 0

        for p in self.game.players:
            widget = player_widget(p, 300, 120)
            widget.y = current_y
            self.add(widget)
            self.player_widgets.append(widget)
            current_y += widget.height

        self.lineups = []

        self.lineups_empty_case = []

        self.curse_stack = card_widget(self, self.game.curses[0], 106, 150)
        self.buyable_power_stack = card_widget(self, self.game.buyable_powers[0], 106, 150)

        self.add(self.curse_stack)
        self.add(self.buyable_power_stack)

        l_start_x = 250
        l_start_y = 300

        self.curse_stack.x = l_start_x - 121*2
        self.curse_stack.y = l_start_y
        self.curse_stack.zoom_width = 424
        self.curse_stack.zoom_height = 600

        self.buyable_power_stack.x = l_start_x - 121
        self.buyable_power_stack.y = l_start_y
        self.buyable_power_stack.zoom_width = 424
        self.buyable_power_stack.zoom_height = 600

        self.supervilain_widget.x = l_start_x - 121
        self.supervilain_widget.y = l_start_y + self.buyable_power_stack.height + 10

        row = 0

        for i in range(len(self.game.lineups)):
            iw = i
            if row == 1:
                iw -= 3

            widget = card_widget(self, self.game.lineups[i], 106, 150)
            self.lineups.append(widget)
            widget.x = l_start_x + 121*iw
            widget.y = l_start_y + row*160
            widget.zoom_width = 424
            widget.zoom_height = 600

            if i == 2:
                row += 1

            self.add(widget)

        #turn info
        self.lbl_current_turn = gui.label()
        self.lbl_current_turn.text = "%s turns" % self.game.get_current_player().name

        self.lbl_current_turn.x = 5
        self.lbl_current_turn.y = 5

        self.add(self.lbl_current_turn)

        self.lbl_hand = gui.label()
        self.lbl_hand.text = "Hand :"
        self.lbl_hand.x = 10
        self.lbl_hand.y = 160

        self.add(self.lbl_hand)


        self.hand_x = 70
        self.hand_y = 160
        self.hand_width = 91
        self.hand_height = 130

        self.play_x = 70
        self.play_y = 20
        self.play_width = 91
        self.play_height = 130

        #todo need a place for gained cards, or a widget that pop up on button..
        self.gained_card_x = 0
        self.gained_card_y = 0

        #quit to main menu button
        self.btn_quit_game = gui.button(200, 30)
        self.btn_quit_game.x = 10
        self.btn_quit_game.y = 10
        self.btn_quit_game.caption = "Quit game"
        self.btn_quit_game.add_receivers(self.quit_game)

        self.btn_end_turn = gui.button(200, 50)
        self.btn_end_turn.caption = "End turn"
        self.btn_end_turn.add_receivers(self.end_turn)

        self.ta_actions = gui.textarea(400, 100)
        self.ta_actions.text = "Starting game"
        self.add(self.ta_actions)

        #actions bindings
        self.game.change_turn = self.player_turn
        self.game.card_played = self.played_card
        self.game.lineup_changed = self.apply_lineup_action
        self.buyable_power_stack.activated = self.buy_card
        self.game.drawn_card = self.drawn_card
        self.game.ask_player = self.ask_player
        self.game.game_text = self.ta_actions.append
        self.game.refresh_hands = self.refresh_hands
        self.game.start_game()
Exemple #27
0
    def sound(self):
        assets = self.assets
        sw,sh = self.sw,self.sh
        settings_menu.firstpane = "sound"
        self.base()
        ermsg = gui.label("")
        ermsg.rpos = [0,140]
        ermsg.textcol = [255,0,0]
        
        line = gui.pane([0,130],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class myb(gui.checkbox):
            def click_down_over(self,*args):
                super(myb,self).click_down_over(*args)
                if self.checked:
                    assets.set_mute_sound(True)
                else:
                    assets.set_mute_sound(False)
        line.children.append(myb("mute sound"))
        if assets.mute_sound:
            line.children[-1].checked = True
        
        if android:
            return
        line = gui.pane([0,30],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class newr(gui.radiobutton):
            def click_down_over(s,*args):
                ermsg.text = ""
                gui.radiobutton.click_down_over(s,*args)
                assets.sound_format = int(s.text)
                if not assets.init_sound(True): 
                    ermsg.text = "Sound not initialized"
                else:
                    assets.play_sound("phoenix/objection.ogg")
                    wini(assets)
        line.children.append(gui.label("Format:"))
        line.children.append(newr("11025","formchoice"))
        line.children.append(newr("22050","formchoice"))
        line.children.append(newr("44100","formchoice"))
        for t in line.children:
            if t.text==str(assets.sound_format):
                t.checked = True
        
        line = gui.pane([0,50],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class newr(gui.radiobutton):
            def click_down_over(s,*args):
                ermsg.text = ""
                gui.radiobutton.click_down_over(s,*args)
                assets.sound_bits = int(s.text)
                if not assets.init_sound(True): 
                    ermsg.text = "Sound not initialized"
                else:
                    assets.play_sound("phoenix/objection.ogg")
                    wini(assets)
        line.children.append(gui.label("Bits:"))
        line.children.append(newr("8","bitschoice"))
        line.children.append(newr("16","bitschoice"))
        for t in line.children:
            if t.text==str(assets.sound_bits):
                t.checked = True
                
        line = gui.pane([0,70],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        class newr(gui.radiobutton):
            def click_down_over(s,*args):
                ermsg.text = ""
                gui.radiobutton.click_down_over(s,*args)
                assets.sound_buffer = int(s.text)
                if not assets.init_sound(True): 
                    ermsg.text = "Sound not initialized"
                else:
                    assets.play_sound("phoenix/objection.ogg")
                    wini(assets)
        line.children.append(gui.label("Buffer:"))
        line.children.append(newr("512","bufchoice"))
        line.children.append(newr("1024","bufchoice"))
        line.children.append(newr("2048","bufchoice"))
        line.children.append(newr("4096","bufchoice"))
        for t in line.children:
            if t.text==str(assets.sound_buffer):
                t.checked = True
                
        line = gui.pane([0,90],[sw,20])
        line.align = "horiz"
        self.children.append(line)

        self.snd_line = gui.label("SoundVolume: %d"%assets.sound_volume)
        def mod(amt,min,max,var,play):
            def modit():
                ermsg.text = ""
                if not assets.init_sound(): 
                    ermsg.text = "Sound not initialized"
                else:
                    n = getattr(assets,var) + amt
                    if n>max:
                        n = max
                    if n<min:
                        n=min
                    setattr(assets,var,n)
                    self.snd_line.text = "SoundVolume: %d"%assets.sound_volume
                    self.mv_line.text = "MusicVolume: %d"%assets.music_volume
                    play()
                    wini(assets)
            return modit
        line.children.append(self.snd_line)
        line.children.append(gui.button(None,"less"))
        line.children[-1].less = mod(-10,0,100,"sound_volume",lambda:assets.play_sound("phoenix/objection.ogg"))
        line.children.append(gui.button(None,"more"))
        line.children[-1].more = mod(10,0,100,"sound_volume",lambda:assets.play_sound("phoenix/objection.ogg"))
                
        line = gui.pane([0,110],[sw,20])
        line.align = "horiz"
        self.children.append(line)
        
        self.mv_line = gui.label("MusicVolume: %d"%assets.music_volume)
        line.children.append(self.mv_line)
        line.children.append(gui.button(None,"less"))
        line.children[-1].less = mod(-10,0,100,"music_volume",lambda:assets.play_music("Ding.ogg",loop=1,pre="data/sfx/",reset_track=False))
        line.children.append(gui.button(None,"more"))
        line.children[-1].more = mod(10,0,100,"music_volume",lambda:assets.play_music("Ding.ogg",loop=1,pre="data/sfx/",reset_track=False))

        self.children.append(ermsg)
Exemple #28
0
    def __init__(self):
        gui.gui_state.__init__(self)

        #loading superheroes

        self.library = cards.library("../dc-deck/pack1")

        self.lbl_title = gui.label()
        self.lbl_title.font = gui.get_big_font()
        self.lbl_title.text = "Game Setup"

        self.lbl_players_name = gui.label()
        self.lbl_players_name.text = "Players name"

        self.lbl_players_num = gui.label()
        self.lbl_players_num.text = "Number of players : "
        self.lbl_players_num.render()

        self.cb_players_num = gui.combobox(50, 22)
        self.cb_players_num.items.append("2")
        self.cb_players_num.items.append("3")
        self.cb_players_num.items.append("4")
        self.cb_players_num.items.append("5")
        self.cb_players_num.add_receiver(self.player_num_changed)

        self.lbl_cb_superhero_pick = gui.label()
        self.lbl_cb_superhero_pick.text = "Random superhero : "

        self.cb_superhero_pick = gui.checkbox()
        self.cb_superhero_pick.checked = True
        self.cb_superhero_pick.state_changed = self.pick_random_changed

        self.add(self.lbl_title)
        self.add(self.lbl_players_name)

        self.add(self.lbl_players_num)
        self.add(self.cb_players_num)

        self.add(self.lbl_cb_superhero_pick)
        self.add(self.cb_superhero_pick)

        self.tb_players = []
        self.lbl_players = []
        self.slider_player_superhero = []
        nb_players = int(self.cb_players_num.get_item())
        for i in range(5):
            tb = gui.textbox(180, 22)
            self.tb_players.append(tb)
            self.add(tb)
            lbl = gui.label(25, 22)
            lbl.text = str(i+1) + " : "
            self.lbl_players.append(lbl)
            self.add(lbl)

            if i < nb_players:
                tb.visible = True
                lbl.visible = True
            else:
                tb.visible = False
                lbl.visible = False

            slider = gui.slider(100, 22)
            slider.visible = False

            for s in self.library.superheroes:
                slider.items.append(s.name)

            self.slider_player_superhero.append(slider)

            self.add(slider)

        self.btn_start = gui.button(180, 40)
        self.btn_start.caption = "Start !"
        self.btn_start.add_receivers(self.start_game)

        self.btn_back = gui.button(180, 40)
        self.btn_back.caption = "Back"
        self.btn_back.add_receivers(self.back)

        self.add(self.btn_start)
        self.add(self.btn_back)