---@type RuntimeUi local runtime_ui = runtime.import("runtime_ui") ---@type RuntimeLayout local layout = runtime.import("layout") local theme = runtime.import("theme") local i18n = runtime.import("i18n") local styles = runtime.import("styles") local state = runtime.import("state") local board = runtime.import("board") local rules = runtime.import("rules") local ui = {} local board_origin = { x = 40, y = 90 } function ui.highlight_updates(ids, enabled) return runtime_ui.batch_update(ids, enabled and styles.piece_highlight or styles.piece_normal) end function ui.create_board_nodes() local nodes = { runtime_ui.sprite("board_panel", "board", 40, 90, 640, 520, styles.board_panel), runtime_ui.text("board_title", theme.title(), 240, 15, 180, 40, runtime_ui.with_parent("board_panel", styles.board_title)), runtime_ui.panel("red_home", 20, 390, 130, 90, runtime_ui.with_parent("board_panel", styles.red_home)), runtime_ui.panel("blue_home", 460, -10, 130, 90, runtime_ui.with_parent("board_panel", styles.blue_home)) } for index, cell in ipairs(board.path) do local pos = layout.local_position(board_origin, cell) runtime_ui.append(nodes, runtime_ui.circle("cell_" .. tostring(index), pos.x, pos.y, 28, runtime_ui.with_parent("board_panel", styles.path_cell))) end for id, piece in pairs(state.pieces) do local pos = rules.piece_home_position(piece) runtime_ui.append(nodes, runtime_ui.circle(id, pos.x, pos.y, 44, styles.piece(piece.owner))) end return nodes end function ui.create_ui_nodes() local hud_items = layout.row("top_bar", { runtime_ui.text("turn_text", i18n.t("current_player", { player = i18n.player(state.current_player) }), 0, 0, 230, 32, styles.hud_text), runtime_ui.text("dice_text", i18n.t("dice_empty"), 0, 0, 120, 32, styles.hud_text), layout.item( runtime_ui.button("dice_button", i18n.t("roll_button"), 0, 0, 130, 48, "roll_dice", styles.dice_button), { marginLeft = 134 } ) }, { x = 24, height = 76, gap = 16, align = "center" }) local nodes = { runtime_ui.panel("top_bar", 0, 0, 720, 76, styles.top_bar) } return runtime_ui.append_all(nodes, hud_items) end function ui.dice_and_turn_updates(dice, current_player) return { runtime_ui.text_update("dice_text", i18n.t("dice_value", { value = dice })), runtime_ui.text_update("turn_text", i18n.t("current_player", { player = i18n.player(current_player) })) } end function ui.dice_update(dice) return { runtime_ui.text_update("dice_text", i18n.t("dice_value", { value = dice })) } end function ui.turn_update(current_player) return { runtime_ui.text_update("turn_text", i18n.t("current_player", { player = i18n.player(current_player) })) } end return ui