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

auto tab switching: fix #97 #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,20 @@ <h3 data-locale="ui.config.color.etc">
data-type="boolean"
data-config-key="format.use_skill_aliases" />
</p>

<blockquote data-locale="ui.config.etc.others.switch-raid-help">
현재 전투의 인원수에 따라 알맞은 24인 모드의 탭으로 자동 전환합니다.
</blockquote>
<p class="control">
<label for="input-format-switch_raid_tab"
data-locale="config.format.switch_raid_tab">
24인 모드 탭 자동 전환
</label>
<input type="checkbox" id="input-format-switch_raid_tab"
data-type="boolean"
data-config-key="format.switch_raid_tab" />
</p>
</article>
<article>
<h3 data-locale="ui.config.etc.others.filter"> 필터 </h3>
<blockquote data-locale="ui.config.etc.others.filter-help.0">
Expand Down
28 changes: 22 additions & 6 deletions overlay/lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

constructor(config) {
this.current = 0
this.combatants = -1

this.standby = true
this.currentHistory = false
Expand Down Expand Up @@ -55,14 +56,13 @@
switchTab(id) {
if(!this.tabs[id]) {
throw new ReferenceError(`Failed to switch to tab '${id}': No such tab`)
return
}
this.current = id
this.updateHeader()
if(window.hist.current)
this.update()

$('#table').setAttribute('data-width', this.tabs[id].tab.width)
$('#table').setAttribute('data-width', this.template.tab.width)
}

browseHistory(id) {
Expand Down Expand Up @@ -100,11 +100,27 @@
this.standby = false
}

if(!this.currentHistory) {
this.render(window.hist.current)
} else {
this.render(window.hist.browse(this.currentHistory).data)
let data = this.currentHistory ?
window.hist.browse(this.currentHistory).data : window.hist.current

let comb = data.data.length
if (this.config.format.switch_raid_tab && comb !== this.combatants) {
this.combatants = comb

let properTab = Object.keys(this.tabs).find(k =>
(this.tabs[k].tab.width === '1') === (this.combatants < 24))

let properIndex = Object.keys(this.tabs).findIndex(t => t === properTab)

if(properTab) {
[].forEach.call($('.tabs span'), v => v.classList.remove('active'))
$('.tabs span', properIndex).classList.add('active')

return this.switchTab(properTab)
}
}

this.render(data)
}

_testRow(data) {
Expand Down
2 changes: 2 additions & 0 deletions share/lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"others": {
"_": "기타",
"skill-aliases-help": "'The Forbidden Chakra'와 같은 긴 스킬 이름에 대해 약칭을 사용합니다.",
"switch-raid-help": "현재 전투의 인원수에 따라 알맞은 24인 모드의 탭으로 자동 전환합니다.",
"filter": "필터",
"filter-help": [
"FFXIV_Plugin이 피아식별조차 제대로 못 하는 관계로, 어떻게든 적을 표시하지 않도록 시도합니다.",
Expand Down Expand Up @@ -211,6 +212,7 @@
"myname": "내 이름",
"use_short_name": "이름을 이니셜로 표시 (글로벌 서버용)",
"use_skill_aliases": "스킬 이름 약칭 사용 (글로벌 서버용)",
"switch_raid_tab": "24인 모드 탭 자동 전환",
"use_tailing_pct": "비율 값 뒤에 % 기호를 표시"
}
},
Expand Down
1 change: 1 addition & 0 deletions share/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const CONFIG_DEFAULT = {
myname: [],
use_short_name: 0,
use_skill_aliases: true,
switch_raid_tab: true,
use_tailing_pct: true
},
filter: {
Expand Down