def __init__(self, WORLD_SIZE): # size in chunks along one axis. self.WORLD_SIZE = WORLD_SIZE self.WORLDMAP = defaultdict(dict) # dict of dicts for chunks self.chunk_size = 13 # size of the chunk, leave it hardcoded here. (0-12) self.FurnitureManager = FurnitureManager() self.ItemManager = ItemManager() start = time.time() #TODO: only need to load the chunks where there are actual players present in memory after generation. print('creating/loading world chunks') count = 0 for i in range(self.WORLD_SIZE): for j in range(self.WORLD_SIZE): for k in range( 0, 1): #just load z0 for now. load the rest as needed. self.WORLDMAP[i][j] = dict() path = str('./worlds/default/' + str(i) + '_' + str(j) + '_' + str(k) + '.chunk') if (os.path.isfile(path) ): # if the chunk already exists on disk just load it. with open(path, 'rb') as fp: self.WORLDMAP[i][j][k] = pickle.load(fp) if (count < 80): print('L', end='') count = count + 1 else: print('L') count = 0 else: # fill each chunk with something interesting print('C', end='') self.WORLDMAP[i][j][k] = Chunk(i, j, k, self.chunk_size) with open(path, 'wb') as fp: pickle.dump(self.WORLDMAP[i][j][k], fp) end = time.time() duration = end - start print() print('---------------------------------------------') print('World generation took: ' + str(duration) + ' seconds.')
def __init__(self, first_name, last_name): MastermindClientTCP.__init__(self) pygame.init() pygame.display.set_caption('Cataclysm: Looming Darkness') self.screen = pygame.display.set_mode((854, 480), pygame.ANYFORMAT) self.TileManager = TileManager() self.ItemManager = ItemManager() self.RecipeManager = RecipeManager() # contains all the known recipes in the game. for reference. self.FontManager = FontManager() self.player = Player(str(first_name) + str(last_name)) # recieves updates from server. the player and all it's stats. #TODO: name and password. self.localmap = None self.hotbars = [] self.hotbars.insert(0, Hotbar(self.screen, 10, 10)) # insert buttons when we open a screen and destroy them when we leave it. self.buttons = [] #self.buttons.insert(0, Button(self.screen, 'BUTTON!', (120,120,120), (50,50,50,50))) #self.buttons.insert(0, Button(self.screen, 'BUTTON!', (120,120,120), (150,50,50,50))) #self.buttons.insert(0, Button(self.screen, 'BUTTON!', (120,120,120), (150,150,50,50))) #self.buttons.insert(0, Button(self.screen, 'BUTTON!', (120,120,120), (50,150,50,50))) self.textboxes = [] self.listboxes = []
''' Created on Mar 3, 2009 @author: thomas ''' import sys from PyQt4.QtGui import * sys.path.append("../code/") from item import ItemManager from gui.item import ItemList app = QApplication(sys.argv) widget = QWidget() widget.resize(250, 150) im = ItemManager() im.createItem(QFont("Helvetica"), QColor("red")) im.createItem(QFont("Helvetica"), QColor("blue")) listWidget = ItemList(widget, im) layout = QVBoxLayout() layout.addWidget(listWidget) widget.setLayout(layout) widget.show() sys.exit(app.exec_())
def __init__(self): pygame.init() pygame.display.set_caption( 'Cataclysm: Looming Darkness WYSIWYG Building Editor') self.screen = pygame.display.set_mode((720, 480), pygame.ANYFORMAT) self.TileManager = TileManager() self.ItemManager = ItemManager() self.RecipeManager = RecipeManager( ) # contains all the known recipes in the game. for reference. self.FurnitureManager = FurnitureManager() self.FontManager = FontManager() self.curFloor = 0 self.group = 'small residential' self.overmap_terrain = 'residential' self.comment = 'put a comment here' self.comment2 = 'put another comment here' self.comment3 = 'put one more comment here' self.fill_terrain = 't_floor' self.building_layout = defaultdict(dict) self.chunk_width = 1 self.chunk_size = 13 print( str(pygame.display.Info().current_w) + ', ' + str(pygame.display.Info().current_h)) self.textboxes = [] self.listboxes = [] self.buttons = [] # z-level UI components self.buttons.insert( 0, Button(self.screen, self.FontManager.convert_string_to_surface('+'), (120, 120, 120), (pygame.display.Info().current_w - 48, pygame.display.Info().current_h - 24, 24, 24), '+')) self.buttons.insert( 0, Button(self.screen, self.FontManager.convert_string_to_surface('-'), (120, 120, 120), (pygame.display.Info().current_w - 24, pygame.display.Info().current_h - 24, 24, 24), '-')) self.textboxes.insert( 0, TextBox( self.screen, (120, 120, 120), (pygame.display.Info().current_w - 72, pygame.display.Info().current_h - 24, 24, 24), self.FontManager.convert_string_to_surface(str( self.curFloor)))) # Listboxes for terrain, furniture, items. self.listboxes.insert( 0, ListBox(self.screen, (120, 120, 120), (pygame.display.Info().current_w - 360, 0, 120, 240))) for k, item in self.TileManager.TILE_TYPES.items(): #print(k.split('_')) if (k.split('_')[0] != 't'): #only load terrain here continue #print(k, item) self.listboxes[0].item_list.insert( len(self.listboxes[0].item_list), Listbox_item(k, self.FontManager.convert_string_to_surface(k), item)) self.listboxes[0].item_list.sort(key=lambda x: x.text) self.listboxes.insert( 1, ListBox(self.screen, (120, 120, 120), (pygame.display.Info().current_w - 240, 0, 120, 240))) for k, item in self.FurnitureManager.FURNITURE_TYPES.items(): if (k.split('_')[0] != 'f'): #only load terrain here continue self.listboxes[1].item_list.insert( len(self.listboxes[1].item_list), Listbox_item(k, self.FontManager.convert_string_to_surface(k), item)) self.listboxes[1].item_list.sort(key=lambda x: x.text) self.listboxes.insert( 2, ListBox(self.screen, (120, 120, 120), (pygame.display.Info().current_w - 120, 0, 120, 240))) for k, item in self.ItemManager.ITEM_TYPES.items(): print(k.split('_')) #print(k, item) self.listboxes[2].item_list.insert( len(self.listboxes[2].item_list), Listbox_item(k, self.FontManager.convert_string_to_surface(k), item)) self.listboxes[2].item_list.sort(key=lambda x: x.text) ## selected stuff. left click listboxes to set self.selected_terrain = None self.textboxes.insert( 1, TextBox(self.screen, (120, 120, 120), (pygame.display.Info().current_w - 360, 240, 120, 24), self.FontManager.convert_string_to_surface(None))) self.selected_furniture = None self.textboxes.insert( 2, TextBox(self.screen, (120, 120, 120), (pygame.display.Info().current_w - 240, 240, 120, 24), self.FontManager.convert_string_to_surface(None))) self.selected_item = None self.textboxes.insert( 3, TextBox(self.screen, (120, 120, 120), (pygame.display.Info().current_w - 120, 240, 120, 24), self.FontManager.convert_string_to_surface(None))) # export button. self.buttons.insert( 0, Button(self.screen, self.FontManager.convert_string_to_surface('Export'), (120, 120, 120), (pygame.display.Info().current_w - 256, pygame.display.Info().current_h - 24, 128, 24), 'Export')) self.buttons.insert( 0, Button(self.screen, self.FontManager.convert_string_to_surface('Import'), (120, 120, 120), (pygame.display.Info().current_w - 256, pygame.display.Info().current_h - 48, 128, 24), 'Import')) self.generate_z_level( 0) # generate the base z-level. ground floor is always 0
def __init__(self): #self.TileManager = TileManager() self.ItemManager = ItemManager() self.RecipeManager = RecipeManager() # contains all the known recipes in the game. for reference. self.FurnitureManager = FurnitureManager()
class BloatedClockApplet(plasmascript.Applet): def __init__(self,parent,args=None): plasmascript.Applet.__init__(self,parent) def init(self): self.setHasConfigurationInterface(True) self.setAspectRatioMode(Plasma.Square) self.theme = Plasma.Svg(self) self.theme.setImagePath("widgets/background") self.setBackgroundHints(Plasma.Applet.DefaultBackground) self.dialog = None self._items() self._engines = {} self.pluginLoader = PluginLoader(self) self.x = False self.initGui() def initGui(self): self.updateUi() self.resize(250,250) def updateUi(self): try: xml = self.xmlEdit.xml() except: xml = """<plugins><clock name="klok1" other="test" bla="koe" /></plugins> <body> <line><item1 parser="klok1" align="left">%hh:%mm:%ss</item1><item2 parser="klok1" align="left">after</item2></line> </body>""" lBuilder = LayoutBuilder(self.im, self.pluginLoader) self.layout = lBuilder.build(xml, self.applet) print self.layout print self.layout.count() self.setLayout(self.layout) def showConfigurationInterface(self): windowTitle = str(self.applet.name()) + " Settings" #i18nc("@title:window", "%s Settings" % str(self.applet.name())) if self.dialog is None: self.dialog = KPageDialog() self.dialog.setFaceType(KPageDialog.List) self.dialog.setButtons( KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel) ) self.dialog.setWindowTitle(windowTitle) self.connect(self.dialog, SIGNAL("applyClicked()"), self, SLOT("configAccepted()")) self.connect(self.dialog, SIGNAL("okClicked()"), self, SLOT("configAccepted()")) self.createConfigurationInterface(self.dialog) self.dialog.show() def createConfigurationInterface(self, parent): print "Layout" print self.layout print self.layout.count() pl = self.pluginLoader.getPluginByName("clock") print pl print pl.name print pl.isLoaded print pl.engine print pl.engine.name print pl.engine.isValid() self.itemList = ItemListWidget(parent, self.im) xml = """<clock> <line><item1 align="left">text %hh.%mm:%ss</item1><item2 align="right">2de text</item2></line> <line><item1 align="center">center</item1></line> <line><item2 align="right">right</item2></line> </clock>""" self.xmlEdit = XMLEditWidget(parent, xml) parent.addPage(self.itemList, i18n("List of items")) parent.addPage(self.xmlEdit, i18n("Edit the xml")) #self.ui = LoginMonitorConfig(self.dialog) #self.dialog.addPage(self.ui, i18n("Configure provider")) #self._fillProviders(self.ui.providerComboBox) #self.ui.providerComboBox.setCurrentItem(self.config().readEntry(PROVIDER)) #self.ui.usernameEdit.setText(self.config().readEntry(NAME)) #self.ui.updateIntervalSpinBox.setValue(self.config().readEntry(UPDATE_INTERVAL, QVariant(0)).toInt()[0]) def _items(self): self.im = ItemManager() self.im.createItem(QFont("Helvetica"), QColor("red")) self.im.createItem(QFont("Helvetica"), QColor("blue")) @pyqtSignature("configAccepted()") def configAccepted(self): cg = self.config() #self.items = self.itemList.items #TODO save items self.updateUi() #cg.writeEntry("provider", self.ui.providerComboBox.currentText()) #cg.writeEntry("name", self.ui.usernameEdit.text()) #cg.writeEntry("updateInterval", QVariant(self.ui.updateIntervalSpinBox.value())) self.emit(SIGNAL("configNeedsSaving()"))
def _items(self): self.im = ItemManager() self.im.createItem(QFont("Helvetica"), QColor("red")) self.im.createItem(QFont("Helvetica"), QColor("blue"))