download through browser

This commit is contained in:
Tanasart 2024-05-07 15:54:34 +07:00
parent b8918d21fb
commit 79b3d8b5be
6 changed files with 74 additions and 57 deletions

View file

@ -128,7 +128,7 @@ event_inherited();
for( var i = 0, n = array_length(dls); i < n; i++ ) {
var dl = dls[i];
var vr = dl.version;
hh = dl.status? ui(56) : ui(36);
hh = dl.status == 0? ui(36) : ui(56);
var hov = sHOVER && point_in_rectangle(_m[0], _m[1], xx, yy, xx + ww, yy + hh);
@ -151,7 +151,12 @@ event_inherited();
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS))
shellOpenExplorer(filename_dir(dl.download_path));
} else if(dl.status == -1 && hov) {
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS))
url_open(dl.download_path);
} else
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS.node_display_text_frame_outline, 1);
@ -171,6 +176,10 @@ event_inherited();
} else if(dl.status == 2) {
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub);
draw_text_cut(xx + ui(8), yy + ui(32), dl.download_path, ww - ui(16));
} else if(dl.status == -1) {
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_value_negative);
draw_text_cut(xx + ui(8), yy + ui(32), $"HTTP get error : open the download link in browser.", ww - ui(16));
}
if(dl.status) {

View file

@ -40,13 +40,24 @@ if (_id == note_get) {
var dl = downloading[$ _id];
if(_status == 0) {
dl.status = 2;
PREFERENCES.versions[$ dl.version] = dl.download_path;
PREF_SAVE();
if(dl.size_downloaded < 10000) {
dl.status = -1;
} else {
dl.status = 2;
PREFERENCES.versions[$ dl.version] = dl.download_path;
PREF_SAVE();
}
} else if(_status == 1) {
if(ds_map_exists(async_load, "http_status")) {
var _http_status = ds_map_find_value(async_load, "http_status");
print(_http_status);
}
dl.size_total = ds_map_find_value(async_load, "contentLength");
dl.size_downloaded = ds_map_find_value(async_load, "sizeDownloaded");
}
} else
noti_warning($"HTTP get error {_status}");
}

View file

@ -27,7 +27,7 @@ if(winMan_isMinimized()) exit;
break;
case VALUE_TYPE.curve :
draw_tooltip_text("[" + __txt("Curve Object") + "]");
draw_tooltip_text($"[{__txt("Curve Object"}]");
break;
case VALUE_TYPE.color :
@ -39,11 +39,11 @@ if(winMan_isMinimized()) exit;
break;
case VALUE_TYPE.d3object :
draw_tooltip_text("[" + __txt("3D Object") + "]");
draw_tooltip_text($"[{__txt("3D Object")}]");
break;
case VALUE_TYPE.object :
draw_tooltip_text("[" + __txt("Object") + "]");
draw_tooltip_text($"[{__txt("Object")}]");
break;
case VALUE_TYPE.surface :
@ -51,43 +51,38 @@ if(winMan_isMinimized()) exit;
break;
case VALUE_TYPE.rigid :
draw_tooltip_text("[" + __txt("Rigidbody Object") + " (id: " + string(content[$ "object"]) + ")]");
draw_tooltip_text($"[{__txt("Rigidbody Object")} (id: {content[$ "object"]})]");
break;
case VALUE_TYPE.particle :
var txt = "[" +
__txt("Particle Object") +
" (size: " + string(array_length(content)) + ") " +
"]";
var txt = $"[{__txt("Particle Object")} (size: {array_length(content)}) ]";
draw_tooltip_text(txt);
break;
case VALUE_TYPE.pathnode :
draw_tooltip_text("[" + __txt("Path Object") + "]");
draw_tooltip_text($"[{__txt("Path Object")}]");
break;
case VALUE_TYPE.sdomain :
draw_tooltip_text("[" + __txt("Domain") + " (id: " + string(content) + ")]");
draw_tooltip_text($"[{__txt("Domain")} (id: {content})]");
break;
case VALUE_TYPE.strands :
var txt = __txt("Strands Object");
if(is_struct(content))
txt += " (strands: " + string(array_length(content.hairs)) + ")";
draw_tooltip_text("[" + txt + "]");
txt += $" (strands: {array_length(content.hairs)})";
draw_tooltip_text($"[{txt}]");
break;
case VALUE_TYPE.mesh :
var txt = __txt("Mesh Object");
if(is_struct(content))
txt += " (triangles: " + string(array_length(content.triangles)) + ")";
draw_tooltip_text("[" + txt + "]");
txt += $" (triangles: {array_length(content.triangles)})";
draw_tooltip_text($"[{txt}]");
break;
case VALUE_TYPE.d3vertex :
var txt = __txt("3D Vertex");
txt += " (groups: " + string(array_length(content)) + ")";
draw_tooltip_text("[" + txt + "]");
draw_tooltip_text($"[{__txt("3D Vertex")} (groups: {array_length(content)})]");
break;
case VALUE_TYPE.buffer :

