예제 #1
0
    def compare(self, dumy):
        if self.right_panel != "snapshot":
            Panel.printLeft("没有快照可以比较!")
            return
        if self.comparing:  #已经处于比对状态,先取消
            self.cancel(dumy)
        self.comparing = True
        mark = 0
        right = self.my_snapshot
        for my_b in self.my_playground.blocks():
            for sn_b in right.blocks():
                if my_b.block.origin == sn_b.block.origin:
                    if my_b.block.current != sn_b.block.current:
                        str_mark = str(mark)
                        my_b.mark = str_mark
                        sn_b.mark = str_mark
                        mark += 1
                    elif my_b.block.colors != sn_b.block.colors:
                        str_mark = str(mark)
                        my_b.mark = str_mark
                        sn_b.mark = str_mark
                        mark += 1

        if mark > 0:
            self.my_playground.displayContent()
            self.my_snapshot.displayContent()
예제 #2
0
 def singleRotate(self, action):
     reverse = False
     if self.rotating:
         return False
     if action == None:
         if len(self.his_actions) > 0:
             pre_action = self.his_actions.pop(-1)
             pre_action_info = a_map.get(pre_action)
             action = pre_action_info["reverse"]
             reverse = True
     if action != None:
         self.rotate_layer = a_map[action]["layer"]
         self.rotating = True
         self.rotate_angle = 0
         self.rotate_face = a_map[action]["face"]
         self.rotate_layer = a_map[action]["layer"]
         self.rotate_clockwize = a_map[action]["clockwize"]
         if not reverse:
             if len(self.his_actions) < self.his_count:
                 self.his_actions.append(action)
             else:
                 self.his_actions.pop(0)
                 self.his_actions.append(action)
     msg = "".join(self.his_actions)
     Panel.printLeft(msg)
     return True
예제 #3
0
 def next(self, dummy):
     if self.current_level == -1:
         self.current_level = self.my_library.lib_level
     current_stage = p_map[self.resolve_method][self.current_level]
     self.current_level += 1
     if self.current_level >= len(p_map[self.resolve_method]):
         Panel.printLeft("魔方已经完全解决")
         return
     next_stage = p_map[self.resolve_method][self.current_level]
     auto_actions = []
     while current_stage < next_stage:
         for a in auto_actions:
             face = a_map[a]["face"]
             layer = a_map[a]["layer"]
             clockwize = a_map[a]["clockwize"]
             self.my_playground.cube().rotateCube(face, layer, clockwize)
         advice = self.hint2()
         auto_actions = parseAdvice(advice.get("h", ""))
         current_stage = advice.get("s", current_stage)
         if auto_actions == "":
             break
     self.his_actions = []
     self.advice = ""
     self.my_playground.rebuild()
     self.my_playground.displayContent()
     self.current_level = -1
예제 #4
0
 def saveCube(self, cube):
     self.setLevel(0)
     self.next_index += 1
     self.writeCube2File(self.snapshots_dir, self.next_index, cube, 0)
     self.build()
     Panel.printLeft(u"保存为第" + str(self.total) + "份快照")
     self.setCurrent((self.getTotal(), -1))
     self.displayContent()
예제 #5
0
 def endBrush(self, dumy):
     if self.brush_copy == 1:
         if not self.my_cube_3d.cube.validateCube():
             msg = u"颜色设置没有完成,请继续完成设置!"
         else:
             self.brush_copy = 0
             msg = u"颜色设置完成"
         Panel.printLeft(msg)
예제 #6
0
 def cancelBrush(self):
     if len(self.his_colors) > 0:
         b, i, c = self.his_colors.pop(-1)
         b.colors[i] = c
         self.my_cube_3d.buildFaces()
         self.my_cube_3d.displayCube()
     else:
         self.brush_copy = 0
         Panel.printLeft(u"取消全部设置")
예제 #7
0
 def showLibBelowLevel3(self):
     if self.total == 0:
         return
     self.legends = []
     file = self.snapshots_dir + self.snapshots[self.current - 1][0]
     cube = cubeModel.Cube(file)
     self.my_cube_3d = cubeLegendF2L.CubeLegendF2L(cube, width, height, fov,
                                                   distance, adj_x, adj_y)
     self.my_cube_3d.buildFaces()
     self.my_cube_3d.setLBDPos([(180, -70), (480, -70), (160, 260)])
     self.my_cube_3d.displayContent()
     self.legends.append(self.my_cube_3d)
     self.current_legend = 0
     Panel.printLeft(u"选择了第" + str(self.current) + "份快照")
예제 #8
0
    def cancelComparing(self):
        if self.right_panel != "snapshot":
            Panel.printLeft("没有快照可以取消比较!")
            self.comparing = False
            return

        self.comparing = False
        mark = 1
        for my_b in self.my_playground.blocks():
            if my_b.mark != "-":
                my_b.mark = "-"
        for sn_b in self.my_snapshot.blocks():
            if sn_b.mark != "-":
                sn_b.mark = "-"
        self.my_playground.displayContent()
        self.my_snapshot.displayContent()
예제 #9
0
 def deleteCurrent(self):
     if self.lib_level > 0:
         Panel.printLeft(u"不能删除非自定义题库里的题目")
         return
     if self.total == 0 or self.current == 0:
         return
     os.remove(self.snapshots_dir + self.snapshots[self.current - 1][0])
     del (self.snapshots[self.current - 1])
     with open(self.snapshots_dir + "index", "w", 1) as fo:
         fo.write("#generated by this program, never modify it.\n")
         for line in self.snapshots:
             fo.write(line[0] + " " + str(line[1]) + "\n")
     self.setTotal(self.total - 1)
     if self.current > 0:
         self.setCurrent((self.current - 1, -1))
     if self.current == 0:
         self.setCurrent((self.current + 1, -1))
     self.displayContent()
예제 #10
0
 def singleClick(self, x, y):
     if self.legends == []:
         return False
     if self.lib_level < 3:
         if self.my_cube_3d.hitMe(x, y):
             self.single_clicked = True
             return True
     count = len(self.legends)
     for i, l in enumerate(self.legends):
         if l.hitMe(x, y):
             l.drawSelected()
             if self.current_legend != -1:
                 self.legends[self.current_legend].redraw()
             Panel.printLeft(u"选择了第%d份快照" % (i + 1))
             self.current_legend = i
             self.my_cube_3d = l
             self.single_clicked = True
             return True
     return False
예제 #11
0
 def displayAll(self):
     self.my_playground.displayContent()
     #self.my_tutorial.displayContent()
     self.my_library.displayContent()
     Panel.printLeft(u"当前解题方法是" + self.resolve_method + u"法")
     Panel.printHint(u"下一步提示")
예제 #12
0
 def method(self, method):
     self.resolve_method = method
     Panel.printLeft("当前提示和自动解题方法是" + method)
예제 #13
0
 def delete(self, dumy):
     if self.right_panel != "library":
         Panel.printLeft(u"当前是帮助窗口,不能删除.")
     else:
         self.my_library.deleteCurrent()
예제 #14
0
 def selectColor(self, c):
     self.brush_color = c
     self.brush_copy = 1
     Panel.printLeft(u"选择色块,双击魔方设置颜色。当前选中:" + colors_n[self.brush_color])