Skip to content

Commit

Permalink
Review fixes: docs and icon colors
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaaad committed May 7, 2024
1 parent eb0b2e6 commit 0702548
Show file tree
Hide file tree
Showing 40 changed files with 186 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
public interface ILuaTranspiler {

/**
* @return A resource path to a build file, a project-relative path starting with slash,
* e.g. {@code "/tlconfig.lua"}
* @return A resource path to a build file, i.e. a file that configures the transpiler;
* a project-relative path starting with slash, e.g. {@code "/tlconfig.lua"}
*/
String getBuildFileResourcePath();

Expand All @@ -39,8 +39,14 @@ public interface ILuaTranspiler {
/**
* Build the project from the source dir to output dir
*
* @param pluginDir a dir inside the project root that contains unpacked plugins that may be
* used for compilation (i.e. transpiler binaries)
* @param pluginDir a build plugins dir inside the project root that contains unpacked plugins
* from all project extensions, useful for distributing and using transpiler
* binaries. When directory is a native extension (i.e. has {@code "ext.manifest"}
* file), even if it comes from a dependency, files from
* {@code "${ext-dir}/plugins/bin/${platform}/"} (or {@code "${ext-dir}/plugins/bin/${platform}.zip"})
* will be extracted to the plugin dir, and then may be subsequently accessed (and
* executed) using this path, e.g. with {@code new File(pluginDir, "my-transpiler-lib/plugins/bin/"
* + Platform.getHostPlatform().getPair() + "/my-transpiler.exe")}
* @param sourceDir a dir that is guaranteed to have all the source code files as reported
* by {@link #getSourceExt()}, and a build file, as reported by
* {@link #getBuildFileResourcePath()}. This might be a real project dir,
Expand All @@ -49,8 +55,9 @@ public interface ILuaTranspiler {
* @param outputDir a dir to put the transpiled lua files to. All lua files from the
* directory will be compiled as a part of the project compilation. The
* directory is preserved over editor/bob transpiler runs and editor restarts,
* so it's a responsibility of the transpiler to clear it from the old files
* @return a possibly empty or nullable list of build issues
* so it's a responsibility of the transpiler to clear out unneeded files from
* previous runs
* @return a possibly empty (but not nullable!) list of build issues
*/
List<Issue> transpile(File pluginDir, File sourceDir, File outputDir) throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,10 @@ private void transpileLua(IProgress monitor) throws CompileExceptionError, IOExc
.map(this::getResource)
.collect(Collectors.toList());
if (!sources.isEmpty()) {
// We transpile to lua from the project dir only if all the source code files exist on disc. Since
// some source file may come as dependencies in zip archives, the transpiler will not be able to
// transpile them. In this situation, we extract all source files to a temporary folder. Similar
// logic is implemented in editor in editor.code.transpilers/produce-build-output function
boolean useProjectDir = buildFileResource instanceof DefaultResource && sources.stream().allMatch(s -> s instanceof DefaultResource);
File sourceDir;
if (useProjectDir) {
Expand Down
1 change: 1 addition & 0 deletions editor/src/clj/editor/animation_set.clj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
(resource-node/register-ddf-resource-type workspace
:ext "animationset"
:icon animation-set-icon
:icon-class :property
:label "Animation Set"
:load-fn load-animation-set
:sanitize-fn sanitize-animation-set
Expand Down
2 changes: 1 addition & 1 deletion editor/src/clj/editor/asset_browser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@
(when (workspace/has-template? workspace resource-type)
{:label (or (:label resource-type) (:ext resource-type))
:icon (:icon resource-type)
:style (resource/ext-style-classes (:ext resource-type))
:style (resource/type-style-classes resource-type)
:command :new-file
:user-data {:resource-type resource-type}})))
(workspace/get-resource-type-map workspace))))))
Expand Down
21 changes: 11 additions & 10 deletions editor/src/clj/editor/atlas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
page-offset-x (get-rect-page-offset layout-width (:page rect))]
(doseq [p vertex-line-points]
(let [x (+ (:x rect) (* 0.5 width) (* width (first p)) page-offset-x)
y (+ (:y rect) (* 0.5 height) (* height (second p))) ]
y (+ (:y rect) (* 0.5 height) (* height (second p)))]
(vtx/buf-push-floats! buf (gen-outline-vertex wt pt x y cr cg cb))))))

