def updateStatus(status): global gStatus gStatus = status BGL.glClearColor(0.392,0.396,0.549,1) BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) size = Blender.Window.GetAreaSize() isize = drawHeader(size) BGL.glColor3f(1.0,1.0,1.0) yval = size[1]-isize[1] - 40 Blender.BGL.glRasterPos2i(60, yval) Blender.Draw.Text('Status:','normal') if type(gStatus) == types.ListType: for s in gStatus: Blender.BGL.glRasterPos2i(105, yval) Blender.Draw.Text(s,'normal') yval = yval - 18 else: Blender.BGL.glRasterPos2i(105, yval) Blender.Draw.Text(gStatus,'normal') yval = yval - 18 Blender.Redraw()
def draw(): # Define the draw function (which draws your GUI). global EVENT_Button global EVENT_Type global EVENT_shtoguntype global EVENT_String global EVENT_Bitmap global EVENT_WVTU_1 global Object_Button global Object_Type global Object_shtoguntype global Object_String global Object_Bitmap global Object_WVTU_1 BGL.glClearColor(0.244564, 0.244406, 0.244406, 0.0) BGL.glClear(GL_COLOR_BUFFER_BIT) BGL.glColor3f(1.000000, 1.000000, 1.000000) Object_Button = Draw.Button("Connect to Shotgun", EVENT_Button, 20, 8, 200, 20, "") BGL.glRasterPos2i(100, 108) Object_Type = Draw.Text("Type") Object_shtoguntype = Draw.Menu("Asset", EVENT_shtoguntype, 20, 100, 60, 20, Object_shtoguntype.val, "Type of Shotgun entry") Object_String = Draw.String("id : ", EVENT_String, 20, 60, 60, 20,Object_String.val, 399, "ID # for the Shotgun entry") BGL.glRasterPos2i(24, 210) BGL.glDrawPixels(0, 0, GL_RGB, GL_UNSIGNED_BYTE, Object_Bitmap) BGL.glRasterPos2i(24, 152) Object_WVTU_1 = Draw.Text("WVTU "+VERSION+"")
def __init__(self, background): ## Basic background colour. BGL.glClearColor(background[0],background[1],background[2],background[3]) ## Clear the OpenGL script window to background colour. BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) ## Create a buffer space for the values we're after. scissorbox=BGL.Buffer(BGL.GL_FLOAT,4) ## Get the openGL window size values. BGL.glGetFloatv(BGL.GL_SCISSOR_BOX,scissorbox) ## The scissorbox values are floats, so we change them to integers. This prevents protests from Python about "int expected". ## The left and base values are mainly used to calculate the position of the mouse x and y values. # Left side of the OpenGL script window. Value is in pixels, from the left side of the main Blender window. self.left=int(scissorbox[0]) # Bottom of the OpenGL script window.Value is in pixels, up from the bottom of the main Blender window. self.base=int(scissorbox[1]) # Width of the OpenGL script window. self.width=int(scissorbox[2]) # Height of the OpenGL script window. self.height=int(scissorbox[3])
def bad_draw(): global _gui_edge_length_button, _gui_edge_angle_button, _gui_edge_weld_button try: BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glRasterPos2d(8, 40) Draw.Text('Blender Assisted Design', 'large') _gui_edge_length_button = Draw.Number('Edge length: ', GUI_EDGE_LENGTH, 8, 8, 200, 24, _gui_edge_length, 0.0, 1000.0, bad_set_length.__doc__) Draw.PushButton( 'Set', 0, 214, 8, 40, 24, bad_set_length.__doc__, lambda *a: bad_script_call(bad_script_set_length, float(_gui_edge_length)) ) _gui_edge_angle_button = Draw.Number('Edge angle: ', GUI_EDGE_ANGLE, 270, 8, 200, 24, _gui_edge_angle, 0.0, 180.0, bad_set_angle.__doc__) Draw.PushButton( 'Set', 0, 476, 8, 40, 24, bad_set_angle.__doc__, lambda *a: bad_script_call(bad_script_set_angle, float(_gui_edge_angle)) ) Draw.PushButton( 'Weld', 0, 534, 8, 50, 24, bad_weld_edges.__doc__, lambda *a: bad_script_call(bad_script_weld) ) except Exception, e: print e Draw.Exit()
def DrawDialog(self): """Should be passed as the 'draw' argument to Blender.Draw.Register(). Defines how the dialog should be drawn on every redraw.""" BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) #BGL.glEnable(BGL.GL_BLEND) #BGL.glBlendFunc( # BGL.GL_SRC_ALPHA, # BGL.GL_ONE_MINUS_SRC_ALPHA #) BGL.glRasterPos2d(self.column(1), self.line(0)) Draw.Text('PySoy importer', 'large') self.importfile = Draw.String('Import from: ', self.EVENT_IMPORTFROM, self.column(1), self.line(2), self.width(30), self.height(1), self.filepathSTR, 399, 'Import an element from this file') self.importfilebutton = Draw.PushButton('Set import file', self.EVENT_SETIMPORT, self.column(31), self.line(2), self.width(10), self.height(1), 'Set file to import from') if self.fileselected == True: self.importmenu = Draw.Menu('Import element:%t|Mesh|Material|Entity|Node', self.EVENT_IMPORTMENU, self.column(1), self.line(4), self.width(10), self.height(1), 1, 'Select element from file to import')
def import_gui(): global filename, fileinput, impstatus # Clear drawing area. BGL.glClearColor(0.9,0.9,0.9,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # Status. BGL.glRasterPos2i(10,8) if impstatus == 0: BGL.glColor3f(0.0,0.0,0.0) Draw.Text('Importer ready.','tiny') elif impstatus == 1: BGL.glColor3f(0.0,0.75,0.0) Draw.Text('Importing...','tiny') elif impstatus == 2: BGL.glColor3f(0.75,0.0,0.0) Draw.Text('File not found!','tiny') # Filename input box. BGL.glRasterPos2i(10,20) w = Draw.Text('File to import:') Draw.Button(filename, 3, w+15, 15, 200,20) #fileinput = Draw.String('',3, w+15,15, 200,20, filename, 512, # 'Filename to import.') Draw.Button('Import', 1, w+15+210,15, 40,20) Draw.Button('Quit', 2, w+15+210+50,15, 40,20)
def gui(self): # the function to draw the screen BGL.glClearColor(0, 0, 0.5, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1, 1, 1) BGL.glRasterPos2i(20, 200) Draw.Text("Select the object to export:", "normal") self.objMenu = Draw.Menu(self.sObjSelection, 1, 20, 170, 200, 20, self.objSel, "Select the animated object.") BGL.glRasterPos2i(20, 150) Draw.Text("Select the armature to export:", "normal") self.armMenu = Draw.Menu(self.sArmSelection, 2, 20, 120, 200, 20, self.armSel, "Select the matching armature.") BGL.glRasterPos2i(20, 100) Draw.Text("Select the root bone of the armature:", "normal") self.boneMenu = Draw.Menu(self.sBoneSelection, 3, 20, 70, 200, 20, self.boneSel, "Select the Root Bone of the armature.") Draw.PushButton("Export", 4, 250, 150, 50, 20, "Export File") Draw.PushButton("Cancel", 5, 250, 110, 50, 20, "Cancel") BGL.glRasterPos2i(72, 16) string = "Selections: " + ("%s" % self.objSel) + " / " + ( "%s" % self.armSel) + " / " + ("%s" % self.boneSel) Draw.Text(string, "small")
def drawGUI(): """ Create and draw the GUI. """ HEIGHT = 382 CONTROL_WIDTH = 400 BGL.glClearColor(0.6, 0.6, 0.6, 1.0) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(0.75, 0.75, 0.75) BGL.glRecti(3,45,CONTROL_WIDTH,3) stitchOffset = 22 HEIGHT += stitchOffset * num_motions_button.val Display_Title_Bar(HEIGHT,25, CONTROL_WIDTH) Display_File_Bar(HEIGHT - 25, 71 + stitchOffset * num_motions_button.val, CONTROL_WIDTH) Display_Mesh_Bar(HEIGHT - 96 - stitchOffset * num_motions_button.val, 48, CONTROL_WIDTH) Display_Camera_Bar(HEIGHT - 144 - stitchOffset * num_motions_button.val, 112, CONTROL_WIDTH) Display_Render_Bar(HEIGHT - 256 - stitchOffset * num_motions_button.val, 48, CONTROL_WIDTH) Display_Output_Bar(HEIGHT - 304 - stitchOffset * num_motions_button.val, 48, CONTROL_WIDTH) Draw.PushButton('Load simulation', SimulationButton, 9, 8, (CONTROL_WIDTH / 2) - 9, 18, 'Load simulation') if hasLoaded: Draw.PushButton('Render scene', RenderButton, (CONTROL_WIDTH / 2) + 3, 8, (CONTROL_WIDTH / 2) - 9, 18, 'Render scene')
def gui(): BGL.glClearColor(1,1,1,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # idle Draw.Label("Idle-Animation:", 10,200,180,20) Draw.Number("von ", 1, 10,180,90,20,idleStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 2, 110,180,90,20,idleEndFrame,0,1000, "", button_event, 1,1) # move Draw.Label("Move-Animation:", 10,150,180,20) Draw.Number("von ", 3, 10,130,90,20,moveStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 4, 110,130,90,20,moveEndFrame,0,1000, "", button_event, 1,1) # attack Draw.Label("Attack-Animation:", 10,90,180,20) Draw.Number("von ", 5, 10,70,90,20,attackStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 6, 110,70,90,20,attackEndFrame,0,1000, "", button_event, 1,1) # die Draw.Label("Die-Animation:", 10,40,180,20) Draw.Number("von ", 7, 10,20,90,20,dieStartFrame,0,1000, "", button_event, 1,1) Draw.Number("bis ", 8, 110,20,90,20,dieEndFrame,0,1000, "", button_event, 1,1) # RENDER-Button: Draw.Button("RENDER", 9, 230,30,80,20, "RENDER!", renderButtonClicked)
def gui_draw(): from Blender import BGL, Draw (width, height) = Blender.Window.GetAreaSize() BGL.glClearColor(0.4, 0.4, 0.45, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1, 1, 1) BGL.glRasterPos2f(5, 55) Draw.Text("FlightGear YASim Import: '%s'" % Global.path) Draw.PushButton("Reload", RELOAD_BUTTON, 5, 5, 80, 32, "reload YASim config file") Global.mirror_button = Draw.Toggle("Mirror", MIRROR_BUTTON, 100, 5, 50, 16, Global.mirror_button.val, \ "show symmetric surfaces on both sides (reloads config)") Draw.PushButton("Update Cursor", CURSOR_BUTTON, width - 650, 5, 100, 32, "update cursor display (in YASim coordinate system)") BGL.glRasterPos2f( width - 530 + Blender.Draw.GetStringWidth("Vector from last") - Blender.Draw.GetStringWidth("Current"), 24) Draw.Text("Current cursor pos: x = %+.3f y = %+.3f z = %+.3f" % tuple(Global.cursor)) c = Global.cursor - Global.last_cursor BGL.glRasterPos2f(width - 530, 7) Draw.Text( "Vector from last cursor pos: x = %+.3f y = %+.3f z = %+.3f length = %.3f m" % (c[0], c[1], c[2], c.length))
def gui(): global buttons, offsets, rows, cols size=BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size=size.list xoff=PANELPAD yoff=int(size[3]) # Default theme text =[ 0, 0, 0, 255] text_hi=[255, 255, 255, 255] header =[165, 165, 165, 255] panel =[255, 255, 255, 40] back =[180, 180, 180, 255] # Actual theme if Blender.Get('version') >= 235: theme=Blender.Window.Theme.Get() if theme: theme=theme[0] text=theme.get('ui').text space=theme.get('buts') text_hi=space.text_hi header=space.header header=[max(header[0]-30, 0), # 30 appears to be hard coded max(header[1]-30, 0), max(header[2]-30, 0), header[3]] panel=space.panel back=space.back BGL.glEnable (BGL.GL_BLEND) BGL.glBlendFunc (BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) BGL.glClearColor(float(back[0])/255, float(back[1])/255, float(back[2])/255, 1) BGL.glClear (BGL.GL_COLOR_BUFFER_BIT) BGL.glColor4ub(*header) BGL.glRectd(xoff, yoff-PANELTOP, xoff-PANELINDENT+PANELWIDTH, yoff-PANELTOP-PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff, yoff-PANELTOP-PANELHEAD, xoff-PANELINDENT+PANELWIDTH, yoff-60-PANELINDENT-rows*CONTROLSIZE) BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff+PANELINDENT, yoff-23) Draw.Text("Fixup UV mapping") BGL.glColor4ub(*text) BGL.glRasterPos2d(xoff+PANELINDENT, yoff-48) Draw.Text("Select where the old image is located in the new:") buttons=[] for i in range(rows): for j in range(cols): buttons.append(Draw.Button('', len(buttons)+CANCEL+1, xoff+PANELINDENT+j*CONTROLSIZE, yoff-80-i*CONTROLSIZE, CONTROLSIZE, CONTROLSIZE)) buttons.append(Draw.Button("Cancel", CANCEL, xoff-PANELINDENT*2+PANELWIDTH-4*CONTROLSIZE, yoff-60-rows*CONTROLSIZE, 4*CONTROLSIZE, CONTROLSIZE))
def gui(): global copynorm, copystrp size=BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size=size.list x=int(size[2]) y=int(size[3]) # Default theme text =[ 0, 0, 0, 255] text_hi=[255, 255, 255, 255] header =[195, 195, 195, 255] panel =[255, 255, 255, 40] back =[180, 180, 180, 255] # Actual theme if Blender.Get('version') >= 235: theme=Blender.Window.Theme.Get() if theme: theme=theme[0] space=theme.get('buts') text=theme.get('ui').text text_hi=space.text_hi header=space.header panel=space.panel back=space.back BGL.glEnable (BGL.GL_BLEND) BGL.glBlendFunc (BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) BGL.glClearColor (float(back[0])/255, float(back[1])/255, float(back[2])/255, 1) BGL.glClear (BGL.GL_COLOR_BUFFER_BIT) BGL.glColor4ub (max(header[0]-30, 0), # 30 appears to be hard coded max(header[1]-30, 0), max(header[2]-30, 0), header[3]) BGL.glRectd(7, y-8, 295, y-28) BGL.glColor4ub (panel[0], panel[1], panel[2], panel[3]) BGL.glRectd(7, y-28, 295, y-130) BGL.glColor4ub (text_hi[0], text_hi[1], text_hi[2], text_hi[3]) BGL.glRasterPos2d(16, y-23) Draw.Text("UV Copy & Paste") BGL.glColor4ub (text[0], text[1], text[2], text[3]) BGL.glRasterPos2d(16, y-48) Draw.Text("Select the faces to paint and then press Paste") BGL.glRasterPos2d(16, y-75) Draw.Text("Copy type:", "small") copynorm = Draw.Toggle("Normal", 3, 73, y-79, 51, 17, copynorm.val, "Copy texture to selected faces in the same or a different mesh") copystrp = Draw.Toggle("Strip", 4, 124, y-79, 51, 17, copystrp.val, "Reverse copied texture as necessary to make a strip in the same mesh") Draw.Button("Paste", 2, 14, y-120, 100, 26) Draw.Button("Cancel", 1, 187, y-120, 100, 26)
def gui(): # the function to draw the screen global mystring, mymsg, toggle if len(mystring) > 90: mystring = "" BGL.glClearColor(0,0,1,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1,1,1) Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button") BGL.glRasterPos2i(72, 16) if toggle: toggle_state = "down" else: toggle_state = "up" Draw.Text("The toggle button is %s." % toggle_state, "small") BGL.glRasterPos2i(10, 230) Draw.Text("Type letters from a to z, ESC to leave.") BGL.glRasterPos2i(20, 200) Draw.Text(mystring) BGL.glColor3f(1,0.4,0.3) BGL.glRasterPos2i(340, 70) Draw.Text(mymsg, "tiny")
def _draw(self): BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) height = 32 y_pos = 10 quit_text = "Quit" Draw.Button(quit_text, self.EVENT_EXIT, 10, y_pos, 2 * Draw.GetStringWidth(quit_text), height, "Quit script") y_pos += int(height * 1.5) render_text = "Render" Draw.Button(render_text, self.EVENT_RENDER, 10, y_pos, 2 * Draw.GetStringWidth(render_text), height, "Render scene to output") y_pos += int(height * 1.5) file_chooser_text = "..." Draw.Button(file_chooser_text, self.EVENT_FILECHOOSER, 10, y_pos, 2 * Draw.GetStringWidth(file_chooser_text), height, "Select file from file system") Draw.String("Output: ", self.EVENT_NONE, 2*Draw.GetStringWidth(file_chooser_text) + 10, y_pos, 256, height, self._get_output(), 399, "Name of output file", self._output_input_callback)
def displayWarnings(): BGL.glClearColor(0.392,0.396,0.549,1) BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) size = Blender.Window.GetAreaSize() isize = drawHeader(size) BGL.glColor3f(1.0,1.0,0.0) yval = size[1]-isize[1] - 40 Blender.BGL.glRasterPos2i(50, yval) Blender.Draw.Text('Warnings:','normal') BGL.glColor3f(1.0,1.0,1.0) for s in gWarnings: Blender.BGL.glRasterPos2i(115, yval) Blender.Draw.Text(s,'normal') yval = yval - 18 Blender.Draw.PushButton('Back', ID_BACK, 105, 10, 100, 20, 'Back To Exporter')
def OnDraw(): global Ticks, Tickctrl BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(0.2, 0.3, 0.3) DrawBox(LEFT-10, TOP - 10, 300, 380) BGL.glColor3f(0.1, 0.1, 0.1) BGL.glRasterPos2i(LEFT, TOP) Draw.Text("DirectX Exporter", "large") BGL.glRasterPos2i(LEFT, TOP - 40) Draw.Text("Export", "large") Draw.Toggle("All", 0, LEFT, TOP - 80, 80, 20, ExportType == 0, "Export all static objects in the current scene.") Draw.Toggle("Selected", 1, LEFT + 100, TOP - 80, 80, 20, ExportType == 1, "Export all selected objects.") Draw.Toggle("Animated", 2, LEFT + 200, TOP - 80, 80, 20, ExportType == 2, "Export one mesh with one armature. Make sure that only the mesh and it's armature are selected.") BGL.glRasterPos2i(LEFT, EDATA) Draw.Text("Exported data", "large") Draw.Toggle("Normals", 3, LEFT, EDATA - 40, 80, 20, Normals, "Export vertex normals.") Draw.Toggle("Colors", 4, LEFT + 200, EDATA - 40, 80, 20, Colors, "Export vertex diffuse colors.") Draw.Toggle("Texcoords", 6, LEFT, EDATA - 70, 80, 20, TexCoords, "Export vertex texture coordinates.") Draw.Toggle("Materials", 7, LEFT + 100, EDATA - 40, 80, 20, Materials, "Export materials.") BGL.glRasterPos2i(LEFT, MISC) Draw.Text("Misc options", "large") Draw.Toggle("Swap y and z", 8, LEFT, MISC - 40, 80, 20, SwapYZ, "Right-handed to left-handed system.") Draw.Toggle("Apply world", 9, LEFT + 100, MISC - 40, 80, 20, UseWTrans, "Apply world transformation to exported vertices.") Tickctrl = Draw.Number("Speed", 10, LEFT + 200, MISC - 40, 80, 20, Ticks, 1, 100, "Animation ticks per second.") #Draw.Toggle("Compressed", 11, LEFT, MISC - 70, 80, 20, Compressed, "Compress the file.") Draw.Button("Export...", 100, LEFT + 40, DOIT, 80, 40, "Export data.") Draw.Button("Exit", 101, LEFT + 140, DOIT, 80, 40, "Exit the script.") BGL.glColor3f(0.3, 0.3, 0.3) BGL.glRasterPos2i(LEFT, 35) Draw.Text("(C) 2006 Heikki Salo", "small") BGL.glRasterPos2i(LEFT, 20) Draw.Text("http://directpython.sourceforge.net/exportx.html", "small")
def gui_draw(): from Blender import BGL, Draw (width, height) = Blender.Window.GetAreaSize() BGL.glClearColor(0.4, 0.4, 0.45, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1, 1, 1) BGL.glRasterPos2f(5, 55) Draw.Text("FlightGear YASim Import: '%s'" % Global.path) Draw.PushButton("Reload", RELOAD_BUTTON, 5, 5, 80, 32, "reload YASim config file") Global.mirror_button = Draw.Toggle("Mirror", MIRROR_BUTTON, 100, 5, 50, 16, Global.mirror_button.val, \ "show symmetric surfaces on both sides (reloads config)") Draw.PushButton("Update Cursor", CURSOR_BUTTON, width - 650, 5, 100, 32, "update cursor display (in YASim coordinate system)") BGL.glRasterPos2f(width - 530 + Blender.Draw.GetStringWidth("Vector from last") - Blender.Draw.GetStringWidth("Current"), 24) Draw.Text("Current cursor pos: x = %+.3f y = %+.3f z = %+.3f" % tuple(Global.cursor)) c = Global.cursor - Global.last_cursor BGL.glRasterPos2f(width - 530, 7) Draw.Text("Vector from last cursor pos: x = %+.3f y = %+.3f z = %+.3f length = %.3f m" % (c[0], c[1], c[2], c.length))
def gui(self): # the function to draw the screen BGL.glClearColor(0,0,0.5,1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3f(1,1,1) BGL.glRasterPos2i(20,200) Draw.Text("Select the object to export:", "normal") self.objMenu = Draw.Menu(self.sObjSelection, 1, 20, 170, 200, 20, self.objSel, "Select the animated object.") BGL.glRasterPos2i(20,150) Draw.Text("Select the armature to export:", "normal") self.armMenu = Draw.Menu(self.sArmSelection, 2, 20, 120, 200, 20, self.armSel, "Select the matching armature.") BGL.glRasterPos2i(20,100) Draw.Text("Select the root bone of the armature:", "normal") self.boneMenu = Draw.Menu(self.sBoneSelection, 3, 20, 70, 200, 20, self.boneSel, "Select the Root Bone of the armature.") Draw.PushButton("Export", 4, 250, 150, 50, 20, "Export File") Draw.PushButton("Cancel", 5, 250, 110, 50, 20, "Cancel") BGL.glRasterPos2i(72, 16) string = "Selections: " + ("%s" % self.objSel) + " / " + ("%s" % self.armSel) + " / " + ("%s" % self.boneSel) Draw.Text(string, "small")
def gui(): # drawing the screen global SCREEN, START_SCREEN, CONFIG_SCREEN, KEYMENUS, LABELS global BEVT_KEYMENU, BUT_KEYMENU, CFGKEY global BUT_TYPES, SCROLL_DOWN, VARS_NUM WIDTH, HEIGHT = Window.GetAreaSize() theme = Theme.Get()[0] tui = theme.get('ui') ttxt = theme.get('text') COL_BG = float_colors(ttxt.back) COL_TXT = ttxt.text COL_TXTHI = ttxt.text_hi BGL.glClearColor(COL_BG[0], COL_BG[1], COL_BG[2], COL_BG[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) if SCREEN == START_SCREEN: x = 10 y = 10 h = 20 w = 90 BGL.glRasterPos2i(x, y) Draw.Text( 'Select a configuration key to access it. Press Q or ESC to leave.' ) km_len = len(KEYMENUS) km_columns = (WIDTH - x) / w if km_columns == 0: km_rows = km_len else: km_rows = km_len / km_columns if (km_len % km_columns): km_rows += 1 if km_rows == 0: km_rows = 1 ystart = y + 2 * h * km_rows if ystart > (HEIGHT - 70): ystart = HEIGHT - 70 y = ystart column = 1 for i, km in enumerate(KEYMENUS): column += 1 BGL.glRasterPos2i(x + 2, y + h + 5) Draw.Text(LABELS[i]) BUT_KEYMENU[i] = Draw.Menu( km, BEVT_KEYMENU[i], x, y, w - 10, h, 0, 'Choose a key to access its configuration data') if column > km_columns: column = 1 y -= 2 * h if y < 35: break x = 10 else: x += w x = 10 y = 50 + ystart BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Configuration Editor') Draw.PushButton('help', BEVT_HELP, x, 22, 45, 16, 'View help information about this script (hotkey: H)') elif SCREEN == CONFIG_SCREEN: x = y = 10 h = 18 data = CFGKEY.sorteddata tips = CFGKEY.tips fromdisk = CFGKEY.fromdisk limits = CFGKEY.limits VARS_NUM = 0 for k in data.keys(): VARS_NUM += len(data[k]) lines = VARS_NUM + 5 # to account for header and footer y = lines * h if y > HEIGHT - 20: y = HEIGHT - 20 BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Configuration Editor') y -= 20 BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) txtsize = 10 if HEIGHT < lines * h: BGL.glRasterPos2i(10, 5) txtsize += Draw.Text('Arrow keys or mouse wheel to scroll, ') BGL.glRasterPos2i(txtsize, 5) Draw.Text('Q or ESC to return.') BGL.glRasterPos2i(x, y) Draw.Text('Key: "%s"' % CFGKEY.name) bh = 16 bw = 45 by = 16 i = -1 if CFGKEY.scriptname: i = 0 Draw.PushButton( 'help', BEVT_HELP, x, by, bw, bh, 'Show documentation for the script that owns this key (hotkey: H)' ) Draw.PushButton('back', BEVT_BACK, x + (1 + i) * bw, by, bw, bh, 'Back to config keys selection screen (hotkey: ESC)') Draw.PushButton('exit', BEVT_EXIT, x + (2 + i) * bw, by, bw, bh, 'Exit from Scripts Config Editor (hotkey: Q)') Draw.PushButton('revert', BEVT_CANCEL, x + (3 + i) * bw, by, bw, bh, 'Revert data to original values (hotkey: U)') Draw.PushButton('apply', BEVT_APPLY, x + (4 + i) * bw, by, bw, bh, 'Apply changes, if any (hotkey: ENTER)') delmsg = 'Delete this data key from memory' if fromdisk: delmsg = "%s and from disk" % delmsg Draw.PushButton('delete', BEVT_DEL, x + (5 + i) * bw, by, bw, bh, '%s (hotkey: DELETE)' % delmsg) if fromdisk: Draw.Toggle( "file", BEVT_DISK, x + 3 + (6 + i) * bw, by, bw, bh, DISK_UPDATE, 'Update also the file where this config key is stored') i = -1 top = -1 y -= 20 yend = 30 if data.has_key(bool) and y > 0: lst = data[bool] for l in lst: top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break w = 20 tog = data[bool][i][1] if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click to toggle" BUT_TYPES[bool][i] = Draw.Toggle("", BEVT_BOOL + i, x, y, w, h, tog, tooltip) BGL.glRasterPos2i(x + w + 3, y + 5) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(int) and y > 0: lst = data[int] for l in lst: w = 70 top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break val = data[int][i][1] if limits: min, max = limits[l[0]] else: min, max = 0, 10 if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click / drag to change" BUT_TYPES[int][i] = Draw.Number("", BEVT_INT + i, x, y, w, h, val, min, max, tooltip) BGL.glRasterPos2i(x + w + 3, y + 3) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(float) and y > 0: lst = data[float] for l in lst: w = 70 top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break val = data[float][i][1] if limits: min, max = limits[l[0]] else: min, max = 0.0, 1.0 if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click and drag to change" BUT_TYPES[float][i] = Draw.Number("", BEVT_FLOAT + i, x, y, w, h, val, min, max, tooltip) BGL.glRasterPos2i(x + w + 3, y + 3) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(str) and y > 0: lst = data[str] for l in lst: top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break name = l[0].lower() is_dir = is_file = False if name.find('_dir', -4) > 0: is_dir = True elif name.find('_file', -5) > 0: is_file = True w = WIDTH - 20 wbrowse = 50 if is_dir and w > wbrowse: w -= wbrowse if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click to write a new string" name = name.replace('_', ' ') + ': ' if len(l[1]) > MAX_STR_LEN: l[1] = l[1][:MAX_STR_LEN] BUT_TYPES[str][i] = Draw.String(name, BEVT_STR + i, x, y, w, h, l[1], MAX_STR_LEN, tooltip) if is_dir: Draw.PushButton( 'browse', BEVT_BROWSEDIR + i, x + w + 1, y, wbrowse, h, 'click to open a file selector (pick any file in the desired dir)' ) elif is_file: Draw.PushButton('browse', BEVT_BROWSEFILE + i, x + w + 1, y, 50, h, 'click to open a file selector')
def renderGUI(): """ Renders the GUI for the script. """ global G # find the selection set and update some selection # related flags haveEmpty = False haveCamera = False emptyName = "" G.selection = Object.GetSelected() G.curempty = None if G.selection is not None and len(G.selection) > 0: mso = G.selection[0] msotype = mso.getType() if msotype == 'Empty': haveEmpty = True G.curempty = mso emptyName = G.curempty.getName() elif msotype == 'Camera': haveCamera = True emptyHasCoords = G.coordmap.has_key(emptyName) removeUnknownsFromCoords() # clear any buttons that need to have set states G.buttons.add = G.buttons.delete = None # clear the window c = COLOR_BACKGROUND BGL.glClearColor(c[0], c[1], c[2], c[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # paint the image in the background if G.image is not None: #drawImage(G.image, G.imgpos, G.iw, G.ih, G.zoom) Draw.Image(G.image, G.imgpos[0], G.imgpos[1], G.zoom, G.zoom) # paint 2D vertices in the image BGL.glPushAttrib(BGL.GL_POINT_BIT | BGL.GL_CURRENT_BIT) BGL.glPointSize(POINT_SIZE) x0 = int(G.imgpos[0] / G.zoom) y0 = int(G.imgpos[1] / G.zoom) def drawvc(ec): emptyname, coord = ec if Object.Get(emptyname) in G.selection: c = COLOR_VERTSEL else: c = COLOR_VERTUNSEL BGL.glColor4f(c[0], c[1], c[2], c[3]) BGL.glVertex2f(G.zoom*(coord[0]+x0), G.zoom*(coord[1]+y0)) BGL.glBegin(BGL.GL_POINTS) map(drawvc, G.coordmap.items()) BGL.glEnd() BGL.glPopAttrib() # if we're in add mode then draw some extra stuff if G.mode == MODE_ADD: xm,ym = map(int, getWMCoords()) xm -= 10 ym += 10 (xw,yw,ww,hw) = getWinRect() # draw crosshairs c = COLOR_CROSSHAIRS BGL.glColor4f(c[0], c[1], c[2], c[3]) verts = [ (xm,0), (xm,hw), (0,ym), (ww,ym) ] BGL.glBegin(BGL.GL_LINES) map(lambda x: BGL.glVertex2d(x[0],x[1]), verts) BGL.glEnd() ############################################# # UNCOMMENT THIS SECTION FOR A COOL MINIMAP # EFFECT - NOT VERY USEFUL THOUGH # ## draw "minimap" background #c = COLOR_MINIMAP #BGL.glColor4f(c[0], c[1], c[2], c[3]) #verts = [ (119,10), (221,10), (221,111), (119,111) ] #BGL.glBegin(BGL.GL_QUADS) #map(lambda x: BGL.glVertex2i(x[0],x[1]), verts) #BGL.glEnd() # ## paint the image into the minimap #ix,iy = wc2ic((xm,ym)) #ix,iy = map(int, [ix, iy]) #drawImage(G.ibuf, (120,10), G.iw, G.ih, 10.0, (ix-5,iy-5,10,10)) # # END OF MINIMAP SECTION ############################################# # paint the current empty name if haveEmpty: c = COLOR_TEXT BGL.glColor4d(c[0], c[1], c[2], c[3]) BGL.glRasterPos2i(220, 10) Draw.Text(emptyName, 'small') # paint the normal GUI buttons G.buttons.quit = Draw.PushButton('Quit', BUTTON_QUIT, 5, 5, 100, 20, 'Exits the script.') G.buttons.load = Draw.PushButton('Load Image', BUTTON_LOAD, 5, 25, 100, 20, 'Loads an image.') G.buttons.zoom = Draw.Number('Zoom', BUTTON_ZOOM, 5, 45, 100, 20, G.zoom, ZOOM_MIN, ZOOM_MAX, 'Adjusts image zoom.') # paint camera-specific stuff if haveCamera: G.buttons.fullopt = Draw.Toggle('Full Optimization', BUTTON_FULLOPT, 110, 5, 120, 20, G.fullopt, 'Full or partial optimization.') G.buttons.coplanar = Draw.Toggle('Coplanar', BUTTON_COPLANAR, 110, 25, 120, 20, G.coplanar, 'Coplanar or non-coplanar target.') # Origin offset is not currently working in the Tsai module. # It should be brought back here when it is. #G.buttons.ofsz = Draw.Number('OfsZ', BUTTON_OFSZ, 110, 50, 100, 20, G.ofsz, OFS_MIN, OFS_MAX, 'Z origin offset.') #G.buttons.ofsy = Draw.Number('OfsY', BUTTON_OFSY, 110, 70, 100, 20, G.ofsy, OFS_MIN, OFS_MAX, 'Y origin offset.') #G.buttons.ofsx = Draw.Number('OfsX', BUTTON_OFSX, 110, 90, 100, 20, G.ofsx, OFS_MIN, OFS_MAX, 'X origin offset.') G.buttons.calibrate = Draw.PushButton('Calibrate', BUTTON_CALIBRATE, 235, 5, 100, 20, 'Calibrates the selected camera.') # paint empty-specific stuff elif haveEmpty and (G.mode == MODE_NORMAL): if emptyHasCoords: G.buttons.delete = Draw.PushButton('Delete', BUTTON_DELETE, 110, 5, 100, 20, 'Adds an image calibration coordinate.') else: G.buttons.add = Draw.PushButton('Add', BUTTON_ADD, 110, 5, 100, 20, 'Removes an image calibration coordinate.')
def gui(): global dataref_m, dataref_b, indices_b, indices_t, vals_b, clear_b, loops_b global hideshow_m, from_b, to_b, up_b, down_b, delete_b, addhs_b global cancel_b, apply_b global manipulator_m, manipulator_b, cursor_m, cursor_b dataref_m = [] dataref_b = [] indices_b = [] indices_t = [] vals_b = [] clear_b = None loops_b = [] hideshow_m = [] from_b = [] to_b = [] up_b = [] down_b = [] delete_b = [] addhs_b = None cancel_b = None apply_b = None # Default theme text = [0, 0, 0, 255] text_hi = [255, 255, 255, 255] header = [165, 165, 165, 255] panel = [255, 255, 255, 40] back = [180, 180, 180, 255] error = [255, 80, 80, 255] # where's the theme value for this? # Actual theme if Blender.Get('version') >= 235: theme = Blender.Window.Theme.Get() if theme: theme = theme[0] space = theme.get('buts') text = theme.get('ui').text text_hi = space.text_hi header = space.header header = [ max(header[0] - 30, 0), # 30 appears to be hard coded max(header[1] - 30, 0), max(header[2] - 30, 0), header[3] ] panel = space.panel back = space.back size = BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size = size.list x = int(size[2]) y = int(size[3]) BGL.glEnable(BGL.GL_BLEND) BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) BGL.glClearColor( float(back[0]) / 255, float(back[1]) / 255, float(back[2]) / 255, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) yoff = y - offset[1] if vertical: xoff = PANELPAD + PANELINDENT - offset[0] for boneno in range(bonecount): eventbase = boneno * EVENTMAX framecount = len(vals[boneno]) if not vertical: xoff = PANELPAD + boneno * (PANELWIDTH + PANELPAD) + PANELINDENT - offset[0] BGL.glColor4ub(*header) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP, xoff - PANELINDENT + PANELWIDTH, yoff - PANELTOP - PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP - PANELHEAD, xoff - PANELINDENT + PANELWIDTH, yoff - 170 - (CONTROLSIZE - 1) * framecount) txt = 'parent bone' if boneno: txt = 'grand' + txt txt = 'great-' * (boneno - 1) + txt txt = txt[0].upper() + txt[1:] BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff, yoff - 23) Draw.Text(txt) Draw.Label("Dataref:", xoff - 4, yoff - 54, 100, CONTROLSIZE) BGL.glColor4ub(*error) # For errors (valid, mbutton, bbutton, ibutton, tbutton) = drawdataref(datarefs, indices, eventbase, boneno, xoff - 4, yoff - 80) dataref_m.append(mbutton) dataref_b.append(bbutton) indices_b.append(ibutton) indices_t.append(tbutton) vals_b.append([]) if valid: # is a valid or custom dataref Draw.Label("Dataref values:", xoff - 4, yoff - 132, 150, CONTROLSIZE) for i in range(framecount): Draw.Label("Frame #%d:" % (i + 1), xoff - 4 + CONTROLSIZE, yoff - 152 - (CONTROLSIZE - 1) * i, 100, CONTROLSIZE) if i > 1: v9 = 'v9: ' else: v9 = '' vals_b[-1].append( Draw.Number( '', i + VALS_B + eventbase, xoff + 104, yoff - 152 - (CONTROLSIZE - 1) * i, 80, CONTROLSIZE, vals[boneno][i], -NUMBERMAX, NUMBERMAX, v9 + 'The dataref value that corresponds to the pose in frame %d' % (i + 1))) if framecount > 2: clear_b = Draw.Button( 'Delete', DELETE_B + eventbase, xoff + 208, yoff - 152 - (CONTROLSIZE - 1) * (framecount - 1), 80, CONTROLSIZE, 'Clear animation keys from this frame') Draw.Label("Loop:", xoff - 4 + CONTROLSIZE, yoff - 160 - (CONTROLSIZE - 1) * framecount, 100, CONTROLSIZE) loops_b.append( Draw.Number( '', LOOPS_B + eventbase, xoff + 104, yoff - 160 - (CONTROLSIZE - 1) * framecount, 80, CONTROLSIZE, loops[boneno], -NUMBERMAX, NUMBERMAX, 'v9: The animation will loop back to frame 1 when the dataref value exceeds this number. Enter 0 for no loop.' )) else: loops_b.append(None) if vertical: yoff -= (170 + (CONTROLSIZE - 1) * framecount) #Draw Manipulator GUI #This is broken #if valid: # Draw.Label("Manipulator:", xoff-4, yoff-220-(CONTROLSIZE-1)*i, 100, CONTROLSIZE) # drawmanipulator(manipulators, indices, eventbase, boneno, xoff-4, yoff-250-(CONTROLSIZE-1)*i) if not vertical: xoff = PANELPAD + bonecount * (PANELWIDTH + PANELPAD) + PANELINDENT - offset[0] BGL.glColor4ub(*header) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP, xoff - PANELINDENT + PANELWIDTH, yoff - PANELTOP - PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff - PANELINDENT, yoff - PANELTOP - PANELHEAD, xoff - PANELINDENT + PANELWIDTH, yoff - 64 - len(hideshow) * 82) BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff, yoff - 23) Draw.Text("Hide/Show for all children of %s" % armature.name) for hs in range(len(hideshow)): eventbase = (bonecount + hs) * EVENTMAX BGL.glColor4ub(*panel) BGL.glRectd(xoff - 4, yoff - PANELTOP - PANELHEAD - 4 - hs * 82, xoff - 13 + PANELWIDTH, yoff - PANELTOP - 101 - hs * 82) BGL.glColor4ub(*error) # For errors (valid, mbutton, bbutton, ibutton, tbutton) = drawdataref(hideshow, hideshowindices, eventbase, hs, xoff - 4, yoff - 54 - hs * 82) dataref_m.append(mbutton) dataref_b.append(bbutton) indices_b.append(ibutton) indices_t.append(tbutton) if hs: up_b.append( Draw.Button('^', UP_B + eventbase, xoff + 217, yoff - 80 - hs * 82, CONTROLSIZE, CONTROLSIZE, 'Move this entry up')) else: up_b.append(None) if hs != len(hideshow) - 1: down_b.append( Draw.Button('v', DOWN_B + eventbase, xoff + 237, yoff - 80 - hs * 82, CONTROLSIZE, CONTROLSIZE, 'Move this entry down')) else: down_b.append(None) delete_b.append( Draw.Button('X', DELETE_B + eventbase, xoff + 267, yoff - 80 - hs * 82, CONTROLSIZE, CONTROLSIZE, 'Delete this entry')) if valid: # is a valid or custom dataref hideshow_m.append( Draw.Menu('Hide%x0|Show%x1', HIDEORSHOW_M + eventbase, xoff, yoff - 106 - hs * 82, 62, CONTROLSIZE, hideorshow[hs], 'Choose Hide or Show')) Draw.Label("when", xoff + 63, yoff - 106 - hs * 82, 60, CONTROLSIZE) from_b.append( Draw.Number( '', FROM_B + eventbase, xoff + 104, yoff - 106 - hs * 82, 80, CONTROLSIZE, hideshowfrom[hs], -NUMBERMAX, NUMBERMAX, 'The dataref value above which the animation will be hidden or shown' )) Draw.Label("to", xoff + 187, yoff - 106 - hs * 82, 60, CONTROLSIZE) to_b.append( Draw.Number( '', TO_B + eventbase, xoff + 207, yoff - 106 - hs * 82, 80, CONTROLSIZE, hideshowto[hs], -NUMBERMAX, NUMBERMAX, 'The dataref value below which the animation will be hidden or shown' )) else: hideshow_m.append(None) from_b.append(None) to_b.append(None) addhs_b = Draw.Button('Add New', ADD_B + bonecount * EVENTMAX, xoff + 217, yoff - 54 - len(hideshow) * 82, 70, CONTROLSIZE, 'Add a new Hide or Show entry') if vertical: xoff = PANELPAD - offset[0] yoff -= (64 + len(hideshow) * 82) else: xoff = PANELPAD + (bonecount + 1) * (PANELWIDTH + PANELPAD) - offset[0] apply_b = Draw.Button('Apply', APPLY_B + bonecount * EVENTMAX, xoff, yoff - PANELTOP - CONTROLSIZE * 2, 80, CONTROLSIZE * 2, 'Apply these settings', doapply) if vertical: cancel_b = Draw.Button('Cancel', CANCEL_B + bonecount * EVENTMAX, xoff + 80 + PANELPAD, yoff - PANELTOP - CONTROLSIZE * 2, 80, CONTROLSIZE * 2, 'Retain existing settings') else: cancel_b = Draw.Button('Cancel', CANCEL_B + bonecount * EVENTMAX, xoff, yoff - PANELTOP - CONTROLSIZE * 4 - PANELPAD, 80, CONTROLSIZE * 2, 'Retain existing settings')
def DrawDialog(self): """Should be passed as the 'draw' argument to Blender.Draw.Register(). Defines how the dialog should be drawn on every redraw.""" BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) #BGL.glEnable(BGL.GL_BLEND) #BGL.glBlendFunc( # BGL.GL_SRC_ALPHA, # BGL.GL_ONE_MINUS_SRC_ALPHA #) BGL.glRasterPos2d(self.column(1), self.line(0)) Draw.Text('PySoy exporter', 'large') BGL.glRasterPos2d(self.column(1), self.line(2)) Draw.Text('Level export options:') self.activescene = Draw.Toggle('Only active scene', self.EVENT_ACTIVE_SCENE, self.column(1), self.line(4), self.width(13), self.height(1), self.activesceneBT, 'Only export the currently active scene as a level') self.allscenes = Draw.Toggle('All scenes', self.EVENT_ALL_SCENES, self.column(14), self.line(4), self.width(13), self.height(1), self.allscenesBT, 'Export all scenes as levels') self.rootpath = Draw.String('Root datapath: ', self.EVENT_ROOTPATH, self.column(1), self.line(5), self.width(30), self.height(1), self.rootpathSTR, 399, 'File path for game data') self.setroot = Draw.PushButton('Set root path', self.EVENT_SETPATH, self.column(31), self.line(5), self.width(10), self.height(1), 'Set another root path for data') self.meshdialog.DrawGroup(1, 6) self.entitydialog.DrawGroup(1, 8) self.nodedialog.DrawGroup(1, 10) self.materialdialog.DrawGroup(1, 12) self.heightmultiplier = Draw.Number('heightmultiplier', self.EVENT_HEIGHTMULT, self.column(32), self.line(14), self.width(15), self.height(1), self.heightmultFLT, 0.0, 10000.0, 'Intended scale of height for the heightmap') self.heightscale = Draw.Number('XY-scale', self.EVENT_HEIGHTSCALE, self.column(32), self.line(15), self.width(15), self.height(1), self.heightscaleFLT, 0.0, 10000.0, 'Intended scale for the X and Y axis of the heightmap.') self.heightmap = Draw.PushButton('Import heightmap', self.EVENT_HEIGHTMAP, self.column(17), self.line(15), self.width(15), self.height(2), 'Import heightmap for reference') self.exportlevel = Draw.PushButton('Export as level(s)', self.EVENT_EXPORTLEVEL, self.column(1), self.line(15), self.width(15), self.height(2), 'Export scene(s) as level(s)') BGL.glRasterPos2d(self.column(1), self.line(17)) Draw.Text('Model export options:') self.modelpath = Draw.String('Save model as: ', self.EVENT_MODELPATH, self.column(1), self.line(19), self.width(30), self.height(1), self.modelpathSTR, 399, 'File path for meshified model') self.setmodel = Draw.PushButton('Set model path', self.EVENT_SETMODEL, self.column(31), self.line(19), self.width(10), self.height(1), 'Set another path for meshes') self.exportmodel = Draw.PushButton('Export as mesh(es)', self.EVENT_EXPORTMODEL, self.column(1), self.line(21), self.width(15), self.height(2), 'Export each Group as a mesh')
def gui(): global dataref_m, dataref_b, indices_b, indices_t, vals_b, clear_b, loops_b global hideshow_m, from_b, to_b, up_b, down_b, delete_b, addhs_b global cancel_b, apply_b global manipulator_m, manipulator_b, cursor_m, cursor_b dataref_m=[] dataref_b=[] indices_b=[] indices_t=[] vals_b=[] clear_b=None loops_b=[] hideshow_m=[] from_b=[] to_b=[] up_b=[] down_b=[] delete_b=[] addhs_b=None cancel_b=None apply_b=None # Default theme text =[ 0, 0, 0, 255] text_hi=[255, 255, 255, 255] header =[165, 165, 165, 255] panel =[255, 255, 255, 40] back =[180, 180, 180, 255] error =[255, 80, 80, 255] # where's the theme value for this? # Actual theme if Blender.Get('version') >= 235: theme=Blender.Window.Theme.Get() if theme: theme=theme[0] space=theme.get('buts') text=theme.get('ui').text text_hi=space.text_hi header=space.header header=[max(header[0]-30, 0), # 30 appears to be hard coded max(header[1]-30, 0), max(header[2]-30, 0), header[3]] panel=space.panel back=space.back size=BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size=size.list x=int(size[2]) y=int(size[3]) BGL.glEnable(BGL.GL_BLEND) BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) BGL.glClearColor(float(back[0])/255, float(back[1])/255, float(back[2])/255, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) yoff=y-offset[1] if vertical: xoff=PANELPAD+PANELINDENT-offset[0] for boneno in range(bonecount): eventbase=boneno*EVENTMAX framecount=len(vals[boneno]) if not vertical: xoff=PANELPAD+boneno*(PANELWIDTH+PANELPAD)+PANELINDENT-offset[0] BGL.glColor4ub(*header) BGL.glRectd(xoff-PANELINDENT, yoff-PANELTOP, xoff-PANELINDENT+PANELWIDTH, yoff-PANELTOP-PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff-PANELINDENT, yoff-PANELTOP-PANELHEAD, xoff-PANELINDENT+PANELWIDTH, yoff-170-(CONTROLSIZE-1)*framecount) txt='parent bone' if boneno: txt='grand'+txt txt='great-'*(boneno-1)+txt txt=txt[0].upper()+txt[1:] BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff, yoff-23) Draw.Text(txt) Draw.Label("Dataref:", xoff-4, yoff-54, 100, CONTROLSIZE) BGL.glColor4ub(*error) # For errors (valid,mbutton,bbutton,ibutton,tbutton)=drawdataref(datarefs, indices, eventbase, boneno, xoff-4, yoff-80) dataref_m.append(mbutton) dataref_b.append(bbutton) indices_b.append(ibutton) indices_t.append(tbutton) vals_b.append([]) if valid: # is a valid or custom dataref Draw.Label("Dataref values:", xoff-4, yoff-132, 150, CONTROLSIZE) for i in range(framecount): Draw.Label("Frame #%d:" % (i+1), xoff-4+CONTROLSIZE, yoff-152-(CONTROLSIZE-1)*i, 100, CONTROLSIZE) if i>1: v9='v9: ' else: v9='' vals_b[-1].append(Draw.Number('', i+VALS_B+eventbase, xoff+104, yoff-152-(CONTROLSIZE-1)*i, 80, CONTROLSIZE, vals[boneno][i], -NUMBERMAX, NUMBERMAX, v9+'The dataref value that corresponds to the pose in frame %d' % (i+1))) if framecount>2: clear_b=Draw.Button('Delete', DELETE_B+eventbase, xoff+208, yoff-152-(CONTROLSIZE-1)*(framecount-1), 80, CONTROLSIZE, 'Clear animation keys from this frame') Draw.Label("Loop:", xoff-4+CONTROLSIZE, yoff-160-(CONTROLSIZE-1)*framecount, 100, CONTROLSIZE) loops_b.append(Draw.Number('', LOOPS_B+eventbase, xoff+104, yoff-160-(CONTROLSIZE-1)*framecount, 80, CONTROLSIZE, loops[boneno], -NUMBERMAX, NUMBERMAX, 'v9: The animation will loop back to frame 1 when the dataref value exceeds this number. Enter 0 for no loop.')) else: loops_b.append(None) if vertical: yoff-=(170+(CONTROLSIZE-1)*framecount) #Draw Manipulator GUI #This is broken #if valid: # Draw.Label("Manipulator:", xoff-4, yoff-220-(CONTROLSIZE-1)*i, 100, CONTROLSIZE) # drawmanipulator(manipulators, indices, eventbase, boneno, xoff-4, yoff-250-(CONTROLSIZE-1)*i) if not vertical: xoff=PANELPAD+bonecount*(PANELWIDTH+PANELPAD)+PANELINDENT-offset[0] BGL.glColor4ub(*header) BGL.glRectd(xoff-PANELINDENT, yoff-PANELTOP, xoff-PANELINDENT+PANELWIDTH, yoff-PANELTOP-PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff-PANELINDENT, yoff-PANELTOP-PANELHEAD, xoff-PANELINDENT+PANELWIDTH, yoff-64-len(hideshow)*82) BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff, yoff-23) Draw.Text("Hide/Show for all children of %s" % armature.name) for hs in range(len(hideshow)): eventbase=(bonecount+hs)*EVENTMAX BGL.glColor4ub(*panel) BGL.glRectd(xoff-4, yoff-PANELTOP-PANELHEAD-4-hs*82, xoff-13+PANELWIDTH, yoff-PANELTOP-101-hs*82) BGL.glColor4ub(*error) # For errors (valid,mbutton,bbutton,ibutton,tbutton)=drawdataref(hideshow, hideshowindices, eventbase, hs, xoff-4, yoff-54-hs*82) dataref_m.append(mbutton) dataref_b.append(bbutton) indices_b.append(ibutton) indices_t.append(tbutton) if hs: up_b.append(Draw.Button('^', UP_B+eventbase, xoff+217, yoff-80-hs*82, CONTROLSIZE, CONTROLSIZE, 'Move this entry up')) else: up_b.append(None) if hs!=len(hideshow)-1: down_b.append(Draw.Button('v', DOWN_B+eventbase, xoff+237, yoff-80-hs*82, CONTROLSIZE, CONTROLSIZE, 'Move this entry down')) else: down_b.append(None) delete_b.append(Draw.Button('X', DELETE_B+eventbase, xoff+267, yoff-80-hs*82, CONTROLSIZE, CONTROLSIZE, 'Delete this entry')) if valid: # is a valid or custom dataref hideshow_m.append(Draw.Menu('Hide%x0|Show%x1', HIDEORSHOW_M+eventbase, xoff, yoff-106-hs*82, 62, CONTROLSIZE, hideorshow[hs], 'Choose Hide or Show')) Draw.Label("when", xoff+63, yoff-106-hs*82, 60, CONTROLSIZE) from_b.append(Draw.Number('', FROM_B+eventbase, xoff+104, yoff-106-hs*82, 80, CONTROLSIZE, hideshowfrom[hs], -NUMBERMAX, NUMBERMAX, 'The dataref value above which the animation will be hidden or shown')) Draw.Label("to", xoff+187, yoff-106-hs*82, 60, CONTROLSIZE) to_b.append(Draw.Number('', TO_B+eventbase, xoff+207, yoff-106-hs*82, 80, CONTROLSIZE, hideshowto[hs], -NUMBERMAX, NUMBERMAX, 'The dataref value below which the animation will be hidden or shown')) else: hideshow_m.append(None) from_b.append(None) to_b.append(None) addhs_b=Draw.Button('Add New', ADD_B+bonecount*EVENTMAX, xoff+217, yoff-54-len(hideshow)*82, 70, CONTROLSIZE, 'Add a new Hide or Show entry') if vertical: xoff=PANELPAD-offset[0] yoff-=(64+len(hideshow)*82) else: xoff=PANELPAD+(bonecount+1)*(PANELWIDTH+PANELPAD)-offset[0] apply_b=Draw.Button('Apply', APPLY_B+bonecount*EVENTMAX, xoff, yoff-PANELTOP-CONTROLSIZE*2, 80, CONTROLSIZE*2, 'Apply these settings', doapply) if vertical: cancel_b=Draw.Button('Cancel', CANCEL_B+bonecount*EVENTMAX, xoff+80+PANELPAD, yoff-PANELTOP-CONTROLSIZE*2, 80, CONTROLSIZE*2, 'Retain existing settings') else: cancel_b=Draw.Button('Cancel', CANCEL_B+bonecount*EVENTMAX, xoff, yoff-PANELTOP-CONTROLSIZE*4-PANELPAD, 80, CONTROLSIZE*2, 'Retain existing settings')
def gui(): global mystring, mymsg, toggle, scriptsLocation global bSelectedOnly, bBaseDir, gBaseDir global gSelectedOnly global gImageDir, gORGOutput, gTGAOutput, bTGA, bORG global bWorld, gCreateWorld, bImageDir global bSceneDir, gOutDir, gExportLights, bExportLights, gLastYVal global bWalkTest, gWalkTest, gExportCameras, bExportCameras, bReWalkTest global bExportPhysics, gExportPhysics global gLastSceneExported, bBinary, gBinary global gCreateScene, bCreateScene, bIrrlichtVersion if gDisplayWarnings: displayWarnings() return BGL.glClearColor(0.392,0.396,0.549,1) BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT) size = Blender.Window.GetAreaSize() isize = drawHeader(size) maxWidth = 440 # Create File path input BGL.glColor3f(1.0,1.0,1.0) # starting x&y position values xval = 10 yval = size[1]-isize[1] - 40 fileWidth = size[0] - (xval+130) if fileWidth > maxWidth: fileWidth = maxWidth # Scene Directory Blender.BGL.glRasterPos2i(xval, yval+5) Blender.Draw.Text('Output Directory','normal') bSceneDir = Blender.Draw.String('', ID_OUTDIR, xval+95, yval, fileWidth, 20, gOutDir, 255) Blender.Draw.PushButton('...', ID_SELECTDIR, xval+95 + fileWidth, yval, 30,20,'Select Output Directory') yval -= 40 # Option Buttons bCreateScene = Blender.Draw.Toggle('Create Scene File', ID_CREATESCENE,xval+95, yval, 150, 20, gCreateScene, 'Create Scene File (.irr)') bSelectedOnly = Blender.Draw.Toggle('Selected Meshes Only', ID_SELECTEDONLY,xval+255, yval, 150, 20, gSelectedOnly, 'Export Select Meshes Only') if gHaveMeshCvt: bBinary = Blender.Draw.Toggle('Create Binary Meshes', ID_BINARY,xval+415, yval, 150, 20, gBinary, 'Export Binary Mesh Format (.irrbmesh)') # Scene Directory if gCreateScene: yval -= 25 bExportCameras = Blender.Draw.Toggle('Export Camera(s)', ID_EXPCAMERAS, xval+95, yval, 150, 20, gExportCameras, 'Export Scene Camera(s)') bExportLights = Blender.Draw.Toggle('Export Light(s)', ID_EXPLIGHTS, xval+255, yval, 150, 20, gExportLights, 'Export Scene Light(s)') bExportPhysics = Blender.Draw.Toggle('Export Physics', ID_EXPPHYSICS, xval+415, yval, 150, 20, gExportPhysics, 'Export Physics/Collision Data') yval -= 25 dx = 95 if gCreateScene and gHaveWalkTest: bWalkTest = Blender.Draw.Toggle('Walk Test', ID_WALKTEST, xval+95, yval, 150, 20, gWalkTest, 'Run Walk Test After Export') dx = 255 Blender.Draw.PushButton('Create irrb Props', ID_GENPROPS, xval + dx, yval, 150, 20, 'Create irrb ID Properties For Selected Object(s)') # Irrlicht Version (target) for imeshcvt if gHaveMeshCvt and gBinary: yval -= 40 Blender.BGL.glRasterPos2i(xval+6, yval+4) Blender.Draw.Text('Irrlicht Version','normal') bIrrlichtVersion = Draw.Menu(sVersionList, ID_IVERSION, xval+95, yval-1, 150, 20, gIrrlichtVersion, 'Irrlicht Version Target') if gWorldLogic: yval -= 40 bWorld = Blender.Draw.Toggle('Create World File', ID_WORLD, xval+95, yval, 150, 20, gCreateWorld, 'Create Compressed .wld File (experimental)') # Export Buttons Blender.Draw.PushButton('Export', ID_EXPORT, xval+95, 10, 100, 20, 'Export') if gCreateScene and gHaveWalkTest and gLastSceneExported != None: bReWalkTest = Blender.Draw.PushButton('Run Walk Test', ID_REWALKTEST, xval + 250, 10, 150, 20, 'Run Walk Test With Last Exported Scene') Blender.Draw.PushButton('Exit', ID_CANCEL, fileWidth+35, 10, 100, 20,'Exit the Exporter') yval -= 40 Blender.BGL.glRasterPos2i(xval+50, yval) Blender.Draw.Text('Status:','normal') gLastYVal = yval if type(gStatus) == types.ListType: for s in gStatus: Blender.BGL.glRasterPos2i(xval+95, yval) Blender.Draw.Text(s,'normal') yval -= 18 if len(gWarnings) > 0 : BGL.glColor3f(1.0,1.0,0.0) Blender.BGL.glRasterPos2i(xval+95, yval) Blender.Draw.Text('%d Warning(s)' % len(gWarnings),'normal') Blender.Draw.PushButton('Warnings', ID_SHOWWARNINGS, xval+255, yval-3, 75, 20, 'Display Warnings From Last Export') else: Blender.BGL.glRasterPos2i(xval+95, yval) Blender.Draw.Text(gStatus,'normal') yval -= 18
def GUI(): global GUIPARAMS, PARAMS BGL.glClearColor(*(ScreenColor + [1.0])) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) minx = 5 maxx = 500 miny = 5 maxy = 450 lineheight = 24 buPad = 5 # Generic Button Padding, most buttons should have 24-19 (or 5) px space around them lP = 5 # Left Padding rP = 5 # Right Padding # Draw Background Box BGL.glColor3f(*BackgroundColor) BGL.glRecti(minx, miny, maxx, maxy) # Draw Title BGL.glColor3f(*TitleBG) BGL.glRecti(minx, maxy - (lineheight), maxx, maxy) BGL.glColor3f(*TitleCol) title = "2D Cutout Image Importer v" + VERSIONSTRING BGL.glRasterPos2i(minx + lP, maxy - 15) Draw.Text(title, 'large') Draw.PushButton('Exit', EXIT, maxx-50-rP, maxy - lineheight + 2, 50, 19, "Exit Script") # Path Buttons if GUIPARAMS['Path'].val == '': Draw.PushButton('Single Image', SINGLE_IMG, minx + lP, maxy - (2*lineheight), 150, 19, "Select a Single Image to Import") Draw.PushButton('Directory', DIRECTORY_IMG, minx + lP + 150, maxy - (2*lineheight), 150, 19, "Select a Directory of Images to Import") else: Draw.PushButton('Clear', CLR_PATH, minx+lP, maxy - (2*lineheight), 50, 19, "Clear Path and Change Import Options") GUIPARAMS['Path'] = Draw.String('Path: ', NO_EVT, minx + lP, maxy - (3*lineheight), (maxx-minx-lP-rP), 19, GUIPARAMS['Path'].val, 399, 'Path to Import From') if PARAMS['ImportType'] == DIR: GUIPARAMS['ImageExt'] = Draw.String('Image Ext: ', CHG_EXT, minx + lP, maxy - (4*lineheight), 110, 19, GUIPARAMS['ImageExt'].val, 6, 'Image extension for batch directory importing (case insensitive)') GUIPARAMS['PackImage'] = Draw.Toggle('Pack', NO_EVT, maxx - rP - 50, maxy - (4*lineheight), 50, 19, GUIPARAMS['PackImage'].val, 'Pack Image(s) into .Blend File') # Geometry and Viewport Options BGL.glColor3f(*TextCol) BGL.glRecti(minx+lP, maxy - (5*lineheight), maxx-rP, maxy - (5*lineheight) + 1) BGL.glRasterPos2i(minx + lP, maxy-(5*lineheight) + 3) Draw.Text('Geometry and Display Options', 'small') GUIPARAMS['PPU'] = Draw.Slider('Pixels Per Unit: ', NO_EVT, minx + lP, maxy - (6*lineheight), (maxx-minx)/2 - lP, 19, GUIPARAMS['PPU'].val, 1, 5000, 0, 'Set the Number of Pixels Per Blender Unit to preserve Image Size Relations') GUIPARAMS['VPTransp'] = Draw.Toggle('Viewport Transparency', NO_EVT, minx + lP, maxy - (8*lineheight), (maxx-minx)/2 - lP, 2*lineheight - buPad, GUIPARAMS['VPTransp'].val, 'Display Alpha Transparency in the Viewport') GUIPARAMS['XOff'] = Draw.Slider('Offs X: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (6*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['XOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the X-Direction if Importing Multiple Images') GUIPARAMS['YOff'] = Draw.Slider('Offs Y: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (7*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['YOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the Y-Direction if Importing Multiple Images') GUIPARAMS['ZOff'] = Draw.Slider('Offs Z: ', NO_EVT, minx + lP + (maxx-minx)/2, maxy - (8*lineheight), (maxx-minx)/2 - lP - rP, 19, GUIPARAMS['ZOff'].val, 0, 5.0, 0, 'Amount to Offset Each Imported in the Z-Direction if Importing Multiple Images') # Material and Texture Options BGL.glColor3f(*TextCol) BGL.glRecti(minx+lP, maxy - (9*lineheight), maxx-rP, maxy - (9*lineheight) + 1) BGL.glRasterPos2i(minx + lP, maxy-(9*lineheight) + 3) Draw.Text('Material and Texture Options', 'small') half = (maxx-minx-lP-rP)/2 GUIPARAMS['CopyMat'] = Draw.Toggle('Copy Existing Material', NO_EVT, minx + lP, maxy-(10*lineheight), half, 19, GUIPARAMS['CopyMat'].val, 'Copy an Existing Material') if GUIPARAMS['CopyMat'].val: menStr = compileMaterialList() GUIPARAMS['MatId'] = Draw.Menu(menStr, NO_EVT, minx + lP, maxy - (11*lineheight), half, 19, GUIPARAMS['MatId'].val, 'Material to Copy Settings From') else: GUIPARAMS['MatCol'] = Draw.ColorPicker(NO_EVT, minx+lP, maxy - (13*lineheight), 40, (3*lineheight) - buPad, GUIPARAMS['MatCol'].val, 'Color of Newly Created Material') GUIPARAMS['Ref'] = Draw.Slider('Ref: ', NO_EVT, minx +lP+45, maxy - (11*lineheight), half-45, 19, GUIPARAMS['Ref'].val, 0.0, 1.0, 0, 'Set the Ref Value for Created Materials') GUIPARAMS['Spec'] = Draw.Slider('Spec: ', NO_EVT, minx +lP+45, maxy - (12*lineheight), half-45, 19, GUIPARAMS['Spec'].val, 0.0, 2.0, 0, 'Set the Spec Value for Created Materials') GUIPARAMS['Hard'] = Draw.Slider('Hard: ', NO_EVT, minx +lP+45, maxy - (13*lineheight), half-45, 19, GUIPARAMS['Hard'].val, 1, 500, 0, 'Set the Hardness Value for Created Materials') GUIPARAMS['Alpha'] = Draw.Slider('A: ', NO_EVT, minx +lP, maxy - (14*lineheight), half, 19, GUIPARAMS['Alpha'].val, 0.0, 1.0, 0, 'Set the Alpha Value for Created Materials') GUIPARAMS['ZTransp'] = Draw.Toggle('ZTransparency', NO_EVT, minx + lP, maxy - (15*lineheight), half, 19, GUIPARAMS['ZTransp'].val, 'Enable ZTransparency') GUIPARAMS['Shadeless'] = Draw.Toggle('Shadeless', NO_EVT, minx + lP, maxy - (16*lineheight), half, 19, GUIPARAMS['Shadeless'].val, 'Enable Shadeless') GUIPARAMS['TexChan'] = Draw.Number('Texture Channel: ', NO_EVT, minx + lP+ half + buPad, maxy - (10*lineheight), half-rP, 19, GUIPARAMS['TexChan'].val, 1, 10, 'Texture Channel for Image Texture') GUIPARAMS['MPTCol'] = Draw.Toggle('Color', NO_EVT, minx + lP + half + buPad, maxy - (11*lineheight), half/2, 19, GUIPARAMS['MPTCol'].val, 'Map To Color Channel') GUIPARAMS['MPTAlpha'] = Draw.Toggle('Alpha', NO_EVT, minx + lP + int((1.5)*half) + buPad, maxy - (11*lineheight), half/2 - rP, 19, GUIPARAMS['MPTAlpha'].val, 'Map To Alpha Channel') third = int((maxx-minx-lP-rP)/6) GUIPARAMS['UseAlpha'] = Draw.Toggle('Use Alpha', NO_EVT, minx + lP + half + buPad, maxy - (12*lineheight), third, 19, GUIPARAMS['UseAlpha'].val, "Use the Images' Alpha Values") GUIPARAMS['CalcAlpha'] = Draw.Toggle('Calc Alpha', NO_EVT, minx + lP + half + third + buPad, maxy - (12*lineheight), third, 19, GUIPARAMS['CalcAlpha'].val, "Calculate Images' Alpha Values") GUIPARAMS['ExtendMode'] = Draw.Toggle('Extend', NO_EVT, minx+lP+half+third+third+buPad, maxy - (12*lineheight), third-3, 19, GUIPARAMS['ExtendMode'].val, "Use Extend texture mode. If deselected, Repeat is used") GUIPARAMS['Seq'] = Draw.Toggle('Sequence', NO_EVT, minx + lP + half + buPad, maxy - (13*lineheight), half-rP, 19, GUIPARAMS['Seq'].val, 'Set the Image(s) to use a Sequence instead of a Still') if GUIPARAMS['Seq'].val and not PARAMS['ImportType'] == DIR: GUIPARAMS['AutoRefresh'] = Draw.Toggle('Auto Refresh', NO_EVT, minx + lP + half + buPad, maxy - (14*lineheight), half/2, 19, GUIPARAMS['AutoRefresh'].val, 'Use Auto Refresh') GUIPARAMS['Cyclic'] = Draw.Toggle('Cyclic', NO_EVT, minx + lP + half + buPad + half/2, maxy - (14*lineheight), half/2 - rP, 19, GUIPARAMS['Cyclic'].val, 'Repeat Frames Cyclically`') GUIPARAMS['Frames'] = Draw.Number('Frames: ', NO_EVT, minx +lP + half + buPad, maxy - (15*lineheight), half - rP, 19, GUIPARAMS['Frames'].val, 1, 30000, 'Sets the Number of Images of a Movie to Use') GUIPARAMS['Offs'] = Draw.Number('Offs: ', NO_EVT, minx +lP + half + buPad, maxy - (16*lineheight), half/2, 19, GUIPARAMS['Offs'].val, -30000, 30000, 'Offsets the Number of the Frame to use in the Animation') GUIPARAMS['StartFr'] = Draw.Number('StartFr: ', NO_EVT, minx +lP + half + buPad + half/2, maxy - (16*lineheight), half/2 - rP, 19, GUIPARAMS['StartFr'].val, 1, 30000, 'Sets the Global Starting Frame of the Movie') elif GUIPARAMS['Seq'].val and PARAMS['ImportType'] == DIR: BGL.glColor3f(*ErrCol) BGL.glRasterPos2i(minx + lP + half + buPad + 7, maxy-(14 * lineheight) + 5) Draw.Text('Sequence only available for Single Image Import', 'small') # Import Options BGL.glColor3f(*TextCol) BGL.glRecti(minx+lP, maxy - (17*lineheight), maxx-rP, maxy - (17*lineheight) + 1) BGL.glRasterPos2i(minx + lP, maxy-(17*lineheight) + 3) Draw.Text('Import', 'small') if GUIPARAMS['Path'].val and GUIPARAMS['ImageExt'].val or GUIPARAMS['Path'].val and PARAMS['ImportType'] == SINGLE: Draw.PushButton('Import', DO_SCRIPT, minx + lP, maxy - (18*lineheight), 75, 19, "Import Image(s)") else: BGL.glColor3f(*ErrCol) BGL.glRasterPos2i(minx+lP, maxy - (18*lineheight) + 5) Draw.Text('A path and image type must be specified to import images') GUIPARAMS['RedrawImp'] = Draw.Toggle('Redraw During Import', NO_EVT, maxx - rP - 150, maxy - (18*lineheight), 150, 19, GUIPARAMS['RedrawImp'].val, 'Redraw the View as Images Import')
def gui(): # drawing the screen global SCREEN, START_SCREEN, CONFIG_SCREEN, KEYMENUS, LABELS global BEVT_KEYMENU, BUT_KEYMENU, CFGKEY global BUT_TYPES, SCROLL_DOWN, VARS_NUM WIDTH, HEIGHT = Window.GetAreaSize() theme = Theme.Get()[0] tui = theme.get('ui') ttxt = theme.get('text') COL_BG = float_colors(ttxt.back) COL_TXT = ttxt.text COL_TXTHI = ttxt.text_hi BGL.glClearColor(COL_BG[0],COL_BG[1],COL_BG[2],COL_BG[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3ub(COL_TXT[0],COL_TXT[1], COL_TXT[2]) if SCREEN == START_SCREEN: x = 10 y = 10 h = 20 w = 90 BGL.glRasterPos2i(x, y) Draw.Text('Select a configuration key to access it. Press Q or ESC to leave.') km_len = len(KEYMENUS) km_columns = (WIDTH - x) / w if km_columns == 0: km_rows = km_len else: km_rows = km_len / km_columns if (km_len % km_columns): km_rows += 1 if km_rows == 0: km_rows = 1 ystart = y + 2*h*km_rows if ystart > (HEIGHT - 70): ystart = HEIGHT - 70 y = ystart column = 1 for i, km in enumerate(KEYMENUS): column += 1 BGL.glRasterPos2i(x + 2, y + h + 5) Draw.Text(LABELS[i]) BUT_KEYMENU[i] = Draw.Menu(km, BEVT_KEYMENU[i], x, y, w - 10, h, 0, 'Choose a key to access its configuration data') if column > km_columns: column = 1 y -= 2*h if y < 35: break x = 10 else: x += w x = 10 y = 50 + ystart BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Configuration Editor') Draw.PushButton('help', BEVT_HELP, x, 22, 45, 16, 'View help information about this script (hotkey: H)') elif SCREEN == CONFIG_SCREEN: x = y = 10 h = 18 data = CFGKEY.sorteddata tips = CFGKEY.tips fromdisk = CFGKEY.fromdisk limits = CFGKEY.limits VARS_NUM = 0 for k in data.keys(): VARS_NUM += len(data[k]) lines = VARS_NUM + 5 # to account for header and footer y = lines*h if y > HEIGHT - 20: y = HEIGHT - 20 BGL.glColor3ub(COL_TXTHI[0],COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Configuration Editor') y -= 20 BGL.glColor3ub(COL_TXT[0],COL_TXT[1], COL_TXT[2]) txtsize = 10 if HEIGHT < lines*h: BGL.glRasterPos2i(10, 5) txtsize += Draw.Text('Arrow keys or mouse wheel to scroll, ') BGL.glRasterPos2i(txtsize, 5) Draw.Text('Q or ESC to return.') BGL.glRasterPos2i(x, y) Draw.Text('Key: "%s"' % CFGKEY.name) bh = 16 bw = 45 by = 16 i = -1 if CFGKEY.scriptname: i = 0 Draw.PushButton('help', BEVT_HELP, x, by, bw, bh, 'Show documentation for the script that owns this key (hotkey: H)') Draw.PushButton('back', BEVT_BACK, x + (1+i)*bw, by, bw, bh, 'Back to config keys selection screen (hotkey: ESC)') Draw.PushButton('exit', BEVT_EXIT, x + (2+i)*bw, by, bw, bh, 'Exit from Scripts Config Editor (hotkey: Q)') Draw.PushButton('revert', BEVT_CANCEL, x + (3+i)*bw, by, bw, bh, 'Revert data to original values (hotkey: U)') Draw.PushButton('apply', BEVT_APPLY, x + (4+i)*bw, by, bw, bh, 'Apply changes, if any (hotkey: ENTER)') delmsg = 'Delete this data key from memory' if fromdisk: delmsg = "%s and from disk" % delmsg Draw.PushButton('delete', BEVT_DEL, x + (5+i)*bw, by, bw, bh, '%s (hotkey: DELETE)' % delmsg) if fromdisk: Draw.Toggle("file", BEVT_DISK, x + 3 + (6+i)*bw, by, bw, bh, DISK_UPDATE, 'Update also the file where this config key is stored') i = -1 top = -1 y -= 20 yend = 30 if data.has_key(bool) and y > 0: lst = data[bool] for l in lst: top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break w = 20 tog = data[bool][i][1] if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click to toggle" BUT_TYPES[bool][i] = Draw.Toggle("", BEVT_BOOL + i, x, y, w, h, tog, tooltip) BGL.glRasterPos2i(x + w + 3, y + 5) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(int) and y > 0: lst = data[int] for l in lst: w = 70 top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break val = data[int][i][1] if limits: min, max = limits[l[0]] else: min, max = 0, 10 if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click / drag to change" BUT_TYPES[int][i] = Draw.Number("", BEVT_INT + i, x, y, w, h, val, min, max, tooltip) BGL.glRasterPos2i(x + w + 3, y + 3) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(float) and y > 0: lst = data[float] for l in lst: w = 70 top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break val = data[float][i][1] if limits: min, max = limits[l[0]] else: min, max = 0.0, 1.0 if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click and drag to change" BUT_TYPES[float][i] = Draw.Number("", BEVT_FLOAT + i, x, y, w, h, val, min, max, tooltip) BGL.glRasterPos2i(x + w + 3, y + 3) Draw.Text(l[0].lower().replace('_', ' ')) i = -1 y -= 5 if data.has_key(str) and y > 0: lst = data[str] for l in lst: top += 1 i += 1 if top < SCROLL_DOWN: continue y -= h if y < yend: break name = l[0].lower() is_dir = is_file = False if name.find('_dir', -4) > 0: is_dir = True elif name.find('_file', -5) > 0: is_file = True w = WIDTH - 20 wbrowse = 50 if is_dir and w > wbrowse: w -= wbrowse if tips and tips.has_key(l[0]): tooltip = tips[l[0]] else: tooltip = "click to write a new string" name = name.replace('_',' ') + ': ' if len(l[1]) > MAX_STR_LEN: l[1] = l[1][:MAX_STR_LEN] BUT_TYPES[str][i] = Draw.String(name, BEVT_STR + i, x, y, w, h, l[1], MAX_STR_LEN, tooltip) if is_dir: Draw.PushButton('browse', BEVT_BROWSEDIR + i, x+w+1, y, wbrowse, h, 'click to open a file selector (pick any file in the desired dir)') elif is_file: Draw.PushButton('browse', BEVT_BROWSEFILE + i, x + w + 1, y, 50, h, 'click to open a file selector')
def gui(): # drawing the screen global SCREEN, START_SCREEN, SCRIPT_SCREEN global SCRIPT_INFO, AllGroups, GROUP_MENUS global BEVT_EMAIL, BEVT_LINK global BEVT_VIEWSOURCE, BEVT_EXIT, BEVT_BACK, BEVT_GMENU, BUT_GMENU, BEVT_EXEC global PADDING, WIN_W, WIN_H, SCROLL_DOWN, COLUMNS, FMODE theme = Theme.Get()[0] tui = theme.get('ui') ttxt = theme.get('text') COL_BG = float_colors(ttxt.back) COL_TXT = ttxt.text COL_TXTHI = ttxt.text_hi BGL.glClearColor(COL_BG[0], COL_BG[1], COL_BG[2], COL_BG[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) resize = screen_was_resized() if resize: fit_on_screen() if SCREEN == START_SCREEN: x = PADDING bw = 85 bh = 25 hincr = 50 butcolumns = (WIN_W - 2 * x) / bw if butcolumns < 2: butcolumns = 2 elif butcolumns > 7: butcolumns = 7 len_gm = len(GROUP_MENUS) butlines = len_gm / butcolumns if len_gm % butcolumns: butlines += 1 h = hincr * butlines + 20 y = h + bh BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Help Browser') y -= bh BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) i = 0 j = 0 for group_menu in GROUP_MENUS: BGL.glRasterPos2i(x, y) Draw.Text(group_menu[0] + ':') BUT_GMENU[j] = Draw.Menu( group_menu[1], BEVT_GMENU[j], x, y - bh - 5, bw, bh, 0, 'Choose a script to read its help information') if i == butcolumns - 1: x = PADDING i = 0 y -= hincr else: i += 1 x += bw + 3 j += 1 x = PADDING y = 10 BGL.glRasterPos2i(x, y) Draw.Text('Select script for its help. Press Q or ESC to leave.') elif SCREEN == SCRIPT_SCREEN: if SCRIPT_INFO: if resize: SCRIPT_INFO.wrap_lines(1) SCROLL_DOWN = 0 h = 18 * SCRIPT_INFO.len_content + 12 * SCRIPT_INFO.spaces x = PADDING y = WIN_H bw = 38 bh = 16 BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) for line in SCRIPT_INFO.header: y -= 18 BGL.glRasterPos2i(x, y) size = Draw.Text(line) for line in text_wrap('Tooltip: %s' % SCRIPT_INFO.script.tip): y -= 18 BGL.glRasterPos2i(x, y) size = Draw.Text(line) i = 0 y -= 28 for data in SCRIPT_INFO.d['__url__']: Draw.PushButton('link %d' % (i + 1), BEVT_LINK[i], x + i * bw, y, bw, bh, data[0]) i += 1 y -= bh + 1 i = 0 for data in SCRIPT_INFO.d['__email__']: Draw.PushButton('email', BEVT_EMAIL[i], x + i * bw, y, bw, bh, data[0]) i += 1 y -= 18 y0 = y BGL.glColor3ub(COL_TXT[0], COL_TXT[1], COL_TXT[2]) for line in SCRIPT_INFO.content[SCROLL_DOWN:]: if line: line = line.replace('<br>', '') BGL.glRasterPos2i(x, y) Draw.Text(line) y -= 18 else: y -= 12 if y < PADDING + 20: # reached end, either stop or go to 2nd column if COLUMNS == 1: break elif x == PADDING: # make sure we're still in column 1 x = 6 * TEXT_WRAP + PADDING / 2 y = y0 x = PADDING Draw.PushButton( 'source', BEVT_VIEWSOURCE, x, 17, 45, bh, 'View this script\'s source code in the Text Editor (hotkey: S)' ) Draw.PushButton('exit', BEVT_EXIT, x + 45, 17, 45, bh, 'Exit from Scripts Help Browser (hotkey: Q)') if not FMODE: Draw.PushButton( 'back', BEVT_BACK, x + 2 * 45, 17, 45, bh, 'Back to scripts selection screen (hotkey: ESC)') Draw.PushButton('run script', BEVT_EXEC, x + 3 * 45, 17, 60, bh, 'Run this script') BGL.glColor3ub(COL_TXTHI[0], COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, 5) Draw.Text('use the arrow keys or the mouse wheel to scroll text', 'small')
def _draw(self): BGL.glClearColor(*self.bg_color) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) for el in self.element: el.draw()
def renderGUI(): """ Renders the GUI for the script. """ global G # find the selection set and update some selection # related flags haveEmpty = False haveCamera = False emptyName = "" G.selection = Object.GetSelected() G.curempty = None if G.selection is not None and len(G.selection) > 0: mso = G.selection[0] msotype = mso.getType() if msotype == 'Empty': haveEmpty = True G.curempty = mso emptyName = G.curempty.getName() elif msotype == 'Camera': haveCamera = True emptyHasCoords = G.coordmap.has_key(emptyName) removeUnknownsFromCoords() # clear any buttons that need to have set states G.buttons.add = G.buttons.delete = None # clear the window c = COLOR_BACKGROUND BGL.glClearColor(c[0], c[1], c[2], c[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) # paint the image in the background if G.image is not None: #drawImage(G.image, G.imgpos, G.iw, G.ih, G.zoom) Draw.Image(G.image, G.imgpos[0], G.imgpos[1], G.zoom, G.zoom) # paint 2D vertices in the image BGL.glPushAttrib(BGL.GL_POINT_BIT | BGL.GL_CURRENT_BIT) BGL.glPointSize(POINT_SIZE) x0 = int(G.imgpos[0] / G.zoom) y0 = int(G.imgpos[1] / G.zoom) def drawvc(ec): emptyname, coord = ec if Object.Get(emptyname) in G.selection: c = COLOR_VERTSEL else: c = COLOR_VERTUNSEL BGL.glColor4f(c[0], c[1], c[2], c[3]) BGL.glVertex2f(G.zoom * (coord[0] + x0), G.zoom * (coord[1] + y0)) BGL.glBegin(BGL.GL_POINTS) map(drawvc, G.coordmap.items()) BGL.glEnd() BGL.glPopAttrib() # if we're in add mode then draw some extra stuff if G.mode == MODE_ADD: xm, ym = map(int, getWMCoords()) xm -= 10 ym += 10 (xw, yw, ww, hw) = getWinRect() # draw crosshairs c = COLOR_CROSSHAIRS BGL.glColor4f(c[0], c[1], c[2], c[3]) verts = [(xm, 0), (xm, hw), (0, ym), (ww, ym)] BGL.glBegin(BGL.GL_LINES) map(lambda x: BGL.glVertex2d(x[0], x[1]), verts) BGL.glEnd() ############################################# # UNCOMMENT THIS SECTION FOR A COOL MINIMAP # EFFECT - NOT VERY USEFUL THOUGH # ## draw "minimap" background #c = COLOR_MINIMAP #BGL.glColor4f(c[0], c[1], c[2], c[3]) #verts = [ (119,10), (221,10), (221,111), (119,111) ] #BGL.glBegin(BGL.GL_QUADS) #map(lambda x: BGL.glVertex2i(x[0],x[1]), verts) #BGL.glEnd() # ## paint the image into the minimap #ix,iy = wc2ic((xm,ym)) #ix,iy = map(int, [ix, iy]) #drawImage(G.ibuf, (120,10), G.iw, G.ih, 10.0, (ix-5,iy-5,10,10)) # # END OF MINIMAP SECTION ############################################# # paint the current empty name if haveEmpty: c = COLOR_TEXT BGL.glColor4d(c[0], c[1], c[2], c[3]) BGL.glRasterPos2i(220, 10) Draw.Text(emptyName, 'small') # paint the normal GUI buttons G.buttons.quit = Draw.PushButton('Quit', BUTTON_QUIT, 5, 5, 100, 20, 'Exits the script.') G.buttons.load = Draw.PushButton('Load Image', BUTTON_LOAD, 5, 25, 100, 20, 'Loads an image.') G.buttons.zoom = Draw.Number('Zoom', BUTTON_ZOOM, 5, 45, 100, 20, G.zoom, ZOOM_MIN, ZOOM_MAX, 'Adjusts image zoom.') # paint camera-specific stuff if haveCamera: G.buttons.fullopt = Draw.Toggle('Full Optimization', BUTTON_FULLOPT, 110, 5, 120, 20, G.fullopt, 'Full or partial optimization.') G.buttons.coplanar = Draw.Toggle('Coplanar', BUTTON_COPLANAR, 110, 25, 120, 20, G.coplanar, 'Coplanar or non-coplanar target.') # Origin offset is not currently working in the Tsai module. # It should be brought back here when it is. #G.buttons.ofsz = Draw.Number('OfsZ', BUTTON_OFSZ, 110, 50, 100, 20, G.ofsz, OFS_MIN, OFS_MAX, 'Z origin offset.') #G.buttons.ofsy = Draw.Number('OfsY', BUTTON_OFSY, 110, 70, 100, 20, G.ofsy, OFS_MIN, OFS_MAX, 'Y origin offset.') #G.buttons.ofsx = Draw.Number('OfsX', BUTTON_OFSX, 110, 90, 100, 20, G.ofsx, OFS_MIN, OFS_MAX, 'X origin offset.') G.buttons.calibrate = Draw.PushButton( 'Calibrate', BUTTON_CALIBRATE, 235, 5, 100, 20, 'Calibrates the selected camera.') # paint empty-specific stuff elif haveEmpty and (G.mode == MODE_NORMAL): if emptyHasCoords: G.buttons.delete = Draw.PushButton( 'Delete', BUTTON_DELETE, 110, 5, 100, 20, 'Adds an image calibration coordinate.') else: G.buttons.add = Draw.PushButton( 'Add', BUTTON_ADD, 110, 5, 100, 20, 'Removes an image calibration coordinate.')
def gui(): # drawing the screen global SCREEN, START_SCREEN, SCRIPT_SCREEN global SCRIPT_INFO, AllGroups, GROUP_MENUS global BEVT_EMAIL, BEVT_LINK global BEVT_VIEWSOURCE, BEVT_EXIT, BEVT_BACK, BEVT_GMENU, BUT_GMENU, BEVT_EXEC global PADDING, WIN_W, WIN_H, SCROLL_DOWN, COLUMNS, FMODE theme = Theme.Get()[0] tui = theme.get('ui') ttxt = theme.get('text') COL_BG = float_colors(ttxt.back) COL_TXT = ttxt.text COL_TXTHI = ttxt.text_hi BGL.glClearColor(COL_BG[0],COL_BG[1],COL_BG[2],COL_BG[3]) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor3ub(COL_TXT[0],COL_TXT[1], COL_TXT[2]) resize = screen_was_resized() if resize: fit_on_screen() if SCREEN == START_SCREEN: x = PADDING bw = 85 bh = 25 hincr = 50 butcolumns = (WIN_W - 2*x)/ bw if butcolumns < 2: butcolumns = 2 elif butcolumns > 7: butcolumns = 7 len_gm = len(GROUP_MENUS) butlines = len_gm / butcolumns if len_gm % butcolumns: butlines += 1 h = hincr * butlines + 20 y = h + bh BGL.glColor3ub(COL_TXTHI[0],COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, y) Draw.Text('Scripts Help Browser') y -= bh BGL.glColor3ub(COL_TXT[0],COL_TXT[1], COL_TXT[2]) i = 0 j = 0 for group_menu in GROUP_MENUS: BGL.glRasterPos2i(x, y) Draw.Text(group_menu[0]+':') BUT_GMENU[j] = Draw.Menu(group_menu[1], BEVT_GMENU[j], x, y-bh-5, bw, bh, 0, 'Choose a script to read its help information') if i == butcolumns - 1: x = PADDING i = 0 y -= hincr else: i += 1 x += bw + 3 j += 1 x = PADDING y = 10 BGL.glRasterPos2i(x, y) Draw.Text('Select script for its help. Press Q or ESC to leave.') elif SCREEN == SCRIPT_SCREEN: if SCRIPT_INFO: if resize: SCRIPT_INFO.wrap_lines(1) SCROLL_DOWN = 0 h = 18 * SCRIPT_INFO.len_content + 12 * SCRIPT_INFO.spaces x = PADDING y = WIN_H bw = 38 bh = 16 BGL.glColor3ub(COL_TXTHI[0],COL_TXTHI[1], COL_TXTHI[2]) for line in SCRIPT_INFO.header: y -= 18 BGL.glRasterPos2i(x, y) size = Draw.Text(line) for line in text_wrap('Tooltip: %s' % SCRIPT_INFO.script.tip): y -= 18 BGL.glRasterPos2i(x, y) size = Draw.Text(line) i = 0 y -= 28 for data in SCRIPT_INFO.d['__url__']: Draw.PushButton('link %d' % (i + 1), BEVT_LINK[i], x + i*bw, y, bw, bh, data[0]) i += 1 y -= bh + 1 i = 0 for data in SCRIPT_INFO.d['__email__']: Draw.PushButton('email', BEVT_EMAIL[i], x + i*bw, y, bw, bh, data[0]) i += 1 y -= 18 y0 = y BGL.glColor3ub(COL_TXT[0],COL_TXT[1], COL_TXT[2]) for line in SCRIPT_INFO.content[SCROLL_DOWN:]: if line: line = line.replace('<br>', '') BGL.glRasterPos2i(x, y) Draw.Text(line) y -= 18 else: y -= 12 if y < PADDING + 20: # reached end, either stop or go to 2nd column if COLUMNS == 1: break elif x == PADDING: # make sure we're still in column 1 x = 6*TEXT_WRAP + PADDING / 2 y = y0 x = PADDING Draw.PushButton('source', BEVT_VIEWSOURCE, x, 17, 45, bh, 'View this script\'s source code in the Text Editor (hotkey: S)') Draw.PushButton('exit', BEVT_EXIT, x + 45, 17, 45, bh, 'Exit from Scripts Help Browser (hotkey: Q)') if not FMODE: Draw.PushButton('back', BEVT_BACK, x + 2*45, 17, 45, bh, 'Back to scripts selection screen (hotkey: ESC)') Draw.PushButton('run script', BEVT_EXEC, x + 3*45, 17, 60, bh, 'Run this script') BGL.glColor3ub(COL_TXTHI[0],COL_TXTHI[1], COL_TXTHI[2]) BGL.glRasterPos2i(x, 5) Draw.Text('use the arrow keys or the mouse wheel to scroll text', 'small')
def gui(): global buttons, offsets, rows, cols size = BGL.Buffer(BGL.GL_FLOAT, 4) BGL.glGetFloatv(BGL.GL_SCISSOR_BOX, size) size = size.list xoff = PANELPAD yoff = int(size[3]) # Default theme text = [0, 0, 0, 255] text_hi = [255, 255, 255, 255] header = [165, 165, 165, 255] panel = [255, 255, 255, 40] back = [180, 180, 180, 255] # Actual theme if Blender.Get('version') >= 235: theme = Blender.Window.Theme.Get() if theme: theme = theme[0] text = theme.get('ui').text space = theme.get('buts') text_hi = space.text_hi header = space.header header = [ max(header[0] - 30, 0), # 30 appears to be hard coded max(header[1] - 30, 0), max(header[2] - 30, 0), header[3] ] panel = space.panel back = space.back BGL.glEnable(BGL.GL_BLEND) BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA) BGL.glClearColor( float(back[0]) / 255, float(back[1]) / 255, float(back[2]) / 255, 1) BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) BGL.glColor4ub(*header) BGL.glRectd(xoff, yoff - PANELTOP, xoff - PANELINDENT + PANELWIDTH, yoff - PANELTOP - PANELHEAD) BGL.glColor4ub(*panel) BGL.glRectd(xoff, yoff - PANELTOP - PANELHEAD, xoff - PANELINDENT + PANELWIDTH, yoff - 60 - PANELINDENT - rows * CONTROLSIZE) BGL.glColor4ub(*text_hi) BGL.glRasterPos2d(xoff + PANELINDENT, yoff - 23) Draw.Text("Fixup UV mapping") BGL.glColor4ub(*text) BGL.glRasterPos2d(xoff + PANELINDENT, yoff - 48) Draw.Text("Select where the old image is located in the new:") buttons = [] for i in range(rows): for j in range(cols): buttons.append( Draw.Button('', len(buttons) + CANCEL + 1, xoff + PANELINDENT + j * CONTROLSIZE, yoff - 80 - i * CONTROLSIZE, CONTROLSIZE, CONTROLSIZE)) buttons.append( Draw.Button("Cancel", CANCEL, xoff - PANELINDENT * 2 + PANELWIDTH - 4 * CONTROLSIZE, yoff - 60 - rows * CONTROLSIZE, 4 * CONTROLSIZE, CONTROLSIZE))
def draw(): global EVENT_gui_exit global EVENT_gui_instruction global EVENT_gui_prepare global EVENT_gui_export global EVENT_gui_nexuizPath global EVENT_gui_fileName global EVENT_Text global EVENT_Text_0 global EVENT_gui_scale global EVENT_Text_1 global EVENT_gui_extrudeHeight global EVENT_Text_2 global EVENT_gui_extrudeDownwards global EVENT_Text_3 global EVENT_gui_echo global EVENT_Text_4 global EVENT_Text_5 global EVENT_Text_6 global EVENT_Text_7 global EVENT_Text_8 global EVENT_Text_9 global EVENT_Text_10 global EVENT_Text_11 global EVENT_Text_12 global EVENT_Text_13 global EVENT_Text_14 global EVENT_Text_15 global EVENT_gui_version global EVENT_Text_16 global EVENT_gui_exportSurf global EVENT_Text_17 global EVENT_gui_textureStri global EVENT_name_textureInd global EVENT_Text_18 global EVENT_gui_textureBtn global Object_gui_exit global Object_gui_instruction global Object_gui_prepare global Object_gui_export global Object_gui_nexuizPath global Object_gui_fileName global Object_Text global Object_Text_0 global Object_gui_scale global Object_Text_1 global Object_gui_extrudeHeight global Object_Text_2 global Object_gui_extrudeDownwards global Object_Text_3 global Object_gui_echo global Object_Text_4 global Object_Text_5 global Object_Text_6 global Object_Text_7 global Object_Text_8 global Object_Text_9 global Object_Text_10 global Object_Text_11 global Object_Text_12 global Object_Text_13 global Object_Text_14 global Object_Text_15 global Object_gui_version global Object_Text_16 global Object_gui_exportSurf global Object_Text_17 global Object_gui_textureStri global Object_name_textureInd global Object_Text_18 global Object_gui_textureBtn global nexify BGL.glClearColor(0.500000, 0.500000, 0.500000, 0.0) BGL.glClear(GL_COLOR_BUFFER_BIT) BGL.glColor3f(0.000000, 0.000000, 0.000000) Object_gui_exit = Draw.Button("Exit", EVENT_gui_exit, 8, 8, 76, 44, "Exit exporter") BGL.glRasterPos2i(64, 560) Object_gui_instruction = Draw.Text("Exporter to MAP format for Nexuiz community") Object_gui_prepare = Draw.Button("Prepare", EVENT_gui_prepare, 88, 8, 76, 44, "Prepares for export: checks is all meshes are convex") Object_gui_export = Draw.Button("Export", EVENT_gui_export, 168, 8, 76, 44, "Exports prepared scene to a MAP file") Object_gui_nexuizPath = Draw.String("", EVENT_gui_nexuizPath, 152, 320, 148, 20, Object_gui_nexuizPath.val, 399, "Nexuiz absolute path") Object_gui_fileName = Draw.String("", EVENT_gui_fileName, 152, 296, 148, 20, Object_gui_fileName.val, 399, "MAP file name") BGL.glRasterPos2i(16, 328) Object_Text = Draw.Text("Nexuiz absolute path") BGL.glRasterPos2i(16, 304) Object_Text_0 = Draw.Text("MAP file name") Object_gui_scale = Draw.Number("", EVENT_gui_scale, 152, 272, 76, 20, Object_gui_scale.val, 0.000000, 1024.000000, "") BGL.glRasterPos2i(16, 280) Object_Text_1 = Draw.Text("Scale factor") Object_gui_extrudeHeight = Draw.Number("", EVENT_gui_extrudeHeight, 152, 248, 76, 20, Object_gui_extrudeHeight.val, 0.000000, 1024.000000, "") BGL.glRasterPos2i(16, 256) Object_Text_2 = Draw.Text("Extrude height") Object_gui_extrudeDownwards = Draw.Toggle("downwards", EVENT_gui_extrudeDownwards, 152, 224, 76, 20, Object_gui_extrudeDownwards.val, "") BGL.glRasterPos2i(16, 232) Object_Text_3 = Draw.Text("Extrude downwards") Object_gui_echo = Draw.Toggle("echo", EVENT_gui_echo, 152, 200, 76, 20, Object_gui_echo.val, "") BGL.glRasterPos2i(16, 208) Object_Text_4 = Draw.Text("Console echo") BGL.glRasterPos2i(32, 536) Object_Text_5 = Draw.Text("Brief instruction:") BGL.glRasterPos2i(8, 504) Object_Text_6 = Draw.Text("Exporter currently work with meshes, lights and nurbs surfaces.") BGL.glRasterPos2i(368, 504) Object_Text_7 = Draw.Text("As far as meshes are converted into NetRadiant brushes they should be convex") BGL.glRasterPos2i(8, 480) Object_Text_8 = Draw.Text("Concave meshes are splitted into individual faces. Faces after that are extruded on \"Extrude height\" parameter (see below).") BGL.glRasterPos2i(8, 456) Object_Text_9 = Draw.Text("As far as objects in NetRadiant may have properties different then objects in Blender game logic properties are used to store such params.") BGL.glRasterPos2i(8, 432) Object_Text_10 = Draw.Text("Possible mesh params: ignore(BOOL), convex(BOOL)") BGL.glRasterPos2i(8, 408) Object_Text_11 = Draw.Text("Possible light params: sun(BOOL), has_target(BOOL), target_x, target_y, target_z(FLOAT), radius(float)") BGL.glRasterPos2i(8, 64) Object_Text_12 = Draw.Text("First press PREPARE, then press EXPORT.") BGL.glRasterPos2i(8, 384) Object_Text_13 = Draw.Text("Due to Blender doesn't understand Radiant shaders one may use texture[i](STRING) properties, to overwrite texture files with shaders(i = material index).") BGL.glRasterPos2i(8, 84) Object_Text_14 = Draw.Text("REMEMBER: textures are to be on \".../nexuiz/data/textures\" subpath!") BGL.glRasterPos2i(272, 24) Object_Text_15 = Draw.Text("Ver") BGL.glRasterPos2i(304, 24) Object_gui_version = Draw.Text( __version__ ) BGL.glRasterPos2i(16, 176) Object_Text_16 = Draw.Text("Focre selected surf") Object_gui_exportSurf = Draw.Button("Treat selected as surf when export", EVENT_gui_exportSurf, 152, 168, 212, 20, "") BGL.glRasterPos2i(16, 136) Object_Text_17 = Draw.Text("Overwrite texture") Object_gui_textureStri = Draw.String("", EVENT_gui_textureStri, 192, 132, 104, 20, Object_gui_textureStri.val, 399, "") Object_name_textureInd = Draw.Number("", EVENT_name_textureInd, 392, 132, 60, 20, Object_name_textureInd.val, 1.000000, 128.000000, "") BGL.glRasterPos2i(304, 140) Object_Text_18 = Draw.Text("material index") Object_gui_textureBtn = Draw.Button("over", EVENT_gui_textureBtn, 152, 132, 32, 20, "Overwrite selected object texture with the following.")