.htmlFile v1.0.0.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.

Introduction

Code

Changelog


.htmlFile v1.0.0.0

A lightweight library that allows you to create, write, and design your own HTML file. It is more faster than .bat to .txt conversion and compatible in Internet Explorer, Google Chrome, Avast Secure Browser, Mozilla Firefox, etc.


Usage


vJass Flavor

Jass Flavor


JASS:
scope Test initializer Initialization

    private function Initialization takes nothing returns nothing
        call HTML.new("HTML\\Design\\Sample1", 13)
        call HTML.print("<center><h1>Save Code</h1>")
        call HTML.print("<br><br><br>")
        call HTML.println("Character")
        call HTML.println("-load ABCD-EFGH-IJKL-MNOP-QRST-UVWX-YZ")
        call HTML.println("<br>Achievements")
        call HTML.println("-load XXXX-XXXX-TTTT-TTTT-QQQQ-WWWS-WW")
        call HTML.print("</center>")
        call HTML.end()
    endfunction

endscope

  • Design GUI
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call HTML_new("SampleGUI\\Hej Hej Monika\\Design\\Sampl1", 10)
      • Custom script: call HTML_print("<center><h1>Save Code</h1>")
      • Custom script: call HTML_print("<br><br><br>")
      • Custom script: call HTML_println("Character")
      • Custom script: call HTML_println("-load ABCD-EFGH-IJKL-MNOP-QRST-UVWX-YZ")
      • Custom script: call HTML_println("<br>Achievements")
      • Custom script: call HTML_println("-load XXXX-XXXX-TTTT-TTTT-QQQQ-WWWS-WW")
      • Custom script: call HTML_print("</center>")
      • Custom script: call HTML_end()



Note


- This library is only works in 1.27 or below. Good Job, Blizzard. You ruined it.
- HTML5 is not supported.


Zinc

Jass


JASS:
//! zinc
library htmlFile { /* v1.0.0.0
*************************************************************************************
*
*   .htmlFile
*      by nel (NELMVN)
*
*   A lightweight library that allows you to create, write, and design your own
*   HTML file. It is more faster than .bat to .txt conversion and compatible in
*   Internet Explorer, Google Chrome, Avast Secure Browser, Mozilla Firefox,
*   etc.
*
************************************************************************************
*
*    struct HTML extends array
*
*        static method new takes string directory, real fontSize returns nothing
*            -   Create a new .html file.
*
*        static method print takes string str returns nothing
*        static method println takes string str returns nothing
*
*        static method end takes nothing returns nothing
*            -   Close the generated .html file.
*
************************************************************************************
*
*    Issues:
*
*        - print() may handle up to 252 characters.
*        - println() may handle up to 248 characters.
*        - Use '<br>' instead of '\r\n' in print() and println().
*
***********************************************************************************/

    public struct HTML[] {
        private static string Directory;

        public {
            static method new( string directory, real fontSize ) {
                PreloadGenClear();
                PreloadGenStart();
           
                debug if( directory == null ) {
                    debug BJDebugMsg("[HTML Error new()] directory is a null.");
                }

                Preload(
                    "<html><body class=\"x\">" +
                    "<style>.x { font-size: 0; }" +
                    ".y { font-size: " + R2S(fontSize) + "; }</style>" +
                    "<div class=\"y\"><!--"
                );

                thistype.Directory = directory;
            }
       
            static method print( string str ) {
                Preload("-->" + str +"<!--");
           
                debug if( StringLength(str) > 252 ) {
                    debug BJDebugMsg("[HTML Error print()] str reached the limit.");
                }
            }

            static method println( string str ) {
                Preload("-->" + str +"<br><!--");

                debug if( StringLength(str) > 248 ) {
                    debug BJDebugMsg("[HTML Error println()] str reached the limit.");
                }
       
            }
            static method end() {
                Preload("--></div></body></html><!--" +
                    "\r\n\r\n\r\nMade by github.com/NELMVN\r\n\r\n\r\n"
                );
                PreloadGenEnd(Directory + ".html");
                thistype.Directory = null;
            }
        }
    }
}
//! endzinc


How to install


  1. Go to the Preferences menu and make sure "Automatically create unknown variables while pasting trigger data" is checked.
  2. Copy and paste the htmlFile Variable Creator and htmlFile trigger to your map.
  3. Go to your htmlFile trigger, copy all the entire codes and paste it to your map's custom script code.
  4. Lastly, delete htmlFile Variable Creator and htmlFile trigger to your map.


