1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
# Balazar Brothers
# Copyright (C) 2006-2007 Jean-Baptiste LAMY
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import soya, soya.editor
import balazar_brothers, balazar_brothers.init_editobj
from balazar_brothers.platform import Platform, PortailPlatform
from balazar_brothers.level import Level
import editobj, editobj.main, editobj.editor as editor, editobj.custom as custom
import Tkinter, dircache, os, os.path
class LevelEditor(Tkinter.Toplevel):
def __init__(self):
# Get, or create if needed, the root Tk.
try:
from Tkinter import _default_root
tkroot = _default_root
except ImportError: pass
if not tkroot:
tkroot = Tkinter.Tk(className = "Balazar Brothers Level Editor")
tkroot.withdraw()
tkroot.option_add("*bd", 1)
tkroot.option_add("*List.background", "#FFFFFF")
tkroot.option_add("*Text.background", "#FFFFFF")
tkroot.option_add("*Text.relief", "flat")
tkroot.option_add("*Entry.background", "#FFFFFF")
tkroot.option_add("*Entry.relief", "flat")
Tkinter.Toplevel.__init__(self, tkroot)
soya.MainLoop()
self.new_level_button = Tkinter.Button(self, text = _(u"New level..."), command = self.on_new_level)
self.new_level_button.pack(fill = Tkinter.BOTH, side = Tkinter.BOTTOM)
self.level_list = Tkinter.Listbox(self, background = "#FFFFFF", selectbackground = "#CCCCFF")
for i, filename in enumerate(Level.availables()):
self.level_list.insert(i, filename)
self.level_list.pack(expand = 1, fill = Tkinter.BOTH, side = Tkinter.LEFT)
self.level_list.bind("<ButtonRelease>", self.on_edit_level)
self.scroll_bar = Tkinter.Scrollbar(self)
self.scroll_bar.pack(side = Tkinter.RIGHT, fill = Tkinter.BOTH)
self.level_list['yscrollcommand'] = self.scroll_bar.set
self.scroll_bar['command'] = self.level_list.yview
def on_edit_level(self, event = None):
level_name = self.level_list.get(self.level_list.curselection()[0])
soya.editor.edit(Level.get(level_name))
def on_new_level(self, event = None):
level = Level()
level.filename = ""
level.random_terrain()
soya.editor.edit(level)
|