(defn- gen-outline-vertex-buffer [renderables count]
Expand Down Expand Up @@ -954,15 +954,16 @@

(defn register-resource-types [workspace]
(resource-node/register-ddf-resource-type workspace
:ext "atlas"
:label "Atlas"
:build-ext "a.texturesetc"
:node-type AtlasNode
:ddf-type AtlasProto$Atlas
:load-fn load-atlas
:icon atlas-icon
:view-types [:scene :text]
:view-opts {:scene {:grid false}}))
:ext "atlas"
:label "Atlas"
:build-ext "a.texturesetc"
:node-type AtlasNode
:ddf-type AtlasProto$Atlas
:load-fn load-atlas
:icon atlas-icon
:icon-class :design
:view-types [:scene :text]
:view-opts {:scene {:grid false}}))

(defn- selection->atlas [selection] (handler/adapt-single selection AtlasNode))
(defn- selection->animation [selection] (handler/adapt-single selection AtlasAnimation))
Expand Down
4 changes: 2 additions & 2 deletions editor/src/clj/editor/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
(if-let [resolved (.get seen content-hash)]
resolved
(let [result
(if (reduce #(if (identical? %2 build-target) (reduced true) %1) false stack)
(if (coll/some #(identical? build-target %) stack)
(let [cycle (into []
(comp
(drop-while #(not (identical? % build-target)))
Expand Down Expand Up @@ -177,5 +177,5 @@
build-targets (resolve-dependencies [node-build-targets extra-build-targets] project evaluation-context)]
(if (g/error? build-targets)
{:error build-targets}
(let [build-dir (workspace/build-path (project/workspace project))]
(let [build-dir (workspace/build-path (project/workspace project evaluation-context))]
(pipeline/build! build-targets build-dir old-artifact-map (progress/nest-render-progress render-progress! (progress/make "" 10 5) 5))))))
1 change: 1 addition & 0 deletions editor/src/clj/editor/camera_editor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@
:ddf-type Camera$CameraDesc
:load-fn load-camera
:icon camera-icon
:icon-class :property
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
Expand Down
4 changes: 4 additions & 0 deletions editor/src/clj/editor/code/script.clj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
:language "lua"
:label "Script"
:icon "icons/32/Icons_12-Script-type.png"
:icon-class :script
:view-types [:code :default]
:view-opts lua-code-opts
:tags #{:component :debuggable :non-embeddable :overridable-properties}
Expand All @@ -122,20 +123,23 @@
:language "lua"
:label "Render Script"
:icon "icons/32/Icons_12-Script-type.png"
:icon-class :script
:view-types [:code :default]
:view-opts lua-code-opts
:tags #{:debuggable}}
{:ext "gui_script"
:language "lua"
:label "Gui Script"
:icon "icons/32/Icons_12-Script-type.png"
:icon-class :script
:view-types [:code :default]
:view-opts lua-code-opts
:tags #{:debuggable}}
{:ext "lua"
:language "lua"
:label "Lua Module"
:icon "icons/32/Icons_11-Script-general.png"
:icon-class :script
:view-types [:code :default]
:view-opts lua-code-opts
:tags #{:debuggable}}])
Expand Down
3 changes: 3 additions & 0 deletions editor/src/clj/editor/code/shader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@
:language "glsl"
:label "Vertex Program"
:icon "icons/32/Icons_32-Vertex-shader.png"
:icon-class :script
:view-types [:code :default]
:view-opts glsl-opts}
{:ext "fp"
:language "glsl"
:label "Fragment Program"
:icon "icons/32/Icons_33-Fragment-shader.png"
:icon-class :script
:view-types [:code :default]
:view-opts glsl-opts}
{:ext "glsl"
:label "Shader Include"
:icon "icons/64/Icons_29-AT-Unknown.png"
:icon-class :script
:view-types [:code :default]
:view-opts glsl-opts}])

Expand Down
13 changes: 11 additions & 2 deletions editor/src/clj/editor/code/transpilers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
use-project-dir (every? (fn [{:keys [resource dirty?]}]
(and (not dirty?) (resource/file-resource? resource)))
all-sources)
;; We transpile to lua from the project dir only if all the source code files exist on disc. Since
;; some source file may come as dependencies in zip archives or modified in memory without saving
;; to disc, the transpiler will not be able to transpile them. In this situation, we extract all
;; source files to a temporary folder. Similar logic is implemented in bob in
;; com.dynamo.bob.Project::transpileLua method
source-dir (if use-project-dir
(io/file root)
(make-temporary-compile-directory! instance all-sources))
Expand All @@ -91,7 +96,10 @@
(into {}
(keep
(fn [^File file]
(when (= "lua" (FilenameUtils/getExtension (.getName file)))
(when (= "lua" (string/lower-case (FilenameUtils/getExtension (.getName file))))
;; If transpiler emits invalid lua file, the build process will return
;; a build error that points to a lua file that does not exist in the
;; resource tree
(let [resource (resource/make-file-resource workspace (str output-dir) file [] (constantly false))
build-targets (script-compilation/build-targets build-file-node-id resource (code.util/split-lines (slurp resource)) lua-preprocessors [] [] proj-path->node-id)]
(pair (resource/proj-path resource) build-targets)))))
Expand Down Expand Up @@ -130,7 +138,7 @@
(pair-map-by :build-file-proj-path :_node-id transpiler-infos))))
(output build-output g/Any :cached
(g/fnk [build-outputs]
(persistent! (reduce conj! (transient {}) build-outputs)))))
(into {} build-outputs))))

(g/defnode SourceNode
(inherits r/CodeEditorResourceNode))
Expand Down Expand Up @@ -220,6 +228,7 @@
workspace
:ext source-ext
:icon "icons/32/Icons_12-Script-type.png"
:icon-class :script
:node-type SourceNode
:view-types [:code :default]
:additional-load-fn (fn [_ self _]
Expand Down
1 change: 1 addition & 0 deletions editor/src/clj/editor/collection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -778,5 +778,6 @@
:dependencies-fn (collection-common/make-collection-dependencies-fn #(workspace/get-resource-type workspace :editable "go"))
:sanitize-fn (partial sanitize-collection workspace)
:icon collection-common/collection-icon
:icon-class :design
:view-types [:scene :text]
:view-opts {:scene {:grid true}}))
1 change: 1 addition & 0 deletions editor/src/clj/editor/collection_non_editable.clj
Original file line number Diff line number Diff line change
Expand Up @@ -441,5 +441,6 @@
:sanitize-fn (partial sanitize-non-editable-collection workspace)
:load-fn load-non-editable-collection
:icon collection-common/collection-icon
:icon-class :design
:view-types [:scene :text]
:view-opts {:scene {:grid true}}))
21 changes: 11 additions & 10 deletions editor/src/clj/editor/collection_proxy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,14 @@
(defn register-resource-types
[workspace]
(resource-node/register-ddf-resource-type workspace
:ext "collectionproxy"
:node-type CollectionProxyNode
:ddf-type GameSystem$CollectionProxyDesc
:load-fn load-collection-proxy
:icon collection-proxy-icon
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Collection Proxy"))
:ext "collectionproxy"
:node-type CollectionProxyNode
:ddf-type GameSystem$CollectionProxyDesc
:load-fn load-collection-proxy
:icon collection-proxy-icon
:icon-class :property
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Collection Proxy"))
23 changes: 12 additions & 11 deletions editor/src/clj/editor/collision_object.clj
Original file line number Diff line number Diff line change
Expand Up @@ -590,17 +590,18 @@

(defn register-resource-types [workspace]
(resource-node/register-ddf-resource-type workspace
:ext "collisionobject"
:node-type CollisionObjectNode
:ddf-type Physics$CollisionObjectDesc
:load-fn load-collision-object
:sanitize-fn sanitize-collision-object
:icon collision-object-icon
:view-types [:scene :text]
:view-opts {:scene {:grid true}}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Collision Object"))
:ext "collisionobject"
:node-type CollisionObjectNode
:ddf-type Physics$CollisionObjectDesc
:load-fn load-collision-object
:sanitize-fn sanitize-collision-object
:icon collision-object-icon
:icon-class :design
:view-types [:scene :text]
:view-opts {:scene {:grid true}}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Collision Object"))

;; outline context menu

Expand Down
1 change: 1 addition & 0 deletions editor/src/clj/editor/cubemap.clj
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,5 @@
:ddf-type Graphics$Cubemap
:load-fn load-cubemap
:icon cubemap-icon
:icon-class :design
:view-types [:scene :text]))
2 changes: 2 additions & 0 deletions editor/src/clj/editor/display_profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
:label "Display Profiles"
:view-types [:cljfx-form-view :text]
:icon "icons/32/Icons_50-Display-profiles.png"
:icon-class :property
:pb-class Render$DisplayProfiles})

(g/defnode ProfileNode
Expand Down Expand Up @@ -140,4 +141,5 @@
:ddf-type Render$DisplayProfiles
:load-fn (fn [project self resource pb] (load-display-profiles project self resource pb))
:icon (:icon pb-def)
:icon-class (:icon-class pb-def)
:view-types (:view-types pb-def)))
50 changes: 26 additions & 24 deletions editor/src/clj/editor/factory.clj
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,29 @@
(defn register-resource-types
[workspace]
(concat
(resource-node/register-ddf-resource-type workspace
:textual? true
:ext "factory"
:node-type FactoryNode
:ddf-type GameSystem$FactoryDesc
:load-fn (partial load-factory :game-object)
:icon (get-in factory-types [:game-object :icon])
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Factory")
(resource-node/register-ddf-resource-type workspace
:textual? true
:ext "collectionfactory"
:node-type FactoryNode
:ddf-type GameSystem$CollectionFactoryDesc
:load-fn (partial load-factory :collection)
:icon (get-in factory-types [:collection :icon])
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Collection Factory")))
(resource-node/register-ddf-resource-type workspace
:textual? true
:ext "factory"
:node-type FactoryNode
:ddf-type GameSystem$FactoryDesc
:load-fn (partial load-factory :game-object)
:icon (get-in factory-types [:game-object :icon])
:icon-class :property
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Factory")
(resource-node/register-ddf-resource-type workspace
:textual? true
:ext "collectionfactory"
:node-type FactoryNode
:ddf-type GameSystem$CollectionFactoryDesc
:load-fn (partial load-factory :collection)
:icon (get-in factory-types [:collection :icon])
:icon-class :property
:view-types [:cljfx-form-view :text]
:view-opts {}
:tags #{:component}
:tag-opts {:component {:transform-properties #{}}}
:label "Collection Factory")))
1 change: 1 addition & 0 deletions editor/src/clj/editor/font.clj
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@
:ddf-type Font$FontDesc
:load-fn load-font
:icon font-icon
:icon-class :design
:view-types [:scene :text])
(workspace/register-resource-type workspace
:ext "glyph_bank")
Expand Down
1 change: 1 addition & 0 deletions editor/src/clj/editor/game_object.clj
Original file line number Diff line number Diff line change
Expand Up @@ -591,5 +591,6 @@
:dependencies-fn (game-object-common/make-game-object-dependencies-fn #(workspace/get-resource-type-map workspace))
:sanitize-fn (partial sanitize-game-object workspace)
:icon game-object-common/game-object-icon
:icon-class :design
:view-types [:scene :text]
:view-opts {:scene {:grid true}}))
1 change: 1 addition & 0 deletions editor/src/clj/editor/game_object_non_editable.clj
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,6 @@
:sanitize-fn (partial sanitize-non-editable-game-object workspace)
:load-fn load-non-editable-game-object
:icon game-object-common/game-object-icon
:icon-class :design
:view-types [:scene :text]
:view-opts {:scene {:grid true}}))
1 change: 1 addition & 0 deletions editor/src/clj/editor/game_project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@
:load-fn load-game-project
:meta-settings (:settings gpcore/basic-meta-info)
:icon game-project-icon
:icon-class :property
:view-types [:cljfx-form-view :text]))

0 comments on commit 0702548

Please sign in to comment.