Skip to content

Commit

Permalink
first working panel version of agsget Editor plugin.
Browse files Browse the repository at this point in the history
Visual Studio duplicated the code when I added the files, so I may need
to reorganize the directories...
  • Loading branch information
ericoporto committed Jan 29, 2020
1 parent fdbe5f2 commit 2a6157c
Show file tree
Hide file tree
Showing 18 changed files with 825 additions and 97 deletions.
13 changes: 0 additions & 13 deletions agsget/agsget/EditorPlugin/AGS.Plugin.AgsGet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AGS.Plugin.AgsGet", "AGS.Plugin.AgsGet\AGS.Plugin.AgsGet.csproj", "{540DA59C-39F9-4B95-B2C0-8458FF7E0B95}"
ProjectSection(ProjectDependencies) = postProject
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B} = {CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "agsgetCore", "..\Core\agsgetCore.csproj", "{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -26,14 +21,6 @@ Global
{540DA59C-39F9-4B95-B2C0-8458FF7E0B95}.Release|Any CPU.Build.0 = Release|Any CPU
{540DA59C-39F9-4B95-B2C0-8458FF7E0B95}.Release|x86.ActiveCfg = Release|x86
{540DA59C-39F9-4B95-B2C0-8458FF7E0B95}.Release|x86.Build.0 = Release|x86
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Debug|x86.ActiveCfg = Release|x86
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Debug|x86.Build.0 = Release|x86
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Release|Any CPU.Build.0 = Release|Any CPU
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Release|x86.ActiveCfg = Release|x86
{CC9603CE-4260-4DA7-BF6C-131DECC5BE5B}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Adventure Game Studio 3.5.0\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand Down
57 changes: 45 additions & 12 deletions agsget/agsget/EditorPlugin/AGS.Plugin.AgsGet/AgsGet.Designer.cs

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;

namespace AgsGetCore.Actions
{
public class ApplyDo
{
public static int Do(Action<string> writerMethod, string changeRunDir, string packageName)
{
BaseFiles.SetRunDirectory(changeRunDir);

//1. If no PACKAGE_NAME is provided, exit with error.
// maybe the required keyword protects and we don't need this
if (string.IsNullOrEmpty(packageName) == true)
{
writerMethod("No Package Specified, will do nothing.");
return 1;
}

//2. Check if the command is run from a folder containing a valid Game.agf project. If not, exit with error.
if (!GameAgfIO.Valid())
{
writerMethod("Not an AGS Game root directory.");
writerMethod("You can only get packages for an AGS Game project.");
return 1;
}

//3. Check if AGS Editor is open by looking for a lockfile in the folder, if it is, exit with error.
if (GameAgfIO.IsProjectOpenOnAGSEditor())
{
writerMethod("AGS Editor is open on project file.");
writerMethod("Close AGS Editor, and try again.");
return 1;
}

//4. Check if a package index exists on `./ ags_packages_cache / package_index`,
// if not, it runs the functionality from `agsget update`.
if(!BaseFiles.ExistsIndexFile())
{
//Update.2.If it is, creates a folder `./ ags_packages_cache /` on the directory if it doesn't exist.
BaseFiles.CreatePackageDirIfDoesntExist();

//Update.3.Downloads the index of packages to `./ ags_packages_cache / package_index`.
//If it already exists, overwrites it.
PackageCacheIO.GetPackageIndex(writerMethod, null);
}

//5. Check if PACKAGE_NAME exists on `./ ags_packages_cache / PACKAGE_NAME`,
// if not, exit with error Download PACKAGE_NAME to `./ ags_packages_cache / PACKAGE_NAME`.
//6.If download doesn't complete, exit with error.
if (!PackageCacheIO.IsPackageOnLocalCache(packageName))
{
//Get.4. Check if PACKAGE_NAME exists on `./ ags_packages_cache / package_index`, if not, exit with error.
if (!PackageCacheIO.PackageOnIndex(packageName))
{
writerMethod(string.Format("Package {0} not found on package index.", packageName));
writerMethod("If you are sure you spelled correctly, try updating your local package index.");
return 1;
}

//Get.5. Download PACKAGE_NAME to `./ags_packages_cache/PACKAGE_NAME`.
if (!PackageCacheIO.GetPackage(
writerMethod,
Configuration.PackageIndexURL,
packageName))
{
writerMethod(string.Format("Error downloading package {0}.", packageName));
return 1;
}
}


//7.Check if a script pair with the same name already exists on Game.agf,
// if there is, ask about update, if the answer is no, exit with error.
if (GameAgfIO.IsScriptPairInserted(packageName))
{
Console.WriteLine("Script already found on Game.agf.");

//TODO: This question must be console on console or a callback to an yes/no GUI, need to figure out how
if (!ConsoleExtra.ConfirmYN("Are you sure you want to replace?"))
{
writerMethod("Package already inserted and will not be replaced.");
return 1;
}
}

//8.Check if script pairs with the same name of dependencies already exists on Game.agf,
// and if they are above insert position, if they are not, exit with error.

//9.If dependencies are already the in Game.agf, ask the user if he
//wants to proceed, if not, exit with error.

//10.Insert or replace the script and dependencies in Game.agf, and
// copy(or overwrite) script pairs in the project folder.


writerMethod("NOT IMPLEMENTED YET");
writerMethod(string.Format("Install Package: '{0}'", packageName));

if (string.IsNullOrEmpty(packageName) == true)
{
writerMethod("No Package Specified, will do nothing.");
return 1;
}

writerMethod("-");
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;

namespace AgsGetCore.Actions
{
public class GetDo
{
public static int Do(Action<string> writerMethod, string changeRunDir, string packageName)
{
BaseFiles.SetRunDirectory(changeRunDir);

//1. If no PACKAGE_NAME is provided, exit with error.
// maybe the required keyword protects and we don't need this
if (string.IsNullOrEmpty(packageName) == true)
{
writerMethod("No Package Specified, will do nothing.");
return 1;
}

//2. Check if the command is run from a folder containing a valid Game.agf project. If not, exit with error.
if (!GameAgfIO.Valid())
{
writerMethod("Not an AGS Game root directory.");
writerMethod("You can only get packages for an AGS Game project.");
return 1;
}

//3. Check if a package index exists on `./ags_packages_cache/package_index`, if not, it runs the functionality from `agsget update`.
if(!BaseFiles.ExistsIndexFile())
{
//Update.2.If it is, creates a folder `./ ags_packages_cache /` on the directory if it doesn't exist.
BaseFiles.CreatePackageDirIfDoesntExist();

//Update.3.Downloads the index of packages to `./ ags_packages_cache / package_index`.
//If it already exists, overwrites it.
PackageCacheIO.GetPackageIndex(writerMethod, null);
}

//4.Check if PACKAGE_NAME exists on `./ ags_packages_cache / package_index`, if not, exit with error.
if (!PackageCacheIO.PackageOnIndex(packageName))
{
writerMethod(string.Format("Package {0} not found on package index.", packageName));
writerMethod("If you are sure you spelled correctly, try updating your local package index.");
return 1;
}

//5. Download PACKAGE_NAME to `./ags_packages_cache/PACKAGE_NAME`.
if(!PackageCacheIO.GetPackage(
writerMethod,
Configuration.PackageIndexURL,
packageName))
{
writerMethod(string.Format("Error downloading package {0}.", packageName));
return 1;
}

return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;

namespace AgsGetCore.Actions
{
public class ListDo
{
public static List<Package> Do(Action<string> writerMethod, string changeRunDir, string packageIndexURL, int pageSize, int pageNumber)
{
BaseFiles.SetRunDirectory(changeRunDir);

if (writerMethod == null) throw new ArgumentNullException(nameof(writerMethod), "was null");

//1. Check if the command is run from a folder containing a valid Game.agf project. If not, exit with error.
if (!GameAgfIO.Valid())
{
writerMethod("Not an AGS Game root directory.");
writerMethod("You can only get packages for an AGS Game project.");
return new List<Package>();
}

//2. Check if a package index exists on `./ags_packages_cache/package_index`, if not, it runs the functionality from `agsget update`.
if (!BaseFiles.ExistsIndexFile())
{
//Update.2.If it is, creates a folder `./ ags_packages_cache /` on the directory if it doesn't exist.
BaseFiles.CreatePackageDirIfDoesntExist();

//Update.3.Downloads the index of packages to `./ ags_packages_cache / package_index`.
//If it already exists, overwrites it.
PackageCacheIO.GetPackageIndex(writerMethod, packageIndexURL);
}

if (!BaseFiles.ExistsIndexFile())
{
return new List<Package>();
}

return PackageCacheIO.PackagesPage(pageNumber, pageSize);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace AgsGetCore.Actions
{
public class PackDo
{
public static int Do(Action<string> writerMethod, string changeRunDir, string pairName)
{
writerMethod("NOT IMPLEMENTED YET");
writerMethod(string.Format("Create Package: '{0}'", pairName));

if (string.IsNullOrEmpty(pairName) == true)
{
writerMethod("No Script Pair Name Specified, will do nothing.");
return 1;
}

writerMethod("-");
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace AgsGetCore.Actions
{
public class SearchDo
{
public static int Do(Action<string> writerMethod, string changeRunDir, string searchQuery)
{
writerMethod("NOT IMPLEMENTED YET");
writerMethod(string.Format("Search query: '{0}'", searchQuery));

if (string.IsNullOrEmpty(searchQuery) == true)
{
writerMethod("No query to use for search.");
return 1;
}

writerMethod("-" );
return 0;
}
}
}
Loading

0 comments on commit 2a6157c

Please sign in to comment.