Skip to content

Commit

Permalink
Make nxthemes from command line arguments, updated built in layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
exelix11 committed Jan 2, 2019
1 parent df35534 commit 46a5a2c
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 7 deletions.
8 changes: 4 additions & 4 deletions SwitchThemes/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class Form1 : MaterialSkin.Controls.MaterialForm
List<PatchTemplate> Templates = new List<PatchTemplate>();
Dictionary<string,LayoutPatch> Layouts = new Dictionary<string, LayoutPatch>();

Dictionary<string, string> HomeMenuParts = new Dictionary<string, string>()
public static Dictionary<string, string> HomeMenuParts = new Dictionary<string, string>()
{
{"Home menu", "home"},
{"Lock screen", "lock"},
Expand Down Expand Up @@ -335,7 +335,7 @@ private void HomeMenuPartBox_SelectedIndexChanged(object sender, EventArgs e)
AllLayoutsBox.SelectedIndex = 0;
}

bool ImageToDDS(string fileName, string outPath)
public static bool ImageToDDS(string fileName, string outPath)
{
if (!File.Exists("texconv.exe"))
{
Expand Down Expand Up @@ -370,7 +370,7 @@ bool ImageToDDS(string fileName, string outPath)
}
return true;
}

bool ImageToDDS()
{
var res = ImageToDDS(tbBntxFile.Text, Path.GetTempPath());
Expand Down Expand Up @@ -466,7 +466,7 @@ private void PatchButtonClick(object sender, EventArgs e)
MessageBox.Show("Done");
}

byte[] GenerateDDSPreview(string path)
public static byte[] GenerateDDSPreview(string path)
{
var image = Pfim.Pfim.FromFile(path);
PixelFormat format;
Expand Down
84 changes: 82 additions & 2 deletions SwitchThemes/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using SwitchThemes.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand All @@ -12,11 +14,89 @@ static class Program
/// Punto di ingresso principale dell'applicazione.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
bool ArgsHandled = false;
if (args != null && args.Length != 0)
{
if (args[0].ToLower() == "buildnx")
ArgsHandled = NXThemeFromArgs(args);
else
ArgsHandled = false;
}

if (ArgsHandled)
return;

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

static bool NXThemeFromArgs(string[] args)
{
if (args.Length < 4)
return false;
string Target = args[1];
if (!Form1.HomeMenuParts.Values.Contains(Target))
return false;

string Image = args.Where(x => x.EndsWith(".dds") || x.EndsWith(".jpg") || x.EndsWith(".png") || x.EndsWith("jpeg")).First();
if (Image == null || !File.Exists(Image))
{
Console.WriteLine("No image file !");
return false;
}
string Layout = args.Where(x => x.EndsWith(".json")).First();

string GetArg(string start)
{
var a = args.Where(x => x.StartsWith(start + "=")).First();
if (a == null) return null;
else return a.Split('=')[1];
}

string Name = GetArg("name");
string Author = GetArg("author");
string Output = GetArg("out");
if (Output == null || Output == "")
return false;

if (Name == null || Name.Trim() == "")
{
var info = ThemeInputInfo.Ask();
Name = info.Item1;
Author = info.Item2;
}

LayoutPatch layout = null;
if (Layout != null && File.Exists(Layout))
layout = LayoutPatch.LoadTemplate(File.ReadAllText(Layout));

if (!Image.EndsWith(".dds"))
{
if (Form1.ImageToDDS(Image, Path.GetTempPath()))
Image = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Image) + ".dds");
else return false;
}

var res = SwitchThemesCommon.GenerateNXTheme(
new ThemeFileManifest()
{
Version = 2,
ThemeName = Name,
Author = Author,
Target = Target,
LayoutInfo = layout == null ? "" : layout.PatchName + " by " + layout.AuthorName,
UseCommon5X = true
},
File.ReadAllBytes(Image),
layout?.AsJson(),
Form1.GenerateDDSPreview(Image));

File.WriteAllBytes(Output, res);

