number of minor bugfixes and UI improvements

This commit is contained in:
Vasyl Horbachenko
2018-10-12 21:32:43 +03:00
parent 07b35f8ee1
commit f21bd10f09
13 changed files with 66 additions and 32 deletions

View File

@@ -96,15 +96,15 @@ class EventMenu(Menu):
header("Support:")
# Options
awacs_enabled = self.game.budget >= AWACS_BUDGET_COST and NORMAL or DISABLED
Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=2, sticky=E)
Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=0, sticky=W, pady=5)
Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=4, sticky=E)
row += 1
Label(self.frame, text="Combined Arms Slots", **STYLES["widget"]).grid(row=row, sticky=W)
self.ca_slot_entry = Entry(self.frame, width=2)
self.ca_slot_entry.insert(0, "0")
self.ca_slot_entry.grid(column=1, row=row, sticky=W, padx=5)
Button(self.frame, text="+", command=self.add_ca_slot, **STYLES["btn-primary"]).grid(column=2, row=row, padx=5, sticky=W)
self.ca_slot_entry.grid(column=3, row=row, sticky=E, padx=5)
Button(self.frame, text="+", command=self.add_ca_slot, **STYLES["btn-primary"]).grid(column=4, row=row, padx=5, sticky=W)
row += 1
header("Ready?")

View File

@@ -118,7 +118,7 @@ class EventResultsMenu(Menu):
def simulate_result(self, player_factor: float, enemy_factor: float):
def action():
debriefing = Debriefing({}, [])
debriefing = Debriefing({})
def count(country: Country) -> typing.Dict[UnitType, int]:
result = {}

View File

@@ -50,20 +50,21 @@ class MainMenu(Menu):
nonlocal row, body
frame = LabelFrame(body, **STYLES["label-frame"])
frame.grid(row=row, sticky=NSEW)
Message(frame, text="{}{}".format(
event.defender_name == self.game.player and "Enemy attacking: " or "",
Message(frame, text="{}".format(
event
), aspect=1600, **STYLES["widget"]).grid(column=0, row=0, sticky=NSEW)
Button(body, text=">", command=self.start_event(event), **STYLES["btn-primary"]).grid(column=1, row=row, sticky=E)
row += 1
def departure_header(text):
def departure_header(text, style="strong"):
nonlocal row, body
Label(body, text=text, **STYLES["strong"]).grid(column=0, columnspan=2, row=row, sticky=N+EW, pady=(0, 5)); row += 1
Label(body, text=text, **STYLES[style]).grid(column=0, columnspan=2, row=row, sticky=N+EW, pady=(0, 5))
row += 1
def destination_header(text, pady=0):
def destination_header(text):
nonlocal row, body
Label(body, text=text, **STYLES["substrong"]).grid(column=0, columnspan=2, row=row, sticky=N+EW, pady=(pady,0)); row += 1
Label(body, text=text, **STYLES["substrong"]).grid(column=0, columnspan=2, row=row, sticky=N+EW)
row += 1
events = self.game.events
events.sort(key=lambda x: x.to_cp.name)
@@ -74,22 +75,25 @@ class MainMenu(Menu):
departure = None
for event in events:
new_departure = event.from_cp.name if not event.informational else "Deliveries"
if event.informational:
new_departure = "Deliveries"
elif not self.game.is_player_attack(event):
new_departure = "Enemy attack"
else:
new_departure = event.from_cp.name
if new_departure != departure:
body = LabelFrame(self.frame, **STYLES["body"])
body.grid(column=column, row=1, sticky=NSEW)
body.grid(column=column, row=1, sticky=N+EW)
row = 0
column += 1
departure = new_departure
departure_header(new_departure)
departure_header(new_departure, style="strong" if self.game.is_player_attack(event) else "supstrong")
destination = None
if not event.informational:
if self.game.is_player_attack(event):
new_destination = "At {}".format(event.to_cp.name)
else:
new_destination = "Enemy attack"
new_destination = "At {}".format(event.to_cp.name)
if destination != new_destination:
destination_header(new_destination)
destination = new_destination

View File

@@ -29,6 +29,7 @@ STYLES["frame-wrapper"] = {"bg": BG_COLOR, "relief":"sunken"}
STYLES["body"] = {"bg": BG_COLOR, "padx": 10, "pady": 10}
STYLES["strong"] = {"font": BOLD_FONT, "bg": BG_TITLE_COLOR, "fg": FG_COLOR}
STYLES["substrong"] = {"font": BOLD_FONT, "bg": BG_SUBTITLE_COLOR, "fg": FG_COLOR}
STYLES["supstrong"] = {"font": BOLD_FONT, "bg": RED, "fg": FG_COLOR}
STYLES["strong-grey"] = {"font": BOLD_FONT, "bg": BG_TITLE_COLOR, "fg": FG_COLOR_LIGHT}
STYLES["mission-preview"] = {"font": BOLD_FONT, "bg": YELLOW, "fg": FG_COLOR}