本文整理汇总了Python中mamewah_ini.MameWahIni类的典型用法代码示例。如果您正苦于以下问题:Python MameWahIni类的具体用法?Python MameWahIni怎么用?Python MameWahIni使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MameWahIni类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, glade_filename, window_name, WinSetup):
"""build the dialog"""
GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
self.dlgAddEmu.set_transient_for(WinSetup.winSetup)
self.dlgAddEmu.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
#winsetup class
self.WinSetup = WinSetup
#create new emulator list
self.tvw, self.ls, self.tvws = self.setup_treeview(
columns = [_('Select an Emulator Template...')],
column_types = [gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING],
container = self.scw,
resizeable_cols = False)
#get list of available templates
emu_ini_files = glob.glob(os.path.join(APP_PATH, 'templates', '*.ini'))
for emu_ini in emu_ini_files:
ini = MameWahIni(emu_ini)
if not ini.has_option('list_title'):
basename = os.path.splitext(os.path.basename(emu_ini))[0]
self.ls.append(
('%s (%s)' % (ini.get('emulator_title'), basename),
basename,
emu_ini))
#set dialog size
num = len(self.ls)
if num > 10:
num = 10
self.dlgAddEmu.set_size_request(320, 120 + (num * 15))
#sort
self.ls.set_sort_column_id(0, gtk.SORT_ASCENDING)
示例2: __init__
def __init__(self, WinMain):
"""setup cp viewer window"""
#set main window
self.WinMain = WinMain
self.layout_filename = ''
self.cpviewer_ok = True
#open cpviewer viewer ini
self.cpviewer_ini = MameWahIni(os.path.join(CONFIG_DIR, 'cpviewer.ini'), 'default')
if os.path.exists(os.path.join(CONFIG_DIR, 'ini', self.WinMain.current_emu + '.cpv')):
self.cpviewer_ini = MameWahIni(os.path.join(CONFIG_DIR, 'ini', self.WinMain.current_emu + '.cpv'), 'default')
self.ctrls_ini_filename = self.cpviewer_ini.get('controls_ini_file')
if not os.path.isfile(self.ctrls_ini_filename):
self.WinMain.log_msg("Warning: controls file: [%s] does not exist" % (self.ctrls_ini_filename))
self.cpviewer_ok = False
self.layout_filename = self.cpviewer_ini.get('viewer_layout')
if not os.path.exists(self.layout_filename):
self.WinMain.log_msg("Warning: CPViewer layout file: [%s] does not exist" % (self.layout_filename))
self.cpviewer_ok = False
#build gui
self.winCPViewer = gtk.Fixed()
self.winCPViewer.set_has_window(True)
self.imgBackground = gtk.Image()
self.winCPViewer.add(self.imgBackground)
self.WinMain.fixd.add(self.winCPViewer)
self.imgBackground.show()
self.winCPViewer.show()
self.ctrls_ini = self.get_controls_ini(self.ctrls_ini_filename)
if self.ctrls_ini is None:
self.cpviewer_ok = False
self.app_number = 0
示例3: __init__
def __init__(self, glade_filename, window_name, emu_name, emu_list_idx):
"""build the window"""
WahCade.__init__(self)
GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
self.config_dir = CONFIG_DIR
self.emu_name = emu_name
self.emu_list_idx = emu_list_idx
#games list
self.tvwList, self.lsList, self.tvwsList = self.setup_treeview(
columns = [
'Game Name',
'ROM Name',
'Year',
'Manufacturer',
'Clone Of',
'Rom Of',
'Display Type',
'Screen Type',
'Controller Type',
'Driver Status',
'Colour Status',
'Sound Status',
'Category'],
column_types = [gobject.TYPE_STRING] * self.NUM_COLS,
container = self.scwList,
edit_cell_cb = self.on_tvwList_edited,
resizeable_cols = True,
highlight_rows = False)
#self.tvwList.connect('row-activated', self.on_tvwList_activated)
self.tvwList.connect('key-release-event', self.on_tvwList_key_event)
#activate multiple selection mode on tvwsList
self.tvwsList.set_mode(gtk.SELECTION_MULTIPLE)
#load lists
i = 0
emu_game_lists = []
while True:
ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, i))
if os.path.isfile(ini_file):
list_ini = MameWahIni(ini_file)
emu_game_lists.append(list_ini.get('list_title'))
i += 1
else:
break
l = ['%s: %s' % (i, r) for i, r in enumerate(emu_game_lists)]
self.setup_combo_box(self.cboList, l)
#setup filters & emu ini
emu_ini_filename = os.path.join(self.config_dir, 'ini', '%s.ini' % (self.emu_name))
if os.path.isfile(emu_ini_filename):
self.emu_ini = MameWahIni(emu_ini_filename)
#filters._mameinfo_file = os.path.join(self.emu_ini.get('dat_file'))
filters._catver_ini = os.path.join(self.emu_ini.get('catver_ini_file'))
else:
print _("Error: Emulator Ini file: [%s] doesn't exist" % (emu_ini_filename))
#load filter
self.new_iter = None
self.new_path = None
self.new_col = 0
self.list_altered = False
self.cboList.set_active(self.emu_list_idx)
示例4: buildemulist
def buildemulist(self):
emu_lists = []
emu_ini_files = self.build_filelist("", "ini", "(.*(?<!=-))")
for emu_ini in emu_ini_files:
ini = MameWahIni(emu_ini)
if not ini.has_option('list_title'):
emu_lists.append(
[ini.get('emulator_title'),
os.path.splitext(os.path.basename(emu_ini))[0],ini])
return emu_lists
示例5: load_emulator_settings
def load_emulator_settings(self, ini_name, emu_ini, default_list=0):
"""load emu settings"""
self.txeEmuTitle.set_text(emu_ini.get('emulator_title'))
self.txeEmuExe.set_text(emu_ini.get('emulator_executable'))
self.txeEmuCmdLine.set_text(emu_ini.get('commandline_format'))
self.txeEmuAltCmdLine1.set_text(emu_ini.get('alt_commandline_format_1'))
self.txeEmuAltCmdLine2.set_text(emu_ini.get('alt_commandline_format_2'))
self.txeEmuRomExt.set_text(emu_ini.get('rom_extension'))
self.txeEmuRomDir.set_text(emu_ini.get('rom_path'))
self.txeEmuNMSFile.set_text(emu_ini.get('nms_file'))
#list gen type
ini_lgen = emu_ini.get('list_generation_method')
lgen_idx = [idx for idx, r in enumerate(self.emu_list_gen_types) if ini_lgen in r[0]][0]
self.cboEmuListGen.set_active(lgen_idx)
#artwork
for idx, emu_art in enumerate(self.emu_artwork_txe):
emu_art.set_text(emu_ini.get('artwork_%s_image_path' % (idx + 1)))
self.txeEmuMovieDir.set_text(emu_ini.get('movie_preview_path'))
self.spnEmuMovieNum.set_value(emu_ini.getint('movie_artwork_no'))
self.cboeEmuExtApp1.child.set_text(emu_ini.get('app_1_executable'))
self.txeEmuExtApp1.set_text(emu_ini.get('app_1_commandline_format'))
self.cboeEmuExtApp2.child.set_text(emu_ini.get('app_2_executable'))
self.txeEmuExtApp2.set_text(emu_ini.get('app_2_commandline_format'))
self.cboeEmuExtApp3.child.set_text(emu_ini.get('app_3_executable'))
self.txeEmuExtApp3.set_text(emu_ini.get('app_3_commandline_format'))
self.txeEmuExtAuto.set_text(emu_ini.get('auto_launch_apps'))
#screen saver
ini_scr = emu_ini.get('saver_type')
scr_idx = [idx for idx, r in enumerate(self.emu_scrsave_types) if r[0] == ini_scr][0]
self.cboEmuScrSaver.set_active(scr_idx)
self.txeEmuScrMovieDir.set_text(emu_ini.get('movie_path'))
self.txeEmuScrExternal.set_text(emu_ini.get('scr_file'))
#load lists
i = 0
self.emu_game_lists = []
while True:
ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (ini_name, i))
if os.path.isfile(ini_file):
list_ini = MameWahIni(ini_file)
self.emu_game_lists.append([list_ini.get('list_title'), list_ini])
i += 1
else:
break
l = ['%s: %s' % (i, r[0]) for i, r in enumerate(self.emu_game_lists)]
self.setup_combo_box(self.cboEmuLists, l)
self.cboEmuLists.set_active(default_list)
#mame only
if ini_name in MAME_INI_FILES:
self.vboxMame.set_sensitive(True)
self.txeMameXMLFile.set_text(emu_ini.get('dat_file'))
self.txeMameCatver.set_text(emu_ini.get('catver_ini_file'))
else:
self.vboxMame.set_sensitive(False)
self.txeMameXMLFile.set_text('')
self.txeMameCatver.set_text('')
示例6: load_settings
def load_settings(self, default_emu=None):
"""load wahcade settings"""
#build list of emulators
self.emu_lists = []
self.emu_game_lists = []
self.current_emu = None
self.current_emu_list = None
emu_ini_files = glob.glob(os.path.join(self.config_dir, 'ini', '*.ini'))
for emu_ini in emu_ini_files:
ini = MameWahIni(emu_ini)
if not ini.has_option('list_title'):
self.emu_lists.append(
[ini.get('emulator_title'),
os.path.splitext(os.path.basename(emu_ini))[0],
ini])
self.emu_lists.sort()
#load emu combo
l = ['%s (%s.ini)' % (e[0], e[1]) for e in self.emu_lists]
self.setup_combo_box(self.cboEmu, l)
#wahcade
self.txeWCLayoutDir.set_text(self.wahcade_ini.get('layout'))
self.chkWCFullscreen.set_active((self.wahcade_ini.getint('fullscreen', 0) == 1))
self.spnWCScrDelay.set_value(self.wahcade_ini.getint('delay'))
self.spnWCScrSlide.set_value(self.wahcade_ini.getint('slide_duration'))
self.spnWCMovieDelay.set_value(self.wahcade_ini.getint('delay_before_movie_preview'))
self.hscWCMovieVolume.set_value(self.wahcade_ini.getint('movie_volume'))
ini_mix = self.wahcade_ini.get('music_movie_mix')
mix_idx = [idx for idx, r in enumerate(self.music_movie_mix) if r[0] == ini_mix][0]
self.cboWCMovieMix.set_active(mix_idx)
self.txeWCMovieIntro.set_text(self.wahcade_ini.get('intro_movie_file'))
self.txeWCMovieExit.set_text(self.wahcade_ini.get('exit_movie_file'))
self.txeWCMusicDir.set_text(self.wahcade_ini.get('music_path'))
self.chkWCMusic.set_active((self.wahcade_ini.getint('enable_music', 0) == 1))
self.hscWCMusicVolume.set_value(self.wahcade_ini.getint('music_volume'))
self.chkWCMusicShuffle.set_active((self.wahcade_ini.getint('shuffle_music', 0) == 1))
self.chkWCMouseCursor.set_active((self.wahcade_ini.getint('show_cursor') == 1))
self.chkWCWrapLists.set_active((self.wahcade_ini.getint('wrap_list') == 1))
self.chkWCScaleImages.set_active((self.wahcade_ini.getint('keep_image_aspect') == 1))
self.chkWCListArrows.set_active((self.wahcade_ini.getint('show_list_arrows', 0) == 1))
#set emu
set_idx = 0
if default_emu:
set_idx = [idx for idx, e in enumerate(self.emu_lists) if e[1] == default_emu][0]
self.cboEmu.set_active(set_idx)
#mame history viewer
self.txeHstDatFile.set_text(self.histview_ini.get('history_dat_file'))
self.txeHstLayout.set_text(self.histview_ini.get('history_layout'))
#mame cp viewer
self.txeCPVIni.set_text(self.cpviewer_ini.get('controls_ini_file'))
self.txeCPVLayout.set_text(self.cpviewer_ini.get('viewer_layout'))
#load keys
self.chkKeysUseKeyboard.set_active((self.ctrlr_ini.getint('keyboard') == 1))
self.chkKeysUseMouse.set_active((self.ctrlr_ini.getint('mouse') == 1))
self.chkKeysUseJoystick.set_active((self.ctrlr_ini.getint('joystick') == 1))
self.populate_keys()
示例7: on_cboLists_changed
def on_cboLists_changed(self, *args):
"""emulator list combo"""
#get settings for current emu list
self.emu_list_idx = self.cboLists.get_active()
emu_list_ini = MameWahIni(os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, self.emu_list_idx)))
if self.emu_list_idx >= 1:
if emu_list_ini.get('list_type') != 'normal':
self.show_msg_dialog(msg=_('List Type must be "normal" to generate filters'))
self.cboLists.set_active(0)
return
if self.emu_list_idx >= 0:
self.load_filter()
示例8: build_filelist
def build_filelist(self, type, ext="ini", regex="(?<=-)\d+", emu="", sep=""):
"""return array of files numbers matching regex value"""
filelist = []
fileset = glob.glob(os.path.join(CONFIG_DIR, ext, emu + sep + '*.' + ext))
for file in fileset:
m = re.search(regex,file)
if m is not None:
if type == "int":
filelist.append(self.return_listnum(file))
elif type == "glist":
if os.path.isfile(file):
list_ini = MameWahIni(file)
filelist.append('%s: %s' % (self.return_listnum(file),list_ini.get('list_title')))
else:
filelist.append(file)
filelist.sort()
return filelist
示例9: __init__
def __init__(self, WinMain):
#set main window
self.WinMain = WinMain
self.layout_filename = ''
self.histview_ok = True
#open history viewer ini
self.histview_ini = MameWahIni(os.path.join(CONFIG_DIR, 'histview.ini'), 'default', '0.16')
if os.path.exists(os.path.join(CONFIG_DIR, 'ini', self.WinMain.current_emu + '.his')):
self.cpviewer_ini = MameWahIni(os.path.join(CONFIG_DIR, 'ini', self.WinMain.current_emu + '.his'), 'default')
if not os.path.isfile(self.histview_ini.get('history_dat_file')):
self.WinMain.log_msg("Warning: history file: [%s] does not exist" % (
self.histview_ini.get('history_dat_file')))
self.histview_ok = False
self.layout_filename = self.histview_ini.get('history_layout')
if not os.path.isfile(self.layout_filename):
self.WinMain.log_msg("Warning: history layout: [%s] does not exist" % (self.layout_filename))
self.histview_ok = False
#build the window
self.winHistory = gtk.Fixed()
self.winHistory.set_has_window(True)
self.imgBackground = gtk.Image()
self.lblHeading = gtk.Label()
self.sclHistory = ScrollList()
self.winHistory.add(self.imgBackground)
self.winHistory.add(self.make_evb_widget(self.lblHeading))
self.winHistory.add(self.sclHistory.fixd)
WinMain.fixd.add(self.winHistory)
self.imgBackground.show()
self.lblHeading.show()
self.winHistory.show()
#build list
self.lsHistory = []
self.sclHistory.auto_update = True
self.sclHistory.display_limiters = self.WinMain.wahcade_ini.getint('show_list_arrows', 0)
#widgets
self._histview_items = [
(8, self.lblHeading),
(21, self.sclHistory)]
#get history
self.history = self.read_history(self.histview_ini.get('history_dat_file'))
#app number
self.app_number = 0
示例10: show_about_dialog
def show_about_dialog(self, app_name, config_dir):
"""about dialog"""
#open controller ini file
self.ctrlr_ini = MameWahIni(os.path.join(config_dir, 'ctrlr', 'default.ini'), 'ctrlr')
#create about dialog
dlg = gtk.AboutDialog()
dlg.set_name(app_name)
dlg.set_version('\n%s "%s"' % (VERSION, VERSION_NAME))
dlg.set_logo(gtk.gdk.pixbuf_new_from_file(
os.path.join(APP_PATH, 'pixmaps', 'wahcade-logo.png')))
gtk.about_dialog_set_url_hook(self.show_website, None)
dlg.set_website('http:///www.anti-particle.com/wahcade.shtml')
dlg.set_website_label('www.anti-particle.com/wahcade')
dlg.set_authors([
'Andy Balcombe', '',
'Fork for Hub!Cade:',
' Quinn \'Spoot\' Granfor', '',
'Bug Reports and Patches:',
' Sylvain Fauveau', ' Robbforce', ' Jim Merullo',
' SeTTleR', ' Mike Crawford', ' Mike Schwartz',
' Nellistc', ' Captbaritone', ' Delphipool', ' 3NF',
' Zerodiv', ' Natrix', ' Bonzo', ' Battlecat', ' Krisbee',
' Buks', ' KillsTheWeak', ' Martin Kalitis', ' Zerojay',
' Dave Baer', ' Spudgunman', ' RomKnight', ' Jason Carter',
' Zombie', ' Pinball Wizard', ' hamelg', ' 3vi1',
' Vítor Baptista', ' Enrico Magrella',
' and anyone I\'ve forgotten...', '',
'Translations:',
' de: SeTTleR', ' es: Nicolás Álvarez',
' fr: Sylvain Faveau', ' it: Diego Pierotto',
' sv: Daniel Nylander', '',
'bdist_debian.py: Gene Cash', '',
])
dlg.set_artists(['Andy Balcombe', 'Buks', 'Battlecat'])
dlg.set_copyright('%s 2005-2010 Andy Balcombe' % (
unichr(169)).encode("utf-8"))
dlg.set_comments('Thanks to:\nMinWah and also the Mame / xMame team')
dlg.set_translator_credits(('translator-credits'))
dlg.set_license(open(os.path.join(APP_PATH, 'doc', 'COPYING')).read())
dlg.connect('key_press_event', self.on_dlgAbout_key_press)
dlg.run()
dlg.hide()
示例11: __init__
def __init__(self, WinMain):
# set main window
self.WinMain = WinMain
self.layout_filename = ""
self.histview_ok = True
# open history viewer ini
self.histview_ini = MameWahIni(os.path.join(CONFIG_DIR, "histview.ini"), "default", "0.16")
if not os.path.isfile(self.histview_ini.get("history_dat_file")):
self.WinMain.log_msg(
"Warning: history file: [%s] does not exist" % (self.histview_ini.get("history_dat_file"))
)
self.histview_ok = False
self.layout_filename = self.histview_ini.get("history_layout")
if not os.path.isfile(self.layout_filename):
self.WinMain.log_msg("Warning: history layout: [%s] does not exist" % (self.layout_filename))
self.histview_ok = False
# build the window
self.winHistory = gtk.Fixed()
self.winHistory.set_has_window(True)
self.imgBackground = gtk.Image()
self.lblHeading = gtk.Label()
self.sclHistory = ScrollList(self.WinMain)
self.winHistory.add(self.imgBackground)
self.winHistory.add(self.make_evb_widget(self.lblHeading))
self.winHistory.add(self.sclHistory.fixd)
WinMain.fixd.add(self.winHistory)
self.imgBackground.show()
self.lblHeading.show()
self.winHistory.show()
# build list
self.lsHistory = []
self.sclHistory.auto_update = True
# widgets
self._histview_items = [(8, self.lblHeading), (21, self.sclHistory)]
# get history
self.history = self.read_history(self.histview_ini.get("history_dat_file"))
# app number
self.app_number = 0
示例12: __init__
class WahCade:
"""Common functions for Wah!Cade"""
def __init__(self):
"""initialise common wahcade class"""
#set default icon for windows
gtk.window_set_default_icon_from_file(
os.path.join(APP_PATH, 'pixmaps', 'wahcade.png'))
### LOGFILE
if os.path.exists(CONFIG_DIR):
self.log_filename = os.path.join(CONFIG_DIR, 'wahcade.log')
try:
f = open(self.log_filename, 'w')
self.log_msg("//======================= NEW LOG RUN =======================//")
f.close
except:
print "ERROR opening LOG FILE, %s, check for orphaned processes" % self.log_filename
def hide_mouse_cursor(self, win):
"""hide mouse cursor"""
gtk_col = gtk.gdk.Color()
pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
invisible_cursor = gtk.gdk.Cursor(
pixmap, pixmap, gtk_col, gtk_col, 0, 0)
win.window.set_cursor(invisible_cursor)
def get_layout_item_properties(self, lines, offset):
"""get properties for item in layout"""
d={}
d['visible'] = (lines[offset].lower() == 'true')
d['transparent'] = (lines[offset + 1] == '1')
d['background-col'] = self.get_colour(int(lines[offset + 2]))
d['text-col'] = self.get_colour(int(lines[offset + 3]))
d['font'] = lines[offset + 4]
d['font-bold'] = (lines[offset + 5].lower() == 'true')
d['font-italic'] = (lines[offset + 6].lower() == 'true')
d['font-size'] = float(lines[offset + 7])
align_rot = lines[offset + 8].split(';')
d['text-align'] = int(align_rot[0])
d['text-rotation'] = 0
if len(align_rot) > 1:
d['text-rotation'] = int(align_rot[1])
d['x'] = int(lines[offset + 9])
d['y'] = int(lines[offset + 10])
d['width'] = int(lines[offset + 11])
d['height'] = int(lines[offset + 12])
#done
return d
def get_colorbutton_info(self, clr_widget):
"""get gtk.ColorButton widgets current colour in gdk and hex format"""
clr = clr_widget.get_color()
hex_clr = '#%s%s%s' % (
hex(clr.red/256)[2:].rjust(2, '0'),
hex(clr.green/256)[2:].rjust(2, '0'),
hex(clr.blue/256)[2:].rjust(2, '0'))
return clr, hex_clr
def get_colour(self, col):
"""convert decimal colour into format suitable for gtk colour"""
hex_col = hex(col)[2:].rjust(6, '0').upper()
#re-arrange
hex_col = '#%s%s%s' % (hex_col[4:6], hex_col[2:4], hex_col[0:2])
return hex_col
def reverse_get_colour(self, hex_col):
"""reverse get_colour method - convert hex colour (#RRGGBB) into
wahcade's decimal format"""
r = int(hex_col[1:3], 16)
g = int(hex_col[3:5], 16)
b = int(hex_col[5:7], 16)
col = (b * 256 * 256) + (g * 256) + r
return col
def get_matching_filename(self, file_prefixes, file_formats):
"""return the filename if it exists from given formats & path
file_prefixes = [(dir_name, filename), ...]
file_formats = [file_ext1, file_ext2, ...]
"""
p = re.compile('(\.[^\.]+$)|(\s(\(|\[).+(?<=(\)|\]|\s))\.[^\.]+$)')
self.wahcade_ini = MameWahIni(os.path.join(CONFIG_DIR, 'wahcade.ini'))
l = self.wahcade_ini.get('layout')
fz = self.wahcade_ini.getint('fuzzy_artwork_search')
#check lower & upper case filenames for each given prefix & format
for dirname, fp in file_prefixes:
if fp == '##random##':
for ff in file_formats:
fnl = walk_dir(dirname, False, '*.%s' % ff.lower(), False) + \
walk_dir(dirname, False, '*.%s' % ff.upper(), False)
#return first valid match
for filename in fnl:
if os.path.isfile(filename):
return filename
elif fp != '':
if file_formats != '':
# Check if this is a layout
if l not in dirname:
if fz:
# NB: we append a fake extension here to support the regex currently - sairuk
# handles . appearing in filename being treated as an ext
#.........这里部分代码省略.........
示例13: WinSetup
class WinSetup(GladeSupport, WahCade):
"""wahcade setup - main window"""
def __init__(self, glade_filename, window_name, config_opts, config_args):
"""build the window"""
WahCade.__init__(self)
GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
#command-line options
self.config_opts = config_opts
#set default config location (create / update as necessary)
self.config_dir = CONFIG_DIR
if not os.path.exists(self.config_dir):
self.copy_user_config('all')
else:
#update current config
self.copy_user_config()
#keys list
self.tvwKeys, self.lsKeys, self.tvwsKeys = self.setup_treeview(
columns = ['Function', 'Key'],
column_types = [gobject.TYPE_STRING, gobject.TYPE_STRING],
container = self.scwKeys,
resizeable_cols = False)
self.lsKeys.set_sort_column_id(0, gtk.SORT_ASCENDING)
self.tvwKeys.connect('row-activated', self.on_tvwKeys_row_activated)
self.tvwKeys.set_tooltip_text(_('Double-Click a row to change a Key...'))
#set max width for keys column (stops window getting too wide)
col = self.tvwKeys.get_column(1)
col.set_max_width(200)
#get ini files
self.wahcade_ini = MameWahIni(os.path.join(self.config_dir, 'wahcade.ini'))
self.histview_ini = MameWahIni(os.path.join(self.config_dir, 'histview.ini'))
self.cpviewer_ini = MameWahIni(os.path.join(self.config_dir, 'cpviewer.ini'))
self.ctrlr_ini = MameWahIni(os.path.join(self.config_dir, 'ctrlr', 'default.ini'), 'ctrlr')
#emu stuff
self.emu_list_gen_types = [
[['rom_folder'], 'Rom Directory'],
[['rom_folder_vs_listxml', 'list_xml'], 'XML File'],
[['rom_folder_vs_dat_file', 'dat_file'], 'DAT File']]
self.emu_scrsave_types = [
['blank_screen', 'Blank Screen'],
['slideshow', 'Slide Show'],
['movie', 'Movies'],
['launch_scr', 'Launch External Screen Saver']]
self.emu_list_types = [
['normal', 'Normal'],
['most_played', 'Most Played'],
['longest_played', 'Longest Played']]
self.music_movie_mix = [
['mute_movies', 'Mute Movies'],
['merge', 'Mix with Music']]
self.emu_artwork_txe = [
self.txeEmuArt1, self.txeEmuArt2, self.txeEmuArt3, self.txeEmuArt4,
self.txeEmuArt5, self.txeEmuArt6, self.txeEmuArt7, self.txeEmuArt8,
self.txeEmuArt9, self.txeEmuArt10]
self.emu_artwork_btn = [
self.btnEmuArt1, self.btnEmuArt2, self.btnEmuArt3, self.btnEmuArt4,
self.btnEmuArt5, self.btnEmuArt6, self.btnEmuArt7, self.btnEmuArt8,
self.btnEmuArt9, self.btnEmuArt10]
#setup combo boxes
self.setup_combo_box(self.cboEmuScrSaver, [r[1] for r in self.emu_scrsave_types])
self.setup_combo_box(self.cboEmuListGen, [r[1] for r in self.emu_list_gen_types])
self.setup_combo_box(self.cboEmuListType, [r[1] for r in self.emu_list_types])
self.setup_combo_box(self.cboWCMovieMix, [r[1] for r in self.music_movie_mix])
#global joy
self.joystick = joystick.joystick()
self.joystick.use_all_controls()
#get default window size & pos
self.do_events()
w, h = self.wahcade_ini.get('setup_window_size', 'default', '400x400').split('x')
self.winSetup.resize(width=int(w), height=int(h))
#load settings
self.load_settings()
self.setup_altered = False
#set icon sizes
settings = gtk.settings_get_default()
settings.set_string_property('gtk-icon-sizes', 'gtk-button=16,16', '')
def on_winSetup_delete_event(self, *args):
"""done, quit the application"""
#save settings
self.save_setups()
#save default window size & pos
win_size = self.winSetup.get_size()
self.wahcade_ini.set('setup_window_size', '%sx%s' % (win_size))
self.wahcade_ini.write()
#exit gtk loop
gtk.main_quit()
return False
def on_Setup_changed(self, widget, *args):
"""widget has been modified, update altered flag"""
self.setup_altered = True
def on_mnuFSave_activate(self, *args):
"""save settings"""
self.save_setups(False)
def on_mnuFReset_activate(self, *args):
"""reset settings"""
dlg = gtk.MessageDialog(
#.........这里部分代码省略.........
示例14: get_matching_filename
def get_matching_filename(self, file_prefixes, file_formats):
"""return the filename if it exists from given formats & path
file_prefixes = [(dir_name, filename), ...]
file_formats = [file_ext1, file_ext2, ...]
"""
p = re.compile('(\.[^\.]+$)|(\s(\(|\[).+(?<=(\)|\]|\s))\.[^\.]+$)')
self.wahcade_ini = MameWahIni(os.path.join(CONFIG_DIR, 'wahcade.ini'))
l = self.wahcade_ini.get('layout')
fz = self.wahcade_ini.getint('fuzzy_artwork_search')
#check lower & upper case filenames for each given prefix & format
for dirname, fp in file_prefixes:
if fp == '##random##':
for ff in file_formats:
fnl = walk_dir(dirname, False, '*.%s' % ff.lower(), False) + \
walk_dir(dirname, False, '*.%s' % ff.upper(), False)
#return first valid match
for filename in fnl:
if os.path.isfile(filename):
return filename
elif fp != '':
if file_formats != '':
# Check if this is a layout
if l not in dirname:
if fz:
# NB: we append a fake extension here to support the regex currently - sairuk
# handles . appearing in filename being treated as an ext
fileset = glob.iglob(os.path.join(CONFIG_DIR, dirname, re.sub(p,'',fp + ".fix") + "*"))
for filename in fileset:
fn = os.path.basename(filename.lower())
f = re.sub(p,'',fn)
g = re.search(re.escape(f),fp.lower())
if f and g is not None:
if f == g.group(0):
return filename
else:
self.log_msg(" [ARTWORK] No match for " + fp + " in " + dirname, 1)
else:
for ff in file_formats:
basename = '%s.%s' % (fp, ff)
#build list of possible filenames
fnl = [os.path.join(dirname, basename),
os.path.join(dirname, basename.lower()),
os.path.join(dirname, basename.upper())]
#return first valid match
for filename in fnl:
if os.path.isfile(filename):
return filename
else:
for ff in file_formats:
basename = '%s.%s' % (fp, ff)
#build list of possible filenames
fnl = [os.path.join(dirname, basename),
os.path.join(dirname, basename.lower()),
os.path.join(dirname, basename.upper())]
#return first valid match
for filename in fnl:
if os.path.isfile(filename):
return filename
else:
filename = os.path.join(dirname, fp)
if os.path.isfile(filename):
return filename
#done - nothing found
return ''
示例15: __init__
def __init__(self, glade_filename, window_name, emu_name):
"""build the window"""
WahCade.__init__(self)
GladeSupport.__init__(self, glade_filename, window_name, APP_NAME)
self.config_dir = CONFIG_DIR
#print "emu_name=",emu_name
self.emu_name = emu_name
self.emu_list_idx = 0
#setup tree & lists
self.tsFilter = gtk.TreeStore(str, gobject.TYPE_BOOLEAN, str)
self.tvwFilter = gtk.TreeView(model = self.tsFilter)
#text col
cellrt = gtk.CellRendererText()
tvcol = gtk.TreeViewColumn(_('Filter'))
tvcol.pack_start(cellrt, True)
tvcol.add_attribute(cellrt, 'text', 0)
tvcol.set_resizable(True)
#checkbox col
crt = gtk.CellRendererToggle()
crt.set_property('activatable', True)
crt.connect('toggled', self.on_tvwFilter_toggled, self.tsFilter)
tvcol2 = gtk.TreeViewColumn(_('Selected?'), crt)
tvcol2.add_attribute(crt, 'active', 1)
#add columns to treeview
self.tvwFilter.append_column(tvcol)
self.tvwFilter.append_column(tvcol2)
#self.tvwFilter.set_rules_hint(True)
self.tvwFilter.show()
self.scwFilter.add(self.tvwFilter)
#games list
self.tvwGames, self.lsGames, self.tvwsGames = self.setup_treeview(
columns = ['Games'],
column_types = [gobject.TYPE_STRING],
container = self.scwGameList,
resizeable_cols = True,
highlight_rows = False)
#load lists
i = 0
emu_game_lists = []
while True:
ini_file = os.path.join(self.config_dir, 'ini', '%s-%s.ini' % (self.emu_name, i))
if os.path.isfile(ini_file):
list_ini = MameWahIni(ini_file)
emu_game_lists.append(list_ini.get('list_title'))
i += 1
else:
break
l = ['%s: %s' % (i, r) for i, r in enumerate(emu_game_lists)]
#setup filters & emu ini
emu_ini_filename = os.path.join(self.config_dir, 'ini', '%s.ini' % (self.emu_name))
if os.path.isfile(emu_ini_filename):
self.emu_ini = MameWahIni(emu_ini_filename)
#filters._mameinfo_file = os.path.join(self.emu_ini.get('dat_file'))
filters._catver_ini = os.path.join(self.emu_ini.get('catver_ini_file'))
else:
print _("Error: Emulator Ini file: [%s] doesn't exist" % (emu_ini_filename))
#filter values
if os.path.isfile(self.emu_ini.get('dat_file')):
self._display_clones = [
[_('No'), 'no'],
[_('Yes'), 'yes'],
[_('Only if better than Parent'), 'better']]
self._filter_sections = [
['filter_type', _('Display Clones')],
['year', _('Year Filters')],
['manufacturer', _('Manufacturer Filters')],
['driver', _('BIOS Filters')],
['display_type', _('Screen Type Filters')],
['screen_type', _('Screen Orientation Filters')],
['controller_type', _('Input Type Filters')],
['driver_status', _('General Status Filters')],
['colour_status', _('Colour Status Filters')],
['sound_status', _('Sound Status Filters')],
['category', _('Category Filters')]]
elif os.path.isfile(self.emu_ini.get('catver_ini_file')):
self._filter_sections = [['category', _('Category Filters')]]
else:
self._filter_sections = []
self.setup_combo_box(self.cboLists, l)
#load filter
self.cboLists.set_active(self.emu_list_idx)
self.filter_altered = False