diff --git a/src/extensions/gamemode_management/actions/settings.ts b/src/extensions/gamemode_management/actions/settings.ts index cf18f91f5..ffde1ab84 100644 --- a/src/extensions/gamemode_management/actions/settings.ts +++ b/src/extensions/gamemode_management/actions/settings.ts @@ -22,6 +22,12 @@ export const addDiscoveredTool = (gameId: string, toolId: string, result: IToolDiscoveryResult) => { return { gameId, toolId, result }; }); +/** + * hide or unhide a game + */ +export const setGameHidden = createAction('SET_GAME_HIDDEN', + (gameId: string, hidden: boolean) => { return { gameId, hidden }; }); + /** * add a search path (path that is searched for game installations) */ diff --git a/src/extensions/gamemode_management/reducers/settings.ts b/src/extensions/gamemode_management/reducers/settings.ts index c6ea1992c..b722a3342 100644 --- a/src/extensions/gamemode_management/reducers/settings.ts +++ b/src/extensions/gamemode_management/reducers/settings.ts @@ -1,6 +1,6 @@ import { IReducerSpec } from '../../../types/IExtensionContext'; import { addDiscoveredGame, addDiscoveredTool, setGameMode } from '../actions/settings'; -import { addSearchPath, removeSearchPath } from '../actions/settings'; +import { addSearchPath, removeSearchPath, setGameHidden } from '../actions/settings'; import update = require('react-addons-update'); /** @@ -15,8 +15,7 @@ export const settingsReducer: IReducerSpec = { // don't replace previously discovered tools as the settings // there may also be user configuration if (state.discovered[payload.id] !== undefined) { - payload.result.tools = Object.assign({}, - payload.result.tools, state.discovered[payload.id].tools); + payload.result = Object.assign({}, state.discovered[payload.id], payload.result); } return update(state, { @@ -36,6 +35,25 @@ export const settingsReducer: IReducerSpec = { }, }); }, + [setGameHidden]: (state, payload) => { + if (!(payload.gameId in state.discovered)) { + return update(state, { + discovered: { + [payload.gameId]: { $set: { + hidden: payload.hidden, + } }, + }, + }); + } else { + return update(state, { + discovered: { + [payload.gameId]: { + hidden: { $set: payload.hidden }, + }, + }, + }); + } + }, [addSearchPath]: (state, payload) => { if (state.searchPaths === undefined) { state = update(state, { diff --git a/src/extensions/gamemode_management/types/IStateEx.ts b/src/extensions/gamemode_management/types/IStateEx.ts index 31f854b98..2828f5a85 100644 --- a/src/extensions/gamemode_management/types/IStateEx.ts +++ b/src/extensions/gamemode_management/types/IStateEx.ts @@ -1,8 +1,9 @@ import { IState } from '../../../types/IState'; export interface IDiscoveryResult { - path: string; - modPath: string; + path?: string; + modPath?: string; + hidden?: boolean; tools?: { [id: string]: IToolDiscoveryResult; }; diff --git a/src/extensions/gamemode_management/util/discovery.ts b/src/extensions/gamemode_management/util/discovery.ts index 6f3f71004..46a6c0b19 100644 --- a/src/extensions/gamemode_management/util/discovery.ts +++ b/src/extensions/gamemode_management/util/discovery.ts @@ -67,6 +67,7 @@ export function quickDiscovery(knownGames: IGame[], onDiscoveredGame: Discovered path: gamePath, modPath: game.queryModPath(), tools: {}, + hidden: false, }); } else { log('debug', 'game not found', game.id); @@ -77,7 +78,6 @@ export function quickDiscovery(knownGames: IGame[], onDiscoveredGame: Discovered onDiscoveredGame(game.id, { path: resolvedPath, modPath: game.queryModPath(), - tools: {}, }); return null; }).catch((err) => { @@ -183,7 +183,6 @@ function testGameDirValid(game: IGame, testPath: string, onDiscoveredGame: Disco onDiscoveredGame(game.id, { path: testPath, modPath: game.queryModPath(), - tools: {}, }); }).catch(() => { log('info', 'invalid', { game: game.id, path: testPath }); diff --git a/src/extensions/gamemode_management/views/GamePicker.tsx b/src/extensions/gamemode_management/views/GamePicker.tsx index 9c06a491c..3debb6e49 100644 --- a/src/extensions/gamemode_management/views/GamePicker.tsx +++ b/src/extensions/gamemode_management/views/GamePicker.tsx @@ -1,14 +1,16 @@ import { IComponentContext } from '../../../types/IComponentContext'; import { IGame } from '../../../types/IGame'; import { ComponentEx, connect, translate } from '../../../util/ComponentEx'; +import getAttr from '../../../util/getAttr'; +import { Button } from '../../../views/TooltipControls'; -import { setGameMode } from '../actions/settings'; +import { setGameHidden, setGameMode } from '../actions/settings'; import { IDiscoveryResult, IDiscoveryState, IGameStored, IStateEx } from '../types/IStateEx'; import GameThumbnail from './GameThumbnail'; import * as React from 'react'; -import { Button, ProgressBar } from 'react-bootstrap'; +import { ProgressBar } from 'react-bootstrap'; import { Fixed, Flex, Layout } from 'react-layout-pane'; import { log } from '../../../util/log'; @@ -25,6 +27,11 @@ interface IConnectedProps { interface IActionProps { onManage: (gameId: string) => void; + onHide: (gameId: string, hidden: boolean) => void; +} + +interface IState { + showHidden: boolean; } /** @@ -32,7 +39,7 @@ interface IActionProps { * * @class GamePicker */ -class GamePicker extends ComponentEx { +class GamePicker extends ComponentEx { public static contextTypes: React.ValidationMap = { api: React.PropTypes.object.isRequired, @@ -44,18 +51,26 @@ class GamePicker extends ComponentEx { super(props); this.state = { - discovery: { - percent: 0, - label: '', - }, + showHidden: false, }; } public render(): JSX.Element { - let { t } = this.props; - const { discovery } = this.props; + const { t, discovery } = this.props; + const { showHidden } = this.state; return ( + +
+ +
+

{ t('Discovered') }

@@ -74,11 +89,13 @@ class GamePicker extends ComponentEx { min={ 0 } max={ 100 } now={ discovery.progress } - label={ `${discovery.directory}` } + label={ discovery.directory } />
- : null; + private renderManageButton() { + const { t, active, game } = this.props; + let buttonId = `manage-${game.id}`; + + if (this.clickHandler === undefined || active) { + return null; + } + + return ( + + ); + } + + private toggleHidden = () => { + const { game, hidden, onHide } = this.props; + onHide(game.id, !hidden); + } + + private renderHideButton() { + const { t, hidden, game } = this.props; + return ( + + ); } } diff --git a/src/extensions/mod_management/modActivation.ts b/src/extensions/mod_management/modActivation.ts index 46111aaa7..bdfecc146 100644 --- a/src/extensions/mod_management/modActivation.ts +++ b/src/extensions/mod_management/modActivation.ts @@ -1,10 +1,10 @@ +import getAttr from '../../util/getAttr'; +import { log } from '../../util/log'; + import { IProfileMod } from '../profile_management/types/IProfile'; import { IMod } from './types/IMod'; import { IModActivator } from './types/IModActivator'; -import getAttr from './util/getAttr'; - -import { log } from '../../util/log'; import * as Promise from 'bluebird'; diff --git a/src/extensions/mod_management/views/HeaderCell.tsx b/src/extensions/mod_management/views/HeaderCell.tsx index a50fa980d..4e7e0de94 100644 --- a/src/extensions/mod_management/views/HeaderCell.tsx +++ b/src/extensions/mod_management/views/HeaderCell.tsx @@ -1,9 +1,9 @@ import { SortDirection } from '../../../types/SortDirection'; +import getAttr from '../../../util/getAttr'; import SortIndicator from '../../../views/SortIndicator'; import { IAttributeState } from '../types/IAttributeState'; import { IModAttribute } from '../types/IModAttribute'; -import getAttr from '../util/getAttr'; import * as React from 'react'; diff --git a/src/extensions/mod_management/views/ModList.tsx b/src/extensions/mod_management/views/ModList.tsx index ac98a308f..6b88824eb 100644 --- a/src/extensions/mod_management/views/ModList.tsx +++ b/src/extensions/mod_management/views/ModList.tsx @@ -1,5 +1,6 @@ import { SortDirection } from '../../../types/SortDirection'; import { ComponentEx, connect, extend, translate } from '../../../util/ComponentEx'; +import getAttr from '../../../util/getAttr'; import { IGameModeSettings } from '../../gamemode_management/types/IStateEx'; @@ -13,7 +14,6 @@ import { IMod } from '../types/IMod'; import { IModAttribute } from '../types/IModAttribute'; import { IStateMods } from '../types/IStateMods'; import { IStateModSettings } from '../types/IStateSettings'; -import getAttr from '../util/getAttr'; import AttributeToggle from './AttributeToggle'; import HeaderCell from './HeaderCell'; diff --git a/src/extensions/mod_management/views/ModRow.tsx b/src/extensions/mod_management/views/ModRow.tsx index 0523e95f5..11aab7ef4 100644 --- a/src/extensions/mod_management/views/ModRow.tsx +++ b/src/extensions/mod_management/views/ModRow.tsx @@ -1,8 +1,9 @@ +import getAttr from '../../../util/getAttr'; + import { IProfileMod } from '../../profile_management/types/IProfile'; import { IMod } from '../types/IMod'; import { IModAttribute } from '../types/IModAttribute'; -import getAttr from '../util/getAttr'; import * as React from 'react'; import { Checkbox } from 'react-bootstrap'; diff --git a/src/extensions/welcome_screen/WelcomeScreen.tsx b/src/extensions/welcome_screen/WelcomeScreen.tsx index 4d92ef190..1e7966430 100644 --- a/src/extensions/welcome_screen/WelcomeScreen.tsx +++ b/src/extensions/welcome_screen/WelcomeScreen.tsx @@ -115,6 +115,10 @@ class WelcomeScreen extends React.Component { let knownTools: ISupportedTool[] = game.supportedTools; + if (knownTools === null) { + return null; + } + return (
{ knownTools.map((tool) => this.renderSupportedTool(game, tool)) } diff --git a/src/extensions/mod_management/util/getAttr.ts b/src/util/getAttr.ts similarity index 100% rename from src/extensions/mod_management/util/getAttr.ts rename to src/util/getAttr.ts