本文整理汇总了Python中fsgs.platform.PlatformHandler类的典型用法代码示例。如果您正苦于以下问题:Python PlatformHandler类的具体用法?Python PlatformHandler怎么用?Python PlatformHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlatformHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_game_variant
def load_game_variant(self, variant_uuid):
# game_database = fsgs.get_game_database()
# values = game_database.get_game_values_for_uuid(variant_uuid)
from .Database import Database
database = Database.instance()
try:
database_name = database.find_game_database_for_game_variant(
variant_uuid)
except LookupError:
return False
values = self.game.set_from_variant_uuid(database_name, variant_uuid)
if not values:
return False
# print("")
# for key in sorted(values.keys()):
# print(" * {0} = {1}".format(key, values[key]))
# print("")
from fsgs.platform import PlatformHandler
platform_handler = PlatformHandler.create(self.game.platform.id)
loader = platform_handler.get_loader(self)
self.config.load(loader.load_values(values))
return True
示例2: get_item_text
def get_item_text(self, index):
item = self.items[index]
name = item[str("name")]
platform = item[str("platform")] or ""
if "[" in name:
name, extra = name.split("[", 1)
name = name.strip()
extra = " \u00b7 " + extra.strip(" ]")
else:
extra = ""
if fsui.toolkit == 'wx':
sep = "\n"
else:
sep = " \u00b7 "
name = name.replace("\n", " \u00b7 ")
if platform == "Amiga":
platform = ""
elif platform:
platform = sep + PlatformHandler.get_platform_name(platform)
# if not extra:
# sep = ""
# return "{0}{1}{2}{3}".format(name, sep, extra, "")
# else:
text = "{0}{1}{2}".format(name, extra, platform) or "Missing Name"
return text
示例3: create_context
def create_context(self):
item = self.items[0]
variant_uuid = item.configurations[0][0]
database_name = item.configurations[0][2]
print("\nitem:\n", item.configurations)
print("\nitem[0]:\n", item.configurations[0])
print("\n\nvariant_uuid =", variant_uuid, "\n\n")
# print("\n\ncreate_context")
# print("configurations: ", item.configurations)
# configs = sort_configurations(item.configurations)
# configs = item.configurations
# config = configs[0]
# self.context = GameContext.create_for_game(
# item.platform, item.name, config)
values = fsgs.game.set_from_variant_uuid(database_name, variant_uuid)
# print("")
# for key in sorted(values.keys()):
# print(" * {0} = {1}".format(key, values[key]))
# print("")
self.platform_handler = PlatformHandler.create(fsgs.game.platform.id)
loader = self.platform_handler.get_loader(fsgs)
fsgs.config.load(loader.load_values(values))
示例4: show
def show():
global current_menu
# fade_from is used on init_display, so we initialize this
# color here. Set alpha to 2.0 to force 1 second of solid
# color in combination with 2 sec. animation below
if False and windows and not Settings.fullscreen_menu:
State.get().fade_from = (1.0, 1.0, 1.0, 2.0)
State.get().fade_to = (1.0, 1.0, 1.0, 0.0)
else:
State.get().fade_from = (0.0, 0.0, 0.0, 2.0)
State.get().fade_to = (0.0, 0.0, 0.0, 0.0)
init_display()
if LIGHTING:
init_lighting()
init_textures()
init_fonts()
if USE_MENU_TRANSITIONS:
compile_programs()
InputHandler.open()
on_resize((Render.get().display_width, Render.get().display_height))
image_loader = ImageLoader.get()
image_loader.start()
new_menu = create_main_menu()
State.get().history.append(new_menu)
for platform_id in PlatformHandler.get_platform_ids():
if "--" + platform_id in sys.argv:
platform_menu = ItemMenu()
platform_menu.parent_menu = new_menu
platform_item = PlatformItem(platform_id)
platform_menu.items.append(platform_item)
# platform_menu.set_selected_index(0, immediate=True)
new_menu = platform_item.activate(platform_menu)
print(new_menu)
State.get().history.append(new_menu)
break
set_current_menu(new_menu)
if len(new_menu) == 1:
# only n/a item showing, possibly
if len(AllMenuItem().activate(None)) == 0:
# no games, initiate game scan
rescan_games()
State.get().fade_start = get_current_time()
State.get().fade_end = get_current_time() + 2.000
# # make a timer so that update events are sent to modules at least once
# # every second
# pygame.time.set_timer(IDLE_EVENT, 1000)
State.get().start_time = get_current_time()
示例5: start
def start(self):
assert self.thread is None
platform_handler = PlatformHandler.create(self.fsgs.game.platform.id)
self.runner = platform_handler.get_runner(self.fsgs)
device_helper = EnumerateHelper()
device_helper.default_port_selection(self.runner.ports)
self.thread = threading.Thread(target=self._thread)
self.thread.start()
示例6: render_bottom_bar_text
def render_bottom_bar_text(item):
strength = 0.9
x = 544
y = 290
title = item.title.upper()
if title:
Render.get().text(title, Font.title_font, x, y, 1920 - x - 170,
shadow=True, color=(1.0, 1.0, 1.0, 1.0 * strength))
year_text = str(getattr(State.get().current_menu.selected_item,
"year", "") or "").upper()
if year_text:
tw, th = Render.get().measure_text(year_text, Font.title_font)
Render.get().text(year_text, Font.title_font, 1920 - 30 - tw, y, 0,
shadow=True, color=(1.0, 1.0, 1.0, 1.0 * strength))
color = (0x6e / 0xff, 0x8b / 0xff, 0x96 / 0xff, 1.0)
y = 258
text_str = ""
companies = set()
publisher_text = (getattr(State.get().current_menu.selected_item,
"publisher", "") or "").upper()
for text in publisher_text.split("/"):
text = text.strip()
if text:
if text not in companies:
text_str = text_str + u" \u00b7 " + text
companies.add(text)
developer_text = (getattr(State.get().current_menu.selected_item,
"developer", "") or "").upper()
for text in developer_text.split("/"):
text = text.strip()
if text:
if text not in companies:
text_str = text_str + u" \u00b7 " + text
companies.add(text)
if len(text_str) > 3:
text_str = text_str[3:] # remove initial middle dot
Render.get().text(text_str, Font.subtitle_font, x, y, 0,
shadow=True, color=color)
platform_str = str(
getattr(State.get().current_menu.selected_item, "platform", "") or "")
if platform_str:
platform_str = PlatformHandler.get_platform_name(platform_str).upper()
if len(platform_str) >= 3:
tw, th = Render.get().measure_text(platform_str, Font.subtitle_font)
Render.get().text(platform_str, Font.subtitle_font, 1920 - 30 - tw, y,
0,
shadow=True, color=color)
return
示例7: run_game
def run_game(self):
from fsgs.platform import PlatformHandler
platform_handler = PlatformHandler.create(self.game.platform.id)
runner = platform_handler.get_runner(self)
from fsgs.input.enumeratehelper import EnumerateHelper
device_helper = EnumerateHelper()
device_helper.default_port_selection(runner.ports)
runner.prepare()
process = runner.run()
process.wait()
runner.finish()
示例8: load_values
def load_values(cls, values, uuid=""):
print("loading config values", values)
platform_id = values.get("platform", "").lower()
if platform_id in ["amiga", "cdtv", "cd32"]:
value_config_loader = ValueConfigLoader(uuid=uuid)
value_config_loader.load_values(values)
config = value_config_loader.get_config()
cls.load(config)
values["__config_name"] = config.get("__config_name")
else:
print("Warning: Non-Amiga game loaded")
platform_handler = PlatformHandler.create(platform_id)
loader = platform_handler.get_loader(fsgs)
fsgs.config.load(loader.load_values(values))
cls.post_load_values(values)
示例9: load_values
def load_values(cls, values, uuid=""):
print("loading config values", values)
platform_id = values.get("platform", "").lower()
if platform_id in ["amiga", "cdtv", "cd32"]:
value_config_loader = ValueConfigLoader(uuid=uuid)
value_config_loader.load_values(values)
config = value_config_loader.get_config()
cls.load(config)
config_name = config.get("__config_name", "")
else:
print("Warning: Non-Amiga game loaded")
platform_handler = PlatformHandler.create(platform_id)
loader = platform_handler.get_loader(fsgs)
fsgs.config.load(loader.load_values(values))
config_name = "{0} ({1})".format(
values.get("game_name"), values.get("platform_name"))
LauncherSettings.set("config_path", "")
# print("config is", config)
# config["x_config_uuid"] = uuid
if config_name:
config_name = cls.create_fs_name(config_name)
# else:
# config_name, ext = os.path.splitext(os.path.basename(path))
if "(" in config_name:
config_base = config_name.split("(")[0].strip()
else:
config_base = config_name
# game = name
# if not Config.get("title"):
# Config.set("title", config_base)
LauncherSettings.set("config_base", config_base)
LauncherSettings.set("config_name", config_name)
LauncherSettings.set("config_xml_path", "")
# Settings.set("config_changed", "0")
cls.set("__changed", "0")
示例10: render_bottom_bar_text
def render_bottom_bar_text(item):
strength = 0.9
x = 544
y = 290
title = item.title.upper()
title = title.strip()
if "[" in title:
title, subtitle = title.rsplit("[", 1)
title = title.strip()
subtitle = subtitle.strip()
if subtitle.endswith("]"):
subtitle = subtitle[:-1]
else:
subtitle = ""
if title:
Render.get().text(
title,
Font.title_font,
x,
y,
1920 - x - 170,
shadow=True,
color=(1.0, 1.0, 1.0, 1.0 * strength),
)
if subtitle:
color = (0x6E / 0xFF, 0x8B / 0xFF, 0x96 / 0xFF, 0.75)
tw, th = Render.get().measure_text(title, Font.title_font)
Render.get().text(
subtitle,
Font.title_font,
x + tw + 20,
y,
1920 - x - 170,
shadow=True,
color=color,
)
color = (0xC4 / 0xFF, 0xD7 / 0xFF, 0xDE / 0xFF, 1.0)
year_text = str(
getattr(State.get().current_menu.selected_item, "year", "") or ""
).upper()
if year_text:
tw, th = Render.get().measure_text(year_text, Font.title_font)
Render.get().text(
year_text,
Font.title_font,
1920 - 30 - tw,
y,
0,
shadow=True,
color=color,
)
color = (0x6E / 0xFF, 0x8B / 0xFF, 0x96 / 0xFF, 1.0)
y = 258
text_str = ""
companies = set()
publisher_text = (
getattr(State.get().current_menu.selected_item, "publisher", "") or ""
).upper()
for text in publisher_text.split("/"):
text = text.strip()
if text:
if text not in companies:
text_str = text_str + u" \u00b7 " + text
companies.add(text)
developer_text = (
getattr(State.get().current_menu.selected_item, "developer", "") or ""
).upper()
for text in developer_text.split("/"):
text = text.strip()
if text:
if text not in companies:
text_str = text_str + u" \u00b7 " + text
companies.add(text)
if len(text_str) > 3:
text_str = text_str[3:] # remove initial middle dot
tw, th = Render.get().measure_text(text_str, Font.subtitle_font)
Render.get().text(
text_str,
Font.subtitle_font,
1920 - 30 - tw,
y,
0,
shadow=True,
color=color,
)
platform_str = str(
getattr(State.get().current_menu.selected_item, "platform", "") or ""
)
if platform_str:
platform_str = PlatformHandler.get_platform_name(platform_str).upper()
if len(platform_str) >= 3:
# tw, th = Render.get().measure_text(platform_str, Font.subtitle_font)
Render.get().text(
platform_str, Font.subtitle_font, x, y, 0, shadow=True, color=color
)
return
示例11: __init__
def __init__(self):
PlatformHandler.__init__(self)
示例12: name
def name(self):
from .platform import PlatformHandler
return PlatformHandler.get_platform_name(self._id)
示例13: __init__
#.........这里部分代码省略.........
# "Atari 5"),
# "bbc-micro": (
# "BBC Micro",
# "Acorn BCC Micro",
# ""),
# "commodore-64": (
# "Commodore 64",
# "",
# "Commodore 1"),
# "game-boy": (
# "Game Boy",
# "",
# "Nintendo 2"),
# "game-boy-color": (
# "Game Boy Color",
# "",
# "Nintendo 5"),
# "game-boy-advance": (
# "Game Boy Advance",
# "",
# "Nintendo 6"),
# "game-cube": (
# "GameCube",
# "Nintendo GameCube",
# "Nintendo 7"),
# "game-gear": (
# "Game Gear",
# "Sega Game Gear",
# "Sega 3"),
# "lynx": (
# "Atari Lynx",
# "",
# "Atari 6"),
# "nintendo": (
# "Nintendo",
# "",
# "Nintendo 1"),
# "nintendo-64": (
# "Nintendo 64",
# "",
# "Nintendo 4"),
# "DOS": (
# "DOS",
# "IBM PC Compatible",
# "PC 1"),
# "master-system": (
# "Master System",
# "Sega Master System / Mark III",
# "Sega 1"),
# "mega-drive": (
# "Mega Drive",
# "Sega Mega Drive / Genesis",
# "Sega 2"),
# "playstation": (
# "PlayStation",
# "Sony PlayStation",
# ""),
# "playstation-2": (
# "PlayStation 2",
# "Sony PlayStation 2",
# ""),
# "super-nintendo": (
# "Super Nintendo",
# "Entertainment System",
# "Nintendo 3"),
# "turbografx-16": (
# "TurboGrafx-16",
# "Entertainment SuperSystem",
# ""),
# "wii": (
# "Wii",
# "Nintendo Wii",
# "Nintendo 8"),
# "windows": (
# "Windows",
# "IBM PC Compatible",
# "PC 2"),
# "zx-spectrum": (
# "ZX Spectrum",
# "Sinclair ZX Spectrum",
# ""),
# }[platform]
# except KeyError:
# self.title = platform
self.platform = platform
self.path_title = platform
self.title = PlatformHandler.get_platform_name(platform)
self.path_title = self.title
# self.title = ""
# self.title = "CHOOSE PLATFORM: " + self.title
# self.subtitle = ""
self.subtitle = "CHOOSE PLATFORM"
# if not self.sort_title:
# self.sort_title = self.title
# FIXME: for now, test using just title as sort title
self.sort_title = self.title