Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRetro2033 committed Dec 8, 2024
1 parent b22c68c commit d66bf08
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 142 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
add-command:
"Copy-Item -Path ./src/squirrel3/squirrel/Debug/squirrel.dll -Destination ./scripts/installers/windows/lib/squirrel.dll -Force &&
Copy-Item -Recurse -Path ./scripts/installers/windows/ -Destination ./build/releases/ -Force"
- os: macos-latest
platform: macos
output: arceus.app
path-to-squirrel-library: ./src/squirrel3/squirrel/libsquirrel.so
rename-squirrel-to: squirrel.dylib
# - os: macos-latest
# platform: macos
# output: arceus.app
# path-to-squirrel-library: ./src/squirrel3/squirrel/libsquirrel.so
# rename-squirrel-to: squirrel.dylib
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

# What is Arceus?

Arceus is a brand-new CLI save manager and editor inspired by version control software like Git. It's designed to provide an easy-to-manage location for your game saves.

# Features
Arceus designed from the ground up to be the ultimate save manager and editor for every game under the sun! Not just Pokémon!

## Branch Off Into Different Timelines 🌌

Expand All @@ -27,18 +25,19 @@ Multiple people can play the same game, even if it’s not designed for switchin

## Go Beyond with Add-Ons 📦

Arceus includes Lua (thanks to lua_dardo), enabling you to edit saves for virtually any game easily.

Arceus intergrates Squirrel, enabling anyone to add new functionality to Arceus. Add-ons make it easy to read and write to files, intergrate game launchers like Steam, and so much more!
> [!NOTE]
> In the future, I plan to add built-in functionality for easier transfer tool creation, similar to Pokémon Bank. For now, you’ll need to build your own transfer tools.
## Built-In Hex Editor #️⃣

Arceus includes a CLI hex editor you can use to edit saves, view changes, and test plugins.
Arceus includes a CLI hex editor you can use to edit saves, view changes, and test plugins!

![alt text](images/image.png)

## Tiny Size 📁

Arceus requires no external libraries not already compiled with the app, so it has a small footprint on your computer. And as a bonus—no DLLs to worry about!
Arceus requires no extra downloads to work, and fits into less than three megabytes!

## Cross Platform 🖥️📱

Expand All @@ -60,21 +59,21 @@ Click the badge below to download the latest artifact.
# Planned Features for the Future

## Frontend GUI 🖱️
Create a frontend for Arceus to make it even simpler to use.
Create a GUI frontend for Arceus to make it even simpler to use.

## Save on Close ❌
Whenever you close a game, Arceus will grow a star,” ensuring you can return to a previous save, even if you forget to use Arceus.
Whenever you close a game, Arceus will grow a star from the current, ensuring you can return to a previous save without lifting a finger.

## Cloud Backups ☁️
Transfer your game saves between devices and keep them safe from data loss.

|Planned | Service |
| --- | --- |
|| Google Drive |
|| OneDrive |
| ⚠️ | Dropbox |
| ⚠️ | Self-hosted |
|| iCloud |
|Yes| Google Drive |
|Yes| OneDrive |
| ⚠️ Maybe| Dropbox |
| ⚠️ Maybe| Self-hosted |
|Unlikely| iCloud |

# Use Cases

Expand Down
Binary file added images/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions lib/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension Compression on String {
return replaceFirst("$relativeTo\\", "").fixPath();
}

