|
4 | 4 | Basic system information screen
|
5 | 5 | """
|
6 | 6 |
|
7 |
| -import pygame |
| 7 | +import tkinter as tk |
| 8 | +from tkinter import ttk |
| 9 | + |
| 10 | +from header import Heading |
8 | 11 |
|
9 | 12 | from ..constants import BKG_COLOR, GameStateID
|
10 | 13 | from .renderer import Header, TextRender, TitleBar
|
11 | 14 | from .state import State
|
12 | 15 |
|
13 | 16 |
|
14 |
| -class SystemInfo(State): |
15 |
| - |
16 |
| - def __init__(self, game) -> None: |
17 |
| - self.game = game |
18 |
| - self.head_font: pygame.font.Font = game.font_sm_bold |
19 |
| - self.font: pygame.font.Font = game.font_sm |
20 |
| - super().__init__(game) |
21 |
| - |
22 |
| - self.header = Header(self.game.canvas, self.font) |
23 |
| - self.buttonB, self.buttonS, self.buttonY, self.buttonW = self.header.get_buttons() |
24 |
| - |
25 |
| - def handle_events(self, event: pygame.event) -> None: |
26 |
| - if event.type == pygame.QUIT: |
27 |
| - self.game.running = False |
28 |
| - if event.type == pygame.KEYDOWN: |
29 |
| - if event.key == pygame.K_ESCAPE: |
30 |
| - self.game.current_state = GameStateID.SPLASH |
31 |
| - if event.key == pygame.K_b: |
32 |
| - self.game.current_state = GameStateID.B_CARGO |
33 |
| - if event.key == pygame.K_s: |
34 |
| - self.game.current_state = GameStateID.S_CARGO |
35 |
| - if event.key == pygame.K_y: |
36 |
| - self.game.current_state = GameStateID.Y_SHIPYARD |
37 |
| - if event.key == pygame.K_e: |
38 |
| - self.game.current_state = GameStateID.BUY_EQUIPMENT |
39 |
| - if event.key == pygame.K_q: |
40 |
| - self.game.current_state = GameStateID.SELL_EQUIPMENT |
41 |
| - if event.key == pygame.K_p: |
42 |
| - self.game.current_state = GameStateID.PERSONNEL |
43 |
| - if event.key == pygame.K_k: |
44 |
| - self.game.current_state = GameStateID.BANK |
45 |
| - if event.key == pygame.K_i: |
46 |
| - self.game.current_state = GameStateID.SYSTEM_INFO |
47 |
| - if event.key == pygame.K_c: |
48 |
| - self.game.current_state = GameStateID.STATUS |
49 |
| - if event.key == pygame.K_g: |
50 |
| - self.game.current_state = GameStateID.GALACTIC_CHART |
51 |
| - if event.key == pygame.K_w: |
52 |
| - self.game.current_state = GameStateID.W_SHORTRANGE |
53 |
| - if event.key == pygame.K_o: |
54 |
| - NotImplemented |
55 |
| - if event.type == pygame.MOUSEBUTTONDOWN: |
56 |
| - if self.buttonB.is_clicked(event.pos): |
57 |
| - print("Clicked B") |
58 |
| - self.game.current_state = GameStateID.B_CARGO |
59 |
| - if self.buttonS.is_clicked(event.pos): |
60 |
| - print("Clicked S") |
61 |
| - self.game.current_state = GameStateID.S_CARGO |
62 |
| - if self.buttonY.is_clicked(event.pos): |
63 |
| - print("Clicked Y") |
64 |
| - self.game.current_state = GameStateID.Y_SHIPYARD |
65 |
| - if self.buttonW.is_clicked(event.pos): |
66 |
| - print("Clicked W") |
67 |
| - self.game.current_state = GameStateID.W_SHORTRANGE |
68 |
| - |
69 |
| - def update(self, actions) -> None: |
70 |
| - pass |
71 |
| - |
72 |
| - def render(self, canvas: pygame.Surface) -> pygame.Surface: |
73 |
| - canvas.fill(BKG_COLOR) |
74 |
| - |
75 |
| - # Draw the header |
76 |
| - # Header(canvas, self.font) |
77 |
| - self.header.render() |
78 |
| - TitleBar("System Info", self.head_font, canvas) |
79 |
| - |
80 |
| - # Category headers |
81 |
| - categories: list[TextRender] = [] |
82 |
| - categories.append(TextRender("Name:", (1, 18), self.head_font)) |
83 |
| - categories.append(TextRender("Size:", (1, 38), self.head_font)) |
84 |
| - categories.append(TextRender("Tech Level:", (1, 58), self.head_font)) |
85 |
| - categories.append(TextRender("Government:", (1, 78), self.head_font)) |
86 |
| - categories.append(TextRender("Resources:", (1, 98), self.head_font)) |
87 |
| - categories.append(TextRender("Police:", (1, 118), self.head_font)) |
88 |
| - categories.append(TextRender("Pirates:", (1, 138), self.head_font)) |
89 |
| - |
90 |
| - for category in categories: |
91 |
| - category.draw(canvas) |
92 |
| - |
93 |
| - return canvas |
| 17 | +class SystemInfo(ttk.frame): |
| 18 | + |
| 19 | + def __init__(self, parent) -> None: |
| 20 | + super().__init__(parent) |
| 21 | + self.pack(expand=True, fill="both") |
| 22 | + |
| 23 | + self.header = Heading(self, "System Info") |
| 24 | + |
| 25 | + self.info_frame = ttk.Frame(self) |
| 26 | + self.pressure_frame = ttk.Frame(self) |
| 27 | + self.shortcut_frame = ttk.Frame(self) |
| 28 | + |
| 29 | + |
| 30 | +# class SystemInfo(State): |
| 31 | + |
| 32 | +# def __init__(self, game) -> None: |
| 33 | +# self.game = game |
| 34 | +# self.head_font: pygame.font.Font = game.font_sm_bold |
| 35 | +# self.font: pygame.font.Font = game.font_sm |
| 36 | +# super().__init__(game) |
| 37 | + |
| 38 | +# self.header = Header(self.game.canvas, self.font) |
| 39 | +# self.buttonB, self.buttonS, self.buttonY, self.buttonW = self.header.get_buttons() |
| 40 | + |
| 41 | +# def handle_events(self, event: pygame.event) -> None: |
| 42 | +# if event.type == pygame.QUIT: |
| 43 | +# self.game.running = False |
| 44 | +# if event.type == pygame.KEYDOWN: |
| 45 | +# if event.key == pygame.K_ESCAPE: |
| 46 | +# self.game.current_state = GameStateID.SPLASH |
| 47 | +# if event.key == pygame.K_b: |
| 48 | +# self.game.current_state = GameStateID.B_CARGO |
| 49 | +# if event.key == pygame.K_s: |
| 50 | +# self.game.current_state = GameStateID.S_CARGO |
| 51 | +# if event.key == pygame.K_y: |
| 52 | +# self.game.current_state = GameStateID.Y_SHIPYARD |
| 53 | +# if event.key == pygame.K_e: |
| 54 | +# self.game.current_state = GameStateID.BUY_EQUIPMENT |
| 55 | +# if event.key == pygame.K_q: |
| 56 | +# self.game.current_state = GameStateID.SELL_EQUIPMENT |
| 57 | +# if event.key == pygame.K_p: |
| 58 | +# self.game.current_state = GameStateID.PERSONNEL |
| 59 | +# if event.key == pygame.K_k: |
| 60 | +# self.game.current_state = GameStateID.BANK |
| 61 | +# if event.key == pygame.K_i: |
| 62 | +# self.game.current_state = GameStateID.SYSTEM_INFO |
| 63 | +# if event.key == pygame.K_c: |
| 64 | +# self.game.current_state = GameStateID.STATUS |
| 65 | +# if event.key == pygame.K_g: |
| 66 | +# self.game.current_state = GameStateID.GALACTIC_CHART |
| 67 | +# if event.key == pygame.K_w: |
| 68 | +# self.game.current_state = GameStateID.W_SHORTRANGE |
| 69 | +# if event.key == pygame.K_o: |
| 70 | +# NotImplemented |
| 71 | +# if event.type == pygame.MOUSEBUTTONDOWN: |
| 72 | +# if self.buttonB.is_clicked(event.pos): |
| 73 | +# print("Clicked B") |
| 74 | +# self.game.current_state = GameStateID.B_CARGO |
| 75 | +# if self.buttonS.is_clicked(event.pos): |
| 76 | +# print("Clicked S") |
| 77 | +# self.game.current_state = GameStateID.S_CARGO |
| 78 | +# if self.buttonY.is_clicked(event.pos): |
| 79 | +# print("Clicked Y") |
| 80 | +# self.game.current_state = GameStateID.Y_SHIPYARD |
| 81 | +# if self.buttonW.is_clicked(event.pos): |
| 82 | +# print("Clicked W") |
| 83 | +# self.game.current_state = GameStateID.W_SHORTRANGE |
| 84 | + |
| 85 | +# def update(self, actions) -> None: |
| 86 | +# pass |
| 87 | + |
| 88 | +# def render(self, canvas: pygame.Surface) -> pygame.Surface: |
| 89 | +# canvas.fill(BKG_COLOR) |
| 90 | + |
| 91 | +# # Draw the header |
| 92 | +# # Header(canvas, self.font) |
| 93 | +# self.header.render() |
| 94 | +# TitleBar("System Info", self.head_font, canvas) |
| 95 | + |
| 96 | +# # Category headers |
| 97 | +# categories: list[TextRender] = [] |
| 98 | +# categories.append(TextRender("Name:", (1, 18), self.head_font)) |
| 99 | +# categories.append(TextRender("Size:", (1, 38), self.head_font)) |
| 100 | +# categories.append(TextRender("Tech Level:", (1, 58), self.head_font)) |
| 101 | +# categories.append(TextRender("Government:", (1, 78), self.head_font)) |
| 102 | +# categories.append(TextRender("Resources:", (1, 98), self.head_font)) |
| 103 | +# categories.append(TextRender("Police:", (1, 118), self.head_font)) |
| 104 | +# categories.append(TextRender("Pirates:", (1, 138), self.head_font)) |
| 105 | + |
| 106 | +# for category in categories: |
| 107 | +# category.draw(canvas) |
| 108 | + |
| 109 | +# return canvas |
0 commit comments