Commit Graph

83 Commits

Author SHA1 Message Date
GarandPLG 06a439ff88 Move ZoomLevel into skirmish_states
Introduce Structure and Unit traits with enum wrappers.
Replace old zoom helper with ZoomLevel methods.
Update imports, BoardState, CellWidget, and CLI to use new locations.
2026-04-20 12:17:56 +02:00
GarandPLG a04264c08b Remove selected check in CellWidget::get_color 2026-04-19 20:06:11 +02:00
GarandPLG 0a8b3562f6 Rename buildings module to structures 2026-04-19 20:02:21 +02:00
GarandPLG 33088dc29d Add Stone and Tunnel, refactor CellStructure
Introduce new building types Stone and Tunnel with their own tag, color,
and
properties. CellStructure now holds these structs (Tunnel, Stone)
instead of
simple variants. BaseBuilding is simplified to return a char tag and a
color
based on owner. BoardState creation and CellWidget rendering are updated
to
use the new building structs and their methods.
2026-04-19 20:00:59 +02:00
GarandPLG 54e86b2688 Move buildings and units under skirmish_states
Reorganize the codebase by moving the buildings and units modules
into the skirmish_states namespace, updating imports accordingly.
2026-04-19 18:02:36 +02:00
GarandPLG 6a43b28e67 Update package metadata and description
- Define `pname` once and inherit it in the package definition.
- Change description to “TUI underground RTS”.
- Set `mainProgram` to `pname` for consistency.
2026-04-17 16:21:40 +02:00
GarandPLG fccb9bf733 Add cargo run help invocation to flake.nix 2026-04-16 23:48:12 +02:00
GarandPLG 8e67166c58 Make helpers public and improve Nix packaging
Export `block_title` and `helpers` with `pub mod` for external use.
Add Nix improvements: version check hook, update script, install check.
Include post‑install step to copy soundtracks and rename binary.
Extend meta with platforms, mainProgram, and maintainer handling.
Update docs to show required imports for block title helpers.
2026-04-16 23:43:36 +02:00
GarandPLG f5ef4b4931 Privatize internal modules and adjust re‑exports 2026-04-16 22:22:32 +02:00
GarandPLG e6d87dd064 Refactor Units enum location and chain CellWidget setters
Move Units enum from the units module into the skirmish state module,
add a dedicated Players enum, and remove the now‑unused unit module.
Update all imports accordingly.
Adjust CellWidget's set_zoom_level and set_structure to return &mut
Self,
enabling method chaining.
2026-04-16 22:02:15 +02:00
GarandPLG 6dc5f8605c Replace CellTag with CellStructure and embed BaseBuilding
The refactor removes the `Buildings` enum and the `building` module,
replacing
`CellTag` with a new `CellStructure` enum that directly holds a
`BaseBuilding`.
A `get_owner` method is added to `BaseBuilding` to support the new
structure.
All related imports, constructors, and rendering logic are updated to
use
`CellStructure` instead of the old tag and building fields.
2026-04-16 21:56:06 +02:00
GarandPLG 268e6d98bf Update cell widget layout to show b_level
Replace static spacing with dynamic `b_level` values for ZoomedIn and
Default zoom levels, and remove redundant placeholder lines.
2026-04-16 20:29:02 +02:00
GarandPLG 0f60249309 Add BaseBuilding and MinerUnit with UI rendering 2026-04-16 10:59:02 +02:00
GarandPLG be41936f14 Refactor buildings/units, move CellTag & Players
Introduce BaseBuilding struct. Rename Building and Unit to enum types
(Buildings, Units). Move CellTag and Players enums to the skirmish state
module and update imports and re‑exports accordingly. Add placeholder
miner module.
2026-04-15 13:21:39 +02:00
GarandPLG 44d29bd3ad Add Building and Unit structs, extend CellWidget
Introduce empty Building and Unit types and expose them
through new modules. Extend CellWidget to store optional
Unit and Building, update its constructor, and adjust board
rendering to create cells with these new fields (currently always None).
2026-04-13 21:27:44 +02:00
GarandPLG 1393f282e8 Refactor cell marking, add undo, update keybindings
CellWidget::set_selected and set_marked now return &mut Self for method
chaining. Added BoardState::undo_marked_cell to remove the last marked
cell and restore focus. Backspace triggers undo, Delete clears marking.
2026-04-13 16:57:44 +02:00
GarandPLG d5f4d03264 Add toggle_marking and simplify marking logic
Introduce a public `BoardState::toggle_marking` that flips the
marking mode and starts or clears marking accordingly. Refactor
`set_marked_cell` to accept tuple coordinates and clean up its
logic. Update `change_focused_cell` to work with the new signature
and use the toggle helper. Adjust cell display to show coordinates
when a cell is marked.
2026-04-10 21:30:48 +02:00
GarandPLG 869ba0bb7f Add marking mode; rename resize and zoom methods
Introduce a marking mode that lets users toggle cells with Space and
clear
them with Backspace. BoardState now stores `marking_cells` and a list of
`marked_cells` and provides methods to start, clear, and update marks.
CellWidget tracks a `marked` flag and renders marked cells in
LightMagenta.

