Skip to content

Commit

Permalink
improve DataStatByStar, new icons, tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
userXinos committed Nov 3, 2023
1 parent 6eb0a3d commit 47861ad
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 24 deletions.
12 changes: 11 additions & 1 deletion src/components/DataHeadStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,24 @@ function getCharacteristics(d: Record<string, unknown>): GetCharacteristicsOut {
),
}) as GetCharacteristicsOut;
// eslint-disable-next-line guard-for-in
for (const key in res) {
if (postfixesRegex.test(key) || starKeys.includes(key)) {
const hasPostfix = postfixesRegex.test(key);
if (hasPostfix || starKeys.includes(key)) {
if (!('_statsByStar' in res)) {
(res as GetCharacteristicsOut)._statsByStar = [{}, false];
}
res._statsByStar[0][key] = res[key][0]; // eslint-disable-line prefer-destructuring
delete res[key];
}
if (hasPostfix) {
const parentKey = key.replace(postfixesRegex, '');
if (parentKey && res[parentKey] && !(parentKey in res._statsByStar[0])) {
res._statsByStar[0][parentKey] = res[parentKey][0]; // eslint-disable-line prefer-destructuring
delete res[parentKey];
}
}
}
if (d.projectile) { // перенести вниз
Expand Down
45 changes: 23 additions & 22 deletions src/components/DataStatByStar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@

<span
v-else
:class="statsStyleName(row[0])"
>{{ format.value(row[0], value) }}
:class="value && statsStyleName(row[0])"
class="stats-style"
><template v-if="value && TO_SPOLER_KEYS.includes(row[0])">
<DataStatTooltip
:k="value"
:is-loc-key="true"
> {{ $t('TID_OBJ_ACTION_EXPLORE_SECTOR') }}
</DataStatTooltip>
</template>
<template v-else>{{ format.value(row[0], value) }}</template>
</span>

</div>
Expand All @@ -81,19 +89,19 @@ import statsStyleName from '@Handlers/statsStyleName';
import { regex as postfixRegex } from '@Regulation/postfixes.mjs';
const dir = 'game/Stars';
const LABEL_BY_ORDER = {
'base': 'Base',
'': { dir, name: 'star_yellow' },
'ys': { dir, name: 'star_yellow' },
'rs': { dir, name: 'star_red' },
'ws': { dir, name: 'star_white' },
'bs': { dir, name: 'star_blue' },
'bls': { dir, name: 'star_blue' },
'pve': [{ dir, name: 'star_yellow' }, { dir, name: 'star_red' }],
'pvp': [{ dir, name: 'star_white' }, { dir, name: 'star_blue' }],
'': { dir: 'icons', name: 'star_multi' },
'ys': { dir: 'game/Stars', name: 'star_yellow' },
'rs': { dir: 'game/Stars', name: 'star_red' },
'ws': { dir: 'game/Stars', name: 'star_white' },
'bs': { dir: 'game/Stars', name: 'star_blue_2' },
'bls': { dir: 'game/Stars', name: 'star_blue_2' },
'pve': { dir: 'icons', name: 'star_pve' },
'pvp': { dir: 'icons', name: 'star_pvp' },
};
const LABEL_KEYS = Object.keys(LABEL_BY_ORDER);
const TO_SPOLER_KEYS = ['TID_Description'];
export interface Props {
items: { [k:string]: object|unknown[] },
Expand All @@ -108,9 +116,6 @@ const table = computed(() => {
const baseKey = k.replace(postfixRegex, '');
const labelIndex = LABEL_KEYS.indexOf((postfixRegex.exec(k)?.[1] ?? '').toLowerCase());
if (baseKey == 'TID_Description') {
return; // TODO
}
if (!(baseKey in preBody)) {
preBody[baseKey] = Array.from({ length: LABEL_KEYS.length });
}
Expand All @@ -122,27 +127,23 @@ const table = computed(() => {
const bodyKeys = Object.keys(preBody);
for (let i = LABEL_KEYS.length; i >= 0; i--) {
const isSkipLabelKey = Object.values(preBody).every((e) => e[i] == undefined);
const isSkipLabelKey = bodyValuesMatrix.every((row) => row[i] == undefined);
if (isSkipLabelKey) {
bodyValuesMatrix.forEach((row) => {
row.splice(i, 1);
});
bodyValuesMatrix.forEach((row) => row.splice(i, 1));
} else {
const headLabel = LABEL_BY_ORDER[LABEL_KEYS[i]];
if (typeof headLabel == 'object' && head.some((e) => typeof e == 'object' && e.name == headLabel.name)) {
// цель состоит в том, чтобы удалить идентичные лейблы столбцов,
// просто перенос значений по индексу с оставлением оригинального, но уже путсного ключа preBody
bodyValuesMatrix.forEach((row, iRow) => {
const value = row[i];
if (value) {
if (value && !row[i + 1]) {
bodyValuesMatrix[iRow][i + 1] = value;
delete bodyValuesMatrix[iRow][i];
}
});
bodyValuesMatrix.forEach((row) => {
row.splice(i, 1);
});
bodyValuesMatrix.forEach((row) => row.splice(i, 1));
} else {
head.unshift(headLabel);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/DataStatTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import locKeys from '@Regulation/locKeys.mjs';
export interface Props {
k: string,
isLocKey?: true,
}
const TOOLTIP_WIDTHS = [400, 200];
Expand All @@ -59,6 +60,9 @@ onUnmounted(() => {
});
function hasInfoGetter() {
if (props.isLocKey) {
return [true, props.k];
}
const newKey = locKeys[props.k] || props.k;
if (te(`${newKey}_DESCR`)) {
Expand Down
Binary file added src/img/icons/star_multi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/icons/star_pve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/icons/star_pvp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/regulation/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default [
path: '/bluestar',
component: () => import(/* webpackChunkName: "BlueStar" */ '../pages/BlueStar.vue'),
icon: {
name: 'star_blue',
name: 'star_blue_2',
dir: 'game/Stars',
},
},
Expand Down

0 comments on commit 47861ad

Please sign in to comment.