Revamp web export page
This commit is contained in:
parent
891e31b139
commit
696643ce18
2 changed files with 415 additions and 1312 deletions
|
@ -50,6 +50,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
|
|||
PACK_MULTIPLE_FILES
|
||||
};
|
||||
|
||||
void _fix_html(Vector<uint8_t>& 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<ImageTexture> 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<PropertyInfo> *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<uint8_t>& html,const String& name,int max_memory) {
|
||||
void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& 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<String> lines=str.split("\n");
|
||||
for(int i=0;i<lines.size();i++) {
|
||||
|
||||
if (lines[i].find("$GODOTTMEM")!=-1) {
|
||||
|
||||
strnew+=lines[i].replace("$GODOTTMEM",itos(max_memory*1024*1024))+"\n";
|
||||
} else if (lines[i].find("$GODOTFS")!=-1) {
|
||||
strnew+=lines[i].replace("$GODOTFS",name+"fs.js")+"\n";
|
||||
} else if (lines[i].find("$GODOTMEM")!=-1) {
|
||||
strnew+=lines[i].replace("$GODOTMEM",name+".mem")+"\n";
|
||||
} else if (lines[i].find("$GODOTJS")!=-1) {
|
||||
strnew+=lines[i].replace("$GODOTJS",name+".js")+"\n";
|
||||
} else {
|
||||
strnew+=lines[i]+"\n";
|
||||
}
|
||||
String current_line = lines[i];
|
||||
current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024));
|
||||
current_line = current_line.replace("$GODOT_FS",p_name+"fs.js");
|
||||
current_line = current_line.replace("$GODOT_MEM",p_name+".mem");
|
||||
current_line = current_line.replace("$GODOT_JS",p_name+".js");
|
||||
current_line = current_line.replace("$GODOT_CANVAS_WIDTH",Globals::get_singleton()->get("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<cs.size();i++) {
|
||||
html[i]=cs[i];
|
||||
p_html[i]=cs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,7 +309,7 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool
|
|||
|
||||
if (file=="godot.html") {
|
||||
|
||||
_fix_html(data,p_path.get_file().basename(),1<<(max_memory+5));
|
||||
_fix_html(data,p_path.get_file().basename(), p_debug);
|
||||
file=p_path.get_file();
|
||||
}
|
||||
if (file=="godotfs.js") {
|
||||
|
@ -335,6 +370,9 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
|
|||
logo = Ref<ImageTexture>( 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;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue