46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
import 'package:flame/game.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import '../packages/game_package_repository.dart';
|
|
import '../scripting/lua_dardo_script_engine.dart';
|
|
import 'flame_lua_game.dart';
|
|
import 'runtime_options.dart';
|
|
|
|
class LuaGameWidget extends StatelessWidget {
|
|
const LuaGameWidget({
|
|
required this.gameId,
|
|
this.packageRepository,
|
|
this.serverUrl,
|
|
this.localeOverride,
|
|
this.runtimeOptions = const RuntimeOptions(),
|
|
super.key,
|
|
});
|
|
|
|
final String gameId;
|
|
final GamePackageRepository? packageRepository;
|
|
final Uri? serverUrl;
|
|
final Locale? localeOverride;
|
|
final RuntimeOptions runtimeOptions;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GameWidget(
|
|
game: FlameLuaGame(
|
|
scriptEngine: LuaDardoScriptEngine(),
|
|
scriptEngineFactory: LuaDardoScriptEngine.new,
|
|
packageRepository:
|
|
packageRepository ??
|
|
(serverUrl == null
|
|
? AssetGamePackageRepository(runtimeOptions: runtimeOptions)
|
|
: RemoteGamePackageRepository(
|
|
baseUri: serverUrl!,
|
|
runtimeOptions: runtimeOptions,
|
|
)),
|
|
gameId: gameId,
|
|
runtimeOptions: runtimeOptions,
|
|
localeOverride: localeOverride,
|
|
),
|
|
);
|
|
}
|
|
}
|