Repository navigation
191 mod tool 13 the side pick screen
Question: The netplay test game (document 188) starts every match from a side-pick screen: each player a row, each side a column, teams from players sharing a column, computer players the host adds, each side's colour, the rules and the host settings. The engine can already play up to four sides (document 189) and the score and time rules (document 190), but only from settings made in code. What does the engine need so a person sets a match up on a screen, plays it, sees the results and comes back for a rematch, and so a game's maker can reword the screen in the mod tool (issue #148, which absorbs #14; tracking #143)?
The mod tool series: S7 builds the mod tool into a toolset that makes a whole game by hand (document 179 is the audit, document 180 the plan, documents 181 to 187 are stages S7.1 to S7.7). Document 188 is the design of S7.8's game. This document is the third and last of S7.8's engine pieces, after up to four sides (document 189) and the score and time limits (document 190).
Everything here is a port feature: the original sets a two-player match up on its Register player window and level select (documents 134-141), which Return Fire keeps.
| Term | Meaning |
|---|---|
| row | One player on the screen: a person (player 1 or 2 on this machine) or a computer player. |
| column | One side of the chosen map, headed by the side's name and colour. "Not playing" is the middle column. |
| match setup |
MatchSetup: everything the screen sets (the map, the rows and their columns, each side's colour, the rules, the host settings). The match reads it; GameFlow keeps it for the rematch. |
| host settings | The settings of document 189: a capture knocks a side out, friendly fire, a side shares one stock. Online, the host sets them (Phase 5). |
| neutral home | A map's home no row picked: no flag, its turrets sleep (document 189). |
-
A new screen type,
side_pick, inui/menus.json, drawn bySidePickScreenin the pack's skin. The engine's default menus gain a Match screen of this type and a "Match" button on the main menu. Return Fire's pack replaces the main menu, so its flow is unchanged. -
Rows and columns. Player 1 and player 2 are rows from the start, in the middle (not playing).
<and>move a row one column; the columns run: the first half of the map's sides, not playing, the second half. Rows in one column are a team. -
Computer rows. Add computer adds a row with a skill level (the pack's
ai/profiles.jsonlevels); Remove takes it away. Up to 8 rows, 2 of them people (split screen). -
Colours (absorbs #14): each column picks its side's colour from
teams/colours.json. A colour another side has swaps the two, so no two sides are alike. The map'sside_coloursare the default.RF_TEAM_COLOURSstays a test override. - The map, the rules and the host settings are under the rows. Choosing a map takes its rules (document 190) and colours as the defaults.
- Start is on once a person plays and two sides are picked; the status line says what is missing. A home nobody picked is neutral; nothing fills it.
-
The match gets everything from the setup (
MatchSetup.apply): the players in order (people first, so they get the views and player 1's and 2's controls), their sides, the computer players and their skill, the rules and the settings. - Results, then back. The end banner lists each side's points (with the winner, or "DRAW"). Enter returns to the side-pick screen with the picks kept: a rematch is one press of Start. A match from this screen keeps no progression or Hall of Fame records.
-
The mod tool offers the
side_picktype on the Front end tab's Screens form, with its title, Back screen, and every word of the screen as a line ("Words"), shown live in the preview.
The engine draws it plainly (here with four homes, player 1 on side 1, a computer on side 3):
Match
Map [ Four Corners v ]
Side 1 Side 2 Not playing Side 3 Side 4
[tan v] [green v] [red v] [blue v]
Player 1 < [Player 1] >
Player 2 < [Player 2] >
Computer < [Computer] > [Normal v] [Remove]
[Add computer]
Rules
[x] Win by bringing a flag home
Score limit (0 = off) [ 7 ]
Time limit, minutes (0 = off) [ 0 ]
[ ] A capture knocks a side out (3-4 sides)
[ ] Friendly fire
[ ] A side shares one stock of vehicles
Ready.
[Back] [Start]
The knockout setting shows only on a map with three or four sides, where it can matter.
A screen in ui/menus.json:
"match": {"type": "side_pick", "title": "Match", "back": "main", "labels": {"start": "Fight", "side": "Team {n}"}}labels replaces the engine's words key by key; {n} is a side's or player's number, {name} a row's name (in the marker that shows where a row is):
# addons/openfire_engine/game/side_pick_screen.gd
const DEFAULT_LABELS := {
"map": "Map", "person": "Player {n}", "computer": "Computer", "not_playing": "Not playing", "side": "Side {n}",
"add_computer": "Add computer", "remove": "Remove", "left": "<", "right": ">", "marker": "[ {name} ]",
"rules": "Rules", "flag": "Win by bringing a flag home", "score_limit": "Score limit (0 = off)", "time_limit": "Time limit, minutes (0 = off)",
"knockout": "A capture knocks a side out (3-4 sides)", "friendly_fire": "Friendly fire", "shared_stock": "A side shares one stock of vehicles",
"back": "Back", "start": "Start",
"no_map": "Choose a map.", "no_person": "Move a player into a column.", "one_side": "Pick at least two sides.", "ready": "Ready.",
}The maps offered are the pack's levels with two or more homes.
The columns' order puts "not playing" in the middle, so a row reaches the left-hand sides with < and the right-hand ones with >:
# addons/openfire_engine/game/match_setup.gd
func move_row(i: int, dir: int, sides: Array[int]) -> void:
if i < 0 or i >= rows.size():
return
var order: Array = sides.slice(0, (sides.size() + 1) / 2)
order.append(-1)
order.append_array(sides.slice((sides.size() + 1) / 2))
var at := order.find(int(rows[i]["side"]))
if at < 0:
at = order.find(-1)
rows[i]["side"] = order[clampi(at + dir, 0, order.size() - 1)]With two sides that is: side 1, not playing, side 2. With four: sides 1 and 2, not playing, sides 3 and 4.
func set_colour(side: int, colour: String) -> void:
while colours.size() <= side:
colours.append(LevelData.default_side_colour(colours.size()))
var old := String(colours[side])
for s in colours.size():
if s != side and String(colours[s]) == colour:
colours[s] = old
colours[side] = colourTerrainView3D lays the picks over the level's side_colours (apply_colours) before the team art is made, so every side's sprites are generated at map load, as before.
MatchSetup holds the picks. Its rows are plain dictionaries, so Phase 5 can add remote rows (#43) and send the setup over the network as it is:
var level_id := ""
## [{"kind": "person" | "computer", "side": int (-1 = not playing), "skill": AIProfile id ("" = the pack's default; a computer row's)}]
var rows: Array = [{"kind": "person", "side": -1, "skill": ""}, {"kind": "person", "side": -1, "skill": ""}]
var colours: Array = [] ## each side's colour id (Pack.team_colours), side by side; [] = the map's own
var rule_flag := true
var score_limit := 0
var time_limit_minutes := 0
var flag_capture_knocks_out := false
var friendly_fire := false
var side_shares_stock := falseBefore the match's setup, apply hands it over. People come first, so the people's slots are players 1 and 2, with their views and controls; a computer player's slot gets its skill. No side is filled by the computer on its own (computer_fills_sides false), and the level's own rules give way (rules_from_level false):
func apply(mc: MatchController) -> void:
var playing := playing_rows()
mc.players = playing.size()
mc.side_of_player.clear()
mc.ai_players.clear()
mc.ai_skill_of.clear()
for i in playing.size():
mc.side_of_player.append(int(playing[i]["side"]))
if playing[i]["kind"] == "computer":
mc.ai_players.append(i)
if String(playing[i].get("skill", "")) != "":
mc.ai_skill_of[i] = String(playing[i]["skill"])
mc.computer_fills_sides = false
mc.rules_from_level = false
mc.rule_flag = rule_flag
mc.score_limit = maxi(score_limit, 0)
mc.time_limit_ticks = maxi(time_limit_minutes, 0) * MatchController.TICKS_PER_MINUTE
mc.flag_capture_knocks_out = flag_capture_knocks_out
mc.friendly_fire = friendly_fire
mc.side_shares_stock = side_shares_stockEverything else (teammates sharing a pad, neutral homes, the knockout, the scoring) is the match's own, from documents 189 and 190.
Start's condition:
func problem() -> String:
if level_id == "":
return "no_map"
if people_playing() == 0:
return "no_person"
if sides_picked().size() < 2:
return "one_side"
return ""Mermaid source
flowchart TB
M[Main menu] -- Match --> S[Side-pick screen]
S -- Back --> M
S -- Start --> L[The match, with the picks]
L -- a rule ends it --> R[Results: the end banner, each side's points]
R -- Enter --> S
GameFlow shows the screen for a side_pick screen id, keeps its MatchSetup, and starts the level with it:
# addons/openfire_engine/game/game_flow.gd
func _show_side_pick_screen(id: String, screen: Dictionary) -> void:
_last_select = id
...
s.setup(pack, screen, _match_setup)
_match_setup = s.setup_data
s.start_pressed.connect(func(setup: MatchSetup):
_match_setup = setup
_from_setup = true
start_level(setup.level_id))The side-pick screen is the "@last" screen, where a level returns to, as a level select is. After the match:
view.continue_pressed.connect(func():
if _from_setup: # results seen (the banner's points): back to the side-pick screen for a rematch
_clear_level()
show_screen("@last")
elif ...A match from this screen records no progression and no Hall of Fame entry: those tables are about a game's own levels and two named players (document 133).
The engine has no separate results screen; the end banner is it. It lists each side's points whenever a score or time rule is on, or the match came from the side-pick screen:
# addons/openfire_engine/game/placeholder_hud.gd
static func results_shown(controller: MatchController) -> bool:
return controller.scoring_shown() or not controller.side_of_player.is_empty()The banner reads, for example, "Green 7 Red 0 / GREEN WINS / press Enter to play again". A game with its own HUD reads the same values (document 190).
The Front end tab's Screens form (document 187) offers the side_pick type. For it the form shows the title, the Back screen and Words: a line per DEFAULT_LABELS key, empty for the engine's word. A word typed is written to the screen's labels; the preview beside the form shows the screen at once, and its controls work (Start puts up the preview's note instead of starting the match).
-
tests/side_pick_check.gd(engine), on the synthetic fixture with a mod adding a four-home map with a score limit:- a row starts in the middle,
<and>move it through the columns and stop at the ends; a colour another side has swaps; - the screen offers the maps with two or more homes; four homes give the columns side 1, side 2, not playing, side 3, side 4; the map's rules become the match's; a pack's word replaces the engine's;
- Start is off until a person plays and two sides are picked, and says why; Add computer and Remove; Start hands the setup over;
- free-for-all on four homes: the person first, then the computers on their sides, each with its skill; the home nobody picked is neutral; the rules and settings come from the screen;
- 2 v 2: teammates share a column, and with the setting a side shares one stock; only the picked sides play;
- colours: the match draws each side in its column's colour;
- through GameFlow: the default menus have the Match screen; Start plays the map with the picks and its rules; the score limit ends it; the end banner lists the points; Enter goes back to the side-pick screen with the picks kept and Start ready.
- a row starts in the middle,
-
tests/front_end_editing_check.gd(engine): the Match screen shows asside_pickwith its words; a word typed is written tolabelsand shows in the preview. - The whole engine suite and the openfire suite pass.
- Remote rows, ready states and the handshake are Phase 5 (#43), on this same screen. A computer row is already the host's: its peer will run it and send its words (document 188).
- A second controller joining by pressing a button. Player 2's row is always there; moving it into a column is joining. Which keys or pad each person uses is the Controls screen's (documents 138-139).
- A results screen of its own (more than the banner) and a fancier look are the game's to make, through its pack.
- The broader custom game screen (#42) stays its own issue.
| What | Where |
|---|---|
| The picks and how the match reads them | addons/openfire_engine/game/match_setup.gd |
| The screen | addons/openfire_engine/game/side_pick_screen.gd |
| The screen type, the default Match screen | game/menu_def.gd |
| Showing it, starting the match, the rematch |
game/game_flow.gd _show_side_pick_screen, _enter_level
|
| The match and its colours |
game/terrain_view_3d.gd match_setup, _spawn_match
|
| The results banner |
game/placeholder_hud.gd results_shown
|
| The mod tool |
addons/openfire_engine/editor/front_end_panel.gd (SCREEN_TYPES, the Words lines) |
| Checks |
addons/openfire_engine/tests/side_pick_check.gd, tests/front_end_editing_check.gd
|
Return Fire, rebuilt
Elsewhere