Пример #1
0
def time(w, time):
    if not time:
        time = 500

    pygame.display.set_caption('Time Menu')

    lastMove = False

    while True:
        if type(time) == list:
            time = time[0]
        moveCheck = False

        x, y = pygame.mouse.get_pos()

        if pygame.mouse.get_pressed()[0]:
            if lastMove:
                if x >= 350 and x <= 850:
                    time = x
                elif x < 350:
                    time = 350
                elif x > 850:
                    time = 850

                moveCheck = True
            else:

                if x > time - 8 and x < time + 8:
                    if y > 492 and y < 508:
                        time = x
                        moveCheck = True
                if c.checkWithin(x, y, 0, 10, 160, 20):
                    #return time conversion here
                    return time
                elif c.checkWithin(x, y, 560, 580, 80, 40):
                    #return time conversion here
                    return time

        d.drawTime(w, x, y, time)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                print("Goodbye!")
                pygame.quit()
                sys.exit()

        lastMove = moveCheck
Пример #2
0
def roadMenu(w, inp):

    lastClick = False
    temp = None

    clock = pygame.time.Clock()

    while True:
        clickCheck = False

        x, y = pygame.mouse.get_pos()

        drawRoadMenu(w, inp, x, y)

        if pygame.mouse.get_pressed()[0]:
            if lastClick:
                if x < 350:
                    x = 350
                elif x > 850:
                    x = 850

                windowValue = inp.getSpecial()
                windowValue[temp - 1] = x
                inp.setSpecial(windowValue)
                clickCheck = True
            else:
                temp = inp.mouseOverSpecial(x, y)
                if temp:
                    print("Getting Special Values", inp.getSpecial())
                    values = inp.getSpecial()
                    values[temp - 1] = x
                    inp.setSpecial(values)
                    clickCheck = True

                elif click.checkWithin(x, y, 0, 10, 160,
                                       20) or click.checkWithin(
                                           x, y, 550, 625, 100, 50):
                    return inp

        clock.tick(60)
        lastClick = clickCheck

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                print("Goodbye")
                sys.exit()
Пример #3
0
def junctionMenu(w, inp):
    tolerance = 8
    lastClick = False
    while True:
        clickCheck = False

        x, y = pygame.mouse.get_pos()

        drawJunctionMenu(w, inp, x, y)

        if pygame.mouse.get_pressed()[0]:
            if click.checkWithin(x, y, 0, 10, 160, 20) or click.checkWithin(
                    x, y, 550, 625, 100, 50):
                print("Goodbye!")
                sys.exit()

            elif not lastClick:
                coord = 300
                special = inp.getSpecial()
                length = len(special)

                for prop in range(length):
                    if y > coord - tolerance and y < coord + tolerance:
                        if x > 450 - tolerance and x < 450 + tolerance:
                            print("P")
                            if "Pink" in special[prop]:
                                special[prop].remove("Pink")
                            else:
                                special[prop].append("Pink")

                        elif x > 550 - tolerance and x < 550 + tolerance:
                            print("B")
                            if "Blue" in special[prop]:
                                special[prop].remove("Blue")
                            else:
                                special[prop].append("Blue")

                        elif x > 650 - tolerance and x < 650 + tolerance:
                            print("G")
                            if "Green" in special[prop]:
                                special[prop].remove("Green")
                            else:
                                special[prop].append("Green")

                        elif x > 750 - tolerance and x < 750 + tolerance:
                            if inp.getTyp() == "4J":
                                print("O")
                                if "Orange" in special[prop]:
                                    special[prop].remove("Orange")
                                else:
                                    special[prop].append("Orange")

                    coord += 50
                if length > 1:
                    if y > coord - 57 - 8 and y < coord - 57 + 8:
                        if x > 778 - 8 and x < 778 + 8:
                            special.pop(length - 1)

                if length <= 7:
                    if y > coord - 16 and y < coord + 16:
                        if x > (600 - 16) and x < (600 + 16):
                            special.append([])

                inp.setSpecial(special)
            clickCheck = True

        clock.tick(60)
        lastClick = clickCheck

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                print("Goodbye!")
                sys.exit()
Пример #4
0
def edit(w, obj):
    pygame.display.set_caption('Edit Menu')

    if obj.typ == "RD" or obj.typ == "TN":
        titleOne = "Length"
        titleTwo = ["Lane Distrobution One", "Lane Distrobution Two"]

    elif obj.typ == "TL":
        titleOne = "Time On"
        titleTwo = "Time Off"

    elif obj.typ == "4J" or "TJ":
        while True:
            x, y = pygame.mouse.get_pos()

            d.editJunction(w, x, y, obj.x, obj.y, obj, obj.rot, obj.states,
                           obj.exits)

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    print("Goodbye!")
                    pygame.quit()
                    sys.exit()

    valueOne, valueTwo = obj.getSpecial()

    if not valueOne:
        valueOne = 500
    if not valueTwo:
        valueTwo = 500

    savedX = obj.x + (obj.width / 2)
    savedY = obj.y + (obj.height / 2)

    image = pygame.transform.scale(obj.img, (150, 150))

    rotation = obj.rotation

    lastMove = False

    lines = [savedX, savedY, rotation]

    if type(valueOne) == int:
        lines.append(valueOne)
    else:
        for i in valueOne:
            lines.append(i)
    if type(valueTwo) == int:
        lines.append(valueTwo)
    else:
        for i in valueTwo:
            lines.append(i)

    print(lines)

    while True:

        moveCheck = False

        x, y = pygame.mouse.get_pos()

        tempList = d.drawEdit(w, x, y, lines[0], lines[1], image, lines[2],
                              valueOne, valueTwo, titleOne, titleTwo)

        if pygame.mouse.get_pressed()[0]:
            if lastMove:
                if x >= 350 and x <= 850:
                    lines[lineID] = x
                elif x < 350:
                    lines[lineID] = 350
                elif x > 850:
                    lines[lineID] = 850
                moveCheck = True

            else:
                print(lines, tempList, x, y)

                lineID = 0
                dontRepeat = False
                userAssist = 8

                for item in tempList:

                    if c.checkWithin(x, y, item[0] - userAssist,
                                     item[1] - userAssist, userAssist * 2,
                                     userAssist * 2) and dontRepeat == False:
                        print("Click")

                        lines[lineID] = x

                        moveCheck = True
                        dontRepeat = True

                    if not dontRepeat:
                        lineID += 1

                if c.checkWithin(x, y, 0, 10, 160, 20) and dontRepeat == False:
                    break

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                print("Goodbye!")
                pygame.quit()
                sys.exit()

        lastMove = moveCheck