JASS:
// v1.0.0.0
// *********************************************************************************
// *
// *   .htmlFile
// *      by nel (NELMVN)
// *
// *   A lightweight library that allows you to create, write, and design your own
// *   HTML file. It is more faster than .bat to .txt conversion and compatible in
// *   Internet Explorer, Google Chrome, Avast Secure Browser, Mozilla Firefox,
// *   etc.
// *
// *********************************************************************************
// *
// *    Functions
// *
// *        function HTML_new takes string directory, real fontSize returns integer
// *            -   Create a new .html file.
// *
// *        function HTML_print takes string str returns nothing
// *        function HTML_println takes string str returns nothing
// *
// *        function HTML_end takes nothing returns nothing
// *            -   Close the generated .html file.
// *
// *********************************************************************************
// *
// *    Issues:
// *
// *        - print() may handle up to 252 characters.
// *        - println() may handle up to 248 characters.
// *        - Use '<br>' instead of '\r\n' in print() and println().
// *
// *********************************************************************************
// *
// *    Note:
// *
// *        Put this on your map's custom script code.
// *
// *********************************************************************************

function HTML_new takes string directory, real fontSize returns nothing
    call PreloadGenClear()
    call PreloadGenStart()
    call Preload("<html><body class=\"x\"><style>.x { font-size: 0; }.y { font-size: " + R2S(fontSize) + "; }</style><div class=\"y\"><!--")
    set udg_HTML_Directory = directory
endfunction

function HTML_print takes string str returns nothing
    call Preload("-->" + str + "<!--")
endfunction

function HTML_println takes string str returns nothing
    call Preload("-->" + str + "<br><!--")
endfunction

function HTML_end takes nothing returns nothing
    call Preload("--></div></body></html><!--\r\n\r\n\r\nMade by github.com/NELMVN\r\n\r\n\r\n")
    call PreloadGenEnd(udg_HTML_Directory + ".html")
    set udg_HTML_Directory = null
endfunction



[ v1.0 ]
- Initial release

Contents

Just another Warcraft III map (Map)

Reviews
MyPad
Review: Notes The use case for this resource is quite ambiguous relating to the World Editor. It appears that only previous versions are supported, due to the exploitation of a now-improbable behavior of the Preload natives. Status: Substandard

Chaosy

Tutorial Reviewer
Level 39
Joined
Jun 9, 2011
Messages
13,087
What is the use case of this?

Designing a HTML page in wc3 sounds beyond redundant.

I guess you would do something like write a html file that visually represent the character, but I would personally find it easier to make the HTML file read from a .txt file.

Also without css usage it will look like dogshit anyway, yes you can use style but that is not ideal since it makes stuff unreadable and is annoying to maintain.

Cool proof of concept I guess.
 

MyPad

Spell Reviewer
Level 20
Joined
May 9, 2014
Messages
1,634
A weird system to submit here (relative to warcraft 3 modding), but this may prove useful for some who would like to understand how the Preload natives work in creating new files.

One thing though, is this capable of overwriting html files or reading them? Writing them alone wouldn't be enough. (Read and write do come together)
 

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
What is the use case of this?
I want to replace my save code text file to this. I don't really like the ugly generated texts from text file.

Also without css usage it will look like dogshit anyway, yes you can use style but that is not ideal since it makes stuff unreadable and is annoying to maintain.
That is main problem here. If I want to make a decent looking html page, I need to write a readable html codes first before I convert them.

One thing though, is this capable of overwriting html files or reading them? Writing them alone wouldn't be enough. (Read and write do come together)
You can overwrite it, but you can't read them via Preloader.
 

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
I'm pissed and disappointed. 1.28+ is no longer able to create any type of file except .txt file in PreloadGenEnd(), nice. Now, I'm going to back to my shitty, ugly notepad. -_-

Do I need to continue this or not? Let me know.
 
There was risk you could write arbitary files in arbitary paths, like in autostart folder of windows. So it's also understandable they cut off some power of the preload function, to counter abusiveness. Though, limiting to wc3 folder would probably be enough, but it's still understandable they whitelist only some file extension, as everything else would be an exploit.
 
Top