Keybindings are updated: Space now reads “Marking cells”, Backspace
reads
“Cancel marking”, and the original Enter binding is commented out.

The former `resize_change` and `zoom_change` functions are renamed to
`change_resize` and `change_zoom`; all call sites are updated
accordingly.
2026-04-10 19:06:47 +02:00
GarandPLG b45c300bc3 Add base tags, adjust margins, update CLI defaults
Introduce `CellTag` and `Players` enums and extend `CellWidget` to carry
a tag.
Store player and enemy base coordinates in `BoardState` and tag those
cells.
Reduce horizontal margin from 3 to 1 in board layout helpers.
Change CLI defaults: map width default 42, map height min 11 and default
11.
Adjust offset calculation and render constraints to match the new
layout.
2026-04-09 18:16:26 +02:00
GarandPLG 6e6181887c Consolidate event handling into events.rs
The event loop function is now defined in `events.rs`, the redundant
`handle_events.rs` file is removed, and the module re‑exports are
updated
to expose `handle_events` from `events`.
2026-04-09 10:07:24 +02:00
GarandPLG 1be72a4596 Rename soundtrack folder to soundtracks and fix path
Remove obsolete test2.ogg file.
2026-04-09 02:02:08 +02:00
GarandPLG 633494ed46 Add selectable soundtracks via CLI
Introduce a `Soundtrack` enum with Clap `ValueEnum` support and expose
it in the CLI as a `--sound-track` option. Extend `AudioCmd` with a
`ChangeSoundtrack` variant and refactor audio handling to load and cache
soundtracks per‑track using a thread‑safe `RwLock`. Update the
`handle_audio` function signature to accept the selected soundtrack,
adjust re‑exports, and modify `main` to pass the chosen soundtrack to
the audio thread. Also reposition the logging flag in the CLI
definition.
2026-04-09 02:00:24 +02:00
GarandPLG 7ec3eec6e3 Preload audio using once_cell and correct typo
Add once_cell 1.21.4 and a Lazy‑initialized HashMap to store OGG bytes.

