ya2 · news · projects · code · about

housekeeping: ya2.utils.gui
[pmachines.git] / ya2 / utils / gui / gui.py
1 from panda3d.core import load_prc_file_data, Texture, TextProperties, TextPropertiesManager
2 from ya2.utils.gfx import Point
3
4 class GuiTools:
5
6 @staticmethod
7 def init():
8 GuiTools.__create_text_properties_scale()
9
10 def __create_text_properties_scale():
11 (t := TextProperties()).set_text_scale(.64)
12 TextPropertiesManager.get_global_ptr().set_properties('scale', t)
13
14 @staticmethod
15 def no_window():
16 load_prc_file_data('', 'window-type none')
17
18 @staticmethod
19 def get_mouse():
20 return Point(base.mouseWatcherNode.get_mouse())
21
22 @staticmethod
23 def load_font(path):
24 font = base.loader.load_font(path)
25 font.clear()
26 font.set_pixels_per_unit(60)
27 font.set_minfilter(Texture.FTLinearMipmapLinear)
28 font.set_outline((0, 0, 0, 1), .8, .2)
29 return font