Blender-Pipeline/UI/UI_helpDialog.py

282 lines
8.3 KiB
Python

# THIS FILE IS A PART OF VCStudio
# PYTHON 3
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
# 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
##########################################################################
# 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()
UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win,
win.current["w"]/2-250,
100,
500,
win.current["h"]-200,
10)
# Exit button
def do():
win.current["calls"][call]["var"] = False
UI_elements.roundrect(layer, win,
win.current["w"]/2-20,
win.current["h"]-140,
40,
40,
10,
button=do,
icon="cancel",
tip=talk.text("cancel"))
x = win.current["w"]/2-250 + 10
y = 170
width = 500 - 20
height = win.current["h"]-270
# Search
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)
# 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("documentation_installation"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Installation+%7C+Version+20.128"]
],
talk.text("documentation_project_manager"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Project+Manager+%7C+Version+20.128"]
],
talk.text("documentation_story_editor"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Story+Editor+%7C+Version+20.128+"]
],
talk.text("documentation_script_writer"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Script+Writer+%7C+Version+20.128"]
],
talk.text("documentation_analytics"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Analytics+%7C+Version+20.128"]
],
talk.text("documentation_assets"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Assets+%7C+Version+20.128"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"]
],
talk.text("documentation_link_assets"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Linking+Assets+%7C+Version+20.128"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"]
],
talk.text("documentation_render"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Rendering+%7C+Version+20.128"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1266+%28+Rendering+Of+Shots+%29"]
]
}
# 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"] != win.current["current_help_selected"]\
and win.text["in_help"]["text"].lower() == name.lower():
win.current["current_help_selected"] = name
# 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"] = ""
if name != win.current["current_help_selected"]:
win.current["current_help_selected"] = name
else:
win.current["current_help_selected"] = False
UI_elements.roundrect(layer, win,
x,
y+current_Y + win.scroll["help"],
width,
40,
10,
icon="question",
button=do)
# And a text. The name of the entry
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)
# 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:
# Launch button
def do():
oscalls.Open(entry[-1])
UI_elements.roundrect(layer, win,
x+20,
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
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]))
current_Y = current_Y + 50
else:
current_Y = current_Y + 50
###########################
UI_elements.scroll_area(layer, win, "help",
x,
y,
width,
height-60,
current_Y,
bar=True,
mmb=True,
url="help"
)
return surface