98 lines
3.6 KiB
Python
98 lines
3.6 KiB
Python
from os import path
|
|
from tkinter import CENTER, END, E, LEFT, NSEW, Image, IntVar, N, S, PhotoImage, Toplevel, W, messagebox, ttk
|
|
|
|
import requests
|
|
import sv_ttk
|
|
from classes.custom.image_label import ImageLabel
|
|
from classes.custom.themed_frame import ThemedFrame
|
|
|
|
from classes.custom.themed_toplevel import ThemedToplevel
|
|
from modules.logger import logger
|
|
from modules.theme_titlebar import theme_title_bar
|
|
from modules.utils import configGet, configSet, resize_window, set_icon, use_dark_mode
|
|
|
|
|
|
class ToplevelWelcome(ThemedToplevel):
|
|
|
|
def __init__(self, parent):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.protocol("WM_DELETE_WINDOW", self.__exit)
|
|
|
|
resize_window(self, 380, 350)
|
|
|
|
self.title("Welcome to Stardew Sync")
|
|
|
|
self.resizable(False, False)
|
|
|
|
sv_ttk.init_theme(self)
|
|
|
|
if use_dark_mode():
|
|
theme_title_bar(self, mode="dark")
|
|
self.update()
|
|
|
|
set_icon(self)
|
|
|
|
self.focus_set()
|
|
|
|
self.grid_columnconfigure(0, weight=1)
|
|
|
|
self.window_frame = ThemedFrame(self)
|
|
self.window_frame.grid(column=0, row=0, sticky=NSEW)
|
|
|
|
self.window_frame["borderwidth"] = 1
|
|
self.window_frame["relief"] = "solid"
|
|
|
|
self.window_frame.grid_columnconfigure(0, weight=1)
|
|
|
|
self.welcome_pic = ImageLabel(self.window_frame)
|
|
self.welcome_pic.grid(column=0, row=0, pady=20)
|
|
self.welcome_pic.load(path.join("assets", "welcome.gif"))
|
|
|
|
self.welcome_text = ttk.Label(self.window_frame, text="Welcome to Stardew Sync", font=("SunValleyBodyFont", 14))
|
|
self.welcome_text.grid(column=0, row=1, pady=10)
|
|
|
|
self.welcome_subtext = ttk.Label(self.window_frame, text="This small open-source application will help you\nto synchronize your Stardew Valley save files\nbetween all your devices", justify=CENTER)
|
|
self.welcome_subtext.grid(column=0, row=2)
|
|
|
|
self.welcome_button = ttk.Button(self.window_frame, text="Begin", style="Accent.TButton", width=10, command=self.stage_address)
|
|
self.welcome_button.grid(column=0, row=3, pady=20)
|
|
|
|
def stage_address(self):
|
|
|
|
for widget in self.window_frame.winfo_children():
|
|
widget.destroy()
|
|
|
|
self.window_frame.grid_rowconfigure(0, weight=2)
|
|
self.window_frame.grid_rowconfigure(1, weight=2)
|
|
#self.window_frame.grid_rowconfigure(2, weight=3)
|
|
|
|
self.stage_label = ttk.Label(self.window_frame, text="Connection", font=("SunValleyBodyFont", 14))
|
|
self.stage_label.grid(column=0, row=0, pady=40)
|
|
|
|
self.stage_label_1 = ttk.Label(self.window_frame, text="Server address", justify=LEFT)
|
|
self.stage_label_1.grid(column=0, row=1, pady=5, padx=35, sticky=W)
|
|
|
|
self.stage_entry_1 = ttk.Entry(self.window_frame)
|
|
self.stage_entry_1.grid(column=0, row=2, pady=5, padx=35, sticky=W+E)
|
|
|
|
self.stage_label_1 = ttk.Label(self.window_frame, text="Personal API key", justify=LEFT)
|
|
self.stage_label_1.grid(column=0, row=3, pady=5, padx=35, sticky=W)
|
|
|
|
self.stage_entry_1 = ttk.Entry(self.window_frame)
|
|
self.stage_entry_1.grid(column=0, row=4, pady=5, padx=35, sticky=W+E)
|
|
|
|
self.stage_button = ttk.Button(self.window_frame, text="Continue", style="Accent.TButton", width=10)
|
|
self.stage_button.grid(column=0, row=5, pady=40)
|
|
|
|
def acknowledged(self):
|
|
configSet(["first_run"], False)
|
|
self.destroy()
|
|
|
|
def __exit(self):
|
|
|
|
decision = messagebox.askyesno(title="Exit confirmation", message="Are you sure? If you exit now, your app will remain unconfigured.")
|
|
|
|
if decision is True:
|
|
self.quit() |