mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Improved style of new game menu
This commit is contained in:
parent
2047089b64
commit
14cd54668e
@ -65,6 +65,7 @@ try:
|
||||
else:
|
||||
proceed_to_main_menu(game)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
ui.corruptedsavemenu.CorruptedSaveMenu(w).display()
|
||||
|
||||
w.run()
|
||||
|
||||
BIN
resources/ui/terrain_caucasus.png
Normal file
BIN
resources/ui/terrain_caucasus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
resources/ui/terrain_nevada.png
Normal file
BIN
resources/ui/terrain_nevada.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
resources/ui/terrain_pg.png
Normal file
BIN
resources/ui/terrain_pg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@ -1,5 +1,6 @@
|
||||
from tkinter import *
|
||||
from tkinter.ttk import *
|
||||
from .styles import STYLES
|
||||
|
||||
from ui.window import *
|
||||
|
||||
@ -12,6 +13,6 @@ class CorruptedSaveMenu(Menu):
|
||||
def display(self):
|
||||
self.window.clear_right_pane()
|
||||
|
||||
Label(text="Your save game was corrupted!").grid(row=0, column=0)
|
||||
Label(text="Please restore it by replacing \"liberation_save\" file with \"liberation_save_tmp\" to restore last saved copy.").grid(row=1, column=0)
|
||||
Label(text="You can find those files under user DCS directory.").grid(row=2, column=0)
|
||||
Label(text="Your save game was corrupted!", **STYLES["widget"]).grid(row=0, column=0)
|
||||
Label(text="Please restore it by replacing \"liberation_save\" file with \"liberation_save_tmp\" to restore last saved copy.", **STYLES["widget"]).grid(row=1, column=0)
|
||||
Label(text="You can find those files under user DCS directory.", **STYLES["widget"]).grid(row=2, column=0)
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import os
|
||||
from tkinter import *
|
||||
from tkinter.ttk import *
|
||||
|
||||
from ui.window import *
|
||||
from .styles import STYLES
|
||||
|
||||
|
||||
class NewGameMenu(Menu):
|
||||
@ -14,6 +16,7 @@ class NewGameMenu(Menu):
|
||||
def __init__(self, window: Window, callback: typing.Callable):
|
||||
super(NewGameMenu, self).__init__(window, None, None)
|
||||
self.frame = window.right_pane
|
||||
window.left_pane.configure(background="black")
|
||||
self.callback = callback
|
||||
|
||||
self.selected_country = IntVar()
|
||||
@ -57,23 +60,69 @@ class NewGameMenu(Menu):
|
||||
def display(self):
|
||||
self.window.clear_right_pane()
|
||||
|
||||
Label(self.frame, text="Player country").grid(row=0, column=0)
|
||||
Radiobutton(self.frame, text="USA", variable=self.selected_country, value=0).grid(row=1, column=0)
|
||||
Radiobutton(self.frame, text="Russia", variable=self.selected_country, value=1).grid(row=2, column=0)
|
||||
# Header
|
||||
head = Frame(self.frame, **STYLES["header"])
|
||||
head.grid(row=0, column=0, sticky=NSEW)
|
||||
Label(head, text="Start a new game", **STYLES["title"]).grid()
|
||||
|
||||
Label(self.frame, text="Terrain").grid(row=0, column=1)
|
||||
Radiobutton(self.frame, text="Caucasus", variable=self.selected_terrain, value=0).grid(row=1, column=1)
|
||||
Radiobutton(self.frame, text="Nevada", variable=self.selected_terrain, value=1).grid(row=2, column=1)
|
||||
Radiobutton(self.frame, text="Persian Gulf", variable=self.selected_terrain, value=2).grid(row=3, column=1)
|
||||
# Main Frame
|
||||
body = Frame(self.frame, **STYLES["body"])
|
||||
body.grid(row=1, column=0, sticky=NSEW)
|
||||
|
||||
Label(self.frame, text="Options").grid(row=1, column=2)
|
||||
Checkbutton(self.frame, text="SAMs", variable=self.sams).grid(row=1, column=2)
|
||||
Checkbutton(self.frame, text="Mid game", variable=self.midgame).grid(row=2, column=2)
|
||||
# Country Selection
|
||||
country = LabelFrame(body, text="Player Side", **STYLES["label-frame"])
|
||||
country.grid(row=0, column=0, sticky=NW, padx=5)
|
||||
Radiobutton(country, variable=self.selected_country, value=0, **STYLES["radiobutton"]).grid(row=0, column=0,
|
||||
sticky=W)
|
||||
Label(country, text="USA", **STYLES["widget"]).grid(row=0, column=1, sticky=W)
|
||||
Radiobutton(country, variable=self.selected_country, value=1, **STYLES["radiobutton"]).grid(row=1, column=0,
|
||||
sticky=W)
|
||||
Label(country, text="Russia", **STYLES["widget"]).grid(row=1, column=1, sticky=W)
|
||||
|
||||
Label(self.frame, text="Multiplier").grid(row=0, column=3)
|
||||
Entry(self.frame, textvariable=self.multiplier).grid(row=1, column=3)
|
||||
# Terrain Selection
|
||||
terrain = LabelFrame(body, text="Terrain", **STYLES["label-frame"])
|
||||
terrain.grid(row=0, column=1, sticky=N, padx=5)
|
||||
|
||||
Button(self.frame, text="Proceed", command=self.proceed).grid(row=5, column=0, columnspan=4)
|
||||
Radiobutton(terrain, variable=self.selected_terrain, value=0, **STYLES["radiobutton"]) \
|
||||
.grid(row=0, column=0, sticky=W)
|
||||
Label(terrain, text="Caucasus", **STYLES["widget"]).grid(row=0, column=1, sticky=W)
|
||||
self.create_label_image(terrain, "terrain_caucasus.png").grid(row=0, column=2, padx=5)
|
||||
|
||||
Radiobutton(terrain, variable=self.selected_terrain, value=1, **STYLES["radiobutton"]) \
|
||||
.grid(row=1, column=0, sticky=W)
|
||||
Label(terrain, text="Nevada", **STYLES["widget"]).grid(row=1, column=1, sticky=W)
|
||||
self.create_label_image(terrain, "terrain_nevada.png").grid(row=1, column=2, padx=5)
|
||||
|
||||
Radiobutton(terrain, variable=self.selected_terrain, value=2, **STYLES["radiobutton"]) \
|
||||
.grid(row=2, column=0, sticky=W)
|
||||
Label(terrain, text="Persian Gulf", **STYLES["widget"]).grid(row=2, column=1, sticky=W)
|
||||
self.create_label_image(terrain, "terrain_pg.png").grid(row=2, column=2, padx=5)
|
||||
|
||||
# Misc Options
|
||||
options = LabelFrame(body, text="Misc Options", **STYLES["label-frame"])
|
||||
options.grid(row=0, column=2, sticky=NE, padx=5)
|
||||
|
||||
Checkbutton(options, variable=self.sams, **STYLES["radiobutton"]).grid(row=0, column=0, sticky=W)
|
||||
Label(options, text="SAMs", **STYLES["widget"]).grid(row=0, column=1, sticky=W)
|
||||
|
||||
Checkbutton(options, variable=self.midgame, **STYLES["radiobutton"]).grid(row=1, column=0, sticky=W)
|
||||
Label(options, text="Mid Game", **STYLES["widget"]).grid(row=1, column=1, sticky=W)
|
||||
|
||||
Label(options, text="Multiplier", **STYLES["widget"]).grid(row=2, column=0, sticky=W)
|
||||
Entry(options, textvariable=self.multiplier).grid(row=2, column=1, sticky=W)
|
||||
|
||||
# Footer with Proceed Button
|
||||
footer = Frame(self.frame, **STYLES["header"])
|
||||
footer.grid(row=2, sticky=N + E + W)
|
||||
Button(footer, text="Proceed", command=self.proceed, **STYLES["btn-primary"]).grid(row=0, column=0, sticky=SE,
|
||||
padx=5, pady=5)
|
||||
|
||||
@staticmethod
|
||||
def create_label_image(parent, image):
|
||||
im = PhotoImage(file=os.path.join("resources", "ui", image))
|
||||
label = Label(parent, image=im)
|
||||
label.image = im
|
||||
return label
|
||||
|
||||
def proceed(self):
|
||||
self.callback(self.player_country_name,
|
||||
|
||||
31
ui/styles.py
Normal file
31
ui/styles.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Style for UI
|
||||
|
||||
# Padding
|
||||
PADDING_X = 5
|
||||
PADDING_Y = 5
|
||||
|
||||
# Colors
|
||||
FG_COLOR = "white"
|
||||
BG_COLOR = "#4E5760"
|
||||
BTN_COLOR = "#699245"
|
||||
BG_TITLE_COLOR = "#2D3E50"
|
||||
|
||||
# Fonts
|
||||
FONT_FAMILY = "Trebuchet MS"
|
||||
DEFAULT_FONT = (FONT_FAMILY, 8)
|
||||
BOLD_FONT = (FONT_FAMILY, 10, "bold italic")
|
||||
TITLE_FONT = (FONT_FAMILY, 16, "bold italic")
|
||||
|
||||
# List of styles
|
||||
STYLES = {}
|
||||
STYLES["label-frame"] = {"font": BOLD_FONT, "bg": BG_COLOR, "fg": FG_COLOR}
|
||||
|
||||
STYLES["body"] = {"bg": BG_COLOR, "padx": 35, "pady": 35}
|
||||
|
||||
STYLES["widget"] = {"bg": BG_COLOR, "fg": FG_COLOR, "padx": PADDING_X, "pady": PADDING_Y, "font": DEFAULT_FONT}
|
||||
STYLES["radiobutton"] = {"bg": BG_COLOR, "fg": "black", "padx": PADDING_X, "pady": PADDING_Y, "font": DEFAULT_FONT,
|
||||
"activebackground": BG_COLOR, "highlightbackground": BG_COLOR, "selectcolor": "white"}
|
||||
STYLES["title"] = {"bg": BG_TITLE_COLOR, "fg": FG_COLOR, "padx": PADDING_X, "pady": PADDING_Y, "font": TITLE_FONT}
|
||||
STYLES["header"] = {"bg": BG_TITLE_COLOR}
|
||||
|
||||
STYLES["btn-primary"] = {"bg": BTN_COLOR, "fg": FG_COLOR, "padx": PADDING_X, "pady": PADDING_Y, "font": DEFAULT_FONT}
|
||||
@ -1,6 +1,6 @@
|
||||
from tkinter import *
|
||||
from game.game import *
|
||||
|
||||
from .styles import BG_COLOR
|
||||
|
||||
class Window:
|
||||
image = None
|
||||
@ -11,13 +11,14 @@ class Window:
|
||||
self.tk = Tk()
|
||||
self.tk.title("DCS Liberation")
|
||||
self.tk.iconbitmap("icon.ico")
|
||||
self.tk.resizable(True, True)
|
||||
self.tk.grid_columnconfigure(0, weight=1)
|
||||
self.tk.grid_rowconfigure(0, weight=1)
|
||||
|
||||
self.frame = Frame(self.tk)
|
||||
self.frame = Frame(self.tk, bg=BG_COLOR)
|
||||
self.frame.grid(column=0, row=0, sticky=NSEW)
|
||||
self.frame.grid_columnconfigure(0, minsize=300)
|
||||
self.frame.grid_columnconfigure(1, minsize=400)
|
||||
self.frame.grid_columnconfigure(0)
|
||||
self.frame.grid_columnconfigure(1)
|
||||
|
||||
self.frame.grid_columnconfigure(0, weight=0)
|
||||
self.frame.grid_columnconfigure(1, weight=1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user