UI_helpDialog.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. # THIS FILE IS A PART OF FreeGILE
  2. # PYTHON 3
  3. import os
  4. import datetime
  5. import json
  6. from subprocess import *
  7. # GTK module ( Graphical interface
  8. import gi
  9. gi.require_version('Gtk', '3.0')
  10. from gi.repository import Gtk
  11. from gi.repository import GLib
  12. from gi.repository import Gdk
  13. import cairo
  14. # Own modules
  15. from settings import settings
  16. from settings import talk
  17. from settings import fileformats
  18. from settings import oscalls
  19. from project_manager import pm_project
  20. #UI modules
  21. from UI import UI_elements
  22. from UI import UI_color
  23. from UI import UI_math
  24. from UI import UI_Markdown
  25. # Studio
  26. from studio import studio_dialogs
  27. from studio import analytics
  28. from studio import story
  29. def layer(win, call):
  30. ##########################################################################
  31. # This file will give the user documentation about various part of FreeGILE
  32. ##########################################################################
  33. # Determening whether we are in a Tiny mode or not. Whether to shrink
  34. # everything or keep it full screen.
  35. tiny = False
  36. if win.current["w"] < 1280:
  37. tiny = True
  38. # Making the layer
  39. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
  40. win.current['h'])
  41. layer = cairo.Context(surface)
  42. #text setting
  43. layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
  44. UI_color.set(layer, win, "dark_overdrop")
  45. layer.rectangle(
  46. 0,
  47. 0,
  48. win.current["w"],
  49. win.current["h"],
  50. )
  51. layer.fill()
  52. nodeX = 500
  53. if tiny:
  54. nodeX = 100
  55. UI_color.set(layer, win, "node_background")
  56. UI_elements.roundrect(layer, win,
  57. 100,
  58. 100,
  59. nodeX,
  60. win.current["h"]-200,
  61. 10)
  62. # Exit button
  63. def do():
  64. win.current["calls"][call]["var"] = False
  65. exitX = 560
  66. if tiny:
  67. exitX = 150
  68. UI_elements.roundrect(layer, win,
  69. exitX,
  70. win.current["h"]-140,
  71. 40,
  72. 40,
  73. 10,
  74. button=do,
  75. icon="cancel",
  76. tip=talk.text("cancel"))
  77. x = 110
  78. y = 170
  79. width = nodeX - 20
  80. height = win.current["h"]-270
  81. # Search
  82. if not tiny:
  83. UI_elements.image(layer, win, "settings/themes/"\
  84. +win.settings["Theme"]+"/icons/search.png",
  85. x+width/4,
  86. y-50,
  87. 40,
  88. 40)
  89. UI_elements.text(layer, win, "in_help",
  90. x+width/4+50,
  91. y-50,
  92. width/2-50,
  93. 40)
  94. ### MARKDOWN
  95. UI_Markdown.draw(layer, win, "help_markdown",
  96. nodeX+200,
  97. 100,
  98. win.current["w"]-(nodeX+300),
  99. win.current["h"]-200)
  100. # Clip
  101. UI_elements.roundrect(layer, win,
  102. x,
  103. y,
  104. width,
  105. height-60,
  106. 10,
  107. fill=False)
  108. layer.clip()
  109. clip = [
  110. x,
  111. y,
  112. width,
  113. height-60]
  114. # Little testing thing. Make it True to see where it's clipping.
  115. if False:
  116. # Background
  117. UI_color.set(layer, win, "dark_overdrop")
  118. layer.rectangle(x,y,width, height)
  119. layer.fill()
  120. # Setting up the scroll
  121. if "help" not in win.scroll:
  122. win.scroll["help"] = 0
  123. current_Y = 0
  124. # So for the help dialog there will be basically a list of documentations
  125. # With links to the various documentation peaces. for this I will need to
  126. # create a little dictionary
  127. documentations = {
  128. talk.text("readme"):[
  129. ["Markdown", "README.md"],
  130. ["icon", "scene"]
  131. ],
  132. talk.text("license"):[
  133. ["Markdown", "LICENSE.md"],
  134. ["icon", "scene"]
  135. ],
  136. talk.text("documentation_installation"):[
  137. ["Markdown", "wiki/docs/Installation.md"],
  138. ["video", "https://search.brave.com/"],
  139. ["icon", "new"]
  140. ],
  141. talk.text("documentation_project_manager"):[
  142. ["Markdown", "wiki/docs/Project-Manager.md"],
  143. ["video", "https://search.brave.com/"],
  144. ["icon", "configure_file"]
  145. ],
  146. talk.text("documentation_story_editor"):[
  147. ["Markdown", "wiki/docs/Story-Editor.md"],
  148. ["icon", "node"]
  149. ],
  150. talk.text("documentation_script_writer"):[
  151. ["Markdown", "wiki/docs/Script-Writer.md"],
  152. ["icon", "frase"]
  153. ],
  154. talk.text("documentation_analytics"):[
  155. ["Markdown", "wiki/docs/Analytics.md"],
  156. ["icon", "analytics"]
  157. ],
  158. talk.text("documentation_assets"):[
  159. ["Markdown", "wiki/docs/Assets.md"],
  160. ["update", "https://notabug.org/jyamihud/FreeGILE/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"],
  161. ["icon", "obj"]
  162. ],
  163. talk.text("documentation_link_assets"):[
  164. ["Markdown", "wiki/docs/LinkingAssets.md"],
  165. ["update", "https://notabug.org/jyamihud/FreeGILE/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"],
  166. ["icon", "link"]
  167. ],
  168. talk.text("documentation_render"):[
  169. ["Markdown", "wiki/docs/Rendering.md"],
  170. ["update", "https://notabug.org/jyamihud/FreeGILE/wiki/Version+20.1266+%28+Rendering+Of+Shots+%29"],
  171. ["icon", "render"]
  172. ],
  173. talk.text("documentation_multiuser"):[
  174. ["Markdown", "wiki/docs/Multiuser.md"],
  175. ["update", "https://notabug.org/jyamihud/FreeGILE/wiki/Version+21.0"],
  176. ["icon", "multiuser"]
  177. ]
  178. }
  179. # Okay let's draw this crazy behimith.
  180. if "current_help_selected" not in win.current:
  181. win.current["current_help_selected"] = False
  182. for name in documentations:
  183. # Let's make the search work.
  184. # First I want it to automatically select the stuff with the right name
  185. if win.text["in_help"]["text"].lower() == name.lower():
  186. win.current["current_help_selected"] = name
  187. win.text["in_help"]["text"] = ""
  188. # Now let's ignore all those not in the search
  189. if win.text["in_help"]["text"] and win.text["in_help"]["text"].lower() not in name.lower():
  190. continue
  191. # let's simplify the name
  192. doc = documentations[name]
  193. # There will be a simple button. That will open one up.
  194. def do():
  195. win.text["in_help"]["text"] = ""
  196. win.scroll["markdown"] = 0
  197. if name != win.current["current_help_selected"]:
  198. win.current["current_help_selected"] = name
  199. else:
  200. win.current["current_help_selected"] = False
  201. # I want to make sure that there is no icon before making it
  202. # be "question"
  203. showicon = "question"
  204. for entry in doc:
  205. if entry[0] == "icon":
  206. showicon = entry[1]
  207. UI_elements.roundrect(layer, win,
  208. x,
  209. y+current_Y + win.scroll["help"],
  210. width,
  211. 40,
  212. 10,
  213. icon=showicon,
  214. button=do,
  215. tip=name)
  216. # And a text. The name of the entry
  217. if not tiny:
  218. UI_color.set(layer, win, "text_normal")
  219. layer.set_font_size(20)
  220. layer.move_to(x+50,
  221. y+current_Y + win.scroll["help"]+25)
  222. layer.show_text(name)
  223. # Now if it's selected we going to see what links are inside.
  224. if name == win.current["current_help_selected"]:
  225. # But first let's draw a roundrect arround the douche
  226. UI_color.set(layer, win, "progress_background")
  227. UI_elements.roundrect(layer, win,
  228. x,
  229. y+current_Y + win.scroll["help"],
  230. width,
  231. 40,
  232. 10,
  233. fill=False)
  234. layer.stroke()
  235. current_Y = current_Y + 50
  236. # Let's not list all the entries.
  237. for entry in doc:
  238. if entry[0] == "Markdown":
  239. win.current["mdfs"]["help_markdown"] = entry[1]
  240. #win.current["current_help_selected"] = ""
  241. continue
  242. # icon do not show
  243. elif entry[0] == "icon":
  244. continue
  245. # Launch button
  246. def do():
  247. oscalls.Open(entry[-1])
  248. UI_elements.roundrect(layer, win,
  249. x+10,
  250. y+current_Y + win.scroll["help"],
  251. width-20,
  252. 40,
  253. 10,
  254. icon=entry[0],
  255. button=do,
  256. tip=entry[-1])
  257. # And a text. The name of the entry
  258. if not tiny:
  259. UI_color.set(layer, win, "text_normal")
  260. layer.set_font_size(20)
  261. layer.move_to(x+70,
  262. y+current_Y + win.scroll["help"]+25)
  263. layer.show_text(talk.text("documentation_type_"+entry[0]))
  264. current_Y = current_Y + 50
  265. else:
  266. current_Y = current_Y + 50
  267. # Call
  268. def do():
  269. os.system("xdg-open https://meet.jit.si/FreeGILEDevelopmentConference")
  270. talk.alert(talk.text("opened_browser"))
  271. UI_elements.roundrect(layer, win,
  272. x,
  273. y+current_Y + win.scroll["help"],
  274. width,
  275. 40,
  276. 10,
  277. button=do,
  278. icon="call",
  279. tip=talk.text("contact_us_tip"))
  280. UI_color.set(layer, win, "text_normal")
  281. layer.set_font_size(20)
  282. layer.move_to(x+50,
  283. y+current_Y + win.scroll["help"]+25)
  284. layer.show_text(talk.text("contact_us_now"))
  285. current_Y = current_Y + 50
  286. # Matrix Chat
  287. def do():
  288. os.system("xdg-open https://matrix.to/#/#FreeGILE:matrix.org")
  289. talk.alert(talk.text("opened_browser"))
  290. UI_elements.roundrect(layer, win,
  291. x,
  292. y+current_Y + win.scroll["help"],
  293. width,
  294. 40,
  295. 10,
  296. button=do,
  297. icon="frase",
  298. tip=talk.text("matrix_chat_tooltip"))
  299. UI_color.set(layer, win, "text_normal")
  300. layer.set_font_size(20)
  301. layer.move_to(x+50,
  302. y+current_Y + win.scroll["help"]+25)
  303. layer.show_text(talk.text("matrix_chat_button"))
  304. current_Y = current_Y + 50
  305. # Report Bug Button
  306. def do():
  307. os.system("xdg-open https://notabug.org/troler/FreeGILE/issues")
  308. talk.alert(talk.text("opened_browser"))
  309. UI_elements.roundrect(layer, win,
  310. x,
  311. y+current_Y + win.scroll["help"],
  312. width,
  313. 40,
  314. 10,
  315. button=do,
  316. icon="bug",
  317. tip=talk.text("report_bug_tip"))
  318. UI_color.set(layer, win, "text_normal")
  319. layer.set_font_size(20)
  320. layer.move_to(x+50,
  321. y+current_Y + win.scroll["help"]+25)
  322. layer.show_text(talk.text("report_bug_now"))
  323. current_Y = current_Y + 50
  324. ###########################
  325. UI_elements.scroll_area(layer, win, "help",
  326. x,
  327. y,
  328. width,
  329. height-60,
  330. current_Y,
  331. bar=True,
  332. mmb=True,
  333. url="help"
  334. )
  335. return surface