def view( self ): map_width = max( self.explo.scene.width * 4, 240 ) self.pic = image.Image( frame_width = map_width, frame_height = self.explo.scene.height * 4 + pygwrap.BIGFONT.get_height() ) self.quill = image.Image( "sys_quill.png", 21, 18 ) mmbits = image.Image( "sys_mapbits.png", 4, 4 ) for x in range( self.explo.scene.width ): for y in range( self.explo.scene.height ): if self.explo.scene.map[x][y].visible: t = 0 if self.explo.scene.map[x][y].wall: t = 2 if self.explo.scene.map[x][y].blocks_walking(): t += 1 mmbits.render( self.pic.bitmap, (x*4,y*4), t ) pygwrap.draw_text( self.pic.bitmap, pygwrap.BIGFONT, str(self.explo.scene), pygame.Rect(0,self.explo.scene.height*4+1, map_width, pygwrap.BIGFONT.get_height()), color=(71,35,0), justify=0, antialias=False ) self.dest = self.pic.bitmap.get_rect( center=(self.explo.screen.get_width()//2-100, self.explo.screen.get_height()//2 ) ) self.menu = rpgmenu.Menu(self.explo.screen,self.explo.screen.get_width()//2+215, self.explo.screen.get_height()//2-200, 150, 400, predraw=self.draw ) pcpos = self.explo.camp.first_living_pc().pos self.menu.add_item( "Party", pcpos ) for t in self.explo.scene.contents: if hasattr( t, "mini_map_label" ) and self.explo.scene.get_visible( *t.pos ): self.menu.add_item( t.mini_map_label, t.pos ) self.menu.sort() self.menu.set_item_by_value( pcpos ) if hasattr( self.explo.scene, "world_map_pos" ): self.menu.add_item( "[World Map]", 0 ) pos = self.menu.query() if pos: self.explo.view.focus( self.explo.screen, *pos ) elif pos is 0: WorldExplorer( self.explo )
def choose_characters( screen ): rpm = rpgmenu.Menu( screen,screen_center_x-100,screen_center_y + 25,200,200,predraw=None ) rpm.add_item( "Load Characters", True ) rpm.add_item( "Random Party", False ) if rpm.query(): return charloader.load_characters( list(), screen ) else: return campaign.random_party()
def Delete_saved_games(screen): rpm = rpgmenu.Menu( screen,screen.get_width()//2-250,screen.get_height()//2-50,500,100,predraw=PosterRedraw(screen) ) rpm.add_files(util.user_dir("rpg_*.sav")) rpm.sort() rpm.add_alpha_keys() rpm.add_item("Cancel Delete Saved Games", None) cmd = rpm.query() if cmd: os.remove(cmd)
def choose_characters(screen): rpm = rpgmenu.Menu(screen, screen.get_width() // 2 - 100, screen.get_height() // 2 + 25, 200, 200, predraw=None) rpm.add_item("Load Characters", True) rpm.add_item("Random Party", False) if rpm.query(): return charloader.load_characters(list(), screen) else: return campaign.Random_party()
def converse( self, pc, npc, cue ): # The party is going to converse with someone. # During the conversation, the Exploration object will have an attribute # called "convo" which is a tuple containing the pc, npc, and conversation. crd = dialogue.ConvoRedraw( npc, screen = self.screen, predraw = self.view ) offers = list() mygram = dialogue.grammar.base_grammar( pc, npc, self ) for p in self.camp.active_plots(): offers += p.get_dialogue_offers( npc, self ) pgram = p.get_dialogue_grammar( npc, self ) if pgram: dialogue.grammar.absorb( mygram, pgram ) # Add special offers- Job Training. That's it for now. if npc.mr_level and npc.mr_level.__class__ in characters.PC_CLASSES: add_ok = False for chara in self.camp.party: if chara.xp >= chara.xp_for_next_level() and npc.mr_level.can_take_level( chara ): add_ok = True if add_ok: offers.append( dialogue.Offer( "[TRAINING]", context = context.ContextTag([context.TRAINING]), effect=services.JobTraining([npc.mr_level.__class__]) ) ) conversation = dialogue.build_conversation( cue , offers ) coff = conversation self.convo = (pc,npc,conversation) pc_voice = pc.get_voice() npc_voice = npc.get_voice() while coff: crd.friendliness = npc.get_friendliness(self.camp) crd.text = dialogue.personalize_text( coff.msg , npc_voice, mygram ) mymenu = rpgmenu.Menu( self.screen, crd.menu_rect.x, crd.menu_rect.y, crd.menu_rect.width, crd.menu_rect.height, border=None, predraw=crd ) for i in coff.replies: mymenu.add_item( dialogue.personalize_text( i.msg, pc_voice, mygram ), i.destination ) if crd.text and not mymenu.items: mymenu.add_item( "[Continue]", None ) else: mymenu.sort() nextfx = coff.effect coff = mymenu.query() if nextfx: nextfx( self ) del self.convo
def load_campaign( screen ): rpm = rpgmenu.Menu( screen,screen.get_width()//2-250,screen.get_height()//2-50,500,100,predraw=PosterRedraw(screen) ) rpm.add_files( util.user_dir("rpg_*.sav") ) rpm.sort() rpm.add_alpha_keys() rpm.add_item( "Cancel Load Campaign", None ) cmd = rpm.query() if cmd: pygwrap.please_stand_by( screen, "Loading..." ) f = open( cmd, "rb" ) camp = cPickle.load( f ) f.close() if camp: camp.play( screen )
def load_settings(screen): rpm = rpgmenu.Menu(screen, screen.get_width() // 2 - 250, screen.get_height() // 2 - 50, 500, 100, predraw=PosterRedraw(screen)) rpm.sort() rpm.add_alpha_keys() rpm.add_item("Fullscreen (on/off)", toggle_fullscreen_default) rpm.add_item("Back", None) cmd = rpm.query() if cmd: cmd(screen, rpm)
def view( self ): self.pic = image.Image( frame_width = 480, frame_height = 480 ) self.quill = image.Image( "sys_quill.png", 21, 18 ) mmbits = image.Image( "sys_worldmapbits.png", 32, 32 ) self.dest = self.pic.bitmap.get_rect( center=(self.explo.screen.get_width()//2-100, self.explo.screen.get_height()//2 ) ) self.menu = rpgmenu.Menu(self.explo.screen,self.explo.screen.get_width()//2+215, self.explo.screen.get_height()//2-200, 150, 400, predraw=self.draw ) for t in self.w.contents: if hasattr( t, "world_map_pos" ) and t.world_map_pos.visible: self.menu.add_item( t.world_map_pos.name, t ) mmbits.render( self.pic.bitmap, (t.world_map_pos.coords[0]*32,t.world_map_pos.coords[1]*32), t.world_map_pos.icon ) self.menu.sort() self.menu.set_item_by_value( self.explo.scene ) dest = self.menu.query() if dest and dest is not self.explo.scene: self.explo.camp.destination = dest self.explo.camp.entrance = dest.world_map_pos.entrance
def main(): pygame.init() pygame.display.set_caption("Dungeon Monkey Eternal", "DMEternal") pygame.display.set_icon(pygame.image.load(util.image_dir("sys_icon.png"))) # Set the screen size. if util.config.getboolean("DEFAULT", "fullscreen"): screen = pygame.display.set_mode((800, 600)) screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) else: screen = pygame.display.set_mode((800, 600)) rpgmenu.init() screen_center_x = screen.get_width() // 2 screen_center_y = screen.get_height() // 2 rpm = rpgmenu.Menu(screen, screen_center_x - 100, screen_center_y + 25, 200, 200, predraw=TitleScreenRedraw(screen)) rpm.add_item("Create Character", chargen.make_and_save_character) rpm.add_item("Load Campaign", load_campaign) rpm.add_item("Start Endless Campaign", endless_start_campaign) #rpm.add_item( "Start Bardic Campaign", bardic_start_campaign ) #rpm.add_item( "Start Gen1 Campaign", default_start_campaign ) rpm.add_item("Browse Characters", campaign.browse_pcs) rpm.add_item("Settings", load_settings) #rpm.add_item( "Test Campaign Generator", test_campaign_generator ) rpm.add_item("Quit Game", None) cmd = True while cmd: cmd = rpm.query() if cmd: cmd(screen) if pygwrap.GOT_QUIT: break
if __name__=='__main__': pygame.init() pygame.display.set_caption("Dungeon Monkey Eternal","DMEternal") pygame.display.set_icon(pygame.image.load(util.image_dir("sys_icon.png"))) # Set the screen size. if util.config.getboolean( "DEFAULT", "fullscreen" ): screen = pygame.display.set_mode( (0,0), pygame.FULLSCREEN ) else: screen = pygame.display.set_mode( (800,600) ) pygwrap.init() rpgmenu.init() screen_center_x = screen.get_width() // 2 screen_center_y = screen.get_height() // 2 rpm = rpgmenu.Menu( screen,screen_center_x-100,screen_center_y + 25,200,200,predraw=TitleScreenRedraw(screen) ) rpm.add_item( "Create Character", chargen.make_and_save_character ) rpm.add_item( "Load Campaign", load_campaign ) rpm.add_item("Delete Saved Games", Delete_saved_games) rpm.add_item( "Start Endless Campaign", endless_start_campaign ) #rpm.add_item( "Start Bardic Campaign", bardic_start_campaign ) #rpm.add_item( "Start Gen1 Campaign", default_start_campaign ) rpm.add_item( "Browse Characters", campaign.browse_pcs ) #rpm.add_item( "Test Campaign Generator", test_campaign_generator ) rpm.add_item( "Quit Game", None ) cmd = True while cmd: cmd = rpm.query() if cmd: