public static void UploadSZS(Uint8Array arr) //called from js { DoActionWithloading(() => { byte[] sarc = ManagedYaz0.Decompress(arr.ToArray()); CommonSzs = SARCExt.SARC.UnpackRamN(sarc); sarc = null; while (LayoutsComboBox.LastChild.TextContent != "Don't patch") { LayoutsComboBox.RemoveChild(LayoutsComboBox.LastChild); } targetPatch = SwitchThemesCommon.DetectSarc(CommonSzs, DefaultTemplates.templates); if (targetPatch == null) { Window.Alert("This is not a valid theme file, if it's from a newer firmware it's not compatible with this tool yet"); CommonSzs = null; targetPatch = null; lblDetected.TextContent = ""; return; } lblDetected.TextContent = "Detected " + targetPatch.TemplateName + " " + targetPatch.FirmName; for (int i = 0; i < layoutPatches.Length; i++) { if (layoutPatches[i] != null && layoutPatches[i].IsCompatible(CommonSzs)) { LayoutsComboBox.Add(new HTMLOptionElement() { TextContent = layoutPatches[i].ToString(), Value = i.ToString() }); } } }); }
public static void HomePartBoxOnChange() { if (HomePartBox_NX.SelectedIndex <= 0) { return; } while (LayoutsComboBox_NX.LastChild.TextContent != "Don't patch") { LayoutsComboBox_NX.RemoveChild(LayoutsComboBox_NX.LastChild); } for (int i = 0; i < layoutPatches.Length; i++) { if (layoutPatches[i] != null && (layoutPatches[i].TargetName == null || layoutPatches[i].TargetName.Contains(SwitchThemesCommon.PartToFileName[HomePartBox_NX.Value]))) { LayoutsComboBox_NX.Add(new HTMLOptionElement() { TextContent = layoutPatches[i].ToString(), Value = i.ToString() }); } } }
public static void Main() { if (WorkerSpawn.CheckIsWorker()) { return; } var meta = Document.CreateElement <HTMLMetaElement>("meta"); meta.Name = "viewport"; meta.Content = "width=device-width, initial-scale=1"; Document.Head.AppendChild(meta); displayHost = Document.CreateElement <HTMLDivElement>("div"); displayHost.Style.Height = "100%"; displayHost.Style.Width = "100vw"; displayHost.Style.Display = Display.TableRow; display = new LoopDisplay(displayHost); typePicker = Document.CreateElement <HTMLSelectElement>("select"); typePicker.Add(Document.CreateElement <HTMLOptionElement>("option")); typePicker.Add(Document.CreateElement <HTMLOptionElement>("option")); typePicker.Options[0].Text = "Square"; typePicker.Options[1].Text = "Hexagon3"; typePicker.SelectedIndex = 0; Document.Body.AppendChild(typePicker); Document.Body.AppendChild(Document.CreateTextNode("Size:")); sizeInput = Document.CreateElement <HTMLInputElement>("input"); sizeInput.Placeholder = "10x10"; sizeInput.Type = InputType.Text; Document.Body.AppendChild(sizeInput); difficultyPicker = Document.CreateElement <HTMLSelectElement>("select"); difficultyPicker.Add(Document.CreateElement <HTMLOptionElement>("option")); difficultyPicker.Add(Document.CreateElement <HTMLOptionElement>("option")); difficultyPicker.Add(Document.CreateElement <HTMLOptionElement>("option")); difficultyPicker.Add(Document.CreateElement <HTMLOptionElement>("option")); difficultyPicker.Add(Document.CreateElement <HTMLOptionElement>("option")); difficultyPicker.Add(Document.CreateElement <HTMLOptionElement>("option")); difficultyPicker.Options[0].Text = "Trivial"; difficultyPicker.Options[1].Text = "Easy"; difficultyPicker.Options[2].Text = "Easyish"; difficultyPicker.Options[3].Text = "Moderate"; difficultyPicker.Options[4].Text = "Maybe Harder"; difficultyPicker.Options[5].Text = "Unlimited"; difficultyPicker.SelectedIndex = 1; Document.Body.AppendChild(difficultyPicker); generateButton = Document.CreateElement <HTMLButtonElement>("button"); generateButton.TextContent = "Generate"; generateButton.OnClick = OnClick; Document.Body.AppendChild(generateButton); timer = Document.CreateTextNode("0:00"); Document.Body.AppendChild(timer); Document.Body.AppendChild(Document.CreateElement <HTMLBRElement>("br")); var undoButton = Document.CreateElement <HTMLButtonElement>("button"); undoButton.TextContent = "Undo"; undoButton.OnClick = e => display.Undo(); Document.Body.AppendChild(undoButton); var redoButton = Document.CreateElement <HTMLButtonElement>("button"); redoButton.TextContent = "Redo"; redoButton.OnClick = e => display.Redo(); Document.Body.AppendChild(redoButton); Document.Body.AppendChild(Document.CreateElement <HTMLBRElement>("br")); var fixButton = Document.CreateElement <HTMLButtonElement>("button"); fixButton.TextContent = "Fix"; fixButton.OnClick = e => display.Fix(); Document.Body.AppendChild(fixButton); var unfixButton = Document.CreateElement <HTMLButtonElement>("button"); unfixButton.TextContent = "Unfix"; unfixButton.OnClick = e => display.Unfix(); Document.Body.AppendChild(unfixButton); var revertButton = Document.CreateElement <HTMLButtonElement>("button"); revertButton.TextContent = "Revert"; revertButton.OnClick = e => display.RevertToFix(); Document.Body.AppendChild(revertButton); Document.Body.AppendChild(displayHost); Document.Body.Style.Height = "100vh"; Document.Body.Style.Width = "100vw"; Document.Body.Style.Margin = "0"; Document.Body.Style.Padding = "0"; Document.Body.Style.Display = Display.Table; Document.DocumentElement.Style.Height = "100vh"; Document.DocumentElement.Style.Width = "100vw"; Document.DocumentElement.Style.Margin = "0"; Document.DocumentElement.Style.Padding = "0"; display.Mesh = new Mesh(4, 4, MeshType.Hexagonal3); //display.Mesh.Generate(); display.Mesh = display.Mesh; Window.OnResize = App_Resize; Window.OnKeyDown = display.OnKeyDown; Document.Body.OnLoad = App_Resize; Window.SetTimeout(App_Tick, 100); }