missed a conflict opps

This commit is contained in:
phyzical 2022-04-07 16:23:26 +08:00
parent 85e65195e5
commit a4d221f709

@ -22,59 +22,73 @@ function error_process(err, error_callback) {
if (err && error_callback) error_callback(err); if (err && error_callback) error_callback(err);
} }
<<<<<<< HEAD
if (greenworks) { if (greenworks) {
greenworks.ugcGetItems = function (options, ugc_matching_type, ugc_query_type, greenworks.ugcGetItems = function (options, ugc_matching_type, ugc_query_type, success_callback, error_callback) {
success_callback, error_callback) { if (typeof options !== "object") {
if (typeof options !== 'object') {
error_callback = success_callback; error_callback = success_callback;
success_callback = ugc_query_type; success_callback = ugc_query_type;
ugc_query_type = ugc_matching_type; ugc_query_type = ugc_matching_type;
ugc_matching_type = options; ugc_matching_type = options;
options = { options = {
'app_id': greenworks.getAppId(), app_id: greenworks.getAppId(),
'page_num': 1 page_num: 1,
} };
} }
greenworks._ugcGetItems(options, ugc_matching_type, ugc_query_type, greenworks._ugcGetItems(options, ugc_matching_type, ugc_query_type, success_callback, error_callback);
success_callback, error_callback); };
}
greenworks.ugcGetUserItems = function (options, ugc_matching_type, greenworks.ugcGetUserItems = function (
ugc_list_sort_order, ugc_list, success_callback, error_callback) { options,
if (typeof options !== 'object') { ugc_matching_type,
ugc_list_sort_order,
ugc_list,
success_callback,
error_callback,
) {
if (typeof options !== "object") {
error_callback = success_callback; error_callback = success_callback;
success_callback = ugc_list; success_callback = ugc_list;
ugc_list = ugc_list_sort_order; ugc_list = ugc_list_sort_order;
ugc_list_sort_order = ugc_matching_type; ugc_list_sort_order = ugc_matching_type;
ugc_matching_type = options; ugc_matching_type = options;
options = { options = {
'app_id': greenworks.getAppId(), app_id: greenworks.getAppId(),
'page_num': 1 page_num: 1,
} };
} }
greenworks._ugcGetUserItems(options, ugc_matching_type, ugc_list_sort_order, greenworks._ugcGetUserItems(
ugc_list, success_callback, error_callback); options,
} ugc_matching_type,
ugc_list_sort_order,
ugc_list,
success_callback,
error_callback,
);
};
greenworks.ugcSynchronizeItems = function (options, sync_dir, success_callback, greenworks.ugcSynchronizeItems = function (options, sync_dir, success_callback, error_callback) {
error_callback) { if (typeof options !== "object") {
if (typeof options !== 'object') {
error_callback = success_callback; error_callback = success_callback;
success_callback = sync_dir; success_callback = sync_dir;
sync_dir = options; sync_dir = options;
options = { options = {
'app_id': greenworks.getAppId(), app_id: greenworks.getAppId(),
'page_num': 1 page_num: 1,
} };
} }
greenworks._ugcSynchronizeItems(options, sync_dir, success_callback, greenworks._ugcSynchronizeItems(options, sync_dir, success_callback, error_callback);
error_callback); };
}
greenworks.publishWorkshopFile = function (options, file_path, image_path, title, greenworks.publishWorkshopFile = function (
description, success_callback, error_callback) { options,
if (typeof options !== 'object') { file_path,
image_path,
title,
description,
success_callback,
error_callback,
) {
if (typeof options !== "object") {
error_callback = success_callback; error_callback = success_callback;
success_callback = description; success_callback = description;
description = title; description = title;
@ -82,230 +96,22 @@ if (greenworks) {
image_path = file_path; image_path = file_path;
file_path = options; file_path = options;
options = { options = {
'app_id': greenworks.getAppId(), app_id: greenworks.getAppId(),
'tags': [] tags: [],
} };
} }
greenworks._publishWorkshopFile(options, file_path, image_path, title, greenworks._publishWorkshopFile(
description, success_callback, error_callback); options,
} file_path,
image_path,
title,
description,
success_callback,
error_callback,
);
};
greenworks.updatePublishedWorkshopFile = function (options, greenworks.updatePublishedWorkshopFile = function (
published_file_handle, file_path, image_path, title, description,
success_callback, error_callback) {
if (typeof options !== 'object') {
error_callback = success_callback;
success_callback = description;
description = title;
title = image_path;
image_path = file_path;
file_path = published_file_handle;
published_file_handle = options;
options = {
'tags': [] // No tags are set
}
}
greenworks._updatePublishedWorkshopFile(options, published_file_handle,
file_path, image_path, title, description, success_callback,
error_callback);
}
// An utility function for publish related APIs.
// It processes remains steps after saving files to Steam Cloud.
function file_share_process(file_name, image_name, next_process_func,
error_callback, progress_callback) {
if (progress_callback)
progress_callback("Completed on saving files on Steam Cloud.");
greenworks.fileShare(file_name, function () {
greenworks.fileShare(image_name, function () {
next_process_func();
}, function (err) { error_process(err, error_callback); });
}, function (err) { error_process(err, error_callback); });
}
// Publishing user generated content(ugc) to Steam contains following steps:
// 1. Save file and image to Steam Cloud.
// 2. Share the file and image.
// 3. publish the file to workshop.
greenworks.ugcPublish = function (file_name, title, description, image_name,
success_callback, error_callback, progress_callback) {
var publish_file_process = function () {
if (progress_callback)
progress_callback("Completed on sharing files.");
greenworks.publishWorkshopFile(file_name, image_name, title, description,
function (publish_file_id) { success_callback(publish_file_id); },
function (err) { error_process(err, error_callback); });
};
greenworks.saveFilesToCloud([file_name, image_name], function () {
file_share_process(file_name, image_name, publish_file_process,
error_callback, progress_callback);
}, function (err) { error_process(err, error_callback); });
}
// Update publish ugc steps:
// 1. Save new file and image to Steam Cloud.
// 2. Share file and images.
// 3. Update published file.
greenworks.ugcPublishUpdate = function (published_file_id, file_name, title,
description, image_name, success_callback, error_callback,
progress_callback) {
var update_published_file_process = function () {
if (progress_callback)
progress_callback("Completed on sharing files.");
greenworks.updatePublishedWorkshopFile(published_file_id,
file_name, image_name, title, description,
function () { success_callback(); },
function (err) { error_process(err, error_callback); });
};
greenworks.saveFilesToCloud([file_name, image_name], function () {
file_share_process(file_name, image_name, update_published_file_process,
error_callback, progress_callback);
}, function (err) { error_process(err, error_callback); });
}
// Greenworks Utils APIs implmentation.
greenworks.Utils.move = function (source_dir, target_dir, success_callback,
error_callback) {
fs.rename(source_dir, target_dir, function (err) {
if (err) {
if (error_callback) error_callback(err);
return;
}
if (success_callback)
success_callback();
});
}
greenworks.init = function () {
if (this.initAPI()) return true;
if (!this.isSteamRunning())
throw new Error("Steam initialization failed. Steam is not running.");
var appId;
try {
appId = fs.readFileSync('steam_appid.txt', 'utf8');
} catch (e) {
throw new Error("Steam initialization failed. Steam is running," +
"but steam_appid.txt is missing. Expected to find it in: " +
require('path').resolve('steam_appid.txt'));
}
if (!/^\d+ *\r?\n?$/.test(appId)) {
throw new Error("Steam initialization failed. " +
"steam_appid.txt appears to be invalid; " +
"it should contain a numeric ID: " + appId);
}
throw new Error("Steam initialization failed, but Steam is running, " +
"and steam_appid.txt is present and valid." +
"Maybe that's not really YOUR app ID? " + appId.trim());
}
var EventEmitter = require('events').EventEmitter;
greenworks.__proto__ = EventEmitter.prototype;
EventEmitter.call(greenworks);
=======
greenworks.ugcGetItems = function (options, ugc_matching_type, ugc_query_type, success_callback, error_callback) {
if (typeof options !== "object") {
error_callback = success_callback;
success_callback = ugc_query_type;
ugc_query_type = ugc_matching_type;
ugc_matching_type = options;
options = {
app_id: greenworks.getAppId(),
page_num: 1,
};
}
greenworks._ugcGetItems(options, ugc_matching_type, ugc_query_type, success_callback, error_callback);
};
greenworks.ugcGetUserItems = function (
options,
ugc_matching_type,
ugc_list_sort_order,
ugc_list,
success_callback,
error_callback,
) {
if (typeof options !== "object") {
error_callback = success_callback;
success_callback = ugc_list;
ugc_list = ugc_list_sort_order;
ugc_list_sort_order = ugc_matching_type;
ugc_matching_type = options;
options = {
app_id: greenworks.getAppId(),
page_num: 1,
};
}
greenworks._ugcGetUserItems(
options,
ugc_matching_type,
ugc_list_sort_order,
ugc_list,
success_callback,
error_callback,
);
};
greenworks.ugcSynchronizeItems = function (options, sync_dir, success_callback, error_callback) {
if (typeof options !== "object") {
error_callback = success_callback;
success_callback = sync_dir;
sync_dir = options;
options = {
app_id: greenworks.getAppId(),
page_num: 1,
};
}
greenworks._ugcSynchronizeItems(options, sync_dir, success_callback, error_callback);
};
greenworks.publishWorkshopFile = function (
options,
file_path,
image_path,
title,
description,
success_callback,
error_callback,
) {
if (typeof options !== "object") {
error_callback = success_callback;
success_callback = description;
description = title;
title = image_path;
image_path = file_path;
file_path = options;
options = {
app_id: greenworks.getAppId(),
tags: [],
};
}
greenworks._publishWorkshopFile(options, file_path, image_path, title, description, success_callback, error_callback);
};
greenworks.updatePublishedWorkshopFile = function (
options,
published_file_handle,
file_path,
image_path,
title,
description,
success_callback,
error_callback,
) {
if (typeof options !== "object") {
error_callback = success_callback;
success_callback = description;
description = title;
title = image_path;
image_path = file_path;
file_path = published_file_handle;
published_file_handle = options;
options = {
tags: [], // No tags are set
};
}
greenworks._updatePublishedWorkshopFile(
options, options,
published_file_handle, published_file_handle,
file_path, file_path,
@ -314,95 +120,86 @@ greenworks.updatePublishedWorkshopFile = function (
description, description,
success_callback, success_callback,
error_callback, error_callback,
); ) {
}; if (typeof options !== "object") {
error_callback = success_callback;
success_callback = description;
description = title;
title = image_path;
image_path = file_path;
file_path = published_file_handle;
published_file_handle = options;
options = {
tags: [], // No tags are set
};
}
greenworks._updatePublishedWorkshopFile(
options,
published_file_handle,
file_path,
image_path,
title,
description,
success_callback,
error_callback,
);
};
// An utility function for publish related APIs. // An utility function for publish related APIs.
// It processes remains steps after saving files to Steam Cloud. // It processes remains steps after saving files to Steam Cloud.
function file_share_process(file_name, image_name, next_process_func, error_callback, progress_callback) { function file_share_process(file_name, image_name, next_process_func, error_callback, progress_callback) {
if (progress_callback) progress_callback("Completed on saving files on Steam Cloud."); if (progress_callback) progress_callback("Completed on saving files on Steam Cloud.");
greenworks.fileShare( greenworks.fileShare(
file_name,
function () {
greenworks.fileShare(
image_name,
function () {
next_process_func();
},
function (err) {
error_process(err, error_callback);
},
);
},
function (err) {
error_process(err, error_callback);
},
);
}
// Publishing user generated content(ugc) to Steam contains following steps:
// 1. Save file and image to Steam Cloud.
// 2. Share the file and image.
// 3. publish the file to workshop.
greenworks.ugcPublish = function (
file_name, file_name,
function () { title,
greenworks.fileShare( description,
image_name,
success_callback,
error_callback,
progress_callback,
) {
var publish_file_process = function () {
if (progress_callback) progress_callback("Completed on sharing files.");
greenworks.publishWorkshopFile(
file_name,
image_name, image_name,
function () { title,
next_process_func(); description,
function (publish_file_id) {
success_callback(publish_file_id);
}, },
function (err) { function (err) {
error_process(err, error_callback); error_process(err, error_callback);
}, },
); );
}, };
function (err) { greenworks.saveFilesToCloud(
error_process(err, error_callback); [file_name, image_name],
},
);
}
// Publishing user generated content(ugc) to Steam contains following steps:
// 1. Save file and image to Steam Cloud.
// 2. Share the file and image.
// 3. publish the file to workshop.
greenworks.ugcPublish = function (
file_name,
title,
description,
image_name,
success_callback,
error_callback,
progress_callback,
) {
var publish_file_process = function () {
if (progress_callback) progress_callback("Completed on sharing files.");
greenworks.publishWorkshopFile(
file_name,
image_name,
title,
description,
function (publish_file_id) {
success_callback(publish_file_id);
},
function (err) {
error_process(err, error_callback);
},
);
};
greenworks.saveFilesToCloud(
[file_name, image_name],
function () {
file_share_process(file_name, image_name, publish_file_process, error_callback, progress_callback);
},
function (err) {
error_process(err, error_callback);
},
);
};
// Update publish ugc steps:
// 1. Save new file and image to Steam Cloud.
// 2. Share file and images.
// 3. Update published file.
greenworks.ugcPublishUpdate = function (
published_file_id,
file_name,
title,
description,
image_name,
success_callback,
error_callback,
progress_callback,
) {
var update_published_file_process = function () {
if (progress_callback) progress_callback("Completed on sharing files.");
greenworks.updatePublishedWorkshopFile(
published_file_id,
file_name,
image_name,
title,
description,
function () { function () {
success_callback(); file_share_process(file_name, image_name, publish_file_process, error_callback, progress_callback);
}, },
function (err) { function (err) {
error_process(err, error_callback); error_process(err, error_callback);
@ -410,71 +207,97 @@ greenworks.ugcPublishUpdate = function (
); );
}; };
greenworks.saveFilesToCloud( // Update publish ugc steps:
[file_name, image_name], // 1. Save new file and image to Steam Cloud.
function () { // 2. Share file and images.
file_share_process(file_name, image_name, update_published_file_process, error_callback, progress_callback); // 3. Update published file.
}, greenworks.ugcPublishUpdate = function (
function (err) { published_file_id,
error_process(err, error_callback); file_name,
}, title,
); description,
}; image_name,
success_callback,
error_callback,
progress_callback,
) {
var update_published_file_process = function () {
if (progress_callback) progress_callback("Completed on sharing files.");
greenworks.updatePublishedWorkshopFile(
published_file_id,
file_name,
image_name,
title,
description,
function () {
success_callback();
},
function (err) {
error_process(err, error_callback);
},
);
};
// Greenworks Utils APIs implmentation. greenworks.saveFilesToCloud(
greenworks.Utils.move = function (source_dir, target_dir, success_callback, error_callback) { [file_name, image_name],
fs.rename(source_dir, target_dir, function (err) { function () {
if (err) { file_share_process(file_name, image_name, update_published_file_process, error_callback, progress_callback);
if (error_callback) error_callback(err); },
return; function (err) {
error_process(err, error_callback);
},
);
};
// Greenworks Utils APIs implmentation.
greenworks.Utils.move = function (source_dir, target_dir, success_callback, error_callback) {
fs.rename(source_dir, target_dir, function (err) {
if (err) {
if (error_callback) error_callback(err);
return;
}
if (success_callback) success_callback();
});
};
greenworks.init = function () {
if (this.initAPI()) return true;
if (!this.isSteamRunning()) throw new Error("Steam initialization failed. Steam is not running.");
var appId;
try {
appId = fs.readFileSync("steam_appid.txt", "utf8");
} catch (e) {
throw new Error(
"Steam initialization failed. Steam is running," +
"but steam_appid.txt is missing. Expected to find it in: " +
require("path").resolve("steam_appid.txt"),
);
}
if (!/^\d+ *\r?\n?$/.test(appId)) {
throw new Error(
"Steam initialization failed. " +
"steam_appid.txt appears to be invalid; " +
"it should contain a numeric ID: " +
appId,
);
} }
if (success_callback) success_callback();
});
};
greenworks.init = function () {
if (this.initAPI()) return true;
if (!this.isSteamRunning()) throw new Error("Steam initialization failed. Steam is not running.");
var appId;
try {
appId = fs.readFileSync("steam_appid.txt", "utf8");
} catch (e) {
throw new Error( throw new Error(
"Steam initialization failed. Steam is running," + "Steam initialization failed, but Steam is running, " +
"but steam_appid.txt is missing. Expected to find it in: " + "and steam_appid.txt is present and valid." +
require("path").resolve("steam_appid.txt"), "Maybe that's not really YOUR app ID? " +
appId.trim(),
); );
} };
if (!/^\d+ *\r?\n?$/.test(appId)) {
throw new Error(
"Steam initialization failed. " +
"steam_appid.txt appears to be invalid; " +
"it should contain a numeric ID: " +
appId,
);
}
throw new Error(
"Steam initialization failed, but Steam is running, " +
"and steam_appid.txt is present and valid." +
"Maybe that's not really YOUR app ID? " +
appId.trim(),
);
};
var EventEmitter = require("events").EventEmitter; var EventEmitter = require("events").EventEmitter;
greenworks.__proto__ = EventEmitter.prototype; greenworks.__proto__ = EventEmitter.prototype;
EventEmitter.call(greenworks); EventEmitter.call(greenworks);
>>>>>>> dev
greenworks._steam_events.on = function () { greenworks._steam_events.on = function () {
greenworks.emit.apply(greenworks, arguments); greenworks.emit.apply(greenworks, arguments);
}; };
<<<<<<< HEAD process.versions["greenworks"] = greenworks._version;
process.versions['greenworks'] = greenworks._version;
} }
=======
process.versions["greenworks"] = greenworks._version;
>>>>>>> dev
module.exports = greenworks; module.exports = greenworks;