summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/SCsub168
-rw-r--r--tools/collada/SCsub2
-rw-r--r--tools/dist/html_fs/godot.html374
-rw-r--r--tools/dist/uwp_template/AppxManifest.xml2
-rw-r--r--tools/doc/SCsub2
-rw-r--r--tools/editor/SCsub158
-rw-r--r--tools/editor/editor_run_native.cpp23
-rw-r--r--tools/editor/fileserver/SCsub2
-rw-r--r--tools/editor/icons/2x/icon_script_create.pngbin0 -> 541 bytes
-rw-r--r--tools/editor/icons/SCsub128
-rw-r--r--tools/editor/icons/icon_script_create.pngbin0 -> 341 bytes
-rw-r--r--tools/editor/icons/source/icon_script_create.svg96
-rw-r--r--tools/editor/io_plugins/SCsub2
-rw-r--r--tools/editor/io_plugins/editor_import_collada.cpp92
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp2
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.h1
-rw-r--r--tools/editor/plugins/SCsub2
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/script_text_editor.cpp8
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp8
-rw-r--r--tools/editor/project_manager.cpp49
-rw-r--r--tools/editor/project_manager.h2
-rw-r--r--tools/editor/scene_tree_dock.cpp141
-rw-r--r--tools/editor/scene_tree_dock.h7
-rw-r--r--tools/editor/script_create_dialog.cpp124
-rw-r--r--tools/editor/script_create_dialog.h4
-rw-r--r--tools/scripts/addheader.py70
-rwxr-xr-xtools/scripts/file-hex-array.py60
-rw-r--r--tools/scripts/make_bmfhdr.py111
-rw-r--r--tools/scripts/make_glwrapper.py143
-rw-r--r--tools/scripts/makeargs.py36
-rw-r--r--tools/scripts/memsort.py36
-rw-r--r--tools/scripts/svgs_2_pngs.py45
-rwxr-xr-xtools/translations/extract.py132
34 files changed, 892 insertions, 1139 deletions
diff --git a/tools/SCsub b/tools/SCsub
index b0b33d4f01..43cad794d4 100644
--- a/tools/SCsub
+++ b/tools/SCsub
@@ -2,124 +2,120 @@
Import('env')
-env.tool_sources=[]
-env.add_source_files(env.tool_sources,"*.cpp")
+env.tool_sources = []
+env.add_source_files(env.tool_sources, "*.cpp")
Export('env')
-def make_translations_header(target,source,env):
+def make_translations_header(target, source, env):
+ dst = target[0].srcnode().abspath
- dst = target[0].srcnode().abspath
+ g = open(dst, "wb")
- g = open(dst,"wb")
-
-
- """"
+ """"
"""
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_TRANSLATIONS_H\n")
- g.write("#define _EDITOR_TRANSLATIONS_H\n")
-
- import zlib
- import os.path
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _EDITOR_TRANSLATIONS_H\n")
+ g.write("#define _EDITOR_TRANSLATIONS_H\n")
- paths = [node.srcnode().abspath for node in source]
- sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0])
+ import zlib
+ import os.path
- xl_names=[]
- for i in range(len(sorted_paths)):
- print("Appending translation: "+sorted_paths[i])
- f = open(sorted_paths[i],"rb")
- buf = f.read()
- decomp_size = len(buf)
- buf = zlib.compress(buf)
- name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
+ paths = [node.srcnode().abspath for node in source]
+ sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0])
- #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n")
- #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n")
- g.write("static const unsigned char _translation_"+name+"_compressed[]={\n")
- for i in range(len(buf)):
- g.write(str(ord(buf[i]))+",\n")
+ xl_names = []
+ for i in range(len(sorted_paths)):
+ print("Appending translation: " + sorted_paths[i])
+ f = open(sorted_paths[i], "rb")
+ buf = f.read()
+ decomp_size = len(buf)
+ buf = zlib.compress(buf)
+ name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
- g.write("};\n")
+ #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n")
+ #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n")
+ g.write("static const unsigned char _translation_" + name + "_compressed[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i])) + ",\n")
- xl_names.append([name,len(buf),str(decomp_size)])
+ g.write("};\n")
- g.write("struct EditorTranslationList {\n")
- g.write("\tconst char* lang;\n");
- g.write("\tint comp_size;\n");
- g.write("\tint uncomp_size;\n");
- g.write("\tconst unsigned char* data;\n");
- g.write("};\n\n");
- g.write("static EditorTranslationList _editor_translations[]={\n")
- for x in xl_names:
- g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n")
- g.write("\t{NULL,0,0,NULL}\n")
- g.write("};\n")
+ xl_names.append([name, len(buf), str(decomp_size)])
- g.write("#endif")
+ g.write("struct EditorTranslationList {\n")
+ g.write("\tconst char* lang;\n")
+ g.write("\tint comp_size;\n")
+ g.write("\tint uncomp_size;\n")
+ g.write("\tconst unsigned char* data;\n")
+ g.write("};\n\n")
+ g.write("static EditorTranslationList _editor_translations[]={\n")
+ for x in xl_names:
+ g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n")
+ g.write("\t{NULL,0,0,NULL}\n")
+ g.write("};\n")
+ g.write("#endif")
-def make_fonts_header(target,source,env):
+def make_fonts_header(target, source, env):
- dst = target[0].srcnode().abspath
+ dst = target[0].srcnode().abspath
- g = open(dst,"wb")
+ g = open(dst, "wb")
-
- """"
+ """"
"""
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_FONTS_H\n")
- g.write("#define _EDITOR_FONTS_H\n")
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _EDITOR_FONTS_H\n")
+ g.write("#define _EDITOR_FONTS_H\n")
+
+ # saving uncompressed, since freetype will reference from memory pointer
+ xl_names = []
+ for i in range(len(source)):
+ print("Appending font: " + source[i].srcnode().abspath)
+ f = open(source[i].srcnode().abspath, "rb")
+ buf = f.read()
+ import os.path
+
+ name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0]
+
+ g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n")
+ g.write("static const unsigned char _font_" + name + "[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i])) + ",\n")
+
+ g.write("};\n")
- #saving uncompressed, since freetype will reference from memory pointer
- xl_names=[]
- for i in range(len(source)):
- print("Appending font: "+source[i].srcnode().abspath)
- f = open(source[i].srcnode().abspath,"rb")
- buf = f.read()
- import os.path
-
- name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0]
+ g.write("#endif")
- g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n")
- g.write("static const unsigned char _font_"+name+"[]={\n")
- for i in range(len(buf)):
- g.write(str(ord(buf[i]))+",\n")
- g.write("};\n")
-
- g.write("#endif")
-
-
-if (env["tools"]!="no"):
+if (env["tools"] != "no"):
- import glob
+ import glob
- dir = env.Dir('.').abspath
- tlist = glob.glob(dir + "/translations/*.po")
+ dir = env.Dir('.').abspath
+ tlist = glob.glob(dir + "/translations/*.po")
- print("translations: ",tlist)
- env.Depends('#tools/editor/translations.h',tlist)
- env.Command('#tools/editor/translations.h',tlist,make_translations_header)
+ print("translations: ", tlist)
+ env.Depends('#tools/editor/translations.h', tlist)
+ env.Command('#tools/editor/translations.h', tlist, make_translations_header)
- flist = glob.glob(dir + "/editor_fonts/*.ttf")
- flist.append( glob.glob(dir + "/editor_fonts/*.otf") )
+ flist = glob.glob(dir + "/editor_fonts/*.ttf")
+ flist.append(glob.glob(dir + "/editor_fonts/*.otf"))
- print("fonts: ",flist)
- env.Depends('#tools/editor/builtin_fonts.h',flist)
- env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header)
+ print("fonts: ", flist)
+ env.Depends('#tools/editor/builtin_fonts.h', flist)
+ env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header)
- SConscript('editor/SCsub');
- SConscript('collada/SCsub');
- SConscript('doc/SCsub')
+ SConscript('editor/SCsub')
+ SConscript('collada/SCsub')
+ SConscript('doc/SCsub')
- lib = env.Library("tool",env.tool_sources)
+ lib = env.Library("tool", env.tool_sources)
- env.Prepend(LIBS=[lib])
+ env.Prepend(LIBS=[lib])
diff --git a/tools/collada/SCsub b/tools/collada/SCsub
index 473474201a..4bc64ffdc2 100644
--- a/tools/collada/SCsub
+++ b/tools/collada/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.tool_sources,"*.cpp")
+env.add_source_files(env.tool_sources, "*.cpp")
Export('env')
diff --git a/tools/dist/html_fs/godot.html b/tools/dist/html_fs/godot.html
deleted file mode 100644
index c354826e1f..0000000000
--- a/tools/dist/html_fs/godot.html
+++ /dev/null
@@ -1,374 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
-<head>
- <meta charset="utf-8" />
- <title>$GODOT_HEAD_TITLE</title>
- $GODOT_HEAD_INCLUDE
- <style type="text/css">
- body {
- margin: 0;
- border: 0 none;
- padding: 0;
- text-align: center;
- background-color: black;
- font-family: $GODOT_STYLE_FONT_FAMILY;
- }
-
-
- /* Godot Engine default theme style
- * ================================ */
-
- .godot {
- color: #e0e0e0;
- background-color: #3b3943;
- background-image: linear-gradient(to bottom, #403e48, #35333c);
- border: 1px solid #45434e;
- box-shadow: 0 0 1px 1px #2f2d35;
- }
-
- button.godot {
- font-family: $GODOT_STYLE_FONT_FAMILY; /* override user agent style */
- padding: 1px 5px;
- background-color: #37353f;
- background-image: linear-gradient(to bottom, #413e49, #3a3842);
- border: 1px solid #514f5d;
- border-radius: 1px;
- box-shadow: 0 0 1px 1px #2a2930;
- }
-
- button.godot:hover {
- color: #f0f0f0;
- background-color: #44414e;
- background-image: linear-gradient(to bottom, #494652, #423f4c);
- border: 1px solid #5a5667;
- box-shadow: 0 0 1px 1px #26252b;
- }
-
- button.godot:active {
- color: #fff;
- background-color: #3e3b46;
- background-image: linear-gradient(to bottom, #36343d, #413e49);
- border: 1px solid #4f4c59;
- box-shadow: 0 0 1px 1px #26252b;
- }
-
- button.godot:disabled {
- color: rgba(230, 230, 230, 0.2);
- background-color: #3d3d3d;
- background-image: linear-gradient(to bottom, #434343, #393939);
- border: 1px solid #474747;
- box-shadow: 0 0 1px 1px #2d2b33;
- }
-
-
- /* Canvas / wrapper
- * ================ */
-
- #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;
- }
-
- #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;
- }
-
-
- /* Status display
- * ============== */
-
- #status-container {
- position: absolute;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- /* don't consume click events - make children visible explicitly */
- visibility: hidden;
- }
-
- #status {
- visibility: visible;
- padding: 4px 6px;
- }
-
-
- /* On-hover controls
- * ================= */
-
- #controls {
- visibility: hidden;
- opacity: 0.0;
- transition: opacity 500ms ease-in-out 200ms;
- position: absolute;
- right: 16px;
- top: 16px;
- padding: 3px 5px;
- font-size: small;
- -moz-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- }
-
- #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
- </style>
-</head>
-<body>
- <div id="container">
- <canvas id="canvas" width="$GODOT_CANVAS_WIDTH" height="$GODOT_CANVAS_HEIGHT" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();">
- HTML5 canvas appears to be unsupported in the current browser.<br />Please try updating or use a different browser.
- </canvas>
- <div id="status-container">
- <span id="status" class="godot" onclick="this.style.visibility='hidden';">Loading page...</span>
- </div>
- <div id="controls" class="godot">
- <label id="display-output"><input id="output-toggle" type="checkbox" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />display output</label>
- <!-- hidden until implemented
- <label><input id="lock-cursor" type="checkbox" autocomplete="off" />lock cursor</label>
- <label><input id="resize-canvas" type="checkbox" autocomplete="off" />resize canvas</label>
- -->
- <button id="fullscreen" class="godot" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.goFullscreen();">fullscreen</button>
- </div>
- </div>
- <!-- Firefox adds extra space to textarea, but shouldn't matter too much https://bugzilla.mozilla.org/show_bug.cgi?id=33654 -->
- <textarea id="output" rows="10" cols="100" readonly="readonly" style="resize:none"></textarea>
-
- <script type="text/javascript">//<![CDATA[
- var Presentation = (function() {
- var statusElement = document.getElementById("status");
- var outputElement = document.getElementById("output");
- var doneLoading = false;
-
- function onLoaded() {
- doneLoading = true;
- var fullscreenButtonElement = document.getElementById("fullscreen");
- fullscreenButtonElement.disabled = false;
- }
-
- var presentation = {
- statusElement: statusElement,
- outputElement: outputElement,
- setOutputVisible: function setOutputVisible(visible) {
- outputElement.style.display = (visible?"block":"none");
- },
- setStatusVisible: function setStatusVisible(visible) {
- statusElement.style.visibility = (visible?"visible":"hidden");
- },
- setStatus: function setStatus(text) {
- if (!text || text.length === 0) {
- Presentation.setStatusVisible(false);
- onLoaded();
- } else {
- Presentation.setStatusVisible(true);
- statusElement.innerHTML = text;
- }
- },
- goFullscreen: function goFullscreen() {
- if (doneLoading) Module.requestFullScreen(false, false);
- }
- };
-
- if ($GODOT_CONTROLS_ENABLED) { // controls enabled
- (function() {
- var controlsElement = document.getElementById("controls");
- controlsElement.style.visibility="visible";
- })();
- }
-
- if ($GODOT_DEBUG_ENABLED) { // debugging enabled
- (function() {
- var outputToggleLabel = document.getElementById("display-output");
- var outputToggle = document.getElementById("output-toggle");
-
- outputElement.value = ""; // clear browser cache
- outputElement.style.display = "block";
- outputToggle.checked = true;
- outputToggleLabel.style.display = "inline";
-
- presentation.print = function print(text) {
- if (outputElement.value.length !== 0)
- outputElement.value += "\n";
- outputElement.value += text;
- outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom
- };
- })();
- }
-
- return presentation;
- })();
-
- // Emscripten interface
- var Module = (function() {
- var print = (function() {
- if (typeof Presentation.print === "function") {
- return function print(text) {
- if (arguments.length > 1)
- text = Array.prototype.slice.call(arguments).join(" ");
- console.log(text);
- Presentation.print(text);
- };
- } else {
- return function print(text) {
- if (arguments.length > 1)
- text = Array.prototype.slice.call(arguments).join(" ");
- console.log(text);
- };
- }
- })();
-
- var canvas = (function() {
- var canvasElement = document.getElementById("canvas");
-
- // As a default initial behavior, pop up an alert when WebGL context is lost. To make your
- // application robust, you may want to override this behavior before shipping!
- // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
- canvasElement.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
-
- return canvasElement;
- })();
-
- var setStatus = (function() {
- if (typeof Presentation.setStatus === "function")
- return function setStatus(text) {
- if (!Module.setStatus.last)
- Module.setStatus.last = { time: Date.now(), text: "" };
- if (text === Module.setStatus.text)
- return;
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m) {
- if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
- return;
- text = m[1];
- }
- Presentation.setStatus(text);
- };
- else
- return function setStatus(text) {
- if (!Module.setStatus.last)
- Module.setStatus.last = { time: Date.now(), text: "" };
- if (text === Module.setStatus.text)
- return;
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m) {
- if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
- return;
- text = m[1];
- }
- };
- })();
-
- return {
- TOTAL_MEMORY: 268435456,
- preRun: [],
- postRun: [],
- print: print,
- printErr: function printErr(text) {
- if (arguments.length > 1)
- text = Array.prototype.slice.call(arguments).join(" ");
- if (0) { // XXX disabled for safety `if (typeof dump == "function")`
- dump(text + "\n"); // fast, straight to the real console
- } else {
- console.error(text);
- }
- },
- canvas: canvas,
- setStatus: setStatus,
- totalDependencies: 0,
- monitorRunDependencies: function monitorRunDependencies(left) {
- this.totalDependencies = Math.max(this.totalDependencies, left);
- Module.setStatus(left ? "Preparing... (" + (this.totalDependencies-left) + "/" + this.totalDependencies + ")" : "All downloads complete.");
- }
- };
- })();
-
- Presentation.setStatus("Downloading...");
-
- window.onerror = function(event) {
- // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
- Module.setStatus("Exception thrown, see JavaScript console");
- Module.setStatus = function(text) {
- if (text) Module.printErr("[post-exception status] " + text);
- };
- };
- //]]></script>
- <script type="text/javascript" src="$GODOT_FS"></script>
- <script>
- (function() {
- var memoryInitializer = "$GODOT_MEM";
- if (typeof Module.locateFile === "function") {
- memoryInitializer = Module.locateFile(memoryInitializer);
- } else if (Module.memoryInitializerPrefixURL) {
- memoryInitializer = Module.memoryInitializerPrefixURL + memoryInitializer;
- }
- var xhr = Module.memoryInitializerRequest = new XMLHttpRequest();
- xhr.open("GET", memoryInitializer, true);
- xhr.responseType = "arraybuffer";
- xhr.send(null);
- })();
-
- var script = document.createElement("script");
- script.src = "$GODOT_JS";
- document.body.appendChild(script);
- </script>
-</body>
-</html>
diff --git a/tools/dist/uwp_template/AppxManifest.xml b/tools/dist/uwp_template/AppxManifest.xml
index 48a2ba7eb3..d5e653708c 100644
--- a/tools/dist/uwp_template/AppxManifest.xml
+++ b/tools/dist/uwp_template/AppxManifest.xml
@@ -15,7 +15,7 @@
<Resource Language="EN-US" />
</Resources>
<Applications>
- <Application Id="App" Executable="godot.winrt.exe" EntryPoint="GodotWinRT.App">
+ <Application Id="App" Executable="godot.uwp.exe" EntryPoint="GodotUWP.App">
<uap:VisualElements DisplayName="$display_name$" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="$app_description$" BackgroundColor="$bg_color$">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" ShortName="$short_name$">
$name_on_tiles$
diff --git a/tools/doc/SCsub b/tools/doc/SCsub
index 473474201a..4bc64ffdc2 100644
--- a/tools/doc/SCsub
+++ b/tools/doc/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.tool_sources,"*.cpp")
+env.add_source_files(env.tool_sources, "*.cpp")
Export('env')
diff --git a/tools/editor/SCsub b/tools/editor/SCsub
index f6cb16dc24..caf45d25be 100644
--- a/tools/editor/SCsub
+++ b/tools/editor/SCsub
@@ -3,86 +3,78 @@
Import('env')
-def make_doc_header(target,source,env):
-
- src = source[0].srcnode().abspath
- dst = target[0].srcnode().abspath
- f = open(src,"rb")
- g = open(dst,"wb")
- buf = f.read()
- decomp_size = len(buf)
- import zlib
- buf = zlib.compress(buf)
-
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _DOC_DATA_RAW_H\n")
- g.write("#define _DOC_DATA_RAW_H\n")
- g.write("static const int _doc_data_compressed_size="+str(len(buf))+";\n")
- g.write("static const int _doc_data_uncompressed_size="+str(decomp_size)+";\n")
- g.write("static const unsigned char _doc_data_compressed[]={\n")
- for i in range(len(buf)):
- g.write(str(ord(buf[i]))+",\n")
- g.write("};\n")
- g.write("#endif")
-
-
-
-def make_certs_header(target,source,env):
-
- src = source[0].srcnode().abspath
- dst = target[0].srcnode().abspath
- f = open(src,"rb")
- g = open(dst,"wb")
- buf = f.read()
- decomp_size = len(buf)
- import zlib
- buf = zlib.compress(buf)
-
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _CERTS_RAW_H\n")
- g.write("#define _CERTS_RAW_H\n")
- g.write("static const int _certs_compressed_size="+str(len(buf))+";\n")
- g.write("static const int _certs_uncompressed_size="+str(decomp_size)+";\n")
- g.write("static const unsigned char _certs_compressed[]={\n")
- for i in range(len(buf)):
- g.write(str(ord(buf[i]))+",\n")
- g.write("};\n")
- g.write("#endif")
-
-
-
-
-
-
-
-if (env["tools"]=="yes"):
-
- reg_exporters_inc='#include "register_exporters.h"\n'
- reg_exporters='void register_exporters() {\n'
- for e in env.platform_exporters:
- env.tool_sources.append("#platform/"+e+"/export/export.cpp")
- reg_exporters+='\tregister_'+e+'_exporter();\n'
- reg_exporters_inc+='#include "platform/'+e+'/export/export.h"\n'
- reg_exporters+='}\n'
- f = open("register_exporters.cpp","wb")
- f.write(reg_exporters_inc)
- f.write(reg_exporters)
- f.close()
-
- env.Depends("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml")
- env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header)
-
- env.Depends("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt")
- env.Command("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt",make_certs_header)
-
- #make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env)
-
- env.add_source_files(env.tool_sources,"*.cpp")
-
- Export('env')
- SConscript('icons/SCsub');
- SConscript('plugins/SCsub');
- SConscript('fileserver/SCsub');
- SConscript('io_plugins/SCsub');
+def make_doc_header(target, source, env):
+
+ src = source[0].srcnode().abspath
+ dst = target[0].srcnode().abspath
+ f = open(src, "rb")
+ g = open(dst, "wb")
+ buf = f.read()
+ decomp_size = len(buf)
+ import zlib
+ buf = zlib.compress(buf)
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _DOC_DATA_RAW_H\n")
+ g.write("#define _DOC_DATA_RAW_H\n")
+ g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n")
+ g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n")
+ g.write("static const unsigned char _doc_data_compressed[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i])) + ",\n")
+ g.write("};\n")
+ g.write("#endif")
+
+
+def make_certs_header(target, source, env):
+
+ src = source[0].srcnode().abspath
+ dst = target[0].srcnode().abspath
+ f = open(src, "rb")
+ g = open(dst, "wb")
+ buf = f.read()
+ decomp_size = len(buf)
+ import zlib
+ buf = zlib.compress(buf)
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _CERTS_RAW_H\n")
+ g.write("#define _CERTS_RAW_H\n")
+ g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n")
+ g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n")
+ g.write("static const unsigned char _certs_compressed[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i])) + ",\n")
+ g.write("};\n")
+ g.write("#endif")
+
+
+if (env["tools"] == "yes"):
+
+ reg_exporters_inc = '#include "register_exporters.h"\n'
+ reg_exporters = 'void register_exporters() {\n'
+ for e in env.platform_exporters:
+ env.tool_sources.append("#platform/" + e + "/export/export.cpp")
+ reg_exporters += '\tregister_' + e + '_exporter();\n'
+ reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
+ reg_exporters += '}\n'
+ f = open("register_exporters.cpp", "wb")
+ f.write(reg_exporters_inc)
+ f.write(reg_exporters)
+ f.close()
+
+ env.Depends("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml")
+ env.Command("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml", make_doc_header)
+
+ env.Depends("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt")
+ env.Command("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt", make_certs_header)
+
+ # make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env)
+
+ env.add_source_files(env.tool_sources, "*.cpp")
+
+ Export('env')
+ SConscript('icons/SCsub')
+ SConscript('plugins/SCsub')
+ SConscript('fileserver/SCsub')
+ SConscript('io_plugins/SCsub')
diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp
index edbcc71284..330103923d 100644
--- a/tools/editor/editor_run_native.cpp
+++ b/tools/editor/editor_run_native.cpp
@@ -55,6 +55,7 @@ void EditorRunNative::_notification(int p_what) {
small_icon->create_from_image(im);
MenuButton *mb = memnew( MenuButton );
mb->get_popup()->connect("item_pressed",this,"_run_native",varray(E->get()));
+ mb->connect("pressed",this,"_run_native",varray(-1, E->get()));
mb->set_icon(small_icon);
add_child(mb);
menus[E->get()]=mb;
@@ -79,13 +80,16 @@ void EditorRunNative::_notification(int p_what) {
if (dc==0) {
mb->hide();
} else {
-
mb->get_popup()->clear();
mb->show();
- for(int i=0;i<dc;i++) {
-
- mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i));
- mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i));
+ if (dc == 1) {
+ mb->set_tooltip(eep->get_device_name(0) + "\n\n" + eep->get_device_info(0).strip_edges());
+ } else {
+ mb->set_tooltip("Select device from the list");
+ for(int i=0;i<dc;i++) {
+ mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i));
+ mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i).strip_edges());
+ }
}
}
}
@@ -96,11 +100,18 @@ void EditorRunNative::_notification(int p_what) {
}
-
void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform);
ERR_FAIL_COND(eep.is_null());
+ if (p_idx == -1) {
+ if (eep->get_device_count() == 1) {
+ menus[p_platform]->get_popup()->hide();
+ p_idx = 0;
+ } else {
+ return;
+ }
+ }
emit_signal("native_run");
int flags=0;
diff --git a/tools/editor/fileserver/SCsub b/tools/editor/fileserver/SCsub
index 6299fd416c..4bf55189cc 100644
--- a/tools/editor/fileserver/SCsub
+++ b/tools/editor/fileserver/SCsub
@@ -2,4 +2,4 @@
Import('env')
Export('env')
-env.add_source_files(env.tool_sources,"*.cpp")
+env.add_source_files(env.tool_sources, "*.cpp")
diff --git a/tools/editor/icons/2x/icon_script_create.png b/tools/editor/icons/2x/icon_script_create.png
new file mode 100644
index 0000000000..67f80e8760
--- /dev/null
+++ b/tools/editor/icons/2x/icon_script_create.png
Binary files differ
diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub
index 9e05d8f391..af6ebd67fd 100644
--- a/tools/editor/icons/SCsub
+++ b/tools/editor/icons/SCsub
@@ -2,97 +2,95 @@
Import('env')
-def make_editor_icons_action(target, source, env):
-
- import os
- import cStringIO
- dst = target[0].srcnode().abspath
- pixmaps = source
-
- s = cStringIO.StringIO()
+def make_editor_icons_action(target, source, env):
- s.write("#include \"editor_icons.h\"\n\n")
- s.write("#include \"editor_scale.h\"\n\n")
- s.write("#include \"scene/resources/theme.h\"\n\n")
+ import os
+ import cStringIO
- hidpi_list=[]
+ dst = target[0].srcnode().abspath
+ pixmaps = source
- for x in pixmaps:
+ s = cStringIO.StringIO()
- x=str(x)
- var_str=os.path.basename(x)[:-4]+"_png";
- #print(var_str)
+ s.write("#include \"editor_icons.h\"\n\n")
+ s.write("#include \"editor_scale.h\"\n\n")
+ s.write("#include \"scene/resources/theme.h\"\n\n")
- s.write("static const unsigned char "+ var_str +"[]={\n");
+ hidpi_list = []
- pngf=open(x,"rb");
+ for x in pixmaps:
- b=pngf.read(1);
- while(len(b)==1):
- s.write(hex(ord(b)))
- b=pngf.read(1);
- if (len(b)==1):
- s.write(",")
+ x = str(x)
+ var_str = os.path.basename(x)[:-4] + "_png"
+ # print(var_str)
- s.write("\n};\n\n");
+ s.write("static const unsigned char " + var_str + "[]={\n")
- pngf.close();
- var_str=os.path.basename(x)[:-4]+"_hidpi_png";
- try:
+ pngf = open(x, "rb")
- pngf = open(os.path.dirname(x)+"/2x/"+os.path.basename(x), "rb")
+ b = pngf.read(1)
+ while(len(b) == 1):
+ s.write(hex(ord(b)))
+ b = pngf.read(1)
+ if (len(b) == 1):
+ s.write(",")
- s.write("static const unsigned char "+ var_str +"[]={\n");
+ s.write("\n};\n\n")
- b=pngf.read(1);
- while(len(b)==1):
- s.write(hex(ord(b)))
- b=pngf.read(1);
- if (len(b)==1):
- s.write(",")
+ pngf.close()
+ var_str = os.path.basename(x)[:-4] + "_hidpi_png"
+ try:
- s.write("\n};\n\n\n");
- hidpi_list.append(x)
+ pngf = open(os.path.dirname(x) + "/2x/" + os.path.basename(x), "rb")
- except:
- s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n");
+ s.write("static const unsigned char " + var_str + "[]={\n")
+ b = pngf.read(1)
+ while(len(b) == 1):
+ s.write(hex(ord(b)))
+ b = pngf.read(1)
+ if (len(b) == 1):
+ s.write(",")
+ s.write("\n};\n\n\n")
+ hidpi_list.append(x)
+ except:
+ s.write("static const unsigned char* " + var_str + "=NULL;\n\n\n")
- s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n")
- s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
- s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n")
- s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n")
- s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n")
- s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n")
- s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n")
- s.write("\treturn texture;\n")
- s.write("}\n\n")
+ s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n")
+ s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
+ s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n")
+ s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n")
+ s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n")
+ s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n")
+ s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n")
+ s.write("\treturn texture;\n")
+ s.write("}\n\n")
- s.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n")
+ s.write("void editor_register_icons(Ref<Theme> p_theme) {\n\n")
- for x in pixmaps:
+ for x in pixmaps:
- x=os.path.basename(str(x))
- type=x[5:-4].title().replace("_","");
- var_str=x[:-4]+"_png";
- var_str_hidpi=x[:-4]+"_hidpi_png";
- s.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+","+var_str_hidpi+"));\n");
+ x = os.path.basename(str(x))
+ type = x[5:-4].title().replace("_", "")
+ var_str = x[:-4] + "_png"
+ var_str_hidpi = x[:-4] + "_hidpi_png"
+ s.write("\tp_theme->set_icon(\"" + type + "\",\"EditorIcons\",make_icon(" + var_str + "," + var_str_hidpi + "));\n")
- s.write("\n\n}\n\n");
+ s.write("\n\n}\n\n")
- f = open(dst,"wb")
- f.write(s.getvalue())
- f.close()
- s.close()
+ f = open(dst, "wb")
+ f.write(s.getvalue())
+ f.close()
+ s.close()
make_editor_icons_builder = Builder(action=make_editor_icons_action,
- suffix = '.cpp',
- src_suffix = '.png')
-env['BUILDERS']['MakeEditorIconsBuilder']=make_editor_icons_builder
-env.Alias('editor_icons',[env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp',Glob("*.png"))])
+ suffix='.cpp',
+ src_suffix='.png')
+env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder
+env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp', Glob("*.png"))])
env.tool_sources.append("#tools/editor/editor_icons.cpp")
Export('env')
diff --git a/tools/editor/icons/icon_script_create.png b/tools/editor/icons/icon_script_create.png
new file mode 100644
index 0000000000..f5d8b0cfd6
--- /dev/null
+++ b/tools/editor/icons/icon_script_create.png
Binary files differ
diff --git a/tools/editor/icons/source/icon_script_create.svg b/tools/editor/icons/source/icon_script_create.svg
new file mode 100644
index 0000000000..c3f69c4601
--- /dev/null
+++ b/tools/editor/icons/source/icon_script_create.svg
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ inkscape:export-filename="/home/godotengine/godot/tools/editor/icons/con_script_create.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_script_create.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="29.966667"
+ inkscape:cx="5.495872"
+ inkscape:cy="2.1206692"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1119"
+ inkscape:window-x="0"
+ inkscape:window-y="26"
+ inkscape:window-maximized="1"
+ showguides="false">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336"
+ empspacing="4" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
+ d="M 6 1 L 6 2 A 1 1 0 0 0 5 3 L 5 13 L 4 13 L 4 11 L 2 11 L 2 13 A 1 1 0 0 0 2.5 13.865234 A 1 1 0 0 0 3 14 L 3 15 L 10 15 L 10 14 L 7 14 L 7 10 L 10 10 L 10 7 L 12 7 L 12 5 L 15 5 L 15 3 A 2 2 0 0 0 13 1 L 6 1 z M 11 8 L 11 11 L 8 11 L 8 13 L 11 13 L 11 14.730469 A 2 2 0 0 0 12 13 L 12 8 L 11 8 z "
+ transform="translate(0,1036.3622)"
+ id="rect4255" />
+ <path
+ style="opacity:1;fill:#b4b4b4;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
+ d="M 6 1 C 4.8954305 1 4 1.8954305 4 3 L 4 10 L 2 10 L 1 10 L 1 11 L 1 13 C 1 14.104569 1.8954305 15 3 15 C 4.1045695 15 5 14.104569 5 13 L 5 3 C 5 2.4477153 5.4477153 2 6 2 C 6.5522847 2 7 2.4477153 7 3 L 7 4 L 7 5 L 7 6 L 8 6 L 12 6 L 12 5 L 8 5 L 8 4 L 8 3 C 8 1.8954305 7.1045695 1 6 1 z M 2 11 L 4 11 L 4 13 C 4 13.552285 3.5522847 14 3 14 C 2.4477153 14 2 13.552285 2 13 L 2 11 z "
+ transform="translate(0,1036.3622)"
+ id="path4265" />
+ <circle
+ cy="1048.3622"
+ cx="3"
+ id="ellipse4234"
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
+ ry="1.0000174"
+ rx="1" />
+ <path
+ style="fill:#e0e0e0;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
+ d="m 13,1049.3622 3,0 0,-2 -3,0 0,-3 -2,0 0,3 -3,0 0,2 3,0 0,3 2,0 z"
+ id="path8069"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/tools/editor/io_plugins/SCsub b/tools/editor/io_plugins/SCsub
index 6299fd416c..4bf55189cc 100644
--- a/tools/editor/io_plugins/SCsub
+++ b/tools/editor/io_plugins/SCsub
@@ -2,4 +2,4 @@
Import('env')
Export('env')
-env.add_source_files(env.tool_sources,"*.cpp")
+env.add_source_files(env.tool_sources, "*.cpp")
diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp
index 1130e2be30..2211167dbb 100644
--- a/tools/editor/io_plugins/editor_import_collada.cpp
+++ b/tools/editor/io_plugins/editor_import_collada.cpp
@@ -88,8 +88,8 @@ struct ColladaImport {
Error _create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes=Vector<Ref<Mesh> >());
Error load(const String& p_path, int p_flags, bool p_force_make_tangents=false);
void _fix_param_animation_tracks();
- void create_animation(int p_clip,bool p_make_tracks_in_all_bones);
- void create_animations(bool p_make_tracks_in_all_bones);
+ void create_animation(int p_clip,bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
+ void create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
Set<String> tracks_in_clips;
Vector<String> missing_textures;
@@ -1898,7 +1898,7 @@ void ColladaImport::_fix_param_animation_tracks() {
}
-void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) {
+void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks) {
_fix_param_animation_tracks();
@@ -1943,14 +1943,14 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) {
}
- create_animation(-1,p_make_tracks_in_all_bones);
+ create_animation(-1,p_make_tracks_in_all_bones, p_import_value_tracks);
//print_line("clipcount: "+itos(collada.state.animation_clips.size()));
for(int i=0;i<collada.state.animation_clips.size();i++)
- create_animation(i,p_make_tracks_in_all_bones);
+ create_animation(i, p_make_tracks_in_all_bones, p_import_value_tracks);
}
-void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones) {
+void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks) {
Ref<Animation> animation = Ref<Animation>( memnew( Animation ));
@@ -2251,64 +2251,68 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
+ if (p_import_value_tracks) {
+ for (int i = 0; i < valid_animated_properties.size(); i++) {
- for(int i=0;i<valid_animated_properties.size();i++) {
+ int ti = valid_animated_properties[i];
- int ti = valid_animated_properties[i];
+ if (p_clip == -1) {
- if (p_clip==-1) {
+ if (track_filter.has(ti))
+ continue;
+ }
+ else {
- if (track_filter.has(ti))
- continue;
- } else {
+ if (!track_filter.has(ti))
+ continue;
- if (!track_filter.has(ti))
- continue;
+ }
- }
+ Collada::AnimationTrack &at = collada.state.animation_tracks[ti];
- Collada::AnimationTrack &at = collada.state.animation_tracks[ ti ];
+ // take snapshots
+ if (!collada.state.scene_map.has(at.target))
+ continue;
- // take snapshots
- if (!collada.state.scene_map.has(at.target))
- continue;
+ NodeMap &nm = node_map[at.target];
+ String path = scene->get_path_to(nm.node);
- NodeMap &nm = node_map[at.target];
- String path = scene->get_path_to(nm.node);
+ animation->add_track(Animation::TYPE_VALUE);
+ int track = animation->get_track_count() - 1;
- animation->add_track(Animation::TYPE_VALUE);
- int track = animation->get_track_count() -1;
+ path = path + ":" + at.param;
+ animation->track_set_path(track, path);
+ animation->track_set_imported(track, true); //helps merging later
- path = path +":"+at.param;
- animation->track_set_path( track , path );
- animation->track_set_imported( track , true ); //helps merging later
+ for (int i = 0; i < at.keys.size(); i++) {
- for(int i=0;i<at.keys.size();i++) {
+ float time = at.keys[i].time;
+ Variant value;
+ Vector<float> data = at.keys[i].data;
+ if (data.size() == 1) {
+ //push a float
+ value = data[0];
- float time = at.keys[i].time;
- Variant value;
- Vector<float> data = at.keys[i].data;
- if (data.size()==1) {
- //push a float
- value=data[0];
+ }
+ else if (data.size() == 16) {
+ //matrix
+ print_line("value keys for matrices not supported");
+ }
+ else {
- } else if (data.size()==16) {
- //matrix
- print_line("value keys for matrices not supported");
- } else {
+ print_line("don't know what to do with this amount of value keys: " + itos(data.size()));
+ }
- print_line("don't know what to do with this amount of value keys: "+itos(data.size()));
+ animation->track_insert_key(track, time, value);
}
- animation->track_insert_key(track,time,value);
- }
+ tracks_found = true;
- tracks_found=true;
-
+ }
}
@@ -2373,7 +2377,7 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_
if (p_flags&IMPORT_ANIMATION) {
- state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS);
+ state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
AnimationPlayer *ap = memnew( AnimationPlayer );
for(int i=0;i<state.animations.size();i++) {
String name;
@@ -2410,7 +2414,7 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String& p_path
ERR_FAIL_COND_V(err!=OK,RES());
- state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS);
+ state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
if (state.scene)
memdelete(state.scene);
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index 56af35c6db..cb8ec6d0bc 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -2164,6 +2164,8 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from
uint32_t import_flags=0;
if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_DETECT_LOOP)
import_flags|=EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP;
+ if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_KEEP_VALUE_TRACKS)
+ import_flags |= EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS;
if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_OPTIMIZE)
import_flags|=EditorSceneImporter::IMPORT_ANIMATION_OPTIMIZE;
if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS)
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h
index c31d3a33d3..2c27f06960 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.h
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.h
@@ -60,6 +60,7 @@ public:
IMPORT_ANIMATION_DETECT_LOOP=4,
IMPORT_ANIMATION_OPTIMIZE=8,
IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=16,
+ IMPORT_ANIMATION_KEEP_VALUE_TRACKS=32,
IMPORT_GENERATE_TANGENT_ARRAYS=256,
IMPORT_FAIL_ON_MISSING_DEPENDENCIES=512
diff --git a/tools/editor/plugins/SCsub b/tools/editor/plugins/SCsub
index 6299fd416c..4bf55189cc 100644
--- a/tools/editor/plugins/SCsub
+++ b/tools/editor/plugins/SCsub
@@ -2,4 +2,4 @@
Import('env')
Export('env')
-env.add_source_files(env.tool_sources,"*.cpp")
+env.add_source_files(env.tool_sources, "*.cpp")
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index ac39e0687c..af9fd69ae7 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3797,6 +3797,7 @@ bool CanvasItemEditorViewport::_create_instance(Node* parent, String& path, cons
if (editor->get_edited_scene()->get_filename()!="") { // cyclical instancing
if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instanced_scene)) {
+ memdelete(instanced_scene);
return false;
}
}
diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp
index 40fc3a7bda..23252c4077 100644
--- a/tools/editor/plugins/script_text_editor.cpp
+++ b/tools/editor/plugins/script_text_editor.cpp
@@ -100,7 +100,7 @@ void ScriptTextEditor::_load_theme_settings() {
/* keyword color */
- text_edit->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
+ text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
@@ -122,6 +122,7 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/breakpoint_color", Color(0.8,0.8,0.4,0.2)));
text_edit->add_color_override("search_result_color",EDITOR_DEF("text_editor/search_result_color",Color(0.05,0.25,0.05,1)));
text_edit->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/search_result_border_color",Color(0.1,0.45,0.1,1)));
+ text_edit->add_color_override("symbol_color",EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff)));
text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/line_spacing",4));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
@@ -190,11 +191,6 @@ void ScriptTextEditor::_load_theme_settings() {
String end = string.get_slice_count(" ")>1?string.get_slice(" ",1):String();
text_edit->add_color_region(beg,end,string_color,end=="");
}
-
- //colorize symbols
- Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff));
- text_edit->set_symbol_color(symbol_color);
-
}
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 861f5678f6..f67151d8e9 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -77,7 +77,7 @@ void ShaderTextEditor::_load_theme_settings() {
/* keyword color */
- get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
+ get_text_edit()->add_color_override("background_color", EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
@@ -99,6 +99,7 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/breakpoint_color", Color(0.8,0.8,0.4,0.2)));
get_text_edit()->add_color_override("search_result_color",EDITOR_DEF("text_editor/search_result_color",Color(0.05,0.25,0.05,1)));
get_text_edit()->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/search_result_border_color",Color(0.1,0.45,0.1,1)));
+ get_text_edit()->add_color_override("symbol_color",EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff)));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
@@ -135,11 +136,6 @@ void ShaderTextEditor::_load_theme_settings() {
String end = string.get_slice_count(" ")>1?string.get_slice(" ",1):String();
get_text_edit()->add_color_region(beg,end,string_color,end=="");
}*/
-
- //colorize symbols
- Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff));
- get_text_edit()->set_symbol_color(symbol_color);
-
}
diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp
index 1c99982155..069d7cef81 100644
--- a/tools/editor/project_manager.cpp
+++ b/tools/editor/project_manager.cpp
@@ -141,7 +141,7 @@ private:
}
String sp = p.simplify_path();
project_path->set_text(sp);
- _path_text_changed(p);
+ _path_text_changed(sp);
get_ok()->call_deferred("grab_focus");
}
@@ -150,7 +150,7 @@ private:
String p = p_path;
String sp = p.simplify_path();
project_path->set_text(sp);
- _path_text_changed(p);
+ _path_text_changed(sp);
get_ok()->call_deferred("grab_focus");
}
@@ -335,7 +335,7 @@ private:
hide();
- emit_signal("project_created");
+ emit_signal("project_created", dir);
}
@@ -882,6 +882,7 @@ void ProjectManager::_load_recent_projects() {
hb->add_child(tf);
VBoxContainer *vb = memnew(VBoxContainer);
+ vb->set_name("project");
hb->add_child(vb);
Control *ec = memnew( Control );
ec->set_custom_minimum_size(Size2(0,1));
@@ -891,6 +892,7 @@ void ProjectManager::_load_recent_projects() {
title->add_color_override("font_color",font_color);
vb->add_child(title);
Label *fpath = memnew( Label(path) );
+ fpath->set_name("path");
vb->add_child(fpath);
fpath->set_opacity(0.5);
fpath->add_color_override("font_color",font_color);
@@ -912,6 +914,43 @@ void ProjectManager::_load_recent_projects() {
tabs->set_current_tab(0);
}
+void ProjectManager::_on_project_created(const String& dir) {
+ bool has_already=false;
+ for (int i=0;i<scroll_childs->get_child_count();i++) {
+ HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
+ Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
+ if (fpath->get_text()==dir) {
+ has_already=true;
+ break;
+ }
+ }
+ if (has_already) {
+ _update_scroll_pos(dir);
+ } else {
+ _load_recent_projects();
+ scroll->connect("draw", this, "_update_scroll_pos", varray(dir), CONNECT_ONESHOT);
+ }
+}
+
+void ProjectManager::_update_scroll_pos(const String& dir) {
+ for (int i=0;i<scroll_childs->get_child_count();i++) {
+ HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
+ Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
+ if (fpath->get_text()==dir) {
+ last_clicked=hb->get_meta("name");
+ selected_list.clear();
+ selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
+ _update_project_buttons();
+ int last_y_visible=scroll->get_v_scroll()+scroll->get_size().y;
+ int offset_diff=(hb->get_pos().y + hb->get_size().y)-last_y_visible;
+
+ if (offset_diff>0)
+ scroll->set_v_scroll(scroll->get_v_scroll()+offset_diff);
+ break;
+ }
+ }
+}
+
void ProjectManager::_open_project_confirm() {
for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
@@ -1164,6 +1203,8 @@ void ProjectManager::_bind_methods() {
ObjectTypeDB::bind_method("_erase_project_confirm",&ProjectManager::_erase_project_confirm);
ObjectTypeDB::bind_method("_exit_dialog",&ProjectManager::_exit_dialog);
ObjectTypeDB::bind_method("_load_recent_projects",&ProjectManager::_load_recent_projects);
+ ObjectTypeDB::bind_method("_on_project_created",&ProjectManager::_on_project_created);
+ ObjectTypeDB::bind_method("_update_scroll_pos",&ProjectManager::_update_scroll_pos);
ObjectTypeDB::bind_method("_panel_draw",&ProjectManager::_panel_draw);
ObjectTypeDB::bind_method("_panel_input",&ProjectManager::_panel_input);
ObjectTypeDB::bind_method("_unhandled_input",&ProjectManager::_unhandled_input);
@@ -1382,7 +1423,7 @@ ProjectManager::ProjectManager() {
npdialog = memnew( NewProjectDialog );
gui_base->add_child(npdialog);
- npdialog->connect("project_created", this,"_load_recent_projects");
+ npdialog->connect("project_created", this,"_on_project_created");
_load_recent_projects();
if ( EditorSettings::get_singleton()->get("global/autoscan_project_path") ) {
diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h
index 46f7aea3a5..af2d47aeb3 100644
--- a/tools/editor/project_manager.h
+++ b/tools/editor/project_manager.h
@@ -85,6 +85,8 @@ class ProjectManager : public Control {
void _scan_begin(const String& p_base);
void _load_recent_projects();
+ void _on_project_created(const String& dir);
+ void _update_scroll_pos(const String& dir);
void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects);
void _install_project(const String& p_zip_path,const String& p_title);
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 16f06c7ac9..990d14196e 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -80,11 +80,11 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
_tool_selected(TOOL_DUPLICATE);
}
- else if (ED_IS_SHORTCUT("scene_tree/add_script", p_event)) {
- _tool_selected(TOOL_CREATE_SCRIPT);
+ else if (ED_IS_SHORTCUT("scene_tree/attach_script", p_event)) {
+ _tool_selected(TOOL_ATTACH_SCRIPT);
}
- else if (ED_IS_SHORTCUT("scene_tree/load_script", p_event)) {
- _tool_selected(TOOL_LOAD_SCRIPT);
+ else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
+ _tool_selected(TOOL_CLEAR_SCRIPT);
}
else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
_tool_selected(TOOL_MOVE_UP);
@@ -269,24 +269,6 @@ void SceneTreeDock::_replace_with_branch_scene(const String& p_file,Node* base)
scene_tree->set_selected(instanced_scene);
}
-
-void SceneTreeDock::_file_selected(String p_file) {
- RES p_script = ResourceLoader::load(p_file, "Script");
- if (p_script.is_null()) {
- accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error loading script from %s"), p_file));
- accept->popup_centered_minsize();
- return;
- }
-
- Node *selected = scene_tree->get_selected();
- if (!selected)
- return;
- selected->set_script(p_script.get_ref_ptr());
- editor->push_item(p_script.operator->());
- file_dialog->hide();
-}
-
bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node) {
int childCount = p_desired_node->get_child_count();
@@ -379,22 +361,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
//groups_editor->set_current(current);
//groups_editor->popup_centered_ratio();
} break;
- case TOOL_LOAD_SCRIPT: {
- Node *selected = scene_tree->get_selected();
- if (!selected)
- break;
-
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
-
- List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
- file_dialog->clear_filters();
- for (List<String>::Element *E = extensions.front(); E; E = E->next())
- file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
-
- file_dialog->popup_centered_ratio();
- } break;
- case TOOL_CREATE_SCRIPT: {
+ case TOOL_ATTACH_SCRIPT: {
Node *selected = scene_tree->get_selected();
if (!selected)
@@ -415,6 +382,18 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
+ case TOOL_CLEAR_SCRIPT: {
+ Node *selected = scene_tree->get_selected();
+ if(!selected)
+ break;
+
+ Ref<Script> existing = selected->get_script();
+ if(existing.is_valid()) {
+ const RefPtr empty;
+ selected->set_script(empty);
+ }
+
+ } break;
case TOOL_MOVE_UP:
case TOOL_MOVE_DOWN: {
@@ -502,6 +481,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
List<Node*> selection = editor_selection->get_selected_node_list();
+ if (selection.size()==0)
+ break;
List<Node*> reselect;
@@ -707,8 +688,8 @@ void SceneTreeDock::_notification(int p_what) {
}
button_add->set_icon(get_icon("Add","EditorIcons"));
button_instance->set_icon(get_icon("Instance","EditorIcons"));
- button_create_script->set_icon(get_icon("Script","EditorIcons"));
- button_load_script->set_icon(get_icon("Script", "EditorIcons"));
+ button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
+ button_clear_script->set_icon(get_icon("Remove", "EditorIcons"));
filter_icon->set_texture(get_icon("Zoom","EditorIcons"));
@@ -1338,12 +1319,18 @@ void SceneTreeDock::_selection_changed() {
_tool_selected(TOOL_MULTI_EDIT);
}
- if (selection_size==1 && EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
- button_create_script->show();
- button_load_script->show();
+ if (selection_size==1) {
+ if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
+ button_create_script->show();
+ button_clear_script->hide();
+ }
+ else {
+ button_create_script->hide();
+ button_clear_script->show();
+ }
} else {
button_create_script->hide();
- button_load_script->hide();
+ button_clear_script->hide();
}
//tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
@@ -1603,7 +1590,7 @@ static bool _is_node_visible(Node* p_node) {
static bool _has_visible_children(Node* p_node) {
- bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false;
+ bool collapsed = p_node->is_displayed_folded();
if (collapsed)
return false;
@@ -1626,7 +1613,7 @@ static Node* _find_last_visible(Node* p_node) {
Node* last=NULL;
- bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false;
+ bool collapsed = p_node->is_displayed_folded();
if (!collapsed) {
for(int i=0;i<p_node->get_child_count();i++) {
@@ -1661,36 +1648,9 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) {
ERR_EXPLAIN("Cannot perform drop above the root node!");
ERR_FAIL();
}
- Node* upper_sibling=NULL;
-
- for(int i=0;i<to_node->get_index();i++) {
- Node *c =to_node->get_parent()->get_child(i);
- if (_is_node_visible(c)) {
- upper_sibling=c;
- }
- }
-
- if (upper_sibling) {
- //quite complicated, look for next visible in tree
- upper_sibling=_find_last_visible(upper_sibling);
-
- if (upper_sibling->get_parent()==to_node->get_parent()) {
- //just insert over this node because nothing is above at an upper level
- to_pos=to_node->get_index();
- to_node=to_node->get_parent();
- } else {
- to_pos=-1; //insert last in whathever is up
- to_node=upper_sibling->get_parent(); //insert at a parent of whathever is up
- }
-
-
- } else {
- //just insert over this node because nothing is above at the same level
- to_pos=to_node->get_index();
- to_node=to_node->get_parent();
-
- }
+ to_pos=to_node->get_index();
+ to_node=to_node->get_parent();
} else if (p_type==1) {
//drop at below selected node
@@ -1823,8 +1783,8 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
//menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_CREATE_SCRIPT);
- menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/load_script"), TOOL_LOAD_SCRIPT);
+ menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
+ menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
menu->add_separator();
}
@@ -1883,7 +1843,7 @@ void SceneTreeDock::_focus_node() {
void SceneTreeDock::open_script_dialog(Node* p_for_node) {
scene_tree->set_selected(p_for_node,false);
- _tool_selected(TOOL_CREATE_SCRIPT);
+ _tool_selected(TOOL_ATTACH_SCRIPT);
}
void SceneTreeDock::_bind_methods() {
@@ -1912,7 +1872,6 @@ void SceneTreeDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_tree_rmb"),&SceneTreeDock::_tree_rmb);
ObjectTypeDB::bind_method(_MD("_filter_changed"),&SceneTreeDock::_filter_changed);
ObjectTypeDB::bind_method(_MD("_focus_node"),&SceneTreeDock::_focus_node);
- ObjectTypeDB::bind_method(_MD("_file_selected"), &SceneTreeDock::_file_selected);
ObjectTypeDB::bind_method(_MD("instance"),&SceneTreeDock::instance);
@@ -1936,8 +1895,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
ED_SHORTCUT("scene_tree/add_child_node",TTR("Add Child Node"), KEY_MASK_CMD|KEY_A);
ED_SHORTCUT("scene_tree/instance_scene",TTR("Instance Child Scene"));
ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type"));
- ED_SHORTCUT("scene_tree/add_script", TTR("Add Script"));
- ED_SHORTCUT("scene_tree/load_script", TTR("Load Script"));
+ ED_SHORTCUT("scene_tree/attach_script", TTR("Attach Script"));
+ ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script"));
ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP);
ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN);
ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"),KEY_MASK_CMD | KEY_D);
@@ -1974,18 +1933,18 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
tb = memnew( ToolButton );
- tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_CREATE_SCRIPT, false));
- tb->set_tooltip(TTR("Create a new script for the selected node."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_script"));
+ tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_ATTACH_SCRIPT, false));
+ tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
+ tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
filter_hbc->add_child(tb);
button_create_script=tb;
tb = memnew(ToolButton);
- tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_LOAD_SCRIPT, false));
- tb->set_tooltip(TTR("Load a script for the selected node."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/load_script"));
+ tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
+ tb->set_tooltip(TTR("Clear a script for the selected node."));
+ tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
filter_hbc->add_child(tb);
- button_load_script = tb;
+ button_clear_script = tb;
scene_tree = memnew( SceneTreeEditor(false,true,true ));
@@ -2004,7 +1963,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
scene_tree->connect("nodes_dragged",this,"_nodes_drag_begin");
scene_tree->get_scene_tree()->connect("item_double_clicked", this, "_focus_node");
- scene_tree->get_scene_tree()->set_delayed_text_editor(true);
scene_tree->set_undo_redo(&editor_data->get_undo_redo());
scene_tree->set_editor_selection(editor_selection);
@@ -2015,11 +1973,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
add_child(create_dialog);
create_dialog->connect("create",this,"_create");
- file_dialog = memnew(EditorFileDialog);
- add_child(file_dialog);
- file_dialog->hide();
- file_dialog->connect("file_selected", this, "_file_selected");
-
//groups_editor = memnew( GroupsEditor );
//add_child(groups_editor);
//groups_editor->set_undo_redo(&editor_data->get_undo_redo());
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index 36d4a6d208..f1b366a4c5 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -58,8 +58,8 @@ class SceneTreeDock : public VBoxContainer {
TOOL_REPLACE,
TOOL_CONNECT,
TOOL_GROUP,
- TOOL_CREATE_SCRIPT,
- TOOL_LOAD_SCRIPT,
+ TOOL_ATTACH_SCRIPT,
+ TOOL_CLEAR_SCRIPT,
TOOL_MOVE_UP,
TOOL_MOVE_DOWN,
TOOL_DUPLICATE,
@@ -76,12 +76,11 @@ class SceneTreeDock : public VBoxContainer {
int current_option;
CreateDialog *create_dialog;
- EditorFileDialog *file_dialog;
ToolButton *button_add;
ToolButton *button_instance;
ToolButton *button_create_script;
- ToolButton *button_load_script;
+ ToolButton *button_clear_script;
SceneTreeEditor *scene_tree;
diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp
index 62d5c7cd84..d7fc87167b 100644
--- a/tools/editor/script_create_dialog.cpp
+++ b/tools/editor/script_create_dialog.cpp
@@ -96,8 +96,20 @@ void ScriptCreateDialog::_class_name_changed(const String& p_name) {
void ScriptCreateDialog::ok_pressed() {
- if (class_name->is_editable() && !_validate(class_name->get_text())) {
+ if (create_new){
+ _create_new();
+ } else {
+ _load_exist();
+ }
+
+ create_new=true;
+ _update_controls();
+
+}
+
+void ScriptCreateDialog::_create_new() {
+ if (class_name->is_editable() && !_validate(class_name->get_text())) {
alert->set_text(TTR("Class name is invalid!"));
alert->popup_centered_minsize();
return;
@@ -105,21 +117,14 @@ void ScriptCreateDialog::ok_pressed() {
if (!_validate(parent_name->get_text())) {
alert->set_text(TTR("Parent class name is invalid!"));
alert->popup_centered_minsize();
-
return;
-
}
-
String cname;
if (class_name->is_editable())
cname=class_name->get_text();
-
-
-
Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
- //scr->set_source_code(text);
String selected_language = language_menu->get_item_text(language_menu->get_selected());
editor_settings->set_last_selected_language(selected_language);
@@ -127,34 +132,40 @@ void ScriptCreateDialog::ok_pressed() {
if (cname!="")
scr->set_name(cname);
-
if (!internal->is_pressed()) {
-
-
String lpath = Globals::get_singleton()->localize_path(file_path->get_text());
scr->set_path(lpath);
if (!path_valid) {
-
alert->set_text(TTR("Invalid path!"));
alert->popup_centered_minsize();
return;
-
}
Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);
if (err!=OK) {
-
alert->set_text(TTR("Could not create script in filesystem."));
alert->popup_centered_minsize();
return;
}
- //scr->set_path(lpath);
- //EditorFileSystem::get_singleton()->update_file(lpath,scr->get_type());
+ }
+ hide();
+ emit_signal("script_created",scr);
+
+}
+void ScriptCreateDialog::_load_exist() {
+
+ String path=file_path->get_text();
+ RES p_script = ResourceLoader::load(path, "Script");
+ if (p_script.is_null()) {
+ alert->get_ok()->set_text(TTR("Ugh"));
+ alert->set_text(vformat(TTR("Error loading script from %s"), path));
+ alert->popup_centered_minsize();
+ return;
}
hide();
- emit_signal("script_created",scr);
+ emit_signal("script_created",p_script.get_ref_ptr());
}
@@ -166,10 +177,35 @@ void ScriptCreateDialog::_lang_changed(int l) {
} else {
class_name->set_editable(false);
}
- if (file_path->get_text().basename()==initial_bp) {
- file_path->set_text(initial_bp+"."+ScriptServer::get_language( l )->get_extension());
- _path_changed(file_path->get_text());
+
+ String selected_ext="."+ScriptServer::get_language( l )->get_extension();
+ String path=file_path->get_text();
+ String extension="";
+ if (path.find(".")>=0) {
+ extension=path.extension();
+ }
+
+ if (extension.length()==0) {
+ // add extension if none
+ path+=selected_ext;
+ _path_changed(path);
+ } else {
+ // change extension by selected language
+ List<String> extensions;
+ // get all possible extensions for script
+ for (int l=0;l<language_menu->get_item_count();l++) {
+ ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ }
+
+ for(List<String>::Element *E=extensions.front();E;E=E->next()) {
+ if (E->get().nocasecmp_to(extension)==0) {
+ path=path.basename()+selected_ext;
+ _path_changed(path);
+ break;
+ }
+ }
}
+ file_path->set_text(path);
_class_name_changed(class_name->get_text());
}
@@ -191,8 +227,10 @@ void ScriptCreateDialog::_browse_path() {
file_browse->clear_filters();
List<String> extensions;
- int l=language_menu->get_selected();
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ // get all possible extensions for script
+ for (int l=0;l<language_menu->get_item_count();l++) {
+ ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ }
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
file_browse->add_filter("*."+E->get());
@@ -246,49 +284,57 @@ void ScriptCreateDialog::_path_changed(const String& p_path) {
memdelete(d);
}
-
-
FileAccess *f = FileAccess::create(FileAccess::ACCESS_RESOURCES);
-
- if (f->file_exists(p)) {
-
- path_error_label->set_text(TTR("File exists"));
- path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
- memdelete(f);
- return;
- }
-
+ create_new=!f->file_exists(p);
memdelete(f);
String extension=p.extension();
List<String> extensions;
- int l=language_menu->get_selected();
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ // get all possible extensions for script
+ for (int l=0;l<language_menu->get_item_count();l++) {
+ ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ }
bool found=false;
+ int index=0;
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
if (E->get().nocasecmp_to(extension)==0) {
+ language_menu->select(index); // change Language option by extension
found=true;
break;
}
+ index++;
}
if (!found) {
-
path_error_label->set_text(TTR("Invalid extension"));
path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
return;
}
+ _update_controls();
- path_error_label->set_text(TTR("Valid path"));
path_error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
path_valid=true;
}
+void ScriptCreateDialog::_update_controls() {
+
+ if (create_new) {
+ path_error_label->set_text(TTR("Create new script"));
+ get_ok()->set_text(TTR("Create"));
+ } else {
+ path_error_label->set_text(TTR("Load existing script"));
+ get_ok()->set_text(TTR("Load"));
+ }
+ parent_name->set_editable(create_new);
+ internal->set_disabled(!create_new);
+
+}
+
void ScriptCreateDialog::_bind_methods() {
@@ -376,7 +422,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
set_size(Size2(200,150));
set_hide_on_ok(false);
- set_title(TTR("Create Node Script"));
+ set_title(TTR("Attach Node Script"));
file_browse = memnew( EditorFileDialog );
file_browse->connect("file_selected",this,"_file_selected");
@@ -385,4 +431,6 @@ ScriptCreateDialog::ScriptCreateDialog() {
alert = memnew( AcceptDialog );
add_child(alert);
_lang_changed(0);
+
+ create_new=true;
}
diff --git a/tools/editor/script_create_dialog.h b/tools/editor/script_create_dialog.h
index c71ea16d39..77e5a9fddd 100644
--- a/tools/editor/script_create_dialog.h
+++ b/tools/editor/script_create_dialog.h
@@ -50,6 +50,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
VBoxContainer *path_vb;
AcceptDialog *alert;
bool path_valid;
+ bool create_new;
String initial_bp;
EditorSettings *editor_settings;
@@ -62,6 +63,9 @@ class ScriptCreateDialog : public ConfirmationDialog {
void _browse_path();
void _file_selected(const String& p_file);
virtual void ok_pressed();
+ void _create_new();
+ void _load_exist();
+ void _update_controls();
protected:
static void _bind_methods();
diff --git a/tools/scripts/addheader.py b/tools/scripts/addheader.py
index d040d8b5d6..7838e16ae0 100644
--- a/tools/scripts/addheader.py
+++ b/tools/scripts/addheader.py
@@ -1,4 +1,4 @@
-header="""\
+header = """\
/*************************************************************************/
/* $filename */
/*************************************************************************/
@@ -29,44 +29,42 @@ header="""\
/*************************************************************************/
"""
-f = open("files","rb")
+f = open("files", "rb")
fname = f.readline()
-while (fname!=""):
+while (fname != ""):
- fr = open(fname.strip(),"rb")
- l = fr.readline()
- bc=False
- fsingle = fname.strip()
+ fr = open(fname.strip(), "rb")
+ l = fr.readline()
+ bc = False
+ fsingle = fname.strip()
- if (fsingle.find("/")!=-1):
- fsingle=fsingle[fsingle.rfind("/")+1:]
- rep_fl="$filename"
- rep_fi=fsingle
- len_fl=len(rep_fl)
- len_fi=len(rep_fi)
- if (len_fi<len_fl):
- for x in range(len_fl-len_fi):
- rep_fi+=" "
- elif (len_fl<len_fi):
- for x in range(len_fi-len_fl):
- rep_fl+=" "
- if (header.find(rep_fl)!=-1):
- text=header.replace(rep_fl,rep_fi)
- else:
- text=header.replace("$filename",fsingle)
+ if (fsingle.find("/") != -1):
+ fsingle = fsingle[fsingle.rfind("/") + 1:]
+ rep_fl = "$filename"
+ rep_fi = fsingle
+ len_fl = len(rep_fl)
+ len_fi = len(rep_fi)
+ if (len_fi < len_fl):
+ for x in range(len_fl - len_fi):
+ rep_fi += " "
+ elif (len_fl < len_fi):
+ for x in range(len_fi - len_fl):
+ rep_fl += " "
+ if (header.find(rep_fl) != -1):
+ text = header.replace(rep_fl, rep_fi)
+ else:
+ text = header.replace("$filename", fsingle)
+ while (l != ""):
+ if ((l.find("//") != 0 and l.find("/*") != 0 and l.strip() != "") or bc):
+ text += l
+ bc = True
+ l = fr.readline()
- while (l!=""):
- if ((l.find("//")!=0 and l.find("/*")!=0 and l.strip()!="") or bc):
- text+=l
- bc=True
- l=fr.readline()
-
- fr.close()
- fr=open(fname.strip(),"wb")
- fr.write(text)
- fr.close()
- #print(text)
- fname=f.readline()
-
+ fr.close()
+ fr = open(fname.strip(), "wb")
+ fr.write(text)
+ fr.close()
+ # print(text)
+ fname = f.readline()
diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py
index 05352396f1..a6cdfe541f 100755
--- a/tools/scripts/file-hex-array.py
+++ b/tools/scripts/file-hex-array.py
@@ -2,34 +2,38 @@ import binascii
import os.path
import sys
+
def tof(filepath):
- with open(filepath, 'r') as f:
- content = f.read()
- content = content.replace("0x","")
- content = content.split(',')
- for i in range(len(content)):
- if len(content[i]) == 1: content[i] = "0" + content[i]
- content = "".join(content)
- with open(filepath+".file", 'wb') as f:
- content = f.write(content.decode("hex"))
- print(os.path.basename(filepath)+".file created.")
- exit(0)
+ with open(filepath, 'r') as f:
+ content = f.read()
+ content = content.replace("0x", "")
+ content = content.split(',')
+ for i in range(len(content)):
+ if len(content[i]) == 1:
+ content[i] = "0" + content[i]
+ content = "".join(content)
+ with open(filepath + ".file", 'wb') as f:
+ content = f.write(content.decode("hex"))
+ print(os.path.basename(filepath) + ".file created.")
+ exit(0)
+
def toa(filepath):
- with open(filepath, 'rb') as f:
- content = f.read()
- content = binascii.hexlify(content)
- content = [content[i:i+2] for i in range(0, len(content), 2)]
- content = ",0x".join(content)
- content = "0x" + content
- content = content.replace("0x00","0x0")
- with open(filepath+".array", 'w') as f:
- content = f.write(content)
- print(os.path.basename(filepath)+".array created.")
- exit(0)
+ with open(filepath, 'rb') as f:
+ content = f.read()
+ content = binascii.hexlify(content)
+ content = [content[i:i + 2] for i in range(0, len(content), 2)]
+ content = ",0x".join(content)
+ content = "0x" + content
+ content = content.replace("0x00", "0x0")
+ with open(filepath + ".array", 'w') as f:
+ content = f.write(content)
+ print(os.path.basename(filepath) + ".array created.")
+ exit(0)
+
def usage():
- print("========================================================\n\
+ print("========================================================\n\
#\n\
# Usage: python file-hex-array.py [action] [option]\n\
#\n\
@@ -40,13 +44,13 @@ def usage():
# Example : python file-hex-array.py toa 1.png\n\
#\n\
========================================================")
- exit(1)
+ exit(1)
if len(sys.argv) != 3:
- usage()
+ usage()
if sys.argv[1] == "toa" and os.path.isfile(sys.argv[2]):
- toa(sys.argv[2])
+ toa(sys.argv[2])
elif sys.argv[1] == "tof" and os.path.isfile(sys.argv[2]):
- tof(sys.argv[2])
+ tof(sys.argv[2])
else:
- usage() \ No newline at end of file
+ usage()
diff --git a/tools/scripts/make_bmfhdr.py b/tools/scripts/make_bmfhdr.py
index 0f6f453004..1d3c40f9c6 100644
--- a/tools/scripts/make_bmfhdr.py
+++ b/tools/scripts/make_bmfhdr.py
@@ -2,69 +2,66 @@
import sys
-if (len(sys.argv)!=2):
- print("Pass me a .fnt argument!")
+if (len(sys.argv) != 2):
+ print("Pass me a .fnt argument!")
-f = open(sys.argv[1],"rb")
+f = open(sys.argv[1], "rb")
-name = sys.argv[1].lower().replace(".fnt","")
+name = sys.argv[1].lower().replace(".fnt", "")
l = f.readline()
-font_height=0
-font_ascent=0
-font_charcount=0
-font_chars=[]
-font_cc=0
-
-while(l!=""):
-
- fs = l.strip().find(" ")
- if (fs==-1):
- l=f.readline()
- continue
- t = l[0:fs]
-
- dv = l[fs+1:].split(" ")
- d = {}
- for x in dv:
- if (x.find("=")==-1):
- continue
- s = x.split("=")
- d[ s[0] ] = s[1]
-
-
- if (t=="common"):
- font_height=d["lineHeight"]
- font_ascent=d["base"]
-
- if (t=="char"):
- font_chars.append(d["id"])
- font_chars.append(d["x"])
- font_chars.append(d["y"])
- font_chars.append(d["width"])
- font_chars.append(d["height"])
- font_chars.append(d["xoffset"])
- font_chars.append(d["yoffset"])
- font_chars.append(d["xadvance"])
- font_cc+=1
-
-
-
- l = f.readline()
-
-
-print("static const int _bi_font_"+name+"_height="+str(font_height)+";")
-print("static const int _bi_font_"+name+"_ascent="+str(font_ascent)+";")
-print("static const int _bi_font_"+name+"_charcount="+str(font_cc)+";")
-cstr="static const int _bi_font_"+name+"_characters={"
+font_height = 0
+font_ascent = 0
+font_charcount = 0
+font_chars = []
+font_cc = 0
+
+while(l != ""):
+
+ fs = l.strip().find(" ")
+ if (fs == -1):
+ l = f.readline()
+ continue
+ t = l[0:fs]
+
+ dv = l[fs + 1:].split(" ")
+ d = {}
+ for x in dv:
+ if (x.find("=") == -1):
+ continue
+ s = x.split("=")
+ d[s[0]] = s[1]
+
+ if (t == "common"):
+ font_height = d["lineHeight"]
+ font_ascent = d["base"]
+
+ if (t == "char"):
+ font_chars.append(d["id"])
+ font_chars.append(d["x"])
+ font_chars.append(d["y"])
+ font_chars.append(d["width"])
+ font_chars.append(d["height"])
+ font_chars.append(d["xoffset"])
+ font_chars.append(d["yoffset"])
+ font_chars.append(d["xadvance"])
+ font_cc += 1
+
+ l = f.readline()
+
+
+print("static const int _bi_font_" + name + "_height=" + str(font_height) + ";")
+print("static const int _bi_font_" + name + "_ascent=" + str(font_ascent) + ";")
+print("static const int _bi_font_" + name + "_charcount=" + str(font_cc) + ";")
+cstr = "static const int _bi_font_" + name + "_characters={"
for i in range(len(font_chars)):
- c=font_chars[i]
- if (i>0):
- cstr+=", "
- cstr+=c
+ c = font_chars[i]
+ if (i > 0):
+ cstr += ", "
+ cstr += c
-cstr+=("};")
+cstr += ("};")
-print(cstr) \ No newline at end of file
+print(cstr)
diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py
index b4c582f1eb..5694d2327e 100644
--- a/tools/scripts/make_glwrapper.py
+++ b/tools/scripts/make_glwrapper.py
@@ -1,32 +1,32 @@
#! /usr/bin/env python
import sys
-if (len(sys.argv)<2):
- print("usage: make_glwrapper.py <headers>")
- sys.exit(255)
+if (len(sys.argv) < 2):
+ print("usage: make_glwrapper.py <headers>")
+ sys.exit(255)
-functions=[]
-types=[]
-constants=[]
+functions = []
+types = []
+constants = []
-READ_FUNCTIONS=0
-READ_TYPES=1
-READ_CONSTANTS=2
+READ_FUNCTIONS = 0
+READ_TYPES = 1
+READ_CONSTANTS = 2
-read_what=READ_TYPES
+read_what = READ_TYPES
-for x in (range(len(sys.argv)-1)):
- f=open(sys.argv[x+1],"r")
+for x in (range(len(sys.argv) - 1)):
+ f = open(sys.argv[x + 1], "r")
- while(True):
+ while(True):
- line=f.readline()
- if (line==""):
- break
+ line = f.readline()
+ if (line == ""):
+ break
- line=line.replace("\n","").strip()
- """
+ line = line.replace("\n", "").strip()
+ """
if (line.find("[types]")!=-1):
read_what=READ_TYPES
continue
@@ -38,67 +38,66 @@ for x in (range(len(sys.argv)-1)):
continue
"""
- if (line.find("#define")!=-1):
- if (line.find("0x")==-1 and line.find("GL_VERSION")==-1):
- continue
- constants.append(line)
- elif (line.find("typedef")!=-1):
- if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1):
- continue
- types.append(line)
- elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1):
+ if (line.find("#define") != -1):
+ if (line.find("0x") == -1 and line.find("GL_VERSION") == -1):
+ continue
+ constants.append(line)
+ elif (line.find("typedef") != -1):
+ if (line.find("(") != -1 or line.find(")") != -1 or line.find("ARB") != -1 or line.find("EXT") != -1 or line.find("GL") == -1):
+ continue
+ types.append(line)
+ elif (line.find("APIENTRY") != -1 and line.find("GLAPI") != -1):
- if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1):
- continue
+ if (line.find("ARB") != -1 or line.find("EXT") != -1 or line.find("NV") != -1):
+ continue
- line=line.replace("APIENTRY","")
- line=line.replace("GLAPI","")
+ line = line.replace("APIENTRY", "")
+ line = line.replace("GLAPI", "")
- glpos=line.find(" gl")
- if (glpos==-1):
+ glpos = line.find(" gl")
+ if (glpos == -1):
- glpos=line.find("\tgl")
- if (glpos==-1):
- continue
+ glpos = line.find("\tgl")
+ if (glpos == -1):
+ continue
- ret=line[:glpos].strip();
+ ret = line[:glpos].strip()
- line=line[glpos:].strip()
- namepos=line.find("(")
+ line = line[glpos:].strip()
+ namepos = line.find("(")
- if (namepos==-1):
- continue
+ if (namepos == -1):
+ continue
- name=line[:namepos].strip()
- line=line[namepos:]
+ name = line[:namepos].strip()
+ line = line[namepos:]
- argpos=line.rfind(")")
- if (argpos==-1):
- continue
+ argpos = line.rfind(")")
+ if (argpos == -1):
+ continue
- args=line[1:argpos]
+ args = line[1:argpos]
- funcdata={}
- funcdata["ret"]=ret
- funcdata["name"]=name
- funcdata["args"]=args
+ funcdata = {}
+ funcdata["ret"] = ret
+ funcdata["name"] = name
+ funcdata["args"] = args
- functions.append(funcdata)
- print(funcdata)
+ functions.append(funcdata)
+ print(funcdata)
+# print(types)
+# print(constants)
+# print(functions)
-#print(types)
-#print(constants)
-#print(functions)
-
-f=open("glwrapper.h","w")
+f = open("glwrapper.h", "w")
f.write("#ifndef GL_WRAPPER\n")
f.write("#define GL_WRAPPER\n\n\n")
-header_code="""\
+header_code = """\
#if defined(__gl_h_) || defined(__GL_H__)
#error gl.h included before glwrapper.h
#endif
@@ -128,56 +127,52 @@ header_code="""\
f.write("#include <stddef.h>\n\n\n")
-f.write(header_code);
+f.write(header_code)
f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n")
f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n")
f.write("#define GLWRP_APIENTRY __stdcall\n")
-f.write("#else\n");
+f.write("#else\n")
f.write("#define GLWRP_APIENTRY \n")
-f.write("#endif\n\n");
+f.write("#endif\n\n")
for x in types:
- f.write(x+"\n")
+ f.write(x + "\n")
f.write("\n\n")
for x in constants:
- f.write(x+"\n")
+ f.write(x + "\n")
f.write("\n\n")
for x in functions:
- f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n")
- f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n")
+ f.write("extern " + x["ret"] + " GLWRP_APIENTRY (*__wrapper_" + x["name"] + ")(" + x["args"] + ");\n")
+ f.write("#define " + x["name"] + " __wrapper_" + x["name"] + "\n")
f.write("\n\n")
-f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n");
+f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n")
f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n")
f.write("#ifdef __cplusplus\n}\n#endif\n")
f.write("#endif\n\n")
-f=open("glwrapper.c","w")
+f = open("glwrapper.c", "w")
f.write("\n\n")
f.write("#include \"glwrapper.h\"\n")
f.write("\n\n")
for x in functions:
- f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n")
+ f.write(x["ret"] + " GLWRP_APIENTRY (*__wrapper_" + x["name"] + ")(" + x["args"] + ")=NULL;\n")
f.write("\n\n")
f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) ) {\n")
f.write("\n")
for x in functions:
- f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n")
+ f.write("\t__wrapper_" + x["name"] + "=(" + x["ret"] + " GLWRP_APIENTRY (*)(" + x["args"] + "))wrapperFunc(\"" + x["name"] + "\");\n")
f.write("\n\n")
f.write("}\n")
f.write("\n\n")
-
-
-
-
diff --git a/tools/scripts/makeargs.py b/tools/scripts/makeargs.py
index 8c5539c5fe..2cd47ae087 100644
--- a/tools/scripts/makeargs.py
+++ b/tools/scripts/makeargs.py
@@ -1,5 +1,5 @@
-text="""
+text = """
#define FUNC$numR(m_r,m_func,$argt)\\
virtual m_r m_func($argtp) { \\
if (Thread::get_caller_ID()!=server_thread) {\\
@@ -64,25 +64,19 @@ text="""
"""
+for i in range(1, 8):
-for i in range(1,8):
-
- tp=""
- p=""
- t=""
- for j in range(i):
- if (j>0):
- tp+=", "
- p+=", "
- t+=", "
- tp +=("m_arg"+str(j+1)+" p"+str(j+1))
- p+=("p"+str(j+1))
- t+=("m_arg"+str(j+1))
-
- t = text.replace("$argtp",tp).replace("$argp",p).replace("$argt",t).replace("$num",str(i))
- print(t)
-
-
-
-
+ tp = ""
+ p = ""
+ t = ""
+ for j in range(i):
+ if (j > 0):
+ tp += ", "
+ p += ", "
+ t += ", "
+ tp += ("m_arg" + str(j + 1) + " p" + str(j + 1))
+ p += ("p" + str(j + 1))
+ t += ("m_arg" + str(j + 1))
+ t = text.replace("$argtp", tp).replace("$argp", p).replace("$argt", t).replace("$num", str(i))
+ print(t)
diff --git a/tools/scripts/memsort.py b/tools/scripts/memsort.py
index d2e4fe0226..fb636b0f78 100644
--- a/tools/scripts/memsort.py
+++ b/tools/scripts/memsort.py
@@ -1,35 +1,35 @@
import sys
-arg="memdump.txt"
+arg = "memdump.txt"
-if (len(sys.argv)>1):
- arg=sys.argv[1]
+if (len(sys.argv) > 1):
+ arg = sys.argv[1]
-f = open(arg,"rb")
+f = open(arg, "rb")
-l=f.readline()
+l = f.readline()
sum = {}
-cnt={}
+cnt = {}
-while(l!=""):
+while(l != ""):
- s=l.split("-")
- amount = int(s[1])
- what=s[2]
- if (what in sum):
- sum[what]+=amount
- cnt[what]+=1
- else:
- sum[what]=amount
- cnt[what]=1
+ s = l.split("-")
+ amount = int(s[1])
+ what = s[2]
+ if (what in sum):
+ sum[what] += amount
+ cnt[what] += 1
+ else:
+ sum[what] = amount
+ cnt[what] = 1
- l=f.readline()
+ l = f.readline()
for x in sum:
- print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x]))
+ print(x.strip() + "(" + str(cnt[x]) + "):\n: " + str(sum[x]))
diff --git a/tools/scripts/svgs_2_pngs.py b/tools/scripts/svgs_2_pngs.py
index 879926ab42..b24324dcd7 100644
--- a/tools/scripts/svgs_2_pngs.py
+++ b/tools/scripts/svgs_2_pngs.py
@@ -51,7 +51,7 @@ def export_icons():
# name without extensions
name_only = file_name.replace('.svg', '')
- out_icon_names = [name_only] # export to a png with the same file name
+ out_icon_names = [name_only] # export to a png with the same file name
theme_out_icon_names = []
# special cases
if special_icons.has_key(name_only):
@@ -73,7 +73,6 @@ def export_icons():
svg_to_png(source_path, theme_dir_base + theme_out_icon_name, 90)
-
def export_theme():
svgs_path = theme_dir_source
file_names = [f for f in listdir(svgs_path) if isfile(join(svgs_path, f))]
@@ -82,7 +81,7 @@ def export_theme():
# name without extensions
name_only = file_name.replace('.svg', '')
- out_icon_names = [name_only] # export to a png with the same file name
+ out_icon_names = [name_only] # export to a png with the same file name
# special cases
if theme_icons.has_key(name_only):
special_icon = theme_icons[name_only]
@@ -102,36 +101,36 @@ special_icons = {
output_names=['icon_add'],
theme_output_names=['icon_add', 'icon_zoom_more']
),
- 'icon_new': dict( output_names=['icon_file'] ),
- 'icon_animation_tree_player': dict( output_names=['icon_animation_tree'] ),
+ 'icon_new': dict(output_names=['icon_file']),
+ 'icon_animation_tree_player': dict(output_names=['icon_animation_tree']),
'icon_tool_rotate': dict(
output_names=['icon_reload'],
- theme_output_names= ['icon_reload']
+ theme_output_names=['icon_reload']
),
- 'icon_multi_edit': dict( output_names=['icon_multi_node_edit'] ),
+ 'icon_multi_edit': dict(output_names=['icon_multi_node_edit']),
'icon_folder': dict(
output_names=['icon_load', 'icon_open'],
- theme_output_names= ['icon_folder']
+ theme_output_names=['icon_folder']
),
- 'icon_file_list': dict( output_names=['icon_enum'] ),
- 'icon_collision_2d': dict( output_names=['icon_collision_polygon_2d', 'icon_polygon_2d'] ),
- 'icon_class_list': dict( output_names=['icon_filesystem'] ),
- 'icon_color_ramp': dict( output_names=['icon_graph_color_ramp'] ),
- 'icon_translation': dict( output_names=['icon_p_hash_translation'] ),
- 'icon_shader': dict( output_names=['icon_shader_material', 'icon_material_shader'] ),
- 'icon_canvas_item_shader_graph': dict( output_names=['icon_material_shader_graph'] ),
-
- 'icon_color_pick': dict( theme_output_names= ['icon_color_pick'], avoid_self=True ),
- 'icon_play': dict( theme_output_names= ['icon_play'] ),
- 'icon_stop': dict( theme_output_names= ['icon_stop'] ),
- 'icon_zoom_less': dict( theme_output_names= ['icon_zoom_less'], avoid_self=True ),
- 'icon_zoom_reset': dict( theme_output_names= ['icon_zoom_reset'], avoid_self=True ),
+ 'icon_file_list': dict(output_names=['icon_enum']),
+ 'icon_collision_2d': dict(output_names=['icon_collision_polygon_2d', 'icon_polygon_2d']),
+ 'icon_class_list': dict(output_names=['icon_filesystem']),
+ 'icon_color_ramp': dict(output_names=['icon_graph_color_ramp']),
+ 'icon_translation': dict(output_names=['icon_p_hash_translation']),
+ 'icon_shader': dict(output_names=['icon_shader_material', 'icon_material_shader']),
+ 'icon_canvas_item_shader_graph': dict(output_names=['icon_material_shader_graph']),
+
+ 'icon_color_pick': dict(theme_output_names=['icon_color_pick'], avoid_self=True),
+ 'icon_play': dict(theme_output_names=['icon_play']),
+ 'icon_stop': dict(theme_output_names=['icon_stop']),
+ 'icon_zoom_less': dict(theme_output_names=['icon_zoom_less'], avoid_self=True),
+ 'icon_zoom_reset': dict(theme_output_names=['icon_zoom_reset'], avoid_self=True),
'icon_snap': dict(theme_output_names=['icon_snap'])
}
theme_icons = {
- 'icon_close': dict(output_names=['close', 'close_hl']),
- 'tab_menu': dict(output_names=['tab_menu_hl'])
+ 'icon_close': dict(output_names=['close', 'close_hl']),
+ 'tab_menu': dict(output_names=['tab_menu_hl'])
}
export_icons()
diff --git a/tools/translations/extract.py b/tools/translations/extract.py
index 61b07b5799..bd6f03237b 100755
--- a/tools/translations/extract.py
+++ b/tools/translations/extract.py
@@ -10,27 +10,27 @@ import sys
line_nb = False
for arg in sys.argv[1:]:
- if (arg == "--with-line-nb"):
- print("Enabling line numbers in the context locations.")
- line_nb = True
- else:
- os.sys.exit("Non supported argument '" + arg + "'. Aborting.")
+ if (arg == "--with-line-nb"):
+ print("Enabling line numbers in the context locations.")
+ line_nb = True
+ else:
+ os.sys.exit("Non supported argument '" + arg + "'. Aborting.")
if (not os.path.exists("tools")):
- os.sys.exit("ERROR: This script should be started from the root of the git repo.")
+ os.sys.exit("ERROR: This script should be started from the root of the git repo.")
matches = []
for root, dirnames, filenames in os.walk('.'):
- for filename in fnmatch.filter(filenames, '*.cpp'):
- if (filename.find("collada") != -1):
- continue
- matches.append(os.path.join(root, filename))
- for filename in fnmatch.filter(filenames, '*.h'):
- if (filename.find("collada") != -1):
- continue
- matches.append(os.path.join(root, filename))
+ for filename in fnmatch.filter(filenames, '*.cpp'):
+ if (filename.find("collada") != -1):
+ continue
+ matches.append(os.path.join(root, filename))
+ for filename in fnmatch.filter(filenames, '*.h'):
+ if (filename.find("collada") != -1):
+ continue
+ matches.append(os.path.join(root, filename))
matches.sort()
@@ -55,51 +55,51 @@ print("Updating the tools.pot template...")
for fname in matches:
- f = open(fname, "rb")
-
- l = f.readline()
- lc = 1
- while (l):
-
- patterns = ['RTR(\"', 'TTR(\"']
- idx = 0
- pos = 0
- while (pos >= 0):
- pos = l.find(patterns[idx], pos)
- if (pos == -1):
- if (idx < len(patterns) - 1):
- idx += 1
- pos = 0
- continue
- pos += 5
-
- msg = ""
- while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')):
- msg += l[pos]
- pos += 1
-
- location = os.path.relpath(fname).replace('\\','/')
- if (line_nb):
- location += ":" + str(lc)
-
- if (not msg in unique_str):
- main_po += "\n#: " + location + "\n"
- main_po += 'msgid "' + msg + '"\n'
- main_po += 'msgstr ""\n'
- unique_str.append(msg)
- unique_loc[msg] = [location]
- elif (not location in unique_loc[msg]):
- # Add additional location to previous occurence too
- msg_pos = main_po.find('\nmsgid "' + msg + '"')
- if (msg_pos == -1):
- print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.")
- main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:]
- unique_loc[msg].append(location)
-
- l = f.readline()
- lc += 1
-
- f.close()
+ f = open(fname, "rb")
+
+ l = f.readline()
+ lc = 1
+ while (l):
+
+ patterns = ['RTR(\"', 'TTR(\"']
+ idx = 0
+ pos = 0
+ while (pos >= 0):
+ pos = l.find(patterns[idx], pos)
+ if (pos == -1):
+ if (idx < len(patterns) - 1):
+ idx += 1
+ pos = 0
+ continue
+ pos += 5
+
+ msg = ""
+ while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')):
+ msg += l[pos]
+ pos += 1
+
+ location = os.path.relpath(fname).replace('\\', '/')
+ if (line_nb):
+ location += ":" + str(lc)
+
+ if (not msg in unique_str):
+ main_po += "\n#: " + location + "\n"
+ main_po += 'msgid "' + msg + '"\n'
+ main_po += 'msgstr ""\n'
+ unique_str.append(msg)
+ unique_loc[msg] = [location]
+ elif (not location in unique_loc[msg]):
+ # Add additional location to previous occurence too
+ msg_pos = main_po.find('\nmsgid "' + msg + '"')
+ if (msg_pos == -1):
+ print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.")
+ main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:]
+ unique_loc[msg].append(location)
+
+ l = f.readline()
+ lc += 1
+
+ f.close()
f = open("tools.pot", "wb")
@@ -107,15 +107,15 @@ f.write(main_po)
f.close()
if (os.name == "posix"):
- print("Wrapping template at 79 characters for compatibility with Weblate.")
- os.system("msgmerge -w79 tools.pot tools.pot > tools.pot.wrap")
- shutil.move("tools.pot.wrap", "tools.pot")
+ print("Wrapping template at 79 characters for compatibility with Weblate.")
+ os.system("msgmerge -w79 tools.pot tools.pot > tools.pot.wrap")
+ shutil.move("tools.pot.wrap", "tools.pot")
shutil.move("tools.pot", "tools/translations/tools.pot")
# TODO: Make that in a portable way, if we care; if not, kudos to Unix users
if (os.name == "posix"):
- added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell = True)
- removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell = True)
- print("\n# Template changes compared to the staged status:")
- print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed)))
+ added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell=True)
+ removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell=True)
+ print("\n# Template changes compared to the staged status:")
+ print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed)))