Skip to content

Commit

Permalink
feat: Start to add helldivers
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisL61 committed Nov 15, 2024
1 parent 00098bc commit 752e5b2
Show file tree
Hide file tree
Showing 17 changed files with 279 additions and 4 deletions.
60 changes: 60 additions & 0 deletions api/v1/helldivers/activities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[
{
"id":"ranked",
"name": "_ranked",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_ranked.jpg",
"description": "_ranked_description",
"gamemodes": [
{
"id": "world_tour",
"name": "_world_tour",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_ranked_world_tour.jpg",
"description": "_world_tour_description",
"rpc": "_world_tour_rpc"
},
{
"id": "ranked_cashout",
"name": "_ranked_cashout",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_ranked_cashout.jpg",
"description": "_ranked_cashout_description",
"rpc": "_ranked_cashout_rpc"
}
]
},
{
"id":"casual",
"name": "_casual",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_casual.jpg",
"description": "_casual_description",
"gamemodes": [
{
"id": "casual_quick_cash",
"name": "_casual_quick_cash",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_casual_quick_cash.png",
"description": "_casual_quick_cash_description",
"rpc": "_casual_quick_cash_rpc"
},
{
"id": "casual_bank_it",
"name": "_casual_bank_it",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_casual_bank_it.png",
"description": "_casual_bank_it_description",
"rpc": "_casual_bank_it_rpc"
},
{
"id": "casual_power_shift",
"name": "_casual_power_shift",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_casual_power_shift.png",
"description": "_casual_power_shift_description",
"rpc": "_casual_power_shift_rpc"
},
{
"id": "casual_terminal_attack",
"name": "_casual_terminal_attack",
"image": "https://alexisl61.github.io/Games_RichPresence/assets/the_finals/gamemodes/the_finals_casual_terminal_attack.png",
"description": "_casual_terminal_attack_description",
"rpc": "_casual_terminal_attack_rpc"
}
]
}
]
10 changes: 10 additions & 0 deletions api/v1/helldivers/translations/available_translations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id":"en",
"name":"English"
},
{
"id":"fr",
"name":"Français"
}
]
30 changes: 30 additions & 0 deletions api/v1/helldivers/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"_ranked": "Ranked",
"_ranked_description": "Compete against other players in a ranked match.",
"_casual": "Casual",
"_casual_description": "Play a casual match with your friends.",

"_world_tour": "World Tour",
"_world_tour_description": "Compete in themed cashout.",
"_world_tour_rpc": "Competing in world tour",

"_ranked_cashout": "Tournament",
"_ranked_cashout_description": "Compete in a tournament",
"_ranked_cashout_rpc": "Competing in a tournament",

"_casual_quick_cash": "Quick Cash",
"_casual_quick_cash_description": "3v3v3 cashout",
"_casual_quick_cash_rpc": "In quick cashout",

"_casual_bank_it": "Bank It",
"_casual_bank_it_description": "Bank coins scattered throughout the arena",
"_casual_bank_it_rpc": "Banking coins in bank it",

"_casual_power_shift": "Power Shift",
"_casual_power_shift_description": "Escort a platform through the arena.",
"_casual_power_shift_rpc": "Escorting a platform in power shift",

"_casual_terminal_attack": "Terminal Attack",
"_casual_terminal_attack_description": "Take turns defending and attacking an objective",
"_casual_terminal_attack_rpc": "In terminal attack"
}
6 changes: 6 additions & 0 deletions api/v1/helldivers/translations/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"_ranked": "Classé",
"_ranked_description": "Affrontez d'autres joueurs dans un match classé.",
"_casual": "Non-classé",
"_casual_description": "Jouez un match non-classé avec vos amis."
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:games_richpresence/gen/assets.gen.dart';

class HelldiversBackground extends StatefulWidget {
final Widget child;

const HelldiversBackground({super.key, required this.child});

@override
State<HelldiversBackground> createState() => _HelldiversBackgroundState();
}

class _HelldiversBackgroundState extends State<HelldiversBackground> {
@override
Widget build(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(image: DecorationImage(image: Assets.helldivers.images.background.provider())),
child: widget.child,
);
}
}
19 changes: 19 additions & 0 deletions games_richpresence/lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions games_richpresence/lib/gen/fonts.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion games_richpresence/lib/model/class/games/game_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import 'package:games_richpresence/transformers/activity/the_finals/the_finals_g

enum GameObject {
seaOfThieves("sea_of_thieves", "Sea of Thieves", "Windlass", "992744165802782741"),
theFinals("the_finals", "The Finals", "Poppins", "1277334180354723980");
theFinals("the_finals", "The Finals", "Poppins", "1277334180354723980"),
helldivers("helldivers", "Helldivers 2", "ChakraPetch", "1277334180354723980");

final String id;
final String name;
Expand All @@ -24,6 +25,8 @@ extension GameObjectExtension on GameObject {
return Assets.common.icons.seaOfThievesIcon.path;
case GameObject.theFinals:
return Assets.common.icons.theFinalsIcon.path;
case GameObject.helldivers:
return Assets.common.icons.helldiversIcon.path;
}
}

Expand All @@ -33,6 +36,8 @@ extension GameObjectExtension on GameObject {
return CommonColors.sotBackgroundDark;
case GameObject.theFinals:
return CommonColors.theFinalsBackgroundDark;
case GameObject.helldivers:
return CommonColors.sotBackgroundDark;
}
}

