Blender-Pipeline/UI/UI_helpDialog.py

430 lines
12 KiB
Python
Raw Permalink Normal View History

2021-12-19 19:12:19 +01:00
####################################
# #
# COPYRIGHT NOTICE #
# #
# This file is a part of Victori- #
# ous Children Studio Organizer. #
# Or simply VCStudio. Copyright #
# of J.Y.Amihud. But don't be sad #
# because I released the entire #
# project under a GNU GPL license. #
# You may use Version 3 or later. #
# See www.gnu.org/licenses if your #
# copy has no License file. Please #
# note. Ones I used the GPL v2 for #
# it. It's no longer the case. #
# #
####################################
2020-12-25 15:22:08 +01:00
import os
import datetime
import json
from subprocess import *
# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Gdk
import cairo
# Own modules
from settings import settings
from settings import talk
from settings import fileformats
from settings import oscalls
from project_manager import pm_project
#UI modules
from UI import UI_elements
from UI import UI_color
from UI import UI_math
from UI import UI_Markdown
2020-12-25 15:22:08 +01:00
# Studio
from studio import studio_dialogs
from studio import analytics
from studio import story
def layer(win, call):
##########################################################################
# This file will give the user documentation about various part of VCStudio
##########################################################################
2021-06-14 18:01:30 +02:00
# Determening whether we are in a Tiny mode or not. Whether to shrink
# everything or keep it full screen.
tiny = False
if win.current["w"] < 1280:
tiny = True
2020-12-25 15:22:08 +01:00
# Making the layer
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
win.current['h'])
layer = cairo.Context(surface)
#text setting
layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_color.set(layer, win, "dark_overdrop")
layer.rectangle(
0,
0,
win.current["w"],
win.current["h"],
)
layer.fill()
2021-06-14 18:01:30 +02:00
nodeX = 500
if tiny:
nodeX = 100
2020-12-25 15:22:08 +01:00
UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win,
100,
2020-12-25 15:22:08 +01:00
100,
2021-06-14 18:01:30 +02:00
nodeX,
2020-12-25 15:22:08 +01:00
win.current["h"]-200,
10)
2020-12-25 15:22:08 +01:00
# Exit button
def do():
win.current["calls"][call]["var"] = False
2021-06-14 18:01:30 +02:00
exitX = 560
if tiny:
exitX = 150
2020-12-25 15:22:08 +01:00
UI_elements.roundrect(layer, win,
2021-06-14 18:01:30 +02:00
exitX,
2020-12-25 15:22:08 +01:00
win.current["h"]-140,
40,
40,
10,
button=do,
icon="cancel",
tip=talk.text("cancel"))
x = 110
2020-12-25 15:22:08 +01:00
y = 170
2021-06-14 18:01:30 +02:00
width = nodeX - 20
2020-12-25 15:22:08 +01:00
height = win.current["h"]-270
# Search
2021-06-14 18:01:30 +02:00
if not tiny:
2020-12-25 15:22:08 +01:00
2021-06-14 18:01:30 +02:00
UI_elements.image(layer, win, "settings/themes/"\
+win.settings["Theme"]+"/icons/search.png",
x+width/4,
y-50,
40,
40)
UI_elements.text(layer, win, "in_help",
x+width/4+50,
y-50,
width/2-50,
40)
2020-12-25 15:22:08 +01:00
### MARKDOWN
UI_Markdown.draw(layer, win, "help_markdown",
2021-06-14 18:01:30 +02:00
nodeX+200,
100,
2021-06-14 18:01:30 +02:00
win.current["w"]-(nodeX+300),
win.current["h"]-200)
2020-12-25 15:22:08 +01:00
# Clip
UI_elements.roundrect(layer, win,
x,
y,
width,
height-60,
10,
fill=False)
layer.clip()
clip = [
x,
y,
width,
height-60]
# Little testing thing. Make it True to see where it's clipping.
if False:
# Background
UI_color.set(layer, win, "dark_overdrop")
layer.rectangle(x,y,width, height)
layer.fill()
# Setting up the scroll
if "help" not in win.scroll:
win.scroll["help"] = 0
current_Y = 0
# So for the help dialog there will be basically a list of documentations
# With links to the various documentation peaces. for this I will need to
# create a little dictionary
documentations = {
talk.text("readme"):[
["Markdown", "README.md"],
2021-06-14 18:01:30 +02:00
["icon", "scene"]
],
talk.text("license"):[
["Markdown", "LICENSE.md"],
2021-06-14 18:01:30 +02:00
["icon", "scene"]
],
2020-12-25 15:22:08 +01:00
talk.text("documentation_installation"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/Installation.md"],
2021-06-14 18:01:30 +02:00
["video", "https://open.lbry.com/@blender-organizer:5/rnd0001-4061:1?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"],
["icon", "new"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_project_manager"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/Project-Manager.md"],
2021-06-14 18:01:30 +02:00
["video", "https://open.lbry.com/@blender-organizer:5/Victorious-Children-Studio-Organizer-%28-VCStudio-%29---Project-Manager-Tutorial---Creating-Projects---Scanning-the-OS---Settings:7?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"],
["icon", "configure_file"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_story_editor"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/Story-Editor.md"],
2021-06-14 18:01:30 +02:00
["icon", "node"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_script_writer"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/Script-Writer.md"],
2021-06-14 18:01:30 +02:00
["icon", "frase"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_analytics"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/Analytics.md"],
2021-06-14 18:01:30 +02:00
["icon", "analytics"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_assets"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/Assets.md"],
2021-06-14 18:01:30 +02:00
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"],
["icon", "obj"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_link_assets"):[
2021-05-10 21:52:14 +02:00
["Markdown", "wiki/docs/LinkingAssets.md"],
2021-06-14 18:01:30 +02:00
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"],
["icon", "link"]
2020-12-25 15:22:08 +01:00
],
talk.text("documentation_render"):[
2021-06-14 18:01:30 +02:00
["Markdown", "wiki/docs/Rendering.md"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1266+%28+Rendering+Of+Shots+%29"],
["icon", "render"]
2021-01-03 14:47:00 +01:00
],
talk.text("documentation_multiuser"):[
2021-06-14 18:01:30 +02:00
["Markdown", "wiki/docs/Multiuser.md"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+21.0"],
["icon", "multiuser"]
2020-12-25 15:22:08 +01:00
]
}
# Okay let's draw this crazy behimith.
if "current_help_selected" not in win.current:
win.current["current_help_selected"] = False
for name in documentations:
# Let's make the search work.
# First I want it to automatically select the stuff with the right name
if win.text["in_help"]["text"].lower() == name.lower():
2020-12-25 15:22:08 +01:00
win.current["current_help_selected"] = name
win.text["in_help"]["text"] = ""
2020-12-25 15:22:08 +01:00
# Now let's ignore all those not in the search
if win.text["in_help"]["text"] and win.text["in_help"]["text"].lower() not in name.lower():
continue
# let's simplify the name
doc = documentations[name]
# There will be a simple button. That will open one up.
def do():
win.text["in_help"]["text"] = ""
2021-05-10 21:52:14 +02:00
win.scroll["markdown"] = 0
2020-12-25 15:22:08 +01:00
if name != win.current["current_help_selected"]:
win.current["current_help_selected"] = name
else:
win.current["current_help_selected"] = False
2021-06-14 18:01:30 +02:00
# I want to make sure that there is no icon before making it
# be "question"
2020-12-25 15:22:08 +01:00
2021-06-14 18:01:30 +02:00
showicon = "question"
for entry in doc:
if entry[0] == "icon":
showicon = entry[1]
2020-12-25 15:22:08 +01:00
UI_elements.roundrect(layer, win,
x,
y+current_Y + win.scroll["help"],
width,
40,
10,
2021-06-14 18:01:30 +02:00
icon=showicon,
button=do,
tip=name)
2020-12-25 15:22:08 +01:00
# And a text. The name of the entry
2021-06-14 18:01:30 +02:00
if not tiny:
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(x+50,
y+current_Y + win.scroll["help"]+25)
layer.show_text(name)
2020-12-25 15:22:08 +01:00
# Now if it's selected we going to see what links are inside.
if name == win.current["current_help_selected"]:
# But first let's draw a roundrect arround the douche
UI_color.set(layer, win, "progress_background")
UI_elements.roundrect(layer, win,
x,
y+current_Y + win.scroll["help"],
width,
40,
10,
fill=False)
layer.stroke()
current_Y = current_Y + 50
# Let's not list all the entries.
for entry in doc:
if entry[0] == "Markdown":
2021-05-10 21:52:14 +02:00
win.current["mdfs"]["help_markdown"] = entry[1]
2021-05-10 21:52:14 +02:00
#win.current["current_help_selected"] = ""
continue
2021-06-14 18:01:30 +02:00
# icon do not show
elif entry[0] == "icon":
continue
2020-12-25 15:22:08 +01:00
# Launch button
def do():
oscalls.Open(entry[-1])
UI_elements.roundrect(layer, win,
2021-06-14 18:01:30 +02:00
x+10,
2020-12-25 15:22:08 +01:00
y+current_Y + win.scroll["help"],
width-20,
40,
10,
icon=entry[0],
button=do,
tip=entry[-1])
# And a text. The name of the entry
2021-06-14 18:01:30 +02:00
if not tiny:
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(x+70,
y+current_Y + win.scroll["help"]+25)
layer.show_text(talk.text("documentation_type_"+entry[0]))
2020-12-25 15:22:08 +01:00
current_Y = current_Y + 50
else:
current_Y = current_Y + 50
# Call
def do():
os.system("xdg-open https://meet.jit.si/VCStudioDevelopmentConference")
2020-12-25 15:22:08 +01:00
UI_elements.roundrect(layer, win,
x,
y+current_Y + win.scroll["help"],
width,
40,
10,
button=do,
icon="call",
tip=talk.text("contact_us_tip"))
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(x+50,
y+current_Y + win.scroll["help"]+25)
layer.show_text(talk.text("contact_us_now"))
current_Y = current_Y + 50
# Report Bug Button
def do():
2021-05-10 21:52:14 +02:00
os.system("xdg-open https://notabug.org/jyamihud/VCStudio/issues")
UI_elements.roundrect(layer, win,
x,
y+current_Y + win.scroll["help"],
width,
40,
10,
button=do,
icon="bug",
tip=talk.text("report_bug_tip"))
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(x+50,
y+current_Y + win.scroll["help"]+25)
layer.show_text(talk.text("report_bug_now"))
current_Y = current_Y + 50
2020-12-25 15:22:08 +01:00
###########################
UI_elements.scroll_area(layer, win, "help",
x,
y,
width,
height-60,
current_Y,
bar=True,
mmb=True,
url="help"
)
return surface