/// # `String` fromHexToCodes(`String` path)
/// # `String` fromHexToCodes()
/// ## Converts a hex string to character codes.
/// This is used to convert a readable hex string to a character codes, to save space in files.
String fromHexToCodes() {
Expand All @@ -40,13 +40,13 @@ extension Compression on String {
throw Exception("Invalid hex string.");
}

/// # `String` fromCodesToHex(`String` path)
/// # `String` fromCodesToHex()
/// ## Converts character codes to a hex string.
/// This is used to convert character codes to a readable hex string, to decrypt Strings from `fromHexToCodes()`.
String fromCodesToHex() {
String finalString = "";
for (int i = 0; i < length; ++i) {
finalString += codeUnitAt(i).toRadixString(16);
finalString += codeUnitAt(i).toRadixString(16).padLeft(2, "0");
}
return finalString;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/hex_editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class HexEditor {
}
if (_primaryFile.unsavedChanges().containsKey(byteAddress)) {
value = value.brightYellow;
} else if (differences.isChanged(byteAddress)) {
} else if (differences.isModified(byteAddress)) {
value = value.brightCyan;
}
return value;
Expand Down
71 changes: 59 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ Future<dynamic> main(List<String> arguments) async {
runner.addCommand(ConstellationDeleteCommand());
runner.addCommand(UsersCommands());
runner.addCommand(StartServerCommand());
runner.addCommand(TrimCommand());
}
runner.addCommand(DoesConstellationExistCommand());
runner.addCommand(ReadFileCommand());
runner.addCommand(OpenFileCommand());
runner.addCommand(OpenFileInHexCommand());
runner.addCommand(ArceusConstellationsCommand());
runner.addCommand(AddonsCommand());

Expand All @@ -79,6 +80,9 @@ Future<dynamic> main(List<String> arguments) async {
exit(0);
}

/// # `ArceusCommand`
/// ## An abstract class that represents a command for the Arceus CLI.
/// Use `getRest()` to get the user input.
abstract class ArceusCommand extends Command {
String getRest() {
return argResults?.rest.join(" ") ?? "";
Expand All @@ -99,6 +103,10 @@ class CreateConstellationCommand extends ArceusCommand {

@override
void run() {
if (getRest().isEmpty) {
print("Please provide a name for the constellation!");
return;
}
final spinner = CliSpin().start("Creating constellation...");
try {
List<String>? users = argResults?["user"];
Expand All @@ -117,7 +125,14 @@ class CreateConstellationCommand extends ArceusCommand {

class ShowMapConstellationCommand extends ArceusCommand {
@override
String get description => "Get the map of the constellation.";
String get summary => "Shows the map of the constellation.";

@override
String get description => """
Shows the map of the constellation.
The current star is marked with ✨
""";

@override
String get name => "map";
Expand Down Expand Up @@ -149,7 +164,7 @@ class CheckForDifferencesCommand extends ArceusCommand {
text:
" Checking for differences between current directory and provided star...")
.start();
bool result = constellation.checkForDifferences();
bool result = constellation.checkForDifferences(true);
if (!result) {
spinner.success(" No differences found.");
} else {
Expand All @@ -161,8 +176,30 @@ class CheckForDifferencesCommand extends ArceusCommand {

class ConstellationJumpToCommand extends ArceusCommand {
@override
String get description =>
"Jumps to a different star in the constellation. Give a trailing hash to jump to a specific star.";
String get description => """
Jumps to a different star in the constellation.
Give it either a star hash, or use the commands below. Replace X with a number:
- root: Jumps to the root star
- recent: Jumps to the most recent star
- back: Jumps to the parent of the current star. Will be clamped to the root star.
- back X: Will jump to the parent of every star preceeding the current star by X. Will be clamped to the the root star.
- forward`: Will jump to the first child of the current star. Will be clamped to any ending stars.
- forward X: Will jump to the Xth child of the current star. Will be clamped to a vaild index of the current star's children.
- above: Jumps to the sibling above the current star. Will wrap around to lowest star.
- above X: Will jump to the Xth sibling above the current star. Will wrap around to lowest star.
- below: Jumps to the sibling below the current star. Will wrap around to highest star.
- below X: Will jump to the Xth sibling above the current star. Will wrap around to lowest star.
- `next X`: Will jump to the Xth child of the current star. Will be wrapped to a vaild index of the current star's children.
You can also chain multiple commands together by adding a comma between each.
""";

@override
String get summary => "Jumps to a different star in the constellation.";

@override
String get name => "jump";
Expand All @@ -186,7 +223,7 @@ class ConstellationJumpToCommand extends ArceusCommand {
return;
}
}
CliSpin? spinner = CliSpin().start("Jumping to star...");
CliSpin? spinner = CliSpin().start(" Jumping to star...");
if (argResults!.rest.isEmpty) {
spinner.fail(" Please provide a star hash to jump to.");
return;
Expand All @@ -196,7 +233,7 @@ class ConstellationJumpToCommand extends ArceusCommand {
try {
final star = constellation.starmap?[hash] as Star;
star.makeCurrent();
spinner.success("Jumped to star \"${star.name}\".");
spinner.success(" Jumped to star \"${star.name}\".");
if (argResults!["print"]) {
constellation.starmap?.printMap();
}
Expand Down Expand Up @@ -227,15 +264,25 @@ This will fail if there no changes to commit, unless '--force' is provided.""";

@override
void run() {
if (getRest().isEmpty) {
throw Exception("Please provide a name for the new star.");
}
Constellation(path: Arceus.currentPath)
.grow(getRest(), force: argResults!["force"]);
}
}

class TrimCommand extends ArceusCommand {
@override
String get description =>
"Trims the branch at the current star. Will confirm before proceeding, unless --force is provided.";
String get summary => "Trims a star and its parents off of the starmap. ";

@override
String get description => """
Trims the current star and its descendants off of the starmap.
Trimming will discard all changes to tracked files, but will not destroy previous changes.
Will confirm before proceeding, unless --force is provided.
""";
@override
String get name => "trim";

Expand All @@ -248,7 +295,7 @@ class TrimCommand extends ArceusCommand {
if (!argResults!["force"]) {
final confirm = Confirm(
prompt:
"Are you sure you want to trim off the current star? (Will delete the current star and its children.)",
"Are you sure you want to trim off the current star? (Will discard all changes to tracked files.)",
defaultValue: false)
.interact();
if (!confirm) {
Expand Down Expand Up @@ -513,11 +560,11 @@ class ArceusConstellationsCommand extends ArceusCommand {
}
}

class OpenFileCommand extends ArceusCommand {
class OpenFileInHexCommand extends ArceusCommand {
@override
String get description => "Opens a file in the Héx Editor.";
@override
String get name => "open";
String get name => "hex";

@override
Future<void> run() async {
Expand Down
Loading

0 comments on commit d66bf08

Please sign in to comment.