-
Notifications
You must be signed in to change notification settings - Fork 270
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
ACHIEVEMENTS: Support achievements with no matching Steam achievement #1508
base: dev
Are you sure you want to change the base?
Changes from all commits
92ad533
590952d
65626c1
121fe03
dbdbc8d
ea25b24
db1f319
1970d3e
59e2783
562479c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
BASEDIR=$(dirname "$0") | ||
ROOTDIR=$BASEDIR/../../.. | ||
echo $ROOTDIR | ||
rm -rf $ROOTDIR/dist/icons/achievements | ||
mkdir -p $ROOTDIR/dist/icons | ||
cp -r $BASEDIR/real $ROOTDIR/dist/icons/achievements | ||
for i in $ROOTDIR/dist/icons/achievements/*.svg; do | ||
echo $i | ||
# Make background transparent and replace green with black | ||
# The icons will be recolored by css filters matching the player's theme | ||
# MacOS uses FreeBSD-style sed instead of GNU sed | ||
sed -i '' "s/fill:#000000;/fill-opacity: 0%;/g" "$i" | ||
sed -i '' "s/fill:#00ff00;/fill:#000000;/g" "$i" | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
|
||
import { Accordion, AccordionSummary, AccordionDetails, Typography } from "@mui/material"; | ||
|
||
import { Achievement } from "./Achievements"; | ||
|
||
interface IProps { | ||
title: string; | ||
achievements: { achievement: Achievement }[]; | ||
allAchievements?: { achievement: Achievement }[]; | ||
sx?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I would either call this something like "pad", or just pass a full |
||
} | ||
|
||
function steamCount(achievements: { achievement: Achievement }[]): number { | ||
return achievements.filter((entry) => !entry.achievement.NotInSteam).length; | ||
} | ||
|
||
export function AchievementCategory({ | ||
title, | ||
achievements, | ||
allAchievements, | ||
sx, | ||
children, | ||
}: React.PropsWithChildren<IProps>): JSX.Element { | ||
// Most parts of the four categories in the old code were very similar (besides the content of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines can probably be removed. Comments should document the code as it is, not in reference to as it was. It was useful to read right now, though. |
||
// AccordianDetails), with the Acquired category having a few differences, | ||
// although both the Acquired and Locked categories also had an extra prop in the AccordianDetails. | ||
// The 264px minWidth feels scuffed, but fixes an edge case. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please say what the edge case is. |
||
return ( | ||
<Accordion defaultExpanded={!!allAchievements} disableGutters square sx={{ minWidth: "264px" }}> | ||
<AccordionSummary> | ||
{allAchievements ? ( | ||
<Typography variant="h5" sx={{ my: 1 }}> | ||
{title} ({achievements.length}/{allAchievements.length}, {steamCount(achievements)}/ | ||
{steamCount(allAchievements)} for Steam) | ||
</Typography> | ||
) : ( | ||
<Typography variant="h5" color="secondary"> | ||
{title} ({achievements.length} remaining, {steamCount(achievements)} for Steam) | ||
</Typography> | ||
)} | ||
</AccordionSummary> | ||
<AccordionDetails sx={sx ? { pt: 2 } : undefined}>{children}</AccordionDetails> | ||
</Accordion> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import React from "react"; | ||
|
||
import { Theme } from "@mui/material/styles"; | ||
import { AchievementList } from "./AchievementList"; | ||
import { achievements } from "./Achievements"; | ||
import { Typography } from "@mui/material"; | ||
import { Box, Typography } from "@mui/material"; | ||
import { Player } from "@player"; | ||
import { makeStyles } from "tss-react/mui"; | ||
|
||
const useStyles = makeStyles()((theme: Theme) => ({ | ||
const useStyles = makeStyles()({ | ||
root: { | ||
width: 50, | ||
padding: theme.spacing(2), | ||
userSelect: "none", | ||
}, | ||
})); | ||
}); | ||
|
||
export function AchievementsRoot(): JSX.Element { | ||
const { classes } = useStyles(); | ||
return ( | ||
<div className={classes.root} style={{ width: "90%" }}> | ||
<Typography variant="h4">Achievements</Typography> | ||
<AchievementList achievements={Object.values(achievements)} playerAchievements={Player.achievements} /> | ||
<Box mx={2}> | ||
<Typography> | ||
Achievements are persistent rewards for various actions and challenges. A limited number of Bitburner | ||
achievements have corresponding achievements in Steam. | ||
</Typography> | ||
<AchievementList achievements={Object.values(achievements)} playerAchievements={Player.achievements} /> | ||
</Box> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# Adding Achievements | ||
|
||
- Add a .svg in `./assets/Steam/achievements/real` | ||
- Create the achievement in Steam Dev Portal | ||
- Run `sh ./assets/Steam/achievements/pack-for-web.sh` | ||
- Run `node ./tools/fetch-steam-achievements-data DEVKEYHERE` | ||
- Get your key here: https://steamcommunity.com/dev/apikey | ||
- If making a Steam achievement, create the achievement in Steam Dev Portal | ||
- Run `sh ./assets/Steam/achievements/pack-for-web.sh`, or `pack-for-web-mac.sh` for MacOS | ||
- Add an entry in `./src/Achievements/AchievementData.json` -> achievements | ||
- It should match the information for the Steam achievement, if applicable | ||
- Order the new achievement entry thematically | ||
- Add an entry in `./src/Achievements/Achievements.ts` -> achievements | ||
- Commit `./dist/icons/achievements` & `./src/Achievements/AchievementData.json` | ||
- Match the order of achievements in `AchievementData.json` | ||
- Commit `./dist/icons/achievements` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of forking off a whole new script, use the following syntax:
sed -i"" "s/fill:#000000;/fill-opacity: 0%;/g" "$i"
The lack of space after the
-i
is the key here. This works for GNU sed (I tested it); it should work for BSD (aka MacOS) sed as well (you can test).