Skip to content

Commit

Permalink
#19 Use shortname for the stash items (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
angel-git authored Aug 18, 2023
1 parent ca3f7ec commit ee51614
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src-tauri/src/ui_profile/ui_profile_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct Item {
pub struct BsgItem {
pub id: String,
pub name: String,
#[serde(rename = "shortName")]
pub short_name: String,
}

pub fn convert_profile_to_ui(
Expand Down Expand Up @@ -132,17 +134,22 @@ pub fn convert_profile_to_ui(
let item = bsg_items_root.get(k).unwrap();
let id = item.get("_id").unwrap().as_str().unwrap();
if let Some(props) = item.get("_props") {
if let Some(name) = props.get("ShortName") {
let locale_id = format!("{} Name", id);
let maybe_name = locale_root.get(locale_id.as_str());
if let Some(short_name) = props.get("ShortName") {
let maybe_name = locale_root.get(format!("{} Name", id).as_str());
let maybe_short_name = locale_root.get(format!("{} ShortName", id).as_str());
let name = maybe_name
.and_then(|v| v.as_str())
.unwrap_or_else(|| name.as_str().unwrap());
.unwrap_or_else(|| short_name.as_str().unwrap());
let short_name = maybe_short_name
.and_then(|v| v.as_str())
.unwrap_or_else(|| short_name.as_str().unwrap());

bsg_items.insert(
id.to_string(),
BsgItem {
id: id.to_string(),
name: name.to_string(),
short_name: short_name.to_string(),
},
);
}
Expand Down
Binary file modified src/lib/images/5449016a4bdc2d6f028b456f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/lib/images/5696686a4bdc2da3298b456a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/lib/images/569668774bdc2da2298b4568.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/lib/images/unknown.png
Binary file not shown.
17 changes: 15 additions & 2 deletions src/routes/stash/stash-grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
orderedItems = [...tempItems];
bsgItems = profile.bsgItems;
console.log('bsgItems', bsgItems);
}
}
Expand Down Expand Up @@ -93,6 +94,7 @@
class="item-info"
style={`background-color: ${hexStringToCssColor(item.tpl, 0.8)};`}
>
<div class="short-name">{bsgItems[item.tpl].shortName}</div>
{#if item.isFir}
<div class="fir" />
{/if}
Expand Down Expand Up @@ -148,7 +150,7 @@
height: 64px;
width: 64px;
position: relative;
background-image: url($lib/images/unknown.png);
background-image: url($lib/images/empty.png);
}
.item-5449016a4bdc2d6f028b456f {
Expand All @@ -169,9 +171,13 @@
cursor: pointer;
}
.item-clickable:hover {
filter: brightness(120%);
}
.fir {
position: absolute;
top: 2px;
bottom: 2px;
left: 2px;
height: 10px;
width: 10px;
Expand All @@ -189,6 +195,13 @@
height: 100%;
}
.short-name {
font-size: 10px;
position: absolute;
right: 2px;
top: 2px;
}
.empty {
height: 64px;
width: 64px;
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Item {
export interface BsgItem {
id: string;
name: string;
shortName: string;
}

export type Option = 'amount' | 'fir';

0 comments on commit ee51614

Please sign in to comment.