class UIChooseGirl(Panel, InputHandler): def __init__(self, trans, *a, **k): self.trans = trans g = Game.getgame() choices = trans.mapping[g.me] w, h = 500 + 1*160, 390 + 1*113 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw-w)/2, (ph-h)/2 self.inputlet = None choices = self.choices = [c for c in choices if c.char_cls and not getattr(c, 'chosen', False)] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, 4) x, y = 15 + 160*x, 45 + 113*(3-y) gs = GirlSelector(c, selectors, parent=self, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs) def process_user_input(self, ilet): self.inputlet = ilet self.begin_selection() def on_girl_chosen(self, choice): for c in self.selectors: if c.choice is choice: c.disable() break self.parent.update_portraits() def begin_selection(self): self.pbar = BigProgressBar( parent=self, x=(self.width-250)//2, y=9, width=250, ) def on_done(*a): self.inputlet.done() self.end_selection() self.pbar.value = LinearInterp( 1.0, 0.0, self.inputlet.timeout, on_done=on_done, ) def end_selection(self): self.inputlet = None self.pbar.delete()
class UIBaseChooseGirl(Panel, InputHandler): hover_pic = None def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None self.selecting = False g = Game.getgame() choices = trans.mapping[g.me] n_choices = len(choices) cols = 5 if n_choices > 16 else 4 rows = max((n_choices - 1) / cols + 1, 4) w, h = 20 + cols * 160, 51 + rows * 113 + 30 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw - w) / 2, (ph - h) / 2 self.inputlet = None choices = self.choices = [ c for c in choices if c.char_cls and not getattr(c, 'chosen', False) ] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, cols) x, y = 15 + 160 * x, 45 + 113 * (rows - 1 - y) gs = GirlSelector(c, selectors, parent=self, hover_pic=self.hover_pic, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs) self.label = Label(text='等待其他玩家操作', x=w // 2, y=51 + rows * 113, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 230), anchor_x='center', anchor_y='bottom') def draw(self): Panel.draw(self) self.label.draw() def on_girl_chosen(self, arg): actor, choice = arg for c in self.selectors: if c.choice is choice: c.disable() break self.parent.update_portraits() def begin_selection(self): self.selecting = True self.pbar and self.pbar.delete() self.pbar = BigProgressBar( parent=self, x=(self.width - 250) // 2, y=9, width=250, ) def on_done(*a): # self.inputlet.done() # FIXME: blindly did this. self.inputlet and self.inputlet.done() self.end_selection() self.pbar.value = LinearInterp( 1.0, 0.0, self.inputlet.timeout, on_done=on_done, ) def end_selection(self): self.inputlet = None self.selecting = False self.pbar.delete()
class UIBaseChooseGirl(Panel, InputHandler): hover_pic = None def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None self.selecting = False g = Game.getgame() choices = trans.mapping[g.me] n_choices = len(choices) cols = 5 if n_choices > 16 else 4 rows = max((n_choices - 1) / cols + 1, 4) w, h = 20 + cols*160, 51 + rows*113 + 30 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw - w)/2, (ph - h)/2 self.inputlet = None choices = self.choices = [c for c in choices if c.char_cls and not getattr(c, 'chosen', False)] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, cols) x, y = 15 + 160*x, 45 + 113*(rows - 1 - y) gs = GirlSelector(c, selectors, parent=self, hover_pic=self.hover_pic, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs) self.label = Label( text='等待其他玩家操作', x=w//2, y=51+rows*113, font_size=12, color=(255, 255, 160, 255), shadow=(2, 0, 0, 0, 230), anchor_x='center', anchor_y='bottom' ) def draw(self): Panel.draw(self) self.label.draw() def on_girl_chosen(self, arg): actor, choice = arg for c in self.selectors: if c.choice is choice: c.disable() break self.parent.update_portraits() def begin_selection(self): self.selecting = True self.pbar and self.pbar.delete() self.pbar = BigProgressBar( parent=self, x=(self.width-250)//2, y=9, width=250, ) def on_done(*a): # self.inputlet.done() # FIXME: blindly did this. self.inputlet and self.inputlet.done() self.end_selection() self.pbar.value = LinearInterp( 1.0, 0.0, self.inputlet.timeout, on_done=on_done, ) def end_selection(self): self.inputlet = None self.selecting = False self.pbar.delete()
class UIChooseGirl(Panel, InputHandler): def __init__(self, trans, *a, **k): self.trans = trans self.pbar = None g = Game.getgame() choices = trans.mapping[g.me] w, h = 500 + 1 * 160, 390 + 1 * 113 Panel.__init__(self, width=w, height=h, zindex=5, *a, **k) p = self.parent pw, ph = p.width, p.height self.x, self.y = (pw - w) / 2, (ph - h) / 2 self.inputlet = None choices = self.choices = [ c for c in choices if c.char_cls and not getattr(c, 'chosen', False) ] self.selectors = selectors = [] for i, c in enumerate(choices): y, x = divmod(i, 4) x, y = 15 + 160 * x, 45 + 113 * (3 - y) gs = GirlSelector(c, selectors, parent=self, x=x, y=y) @gs.event def on_dblclick(gs=gs): c = gs.choice ilet = self.inputlet if not c.chosen and ilet: ilet.set_choice(c) ilet.done() self.end_selection() selectors.append(gs) def process_user_input(self, ilet): self.inputlet = ilet self.begin_selection() def on_girl_chosen(self, choice): for c in self.selectors: if c.choice is choice: c.disable() break self.parent.update_portraits() def begin_selection(self): self.pbar and self.pbar.delete() self.pbar = BigProgressBar( parent=self, x=(self.width - 250) // 2, y=9, width=250, ) def on_done(*a): # self.inputlet.done() # FIXME: blindly did this. self.inputlet and self.inputlet.done() self.end_selection() self.pbar.value = LinearInterp( 1.0, 0.0, self.inputlet.timeout, on_done=on_done, ) def end_selection(self): self.inputlet = None self.pbar.delete()