Skip to content

Commit

Permalink
[harmony] different fixes for Harmony with openHarmony
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Jan 5, 2022
1 parent 811b70f commit ef3449c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/renderer/src/components/modals/AddPreviewModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</h5>

<p>
<span class="select">
<span v-if="DCCClient.cameras.length > 0" class="select">
<select
class="select-input"
@change="(event) => DCCClient.setCamera(event.target.value)"
Expand All @@ -91,7 +91,7 @@
</select>
</span>

<span class="select">
<span v-if="DCCClient.renderers.length > 0" class="select">
<select
class="select-input"
@change="(event) => DCCClient.setRenderer(event.target.value)"
Expand Down
15 changes: 9 additions & 6 deletions connectors/harmony/Kitsu Publisher Plugin/HTTP/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(globals.packageFolder + '/openHarmony.js')

function HTTPDaemon(parent) {
QTcpServer.call(this, parent)

Expand All @@ -10,14 +12,12 @@ function HTTPDaemon(parent) {
}
for (var port = portIntervalMin; port <= portIntervalMax; port++) {
if (this.listen(QHostAddress.Any, port)) {
globals.$.log('INFO: Server is listening')
globals.$.log(
'INFO: Server is running on http://0.0.0.0:' + String(port)
)
$.log('INFO: Server is listening')
$.log('INFO: Server is running on http://0.0.0.0:' + String(port))
return
}
}
globals.$.log(
$.log(
'Cannot find a free port in the range [' +
String(portIntervalMin) +
'...' +
Expand Down Expand Up @@ -47,6 +47,9 @@ function HTTPDaemon(parent) {
return
}

$ = globals.$
oNode = globals.$.oNode

if (this.socket.canReadLine()) {
status_line = this.socket.readLine().toString().trim()
status_line_split = status_line.split(' ')
Expand Down Expand Up @@ -101,7 +104,7 @@ function HTTPDaemon(parent) {
this.socket.write(new QByteArray('\r\n'))
this.socket.write(new QByteArray(JSON.stringify(result)))

globals.$.log(log)
$.log(log)

this.socket.close()

Expand Down
4 changes: 2 additions & 2 deletions connectors/harmony/Kitsu Publisher Plugin/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ include(packageFolder + '/openHarmony.js')
HTTPExceptions = require(packageFolder + '/HTTP/exceptions.js')

var globals = {
packageFolder: packageFolder,
$: $,
packageFolder: packageFolder,
HTTPExceptions: HTTPExceptions
}

function configure(packageFolder, packageName) {
if (about.isPaintMode()) return

harmonyServer = require(packageFolder + '/harmonyServer.js')
harmonyServer.server.start()
}

exports.globals = globals
exports.configure = configure
47 changes: 30 additions & 17 deletions connectors/harmony/Kitsu Publisher Plugin/harmonyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ server = new HTTPServer.HTTPDaemon()
server.add_route('/', ['GET'], function (method, url) {
return {
dcc_name: 'Toon Boom Harmony',
dcc_version: globals.$.app.version,
current_project: globals.$.scene.path._path
dcc_version: $.app.version,
current_project: $.scene.path._path
}
})

Expand All @@ -32,10 +32,14 @@ server.add_route('/get-renderers', ['GET'], function (method, url) {
return nodes_str
})

globals.getExtensions = function (isVideo) {
return isVideo ? [['.mov', 'QUICKTIME']] : [['.png', 'PNG']]
}

server.add_route('/get-extensions', ['GET'], function (method, url) {
return ['true', '1', 'yes'].indexOf(url.queryItemValue('is_video')) >= 0
? [['.mov', 'QUICKTIME']]
: [['.png', 'PNG']]
return globals.getExtensions(
['true', '1', 'yes'].indexOf(url.queryItemValue('is_video')) >= 0
)
})

server.add_route('/take-render-screenshot', ['GET'], function (method, url) {
Expand All @@ -51,6 +55,14 @@ server.add_route('/take-render-screenshot', ['GET'], function (method, url) {
'Missing query argument <extension>'
)
}

image_extensions = globals.getExtensions(false)
for (var n = 0; n < image_extensions.length; n++) {
if (image_extensions[n][1] == extension) {
extension = image_extensions[n][0]
}
}

output_path = url.queryItemValue('output_path')
if (!output_path) {
date = new Date()
Expand All @@ -68,13 +80,14 @@ server.add_route('/take-render-screenshot', ['GET'], function (method, url) {
date.getSeconds()
output_path = System.getenv('TEMP') + '/harmony-' + date + extension
}

use_colorspace =
['true', '1', 'yes'].indexOf(url.queryItemValue('use_colorspace')) >= 0
return {
file: globals.$.scene.exportLayoutImage(
file: $.scene.exportLayoutImage(
output_path,
undefined,
globals.$.scene.currentFrame,
$.scene.currentFrame,
use_colorspace,
1
)._path
Expand Down Expand Up @@ -108,6 +121,14 @@ server.add_route('/take-render-animation', ['GET'], function (method, url) {
'Missing query argument <extension>'
)
}

video_extensions = globals.getExtensions(true)
for (var n = 0; n < video_extensions.length; n++) {
if (video_extensions[n][1] == extension) {
extension = video_extensions[n][0]
}
}

output_path = url.queryItemValue('output_path')
if (!output_path) {
date = new Date()
Expand All @@ -125,18 +146,10 @@ server.add_route('/take-render-animation', ['GET'], function (method, url) {
date.getSeconds()
output_path = System.getenv('TEMP') + '/harmony-' + date + extension
}
output_path = new globals.$.oFile(output_path)
output_path = new $.oFile(output_path)
use_colorspace =
['true', '1', 'yes'].indexOf(url.queryItemValue('use_colorspace')) >= 0
if (
globals.$.scene.exportQT(
output_path,
globals.$.scene.defaultDisplay,
1,
true,
false
)
) {
if ($.scene.exportQT(output_path, $.scene.defaultDisplay, 1, true, false)) {
return { file: output_path.toString() }
} else {
throw new Error("Can't create QuickTime export (" + output_path + ')')
Expand Down

0 comments on commit ef3449c

Please sign in to comment.