Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Select): Add ruler settings to select UI #1462

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ tech changes will usually be stripped from release notes for the public

### Changed

- Select tool:
- now integrates all the ruler toggles in its UI as well
- these toggles are synced with the ones in the ruler
- Spell tool:
- now renders hexes instead of squares in Hex grid mode
- step size changed to 1 in Hex grid mode
Expand Down
24 changes: 24 additions & 0 deletions client/src/game/ui/tools/SelectTool.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<script setup lang="ts">
import { onMounted, toRef } from "vue";
import { useI18n } from "vue-i18n";

import type { GlobalPoint } from "../../../core/geometry";
import { rotateAroundPoint } from "../../../core/math";
import type { Polygon } from "../../shapes/variants/polygon";
import { selectedSystem } from "../../systems/selected";
import { rulerTool } from "../../tools/variants/ruler";
import { selectTool } from "../../tools/variants/select";
import { selectToolState } from "../../tools/variants/select/state";

const { t } = useI18n();

const { $, _$ } = selectToolState;

const selected = selectTool.isActiveTool;
Expand Down Expand Up @@ -47,6 +51,16 @@ function removePoint(): void {
const selection = selectedSystem.get({ includeComposites: false })[0] as Polygon;
selection.removePoint(getGlobalRefPoint(selection));
}

function toggle(event: MouseEvent): void {
const state = (event.target as HTMLButtonElement).getAttribute("aria-pressed") ?? "false";
rulerTool.showPublic.value = state === "false";
}

function toggleGridMode(event: MouseEvent): void {
const state = (event.target as HTMLButtonElement).getAttribute("aria-pressed") ?? "false";
rulerTool.gridMode.value = state === "false";
}
</script>

<template>
Expand All @@ -58,6 +72,12 @@ function removePoint(): void {

<div v-if="selected && $.hasSelection" class="tool-detail">
<button :aria-pressed="$.showRuler" @click="toggleShowRuler">Show ruler</button>
<button :aria-pressed="rulerTool.showPublic.value" :disabled="!$.showRuler" @click="toggle">
{{ t("game.ui.tools.RulerTool.share") }}
</button>
<button :aria-pressed="rulerTool.gridMode.value" :disabled="!$.showRuler" @click="toggleGridMode">
Grid Mode
</button>
</div>
</template>

Expand Down Expand Up @@ -99,6 +119,10 @@ button {
position: relative;
outline: none;

&:disabled {
opacity: 0.5;
}

&:hover {
&::before {
box-shadow: 0 0 0.5em #333;
Expand Down