Commit | Line | Data |
---|---|---|
cb700bcc FC |
1 | # from logging import info |
2 | # from ya2.gameobject import GuiColleague | |
3 | # from ya2.engine.gui.cursor import MouseCursor | |
4 | # from ya2.engine.gui.browser import Browser | |
8ee66edd FC |
5 | |
6 | ||
cb700bcc FC |
7 | # up = (0, 1) |
8 | # down = (0, -1) | |
9 | # left = (-1, 0) | |
10 | # right = (1, 0) | |
8ee66edd FC |
11 | |
12 | ||
cb700bcc | 13 | # class EngineGuiBase(GuiColleague): # no win: EngineGui strictly manages win |
8ee66edd | 14 | |
cb700bcc FC |
15 | # @staticmethod |
16 | # def init_cls(): | |
17 | # return EngineGui if EngineGuiBase.eng.lib.has_window else EngineGuiBase | |
8ee66edd | 18 | |
cb700bcc FC |
19 | # @staticmethod |
20 | # def open_browser(url): Browser.open(url) | |
8ee66edd | 21 | |
cb700bcc FC |
22 | # @property |
23 | # def resolutions(self): | |
24 | # return sorted(list(set(self.eng.lib.resolutions))) | |
8ee66edd | 25 | |
cb700bcc FC |
26 | # @property |
27 | # def closest_resolution(self): | |
28 | # def distance(res): | |
29 | # curr_res = self.eng.lib.resolution | |
30 | # return abs(res[0] - curr_res[0]) + abs(res[1] - curr_res[1]) | |
8ee66edd | 31 | |
cb700bcc FC |
32 | # try: |
33 | # return min(self.resolutions, key=distance) | |
34 | # except ValueError: # sometimes we have empty resolutions | |
35 | # return self.eng.lib.resolution | |
8ee66edd | 36 | |
cb700bcc FC |
37 | # def set_resolution_check(self, res): |
38 | # res_msg = 'resolutions: {curr} (current), {res} (wanted)' | |
39 | # info(res_msg.format(curr=self.eng.lib.resolution, res=res)) | |
40 | # if self.eng.lib.resolution == res: return | |
41 | # retry = 'second attempt: {curr} (current) {res} (wanted)' | |
42 | # info(retry.format(curr=self.eng.lib.resolution, res=res)) | |
43 | # self.set_resolution(res, False) | |
8ee66edd | 44 | |
cb700bcc FC |
45 | # def toggle_fullscreen(self): |
46 | # self.set_resolution(self.closest_resolution) | |
47 | # self.eng.lib.toggle_fullscreen() | |
8ee66edd FC |
48 | |
49 | ||
cb700bcc | 50 | # class EngineGui(EngineGuiBase): |
8ee66edd | 51 | |
cb700bcc FC |
52 | # def __init__(self, mediator): |
53 | # EngineGuiBase.__init__(self, mediator) | |
54 | # cfg = self.eng.cfg | |
55 | # res_strings = cfg.gui_cfg.win_size.split() | |
56 | # res_ints = tuple(int(size) for size in res_strings) | |
57 | # self.set_resolution(res_ints, fullscreen=cfg.gui_cfg.fullscreen) | |
58 | # cur_cfg = cfg.cursor_cfg | |
59 | # self.cursor = MouseCursor( | |
60 | # cur_cfg.cursor_path, cur_cfg.cursor_scale, cur_cfg.cursor_color, | |
61 | # cur_cfg.cursor_hotspot) | |
8ee66edd | 62 | |
cb700bcc FC |
63 | # def set_resolution(self, res, check=True, fullscreen=None): |
64 | # info('setting resolution ' + str(res)) | |
65 | # self.eng.lib.set_resolution(res, fullscreen) | |
66 | # if check: self.eng.do_later(3.0, self.set_resolution_check, [res]) |