Containers now work. Discovered issue with loading saved games.
This commit is contained in:
parent
eeab517213
commit
2719075a33
3 changed files with 94 additions and 11 deletions
32
gamegui.py
32
gamegui.py
|
@ -25,10 +25,11 @@ class App(ttk.Frame):
|
|||
self.invTuple = tuple(self.gameBase.playerInv.keys())
|
||||
self.invNames = StringVar(value=self.invTuple)
|
||||
#self.project = Project()
|
||||
self.tool = StringVar()
|
||||
self.brush = StringVar()
|
||||
self.history = []
|
||||
self.redos = []
|
||||
#self.tool = StringVar()
|
||||
#self.brush = StringVar()
|
||||
#self.history = []
|
||||
#self.redos = []
|
||||
self.useOnCont = None # useOn continued
|
||||
#self.selectedArea = (0, 0, self.project.x-1, self.project.y-1)
|
||||
self.parent.clipboard_clear()
|
||||
self.parent.clipboard_append('')
|
||||
|
@ -144,7 +145,7 @@ class App(ttk.Frame):
|
|||
#print('Making the display work...')
|
||||
# level display
|
||||
self.context = Menu(self.levelDisplay)
|
||||
self.context.add_command(label = 'Load Map', command = lambda: self.loadLevel('maps/apartment.xml'))
|
||||
self.context.add_command(label = 'Load Map', command = lambda: self.loadLevel('maps/apartment.yml'))
|
||||
self.context.add_command(label = 'Go', command = lambda: self.go(self.selected[0], self.selected[1]))
|
||||
self.context.add_command(label = 'Run', command = lambda: self.go(self.selected[0], self.selected[1], True))
|
||||
self.context.add_command(label = 'Look', command = lambda: self.look(self.selected[0], self.selected[1]))
|
||||
|
@ -164,6 +165,7 @@ class App(ttk.Frame):
|
|||
self.invContext = Menu(self.invDisplay)
|
||||
self.invContext.add_command(label = 'Look', command = lambda: self.look(self.invTuple[self.invDisplay.curselection()[0]]))
|
||||
self.invContext.add_command(label = 'Use', command = lambda: self.use(self.invTuple[self.invDisplay.curselection()[0]]))
|
||||
self.invContext.add_command(label = 'Use on...', command = lambda: self.useOn(self.invTuple[self.invDisplay.curselection()[0]]))
|
||||
self.invContext.add_command(label = 'Drop', command = lambda: self.drop(self.invTuple[self.invDisplay.curselection()[0]]))
|
||||
self.invDisplay.bind('<<ListboxSelect>>', lambda e: self.look(self.invTuple[self.invDisplay.curselection()[0]]))
|
||||
self.invDisplay.bind('<3>', lambda e: self.invContext.post(e.x_root, e.y_root))
|
||||
|
@ -211,9 +213,12 @@ class App(ttk.Frame):
|
|||
def handleClick(self, event):
|
||||
x = int(self.levelDisplay.canvasx(event.x) / 32)
|
||||
y = int(self.levelDisplay.canvasy(event.y) / 32)
|
||||
if (x, y) != self.selected:
|
||||
self.selected = (x, y)
|
||||
self.look(x, y)
|
||||
if self.useOnCont == None:
|
||||
if (x, y) != self.selected:
|
||||
self.selected = (x, y)
|
||||
self.look(x, y)
|
||||
else:
|
||||
self.useOn(x, y)
|
||||
|
||||
def handleDoubleClick(self, event):
|
||||
x = int(self.levelDisplay.canvasx(event.x) / 32)
|
||||
|
@ -303,6 +308,17 @@ class App(ttk.Frame):
|
|||
self.gameBase.gameEventLoop()
|
||||
self.refreshDisplay() #inefficient, but will work for now.
|
||||
|
||||
def useOn(self, x, y = 1):
|
||||
if isinstance(x, int):
|
||||
self.gameBase.use([self.useOnCont, 'on', str(x), str(y)])
|
||||
self.useOnCont = None
|
||||
self.gameBase.gameEventLoop()
|
||||
self.refreshDisplay()
|
||||
else: # x is a string
|
||||
self.useOnCont = x
|
||||
print("Click on something to use {0} on.".format(x), file = self.gameBase.outstream)
|
||||
self.refreshDisplay()
|
||||
|
||||
def take(self, x, y):
|
||||
self.gameBase.take([str(x), str(y)])
|
||||
self.gameBase.gameEventLoop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue