def load_game_menu(): if [1 for o in assets.cur_script.obs if isinstance(o,choose_game)]: return root = choose_game() root.pri = -1000 root.z = 5000 root.width,root.height = [assets.sw,assets.sh] list = gui.scrollpane([0,0]) list.width,list.height = [assets.sw,assets.sh] root.add_child(list) title = gui.editbox(None,"Choose save to load") title.draw_back = False list.add_child(title) list.add_child(ws_button(root,"cancel",pos=[200,0])) cb = list.children[-1] def cancel(*args): print "canceling" root.delete() setattr(root,"cancel",cancel) cb.bgcolor = [0, 0, 0] cb.textcolor = [255,255,255] cb.highlightcolor = [50,75,50] assets.cur_script.obs.append(root) saves = [] for p in os.listdir(assets.game+"/"): if not p.endswith(".ns"): continue fp = assets.game+"/"+p if os.path.exists(fp): saves.append((fp,os.path.getmtime(fp))) if os.path.isdir(assets.game+"/save_backup"): for f in os.listdir(assets.game+"/save_backup"): p = f fp = assets.game+"/save_backup/"+p saves.append((fp,float(fp.rsplit("_",1)[1]))) saves.sort(key=lambda a: -a[1]) i = len(saves) for s in saves: lt = time.localtime(s[1]) fn = s[0].rsplit("/",1)[1].split(".",1)[0] t = str(i)+") "+fn+" %s/%s/%s %s:%s"%(lt.tm_mon,lt.tm_mday,lt.tm_year,lt.tm_hour,lt.tm_min) i -= 1 item = ws_button(root,t) list.add_child(item) filename=s[0].replace(assets.game,"")[1:] fullpath=s[0] def do_load(filename=filename,fullpath=fullpath): root.delete() print "loading",filename,fullpath assets.clear() assets.show_load() assets.load_game_from_string(open(fullpath).read()) setattr(root,t.replace(" ","_"),do_load)
def __init__(self,*args,**kwargs): gui.widget.__init__(self,*args,**kwargs) self.rpos[1] = other_screen(0) self.width,self.height = [1000,1000] self.z = 1000 self.pri = -1000 self.list = gui.scrollpane([0,10]) self.list.width,self.list.height = [assets.sw,assets.sh-10] self.add_child(self.list) self.jump_when_close = None self.sort = "played"
def display(self): assets = self.assets sw,sh = self.sw,self.sh settings_menu.firstpane = "display" self.base() res_box = gui.scrollpane([10,20]) res_box.width = 200 res_box.height = 120 self.res_box = res_box self.children.append(res_box) res_box.add_child(gui.button(self,"Change resolution (%sx%s)"%(assets.swidth,assets.sheight))) res = res_box.pane.children[-1] res.checked = True res.click_down_over = self.popup_resolution res_box.add_child(gui.checkbox("smoothscale")) self.smoothscale = res_box.pane.children[-1] res_box.add_child(gui.checkbox("fullscreen")) self.fs = res_box.pane.children[-1] res_box.add_child(gui.checkbox("dualscreen")) ds = self.ds = res_box.pane.children[-1] res_box.add_child(gui.checkbox("virtual dualscreen")) self.vds = res_box.pane.children[-1] self.vds.visible = 0 res_box.add_child(gui.checkbox("show fps")) self.show_fps = res_box.pane.children[-1] s_c = self.show_fps.set_checked def set_checked(val): s_c(val) assets.show_fps = val wini(assets) self.show_fps.set_checked = set_checked #self.reses = gui.radiobutton.groups["resopt"] if assets.fullscreen: self.fs.checked = True if assets.num_screens==2: self.ds.checked = True if not assets.screen_compress: self.vds.checked = True if assets.show_fps: self.show_fps.checked = True if assets.smoothscale: self.smoothscale.checked = True self.children.append(gui.button(self,"apply",[10,140]))
def display(self): assets = self.assets sw,sh = self.sw,self.sh settings_menu.firstpane = "display" self.base() res_box = gui.scrollpane([10,20]) res_box.width = 200 res_box.height = 120 self.res_box = res_box self.children.append(res_box) res_box.add_child(gui.button(self,"Change resolution (%sx%s)"%(assets.swidth,assets.sheight))) res = res_box.pane.children[-1] res.checked = True res.click_down_over = self.popup_resolution res_box.add_child(gui.button(self,"dualscreen mode(%s)"%(assets.screen_mode))) res = res_box.pane.children[-1] self.screens = [] res.checked = True res.click_down_over = self.popup_screenmode res_box.add_child(gui.checkbox("smoothscale")) self.smoothscale = res_box.pane.children[-1] res_box.add_child(gui.checkbox("fullscreen")) self.fs = res_box.pane.children[-1] res_box.add_child(gui.checkbox("show fps")) self.show_fps = res_box.pane.children[-1] s_c1 = self.show_fps.set_checked def set_checked(val): s_c1(val) assets.show_fps = val wini(assets) self.show_fps.set_checked = set_checked self.frameskip = gui.checkbox("frameskip") res_box.add_child(self.frameskip) s_c = self.frameskip.set_checked def set_checked1(val): s_c(val) if val: assets.screen_refresh = 3 else: assets.screen_refresh = 1 wini(assets) self.frameskip.set_checked = set_checked1 #self.reses = gui.radiobutton.groups["resopt"] if assets.fullscreen: self.fs.checked = True if assets.show_fps: self.show_fps.checked = True if assets.smoothscale: self.smoothscale.checked = True if assets.screen_refresh>1: self.frameskip.checked = True self.children.append(gui.button(self,"apply",[10,140]))
def display(self): assets = self.assets sw, sh = self.sw, self.sh settings_menu.firstpane = "display" self.base() res_box = gui.scrollpane([10, 20]) res_box.width = 200 res_box.height = 120 self.res_box = res_box self.children.append(res_box) res_box.add_child( gui.button( self, "Change resolution (%sx%s)" % (assets.swidth, assets.sheight))) res = res_box.pane.children[-1] res.checked = True res.click_down_over = self.popup_resolution res_box.add_child( gui.button(self, "dualscreen mode(%s)" % (assets.screen_mode))) res = res_box.pane.children[-1] self.screens = [] res.checked = True res.click_down_over = self.popup_screenmode res_box.add_child(gui.checkbox("smoothscale")) self.smoothscale = res_box.pane.children[-1] res_box.add_child(gui.checkbox("fullscreen")) self.fs = res_box.pane.children[-1] res_box.add_child(gui.checkbox("show fps")) self.show_fps = res_box.pane.children[-1] s_c1 = self.show_fps.set_checked def set_checked(val): s_c1(val) assets.show_fps = val wini(assets) self.show_fps.set_checked = set_checked self.frameskip = gui.checkbox("frameskip") res_box.add_child(self.frameskip) s_c = self.frameskip.set_checked def set_checked1(val): s_c(val) if val: assets.screen_refresh = 3 else: assets.screen_refresh = 1 wini(assets) self.frameskip.set_checked = set_checked1 #self.reses = gui.radiobutton.groups["resopt"] if assets.fullscreen: self.fs.checked = True if assets.show_fps: self.show_fps.checked = True if assets.smoothscale: self.smoothscale.checked = True if assets.screen_refresh > 1: self.frameskip.checked = True self.children.append(gui.button(self, "apply", [10, 140]))