def __init__(self, filename): vfs = VirtualFileSystem.getGlobalPtr() self.material = BSPMaterial.getFromFile(filename) self.filename = filename if self.material.hasKeyvalue("$basetexture"): baseTexturePath = Filename( self.material.getKeyvalue("$basetexture")) if vfs.resolveFilename(baseTexturePath, getModelPath().getValue()): imageData = bytes(VirtualFileSystem.getGlobalPtr().readFile( baseTexturePath, True)) byteArray = QtCore.QByteArray.fromRawData(imageData) image = QtGui.QImage.fromData(byteArray) self.pixmap = QtGui.QPixmap.fromImage(image) self.icon = QtGui.QIcon(self.pixmap) self.size = LVector2i(image.width(), image.height()) else: self.texture = None self.size = LVector2i(64, 64) self.icon = None self.pixmap = None else: self.texture = None self.size = LVector2i(64, 64) self.icon = None self.pixmap = None
def __init__(self, filename): vfs = VirtualFileSystem.getGlobalPtr() #self.material = BSPMaterial.getFromFile(filename) self.material = TexturePool.loadTexture(filename) self.filename = filename if self.material: #.hasKeyvalue("$basetexture"): # baseTexturePath = self.material.getKeyvalue("$basetexture") if True: #vfs.exists(baseTexturePath): #imageData = bytes(VirtualFileSystem.getGlobalPtr().readFile(baseTexturePath, True)) pimage = PNMImage() self.material.store(pimage, 0, 0) ss = StringStream() pimage.write(ss, "tmp.png") imageData = bytes(ss) byteArray = QtCore.QByteArray.fromRawData(imageData) image = QtGui.QImage.fromData(byteArray) self.pixmap = QtGui.QPixmap.fromImage(image) self.icon = QtGui.QIcon(self.pixmap) self.size = LVector2i(pimage.getXSize(), pimage.getYSize()) print(pimage, self.size) else: self.size = LVector2i(64, 64) self.icon = None self.pixmap = None else: self.size = LVector2i(64, 64) self.icon = None self.pixmap = None
def getStippleShader(): global StippleShader if not StippleShader: shattr = ShaderAttrib.make(Shader.load(Shader.SLGLSL, "shaders/editor/lineStipple.vert.glsl", "shaders/editor/lineStipple.frag.glsl")) shattr = shattr.setShaderInput("stippleParams", LVector2i(0xAAAA, 10)) StippleShader = shattr return StippleShader
def clone(self): mat = FaceMaterial() mat.material = self.material mat.scale = Vec2(self.scale) mat.shift = LVector2i(self.shift) mat.uAxis = Vec3(self.uAxis) mat.vAxis = Vec3(self.vAxis) mat.rotation = float(self.rotation) return mat
def __init__(self): self.material = None self.tangent = Vec3(1, 0, 0) self.binormal = Vec3(0, 0, 1) self.scale = Vec2(1, 1) self.shift = LVector2i(0, 0) self.uAxis = Vec3(0) self.vAxis = Vec3(0) self.rotation = 0.0
def __init__(self): self.material = None self.tangent = Vec3(1, 0, 0) self.binormal = Vec3(0, 0, 1) self.scale = Vec2(LEConfig.default_texture_scale.getValue()) self.shift = LVector2i(0, 0) self.uAxis = Vec3(0) self.vAxis = Vec3(0) self.rotation = 0.0 self.lightmapScale = LEConfig.default_lightmap_scale.getValue()
def resizeEvent(self, event): if not self.win: return newsize = LVector2i(event.size().width(), event.size().height()) self.qtWidget.resize(newsize[0], newsize[1]) self.qtWidget.move(0, 0) #props = WindowProperties() #props.setSize(newsize) #props.setOrigin(0, 0) #self.win.requestProperties(props) self.fixRatio(newsize) self.updateView()
def on_size(self, *args): self.fbo.size = self.size self.viewport.size = self.size props = WindowProperties() props.setSize(LVector2i(*self.size)) self.msb.win.requestProperties(props)
def build(self): menu_args = self.menu_args widgets = [self.__add_lab('Language', _('Language'), .85)] langs = [lan[0] for lan in self.eng.languages] self.lang_opt = OptionMenu(text='', items=langs, pos=(.29, 1, .85), initialitem=self.props.lang, command=self.__change_lang, **menu_args.option_args) widgets += [self.__add_lab('Volume', _('Volume'), .65)] self.vol_slider = Slider( pos=(.32, 0, .68), scale=.49, value=self.props.volume, frameColor=menu_args.btn_color, thumb_frameColor=menu_args.text_active, command=lambda: self.eng.set_volume(self.vol_slider['value'])) widgets += [self.__add_lab('Fullscreen', _('Fullscreen'), .45)] self.fullscreen_cb = CheckBtn( pos=(-.08, 1, .47), text='', indicatorValue=self.props.fullscreen, indicator_frameColor=menu_args.text_active, command=lambda val: self.eng.toggle_fullscreen(), **menu_args.checkbtn_args) widgets += [self.__add_lab('Resolution', _('Resolution'), .25)] res2vec = lambda res: LVector2i(*[int(val) for val in res.split('x')]) self.res_opt = OptionMenu( text='', items=[ 'x'.join([str(el_res) for el_res in res]) for res in self.eng.resolutions ], pos=(.29, 1, .25), initialitem='x'.join( str(res) for res in self.eng.closest_resolution), command=lambda res: self.eng.set_resolution(res2vec(res)), **menu_args.option_args) widgets += [self.__add_lab('Antialiasing', _('Antialiasing'), .05)] widgets += [ self.__add_lab('(from the next execution)', _('(from the next execution)'), .05, 0, TextNode.ALeft, .06) ] self.aa_cb = CheckBtn(pos=(-.08, 1, .08), text='', indicatorValue=self.props.antialiasing, indicator_frameColor=menu_args.text_active, **menu_args.checkbtn_args) widgets += [self.__add_lab('Shaders', _('Shaders'), -.15)] self.shaders_cb = CheckBtn(pos=(-.08, 1, -.12), text='', indicatorValue=self.props.shaders, indicator_frameColor=menu_args.text_active, **menu_args.checkbtn_args) widgets += [self.__add_lab('Cars number', _('Cars number'), -.35)] widgets += [self.__add_lab('Camera', _('Camera'), -.55)] self.cars_opt = OptionMenu(text='', items=[str(i) for i in range(1, 9)], pos=(.29, 1, -.35), initialitem=self.props.cars_num - 1, **menu_args.option_args) self.cameras = [_('Top'), _('Rear')] self.camera_codes = ['top', 'rear'] self.cam_opt = OptionMenu( text='', items=self.cameras, pos=(.29, 1, -.55), initialitem=self.cameras[self.camera_codes.index( self.props.camera)], **menu_args.option_args) input_btn = Btn(text='', pos=(-.2, 1, -.75), command=self.on_input_btn, tra_src='Configure input', tra_tra=_('Configure input'), **menu_args.btn_args) widgets += [ self.lang_opt, self.vol_slider, self.fullscreen_cb, self.res_opt, self.aa_cb, input_btn, self.shaders_cb, self.cars_opt, self.cam_opt ] self.add_widgets(widgets) idx = self.eng.lang_mgr.lang_codes.index(self.props.lang) self.__change_lang(self.eng.languages[idx][0]) ThanksPageGui.build(self)
def fullscreen(self, value: bool) -> None: props = WindowProperties() props.fullscreen = value props.size = LVector2i(self.pipe.getDisplayWidth(), self.pipe.getDisplayHeight()) self.win.request_properties(props)
def size(self, value: Size) -> None: props = WindowProperties() props.size = LVector2i(*value) self.win.request_properties(props)
def bld_page(self): menu_args = self.menu_args self.pagewidgets = [] def add_lab(txt, txt_tr, pos_z): lab = DirectLabel(text='', pos=(-.1, 1, pos_z), text_align=TextNode.ARight, **menu_args.label_args) PageGui.transl_text(lab, txt, txt_tr) self.pagewidgets += [lab] return lab add_lab('Language', _('Language'), .7) self._lang_opt = DirectOptionMenu(text='', items=eng.languages, pos=(.49, 1, .7), initialitem=self.props.lang, command=self.__change_lang, **menu_args.option_args) add_lab('Volume', _('Volume'), .5) self._vol_slider = DirectSlider(pos=(.52, 0, .53), scale=.49, value=self.props.volume, frameColor=menu_args.btn_color, thumb_frameColor=menu_args.text_fg, command=self.__on_volume) add_lab('Fullscreen', _('Fullscreen'), .3) self._fullscreen_cb = DirectCheckButton( pos=(.12, 1, .32), text='', indicatorValue=self.props.fullscreen, indicator_frameColor=menu_args.text_fg, command=lambda val: eng.toggle_fullscreen(), **menu_args.checkbtn_args) add_lab('Resolution', _('Resolution'), .1) res2vec = lambda res: LVector2i(*[int(val) for val in res.split('x')]) self._res_opt = DirectOptionMenu( text='', items=[ 'x'.join([str(el_res) for el_res in res]) for res in eng.resolutions ], pos=(.49, 1, .1), initialitem='x'.join(str(res) for res in eng.closest_res), command=lambda res: eng.set_resolution(res2vec(res)), **menu_args.option_args) add_lab('Antialiasing', _('Antialiasing'), -.1) aa_next_lab = DirectLabel(text='', pos=(.2, 1, -.1), text_align=TextNode.ALeft, **menu_args.label_args) PageGui.transl_text(aa_next_lab, '(from the next execution)', _('(from the next execution)')) self._aa_cb = DirectCheckButton(pos=(.12, 1, -.07), text='', indicatorValue=self.props.aa, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) add_lab('Shaders', _('Shaders'), -.3) self._shaders_cb = DirectCheckButton( pos=(.12, 1, -.27), text='', indicatorValue=self.props.shaders, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) # bld_in = lambda: self.menu.logic.push_page( # InputPage(self.menu, self.props.joystick, self.props.keys)) # it doesn't work if we go forward and back between options and input: # we should update keys input_btn = DirectButton(text='', pos=(0, 1, -.5), command=self.on_input_btn, **menu_args.btn_args) PageGui.transl_text(input_btn, 'Configure input', _('Configure input')) self.pagewidgets += [ self._lang_opt, self._vol_slider, self._fullscreen_cb, self._res_opt, self._aa_cb, aa_next_lab, input_btn, self._shaders_cb ] map(self.add_widget, self.pagewidgets) idx = LangMgr().lang_codes.index(self.props.lang) self.__change_lang(eng.languages[idx]) ThanksPageGui.bld_page(self)