Add option to launch games by clicking cover
This commit is contained in:
@@ -32,7 +32,6 @@ template game : Box {
|
||||
Box {
|
||||
Button button_play {
|
||||
halign: start;
|
||||
label: _("Play");
|
||||
margin-start: 6;
|
||||
margin-end: 6;
|
||||
margin-top: 6;
|
||||
|
||||
@@ -3,7 +3,7 @@ using Adw 1;
|
||||
|
||||
template PreferencesWindow : Adw.PreferencesWindow {
|
||||
search-enabled: false;
|
||||
default-height: 500;
|
||||
default-height: 550;
|
||||
|
||||
Adw.PreferencesPage page {
|
||||
Adw.PreferencesGroup general_group {
|
||||
@@ -16,6 +16,16 @@ template PreferencesWindow : Adw.PreferencesWindow {
|
||||
valign: center;
|
||||
}
|
||||
}
|
||||
|
||||
Adw.ActionRow {
|
||||
title: _("Cover Image Launches Game");
|
||||
subtitle: _("Swaps the behavior of the cover image and the play button");
|
||||
|
||||
Switch cover_launches_game_switch {
|
||||
valign: center;
|
||||
}
|
||||
}
|
||||
|
||||
Adw.ActionRow {
|
||||
title: _("High Quality Images");
|
||||
subtitle: _("Save game covers losslessly at the cost of storage");
|
||||
|
||||
@@ -4,6 +4,21 @@
|
||||
<key name="exit-after-launch" type="b">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key name="cover-launches-game" type="b">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key name="high-quality-images" type="b">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key name="steam-location" type="s">
|
||||
<default>"~/.steam/"</default>
|
||||
</key>
|
||||
<key name="steam-extra-dirs" type="as">
|
||||
<default>[]</default>
|
||||
</key>
|
||||
<key name="heroic-location" type="s">
|
||||
<default>"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/"</default>
|
||||
</key>
|
||||
<key name="heroic-import-epic" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
@@ -13,20 +28,8 @@
|
||||
<key name="heroic-import-sideload" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
<key name="steam-location" type="s">
|
||||
<default>"~/.steam/"</default>
|
||||
</key>
|
||||
<key name="steam-extra-dirs" type="as">
|
||||
<default>[]</default>
|
||||
</key>
|
||||
<key name="heroic-location" type="s">
|
||||
<default>"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/"</default>
|
||||
</key>
|
||||
<key name="bottles-location" type="s">
|
||||
<default>"~/.var/app/com.usebottles.bottles/data/bottles/"</default>
|
||||
</key>
|
||||
<key name="high-quality-images" type="b">
|
||||
<default>false</default>
|
||||
</key>
|
||||
</schema>
|
||||
<schema id="hu.kramo.Cartridge.State" path="/hu/kramo/Cartridges/State/">
|
||||
|
||||
32
src/game.py
32
src/game.py
@@ -66,10 +66,16 @@ class game(Gtk.Box): # pylint: disable=invalid-name
|
||||
self.add_controller(self.event_contoller_motion)
|
||||
self.overlay.set_measure_overlay(self.play_revealer, True)
|
||||
|
||||
self.button_play.connect("clicked", self.launch_game)
|
||||
self.set_play_label()
|
||||
|
||||
self.cover_button.connect("clicked", self.cover_button_clicked)
|
||||
self.button_play.connect("clicked", self.button_play_clicked)
|
||||
|
||||
self.event_contoller_motion.connect("enter", self.show_play)
|
||||
self.event_contoller_motion.connect("leave", self.hide_play)
|
||||
|
||||
self.parent_widget.schema.connect("changed", self.schema_changed)
|
||||
|
||||
if self.hidden:
|
||||
self.menu_button.set_menu_model(self.hidden_game_options)
|
||||
else:
|
||||
@@ -146,6 +152,28 @@ class game(Gtk.Box): # pylint: disable=invalid-name
|
||||
self.play_revealer.set_reveal_child(False)
|
||||
self.title_revealer.set_reveal_child(True)
|
||||
|
||||
def launch_game(self, _widget):
|
||||
def launch_game(self, _widget, *_unused):
|
||||
self.parent_widget.set_active_game(None, None, self.game_id)
|
||||
self.parent_widget.get_application().on_launch_game_action(None)
|
||||
|
||||
def cover_button_clicked(self, _widget):
|
||||
if self.parent_widget.schema.get_boolean("cover-launches-game"):
|
||||
self.launch_game(None)
|
||||
else:
|
||||
self.parent_widget.show_overview(None, self.game_id)
|
||||
|
||||
def button_play_clicked(self, _widget):
|
||||
if self.parent_widget.schema.get_boolean("cover-launches-game"):
|
||||
self.parent_widget.show_overview(None, self.game_id)
|
||||
else:
|
||||
self.launch_game(None)
|
||||
|
||||
def set_play_label(self):
|
||||
if self.parent_widget.schema.get_boolean("cover-launches-game"):
|
||||
self.button_play.set_label(_("Details"))
|
||||
else:
|
||||
self.button_play.set_label(_("Play"))
|
||||
|
||||
def schema_changed(self, _settings, key):
|
||||
if key == "cover-launches-game":
|
||||
self.set_play_label()
|
||||
|
||||
@@ -29,6 +29,8 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
page = Gtk.Template.Child()
|
||||
|
||||
exit_after_launch_switch = Gtk.Template.Child()
|
||||
cover_launches_game_switch = Gtk.Template.Child()
|
||||
high_quality_images_switch = Gtk.Template.Child()
|
||||
|
||||
steam_file_chooser_button = Gtk.Template.Child()
|
||||
steam_extra_file_chooser_button = Gtk.Template.Child()
|
||||
@@ -43,8 +45,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
bottles_group = Gtk.Template.Child()
|
||||
bottles_file_chooser_button = Gtk.Template.Child()
|
||||
|
||||
high_quality_images_switch = Gtk.Template.Child()
|
||||
|
||||
def __init__(self, parent_widget, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@@ -56,6 +56,18 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
"active",
|
||||
Gio.SettingsBindFlags.DEFAULT,
|
||||
)
|
||||
schema.bind(
|
||||
"cover-launches-game",
|
||||
self.cover_launches_game_switch,
|
||||
"active",
|
||||
Gio.SettingsBindFlags.DEFAULT,
|
||||
)
|
||||
schema.bind(
|
||||
"high-quality-images",
|
||||
self.high_quality_images_switch,
|
||||
"active",
|
||||
Gio.SettingsBindFlags.DEFAULT,
|
||||
)
|
||||
schema.bind(
|
||||
"heroic-import-epic",
|
||||
self.heroic_epic_switch,
|
||||
@@ -74,12 +86,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
"active",
|
||||
Gio.SettingsBindFlags.DEFAULT,
|
||||
)
|
||||
schema.bind(
|
||||
"high-quality-images",
|
||||
self.high_quality_images_switch,
|
||||
"active",
|
||||
Gio.SettingsBindFlags.DEFAULT,
|
||||
)
|
||||
|
||||
filechooser = Gtk.FileDialog()
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
||||
self.hidden_widgets[game_id] = entry
|
||||
self.hidden_library.append(entry)
|
||||
|
||||
entry.cover_button.connect("clicked", self.show_overview, game_id)
|
||||
entry.menu_button.get_popover().connect(
|
||||
"notify::visible", self.set_active_game, game_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user