From a17e04016288c226f23f7d9f29e67573d597cc08 Mon Sep 17 00:00:00 2001 From: Forecaster Date: Mon, 26 Jul 2021 17:33:35 +0200 Subject: [PATCH] - Fix ignore lights and ignore walls & doors always being enabled - Add example command output based on form fields --- MCP/usr/pages/default.php | 76 +++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/MCP/usr/pages/default.php b/MCP/usr/pages/default.php index 515467b..e686b83 100644 --- a/MCP/usr/pages/default.php +++ b/MCP/usr/pages/default.php @@ -8,6 +8,11 @@ public static function GetTitle($page_title = "") { } private static $form; + private static $name; + private static $author; + private static $files; + private static $ignore_lights; + private static $ignore_walls_and_doors; private static $path; private static $file; private static $cmd_output; @@ -15,29 +20,30 @@ public static function GetTitle($page_title = "") { public static function Pre() { self::$form = new Form(); - $name = new TextBox("Module Name", array("required" => true, "defaultValue" => "MyModule")); - $author = new TextBox("Module Author", array("placeholder" => "DungeonFog", "description" => "The author the module is credited to. Used for organization within Fantasy Grounds.")); - $files = new FileSelector("df2vtt files", array("acceptedFiles" => array("df2vtt"), "allowMultiple" => true, "minFiles" => 1, "description" => "Max individual file size is 20 MB. Max total file size is 50 MB. A maximum of 20 files can be uploaded at a time.")); - $ignore_lights = new CheckBox("Ignore lights"); - $ignore_walls_and_doors = new CheckBox("Ignore walls & doors"); - self::$form->AddFields(array($name, $author, $files, $ignore_lights, $ignore_walls_and_doors)); + self::$name = new TextBox("Module Name", array("required" => true, "defaultValue" => "MyModule", "onKeyUp" => "on_field_change()")); + self::$author = new TextBox("Module Author", array("placeholder" => "DungeonFog", "description" => "The author the module is credited to. Used for organization within Fantasy Grounds.", "onKeyUp" => "on_field_change()")); + self::$files = new FileSelector("df2vtt files", array("acceptedFiles" => array("df2vtt"), "allowMultiple" => true, "minFiles" => 1, "description" => "Max individual file size is 20 MB. Max total file size is 50 MB. A maximum of 20 files can be uploaded at a time.", "onChange" => "on_field_change()")); + self::$ignore_lights = new CheckBox("Ignore lights", array("onChange" => "on_field_change()")); + self::$ignore_walls_and_doors = new CheckBox("Ignore walls & doors", array("onChange" => "on_field_change()")); + self::$form->AddFields(array(self::$name, self::$author, self::$files, self::$ignore_lights, self::$ignore_walls_and_doors)); if (self::$form->IsSubmitted()) { $session_id = uniqid("", true); $dir_path = __DIR__ . "/../sessions/" . $session_id . "/"; @mkdir($dir_path, 0777, true); - $files->MoveUploadedFiles($dir_path); - $file_list = explode(", ", $files->GetValue()); + file_put_contents($dir_path . "created", time()); + self::$files->MoveUploadedFiles($dir_path); + $file_list = explode(", ", self::$files->GetValue()); - $module_name = $name->GetValue(); + $module_name = self::$name->GetValue(); $auth = ""; - if (!empty($author->GetValue())) - $auth = " -a \"" . $author->GetValue() . "\""; + if (!empty(self::$author->GetValue())) + $auth = " -a \"" . self::$author->GetValue() . "\""; chdir($dir_path); $options = "-v"; - if ($ignore_lights->GetValue() == true) + if (self::$ignore_lights->IsChecked() == true) $options .= "i"; - if ($ignore_walls_and_doors->GetValue() == true) + if (self::$ignore_walls_and_doors->isChecked() == true) $options .= "o"; $cmd = escapeshellcmd("python3 " . __DIR__ . "/../generator_scripts/df2vtt_parser.py $options $auth \"$module_name\" \"" . implode("\" \"", $file_list) . "\"") . " 2>&1"; try { @@ -135,6 +141,42 @@ public static function Content1() { margin-bottom:40px; } +

Hello! Welcome to the Fantasy Grounds module generator for DungeonFog

This page and the generator itself were coded in their entirety by Forecaster, for the benefit of the venn diagram overlap between DungeonFog users and Fantasy Grounds users (such as myself).

You can get started right away by using the form below, or read on for more information!

@@ -194,9 +236,10 @@ public static function Content1() {
For the application version of the module generator see the sections below the form. Get more options and features by downloading the application.
BuildForm(); - elseif (self::$file === false || self::$script_error) { + echo ""; + } elseif (self::$file === false || self::$script_error) { ?>

An error occurred!

Unable to generate module! Please try again!

@@ -237,6 +280,9 @@ public static function Content1() {

The following changelog is for the module generator in general, including this web page, the application and the Python scripts. Changes, features, or fixes unless specified may apply to all of these.

+ 2021-07-26 + Ignore lights and ignore walls & doors is always on in online generator + Add example command output based on form fields 2021-07-20 Improve layout of web page Improve feedback from script when using form