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

Add Korok Type List in Filter Pane #71

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
3 changes: 2 additions & 1 deletion src/MapMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,13 @@ export class MapMarkerKorok extends MapMarkerCanvasImpl {

constructor(mb: MapBase, info: any, extra: any) {
let id = info.id || 'Korok';
extra.styleLabel = (extra.styleLabel !== undefined) ? extra.styleLabel : true;
super(mb, `${id}`, [info.Translate.X, info.Translate.Y, info.Translate.Z], {
icon: KOROK_ICON,
iconWidth: 20,
iconHeight: 20,
showLabel: extra.showLabel,
className: classToColor(id),
className: (extra.styleLabel) ? classToColor(id) : "default",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
className: (extra.styleLabel) ? classToColor(id) : "default",
className: extra.styleLabel ? classToColor(id) : "default",

});
this.info = info;
// @ts-ignore
Expand Down
37 changes: 37 additions & 0 deletions src/MapSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,43 @@ function makeNameQuery(names: string[]): string {
return names.map(x => `name:"^${x}"`).join(' OR ');
}

export const KOROK_TYPES =
[
"Acorn in a Hole",
"Ball and Chain",
"Burn the Leaves",
"Circle of Rocks",
"Cube Puzzle",
"Dive",
"Flower Order",
"Flower Trail",
"Goal Ring",
"Hanging Acorn",
"Jump the Fences",
"Light Torch",
"Matching Trees",
"Melt Ice Block",
"Moving Lights",
"Offering Plate",
"Pinwheel Acorns",
"Pinwheel Balloons",
"Remove Luminous Stone",
"Rock Lift",
"Rock Lift (Boulder)",
"Rock Lift (Door)",
"Rock Lift (Leaves)",
"Rock Lift (Rock Pile)",
"Rock Lift (Slab)",
"Rock Pattern",
"Roll a Boulder",
"Shoot the Crest",
"Shoot the Targets",
"Stationary Balloon",
"Stationary Lights",
"Take Apple from Palm Tree",
"Take the Stick",
];

export const SEARCH_PRESETS: ReadonlyArray<SearchPresetGroup> = Object.freeze([
{
label: '<i class="far fa-gem"></i>',
Expand Down
41 changes: 40 additions & 1 deletion src/components/AppMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as MapIcons from '@/MapIcon';
import * as MapMarkers from '@/MapMarker';
import { MapMarker, SearchResultUpdateMode } from '@/MapMarker';
import { MapMarkerGroup } from '@/MapMarkerGroup';
import { SearchResultGroup, SearchExcludeSet, SEARCH_PRESETS } from '@/MapSearch';
import { SearchResultGroup, SearchExcludeSet, SEARCH_PRESETS, KOROK_TYPES } from '@/MapSearch';
import * as save from '@/save';

import MixinUtil from '@/components/MixinUtil';
Expand Down Expand Up @@ -240,6 +240,9 @@ export default class AppMap extends mixins(MixinUtil) {
private searchResultMarkers: ui.Unobservable<MapMarkers.MapMarkerSearchResult>[] = [];
private searchGroups: SearchResultGroup[] = [];
private searchPresets = SEARCH_PRESETS;
private korokTypes = KOROK_TYPES;
private korokTypeOn = KOROK_TYPES.map(t => false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enabledKorokTypes?

private korokTypeOpen: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "filterOnKorokTypes" -- this name isn't super clear atm

private searchExcludedSets: SearchExcludeSet[] = [];
private readonly MAX_SEARCH_RESULT_COUNT = 2000;

Expand Down Expand Up @@ -804,6 +807,42 @@ export default class AppMap extends mixins(MixinUtil) {
this.search();
}

async addKorokType(name: string, query: string) {
let objs = await MapMgr.getInstance().getObjs(this.settings!.mapType,
this.settings!.mapName, query);
objs.forEach((obj: any) => {
obj.Translate = { X: obj.pos[0], Y: obj.pos[1], Z: obj.pos[2] };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

obj.id = obj.korok_type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Is there no other way of doing this? Not a big fan of overwriting a property with completely unrelated data...

});
let group = new MapMarkerGroup(
objs.map((m: any) =>
new MapMarkers.MapMarkerKorok(this.map, m, {
showLabel: this.showKorokIDs,
styleLabel: false
})),
1.0, false);
this.markerGroups.set(name, group);
group.addToMap(this.map.m);

for (const group of this.markerGroups.values())
group.update();

}

searchToggleGroup(name: string) {
const ROCK_LIFT_QUERY = 'korok_type: "Rock Lift" NOT Leaves NOT Pile NOT Slab NOT Door NOT Boulder';
let query = `korok_type: "${name}"`;
if (name == "Rock Lift") {
query = ROCK_LIFT_QUERY;
}
if (this.markerGroups.has(name)) {
this.markerGroups.get(name)!.destroy();
this.markerGroups.delete(name);
} else {
this.addKorokType(name, query);
}
}

searchRemoveGroup(idx: number) {
const group = this.searchGroups[idx];
group.remove();
Expand Down
8 changes: 8 additions & 0 deletions src/components/AppMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
<AppMapFilterMainButton v-for="(v, type) in markerComponents" :key="type" :type="type" :label="v.filterLabel" :icon="v.filterIcon" @toggle="updateMarkers" />
</div>
<b-checkbox switch v-model="showKorokIDs" @change="updateKorokIDs">Show Korok IDs</b-checkbox>
<b-checkbox v-model="korokTypeOpen" switch >Korok Types</b-checkbox>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<b-checkbox v-model="korokTypeOpen" switch >Korok Types</b-checkbox>
<b-checkbox v-model="korokTypeOpen" switch>Filter Korok Types</b-checkbox>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the UX is somewhat confusing. It's in the filter pane so I would have expected this feature to filter visible Korok markers, not add/remove extra search groups.


<b-collapse id="korokTypesList" class="mt-2" v-model="korokTypeOpen">
<b-card style="background: rgba(0,0,0,0); overflow-y: scroll; max-height: 300px; border:1px solid #333;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the styles into CSS.

<b-checkbox v-for="(ktype, index) in korokTypes" :key="ktype" ref="koroks" v-model="korokTypeOn[index]" :checked=false switch @input='searchToggleGroup(ktype)'>{{ktype}}</b-checkbox>
</b-card>
</b-collapse>

<hr>
<h4 class="subsection-heading">Visible map areas</h4>
<b-radio-group stacked class="mb-4" v-model="shownAreaMap" @change="onShownAreaMapChanged">
Expand Down
1 change: 1 addition & 0 deletions src/components/ObjectInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<span v-if="data.sharp_weapon_judge_type == 4"><i class="far fa-star fa-fw" style="color: tomato"></i> No modifier</span>
</section>
<section class="search-result-link" v-if="link"><i class="fa fa-link fa-fw"></i> Link type: {{link.ltype}}</section>
<section v-if="data.korok_type">Korok Type: {{data.korok_type}}</section>
</div>
</template>
<style lang="less">
Expand Down
4 changes: 4 additions & 0 deletions src/services/MapMgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export interface ObjectMinData {
// Only for weapons and enemies.
scale?: number;
sharp_weapon_judge_type?: number;

// Korok Data
korok_id?: string;
korok_type?: string;
}

export interface ObjectData extends ObjectMinData {
Expand Down