Expand All @@ -42,6 +47,8 @@ extension GameObjectExtension on GameObject {
return CommonColors.sotBackgroundLight;
case GameObject.theFinals:
return CommonColors.theFinalsBackgroundLight;
case GameObject.helldivers:
return CommonColors.sotBackgroundLight;
}
}

Expand All @@ -51,6 +58,8 @@ extension GameObjectExtension on GameObject {
return SeaOfThievesActivityCompanyTransformer();
case GameObject.theFinals:
return TheFinalsGamemodeCategoryTransformer();
case GameObject.helldivers:
return TheFinalsGamemodeCategoryTransformer();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:games_richpresence/model/class/user_data/user_data.dart';
import 'package:games_richpresence/model/class/user_group/helldivers/group.dart';

class HelldiversUserData extends UserData {
HelldiversGroup? group;

String Function(String) onlineTranslate;

HelldiversUserData({this.group, required this.onlineTranslate});

@override
String? getRpcDetails() {
throw UnimplementedError();
}

@override
String? getRpcLargeImageKey() {
throw UnimplementedError();
}

@override
String? getRpcLargeImageText() {
throw UnimplementedError();
}

@override
String? getRpcSmallImageKey() {
throw UnimplementedError();
}

@override
String? getRpcSmallImageText() {
throw UnimplementedError();
}

@override
String? getRpcState() {
throw UnimplementedError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ class TheFinalsUserData extends UserData {

@override
String? getRpcLargeImageText() {
gamemode?.name.let((name) {
return gamemode?.name.let((name) {
return onlineTranslate(name);
});
return null;
}

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class HelldiversGroup {
int groupSize;

HelldiversGroup({required this.groupSize});
}
33 changes: 33 additions & 0 deletions games_richpresence/lib/pages/helldivers/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:games_richpresence/components/helldivers/background/background.dart';
import 'package:games_richpresence/model/class/user_data/user_data.dart';
import 'package:games_richpresence/model/mvvm/widget_event_observer.dart';
import 'package:games_richpresence/pages/helldivers/home/home_page_view_model.dart';

class HelldiversHomePage extends StatefulWidget {
final Function(UserData) updateRpc;
const HelldiversHomePage({super.key, required this.updateRpc});

@override
State<HelldiversHomePage> createState() => _HelldiversHomePageState();
}

class _HelldiversHomePageState extends WidgetEventObserver<HelldiversHomePage> {
late HelldiversHomePageViewModel viewModel;

@override
void initState() {
// TODO: implement initState
super.initState();
viewModel = HelldiversHomePageViewModel(updateRpc: widget.updateRpc);
viewModel.subscribe(this);
}

@override
Widget build(BuildContext context) {
return HelldiversBackground(
child: Column(
children: [],
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:games_richpresence/model/class/game_activities/the_finals/gamemode.dart';
import 'package:games_richpresence/model/class/user_data/the_finals_user_data.dart';
import 'package:games_richpresence/model/class/user_data/user_data.dart';
import 'package:games_richpresence/model/class/user_group/the_finals/group.dart';
import 'package:games_richpresence/model/mvvm/view_events/push_route_event.dart';
import 'package:games_richpresence/model/mvvm/view_model.dart';
import 'package:games_richpresence/pages/the_finals/gamemodes/gamemodes_categories_page.dart';
import 'package:games_richpresence/pages/the_finals/group/group_page.dart';
import 'package:games_richpresence/services/online_translation_service.dart';
import 'package:get_it/get_it.dart';

class HelldiversHomePageViewModel extends EventViewModel {
late TheFinalsUserData userData;

final GetIt getIt = GetIt.instance;
late OnlineTranslationsService translationService;
Function(UserData) updateRpc;

HelldiversHomePageViewModel({OnlineTranslationsService? translationService, required this.updateRpc}) {
this.translationService = translationService ?? getIt.get<OnlineTranslationsService>();
userData = TheFinalsUserData(group: null, onlineTranslate: this.translationService.onlineTranslate);
}

void onGroupClicked() async {
userData.group = await notify(PushRouteEvent(TheFinalsGroupPage.route)) as TheFinalsGroup?;
notify();
updateRpc(userData);
}

void onActivityClick() async {
userData.gamemode = await notify(const PushRouteEvent(TheFinalsGamemodesCategoriesPage.route)) as TheFinalsGamemode?;
notify();
updateRpc(userData);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:games_richpresence/model/class/game_activities/the_finals/gamemode.dart';
import 'package:games_richpresence/model/class/game_activities/the_finals/gamemode_category.dart';
import 'package:games_richpresence/model/class/user_data/the_finals_user_data.dart';
import 'package:games_richpresence/model/class/user_data/user_data.dart';
import 'package:games_richpresence/model/class/user_group/the_finals/group.dart';
Expand Down
4 changes: 4 additions & 0 deletions games_richpresence/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ flutter:
- assets/sea_of_thieves/icons/
- assets/sea_of_thieves/separator/
- assets/the_finals/images/
- assets/helldivers/images/
- assets/translations/

fonts:
Expand All @@ -63,3 +64,6 @@ flutter:
- family: Poppins
fonts:
- asset: assets/the_finals/fonts/poppins.ttf
- family: ChakraPetch
fonts:
- asset: assets/helldivers/fonts/chakrapetch.ttf

0 comments on commit 752e5b2

Please sign in to comment.