Skip to content

Commit

Permalink
update blockbreak stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
fhnaumann committed Feb 15, 2024
1 parent 20f2195 commit e64b55d
Show file tree
Hide file tree
Showing 10 changed files with 17,228 additions and 14 deletions.
423 changes: 423 additions & 0 deletions builder_website/src/assets/challenges_schema.json

Large diffs are not rendered by default.

6,542 changes: 6,542 additions & 0 deletions builder_website/src/assets/en_us.json

Large diffs are not rendered by default.

10,175 changes: 10,175 additions & 0 deletions builder_website/src/assets/materials.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions builder_website/src/components/goals/BlockBreakGoal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<Checkbox v-model="collectable.selectAllData.value" input-id="selectAllBlockMats" binary/>
<label for="selectAllBlockMats" class="ml-2">Break all blocks once</label>
</div>
<div>
<Checkbox v-model="fixedOrder" input-id="fixedOrderBlockMats" binary/>
<label for="fixedOrderBlockMats" class="ml-2">Fixed random order</label>
</div>
</div>
</div>
</DefaultGoal>
Expand Down Expand Up @@ -68,5 +72,12 @@ const collectable = useCollectableGoal(
JSONSchemaConfig.BlockBreakGoalConfig.properties.allBlocks.default
)
const defaultFixedOrder = JSONSchemaConfig.BlockBreakGoalConfig.properties.fixedOrder.default
const fixedOrder = ref<boolean>(false)
watch(fixedOrder, newFixedOrder => {
store.goals!.blockbreakGoal!.fixedOrder! = newFixedOrder
})
fixedOrder.value = defaultFixedOrder
</script>
11 changes: 7 additions & 4 deletions builder_website/src/components/goals/CollectableGoalEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
display="chip" :virtual-scroller-options="{ itemSize: 44 }" filter class="w-full md:w-80">
<template #value="slotProps">
<div v-if="slotProps.value" class="flex justify-start items-center space-x-2">
<img class="w-6" :src="'/rendered_items/' + slotProps.value.img_name + '.png'" :alt="slotProps.value" @error="$event.target.src = 'unknown.png'">
<div>{{ slotProps.value.translation_key }}</div>
<img class="w-6" :src="'/rendered_items/' + slotProps.value.img_name" :alt="slotProps.value" @error="$event.target.src = 'unknown.png'">
<div>{{ translation.translate(slotProps.value.translation_key) }}</div>
</div>
</template>
<template #option="slotProps">
<div class="flex justify-start items-center space-x-2">
<img class="w-6" :src="'/rendered_items/' + slotProps.option.img_name + '.png'" :alt="slotProps.option" @error="$event.target.src = 'unknown.png'">
<div>{{ slotProps.option.translation_key }}</div>
<img class="w-6" :src="'/rendered_items/' + slotProps.option.img_name" :alt="slotProps.option" @error="$event.target.src = 'unknown.png'">
<div>{{ translation.translate(slotProps.option.translation_key) }}</div>
</div>
</template>
</Dropdown>
Expand All @@ -29,6 +29,7 @@ import Button from 'primevue/button';
import { ref, defineComponent, toRef, watch, computed } from 'vue'
import { useConfigStore } from '@/main';
import { type DataRow } from '../loadableDataRow';
import { useTranslation } from '../language';
const props = defineProps<{
selectedData: DataRow,
Expand All @@ -44,6 +45,8 @@ const newSelectedMob = computed({
})
const store = useConfigStore().model
const translation = useTranslation()
const kills = ref(1)
watch(kills, (newKills) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
@update:modelValue="$emit('transferDataFromPlaceHolderToNewInstance', selectedData!); selectedData=undefined">
<template #value="slotProps">
<div v-if="slotProps.value" class="flex justify-start items-center space-x-2">
<img class="w-6" :src="'/rendered_items/' + slotProps.value.img_name + '.png'" :alt="slotProps.value" @error="$event.target!.src = 'unknown.png'">
<div>{{ slotProps.value.translation_key }}</div>
<img class="w-6" :src="'/rendered_items/' + slotProps.value.img_name" :alt="slotProps.value" @error="$event.target!.src = 'unknown.png'">
<div>{{ translation.translate(slotProps.value.translation_key) }}</div>
</div>
</template>
<template #option="slotProps">
<div class="flex justify-start items-center space-x-2">
<img class="w-6" :src="'/rendered_items/' + slotProps.option.img_name + '.png'" :alt="slotProps.option" @error="$event.target!.src = 'unknown.png'">
<div>{{ slotProps.option.translation_key }}</div>
<img class="w-6" :src="'/rendered_items/' + slotProps.option.img_name" :alt="slotProps.option" @error="$event.target!.src = 'unknown.png'">
<div>{{ translation.translate(slotProps.option.translation_key) }}</div>
</div>
</template>
</Dropdown>
Expand All @@ -29,6 +29,7 @@ import Button from 'primevue/button';
import { ref, defineComponent, toRef, watch } from 'vue'
import { useConfigStore } from '@/main';
import type { DataRow } from '../loadableDataRow';
import { useTranslation } from '../language';
//const props = defineProps(['possibleMobs', 'collectablePrefix', 'amountPrefix', 'placeHolderText'])
const props = defineProps<{
Expand All @@ -38,6 +39,9 @@ const props = defineProps<{
placeHolderText: string
disabled: boolean
}>()
const translation = useTranslation()
const selectedData = ref<DataRow>()
const kills = 0
// defineEmits(["transferDataFromPlaceHolderToNewInstance"])
Expand Down
14 changes: 13 additions & 1 deletion builder_website/src/components/goals/GoalSelectionEntry.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<button
<Button
class="border-solid border-2 rounded-md bg-blue-500 hover:brightness-125"
:disabled="isActive()"
@click="addDefaultSectionToConfig"
>
<div class="flex items-center max-w-96">
Expand All @@ -23,17 +24,28 @@ import { defineProps } from 'vue'
import { useConfigStore, useDefaultConfigStore } from '@/main'
import type { GoalView } from '../view/goals'
import type { BaseRuleConfig } from '../model/rules';
import type Button from 'primevue/button';
const props = defineProps({
goal: {
type: Object as () => GoalView,
required: true,
},
})
function isActive() {
try {
return store.goals![props.goal.id]
} catch (error) {
return false
}
}
const store = useConfigStore().model
const defaultConfig = useDefaultConfigStore()
function addDefaultSectionToConfig() {
console.log('added default section to', props.goal.id)
store.goals[props.goal.id as keyof BaseRuleConfig] = defaultConfig.goals[props.goal.id as keyof BaseRuleConfig]
isActive()
}
</script>
3 changes: 0 additions & 3 deletions builder_website/src/components/goals/MyGoals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ watch(config.rules, (newRules) => {
function deleteActiveGoal(goalName: GoalName): void {
delete config.goals[goalName]
activeGoalReferences.forEach(reference => {
(reference.value! as any).cleanupFunc
})
}
function showGoalSelection() {
Expand Down
32 changes: 32 additions & 0 deletions builder_website/src/components/language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import lang_en from '../assets/en_us.json'


export type Language = 'en' | 'de'

interface Translations {
[translationKey: string]: {
lang: string
}
}

let selectedLanguage: Language = 'en'

export function useTranslation() {

function translate(translationKey: string): string {
try {
if(selectedLanguage === 'en') {
return lang_en[translationKey as keyof typeof lang_en]
}
else if(selectedLanguage === 'de') {
return 'TODO German language'
}
} catch(error) {
throw new Error(`Failed to get translation key '${translationKey}' for language '${selectedLanguage}'. This is a bug!`)
}
return 'LANGAUGE UNKNOWN'
}

return { translate }

}
19 changes: 17 additions & 2 deletions builder_website/src/components/searchable.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import { ref } from "vue"
import type { BaseGoalConfig, GoalsConfig } from "./model/goals"
import type { GoalsView } from "./view/goals"
import { useConfigStore } from "@/main"

export interface Searchable {
label: string,
}

export function useSearchable(options: Searchable[]) {
const model = useConfigStore().model

const searchFieldValue = ref<string>('')

function getPartialMatches(): Searchable[] {

if(!searchFieldValue.value.trim()) {
return options
}
else {
return options.filter((searchable) => searchable.label.toLowerCase().includes(searchFieldValue.value.toLowerCase()))
return options.filter((searchable) =>
searchable.label.toLowerCase().includes(searchFieldValue.value.toLowerCase())
)
}
}
return { searchFieldValue, getPartialMatches }

function allActiveGoalsAsLabels(goalsView: GoalsView): string[] {
const allGoalsView = Object.values(goalsView.allgoals)
const activeGoals = Object.keys(model.goals!)

return allGoalsView.filter(goalView => activeGoals.includes(goalView.id)).map(goalView => goalView.label)
}

return { searchFieldValue, getPartialMatches, allActiveGoalsAsLabels }
}

0 comments on commit e64b55d

Please sign in to comment.