def check_update_main(): try: update_result = nlib.get_json_from_url( "https://raw.githubusercontent.com/SiniKraft/" "NoMoskito/master/update.json") except Exception as e: nlib.log( "Failed to check for updates ! %s" % repr(e).split("(")[0] + ": " + str(e), "error", "settings_window") messagebox.showerror( "Cannot check for updates !", "Failed to check for updates !\n%s" % repr(e).split("(")[0] + ": " + str(e)) return def download(): webbrowser.open(update_result["version"]["latest"]["download"]) if update_result["version"]["latest"]["number"] > version_number: txt_to_config = default_lang[5].format( version_name, update_result["version"]["latest"]["name"]) btn_update2 = ttk.Button(settings_window, text=default_lang[6], command=download) btn_update2.place(x=320, y=165) else: txt_to_config = default_lang[9].format(version_name) update_txt.config(text=txt_to_config)
def get_better_score(): try: if nlib.load("save.dat")[-1] != version_name: tk = tkinter.Tk() tk.withdraw() if tkinter.messagebox.askyesno( "Update save data", "Your game is running version %s\n" "However, it seems your save data is from %s\n" "Do you want to try converting your save data ?\n" "A backup will be made, but\n" "Previous versions may not be able to load your save\n" "Proceed ?" % (version_name, str(nlib.load("save.dat")[-1]))): copyfile("save.dat", "backup_%s" % (str(nlib.load("save.dat")[-1]))) update_save_data() else: quit() return nlib.load('save.dat') except Exception as e: nlib.log("Failed to read save data : %s" % str(e), "error", "file_manager") return [ 0, "nobody", 0, 0, [] ] # Best score, best player name, b coins, 0: Basic Swatter, 1: Swatter Pro 2:
def destroy(self): if not self.isDestroyed: self.isDestroyed = True global_var.moskitos_killed = global_var.moskitos_killed + 1 global_var.renew_sound = True if global_var.enable_sound: try: self.play_obj.stop() except: nlib.log("Couldn't stop a moskito sound !", "warn")
def exception_handler(type, value, traceback): nlib.log("{0}: {1}".format(repr(value).split("(")[0], value), "critical", 'main') from tkinter import Tk, messagebox root = Tk() root.withdraw() messagebox.showerror("An error occurred", "{}: {}".format(repr(value).split("(")[0], value)) root.destroy() sys.exit()
import os import tkinter.messagebox import nathlib as nlib import sys import time version_name = "snapshot_014" # DO NOT FORGET TO CHANGE FILEMANAGER CONSTANTS !!! version_number = 1 debug_mouse = False try: os.remove('latest.log') except Exception as e: nlib.log("Couldn't remove latest.log : {}".format(str(e)), "warn") nlib.start_logs("latest.log") nlib.log("Launching game version {0} ...".format(version_name), "info") def exception_handler(type, value, traceback): nlib.log("{0}: {1}".format(repr(value).split("(")[0], value), "critical", 'main') from tkinter import Tk, messagebox root = Tk() root.withdraw() messagebox.showerror("An error occurred", "{}: {}".format(repr(value).split("(")[0], value)) root.destroy() sys.exit()
import os.path import tkinter import tkinter.messagebox from shutil import copyfile from importlib import import_module import pickle from os.path import isfile import nathlib as nlib version_name = "snapshot_014" # DO NOT FORGET TO CHANGE MAIN CONSTANTS !!! version_number = 1 nlib.start_logs("latest.log") nlib.log("Starting file manager ...", "info", "file_manager") lang_files_to_load = ['en_US', 'fr_FR'] lang_files_names = {"Français": "fr_FR", "English": "en_US"} lang_list = ['English', 'Français'] lang_number = len(lang_files_to_load) # Count the number of files entries # settings loader def new_settings(): with open('settings.ini', 'wb') as settings_file: setting_list = ["English", False, False, False, 0] # 0 is swatter, 1 pro, 2 ruler pickle.dump(setting_list, settings_file)