Skip to content

Commit

Permalink
Add textures tab
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 8, 2025
1 parent c0368f1 commit 2360051
Show file tree
Hide file tree
Showing 19 changed files with 450 additions and 412 deletions.
16 changes: 16 additions & 0 deletions api/lib/src/models/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ class SetonixData extends ArchiveData<SetonixData> {
'$kPackTranslationsPath/$locale.json',
utf8.encode(translation.toJson()),
);

Iterable<String> getTextures() => getAssets(kPackTexturesPath);
Map<String, Uint8List> getTexturesData() =>
Map.fromEntries(getTextures().map((e) {
final data = getTexture(e);
if (data == null) return null;
return MapEntry(e, data);
}).nonNulls);

SetonixData setTexture(String texture, Uint8List data) => setAsset(
'$kPackTexturesPath/$texture',
data,
);

SetonixData removeTexture(String texture) =>
removeAsset('$kPackTexturesPath/$texture');
}

class SetonixFile {
Expand Down
4 changes: 2 additions & 2 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ packages:
dependency: "direct main"
description:
path: "packages/lw_file_system_api"
ref: "5ab1b96bea6ef0e0c07629ff4e7152b4437cf8ee"
resolved-ref: "5ab1b96bea6ef0e0c07629ff4e7152b4437cf8ee"
ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
resolved-ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
url: "https://github.com/LinwoodDev/dart_pkgs"
source: git
version: "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
lw_file_system_api:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 5ab1b96bea6ef0e0c07629ff4e7152b4437cf8ee
ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
path: packages/lw_file_system_api
networker:
git:
Expand Down
36 changes: 18 additions & 18 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1013.0)
aws-sdk-core (3.214.0)
aws-partitions (1.1033.0)
aws-sdk-core (3.214.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.174.0)
aws-sdk-s3 (1.177.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -58,17 +58,17 @@ GEM
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-multipart (1.1.0)
multipart-post (~> 2.0)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.225.0)
fastimage (2.4.0)
fastlane (2.226.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -108,7 +108,7 @@ GEM
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty (~> 0.4.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
Expand Down Expand Up @@ -150,12 +150,12 @@ GEM
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.7)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.8.2)
jwt (2.9.3)
json (2.9.1)
jwt (2.10.1)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand All @@ -166,18 +166,18 @@ GEM
nkf (0.2.0)
optparse (0.6.0)
os (1.1.4)
plist (3.7.1)
plist (3.7.2)
public_suffix (6.0.1)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.3.9)
rouge (2.0.7)
rexml (3.4.0)
rouge (3.28.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rubyzip (2.4.1)
screengrab (1.0.0)
fastlane (>= 2.0.0, < 3.0.0)
security (0.1.5)
Expand Down Expand Up @@ -208,8 +208,8 @@ GEM
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty (0.4.0)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)

Expand All @@ -224,4 +224,4 @@ DEPENDENCIES
screengrab

BUNDLED WITH
2.5.23
2.6.2
2 changes: 1 addition & 1 deletion app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
applicationId = "dev.linwood.setonix"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
minSdk = 23
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
Expand Down
40 changes: 19 additions & 21 deletions app/lib/bloc/editor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:typed_data';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:setonix/services/file_system.dart';
import 'package:setonix_api/setonix_api.dart';
Expand Down Expand Up @@ -33,32 +35,28 @@ class EditorCubit extends Cubit<SetonixData> {
_isSaving = false;
}

void removeFigure(String figure) {
emit(state.removeFigure(figure));
}
void removeFigure(String figure) => emit(state.removeFigure(figure));

void setFigure(String figure, FigureDefinition definition) {
emit(state.setFigure(figure, definition));
}
void setFigure(String figure, FigureDefinition definition) =>
emit(state.setFigure(figure, definition));

void removeDeck(String deck) {
emit(state.removeDeck(deck));
}
void removeDeck(String deck) => emit(state.removeDeck(deck));

void setDeck(String deck, DeckDefinition definition) {
emit(state.setDeck(deck, definition));
}
void setDeck(String deck, DeckDefinition definition) =>
emit(state.setDeck(deck, definition));

void removeBackground(String background) {
emit(state.removeBackground(background));
}
void removeBackground(String background) =>
emit(state.removeBackground(background));