Replace file reads with in‑memory Cursor decoding, fix the
SoundrackParts enum typo, and derive Hash traits for it.
2026-04-09 01:37:57 +02:00
GarandPLG 3e932e5638 Add ChangePart command and buffered audio sink
Introduce a `ChangePart` variant to `AudioCmd` and a `current_part`
state in
`handle_audio`.  The audio sink is now created via
`DeviceSinkBuilder::from_default_device` with a fixed buffer size.
`load_audio`
now accepts a reference to `SoundrackParts`, and the player
automatically
queues the correct part when the queue becomes empty.
2026-04-09 01:08:50 +02:00
GarandPLG 56bef7c98e Refactor CellWidget constructor to accept selected
Update `CellWidget::new` to take a `selected` flag and remove the
chaining return values from `set_selected` and `set_zoom_level`. The
board code now passes the selection state directly during construction.
2026-04-08 23:43:16 +02:00
GarandPLG 247f5c143b Adjust board vertical offset and focus 2026-04-08 14:51:04 +02:00
GarandPLG e4682f1c52 Refactor board cells to 2D vector and auto‑scroll
Store cells as a nested vector instead of a flat list, simplifying
indexing and
rendering. Add `is_focused_cell_visible` to detect when the focused cell
is
outside the viewport and adjust vertical/horizontal offsets accordingly
in
the skirmish keybindings. Update related methods and widget rendering to
use
the new 2‑D structure.
2026-04-08 14:25:14 +02:00
GarandPLG 4917068fb1 Fix board after resize 2026-04-08 13:24:44 +02:00
GarandPLG 04db2f1daf Make BoardState fields private 2026-04-08 00:08:09 +02:00
GarandPLG 48483da1a4 Refactor skirmish focus handling and CellWidget API
Introduce a MoveFocusedCell enum and a BoardState.change_focused_cell
method to
centralize focus movement logic. Update skirmish keybindings to use this
new
method and simplify board rendering by directly using stored CellWidget
state.
Make CellWidget setters chainable and expose the new enum in the module
re‑exports. Remove duplicated max_offset logic and old move_* methods.
2026-04-07 23:20:11 +02:00
GarandPLG e3fea75983 Add zoom support and emoji keybinding icons
- CellWidget now stores a ZoomLevel, renders size‑dependent text, and
  provides
  methods to set the zoom level and build its block.
- BoardState creates cells with the current zoom level, adds a helper to
  get a
  mutable cell, and updates each cell’s zoom level in `zoom_change`.
- KeybindingsWidget constructor now takes the widget height, calculates
  vertical padding to centre groups, and adds left borders between
  groups.
- Views (default, main_menu, skirmish) pass the area height to the new
  constructor.
- Keybinding descriptions are replaced with emoji symbols (🔈, 🔊, 🔉).
- BoardWidget clones the cell template instead of dereferencing it.
2026-04-07 19:21:43 +02:00
GarandPLG 3f646de3bb Encapsulate cell selection and simplify board rendering 2026-04-07 17:48:05 +02:00
GarandPLG 2b96ec129f Encapsulate FocusedCell fields and add getters 2026-04-07 01:14:36 +02:00
GarandPLG 8e01c8c33a Add audio subsystem with mute and volume controls
Update flake.lock dependencies to latest revisions
2026-04-07 01:05:33 +02:00
GarandPLG 0f37989f55 Rename input event handler to handle_events
Rename the input event handler module and function.
Update imports, re‑exports, and main.rs to use handle_events.
Add a brief doc comment for the new function.
2026-04-06 12:20:19 +02:00
GarandPLG 30f2e17ed7 Add audio deps; extract input handling to threads
Add ALSA and Rodio crates to Cargo.toml and lockfile to enable audio
playback.
Update Nix expressions to include `alsa-lib` as a build input.
Refactor input event handling into a new `app::threads` module:
 - Define `AppEvent` enum and `handle_input_events` function there.
 - Adjust imports in `app/app.rs` and `main.rs` accordingly.
   Remove the now‑unused `handle_input_events` and `AppEvent`
   definitions from
   `app/app.rs`.
