feat(wip): 연감에서 지도를 부르는 작업 준비중

This commit is contained in:
2022-04-20 20:59:10 +09:00
parent e014bc05e8
commit 1e19213f76
4 changed files with 150 additions and 44 deletions
+42
View File
@@ -0,0 +1,42 @@
@import "./common/bootstrap5.scss";
@import "./editor_component.scss";
@import "./util.scss";
@include media-1000px {
#container {
width: 1000px;
margin: 0 auto;
padding: 0;
}
.year-selector{
margin-left: 100%/24*5;
}
.map_position{
flex: 0 0 auto;
width: 700px;
}
.nation_position{
flex: 0 0 auto;
width: 300px;
}
}
@include media-500px {
#container {
width: 500px;
margin: 0 auto;
padding: 0;
}
.map_position{
flex: 0 0 auto;
width: 100%;
}
.nation_position{
flex: 0 0 auto;
width: 100%;
}
}
+98 -41
View File
@@ -1,25 +1,53 @@
<template> <template>
<div>연감</div> <BContainer v-if="asyncReady" id="container" :toast="{ root: true }" class="bg0 pageHistory">
<div v-if="history"> <TopBackBar title="연감" type="close"></TopBackBar>
있음 <div class="center row mx-0 s-border-tb">
<div v-for="date of generateYearMonthList()" :key="date.yearMonth" @click="queryYearMonth = date.yearMonth"> <div class="col-md-1 col-2 year-selector text-end align-self-center">연월 선택:</div>
{{ date.year }} {{ date.month }} {{ date.queried ? `선택` : "" }} {{ date.current ? "현재" : "" }} <BButton class="col-md-1 col-2" @click="queryYearMonth -= 1"> 이전달</BButton>
<div class="col-md-3 col-5 d-grid">
<BFormSelect v-model="queryYearMonth" :options="generateYearMonthList()" />
</div>
<BButton class="col-md-1 col-2" @click="queryYearMonth += 1">다음달 </BButton>
</div> </div>
<div> <div v-if="history" class="mx-0">
<template v-for="(item, idx) in history.global_action" :key="idx"> <div class="row g-0">
<!-- eslint-disable-next-line vue/no-v-html --> <div class="map_position">
<span v-html="formatLog(item)"></span> <StaticMapTemplate
<br /> :server-nick="serverNick"
</template> :serverID="queryServerID"
:map-name="unwrap(gameConstStore?.gameConst.mapName)"
:model-value="history.map"
:is-detail-map="true"
:city-position="cityPosition"
:format-city-info="formatCityInfoText"
:image-path="imagePath"
/>
</div>
<div class="nation_position"><SimpleNationList :nations="history.nations" /></div>
</div>
<div class="world_history">
<div class="bg1 center s-border-tb"><b>중원 정세</b></div>
<div class="content">
<template v-for="(item, idx) in history.global_history" :key="idx">
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="formatLog(item)"></span>
<br />
</template>
</div>
</div>
<div class="general_public_record">
<div class="bg1 center s-border-tb"><b>장수 동향</b></div>
<div class="content">
<template v-for="(item, idx) in history.global_action" :key="idx">
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="formatLog(item)"></span>
<br />
</template>
</div>
</div>
</div> </div>
<div> <BottomBar type="close"></BottomBar>
<template v-for="(item, idx) in history.global_history" :key="idx"> </BContainer>
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="formatLog(item)"></span>
<br />
</template>
</div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@@ -34,50 +62,70 @@ declare const query: {
yearMonth: number | null; yearMonth: number | null;
serverID: string; serverID: string;
}; };
declare const getCityPosition: () => CityPositionMap;
declare const formatCityInfo: (city: MapCityParsedRaw) => MapCityParsed;
</script> </script>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref, watch } from "vue"; import { onMounted, provide, ref, watch } from "vue";
import { BContainer, BButton, BFormSelect } from "bootstrap-vue-3";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import type { HistoryObj } from "./defs/API/Global"; import type { HistoryObj } from "./defs/API/Global";
import { SammoAPI } from "./SammoAPI"; import { SammoAPI } from "./SammoAPI";
import { joinYearMonth } from "./util/joinYearMonth"; import { joinYearMonth } from "./util/joinYearMonth";
import { parseYearMonth } from "./util/parseYearMonth"; import { parseYearMonth } from "./util/parseYearMonth";
import { formatLog } from "./utilGame/formatLog"; import { formatLog } from "./utilGame/formatLog";
import SimpleNationList from "./components/SimpleNationList.vue";
import StaticMapTemplate, { type CityPositionMap, type MapCityParsedRaw, type MapCityParsed} from "./components/StaticMapTemplate.vue";
import { getGameConstStore, type GameConstStore } from "./GameConstStore";
import { unwrap } from "@/util/unwrap";
const queryYearMonth = ref<number>(); const queryYearMonth = ref<number>();
const queryServerID = query.serverID; const queryServerID = query.serverID;
const serverNick = staticValues.serverNick;
const lastYearMonth = ref(staticValues.lastYearMonth); const lastYearMonth = ref(staticValues.lastYearMonth);
const firstYearMonth = ref(staticValues.fisrtYearMonth); const firstYearMonth = ref(staticValues.fisrtYearMonth);
const currentYearMonth = ref(staticValues.currentYearMonth); const currentYearMonth = ref(staticValues.currentYearMonth);
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const cityPosition = getCityPosition();
const formatCityInfoText = formatCityInfo;
const imagePath = window.pathConfig.gameImage;
const history = ref<HistoryObj>(); const history = ref<HistoryObj>();
function* generateYearMonthList(): Generator<{ function generateYearMonthList(): { text: string; value: number }[] {
year: number; const result: { text: string; value: number }[] = [];
month: number;
yearMonth: number;
current?: true;
queried: boolean;
}> {
let yearMonth = firstYearMonth.value; let yearMonth = firstYearMonth.value;
while (yearMonth <= lastYearMonth.value) { while (yearMonth <= lastYearMonth.value) {
const [year, month] = parseYearMonth(yearMonth); const [year, month] = parseYearMonth(yearMonth);
yield { const info: string[] = [];
year, if (queryYearMonth.value === yearMonth) {
month, info.push("선택");
yearMonth, }
queried: queryYearMonth.value === yearMonth, result.push({ text: `${year}${month}${info.length > 0 ? `(${info.join(", ")})` : ""}`, value: yearMonth });
}; yearMonth += 1;
yearMonth++;
} }
const [year, month] = parseYearMonth(yearMonth); const [year, month] = parseYearMonth(yearMonth);
yield { const info: string[] = [];
year, if (queryYearMonth.value === yearMonth) {
month, info.push("선택");
yearMonth, }
current: true, info.push("현재");
queried: queryYearMonth.value === yearMonth, result.push({ text: `${year}${month}${info.length > 0 ? `(${info.join(", ")})` : ""}`, value: yearMonth });
}; return result;
} }
watch(queryYearMonth, async (yearMonth) => { watch(queryYearMonth, async (yearMonth) => {
@@ -85,6 +133,15 @@ watch(queryYearMonth, async (yearMonth) => {
return; return;
} }
if (yearMonth < firstYearMonth.value) {
queryYearMonth.value = firstYearMonth.value;
return;
}
if (yearMonth > lastYearMonth.value + 1) {
queryYearMonth.value = lastYearMonth.value + 1;
return;
}
if (yearMonth > lastYearMonth.value) { if (yearMonth > lastYearMonth.value) {
try { try {
const result = await SammoAPI.Global.GetCurrentHistory(); const result = await SammoAPI.Global.GetCurrentHistory();
+3 -3
View File
@@ -1,7 +1,7 @@
import "@scss/board.scss"; import "@scss/history.scss";
import { createApp } from 'vue' import { createApp } from 'vue'
import PageHistory from '@/PageHistory.vue'; import PageHistory from '@/PageHistory.vue';
import BootstrapVue3 from 'bootstrap-vue-3' import { BootstrapVue3, BToastPlugin } from 'bootstrap-vue-3'
import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest'; import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest';
import { auto500px } from "./util/auto500px"; import { auto500px } from "./util/auto500px";
import { htmlReady } from "./util/htmlReady"; import { htmlReady } from "./util/htmlReady";
@@ -13,4 +13,4 @@ auto500px();
htmlReady(() => { htmlReady(() => {
insertCustomCSS(); insertCustomCSS();
}); });
createApp(PageHistory).use(BootstrapVue3).mount('#app'); createApp(PageHistory).use(BootstrapVue3).use(BToastPlugin).mount('#app');
+7
View File
@@ -15,6 +15,11 @@ $serverID = Util::getReq('serverID', 'string', null);
if (!$serverID) { if (!$serverID) {
$serverID = UniqueConst::$serverID; $serverID = UniqueConst::$serverID;
} }
if ($serverID !== UniqueConst::$serverID) {
$mapName = $db->queryFirstField('SELECT map FROM ng_games WHERE server_id=%s', $serverID) ?: 'che';
} else {
$mapName = GameConst::$mapName;
}
[$f_year, $f_month] = $db->queryFirstList('SELECT year, month FROM ng_history WHERE server_id = %s ORDER BY year ASC, month ASC LIMIT 1', $serverID); [$f_year, $f_month] = $db->queryFirstList('SELECT year, month FROM ng_history WHERE server_id = %s ORDER BY year ASC, month ASC LIMIT 1', $serverID);
[$l_year, $l_month] = $db->queryFirstList('SELECT year, month FROM ng_history WHERE server_id = %s ORDER BY year DESC, month DESC LIMIT 1', $serverID); [$l_year, $l_month] = $db->queryFirstList('SELECT year, month FROM ng_history WHERE server_id = %s ORDER BY year DESC, month DESC LIMIT 1', $serverID);
@@ -32,6 +37,8 @@ $me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner = %i', $
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=500" /> <meta name="viewport" content="width=500" />
<?= WebUtil::printJS('../d_shared/common_path.js', true) ?> <?= WebUtil::printJS('../d_shared/common_path.js', true) ?>
<?= WebUtil::printJS("js/map/theme_{$mapName}.js") ?>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
<?= WebUtil::printStaticValues([ <?= WebUtil::printStaticValues([
'staticValues' => [ 'staticValues' => [
'fisrtYearMonth' => Util::joinYearMonth($f_year, $f_month), 'fisrtYearMonth' => Util::joinYearMonth($f_year, $f_month),