diff --git a/bbs.rb b/bbs.rb index f4e1b4c..d9906b7 100644 --- a/bbs.rb +++ b/bbs.rb @@ -221,8 +221,7 @@ MAIN_TUI = BBS::TUI.define do @status = 'Message cannot be empty.' else MESSAGES.append(@username, @input.strip[0...200]) - @status = 'Sent!' - @input = +'' + go :idle end end key(:backspace) { @input.chop! unless @input.empty? } @@ -275,20 +274,25 @@ MAIN_TUI = BBS::TUI.define do if @items.empty? text 'No games found.', x: CONT_X, y: CONT_Y, style: THEME[:normal] else - game = @items[@item_sel] + game = @items[@item_sel] + links = game.external_links + text "#{@item_sel + 1}/#{@items.size} #{game.title}"[0, cont_w], x: CONT_X, y: CONT_Y, style: THEME[:bright] - text "#{game.platform} #{game.author}"[0, cont_w], + text "#{game.platform} · #{game.author}"[0, cont_w], x: CONT_X, y: CONT_Y + 1, style: THEME[:normal] - wordwrap(game.desc.to_s, cont_w).first(cont_h - 8).each_with_index do |l, i| + + story_rows = cont_h - 4 - links.size + wordwrap(game.story, cont_w).first(story_rows).each_with_index do |l, i| text l, x: CONT_X, y: CONT_Y + 3 + i, style: THEME[:normal] end - badges = [] - badges << tc(:success, '[▶ Play]') unless game.play_path.empty? - badges << tc(:label, '[⬇ Download]') unless game.download_path.empty? - badges << tc(:bright, '[Source]') unless game.source_path.empty? - badges << tc(:header, '[Docs]') unless game.docs_path.empty? - text badges.join(' '), x: CONT_X, y: CONT_Y + cont_h - 3 + + link_y = CONT_Y + cont_h - links.size + links.each_with_index do |lnk, i| + text "#{tc(:label, lnk[:label])} #{lnk[:url]}"[0, cont_w], + x: CONT_X, y: link_y + i + end + text '↑↓ navigate q back', x: CONT_X, y: CONT_Y + cont_h, style: THEME[:normal] end end diff --git a/lib/model/game_model.rb b/lib/model/game_model.rb index 94d5dc9..4b7ce42 100644 --- a/lib/model/game_model.rb +++ b/lib/model/game_model.rb @@ -1,21 +1,25 @@ # frozen_string_literal: true class GameModel - attr_reader :title, :platform, :author, :desc, + attr_reader :title, :platform, :author, :desc, :story, :play_path, :download_path, :source_path, :docs_path, - :release_count + :release_count, :external_links def initialize(entry) sw = entry['software'] || {} latest = entry['latestRelease'] || {} - @title = sw['title'].to_s - @platform = sw['platform'].to_s - @author = sw['author'].to_s - @desc = sw['desc'].to_s - @play_path = latest['htmlFolderPath'].to_s - @download_path = latest['cartridgePath'].to_s - @source_path = latest['sourcePath'].to_s - @docs_path = latest['docsFolderPath'].to_s - @release_count = (entry['releases'] || []).length + @title = sw['title'].to_s + @platform = sw['platform'].to_s + @author = sw['author'].to_s + @desc = sw['desc'].to_s + @story = sw['story'].to_s + @play_path = latest['htmlFolderPath'].to_s + @download_path = latest['cartridgePath'].to_s + @source_path = latest['sourcePath'].to_s + @docs_path = latest['docsFolderPath'].to_s + @release_count = (entry['releases'] || []).length + @external_links = (sw['externalLinks'] || []).filter_map do |l| + { label: l['label'].to_s, url: l['url'].to_s } unless l['url'].to_s.empty? + end end end