2026-04-06 11:47:46 +02:00
GarandPLG 92ace142b4 Join input thread before exiting
Store the input event thread handle and join it after the app finishes.
This
replaces the previous fire‑and‑forget spawn and ensures the thread is
cleanly
terminated before the program exits.
2026-04-06 11:10:03 +02:00
GarandPLG dd64ef78f7 Rename Event to AppEvent and update imports
Rename the generic `Event` enum to `AppEvent` and propagate the change
through `app.rs`, `mod.rs`, and `main.rs`. Adjust function signatures,
imports, and channel usage to use the new name and the `read` helper
from crossterm. Ensure all senders/receivers now work with `AppEvent`.
2026-04-06 10:34:33 +02:00
GarandPLG 921596376f Adjust map size CLI defaults and ranges 2026-04-06 10:12:43 +02:00
GarandPLG 923af91aeb Lazy init game states and extract board module
App now stores CLI arguments and an optional GameStates, initializing
the
states lazily on the first window resize. Skirmish board logic is moved
to
a new BoardState module with dedicated helpers (cells_area_helper and
updated cell size handling). Views and keybindings are updated to use
the
optional state accessors.
2026-04-02 00:45:57 +02:00
GarandPLG c4e28255b6 Move skirmish Offset and FocusedCell to own module
Extract Offset and FocusedCell structs from skirmish.rs into a new
skirmish_states module. Re-export the structs from the top-level states
module and adjust imports in skirmish.rs.
2026-04-01 22:10:25 +02:00
GarandPLG f405c3cde1 Track window area and refactor keybinding APIs
- Track terminal size in `App::window_area` and update on resize
- Accept action slices in `count_largest_group` and
  `KeybindingsWidget::new`
- Add ACTIONS slices and layout helpers for default, main_menu, skirmish
- Add `main_menu_option_helper` for formatting menu strings and export
  it
2026-04-01 20:27:50 +02:00
GarandPLG bf8883934d Add zoom level helper and use it for cell sizing
Introduce a new `zoom_level` module containing the `CellSizes` enum and
`cell_size_helper` function to map `ZoomLevel` values to width and
height
dimensions. Export the helper from `mod.rs` and refactor `BoardWidget`
to
import and use `cell_size_helper`, eliminating duplicated match
statements.
2026-04-01 19:57:44 +02:00
GarandPLG 07e941eba1 Add bounded focus and padding to skirmish UI
- Initialize FocusedCell with map dimensions and start near the map
  centre.
- Store max rows/cols in FocusedCell and clamp moves to these bounds.
- Scroll actions now adjust the corresponding offset and also move the
  focused cell, keeping navigation consistent.
- Zoom actions modify the vertical offset to keep the view centered
  after
  changing zoom levels.
- Cell widget now uses a Padding widget with dynamic top padding based
  on
  the area height.
2026-03-30 16:32:28 +02:00
GarandPLG 363baa1c1a Add navigation and selection for skirmish cells
Reclassify Escape key as Quit and add directional actions to move the
focused cell.
2026-03-29 22:03:22 +02:00
GarandPLG d35d803a78 Show cell coordinates with column letters
Introduce `col_to_letters` to convert a zero‑based column index into
Excel‑style
letters. Add `display_coords` that returns the column letters followed
by the
row number. Update `render` to use this formatted coordinate as the
block
title instead of the previous row/col placeholder.
2026-03-29 21:07:05 +02:00
GarandPLG 6f17406d98 Add documentation
Extensive doc comments were added to keybindings, CLI options, logging,
and
widget modules. The `count_largest_group` function was introduced to
compute
the largest group size among actions. CLI validation for
`skill_points_limit`
was broadened to a 90‑690 range. Imports and signatures for `Display`
were
adjusted accordingly.
2026-03-29 15:36:11 +02:00
GarandPLG 9719e1ba6b Add block title helpers and use them in UI 2026-03-29 15:12:40 +02:00
GarandPLG 1d1dc0f2f7 Add zoom support and dynamic keybinding layout
Introduce ZoomIn/ZoomOut actions and a Zoom group with corresponding
keybindings.
Add a CLI option to set the initial zoom level and a ZoomLevel enum.
Expose a utility to compute the largest keybinding group size for layout
sizing.
Refactor board widget to adjust cell dimensions based on zoom level and
simplify offset calculations.
Update views to use the new layout sizing helper and integrate zoom
handling in skirmish logic.
2026-03-29 14:12:03 +02:00
GarandPLG edf491457e Add init flags to Offset and set vertical offset
Add `value_initiated` and `max_initiated` flags to prevent
repeated assignments. Provide `set_initial_value` for one‑time
initialisation and use it to centre the vertical offset when
creating the board widget. Remove stale comments on cell size constants.
2026-03-28 14:35:05 +01:00