From 696643ce1827f028864de94f1fc6b340d43dbb0e Mon Sep 17 00:00:00 2001 From: eska Date: Wed, 20 Jan 2016 03:21:29 +0100 Subject: [PATCH] Revamp web export page --- platform/javascript/export/export.cpp | 72 +- tools/html_fs/godot.html | 1655 ++++++------------------- 2 files changed, 415 insertions(+), 1312 deletions(-) diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index c769d2082a6..2a92c02d3d8 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -50,6 +50,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform { PACK_MULTIPLE_FILES }; + void _fix_html(Vector& p_html, const String& p_name, bool p_debug); PackMode pack_mode; @@ -58,6 +59,12 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform { int max_memory; int version_code; + String html_title; + String html_head_include; + String html_font_family; + String html_style_include; + bool html_controls_enabled; + Ref logo; protected: @@ -101,6 +108,16 @@ bool EditorExportPlatformJavaScript::_set(const StringName& p_name, const Varian show_run=p_value; else if (n=="options/memory_size") max_memory=p_value; + else if (n=="html/title") + html_title=p_value; + else if (n=="html/head_include") + html_head_include=p_value; + else if (n=="html/font_family") + html_font_family=p_value; + else if (n=="html/style_include") + html_style_include=p_value; + else if (n=="html/controls_enabled") + html_controls_enabled=p_value; else return false; @@ -119,6 +136,16 @@ bool EditorExportPlatformJavaScript::_get(const StringName& p_name,Variant &r_re r_ret=show_run; else if (n=="options/memory_size") r_ret=max_memory; + else if (n=="html/title") + r_ret=html_title; + else if (n=="html/head_include") + r_ret=html_head_include; + else if (n=="html/font_family") + r_ret=html_font_family; + else if (n=="html/style_include") + r_ret=html_style_include; + else if (n=="html/controls_enabled") + r_ret=html_controls_enabled; else return false; @@ -130,39 +157,47 @@ void EditorExportPlatformJavaScript::_get_property_list( List *p_l p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE,"zip")); p_list->push_back( PropertyInfo( Variant::INT, "options/memory_size",PROPERTY_HINT_ENUM,"32mb,64mb,128mb,256mb,512mb,1024mb")); p_list->push_back( PropertyInfo( Variant::BOOL, "browser/enable_run")); + p_list->push_back( PropertyInfo( Variant::STRING, "html/title")); + p_list->push_back( PropertyInfo( Variant::STRING, "html/head_include",PROPERTY_HINT_MULTILINE_TEXT)); + p_list->push_back( PropertyInfo( Variant::STRING, "html/font_family")); + p_list->push_back( PropertyInfo( Variant::STRING, "html/style_include",PROPERTY_HINT_MULTILINE_TEXT)); + p_list->push_back( PropertyInfo( Variant::BOOL, "html/controls_enabled")); + //p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)")); } -static void _fix_html(Vector& html,const String& name,int max_memory) { +void EditorExportPlatformJavaScript::_fix_html(Vector& p_html, const String& p_name, bool p_debug) { String str; String strnew; - str.parse_utf8((const char*)html.ptr(),html.size()); + str.parse_utf8((const char*)p_html.ptr(),p_html.size()); Vector lines=str.split("\n"); for(int i=0;iget("display/width")); + current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",Globals::get_singleton()->get("display/height")); + current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:Globals::get_singleton()->get("application/name")); + current_line = current_line.replace("$GODOT_HEAD_INCLUDE",html_head_include); + current_line = current_line.replace("$GODOT_STYLE_FONT_FAMILY",html_font_family); + current_line = current_line.replace("$GODOT_STYLE_INCLUDE",html_style_include); + current_line = current_line.replace("$GODOT_CONTROLS_ENABLED",html_controls_enabled?"true":"false"); + current_line = current_line.replace("$GODOT_DEBUG_ENABLED",p_debug?"true":"false"); + strnew += current_line+"\n"; } CharString cs = strnew.utf8(); - html.resize(cs.size()); + p_html.resize(cs.size()); for(int i=9;i( memnew( ImageTexture )); logo->create_from_image(img); max_memory=3; + html_title=""; + html_font_family="arial,sans-serif"; + html_controls_enabled=true; pack_mode=PACK_SINGLE_FILE; } diff --git a/tools/html_fs/godot.html b/tools/html_fs/godot.html index 36761deb906..6176fe7afad 100644 --- a/tools/html_fs/godot.html +++ b/tools/html_fs/godot.html @@ -1,1317 +1,382 @@ - - - - - - Emscripten-Generated Code - - - - - image/svg+xml - + #container { + display: inline-block; /* scale with canvas */ + vertical-align: top; /* prevent extra height */ + position: relative; /* root for absolutely positioned overlay */ + margin: 0; + border: 0 none; + padding: 0; + background-color: #111; + } -
-
Downloading...
+ #canvas { + display: block; + margin: 0 auto; + /* canvas must have border and padding set to zero to + * calculate cursor coordinates correctly */ + border: 0 none; + padding: 0; + } - - Resize canvas - Lock/hide mouse pointer     - - - -
- -
+ /* Status display + * ============== */ - -
- -
- + #status-container { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + } - - - - + #container:hover > #controls { + opacity: 1.0; + transition: opacity 60ms ease-in-out; + } + + #controls > button, + #controls > label { + vertical-align: middle; + margin-left: 2px; + margin-right: 2px; + } + + #controls > label > input[type="checkbox"] { + /* override user agent style */ + margin-left: 0; + } + + label > input { + vertical-align: middle; + } + + #display-output { display: none; } + + + /* Debug output + * ============ */ + + #output { + display: none; + margin: 6px auto; + border: 2px groove grey; + padding: 4px; + outline: none; + text-align: left; + white-space: pre-wrap; + font-size: small; + color: #eee; + background-color: black; + font-family: "Lucida Console", Monaco, monospace; + } + + + /* Export style include + * ==================== */ + + $GODOT_STYLE_INCLUDE + + + +
+ + HTML5 canvas appears to be unsupported in the current browser.
Please try updating or use a different browser. +
+
+ Loading page... +
+
+ + + +
+
+ + + + + + +