View file

@ -79,6 +79,7 @@ if(PROJECT.active && !PROJECT.safeMode) { #region
load_file_path(drop_path);
drop_path = [];
}
} else if(OS == os_macosx) {
file_dnd_set_files(file_dnd_pattern, file_dnd_allowfiles, file_dnd_allowdirs, file_dnd_allowmulti);
file_dnd_filelist = file_dnd_get_files();
@ -128,7 +129,7 @@ if(PROJECT.active && !PROJECT.safeMode) { #region
if(STEAM_ENABLED) {
if (steam_is_screenshot_requested()) {
var file = "PixelComposer_" + string(irandom_range(100_000, 999_999)) + ".png";
var file = $"PixelComposer_{seed_random(6)}.png";
screen_save(file);
steam_send_screenshot(file, window_get_width(), window_get_height());
}

View file

@ -11,6 +11,7 @@ _HOVERING_ELEMENT = noone;
if(!minimized) game_set_speed(1, gamespeed_fps);
minimized = true;
exit;
} else if(!minimized)
window_preminimize_rect = [ window_get_x(), window_get_y(), window_get_width(), window_get_height() ];
@ -201,7 +202,7 @@ _HOVERING_ELEMENT = noone;
if(ALT == KEYBOARD_STATUS.up) ALT = KEYBOARD_STATUS.idle;
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
CTRL = KEYBOARD_STATUS.up;
CTRL = KEYBOARD_STATUS.up;
if(SHIFT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_shift))
SHIFT = KEYBOARD_STATUS.up;

View file

@ -1,7 +1,7 @@
{
"$GMObject":"",
"%Name":"o_main",
"eventList":[
"$GMObject": "",
"%Name": "o_main",
"eventList": [
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
@ -13,41 +13,41 @@
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"resourceVersion":"1.0","name":"","resourceType":"GMEvent","eventNum":1,"eventType":9,"isDnD":false,},
{"resourceVersion":"1.0","name":"","resourceType":"GMEvent","eventNum":1,"eventType":10,"isDnD":false,},
],
"managed":true,
"name":"o_main",
"overriddenProperties":[],
"parent":{
"name":"main",
"path":"folders/main.yy",
"managed": true,
"name": "o_main",
"overriddenProperties": [],
"parent": {
"name": "main",
"path": "folders/main.yy",
},
"parentObjectId":null,
"persistent":true,
"physicsAngularDamping":0.1,
"physicsDensity":0.5,
"physicsFriction":0.2,
"physicsGroup":1,
"physicsKinematic":false,
"physicsLinearDamping":0.1,
"physicsObject":false,
"physicsRestitution":0.1,
"physicsSensor":false,
"physicsShape":1,
"physicsShapePoints":[],
"physicsStartAwake":true,
"properties":[],
"resourceType":"GMObject",
"resourceVersion":"2.0",
"solid":false,
"spriteId":null,
"spriteMaskId":null,
"visible":true,
"parentObjectId": null,
"persistent": true,
"physicsAngularDamping": 0.1,
"physicsDensity": 0.5,
"physicsFriction": 0.2,
"physicsGroup": 1,
"physicsKinematic": false,
"physicsLinearDamping": 0.1,
"physicsObject": false,
"physicsRestitution": 0.1,
"physicsSensor": false,
"physicsShape": 1,
"physicsShapePoints": [],
"physicsStartAwake": true,
"properties": [],
"resourceType": "GMObject",
"resourceVersion": "2.0",
"solid": false,
"spriteId": null,
"spriteMaskId": null,
"visible": true,
}