mirror of
https://github.com/lutris/lutris
synced 2024-09-15 13:59:50 +00:00
Game cover is now droppable (but does nothing yet)
This commit is contained in:
parent
07fb3274f9
commit
6fa79308dc
|
@ -57,11 +57,11 @@ parser.add_option("-v", "--verbose", action="store_true",
|
|||
dest="verbose", help="Verbose output")
|
||||
parser.add_option("-d", "--debug", action="store_true",
|
||||
dest="debug", help="Show debug messages")
|
||||
parser.add_option("-i", "--install", dest="installer_file",
|
||||
parser.add_option("-i", "--install", dest="installer_file",
|
||||
help="Install a game from a yml file")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
|
||||
|
||||
|
||||
# Set the logging level to show debug messages.
|
||||
if options.debug:
|
||||
|
@ -98,7 +98,7 @@ for arg in args:
|
|||
break
|
||||
if game is not None:
|
||||
if isinstance(game, str):
|
||||
file_path = os.path.join(GAME_CONFIG_PATH,
|
||||
file_path = os.path.join(GAME_CONFIG_PATH,
|
||||
game + CONFIG_EXTENSION)
|
||||
else:
|
||||
file_path = None
|
||||
|
@ -108,6 +108,7 @@ if game is not None:
|
|||
lutris_game = lutris.game.LutrisGame(game)
|
||||
lutris_game.play()
|
||||
else:
|
||||
log.logger.debug('File %s does not exist, installing game' % file_path)
|
||||
installer = Installer(game, installer)
|
||||
gtk.main()
|
||||
else:
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 955 B |
|
@ -288,14 +288,15 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="game_cover_image">
|
||||
<property name="width_request">250</property>
|
||||
<object class="GtkAlignment" id="cover_alignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
|
|
@ -44,7 +44,7 @@ from lutris.gui.googleimagedialog import GoogleImageDialog
|
|||
from lutris.gui.editgameconfigdialog import EditGameConfigDialog
|
||||
from lutris.gui.aboutdialog import NewAboutLutrisDialog
|
||||
from lutris.desktop_control import LutrisDesktopControl
|
||||
from lutris.gui.widgets import GameTreeView
|
||||
from lutris.gui.widgets import GameTreeView, GameCover
|
||||
import lutris.coverflow.coverflow
|
||||
|
||||
class LutrisWindow(gtk.Window):
|
||||
|
@ -63,7 +63,6 @@ class LutrisWindow(gtk.Window):
|
|||
# Widgets
|
||||
self.status_label = None
|
||||
self.menu = None
|
||||
self.game_cover_image = None
|
||||
self.toolbar = None
|
||||
|
||||
self.joystick_icons = []
|
||||
|
@ -88,52 +87,52 @@ class LutrisWindow(gtk.Window):
|
|||
else:
|
||||
LAUNCHPAD_AVAILABLE = False
|
||||
|
||||
# TODO: The game_cover_image will be moved inot it's own widget
|
||||
self.game_cover_image = self.builder.get_object("game_cover_image")
|
||||
self.game_cover_image.set_from_file(
|
||||
os.path.join(data_path, "media/background.png")
|
||||
)
|
||||
#Context menu
|
||||
game_rename = "Rename", self.edit_game_name
|
||||
game_config = "Configure", self.edit_game_configuration
|
||||
game_get_cover = "Get cover", self.get_cover
|
||||
menu_actions = [game_rename, game_config, game_get_cover]
|
||||
self.game_cover = GameCover()
|
||||
self.game_cover.show()
|
||||
cover_alignment = self.builder.get_object('cover_alignment')
|
||||
cover_alignment.add(self.game_cover)
|
||||
|
||||
#Contextual menu
|
||||
play = 'Play', self.game_launch
|
||||
rename = 'Rename', self.edit_game_name
|
||||
config = 'Configure', self.edit_game_configuration
|
||||
get_cover = 'Get cover', self.get_cover
|
||||
self.menu = gtk.Menu()
|
||||
for item in menu_actions:
|
||||
for item in [play, rename, config, get_cover]:
|
||||
if item == None:
|
||||
subitem = gtk.SeparatorMenuItem()
|
||||
else:
|
||||
subitem = gtk.ImageMenuItem(item[0])
|
||||
subitem.connect("activate", item[1])
|
||||
subitem.connect('activate', item[1])
|
||||
self.menu.append(subitem)
|
||||
self.menu.show_all()
|
||||
|
||||
#Status bar
|
||||
self.status_label = self.builder.get_object("status_label")
|
||||
self.status_label.set_text("Ready to roll !")
|
||||
self.status_label = self.builder.get_object('status_label')
|
||||
self.status_label.set_text('Insert coin')
|
||||
|
||||
for index in range(4):
|
||||
self.joystick_icons.append(
|
||||
self.builder.get_object("js" + str(index) + "image")
|
||||
self.builder.get_object('js' + str(index) + 'image')
|
||||
)
|
||||
self.joystick_icons[index].hide()
|
||||
|
||||
# Toolbar
|
||||
self.toolbar = self.builder.get_object("lutris_toolbar")
|
||||
self.toolbar = self.builder.get_object('lutris_toolbar')
|
||||
|
||||
# Game list
|
||||
self.game_list = get_list()
|
||||
self.game_treeview = GameTreeView(self.game_list)
|
||||
self.game_treeview.show()
|
||||
self.game_treeview.connect('row-activated', self.game_launch)
|
||||
self.game_treeview.connect("cursor-changed", self.select_game)
|
||||
self.game_treeview.connect("button-press-event", self.mouse_menu)
|
||||
self.game_treeview.connect('cursor-changed', self.select_game)
|
||||
self.game_treeview.connect('button-press-event', self.mouse_menu)
|
||||
|
||||
self.game_column = self.game_treeview.get_column(1)
|
||||
self.game_cell = self.game_column.get_cell_renderers()[0]
|
||||
self.game_cell.connect('edited', self.game_name_edited_callback)
|
||||
|
||||
self.game_list_scrolledwindow = self.builder.get_object("game_list_scrolledwindow")
|
||||
self.game_list_scrolledwindow = self.builder.get_object('game_list_scrolledwindow')
|
||||
self.game_list_scrolledwindow.add_with_viewport(self.game_treeview)
|
||||
|
||||
# Set buttons state
|
||||
|
@ -327,9 +326,13 @@ class LutrisWindow(gtk.Window):
|
|||
h = cover_pixbuf.get_height()
|
||||
w = cover_pixbuf.get_width()
|
||||
dest_h = h * (dest_w / w)
|
||||
self.game_cover_image.set_from_pixbuf(cover_pixbuf.scale_simple(int(dest_w), int(dest_h), gtk.gdk.INTERP_BILINEAR))
|
||||
self.game_cover.set_from_pixbuf(cover_pixbuf.scale_simple(
|
||||
int(dest_w),
|
||||
int(dest_h),
|
||||
gtk.gdk.INTERP_BILINEAR
|
||||
))
|
||||
return
|
||||
else:
|
||||
self.game_cover_image.set_from_file(
|
||||
self.game_cover.set_from_file(
|
||||
os.path.join(DATA_PATH, "media/background.png")
|
||||
)
|
||||
|
|
|
@ -58,7 +58,7 @@ class GameTreeView(gtk.TreeView):
|
|||
def add_row(self, game):
|
||||
model = self.get_model()
|
||||
s = "%s \n<small>%s</small>" % (game['name'], game['runner'])
|
||||
icon_path = os.path.join(lutris.constants.DATA_PATH,
|
||||
icon_path = os.path.join(lutris.constants.DATA_PATH,
|
||||
'media/runner_icons',
|
||||
game['runner'] + '.png')
|
||||
pix = gtk.gdk.pixbuf_new_from_file_at_size(icon_path,
|
||||
|
@ -74,6 +74,27 @@ class GameTreeView(gtk.TreeView):
|
|||
model = self.get_model()
|
||||
gtk.TreeModelSort(model)
|
||||
|
||||
class GameCover(gtk.Image):
|
||||
def __init__(self, parent=None):
|
||||
super(GameCover, self).__init__()
|
||||
self.set_from_file(os.path.join(
|
||||
lutris.constants.DATA_PATH, "media/background.png"
|
||||
))
|
||||
self.connect('drag_data_received', self.on_cover_drop)
|
||||
targets = [('text/plain',0 , 100)]
|
||||
self.drag_dest_set(gtk.DEST_DEFAULT_ALL, targets, gtk.gdk.ACTION_ASK)
|
||||
|
||||
def on_cover_drop(self, widget, context, x, y, selection, target, ts):
|
||||
# TODO : Change mouse cursor if no game is selected
|
||||
print selection.data
|
||||
file_path = selection.data
|
||||
if file_path.startswith('file://'):
|
||||
file_path = file_path[7:]
|
||||
else:
|
||||
# TODO : Handle http: (and smb:, stuff like that)
|
||||
return True
|
||||
print "matching %s" % file_path
|
||||
return True
|
||||
|
||||
class DownloadProgressBox(gtk.HBox):
|
||||
__gsignals__ = {'complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
|
|
Loading…
Reference in a new issue