Add theme browser page accessible from game options

Removed the themes buttons that were in the ThemeEditorModal and only
left a "Revert to Default" button along with a link to the ThemeBrowser
page.

Split off the buttons into reusable components since they are now used
in two pages.

Display the themes in big cards with a zoomable screenshot. Applying the
theme now shows a toast with an option to undo the action.

The snackbar now allows ReactNode instead of only strings.

- Add link with details on how to create a new theme in the game.
- Add link to the theme-sharing discord channel.
- Add icons to the theme & style buttons in GameOptions
- Add "Theme Editor" button to ThemeBrowser
- Add "Style Editor" button to ThemeBrowser
- Move Styles related files into Themes folder
- Includes a modal that shows a bigger version of the screenshot.
- Change Snackbar to allow for ReactNode as the message
This commit is contained in:
Martin Fournier
2022-01-19 09:49:08 -05:00
parent 61d6e43b37
commit a26b9c8dcf
15 changed files with 294 additions and 41 deletions
+12
View File
@@ -79,6 +79,7 @@ import { RecoveryMode, RecoveryRoot } from "./React/RecoveryRoot";
import { AchievementsRoot } from "../Achievements/AchievementsRoot";
import { ErrorBoundary } from "./ErrorBoundary";
import { Settings } from "../Settings/Settings";
import { ThemeBrowser } from "../Themes/ui/ThemeBrowser";
const htmlLocation = location;
@@ -194,6 +195,9 @@ export let Router: IRouter = {
toAchievements: () => {
throw new Error("Router called before initialization");
},
toThemeBrowser: () => {
throw new Error("Router called before initialization");
},
};
function determineStartPage(player: IPlayer): Page {
@@ -307,6 +311,9 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
toAchievements: () => {
setPage(Page.Achievements);
},
toThemeBrowser: () => {
setPage(Page.ThemeBrowser);
}
};
useEffect(() => {
@@ -471,6 +478,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
mainPage = (
<GameOptionsRoot
player={player}
router={Router}
save={() => saveObject.saveGame()}
export={() => {
// Apply the export bonus before saving the game
@@ -503,6 +511,10 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
mainPage = <AchievementsRoot />;
break;
}
case Page.ThemeBrowser: {
mainPage = <ThemeBrowser router={Router} />;
break;
}
}
return (