def __init__(self, project): QtGui.QWidget.__init__(self) self.project = project ### coordinates ### self.coords = Label("Cursor coordinates") self.coords.setText("x\ny"); ### tools buttons ### self.penB = Button("pen (1)", "icons/tool_pen.png", self.penClicked, True) self.penB.setChecked(True) self.project.toolSetPenSign.connect(self.penClicked) self.pipetteB = Button("pipette (2)", "icons/tool_pipette.png", self.pipetteClicked, True) self.fillB = Button("fill (3)", "icons/tool_fill.png", self.fillClicked, True) self.moveB = Button("move (4)", "icons/tool_move.png", self.moveClicked, True) self.selectB = Button("select (5)", "icons/tool_select.png", self.selectClicked, True) ### Layout ### layout = QtGui.QVBoxLayout() layout.setSpacing(0) layout.addWidget(self.coords) layout.addWidget(self.penB) layout.addWidget(self.pipetteB) layout.addWidget(self.fillB) layout.addWidget(self.moveB) layout.addWidget(self.selectB) layout.addStretch() layout.setContentsMargins(6, 0, 6, 0) self.setLayout(layout)
def setup_creature_role(self): self.is_creature = True gamecard = self.gamecard self.power = 0 #gamecard.power self.toughness = 0 #gamecard.toughness self.damage = 0 #gamecard.currentDamage() #dispatcher.connect(self.change_value, signal=PowerToughnessModifiedEvent(), sender=gamecard) # XXX This will lead to a lot of events each time priority is passed # but I'm not sure how to do it otherwise for cards like "Coat of Arms", which use a lambda function # or for damage self.text = Label("", size=34, background=True, shadow=False, halign="center", valign="center") #self.text._scale = anim.animate(0, 2.0, dt=0.25, method="sine") self.text.scale = 2.0 #self.text._pos.set(euclid.Vector3(0,0,0)) #_transition(dt=0.25, method="sine") self.text.orig_pos = euclid.Vector3(0, -self.height * 0.25, 0.001) self.text.zoom_pos = euclid.Vector3(self.width * 1.375, -self.height * 0.454, 0.01) self.text.pos = self.text.orig_pos #self.damage_text = Label("", size=34, background=True, shadow=False, halign="center", valign="center", color=(1., 0., 0., 1.)) #self.damage_text._scale = anim.animate(0.0, 0.0, dt=0.25, method="sine") #self.damage_text.scale = 0.4 #self.damage_text.visible = 0 #self.damage_text._pos.set(euclid.Vector3(0,0,0)) #_transition(dt=0.25, method="sine") #self.damage_text.zoom_pos = euclid.Vector3(self.width*(1-.375),-self.height*0.454, 0.01) #self.damage_text.pos = self.damage_text.zoom_pos self.change_value() self.draw = self.draw_creature dispatcher.connect(self.change_value, signal=TimestepEvent())
def add_number_spark(self, number, start_pos, end_pos, dt=1.0, color=None, dim=2): random_offset = euclid.Vector3(self.randomizer.random() * 50 - 25, self.randomizer.random() * 30, 0) start_pos += random_offset end_pos += random_offset if color == None: color = (1., 1., 1., 1) elif isinstance(color, str): color = self.COLORS.get(color) else: color = color spark = Label(str(number), size=40, color=color, shadow=False, halign="center", valign="center", pos=start_pos) spark._pos.set_transition(dt=dt, method="ease_out_circ") #ease_out_back") spark.pos = end_pos spark.visible = anim.animate(1., 0., dt=dt) spark.scale = anim.animate(1.0, 1.3, dt=dt, method="sine") if dim == 2: self.active_sparks.append(spark) else: self.active_sparks_3d.append(spark)
def __init__(self, pos=zero): super(ManaView, self).__init__(pos) self._pos.set_transition(dt=1.0, method="ease_out_circ") self.colors = ["white", "blue", "black", "red", "green", "colorless"] self.colormap = dict(zip(self.colors, "WUBRG")) self.nummana = len(self.colors) self.symbols = [ManaImage(color) for color in self.colors] self.pool = [Label("", size=20) for i in range(self.nummana)] self.values = dict([(c, v) for c, v in zip(self.colors, self.pool)]) self.spend = [Label("0", size=30) for i in range(self.nummana)] self.spend_values = dict([(c, v) for c, v in zip(self.colors, self.spend)]) for p, s in zip(self.pool, self.spend): p.visible = anim.constant(1) s.visible = anim.constant(1) self.cost = Label("0", size=40, halign="center", background=True) self.select_mana = self.select_x = False self.layout()
def __init__(self, pos=zero): super(GameStatus, self).__init__(pos) self.screen_width = self.screen_height = 0 self._pos.set_transition(dt=0.5, method="ease_out_back") self.prompt = Label("", size=20, shadow=False, halign="center", valign="top", background=True) self.prompt.border = 3 self.prompt._pos.set_transition(dt=0.5, method="sine") self.show_log = False self.width = 400 self.gamelog = [ Label('', size=14, halign="left", width=self.width) for i in range(15) ] self.logger = []
def __init__(self, pos=zero): super(PhaseStatus, self).__init__(pos) self.visible = anim.constant(0) states = [('Untap', 'Untap'), ('Upkeep', 'Upkeep'), ('Draw', 'Draw'), ('Main1', 'Main 1'), ('BeginCombat', 'Beginning of combat'), ('Attack', 'Declare attackers'), ('Block', 'Declare blockers'), ('Damage', 'Combat damage'), ('EndCombat', 'End of combat'), ('Main2', 'Main 2'), ('EndStep', 'End Step'), ('Cleanup', 'Cleanup')] self.state_list = [s.lower() for s, t in states] self.grouping = [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0] self.state_map = dict([(key, (i, val)) for i, (key, val) in enumerate(states)]) self.states = [Image(key) for key, val in states] self.state_labels = [ Label(val, size=20, valign="center", shadow=False) for key, val in states ] self.state_text = None for state in self.states: state.visible = anim.constant(1.0) state.alpha = anim.animate(1.0, 1.0, dt=0.5, method="ease_out_circ") ##sine") state.scale = anim.animate(1.0, 1.0, dt=0.5, method="sine") state._pos.set_transition(dt=0.5, method="sine") for label in self.state_labels: label.scale = 0.8 label._pos.y = anim.constant( -100) # This is just a hack to hide it self.width = state.width self.current = 0 self.select = False self.curr_player = None self.turn_label = Label("", size=24, halign="center", valign="top", shadow=False) self.render_after_transform = self.render_game self.set_stops()
def info(string): from widget import WidgetState class InfoState(WidgetState): pass state = InfoState() from widget import Label Label(string, (None, None)).draw() update() state.quit()
def __init__(self, pos=zero, is_opponent=False): super(StatusView, self).__init__(pos) self._toggled = False self._spacing = 10 self._reveal_library = False self.color = (0.5, 0.5, 0.5) self.is_opponent = is_opponent #self._pos.set_transition(dt=0.1, method="linear") #symbols = ["life", "library", "hand", "graveyard", "exile"] symbols = ["life", "hand", "library", "graveyard", "exile"] self.symbols = dict([(symbol, cls(symbol)) for symbol, cls in zip( symbols, [Image, Image, Image, Image, Image])]) for symbol in self.symbols.values(): symbol.alpha = 0.8 self.player_name = Label("", 11, halign="left", fontname="Arial Bold", valign="center", shadow=False) #sizes = [20, 16, 14, 14, 14] sizes = [20, 14, 14, 14, 14] self.values = dict([(symbol, Label('', size, fontname="Arial Bold", halign="center", valign="center", shadow=False)) for symbol, size in zip(symbols, sizes)]) #for val in self.values.values(): self.avatar = Image(pyglet.image.Texture.create(80, 80)) self.avatar.shaking = 0 self.avatar.alpha = anim.animate(1., 1., dt=0.25) self.alpha = anim.animate(1., 1., dt=0.25) self.manapool = ManaPool(is_opponent) self.zone_view = ZoneView() self._library = LibraryImage(is_opponent) self.width, self.height = 145, 135
def __init__(self, pos=zero): super(SelectionList, self).__init__(pos) #self.options = [] #self.alpha = anim.animate(0, 0.9, dt=1.0, method="sine") self.border = 20 self.visible = anim.constant(0) #self.focus_idx = 0 self.large_size = 17 self.max_width = 700 #self.small_scale = 0.35 #self.intermediate_scale = 0.55 #self.layout = self.layout_normal self.prompt = Label("", size=self.large_size, halign="center", shadow=False)
def __init__(self): from widget import Label WidgetState.__init__(self) Label("Waiting for Players to join", (None, None))
def __init__(self): from widget import Label WidgetState.__init__(self) Label("Connecting to server", (None, None))