mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
- Add option to include Steam avatar in the workshop thumbnail.
This commit is contained in:
parent
87295a5f88
commit
844d9e6f27
5 changed files with 129 additions and 24 deletions
|
@ -185,8 +185,10 @@
|
|||
#endregion
|
||||
|
||||
#region steam
|
||||
globalvar STEAM_ENABLED, STEAM_APP_ID, STEAM_USER_ID, STEAM_USERNAME;
|
||||
globalvar STEAM_ENABLED, STEAM_APP_ID, STEAM_USER_ID, STEAM_USERNAME, STEAM_AVATAR;
|
||||
globalvar STEAM_UGC_ITEM_UPLOADING, STEAM_UGC_ITEM_ID, STEAM_UGC_ITEM_FILE, STEAM_UGC_UPDATE_HANDLE;
|
||||
globalvar STEAM_UGC_ITEM_AVATAR;
|
||||
|
||||
globalvar STEAM_UGC_SUBMIT_ID, STEAM_UGC_UPDATE_MAP, STEAM_UGC_PUBLISH_ID, STEAM_UGC_UPDATE, STEAM_UGC_TYPE;
|
||||
globalvar STEAM_SUB_ID;
|
||||
|
||||
|
@ -200,20 +202,27 @@
|
|||
STEAM_SUB_ID = 0;
|
||||
STEAM_USER_ID = 0;
|
||||
STEAM_USERNAME = "";
|
||||
STEAM_AVATAR = 0;
|
||||
|
||||
STEAM_UGC_UPDATE_HANDLE = 0;
|
||||
STEAM_UGC_ITEM_ID = 0;
|
||||
STEAM_UGC_PUBLISH_ID = 0;
|
||||
STEAM_UGC_SUBMIT_ID = 0;
|
||||
STEAM_UGC_ITEM_UPLOADING = false;
|
||||
STEAM_ENABLED = steam_initialised();
|
||||
STEAM_UGC_UPDATE = false;
|
||||
STEAM_UGC_UPDATE_MAP = ds_map_create();
|
||||
steam_avatar_id = "";
|
||||
|
||||
STEAM_UGC_UPDATE_HANDLE = 0;
|
||||
STEAM_UGC_ITEM_ID = 0;
|
||||
STEAM_UGC_PUBLISH_ID = 0;
|
||||
STEAM_UGC_SUBMIT_ID = 0;
|
||||
STEAM_UGC_ITEM_UPLOADING = false;
|
||||
STEAM_ENABLED = steam_initialised();
|
||||
STEAM_UGC_UPDATE = false;
|
||||
STEAM_UGC_UPDATE_MAP = ds_map_create();
|
||||
|
||||
STEAM_UGC_ITEM_AVATAR = true;
|
||||
|
||||
if(STEAM_ENABLED) {
|
||||
STEAM_APP_ID = steam_get_app_id();
|
||||
STEAM_USER_ID = steam_get_user_account_id();
|
||||
STEAM_USERNAME = steam_get_persona_name();
|
||||
STEAM_APP_ID = steam_get_app_id();
|
||||
STEAM_USER_ID = steam_get_user_account_id();
|
||||
STEAM_USERNAME = steam_get_persona_name();
|
||||
steam_avatar_id = steam_get_user_avatar(steam_get_user_steam_id(), steam_user_avatar_size_large);
|
||||
|
||||
steam_set_warning_message_hook();
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -129,5 +129,22 @@ if(PROJECT.active && !PROJECT.safeMode) { #region node step
|
|||
screen_save(file);
|
||||
steam_send_screenshot(file, window_get_width(), window_get_height());
|
||||
}
|
||||
|
||||
if (steam_avatar_id > 0 && STEAM_AVATAR == 0) {
|
||||
var _l_dims = steam_image_get_size(steam_avatar_id);
|
||||
var _buff_size = _l_dims[0] * _l_dims[1] * 4;
|
||||
var _l_cols = buffer_create(_buff_size, buffer_fixed, 1);
|
||||
var _l_ok = steam_image_get_rgba(steam_avatar_id, _l_cols, _buff_size);
|
||||
|
||||
if(_l_ok) {
|
||||
var _l_surf = surface_create(_l_dims[0], _l_dims[1]);
|
||||
buffer_set_surface(_l_cols, _l_surf, 0);
|
||||
|
||||
STEAM_AVATAR = sprite_create_from_surface(_l_surf, 0, 0, _l_dims[0], _l_dims[1], false, false, 0, 0);
|
||||
surface_free(_l_surf);
|
||||
}
|
||||
|
||||
buffer_delete(_l_cols);
|
||||
}
|
||||
}
|
||||
#endregion
|
|
@ -122,6 +122,8 @@ function Panel_Inspector() : PanelContent() constructor {
|
|||
[ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ],
|
||||
[ __txt("Group Properties"), true ],
|
||||
];
|
||||
|
||||
meta_steam_avatar = new checkBox(function() { STEAM_UGC_ITEM_AVATAR = !STEAM_UGC_ITEM_AVATAR; });
|
||||
#endregion
|
||||
|
||||
#region ---- workshop ----
|
||||
|
@ -299,7 +301,7 @@ function Panel_Inspector() : PanelContent() constructor {
|
|||
switch(i) {
|
||||
case 0 :
|
||||
var _edt = PROJECT.attributeEditor;
|
||||
var _lh;
|
||||
var _lh, wh;
|
||||
|
||||
for( var j = 0; j < array_length(_edt); j++ ) {
|
||||
var title = _edt[j][0];
|
||||
|
@ -359,6 +361,9 @@ function Panel_Inspector() : PanelContent() constructor {
|
|||
break;
|
||||
|
||||
case 1 :
|
||||
var _wdx = viewMode == INSP_VIEW_MODE.spacious? ui(16) : ui(140);
|
||||
var _wdw = w - ui(48) - _wdx;
|
||||
|
||||
for( var j = 0; j < array_length(meta.displays); j++ ) {
|
||||
var display = meta.displays[j];
|
||||
|
||||
|
@ -377,12 +382,9 @@ function Panel_Inspector() : PanelContent() constructor {
|
|||
meta_tb[j].setFocusHover(pFOCUS, _hover);
|
||||
if(pFOCUS) meta_tb[j].register(contentPane);
|
||||
|
||||
var wh = 0;
|
||||
var _dataFunc = display[1];
|
||||
var _data = _dataFunc(meta);
|
||||
var _wdx = viewMode == INSP_VIEW_MODE.spacious? ui(16) : ui(140);
|
||||
var _wdy = yy;
|
||||
var _wdw = w - ui(48) - _wdx;
|
||||
var _wdh = display[2];
|
||||
|
||||
var _param = new widgetParam(_wdx, _wdy, _wdw, _wdh, _data, {}, _m, rx, ry);
|
||||
|
@ -404,6 +406,21 @@ function Panel_Inspector() : PanelContent() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
if(STEAM_ENABLED) {
|
||||
meta_steam_avatar.setFocusHover(pFOCUS, _hover);
|
||||
if(pFOCUS) meta_steam_avatar.register(contentPane);
|
||||
|
||||
draw_set_text(_font, fa_left, fa_top, COLORS._main_text_inner);
|
||||
draw_text_over(ui(16), viewMode == INSP_VIEW_MODE.spacious? yy : yy + ui(3), __txt("Show Avatar"));
|
||||
|
||||
var _param = new widgetParam(_wdx, yy, _wdw, TEXTBOX_HEIGHT, STEAM_UGC_ITEM_AVATAR, {}, _m, rx, ry);
|
||||
_param.font = _font;
|
||||
wh = meta_steam_avatar.drawParam(_param);
|
||||
|
||||
yy += wh + ui(6); hh += wh + ui(6);
|
||||
if(viewMode == INSP_VIEW_MODE.spacious) { yy += ui(2); hh += ui(2); }
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
|
|
|
@ -63,6 +63,33 @@ function steam_ugc_collection_generate(file, dest_path = TEMPDIR + "steamUGCthum
|
|||
var spr = sprite_add(file, 0, false, false, 0, 0);
|
||||
var _s = surface_create(prev_size, prev_size);
|
||||
|
||||
var avar_size = 80;
|
||||
var avartar = surface_create(avar_size, avar_size);
|
||||
|
||||
if(sprite_exists(STEAM_AVATAR)) {
|
||||
var spw = sprite_get_width(STEAM_AVATAR);
|
||||
var sph = sprite_get_height(STEAM_AVATAR);
|
||||
var ss = avar_size / max(spw, sph);
|
||||
|
||||
surface_set_target(avartar);
|
||||
DRAW_CLEAR
|
||||
|
||||
var avw = spw * ss;
|
||||
var avh = sph * ss;
|
||||
var avx = avar_size / 2 - avw / 2;
|
||||
var avy = avar_size / 2 - avh / 2;
|
||||
|
||||
BLEND_NORMAL
|
||||
draw_sprite_ext(STEAM_AVATAR, 0, avx, avy, ss, ss, 0, c_white, 1);
|
||||
BLEND_MULTIPLY
|
||||
draw_sprite_stretched(THEME.timeline_node, 0, avx, avy, avw, avh);
|
||||
BLEND_NORMAL
|
||||
|
||||
draw_sprite_stretched_add(THEME.timeline_node, 1, avx, avy, avw, avh, c_white, 0.3);
|
||||
|
||||
surface_reset_target();
|
||||
}
|
||||
|
||||
surface_set_target(_s);
|
||||
draw_clear(COLORS._main_icon_dark);
|
||||
draw_sprite_tiled(s_workshop_bg, 0, -64, -64);
|
||||
|
@ -81,8 +108,12 @@ function steam_ugc_collection_generate(file, dest_path = TEMPDIR + "steamUGCthum
|
|||
var _bw = 48 + string_width(VERSION_STRING);
|
||||
var _bh = 80;
|
||||
draw_sprite_stretched(s_workshop_badge_version, 0, prev_size - 8 - _bw, prev_size - 8 - _bh, _bw, _bh);
|
||||
draw_text(prev_size - 16, prev_size - 8, VERSION_STRING);
|
||||
draw_text(prev_size - 16, prev_size - 4, VERSION_STRING);
|
||||
|
||||
if(sprite_exists(STEAM_AVATAR) && STEAM_UGC_ITEM_AVATAR) draw_surface(avartar, prev_size - 24 - avar_size, 24);
|
||||
surface_reset_target();
|
||||
surface_save_safe(_s, dest_path);
|
||||
|
||||
surface_free(_s);
|
||||
surface_free(avartar);
|
||||
} #endregion
|
|
@ -1,4 +1,4 @@
|
|||
function steam_ugc_create_project() { #region
|
||||
function steam_ugc_create_project() {
|
||||
if(STEAM_UGC_ITEM_UPLOADING) return;
|
||||
|
||||
var file = new FileObject(string_replace(filename_name(PROJECT.path), filename_ext(PROJECT.path), ""), PROJECT.path);
|
||||
|
@ -21,9 +21,9 @@ function steam_ugc_create_project() { #region
|
|||
steam_ugc_project_generate(DIRECTORY + "steamUGC/thumbnail.png");
|
||||
|
||||
STEAM_UGC_ITEM_ID = steam_ugc_create_item(STEAM_APP_ID, ugc_filetype_community);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function steam_ugc_update_project(update_preview = false, update_note = "Updated") { #region
|
||||
function steam_ugc_update_project(update_preview = false, update_note = "Updated") {
|
||||
if(STEAM_UGC_ITEM_UPLOADING) return;
|
||||
|
||||
var file = new FileObject(filename_name_only(PROJECT.path), PROJECT.path);
|
||||
|
@ -61,15 +61,42 @@ function steam_ugc_update_project(update_preview = false, update_note = "Updated
|
|||
steam_ugc_set_item_preview(STEAM_UGC_UPDATE_HANDLE, TEMPDIR + "steamUGCthumbnail.png");
|
||||
|
||||
STEAM_UGC_SUBMIT_ID = steam_ugc_submit_item_update(STEAM_UGC_UPDATE_HANDLE, update_note);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function steam_ugc_project_generate(file, dest_path = TEMPDIR + "steamUGCthumbnail.png") { #region
|
||||
function steam_ugc_project_generate(file, dest_path = TEMPDIR + "steamUGCthumbnail.png") {
|
||||
file_delete(dest_path);
|
||||
|
||||
var prev_size = 512;
|
||||
var spr = sprite_add(file, 0, false, false, 0, 0);
|
||||
var _s = surface_create(prev_size, prev_size);
|
||||
|
||||
var avar_size = 80;
|
||||
var avartar = surface_create(avar_size, avar_size);
|
||||
|
||||
if(sprite_exists(STEAM_AVATAR)) {
|
||||
var spw = sprite_get_width(STEAM_AVATAR);
|
||||
var sph = sprite_get_height(STEAM_AVATAR);
|
||||
var ss = avar_size / max(spw, sph);
|
||||
|
||||
surface_set_target(avartar);
|
||||
DRAW_CLEAR
|
||||
|
||||
var avw = spw * ss;
|
||||
var avh = sph * ss;
|
||||
var avx = avar_size / 2 - avw / 2;
|
||||
var avy = avar_size / 2 - avh / 2;
|
||||
|
||||
BLEND_NORMAL
|
||||
draw_sprite_ext(STEAM_AVATAR, 0, avx, avy, ss, ss, 0, c_white, 1);
|
||||
BLEND_MULTIPLY
|
||||
draw_sprite_stretched(THEME.timeline_node, 0, avx, avy, avw, avh);
|
||||
BLEND_NORMAL
|
||||
|
||||
draw_sprite_stretched_add(THEME.timeline_node, 1, avx, avy, avw, avh, c_white, 0.3);
|
||||
|
||||
surface_reset_target();
|
||||
}
|
||||
|
||||
surface_set_target(_s);
|
||||
draw_clear(COLORS._main_icon_dark);
|
||||
draw_sprite_tiled(s_workshop_bg, 0, -64, -64);
|
||||
|
@ -88,8 +115,12 @@ function steam_ugc_project_generate(file, dest_path = TEMPDIR + "steamUGCthumbna
|
|||
var _bw = 48 + string_width(VERSION_STRING);
|
||||
var _bh = 80;
|
||||
draw_sprite_stretched(s_workshop_badge_version, 0, prev_size - 8 - _bw, prev_size - 8 - _bh, _bw, _bh);
|
||||
draw_text(prev_size - 16, prev_size - 8, VERSION_STRING);
|
||||
draw_text(prev_size - 16, prev_size - 4, VERSION_STRING);
|
||||
|
||||
if(sprite_exists(STEAM_AVATAR) && STEAM_UGC_ITEM_AVATAR) draw_surface(avartar, prev_size - 24 - avar_size, 24);
|
||||
surface_reset_target();
|
||||
surface_save_safe(_s, dest_path);
|
||||
|
||||
surface_free(_s);
|
||||
} #endregion
|
||||
surface_free(avartar);
|
||||
}
|
Loading…
Reference in a new issue