return true;
}
}
}
19 changes: 19 additions & 0 deletions SwitchThemesOnline/html/layouts/DogeFl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"PatchName": "All Apps 90% Scale",
"AuthorName": "Such Meme, Many Skill",
"TargetName": "Flaunch.szs",
"Files": [
{
"FileName": "blyt/FlcBtnIconGame.bflyt",
"Patches": [
{
"PaneName": "N_Delete",
"Scale": {
"X": 0.9,
"Y": 0.9
}
},
]
}
]
}
Binary file added SwitchThemesOnline/html/layouts/DogeFl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions SwitchThemesOnline/html/layouts/SideViewHome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"TargetName":"ResidentMenu.szs","PatchName":"sideview home menu","AuthorName":"zaigenshi","Files":[{"FileName":"blyt/RdtBtnCtrl.bflyt","Patches":[{"PaneName":"N_Tip","Scale":{"X":0,"Y":0}},{"PaneName":"B_Hit","Position":{"X":400,"Y":0,"Z":0}}]},{"FileName":"blyt/RdtBtnFullLauncher.bflyt","Patches":[{"PaneName":"N_Tip","Scale":{"X":400,"Y":0}},{"PaneName":"B_Hit","Position":{"X":400,"Y":0,"Z":0}}]},{"FileName":"blyt/RdtBtnSet.bflyt","Patches":[{"PaneName":"N_Tip","Scale":{"X":0,"Y":0}},{"PaneName":"B_Hit","Position":{"X":400,"Y":-120,"Z":0}}]},{"FileName":"blyt/RdtBtnPvr.bflyt","Patches":[{"PaneName":"N_Tip","Scale":{"X":0,"Y":0}},{"PaneName":"B_Hit","Position":{"X":-1200,"Y":-120,"Z":-120}}]},{"FileName":"blyt/RdtBtnMyPage.bflyt","Patches":[{"PaneName":"N_Tip","Scale":{"X":0,"Y":0}},{"PaneName":"B_Hit","Position":{"X":-1220,"Y":-60,"Z":-60}}]},{"FileName":"blyt/RdtBtnIconGame.bflyt","Patches":[{"PaneName":"RootPane","Scale":{"X":0.7,"Y":0.7}},{"PaneName":"B_Hit","Position":{"X":-62,"Y":0,"Z":0}}]},{"FileName":"blyt/RdtBase.bflyt","Patches":[{"PaneName":"N_ScrollArea","Position":{"X":0,"Y":0,"Z":0},"Size":{"X":1210,"Y":784}},{"PaneName":"N_ScrollWindow","Position":{"X":0,"Y":0,"Z":0},"Size":{"X":740,"Y":322}},{"PaneName":"N_GameRoot","Position":{"X":0,"Y":-45,"Z":-45}},{"PaneName":"N_Game","Position":{"X":0,"Y":-65,"Z":-65},"Scale":{"X":0.86,"Y":0.86}},{"PaneName":"N_Icon_00","Position":{"X":15,"Y":325,"Z":325},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_01","Position":{"X":200,"Y":325,"Z":325},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_02","Position":{"X":385,"Y":325,"Z":325},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_03","Position":{"X":570,"Y":325,"Z":325},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_04","Position":{"X":15,"Y":105,"Z":105},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_05","Position":{"X":200,"Y":105,"Z":105},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_06","Position":{"X":385,"Y":105,"Z":105},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_07","Position":{"X":570,"Y":105,"Z":105},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_08","Position":{"X":15,"Y":-115,"Z":-115},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_09","Position":{"X":200,"Y":-115,"Z":-115},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_10","Position":{"X":385,"Y":-115,"Z":-115},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_11","Position":{"X":570,"Y":-115,"Z":-115},"Scale":{"X":0.7,"Y":0.7}},{"PaneName":"N_Icon_12","Position":{"X":694.4,"Y":102.55,"Z":0},"Scale":{"X":0.3,"Y":0.3}},{"PaneName":"N_System","Position":{"X":239,"Y":0,"Z":0},"Scale":{"X":0.6,"Y":0.6}},{"PaneName":"L_BtnNoti","Position":{"X":-565,"Y":-240,"Z":0},"Scale":{"X":0.8,"Y":0.8}},{"PaneName":"L_BtnShop","Position":{"X":-9999,"Y":-9999,"Z":-9999},"Scale":{"X":0,"Y":0}},{"PaneName":"L_BtnPvr","Position":{"X":-565,"Y":390,"Z":0},"Scale":{"X":0.8,"Y":0.8}},{"PaneName":"L_BtnCtrl","Position":{"X":606,"Y":-240,"Z":0},"Scale":{"X":0.8,"Y":0.8}},{"PaneName":"L_BtnSet","Position":{"X":606,"Y":390,"Z":0},"Scale":{"X":0.8,"Y":0.8}},{"PaneName":"L_BtnPow","Position":{"X":-9999,"Y":-9999,"Z":-9999},"Scale":{"X":0,"Y":0}},{"PaneName":"L_ChildLock","Position":{"X":-9999,"Y":0,"Z":0}},{"PaneName":"N_MyPage","Position":{"X":-100,"Y":44,"Z":0},"Scale":{"X":0.75,"Y":0.75}},{"PaneName":"L_BtnAccount_00","Position":{"X":0,"Y":0,"Z":0}},{"PaneName":"L_BtnAccount_01","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_BtnAccount_02","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_BtnAccount_03","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_BtnAccount_04","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_BtnAccount_05","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_BtnAccount_06","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_BtnAccount_07","Position":{"X":-9999,"Y":-9999,"Z":-9999}},{"PaneName":"L_Hud","Position":{"X":816,"Y":385,"Z":0}}]},{"FileName":"blyt/RdtBalloon.bflyt","Patches":[{"PaneName":"T_Main"},{"PaneName":"T_Sub"}]},{"FileName":"blyt/Hud.bflyt","Patches":[{"PaneName":"N_Root","Position":{"X":-456.5,"Y":-640,"Z":0}}]},{"FileName":"blyt/RdtBtnNtf.bflyt","Patches":[{"PaneName":"N_Tip","Scale":{"X":0,"Y":0}},{"PaneName":"B_Hit","Position":{"X":-1200,"Y":0,"Z":0}}]},{"FileName":"blyt/RdtBtnChangeUser.bflyt","Patches":[{"PaneName":"T_00"}]}]}
Binary file modified SwitchThemesOnline/html/layouts/SuchHm.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 46a5a2c

Please sign in to comment.