class MapEditorWidget(FloatLayout): def __init__(self, **kwargs): super(MapEditorWidget, self).__init__(**kwargs) # open up worlddb.sqlite, for now self.dbr = DatabaseReader( os.path.join(os.path.dirname(__file__), 'worlddb.sqlite')) pu = CBLPopup(self.menu_callback, title='Tales of Isan: Level Editor', buttons=['New Map', 'Load Map', 'Close'], size_hint=(.4, .4)) pu.open() def menu_callback(self, instance): print instance.text if instance.text == 'New Map': self.create_map('000') elif instance.text == 'Load Map': self.load_map() def create_map(self, maplabel): self.rows = 6 self.cols = 9 # this should be somewhere else self.dbr.add_tileset([ Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/', 'Grass', None, 1), Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/', 'Sand', None, 1), Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/', 'Water', None, 4), Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/', 'Dirt', None, 1) ]) # for debugging, ignore if map already exists self.dbr.add_map(maplabel, rows=self.rows, cols=self.cols) # get all tiles used in the database tileset = self.dbr.tile_dict # now make a screen filled with the second item in the tileset first_tile_id = tileset.keys()[1] tiles = [[first_tile_id] for i in xrange(int(self.rows)) for j in xrange(int(self.cols))] screenid = self.dbr.add_screen(tiles, None, maplabel, None, None) # screen_editor = ScreenEditor(self.dbr,maplabel,screenid) # self.add_widget(screen_editor) def load_map(self, maplabel): pass
def __init__(self, **kwargs): super(MapEditorWidget, self).__init__(**kwargs) # open up worlddb.sqlite, for now self.dbr = DatabaseReader( os.path.join(os.path.dirname(__file__), 'worlddb.sqlite')) pu = CBLPopup(self.menu_callback, title='Tales of Isan: Level Editor', buttons=['New Map', 'Load Map', 'Close'], size_hint=(.4, .4)) pu.open()
def __init__(self,**kwargs): super(MapEditorWidget,self).__init__(**kwargs) # open up worlddb.sqlite, for now self.dbr = DatabaseReader(os.path.join(os.path.dirname(__file__),'worlddb.sqlite')) pu = CBLPopup(self.menu_callback,title='Tales of Isan: Level Editor', buttons=['New Map','Load Map','Close'], size_hint=(.4,.4)) pu.open()
class MapEditorWidget(FloatLayout): def __init__(self,**kwargs): super(MapEditorWidget,self).__init__(**kwargs) # open up worlddb.sqlite, for now self.dbr = DatabaseReader(os.path.join(os.path.dirname(__file__),'worlddb.sqlite')) pu = CBLPopup(self.menu_callback,title='Tales of Isan: Level Editor', buttons=['New Map','Load Map','Close'], size_hint=(.4,.4)) pu.open() def menu_callback(self,instance): print instance.text if instance.text == 'New Map': self.create_map('000') elif instance.text == 'Load Map': self.load_map() def create_map(self,maplabel): self.rows = 6 self.cols = 9 # this should be somewhere else self.dbr.add_tileset([Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/','Grass',None,1), Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/','Sand',None,1), Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/','Water',None,4), Subtile('atlas://ArtAssets/TileSets/Tileset-SeaGrass_Forest_128/','Dirt',None,1)]) # for debugging, ignore if map already exists self.dbr.add_map(maplabel,rows=self.rows,cols=self.cols) # get all tiles used in the database tileset = self.dbr.tile_dict # now make a screen filled with the second item in the tileset first_tile_id = tileset.keys()[1] tiles = [[first_tile_id] for i in xrange(int(self.rows)) for j in xrange(int(self.cols))] screenid = self.dbr.add_screen(tiles,None,maplabel,None,None) # screen_editor = ScreenEditor(self.dbr,maplabel,screenid) # self.add_widget(screen_editor) def load_map(self,maplabel): pass
import kivy from kivy.uix.boxlayout import BoxLayout from kivy.uix.recycleview import RecycleView from DatabaseReader import DatabaseReader kivy.require('1.0.6') # replace with your current kivy version ! from kivy.app import App db = DatabaseReader() class ListBox(RecycleView): def __init__(self, **kwargs): super(ListBox, self).__init__(**kwargs) self.data = [{'text': str(x.name)} for x in db.get_vendor_names()] class BaseWidget(BoxLayout): pass class SalesApp(App): def build(self): return BaseWidget() if __name__ == '__main__': print([{'text': str(x)} for x in db.get_vendor_names()])