window.open

This commit is contained in:
2026-05-13 21:12:39 +02:00
parent 757d999b9a
commit f79a98229a
10 changed files with 277 additions and 269 deletions

View File

@@ -2,33 +2,34 @@
module UI
module Windows
module_function
# Game catalog browser. Left=titles, right=card with story + links.
def games(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 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"
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
lines
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