menu.gd 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. extends GridContainer
  2. # include render logic
  3. onready var global_v=get_tree().get_root().get_node("scene")
  4. var save_folder="out_img"
  5. func _ready():
  6. var dir = Directory.new()
  7. var path = OS.get_executable_path().get_base_dir().plus_file(save_folder)
  8. dir.make_dir(path)
  9. get_node("../imgl").connect("file_selected",self,"_on_file_select")
  10. get_node("../imgl").connect("popup_hide",self,"_on_file_hide")
  11. get_node("../warn").connect("confirmed",self,"_render_confirm")
  12. var render_once=false
  13. var pass_one_frame=true
  14. var ftps=0
  15. var iFrame=0
  16. var iFrame1=0
  17. var once_a=false
  18. var glow_frames=0
  19. var serr=false
  20. var err=0
  21. func save_frame(name):
  22. var image = get_node("../../Viewport").get_texture().get_data()
  23. #image.flip_y()
  24. var path = OS.get_executable_path().get_base_dir().plus_file(save_folder)
  25. var dir = Directory.new()
  26. dir.make_dir(path)
  27. err=image.save_png(path.plus_file(name+".png"))
  28. if err!=0:
  29. serr=true
  30. func do_task():
  31. if(render_once)&&(iFrame<glow_frames+1)&&(!serr):
  32. if(pass_one_frame):
  33. if(ftps>10):
  34. ftps=0
  35. pass_one_frame=false
  36. gen_data(true,false,0)
  37. else:
  38. ftps+=1
  39. return
  40. if(iFrame==0)&&(iFrame1==0):
  41. get_node("../../Viewport").render_target_update_mode=Viewport.UPDATE_ALWAYS
  42. if(iFrame==1)&&(iFrame1==0):
  43. save_frame("orig_"+str(iFrame))
  44. if(iFrame>1)&&(iFrame1==0):
  45. save_frame("glow_"+str(iFrame-1))
  46. if(iFrame>0)&&(iFrame1==0):
  47. gen_data(true,true,iFrame)
  48. get_node("../../Viewport/Sprite").material.set("shader_param/iFrame",iFrame)
  49. get_node("../../Viewport/Sprite").material.set("shader_param/iFrame1",iFrame1)
  50. get_node("../pct/Label").text="Progress: Frame - "+str(iFrame+1)
  51. iFrame1+=1
  52. if(iFrame1>=14*8):
  53. iFrame1=0
  54. iFrame+=1
  55. get_node("../pct/ProgressBar2").value=0
  56. get_node("../pct/ProgressBar").value=(float(iFrame)/(glow_frames+1))*100
  57. get_node("../pct/ProgressBar2").value=(float(iFrame1)/(14*8))*100
  58. else:
  59. if(once_a):
  60. if(iFrame==1)&&(!serr):
  61. save_frame("orig_"+str(iFrame))
  62. if(iFrame>1)&&(!serr):
  63. save_frame("glow_"+str(iFrame-1))
  64. if(serr):
  65. get_node("../serr").dialog_text="Error on save file: "+str(err)
  66. get_node("../serr").popup_centered(Vector2(320, 240))
  67. get_node("../../Viewport").render_target_update_mode=Viewport.UPDATE_DISABLED
  68. iFrame=0
  69. iFrame1=0
  70. render_once=false
  71. once_a=false
  72. self.visible=true
  73. serr=false
  74. err=0
  75. ftps=0
  76. pass_one_frame=true
  77. get_node("../pct").visible=false
  78. func _process(delta):
  79. do_task()
  80. if(get_node("vc/rtx").pressed):
  81. update_box_data()
  82. var r3=false
  83. func _on_hs_pressed():
  84. r3=!r3
  85. get_node("../../bg").material.set("shader_param/render3",r3)
  86. get_node("../../elems").visible=!get_node("../../elems").visible
  87. for a in range(get_node("vc").get_child_count()-1):
  88. get_node("vc").get_child(a).visible=!get_node("vc").get_child(a).visible
  89. var once_rconfirm=true
  90. func _on_re_pressed():
  91. if(once_rconfirm):
  92. get_node("../warn").popup_centered(Vector2(640, 480))
  93. else:
  94. _render_confirm()
  95. func _render_confirm():
  96. once_rconfirm=false
  97. get_node("../../Viewport2").render_target_update_mode=Viewport.UPDATE_DISABLED
  98. get_node("../../Viewport3").render_target_update_mode=Viewport.UPDATE_DISABLED
  99. get_node("../../bg").material.set("shader_param/render2",false)
  100. get_node("vc/rtx").pressed=false
  101. r3=true
  102. get_node("../../bg").material.set("shader_param/render3",r3)
  103. for a in range(get_node("vc").get_child_count()-1):
  104. get_node("vc").get_child(a).visible=false
  105. get_node("../../bg").material.set("shader_param/render",true)
  106. self.visible=false
  107. get_node("../pct").visible=true
  108. get_node("../../elems").visible=false
  109. get_node("../pct/ProgressBar").value=0
  110. get_node("../pct/ProgressBar2").value=0
  111. get_node("../pct/Label").text="Progress: Frame - "+str(0+1)
  112. render_once=true
  113. once_a=true
  114. func _on_x_text_changed(new_text):
  115. var res=Vector2(get_node("vc/hb/x").text.to_int(),get_node("vc/hb/y").text.to_int())
  116. if(res.x<1)||(res.x>4096):
  117. get_node("vc/hb/x").text=str(clamp(res.x,10,4096))
  118. res=Vector2(get_node("vc/hb/x").text.to_int(),get_node("vc/hb/y").text.to_int())
  119. if(res.x>=1)&&(res.x<=4096)&&(res.y>=1)&&(res.y<=4096):
  120. get_node("../../bg").material.set("shader_param/l_res",res)
  121. func _on_y_text_changed(new_text):
  122. var res=Vector2(get_node("vc/hb/x").text.to_int(),get_node("vc/hb/y").text.to_int())
  123. if(res.y<1)||(res.y>4096):
  124. get_node("vc/hb/y").text=str(clamp(res.y,10,4096))
  125. res=Vector2(get_node("vc/hb/x").text.to_int(),get_node("vc/hb/y").text.to_int())
  126. if(res.x>=1)&&(res.x<=4096)&&(res.y>=1)&&(res.y<=4096):
  127. get_node("../../bg").material.set("shader_param/l_res",res)
  128. var image_texture
  129. func _on_file_select(path):
  130. get_node("vc").visible=true
  131. var img = Image.new()
  132. img.load(path)
  133. if(!is_instance_valid(img)):
  134. return
  135. image_texture=ImageTexture.new()
  136. image_texture.create_from_image(img, 0)
  137. get_node("../../bg").material.set("shader_param/iChannel1",image_texture)
  138. get_node("../../Viewport/Sprite").material.set("shader_param/iChannel1",image_texture)
  139. get_node("../../Viewport2/Sprite").material.set("shader_param/iChannel1",image_texture)
  140. func _on_file_hide():
  141. get_node("vc").visible=true
  142. func _on_bgib_pressed():
  143. get_node("vc").visible=false
  144. get_node("../imgl").popup_centered(Vector2(640, 480))
  145. func _on_hp_pressed():
  146. get_node("../info").popup_centered(Vector2(640, 480))
  147. onready var elems=get_node("../../elems")
  148. onready var elem_text=preload("res://text_ctrl.tscn")
  149. onready var elem_circle=preload("res://circle_ctrl.tscn")
  150. onready var elem_line=preload("res://line_ctrl.tscn")
  151. onready var elem_box=preload("res://box_ctrl.tscn")
  152. onready var elem_tri=preload("res://tri_ctrl.tscn")
  153. func _on_at_pressed():
  154. if(global_v.live_text_elem<global_v.max_elems):
  155. var s=elem_text.instance()
  156. var rect=21
  157. s.rect_position=global_v.iResolution/2-Vector2(rect/2,rect/2)
  158. elems.call_deferred("add_child",s,true)
  159. else:
  160. get_node("../maxe").popup_centered(Vector2(320, 240))
  161. func _on_al_pressed():
  162. if(global_v.live_line_elem<global_v.max_elems):
  163. var s=elem_line.instance()
  164. var rect=21
  165. s.rect_position=global_v.iResolution/2-Vector2(rect/2,rect/2)
  166. elems.call_deferred("add_child",s,true)
  167. else:
  168. get_node("../maxe").popup_centered(Vector2(320, 240))
  169. func _on_al2_pressed():
  170. if(global_v.live_circle_elem<global_v.max_elems):
  171. var s=elem_circle.instance()
  172. var rect=21
  173. s.rect_position=global_v.iResolution/2-Vector2(rect/2,rect/2)
  174. elems.call_deferred("add_child",s,true)
  175. else:
  176. get_node("../maxe").popup_centered(Vector2(320, 240))
  177. func update_box_data():
  178. if(global_v.iTime>0):
  179. gen_data(false,false,0)
  180. # [0] [0]=size or array
  181. # [1] [0-1]=position, [2] box size, [3-5]color [6]glow
  182. func gen_array_line(arr,a,b,c,d,e,f,g,h):
  183. arr.append(a)
  184. arr.append(b)
  185. arr.append(c)
  186. arr.append(d)
  187. arr.append(e)
  188. arr.append(f)
  189. arr.append(g)
  190. arr.append(h)
  191. func pass_float(array):
  192. var stream = StreamPeerBuffer.new()
  193. var data_in_bytes = PoolByteArray([])
  194. for i in array:
  195. stream.clear()
  196. stream.put_float(i)
  197. stream.seek(0)
  198. for j in range(4):
  199. data_in_bytes.append(stream.get_8())
  200. return data_in_bytes
  201. const itri=4
  202. const ibox=3
  203. const icircle=2
  204. const iline=1
  205. const itext=0
  206. var t_glow_counter=0
  207. func gen_box_data(count,glowa,glowb,glowc):
  208. var array = []
  209. var elemsn=get_node("../../elems")
  210. gen_array_line(array,count,0,0,0,0,0,0,0)
  211. for a in range(elemsn.get_child_count()):
  212. if(!is_instance_valid(elemsn.get_child(a).get_child(0))):
  213. continue
  214. if(!elemsn.get_child(a).get_child(0).has_method("get_self_type")):
  215. continue
  216. if(elemsn.get_child(a).get_child(0).self_type==ibox):
  217. var pos=elemsn.get_child(a).rect_position
  218. var ss=elemsn.get_child(a).get_child(0).self_size/global_v.iResolution.y
  219. var col=elemsn.get_child(a).get_child(0).self_color
  220. var rot=elemsn.get_child(a).get_child(0).self_rot
  221. var glowx=0
  222. if(elemsn.get_child(a).get_child(0).self_render):
  223. glowx=1
  224. t_glow_counter+=1
  225. if(glowa)&&(!glowb):
  226. glowx=0
  227. if(glowa)&&(glowb):
  228. if(glowx==1)&&(t_glow_counter==glowc):
  229. glowx=1
  230. else:
  231. glowx=0
  232. pos+=Vector2(21/2,21/2)
  233. pos=pos/global_v.iResolution.y
  234. pos.y=1-pos.y
  235. pos=pos-(global_v.iResolution/global_v.iResolution.y)*0.5
  236. gen_array_line(array,pos.x,pos.y,ss,col.r,col.g,col.b,deg2rad(rot),glowx)
  237. var array_width = 8
  238. var array_heigh = count+1
  239. var byte_array = pass_float(array)
  240. var img = Image.new()
  241. img.create_from_data(array_width, array_heigh, false, Image.FORMAT_RF, byte_array)
  242. var b_array = ImageTexture.new()
  243. b_array.create_from_image(img, 0)
  244. get_node("../../Viewport2/Sprite").material.set("shader_param/box_array",b_array)
  245. get_node("../../Viewport/Sprite").material.set("shader_param/box_array",b_array)
  246. func gen_circle_data(count,glowa,glowb,glowc):
  247. var array = []
  248. var elemsn=get_node("../../elems")
  249. gen_array_line(array,count,0,0,0,0,0,0,0)
  250. for a in range(elemsn.get_child_count()):
  251. if(!is_instance_valid(elemsn.get_child(a).get_child(0))):
  252. continue
  253. if(!elemsn.get_child(a).get_child(0).has_method("get_self_type")):
  254. continue
  255. if(elemsn.get_child(a).get_child(0).self_type==icircle):
  256. var pos=elemsn.get_child(a).rect_position
  257. var ss=elemsn.get_child(a).get_child(0).self_size/global_v.iResolution.y
  258. var col=elemsn.get_child(a).get_child(0).self_color
  259. var glowx=0
  260. if(elemsn.get_child(a).get_child(0).self_render):
  261. glowx=1
  262. t_glow_counter+=1
  263. if(glowa)&&(!glowb):
  264. glowx=0
  265. if(glowa)&&(glowb):
  266. if(glowx==1)&&(t_glow_counter==glowc):
  267. glowx=1
  268. else:
  269. glowx=0
  270. pos+=Vector2(21/2,21/2)
  271. pos=pos/global_v.iResolution.y
  272. pos.y=1-pos.y
  273. pos=pos-(global_v.iResolution/global_v.iResolution.y)*0.5
  274. gen_array_line(array,pos.x,pos.y,ss,col.r,col.g,col.b,0,glowx)
  275. var array_width = 8
  276. var array_heigh = count+1
  277. var byte_array = pass_float(array)
  278. var img = Image.new()
  279. img.create_from_data(array_width, array_heigh, false, Image.FORMAT_RF, byte_array)
  280. var b_array = ImageTexture.new()
  281. b_array.create_from_image(img, 0)
  282. get_node("../../Viewport2/Sprite").material.set("shader_param/circle_array",b_array)
  283. get_node("../../Viewport/Sprite").material.set("shader_param/circle_array",b_array)
  284. func gen_tri_data(count,glowa,glowb,glowc):
  285. var array = []
  286. var elemsn=get_node("../../elems")
  287. gen_array_line(array,count,0,0,0,0,0,0,0)
  288. for a in range(elemsn.get_child_count()):
  289. if(!is_instance_valid(elemsn.get_child(a).get_child(0))):
  290. continue
  291. if(!elemsn.get_child(a).get_child(0).has_method("get_self_type")):
  292. continue
  293. if(elemsn.get_child(a).get_child(0).self_type==itri):
  294. var pos=elemsn.get_child(a).rect_position
  295. var ss=elemsn.get_child(a).get_child(0).self_size/global_v.iResolution.y #unused
  296. var col=elemsn.get_child(a).get_child(0).self_color
  297. var rot=elemsn.get_child(a).get_child(0).self_rot
  298. var glowx=0
  299. if(elemsn.get_child(a).get_child(0).self_render):
  300. glowx=1
  301. t_glow_counter+=1
  302. if(glowa)&&(!glowb):
  303. glowx=0
  304. if(glowa)&&(glowb):
  305. if(glowx==1)&&(t_glow_counter==glowc):
  306. glowx=1
  307. else:
  308. glowx=0
  309. pos+=Vector2(21/2,21/2)
  310. pos=pos/global_v.iResolution.y
  311. pos.y=1-pos.y
  312. pos=pos-(global_v.iResolution/global_v.iResolution.y)*0.5
  313. gen_array_line(array,pos.x,pos.y,ss,col.r,col.g,col.b,deg2rad(rot),glowx)
  314. var array_width = 8
  315. var array_heigh = count+1
  316. var byte_array = pass_float(array)
  317. var img = Image.new()
  318. img.create_from_data(array_width, array_heigh, false, Image.FORMAT_RF, byte_array)
  319. var b_array = ImageTexture.new()
  320. b_array.create_from_image(img, 0)
  321. get_node("../../Viewport2/Sprite").material.set("shader_param/tri_array",b_array)
  322. get_node("../../Viewport/Sprite").material.set("shader_param/tri_array",b_array)
  323. func gen_array_line_l(arr,a,b,c,d,e,f,g,h):
  324. arr.append(a)
  325. arr.append(b)
  326. arr.append(c)
  327. arr.append(d)
  328. arr.append(e)
  329. arr.append(f)
  330. arr.append(g)
  331. arr.append(h)
  332. # [0] [0]=size or array
  333. # [1] [0-1]=position, [2] size, [3-5]color, [6]rotation, [7]glow
  334. func gen_line_data(count,glowa,glowb,glowc):
  335. var array = []
  336. var elemsn=get_node("../../elems")
  337. gen_array_line_l(array,count,0,0,0,0,0,0,0)
  338. for a in range(elemsn.get_child_count()):
  339. if(!is_instance_valid(elemsn.get_child(a).get_child(0))):
  340. continue
  341. if(!elemsn.get_child(a).get_child(0).has_method("get_self_type")):
  342. continue
  343. if(elemsn.get_child(a).get_child(0).self_type==iline):
  344. var pos=elemsn.get_child(a).rect_position
  345. var ss=elemsn.get_child(a).get_child(0).self_size/global_v.iResolution.y
  346. var col=elemsn.get_child(a).get_child(0).self_color
  347. var rot=elemsn.get_child(a).get_child(0).self_rot
  348. var glowx=0
  349. if(elemsn.get_child(a).get_child(0).self_render):
  350. glowx=1
  351. t_glow_counter+=1
  352. if(glowa)&&(!glowb):
  353. glowx=0
  354. if(glowa)&&(glowb):
  355. if(glowx==1)&&(t_glow_counter==glowc):
  356. glowx=1
  357. else:
  358. glowx=0
  359. pos+=Vector2(21/2,21/2)
  360. pos=pos/global_v.iResolution.y
  361. pos.y=1-pos.y
  362. pos=pos-(global_v.iResolution/global_v.iResolution.y)*0.5
  363. gen_array_line_l(array,pos.x,pos.y,ss,col.r,col.g,col.b,deg2rad(rot),glowx)
  364. var array_width = 8
  365. var array_heigh = count+1
  366. var byte_array = pass_float(array)
  367. var img = Image.new()
  368. img.create_from_data(array_width, array_heigh, false, Image.FORMAT_RF, byte_array)
  369. var b_array = ImageTexture.new()
  370. b_array.create_from_image(img, 0)
  371. get_node("../../Viewport2/Sprite").material.set("shader_param/line_array",b_array)
  372. get_node("../../Viewport/Sprite").material.set("shader_param/line_array",b_array)
  373. func gen_array_line_t(arr,a,b,c,d,e,f,g,h,i):
  374. arr.append(a)
  375. arr.append(b)
  376. arr.append(c)
  377. arr.append(d)
  378. arr.append(e)
  379. arr.append(f)
  380. arr.append(g)
  381. for ax in range(10):
  382. arr.append(h[ax])
  383. arr.append(i)
  384. # [0] [0]=size or array
  385. # [1] [0-1]=position, [2] size, [3-5]color, [6]rotation, [7-17]text [18]glow
  386. func gen_text_data(count,glowa,glowb,glowc):
  387. var array = []
  388. var elemsn=get_node("../../elems")
  389. gen_array_line_t(array,count,0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,0],0)
  390. for a in range(elemsn.get_child_count()):
  391. if(!is_instance_valid(elemsn.get_child(a).get_child(0))):
  392. continue
  393. if(!elemsn.get_child(a).get_child(0).has_method("get_self_type")):
  394. continue
  395. if(elemsn.get_child(a).get_child(0).self_type==itext):
  396. var pos=elemsn.get_child(a).rect_position
  397. var ss=elemsn.get_child(a).get_child(0).self_size
  398. var col=elemsn.get_child(a).get_child(0).self_color
  399. var rot=elemsn.get_child(a).get_child(0).self_rot
  400. var text=elemsn.get_child(a).get_child(0).self_text
  401. var glowx=0
  402. if(elemsn.get_child(a).get_child(0).self_render):
  403. glowx=1
  404. t_glow_counter+=1
  405. if(glowa)&&(!glowb):
  406. glowx=0
  407. if(glowa)&&(glowb):
  408. if(glowx==1)&&(t_glow_counter==glowc):
  409. glowx=1
  410. else:
  411. glowx=0
  412. var texta=Array(text.to_ascii())
  413. for b in range(10-texta.size()):
  414. texta.append(32)
  415. #pos+=Vector2(21/2,21/2)
  416. pos=pos/global_v.iResolution.y
  417. pos.y=1-pos.y
  418. pos=pos-(global_v.iResolution/global_v.iResolution.y)*0.5
  419. gen_array_line_t(array,pos.x,pos.y,ss,col.r,col.g,col.b,deg2rad(rot),texta,glowx)
  420. var array_width = 18
  421. var array_heigh = count+1
  422. var byte_array = pass_float(array)
  423. var img = Image.new()
  424. img.create_from_data(array_width, array_heigh, false, Image.FORMAT_RF, byte_array)
  425. var b_array = ImageTexture.new()
  426. b_array.create_from_image(img, 0)
  427. get_node("../../Viewport2/Sprite").material.set("shader_param/text_array",b_array)
  428. get_node("../../Viewport/Sprite").material.set("shader_param/text_array",b_array)
  429. # bool,bool,int [enable glow control][enable glow by ID(false=no glow at all)][ID]
  430. func gen_data(glowa,glowb,glowc):
  431. var elemsn=get_node("../../elems")
  432. var box_count=0
  433. var circle_count=0
  434. var line_count=0
  435. var text_count=0
  436. var tri_count=0
  437. glow_frames=0
  438. t_glow_counter=0
  439. for a in range(elemsn.get_child_count()):
  440. if(!is_instance_valid(elemsn.get_child(a).get_child(0))):
  441. continue
  442. if(!elemsn.get_child(a).get_child(0).has_method("get_self_type")):
  443. continue
  444. if(elemsn.get_child(a).get_child(0).self_type==ibox):
  445. box_count+=1
  446. if(elemsn.get_child(a).get_child(0).self_type==icircle):
  447. circle_count+=1
  448. if(elemsn.get_child(a).get_child(0).self_type==iline):
  449. line_count+=1
  450. if(elemsn.get_child(a).get_child(0).self_type==itext):
  451. text_count+=1
  452. if(elemsn.get_child(a).get_child(0).self_type==itri):
  453. tri_count+=1
  454. if(elemsn.get_child(a).get_child(0).self_render):
  455. glow_frames+=1
  456. gen_box_data(box_count,glowa,glowb,glowc)
  457. gen_circle_data(circle_count,glowa,glowb,glowc)
  458. gen_tri_data(tri_count,glowa,glowb,glowc)
  459. gen_line_data(line_count,glowa,glowb,glowc)
  460. gen_text_data(text_count,glowa,glowb,glowc)
  461. func _on_al3_pressed():
  462. if(global_v.live_box_elem<global_v.max_elems):
  463. var s=elem_box.instance()
  464. var rect=21
  465. s.rect_position=global_v.iResolution/2-Vector2(rect/2,rect/2)
  466. elems.call_deferred("add_child",s,true)
  467. else:
  468. get_node("../maxe").popup_centered(Vector2(320, 240))
  469. func _on_rtx_toggled(button_pressed):
  470. get_node("../../bg").material.set("shader_param/render",!button_pressed)
  471. get_node("../../bg").material.set("shader_param/render2",button_pressed)
  472. if(button_pressed):
  473. get_node("../../Viewport2").render_target_update_mode=Viewport.UPDATE_ALWAYS
  474. get_node("../../Viewport3").render_target_update_mode=Viewport.UPDATE_ALWAYS
  475. else:
  476. get_node("../../Viewport2").render_target_update_mode=Viewport.UPDATE_DISABLED
  477. get_node("../../Viewport3").render_target_update_mode=Viewport.UPDATE_DISABLED
  478. func _on_opx_item_selected(ID):
  479. if(ID==0):
  480. get_node("../../Viewport").size=Vector2(1280,720)
  481. var tx=ImageTexture.new()
  482. tx.create(1280,720,Image.FORMAT_RGBAF)
  483. get_node("../../Viewport/Sprite").texture=tx
  484. if(ID==1):
  485. get_node("../../Viewport").size=Vector2(1920,1080)
  486. var tx=ImageTexture.new()
  487. tx.create(1920,1080,Image.FORMAT_RGBAF)
  488. get_node("../../Viewport/Sprite").texture=tx
  489. if(ID==2):
  490. get_node("../../Viewport").size=Vector2(3840,2160)
  491. var tx=ImageTexture.new()
  492. tx.create(3840,2160,Image.FORMAT_RGBAF)
  493. get_node("../../Viewport/Sprite").texture=tx
  494. func _on_al4_pressed():
  495. if(global_v.live_tri_elem<global_v.max_elems):
  496. var s=elem_tri.instance()
  497. var rect=21
  498. s.rect_position=global_v.iResolution/2-Vector2(rect/2,rect/2)
  499. elems.call_deferred("add_child",s,true)
  500. else:
  501. get_node("../maxe").popup_centered(Vector2(320, 240))
  502. func _on_bgib2_pressed():
  503. image_texture=load("res://textures/px.png") as Texture
  504. if(!is_instance_valid(image_texture)):
  505. return
  506. get_node("../../bg").material.set("shader_param/iChannel1",image_texture)
  507. get_node("../../Viewport/Sprite").material.set("shader_param/iChannel1",image_texture)
  508. get_node("../../Viewport2/Sprite").material.set("shader_param/iChannel1",image_texture)