Skip to content

Commit

Permalink
add kenny audio
Browse files Browse the repository at this point in the history
  • Loading branch information
izure1 committed Dec 21, 2021
1 parent 63cfbeb commit 40dd0a2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 31 deletions.
Binary file added build/additional/FreeAssets/Kenny-audio.zip
Binary file not shown.
File renamed without changes.
20 changes: 11 additions & 9 deletions src/Renderer/components/Manager/FileGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
<v-card-title>이름을 입력하세요</v-card-title>
<v-card-subtitle>이름을 변경하면 이 파일을 참조하는 다른 파일에서도 수정해야합니다</v-card-subtitle>
<v-card-text>
<v-text-field v-model="namingText"
:rules="[ namingRule ]"
:suffix="namingExt"
ref="dialog-naming"
label="이름"
placeholder="이곳에 입력하세요"
filled
rounded
/>
<v-form @submit.prevent="dispatchNaming">
<v-text-field v-model="namingText"
:rules="[ namingRule ]"
:suffix="namingExt"
ref="dialog-naming"
label="이름"
placeholder="이곳에 입력하세요"
filled
rounded
/>
</v-form>
</v-card-text>

<v-divider />
Expand Down
16 changes: 12 additions & 4 deletions src/Renderer/components/Manager/Tool/AssetAppender.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,23 @@ export default defineComponent({
setup() {
const isProduction = process.env.NODE_ENV === 'production'
const resourcesPath = isProduction ? process.resourcesPath : path.resolve(process.cwd(), 'build')
console.log(resourcesPath)
const list = ref<Card[]>([
{
logo: 'https://www.kenney.nl/data/img/logo.png',
title: 'Kenny Isometric Tiles',
subtitle: 'Kenny.nl에서 제공한 무료 에셋을 프로젝트에 추가합니다.',
source: path.resolve(resourcesPath, 'additional', 'FreeAssets', 'Kenny.zip'),
namespace: 'Kenny-isometric-tiles',
subtitle: 'Kenny.nl에서 제공한 아이소메트릭 타일 에셋을 프로젝트에 추가합니다.',
source: path.resolve(resourcesPath, 'additional', 'FreeAssets', 'Kenny-isometric.zip'),
namespace: 'Kenny',
url: 'https://www.kenney.nl/',
color: '#2ECC92',
},
{
logo: 'https://www.kenney.nl/data/img/logo.png',
title: 'Kenny Audio',
subtitle: 'Kenny.nl에서 제공한 오디오 에셋을 프로젝트에 추가합니다.',
source: path.resolve(resourcesPath, 'additional', 'FreeAssets', 'Kenny-audio.zip'),
namespace: 'Kenny',
url: 'https://www.kenney.nl/',
color: '#2ECC92',
}
Expand Down
38 changes: 21 additions & 17 deletions src/Renderer/components/Manager/Tool/AssetAppenderCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
:elevation="hover ? 12 : 2"
:class="{ 'on-hover': hover }"
max-width="250"
min-height="400"
class="card-wrapper"
min-height="425"
class="d-flex flex-column card-wrapper"
@click="openExternal(url)"
>
<v-img
:src="logo"
height="250"
width="100%"
min-height="250"
max-height="250"
class="align-end text-h5 white--text font-weight-bold"
:style="{ 'background-color': color }"
>
Expand All @@ -20,11 +22,12 @@

<v-divider />
<v-card-subtitle>{{ subtitle }}</v-card-subtitle>
<v-card-actions class="pt-10 px-3 pb-3 flex-column flex-nowrap">
<v-card-actions class="px-3 pb-3 flex-grow-1 flex-reverse-column align-end">
<v-btn
class="primary--text mx-0"
width="100%"
outlined
large
@click.stop="confirmAppend(namespace)"
>
설치하기
Expand All @@ -50,7 +53,7 @@
설치할 경우 프로젝트의 용량이 <span class="font-weight-bold">{{ calcSize(source).toFixed(2) }}MB</span>만큼 늘어납니다.
</p>
<p>
이 에셋은 <span class="font-weight-bold">Assets/{{ namespace }} </span> 경로를 포함해, 일부 프로젝트 디렉토리를 덮어 씌울 것입니다.
이 에셋은 <span class="font-weight-bold">{{ warnDirectory }}</span> 경로를 덮어 씌울 것입니다.
<br>
해당 경로에 중요한 데이터가 있다면 백업하십시오.
</p>
Expand Down Expand Up @@ -78,7 +81,7 @@
import path from 'path'
import fs from 'fs-extra'
import { shell, ipcRenderer } from 'electron'
import { defineComponent, getCurrentInstance, ref } from '@vue/composition-api'
import { computed, defineComponent, getCurrentInstance, ref } from '@vue/composition-api'
import {
PROJECT_SRC_DIRECTORY_NAME,
Expand Down Expand Up @@ -120,12 +123,20 @@ function useStatSize() {
}
function useAppender() {
const { root } = getCurrentInstance()!
const { root, props } = getCurrentInstance()!
const namespace = props.namespace as string
const source = props.source as string
const projectDirectory = path.resolve(root.proxy.$store.state.projectDirectory)
const isAppendDialogOpen = ref(false)
const appending = ref(false)
const warnDirectory = computed(() => {
const zipName = path.parse(source).name
return path.posix.join('Assets', namespace, zipName)
})
const confirmAppend = () => {
isAppendDialogOpen.value = true
}
Expand All @@ -136,10 +147,9 @@ function useAppender() {
// 임시 폴더에 생성한 후, 완료되면 프로젝트 디렉토리로 이동합니다.
// 이는 압축 해제 시, 파일이 실시간으로 생성되면 리스트 업데이트가 불필요할 정도로 일어나는 것을 방지하기 위함입니다.
const src = source
const dist = path.resolve(projectDirectory, PROJECT_SRC_DIRECTORY_NAME, PROJECT_SRC_ASSET_DIRECTORY_NAME, namespace)
const dist = path.resolve(projectDirectory, PROJECT_SRC_DIRECTORY_NAME, PROJECT_SRC_ASSET_DIRECTORY_NAME, namespace, path.parse(source).name)
const dist_tmp = await fs.mkdtemp(path.resolve(projectDirectory, 'unpackage-'))
const unzip: Engine.FileSystem.UnzipSuccess|Engine.FileSystem.UnzipFail = await ipcRenderer.invoke('unzip', src, dist_tmp)
const unzip: Engine.FileSystem.UnzipSuccess|Engine.FileSystem.UnzipFail = await ipcRenderer.invoke('unzip', src, dist)
const fail = (message: string) => {
root.proxy.$store.dispatch('snackbar', message)
Expand All @@ -151,20 +161,14 @@ function useAppender() {
return fail(unzip.message)
}
try {
await fs.rename(dist_tmp, dist)
} catch (reason) {
const message = reason.toString()
return fail(message)
}
isAppendDialogOpen.value = false
appending.value = false
}
return {
isAppendDialogOpen,
appending,
warnDirectory,
confirmAppend,
append,
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/FileWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class FileWatcher {
// todo: 폴링을 쓰는 이유
// chikidar에서 폴링을 사용하지 않으면 여러 디렉토리가 중첩되어 있을 경우, 상위 디렉토리를 잠그는 오류가 발생함.
// https://github.com/paulmillr/chokidar/issues/320
const watchInterval = 3000
const watchInterval = 1500
this.watcher = chokidar.watch(this.cwd, { ignoreInitial: true, awaitWriteFinish: true, usePolling: true, interval: watchInterval, binaryInterval: watchInterval })
this.watcher.on('add', (filePath) => { this.onUpdate(filePath) })
this.watcher.on('change', (filePath) => { this.onUpdate(filePath) })
Expand Down

0 comments on commit 40dd0a2

Please sign in to comment.