void setBackground(String background, BackgroundDefinition definition) {
emit(state.setBackground(background, definition));
}
void setBackground(String background, BackgroundDefinition definition) =>
emit(state.setBackground(background, definition));

void setTranslation(PackTranslation translation,
[String locale = kFallbackLocale]) {
emit(state.setTranslation(translation, locale));
}
[String locale = kFallbackLocale]) =>
emit(state.setTranslation(translation, locale));

void removeTexture(String texture) => emit(state.removeTexture(texture));

void setTexture(String name, Uint8List bytes) =>
emit(state.setTexture(name, bytes));
}
3 changes: 2 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,6 @@
"variations": "Variations",
"offset": "Offset",
"wholeSizeClickCustomize": "Whole size, click to customize",
"clear": "Clear"
"clear": "Clear",
"textures": "Textures"
}
2 changes: 1 addition & 1 deletion app/lib/pages/editor/figures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:setonix/bloc/editor.dart';
import 'package:setonix/pages/editor/texture.dart';
import 'package:setonix/pages/editor/textures.dart';
import 'package:setonix_api/setonix_api.dart';

class FiguresEditorPage extends StatelessWidget {
Expand Down
17 changes: 11 additions & 6 deletions app/lib/pages/editor/shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'package:go_router/go_router.dart';
import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:setonix/bloc/editor.dart';
import 'package:setonix/bloc/settings.dart';
import 'package:setonix/pages/editor/backgrounds.dart';
import 'package:setonix/pages/editor/decks.dart';
import 'package:setonix/pages/editor/figures.dart';
import 'package:setonix/pages/editor/general.dart';
import 'package:setonix/pages/editor/textures.dart';
import 'package:setonix/services/file_system.dart';
import 'package:setonix_api/setonix_api.dart';

Expand All @@ -19,7 +21,8 @@ enum EditorPage {
figures(PhosphorIcons.cube, '/figures'),
decks(PhosphorIcons.stack, '/decks'),
backgrounds(PhosphorIcons.image, '/backgrounds'),
translations(PhosphorIcons.translate, null);
translations(PhosphorIcons.translate, null),
textures(PhosphorIcons.paintBucket, '/textures');

final IconGetter icon;
final String? location;
Expand All @@ -41,6 +44,7 @@ enum EditorPage {
EditorPage.decks => loc.decks,
EditorPage.backgrounds => loc.backgrounds,
EditorPage.translations => loc.translations,
EditorPage.textures => loc.textures,
};
}

Expand All @@ -51,6 +55,7 @@ enum EditorPage {
EditorPage.decks => const DecksEditorPage(),
EditorPage.backgrounds => const BackgroundsEditorPage(),
EditorPage.translations => const GeneralEditorPage(),
EditorPage.textures => const TexturesEditorPage(),
};
}
}
Expand Down Expand Up @@ -140,15 +145,15 @@ class _EditorShellState extends State<EditorShell> {
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
appBar: AppBar(
appBar: WindowTitleBar<SettingsCubit, SetonixSettings>(
title: Text(AppLocalizations.of(context).loading),
),
body: const Center(child: CircularProgressIndicator()),
);
}
if (snapshot.hasError) {
return Scaffold(
appBar: AppBar(
appBar: WindowTitleBar<SettingsCubit, SetonixSettings>(
title: Text(AppLocalizations.of(context).error),
),
body: Center(
Expand All @@ -161,7 +166,7 @@ class _EditorShellState extends State<EditorShell> {
final data = snapshot.data;
if (data == null) {
return Scaffold(
appBar: AppBar(
appBar: WindowTitleBar<SettingsCubit, SetonixSettings>(
title: Text(AppLocalizations.of(context).error),
),
body: Center(
Expand Down Expand Up @@ -189,11 +194,11 @@ class _EditorShellState extends State<EditorShell> {
children: [
if (!isMobile) ...[
EditorNavigatorView(currentPage: currentPage),
const SizedBox(width: 8)
const SizedBox(width: 4)
],
Expanded(
child: Scaffold(
appBar: AppBar(
appBar: WindowTitleBar<SettingsCubit, SetonixSettings>(
title: Text(currentPage.getLocalizedName(context)),
),
drawer: isMobile
Expand Down
54 changes: 0 additions & 54 deletions app/lib/pages/editor/texture.dart

This file was deleted.

Loading

0 comments on commit 2360051

Please sign in to comment.