def startMenu(): py.init() v.screen = py.display.set_mode((920, 630), py.DOUBLEBUF) buttons = py.sprite.Group() buttons.add(mapMenuItems.button("New Map", (460, 270), 50, (255, 255, 0), (0, 0, 255), "../Resources/Fonts/RunicSolid.ttf", "NM", True, (220, 50))) buttons.add(mapMenuItems.button("Load Map", (460, 360), 50, (255, 255, 0), (0, 0, 255), "../Resources/Fonts/RunicSolid.ttf", "LM", True, (220, 50))) texts = py.sprite.Group() texts.add(mapMenuItems.textLabel("Legend Of Aiopa RPG", (460, 150), (255, 0, 255), "../Resources/Fonts/RunicSolid.ttf", 50, variable = False, centred = True)) texts.add(mapMenuItems.textLabel("Map Editor", (460, 200), (200, 0, 200), "../Resources/Fonts/RunicSolid.ttf", 40, variable = False, centred = True)) v.textNum = 1 while True: py.event.pump() v.events = [] v.events = py.event.get() v.screen.fill((0, 255, 255)) texts.update() buttons.update() py.display.flip() for event in v.events: if event.type == py.MOUSEBUTTONDOWN: for b in buttons: if b.pressed(): if b.ID == "NM": #setup() npcEdit.createNPC() if b.ID == "LM": from sys import path path.append('../Saves') import mapFile # @UnresolvedImport v.totalMap = mapFile.map load()
def __init__(self, c_message="", c_goto = "", c_id = "", c_charisma = "", c_buttons = [], c_changelike = "", c_end = ""): super().__init__() print("new", c_buttons) self.created = False self.c_message = c_message self.c_goto = c_goto self.c_id = c_id self.c_charisma = c_charisma self.c_buttons = c_buttons self.c_changelike = c_changelike self.c_end = c_end self.posx = 210 self.posy = 50 self.rect = py.Rect(self.posx, self.posy, 500, 150) self.tinps = py.sprite.Group() self.texts = py.sprite.Group() self.texts.add(mapMenuItems.textLabel("ID:", (self.posx + 20, self.posy + 20), (0, 0, 0), None, 25)) self.tinps.add(mapMenuItems.textInput((self.posx + 10, self.posy + 40), 25, 2, 1, button=None, default=list(self.c_id), type="int", fontfile=None)) self.texts.add(mapMenuItems.textLabel("Message: (Lines are conjoined with no space)", (self.posx + 20, self.posy + 80), (0, 0, 0), None, 25)) self.tinps.add(mapMenuItems.textInput((self.posx + 10, self.posy + 100), 15, 50, 2, button=None, default=list(self.c_message[:len(self.c_message)//2]), type="str", fontfile=None)) self.tinps.add(mapMenuItems.textInput((self.posx + 10, self.posy + 120), 15, 50, 3, button=None, default=list(self.c_message[len(self.c_message)//2:]), type="str", fontfile=None)) self.texts.add(mapMenuItems.textLabel("Goto:", (self.posx + 80, self.posy + 20), (0, 0, 0), None, 25)) self.tinps.add(mapMenuItems.textInput((self.posx + 80, self.posy + 40), 25, 2, 4, button=None, default=list(self.c_goto), type="int", fontfile=None)) self.texts.add(mapMenuItems.textLabel("Charisma", (self.posx + 160, self.posy + 5), (0, 0, 0), None, 20)) self.texts.add(mapMenuItems.textLabel("Needed:", (self.posx + 160, self.posy + 20), (0, 0, 0), None, 20)) self.tinps.add(mapMenuItems.textInput((self.posx + 160, self.posy + 40), 25, 2, 5, button=None, default=list(self.c_charisma), type="int", fontfile=None)) self.texts.add(mapMenuItems.textLabel("Change", (self.posx + 240, self.posy + 5), (0, 0, 0), None, 20)) self.texts.add(mapMenuItems.textLabel("Friendliness:", (self.posx + 240, self.posy + 20), (0, 0, 0), None, 20)) self.tinps.add(mapMenuItems.textInput((self.posx + 240, self.posy + 40), 25, 2, 6, button=None, default=list(self.c_changelike), type="int", fontfile=None)) self.texts.add(mapMenuItems.textLabel("End:", (self.posx + 330, self.posy + 20), (0, 0, 0), None, 25)) self.tinps.add(mapMenuItems.textInput((self.posx + 330, self.posy + 40), 25, 2, 7, button=None, default=list(self.c_end), type="int", fontfile=None)) self.Btexts = py.sprite.Group() self.Btinps = py.sprite.Group() self.Bselect = py.sprite.Group() print("c buttons:", self.c_buttons) #TODO: Fix blank buttons while len(self.c_buttons) < 4: self.c_buttons.append({}) for i in range(len(self.c_buttons)): self.Bselect.add(self.button(i, self)) self.editButton = None self.buttonGo = mapMenuItems.button("Save", (570, 60), 80, (100, 100, 100), (150, 150, 150), None, "save", centred=False, bsize=(130, 80), centretext=True) self.buttonDel = mapMenuItems.button("Delete", (420, 60), 60, (100, 100, 100), (150, 150, 150), None, "delete", centred=False, bsize=(130, 80), centretext=True)
def createNPC(): bar = mapMenuItems.scrollBar(910, 10, 610, 10) texts = py.sprite.Group() ni = mapMenuItems.textInput((350, 200), 30, 16, 1, button=None, default=[], type="str") texts.add(mapMenuItems.textLabel("NPC Name:", (150, 210), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) fi = mapMenuItems.textInput((450, 260), 30, 2, 2, button=None, default=[], type="int") texts.add(mapMenuItems.textLabel("Base Friendliness:", (150, 270), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) arb = mapMenuItems.radioButtons(350, 330, ["Good", "Evil"]) texts.add(mapMenuItems.textLabel("Alignment:", (150, 330), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) drb = mapMenuItems.radioButtons(350, 390, ["Up", "Down", "Left", "Right"]) texts.add(mapMenuItems.textLabel("Direction:", (150, 390), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) buttons = py.sprite.Group() buttons.add(mapMenuItems.button("Done", (800, 550), 60, (200, 0, 200), (255, 50, 255), "../Resources/Fonts/RPGSystem.ttf", "done")) buttons.add(mapMenuItems.button("Add Conversation", (460, 500), 60, (200, 200, 100), (100, 200, 200), "../Resources/Fonts/RPGSystem.ttf", "convo", centred=True)) imageButton = npcImageButton(drb) faceButton = npcFaceButton() while True: v.screen.fill((220, 220, 220)) v.events = [] v.events = py.event.get() imageButton.update() faceButton.update() bar.update() texts.update() arb.update() drb.update() ni.update() fi.update() buttons.update() for event in v.events: if event.type == py.MOUSEBUTTONDOWN: for button in buttons: if button.pressed(): if button.ID == "done": v.selectedNPC = {"Image": imageButton.selected, "Name": ni.outText, "Alignment": arb.outText, "Base Like": fi.outText, "Direction": drb.outText} print(v.selectedNPC) return if button.ID == "convo": chatEdit() py.display.flip()
def createEnemy(): tinps = py.sprite.Group() texts = py.sprite.Group() v.textNum = 1 tinps.add(mapMenuItems.textInput((400, 100), 40, 16, 1, button=None, default=[], type="str")) texts.add(mapMenuItems.textLabel("Enemy Name:", (150, 110), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) tinps.add(mapMenuItems.textInput((400, 200), 40, 2, 2, button=None, default=[], type="int")) texts.add(mapMenuItems.textLabel("Attack:", (150, 210), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) tinps.add(mapMenuItems.textInput((400, 300), 40, 3, 3, button=None, default=[], type="int")) texts.add(mapMenuItems.textLabel("Health:", (150, 310), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) tinps.add(mapMenuItems.textInput((400, 400), 40, 2, 4, button=None, default=[], type="int")) texts.add(mapMenuItems.textLabel("Speed:", (150, 410), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 40, variable=False, centred=False)) button = mapMenuItems.button("Done", (500, 500), 60, (200, 0, 0), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "GO") while True: py.event.pump() v.events = [] v.events = py.event.get() v.screen.fill((200, 200, 200)) tinps.update() texts.update() button.update() for event in v.events: if event.type == py.MOUSEBUTTONDOWN: if button.pressed(): for t in tinps: if t.num == 1: v.selectedEnemy["Name"] = t.outText if t.num == 2: v.selectedEnemy["Attack"] = t.outText if t.num == 3: v.selectedEnemy["Health"] = t.outText if t.num == 4: v.selectedEnemy["Speed"] = t.outText py.time.delay(200) return py.display.flip()
def setup(): tinps = py.sprite.Group() texts = py.sprite.Group() v.textNum = 1 tinps.add(mapMenuItems.textInput((500, 100), 60, 2, 1, button=None, default=['1', '0'], type="int")) texts.add(mapMenuItems.textLabel("Map Width:", (240, 110), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60)) tinps.add(mapMenuItems.textInput((500, 180), 60, 2, 2, button=None, default=['1', '0'], type="int")) texts.add(mapMenuItems.textLabel("Map Height:", (240, 190), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60)) if v.tempId == None: df = ['1'] else: df = list(str(v.tempId)) tinps.add(mapMenuItems.textInput((500, 260), 60, 2, 3, button=None, default=df, type="int")) texts.add(mapMenuItems.textLabel("Map ID:", (240, 270), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60)) tinps.add(mapMenuItems.textInput((400, 350), 30, 24, 4, button=None, default=['P', 'l', 'a', 'c', 'e'], type="str")) texts.add(mapMenuItems.textLabel("Location Name:", (40, 350), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60)) tinps.add(mapMenuItems.textInput((500, 430), 40, 10, 5, button=None, default=['P', 'l', 'a', 'i', 'n', 's'], type="str")) texts.add(mapMenuItems.textLabel("Biome:", (240, 440), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60)) buttons = py.sprite.Group() buttons.add(mapMenuItems.button("Back", (10, 550),80, (255, 255, 255), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "B")) buttons.add(mapMenuItems.button("Continue", (690, 550), 70, (255, 255, 255), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "C")) while True: py.event.pump() v.events = [] v.events = py.event.get() v.screen.fill((0, 255, 0)) tinps.update() texts.update() buttons.update() py.display.flip() for b in buttons: if b.pressed(): if py.mouse.get_pressed()[0]: if b.ID == "B": startMenu() return if b.ID == "C": for i in tinps: if i.num == 1: x = int(i.outText) if i.num == 2: y = int(i.outText) if i.num == 3: v.currentID = int(i.outText) if i.num == 4: v.currentName = str(i.outText) if i.num == 5: v.currentBiome = str(i.outText) v.size = (x, y) v.baseTiles = py.sprite.Group() v.topTiles = py.sprite.Group() v.tiles = py.sprite.Group() for x in range(v.size[0]): for y in range(v.size[1]): v.baseTiles.add(tileEdit.tile(x, y, "base")) v.topTiles.add(tileEdit.tile(x, y, "top")) mapEditor() return
def chatEdit(): v.chunks = py.sprite.Group() v.chunkIDs['0'] = [] v.chunkIDs['1'] = [] v.chunkIDs['2'] = [] v.chatEdit = editChunk() buttons = py.sprite.Group() buttons.add(mapMenuItems.button("ADD", (720, 50), 100, (150, 150, 150), (200, 200, 200), None, "add", bsize=(150, 150), centretext=True)) buttons.add(mapMenuItems.button("Save & Exit", (10, 10), 30, (150, 150, 150), (200, 200, 200), None, "exit")) texts = py.sprite.Group() texts.add(mapMenuItems.textLabel("ID:", (5, 250), (0, 0, 0), None, 40)) boxes = py.sprite.Group() for i in range(0, 10): boxes.add(box(i)) barX = mapMenuItems.scrollBar(0, 620, 910, 2200, verticle=False) barY = mapMenuItems.scrollBar(910, 0, 620, 200, verticle=True) while True: v.screen.fill((250, 250, 250)) v.events = [] v.events = py.event.get() v.chunks.update() py.draw.rect(v.screen, (255, 255, 255), (0, 0, 920, 290)) for ch in v.chunks: if ch.hovered: ch.update() v.chatEdit.update() buttons.update() #texts.update() mapMenuItems.textLabel("ID:", (5 - v.npcScrollX, 250), (0, 0, 0), None, 40).update() boxes.update() py.draw.line(v.screen, (0, 0, 0), (0, 290), (920, 290), 2) for i in range(10): py.draw.line(v.screen, (0, 0, 0), ((300 * i) - 30 - v.npcScrollX, 290), ((300 * i) - 30 - v.npcScrollX, 630), 2) #py.draw.line(v.screen, (0, 0, 0), (570 - v.npcScrollX, 290), (570 - v.npcScrollX, 630), 2) py.draw.rect(v.screen, (255, 255, 255), (0, 600, 920, 30)) barX.update() barY.update() v.npcScrollX = barX.scroll v.npcScrollY = barY.scroll for event in v.events: if event.type == py.MOUSEBUTTONDOWN: for button in buttons: if button.pressed(): if button.ID == "add": if v.chatEdit.created == True: v.chatEdit.save() v.chunks.add(chatChunk(v.chatEdit.c_message, v.chatEdit.c_id, v.chatEdit.c_goto, v.chatEdit.c_charisma, v.chatEdit.c_buttons, v.chatEdit.c_changelike, v.chatEdit.c_end)) v.chatEdit = editChunk() if button.ID == "exit": out = [] for but in v.chunks: out.append(but.save()) print(out) return out py.display.flip()