Skip to content

Commit

Permalink
OPGG 页面添加召唤师技能闪现位置偏好
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanxven committed Aug 11, 2024
1 parent 203f6e5 commit 50244df
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 17 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

## 调整

- 辅助窗口现在将始终展示任务栏图标,可以调整大小且可以最小化。
- 辅助窗口在未被关闭时将始终展示任务栏图标,可以调整大小且可以最小化。

- 战绩页面在提供较小宽度时会改变布局,展示更少的内容。

## 修复

Expand Down
24 changes: 24 additions & 0 deletions src/main/modules/akari-core/auxiliary-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ export class AuxWindowModule extends MobxBasedBasicModule {
return 'hide'
})

const auxWindowOpggShowTiming = computed(() => {
switch (this._lcu.gameflow.phase) {
case 'ChampSelect':
return 'show'
}

return 'normal'
})

// normally show & hide
this.autoDisposeReaction(
() => auxWindowIndicatorShowTiming.get(),
(timing) => {
Expand All @@ -179,6 +189,20 @@ export class AuxWindowModule extends MobxBasedBasicModule {
}
)

// shows only in champ select and never hides
this.autoDisposeReaction(
() => auxWindowOpggShowTiming.get(),
(timing) => {
if (this.state.currentFunctionality !== 'opgg') {
return
}

if (timing === 'show') {
this.showWindow()
}
}
)

this.autoDisposeReaction(
() => this.state.bounds,
(bounds) => {
Expand Down
75 changes: 64 additions & 11 deletions src/renderer/src-auxiliary-window/views/opgg/OpggChampion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,17 @@
v-if="data && data.data.summoner_spells && data.data.summoner_spells.length"
>
<div class="card-title">
召唤师技能<NCheckbox size="small" v-model:checked="isSummonerSpellsExpanded"
>展示全部</NCheckbox
>
召唤师技能
<div>
<NRadioGroup v-model:value="flashPosition" size="small" style="margin-right: 12px">
<NFlex style="gap: 4px;">
<NRadio value="d" title="闪现位置默认在 D">D 闪</NRadio>
<NRadio value="f" title="闪现位置默认在 F">F 闪</NRadio>
<NRadio value="auto" title="根据当前闪现的位置决定">自动</NRadio>
</NFlex>
</NRadioGroup>
<NCheckbox size="small" v-model:checked="isSummonerSpellsExpanded">展示全部</NCheckbox>
</div>
</div>
<div class="card-content">
<div
Expand Down Expand Up @@ -599,6 +607,7 @@ import PerkDisplay from '@shared/renderer/components/widgets/PerkDisplay.vue'
import PerkstyleDisplay from '@shared/renderer/components/widgets/PerkstyleDisplay.vue'
import SummonerSpellDisplay from '@shared/renderer/components/widgets/SummonerSpellDisplay.vue'
import { getMySelections, setMySummonerSpells } from '@shared/renderer/http-api/champ-select'
import { chatSend } from '@shared/renderer/http-api/chat'
import {
getPerkInventory,
getPerkPages,
Expand All @@ -608,13 +617,18 @@ import {
} from '@shared/renderer/http-api/perks'
import { championIconUrl } from '@shared/renderer/modules/game-data'
import { useLcuConnectionStore } from '@shared/renderer/modules/lcu-connection/store'
import { useChatStore } from '@shared/renderer/modules/lcu-state-sync/chat'
import { useGameDataStore } from '@shared/renderer/modules/lcu-state-sync/game-data'
import { useGameflowStore } from '@shared/renderer/modules/lcu-state-sync/gameflow'
import { ArrowForwardIosOutlined as ArrowForwardIosOutlinedIcon } from '@vicons/material'
import { useLocalStorage } from '@vueuse/core'
import {
NButton,
NCheckbox,
NFlex,
NIcon,
NRadio,
NRadioGroup,
NScrollbar,
NSpin,
NSwitch,
Expand All @@ -637,6 +651,7 @@ const props = defineProps<{
const gameflow = useGameflowStore()
const lc = useLcuConnectionStore()
const chat = useChatStore()
const positionTextMap = {
TOP: '上单',
Expand Down Expand Up @@ -726,6 +741,8 @@ const isPrismItemsExpanded = ref(false)
const isCoreItemsExpanded = ref(false)
const isLastItemsExpanded = ref(false)
const flashPosition = useLocalStorage('opgg-flash-position', 'auto')
watchEffect(() => {
if (!props.data) {
isSummonerSpellsExpanded.value = false
Expand Down Expand Up @@ -762,33 +779,58 @@ const gameData = useGameDataStore()
if (import.meta.env.DEV) {
watchEffect(() => {
console.log('OPGG Component: ', props.data, props.champion, info.value)
console.debug('OPGG Component: ', props.data, props.champion, info.value)
})
watchEffect(() => {
console.log('OPGG Component: Info', info.value)
console.debug('OPGG Component: Info', info.value)
})
}
const message = useMessage()
const SUMMONER_SPELL_FLASH_ID = 4
const handleSetSummonerSpells = async (ids: number[]) => {
try {
const selection = (await getMySelections()).data
const [oldSpell1Id, oldSpell2Id] = [selection.spell1Id, selection.spell2Id]
let [newSpell1Id, newSpell2Id] = ids
// 需要尽可能保持原有的技能位置, 俗话说的好, D 闪都是白银, 我们要避免成为白银——如果你曾经是 F 闪玩家的话...
if (newSpell1Id === oldSpell2Id || newSpell2Id === oldSpell1Id) {
;[newSpell1Id, newSpell2Id] = [newSpell2Id, newSpell1Id]
// 有闪现的情况且不为 auto 时, 优先按照偏好闪现位置, 否则强制按照 auto
if (
flashPosition.value !== 'auto' &&
(newSpell1Id === SUMMONER_SPELL_FLASH_ID || newSpell2Id === SUMMONER_SPELL_FLASH_ID)
) {
if (newSpell2Id === SUMMONER_SPELL_FLASH_ID) {
if (flashPosition.value === 'd') {
;[newSpell1Id, newSpell2Id] = [newSpell2Id, newSpell1Id]
}
} else if (newSpell1Id === SUMMONER_SPELL_FLASH_ID) {
if (flashPosition.value === 'f') {
;[newSpell1Id, newSpell2Id] = [newSpell2Id, newSpell1Id]
}
}
} else {
if (newSpell1Id === oldSpell2Id || newSpell2Id === oldSpell1Id) {
;[newSpell1Id, newSpell2Id] = [newSpell2Id, newSpell1Id]
}
}
await setMySummonerSpells({
spell1Id: newSpell1Id,
spell2Id: newSpell2Id
})
message.success('请求已发送')
if (chat.conversations.championSelect) {
chatSend(
chat.conversations.championSelect.id,
`[League Akari] 已设置召唤师技能: ${gameData.summonerSpells[newSpell1Id]?.name} | ${gameData.summonerSpells[newSpell2Id]?.name}`,
'celebration'
)
}
} catch (error) {
console.warn(error)
message.warning(`设置召唤师技能失败: ${(error as any).message}`)
Expand All @@ -804,23 +846,26 @@ const handleSetRunes = async (r: {
}) => {
try {
const inventory = (await getPerkInventory()).data
let addedNew = false
const positionName = props.position ? positionTextMap[props.position.toUpperCase()] || '' : ''
if (inventory.canAddCustomPage) {
const { data: added } = await postPerkPage({
name: `[OP.GG] ${gameData.champions[info.value?.id]?.name || '-'}`,
name: `[OP.GG] ${gameData.champions[info.value?.id]?.name || '-'}${positionName ? ` - ${positionName}` : ''}`,
isEditable: true,
primaryStyleId: r.primary_page_id.toString()
})
await putPage({
id: added.id,
isRecommendationOverride: false,
isTemporary: false,
name: `[OP.GG] ${gameData.champions[info.value?.id]?.name || '-'}`,
name: `[OP.GG] ${gameData.champions[info.value?.id]?.name || '-'}${positionName ? ` - ${positionName}` : ''}`,
primaryStyleId: r.primary_page_id,
selectedPerkIds: [...r.primary_rune_ids, ...r.secondary_rune_ids, ...r.stat_mod_ids],
subStyleId: r.secondary_page_id
})
await putCurrentPage(added.id)
addedNew = true
} else {
const pages = (await getPerkPages()).data
if (!pages.length) {
Expand All @@ -832,7 +877,7 @@ const handleSetRunes = async (r: {
id: page1.id,
isRecommendationOverride: false,
isTemporary: false,
name: `[OP.GG] ${gameData.champions[info.value?.id]?.name || '-'}`,
name: `[OP.GG] ${gameData.champions[info.value?.id]?.name || '-'}${positionName ? ` - ${positionName}` : ''}`,
primaryStyleId: r.primary_page_id,
selectedPerkIds: [...r.primary_rune_ids, ...r.secondary_rune_ids, ...r.stat_mod_ids],
subStyleId: r.secondary_page_id
Expand All @@ -841,6 +886,14 @@ const handleSetRunes = async (r: {
}
message.success('请求已发送')
if (chat.conversations.championSelect) {
chatSend(
chat.conversations.championSelect.id,
`[League Akari] 已${addedNew ? '添加' : '替换'}符文页: ${gameData.champions[info.value?.id]?.name || '-'}${positionName ? ` - ${positionName}` : ''}`,
'celebration'
)
}
} catch (error) {
console.warn(error)
message.warning(`设置符文配法失败: ${(error as any).message}`)
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/src-auxiliary-window/views/opgg/OpggTier.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
NDataTable,
NInput
} from 'naive-ui'
import { computed, h, ref, useCssModule, watchEffect } from 'vue'
import { computed, h, ref, useCssModule } from 'vue'
const props = defineProps<{
championId?: number
Expand Down Expand Up @@ -391,10 +391,6 @@ const combinedColumns = computed(() => {
return columns
})
watchEffect(() => {
console.log('isLargeEnoughToShow', isLargeEnoughToShow.value)
})
const filterText = ref('')
const isNameMatch = (pattern: string, label: string, value?: number) => {
Expand Down

0 comments on commit 50244df

Please sign in to comment.