Files
bbs-server/lib/ui/windows/games_window.rb
2026-05-13 21:12:39 +02:00

36 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module UI
module Windows
# Game catalog browser. Left=titles, right=card with story + links.
class Games
def self.open(app, services:)
BBS::Windows::MasterDetail.open(app,
title: ' Game Catalog ',
items: services[:games].all,
item_label: ->(g) { g.title },
list_width: 30,
empty_message: ' (no games)',
render_detail: ->(game, width) { game_card_lines(game, width) }
)
end
def self.game_card_lines(game, width)
lines = []
lines << " \e[1;33m#{game.title}\e[0m"
lines << " \e[0;36m#{game.platform} · #{game.author}\e[0m"
lines << ''
BBS::FrameBuffer.wrap_ansi(game.desc.to_s, width - 4).each { |l| lines << " #{l}" }
lines << ''
BBS::FrameBuffer.wrap_ansi(game.story.to_s, width - 4).each { |l| lines << " #{l}" }
lines << ''
game.external_links.each do |link|
lines << " \e[0;37m#{link[:label].ljust(10)}\e[0m \e[1;36m#{link[:url]}\e[0m"
end
lines
end
private_class_method :game_card_lines
end
end
end