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

fuzzy searching improvments and also actuall entries #29

Merged
merged 5 commits into from
Dec 29, 2024
Merged
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
8 changes: 4 additions & 4 deletions Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ private void OnGridViewRecipeSelected(object? sender, ConstructionPrototype? rec
PopulateInfo(_selected);
}

private int CheckFuzzySearch(string hostfield,string searchtext){// return an int for futureproofing, if you wanted to sort by likeness, or something. doesn't matter much now, ints are compatible with boolean logic, anyways.
private bool CheckFuzzySearch(string hostfield,string searchtext){
int matchedtokens=0;
char[] str_seps={' ',':','.',',','/'}; //flatten punctuation.
char[] str_seps={' ',':','.',',','/','-'}; //flatten punctuation.
string[] searchtokens = searchtext.Split(str_seps); //turn the search into tokens

foreach (string stoken in searchtokens){
if(hostfield.Contains(stoken,StringComparison.OrdinalIgnoreCase)) matchedtokens++; //thanks chatGPT for helping me.
}

return matchedtokens;
return matchedtokens==searchtokens.Length;
}


Expand Down Expand Up @@ -205,7 +205,7 @@ private void OnViewPopulateRecipes(object? sender, (string search, string catago

if (!string.IsNullOrEmpty(search))
{
if ( fuzzySearch? CheckFuzzySearch( string.IsNullOrEmpty(recipe.FuzzyName) ? recipe.Name : recipe.FuzzyName,search)==0 :(!recipe.Name.ToLowerInvariant().Contains(search.Trim().ToLowerInvariant())))
if ( fuzzySearch? !CheckFuzzySearch( string.IsNullOrEmpty(recipe.FuzzyName) ? recipe.Name : recipe.FuzzyName,search) :(!recipe.Name.ToLowerInvariant().Contains(search.Trim().ToLowerInvariant())))
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Recipes/Construction/clothing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: construction
name: clown hardsuit
fuzzyname: harsuit eva clown
id: ClownHardsuit
graph: ClownHardsuit
startNode: start
Expand All @@ -11,6 +12,7 @@

- type: construction
name: mime hardsuit
fuzzyname: harsuit eva mime
id: MimeHardsuit
graph: MimeHardsuit
startNode: start
Expand Down Expand Up @@ -77,6 +79,7 @@

- type: construction
name: medsec hud
fuzzyname: hud medical security medsec glasses
id: ClothingEyesHudMedSec
graph: HudMedSec
startNode: start
Expand All @@ -99,6 +102,7 @@

- type: construction
name: security glasses
fuzzyname: security hud glasses
id: ClothingEyesGlassesSecurity
graph: GlassesSecHUD
startNode: start
Expand Down
17 changes: 17 additions & 0 deletions Resources/Prototypes/Recipes/Construction/furniture.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#chairs
- type: construction
name: chair
fuzzyname: chair
id: Chair
graph: Seat
startNode: start
Expand All @@ -18,6 +19,7 @@

- type: construction
name: stool
fuzzyname: chair stool
id: Stool
graph: Seat
startNode: start
Expand All @@ -35,6 +37,7 @@

- type: construction
name: bar stool
fuzzyname: chair stool bar
id: StoolBar
graph: Seat
startNode: start
Expand All @@ -52,6 +55,7 @@

- type: construction
name: brass chair
fuzzyname: chair brass
id: ChairBrass
graph: Seat
startNode: start
Expand All @@ -69,6 +73,7 @@

- type: construction
name: office chair
fuzzyname: chair office
id: ChairOfficeLight
graph: Seat
startNode: start
Expand All @@ -86,6 +91,7 @@

- type: construction
name: dark office chair
fuzzyname: chair office dark
id: ChairOfficeDark
graph: Seat
startNode: start
Expand All @@ -103,6 +109,7 @@

- type: construction
name: comfy chair
fuzzyname: chair comfy
id: ChairComfy
graph: Seat
startNode: start
Expand All @@ -120,6 +127,7 @@

- type: construction
name: pilots chair
fuzzyname: chair pilots
id: chairPilotSeat
graph: Seat
startNode: start
Expand All @@ -137,6 +145,7 @@

- type: construction
name: wooden chair
fuzzyname: chair wooden
id: ChairWood
graph: Seat
startNode: start
Expand Down Expand Up @@ -205,6 +214,7 @@

- type: construction
name: steel bench
fuzzyname: chair steel bench
id: ChairSteelBench
graph: Seat
startNode: start
Expand All @@ -222,6 +232,7 @@

- type: construction
name: wooden bench
fuzzyname: chair wooden bench
id: ChairWoodBench
graph: Seat
startNode: start
Expand All @@ -239,6 +250,7 @@

- type: construction
name: comfortable red bench
fuzzyname: chair comfortable bench red
id: RedComfBench
graph: Seat
startNode: start
Expand All @@ -256,6 +268,7 @@

- type: construction
name: comfortable blue bench
fuzzyname: chair comfortable bench blue
id: BlueComfBench
graph: Seat
startNode: start
Expand Down Expand Up @@ -376,6 +389,7 @@

- type: construction
name: wood table
fuzzyname: table wooden
id: TableWood
graph: Table
startNode: start
Expand Down Expand Up @@ -580,6 +594,7 @@

- type: construction
name: wood counter
fuzzyname: counter wooden
id: TableCounterWood
graph: Table
startNode: start
Expand All @@ -598,6 +613,7 @@
#bathroom
- type: construction
name: toilet
fuzzyname: chair toilet
id: ToiletEmpty
graph: Toilet
startNode: start
Expand Down Expand Up @@ -668,6 +684,7 @@
- type: construction
id: Dresser
name: dresser
fuzzyname: dresser wooden
description: Wooden dresser, can store things inside itself.
graph: Dresser
startNode: start
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Recipes/Construction/machines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: construction
name: computer
fuzzyname: computer frame
id: Computer
graph: Computer
startNode: start
Expand Down
24 changes: 24 additions & 0 deletions Resources/Prototypes/Recipes/Construction/structures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: construction
name: girder
fuzzyname: girder wall
id: Girder
graph: Girder
startNode: start
Expand All @@ -18,6 +19,7 @@

- type: construction
name: reinforced girder
fuzzyname: girder wall reinforced
id: ReinforcedGirder
graph: Girder
startNode: start
Expand Down Expand Up @@ -54,6 +56,7 @@

- type: construction
name: wall
fuzzyname: wall metal
id: Wall
graph: Girder
startNode: start
Expand Down Expand Up @@ -306,6 +309,7 @@

- type: construction
name: grille
fuzzyname: grille metal
id: Grille
graph: Grille
startNode: start
Expand Down Expand Up @@ -342,6 +346,7 @@

- type: construction
name: diagonal grille
fuzzyname: grille diagonal metal
id: GrilleDiagonal
graph: GrilleDiagonal
startNode: start
Expand Down Expand Up @@ -376,6 +381,7 @@

- type: construction
name: window
fuzzyname: glass window
id: Window
graph: Window
startNode: start
Expand All @@ -395,6 +401,7 @@

- type: construction
name: diagonal window
fuzzyname: glass window diagonal
id: WindowDiagonal
graph: WindowDiagonal
startNode: start
Expand All @@ -413,6 +420,7 @@

- type: construction
name: reinforced window
fuzzyname: glass window reinforced
id: ReinforcedWindow
graph: Window
startNode: start
Expand All @@ -432,6 +440,7 @@

- type: construction
name: diagonal reinforced window
fuzzyname: glass window reinforced diagonal
id: ReinforcedWindowDiagonal
graph: WindowDiagonal
startNode: start
Expand All @@ -450,6 +459,7 @@

- type: construction
name: tinted window
fuzzyname: glass window tinted
id: TintedWindow
graph: Window
startNode: start
Expand Down Expand Up @@ -599,6 +609,7 @@

- type: construction
name: directional window
fuzzyname: glass directional window
id: WindowDirectional
graph: WindowDirectional
startNode: start
Expand All @@ -617,6 +628,7 @@

- type: construction
name: directional reinforced window
fuzzyname: glass directional window reinforced
id: WindowReinforcedDirectional
graph: WindowDirectional
startNode: start
Expand Down Expand Up @@ -763,6 +775,7 @@

- type: construction
name: firelock
fuzzyname: firelock atmospherics
id: Firelock
graph: Firelock
startNode: start
Expand All @@ -781,6 +794,7 @@

- type: construction
name: glass firelock
fuzzyname: firelock atmospherics glass
id: FirelockGlass
graph: Firelock
startNode: start
Expand All @@ -799,6 +813,7 @@

- type: construction
name: thin firelock
fuzzyname: firelock atmospherics thin
id: FirelockEdge
graph: Firelock
startNode: start
Expand Down Expand Up @@ -1263,6 +1278,7 @@
#Airlocks
- type: construction
name: airlock
fuzzyname: airlock door
id: Airlock
graph: Airlock
startNode: start
Expand All @@ -1280,6 +1296,7 @@

- type: construction
name: glass airlock
fuzzyname: airlock door glass
id: AirlockGlass
graph: Airlock
startNode: start
Expand All @@ -1297,6 +1314,7 @@

- type: construction
name: pinion airlock
fuzzyname: airlock door pinion
id: PinionAirlock
graph: PinionAirlock
startNode: start
Expand All @@ -1314,6 +1332,7 @@

- type: construction
name: glass pinion airlock
fuzzyname: airlock door pinion glass
id: PinionAirlockGlass
graph: PinionAirlock
startNode: start
Expand All @@ -1331,6 +1350,7 @@

- type: construction
name: shuttle airlock
fuzzyname: airlock door shuttle
id: AirlockShuttle
graph: AirlockShuttle
startNode: start
Expand All @@ -1349,6 +1369,7 @@

- type: construction
name: glass shuttle airlock
fuzzyname: airlock door shuttle glass
id: AirlockGlassShuttle
graph: AirlockShuttle
startNode: start
Expand All @@ -1367,6 +1388,7 @@

- type: construction
name: windoor
fuzzyname: door window windoor glass
id: Windoor
graph: Windoor
startNode: start
Expand All @@ -1384,6 +1406,7 @@

- type: construction
name: secure windoor
fuzzyname: door window windoor glass secure locked
id: SecureWindoor
graph: Windoor
startNode: start
Expand All @@ -1401,6 +1424,7 @@

- type: construction
name: clockwork windoor
fuzzyname: door window windoor clockwork
id: ClockworkWindoor
graph: Windoor
startNode: start
Expand Down
Loading
Loading