Пример #5
0
def main(w, clock):
    pygame.display.set_caption('Design Phase')

    itemList = []
    groupList = []
    menu = 0
    saveImport = 0
    lastMove = False
    lastClick = False
    l = None
    time = None

    while True:
        clickCheck = False
        moveCheck = False

        clock.tick(60)

        x, y = pygame.mouse.get_pos()

        if pygame.mouse.get_pressed()[0]:
            clickCheck = True
            if lastMove:
                l.move(x, y, w)
                moveCheck = True
            else:
                if x > 1050 and x < 1190:  #Run GUI or MRS
                    if y > 740 and y < 770:
                        s.MRS()
                        break
                    elif y > 680 and y < 710:
                        s.GUI()
                        break

                if not lastClick:
                    if c.checkWithin(x, y, 0, 10, 160, 20):
                        print("Returning To Main Menu")
                        itemList[0].resetCounter()
                        break

                    l = c.checkMove(w, x, y, itemList)
                if l:
                    if l.typ == ("TM"):
                        pass
                    else:
                        moveCheck = True

                if not moveCheck and not lastClick:
                    quart = 0
                    if c.checkWithin(x, y, 1000, 0, 100, 30):
                        if saveImport == 0:
                            saveImport = 1
                        elif saveImport == 1:
                            p.pack(itemList, 1, time, groupList)
                            saveImport = 0
                        elif saveImport == 2:
                            itemList, time, groupList = p.unpack(1)
                            saveImport = 0

                    if c.checkWithin(x, y, 1100, 0, 100, 30):
                        if saveImport == 0:
                            saveImport = 2
                        elif saveImport == 1:
                            p.pack(itemList, 2, time, groupList)
                            saveImport = 0
                        elif saveImport == 2:
                            itemList, time, groupList = p.unpack(2)
                            saveImport = 0

                    elif c.checkWithin(x, y, 0, 700, 100, 100):
                        quart = 1
                    elif c.checkWithin(x, y, 100, 700, 100, 100):
                        quart = 2
                    if menu == 0:
                        if quart == 1:
                            length = len(itemList)
                            for x in range(length, 0, -1):
                                o = itemList[x - 1]
                                if o.checkInside(0, 600, 200, 800):
                                    itemList.remove(o)
                                    classy.Object.counterStorage.append(o.id)
                            menu = 1
                        elif quart == 2:
                            length = len(itemList)
                            for x in range(length, 0, -1):
                                o = itemList[x - 1]
                                if o.checkInside(0, 600, 200, 800):
                                    itemList.remove(o)
                                    classy.Object.counterStorage.append(o.id)
                            menu = 2

                    elif menu == 1 or menu == 2:
                        if quart == 2:
                            length = len(itemList)
                            for x in range(length, 0, -1):
                                o = itemList[x - 1]
                                if o.checkInside(0, 600, 200, 800):
                                    itemList.remove(o)
                                    classy.Object.counterStorage.append(o.id)
                            menu = 0
                    if menu == 2:
                        if c.checkWithin(x, y, 100, 600, 100, 100):
                            time = e.time(w, time)

        if lastMove and not clickCheck:
            if l.checkInside(200, 740, 240, 800):
                itemList.remove(l)
                classy.Object.counterStorage.append(l.id)
            """ elif onTop(l, itemList):
                itemList.remove(l) """

            e.snap(w, itemList, l)

            tempX = l.x + (l.width / 2)
            tempY = l.y + (l.height / 2)
            if l.typ == "ET":
                for i in itemList:
                    if i.checkWithin(tempX, tempY):
                        itemList.remove(l)
                        classy.Object.counterStorage.append(l.id)
                        if i != l:
                            if i.typ == "TL":
                                groupList.append(e.edit(w, i, itemList))
                            else:
                                i = e.edit(w, i, itemList)

                            clickCheck = True
                        break

            elif l.typ == "RO":
                for i in itemList:
                    if i.checkWithin(tempX, tempY):
                        itemList.remove(l)
                        classy.Object.counterStorage.append(l.id)
                        c.rotate(i, itemList)
                        i.defineGeometry()
                        clickCheck = True
                        break

        d.drawAll(w, x, y, itemList, menu, saveImport)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                print("Goodbye!")
                pygame.quit()
                sys.exit()

        lastClick = clickCheck
        lastMove = moveCheck