forked from FAForever/downlords-faf-client
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Smart live replays (FAForever#2529)
Co-authored-by: Ivan <v23620@gmail.com>
- Loading branch information
1 parent
a2146cc
commit a4dd4e9
Showing
52 changed files
with
1,307 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/faforever/client/fx/contextmenu/CancelActionNotifyMeMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.faforever.client.fx.contextmenu; | ||
|
||
import com.faforever.client.domain.GameBean; | ||
import com.faforever.client.i18n.I18n; | ||
import com.faforever.client.replay.LiveReplayService; | ||
import com.faforever.client.replay.TrackingLiveReplay; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.faforever.client.replay.TrackingLiveReplayAction.NOTIFY_ME; | ||
|
||
@Component | ||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
@RequiredArgsConstructor | ||
public class CancelActionNotifyMeMenuItem extends AbstractMenuItem<GameBean> { | ||
|
||
private final I18n i18n; | ||
private final LiveReplayService liveReplayService; | ||
|
||
@Override | ||
protected void onClicked() { | ||
liveReplayService.stopTrackingLiveReplay(); | ||
} | ||
|
||
@Override | ||
protected boolean isItemVisible() { | ||
boolean isValid = object != null && object.getStartTime() != null; | ||
if (!isValid) { | ||
return false; | ||
} | ||
|
||
Optional<TrackingLiveReplay> trackingLiveReplayOptional = liveReplayService.getTrackingLiveReplay(); | ||
return trackingLiveReplayOptional.stream().anyMatch(trackingLiveReplay -> trackingLiveReplay.getGameId().equals(object.getId()) | ||
&& trackingLiveReplay.getAction() == NOTIFY_ME); | ||
} | ||
|
||
@Override | ||
protected String getItemText() { | ||
return i18n.get("vault.liveReplays.contextMenu.notifyMe.cancel"); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...in/java/com/faforever/client/fx/contextmenu/CancelActionRunReplayImmediatelyMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.faforever.client.fx.contextmenu; | ||
|
||
import com.faforever.client.domain.GameBean; | ||
import com.faforever.client.i18n.I18n; | ||
import com.faforever.client.replay.LiveReplayService; | ||
import com.faforever.client.replay.TrackingLiveReplay; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.faforever.client.replay.TrackingLiveReplayAction.RUN_REPLAY; | ||
|
||
@Component | ||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
@RequiredArgsConstructor | ||
public class CancelActionRunReplayImmediatelyMenuItem extends AbstractMenuItem<GameBean> { | ||
|
||
private final I18n i18n; | ||
private final LiveReplayService liveReplayService; | ||
|
||
@Override | ||
protected void onClicked() { | ||
liveReplayService.stopTrackingLiveReplay(); | ||
} | ||
|
||
@Override | ||
protected boolean isItemVisible() { | ||
boolean isValid = object != null && object.getStartTime() != null; | ||
if (!isValid) { | ||
return false; | ||
} | ||
|
||
Optional<TrackingLiveReplay> trackingLiveReplayOptional = liveReplayService.getTrackingLiveReplay(); | ||
return trackingLiveReplayOptional.stream().anyMatch(trackingLiveReplay -> trackingLiveReplay.getGameId().equals(object.getId()) | ||
&& trackingLiveReplay.getAction() == RUN_REPLAY); | ||
} | ||
|
||
@Override | ||
protected String getItemText() { | ||
return i18n.get("vault.liveReplays.contextMenu.runReplayImmediately.cancel"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/faforever/client/fx/contextmenu/NotifyMeMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.faforever.client.fx.contextmenu; | ||
|
||
import com.faforever.client.domain.GameBean; | ||
import com.faforever.client.i18n.I18n; | ||
import com.faforever.client.replay.LiveReplayService; | ||
import com.faforever.client.replay.TrackingLiveReplay; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.faforever.client.replay.TrackingLiveReplayAction.NOTIFY_ME; | ||
|
||
@Component | ||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
@RequiredArgsConstructor | ||
public class NotifyMeMenuItem extends AbstractMenuItem<GameBean> { | ||
|
||
private final I18n i18n; | ||
private final LiveReplayService liveReplayService; | ||
|
||
@Override | ||
protected void onClicked() { | ||
liveReplayService.performActionWhenAvailable(object, NOTIFY_ME); | ||
} | ||
|
||
@Override | ||
protected boolean isItemVisible() { | ||
boolean isValid = object != null && object.getStartTime() != null; | ||
if (!isValid) { | ||
return false; | ||
} | ||
|
||
Optional<TrackingLiveReplay> trackingLiveReplayOptional = liveReplayService.getTrackingLiveReplay(); | ||
return trackingLiveReplayOptional.isEmpty() || trackingLiveReplayOptional.stream() | ||
.anyMatch(trackingLiveReplay -> !trackingLiveReplay.getGameId().equals(object.getId()) || trackingLiveReplay.getAction() != NOTIFY_ME); | ||
} | ||
|
||
@Override | ||
protected String getItemText() { | ||
return i18n.get("vault.liveReplays.contextMenu.notifyMe"); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/faforever/client/fx/contextmenu/RunReplayImmediatelyMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.faforever.client.fx.contextmenu; | ||
|
||
import com.faforever.client.domain.GameBean; | ||
import com.faforever.client.i18n.I18n; | ||
import com.faforever.client.replay.LiveReplayService; | ||
import com.faforever.client.replay.TrackingLiveReplay; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.faforever.client.replay.TrackingLiveReplayAction.RUN_REPLAY; | ||
|
||
@Component | ||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
@RequiredArgsConstructor | ||
public class RunReplayImmediatelyMenuItem extends AbstractMenuItem<GameBean> { | ||
|
||
private final I18n i18n; | ||
private final LiveReplayService liveReplayService; | ||
|
||
@Override | ||
protected void onClicked() { | ||
liveReplayService.performActionWhenAvailable(object, RUN_REPLAY); | ||
} | ||
|
||
@Override | ||
protected boolean isItemVisible() { | ||
boolean isValid = object != null && object.getStartTime() != null; | ||
if (!isValid) { | ||
return false; | ||
} | ||
|
||
Optional<TrackingLiveReplay> trackingLiveReplayOptional = liveReplayService.getTrackingLiveReplay(); | ||
return trackingLiveReplayOptional.isEmpty() || trackingLiveReplayOptional.stream() | ||
.anyMatch(trackingLiveReplay -> !trackingLiveReplay.getGameId().equals(object.getId()) || trackingLiveReplay.getAction() != RUN_REPLAY); | ||
} | ||
|
||
@Override | ||
protected String getItemText() { | ||
return i18n.get("vault.liveReplays.contextMenu.runReplayImmediately"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.