From 2a94d52b081284e7f8165948fae50b3efabcd625 Mon Sep 17 00:00:00 2001
From: Cecil <knoppmyth@gmail.com>
Date: Sun, 10 Jun 2012 02:20:22 -0700
Subject: dolphin-emu:Added menu entry for Dolphin. Added script that parse
 directory to create menu entry for games.

---
 abs/extra/community/dolphin-emu/PKGBUILD           | 20 +++++++++---
 abs/extra/community/dolphin-emu/__changelog        |  2 ++
 .../community/dolphin-emu/dolphin-emu.install      | 36 ++++++++++++++++++++++
 abs/extra/community/dolphin-emu/dolphin-emu.xml    | 18 +++++++++++
 .../community/dolphin-emu/dolphin-emu_games.xml    |  7 +++++
 .../community/dolphin-emu/dolphin-emu_scan.sh      | 34 ++++++++++++++++++++
 6 files changed, 113 insertions(+), 4 deletions(-)
 create mode 100644 abs/extra/community/dolphin-emu/__changelog
 create mode 100644 abs/extra/community/dolphin-emu/dolphin-emu.install
 create mode 100644 abs/extra/community/dolphin-emu/dolphin-emu.xml
 create mode 100644 abs/extra/community/dolphin-emu/dolphin-emu_games.xml
 create mode 100644 abs/extra/community/dolphin-emu/dolphin-emu_scan.sh

diff --git a/abs/extra/community/dolphin-emu/PKGBUILD b/abs/extra/community/dolphin-emu/PKGBUILD
index a617981..a75a929 100644
--- a/abs/extra/community/dolphin-emu/PKGBUILD
+++ b/abs/extra/community/dolphin-emu/PKGBUILD
@@ -5,7 +5,7 @@
 
 pkgname=dolphin-emu
 pkgver=3.0
-pkgrel=9
+pkgrel=10
 epoch=1
 pkgdesc="A GameCube and Wii emulator (stable git branch)"
 arch=('i686' 'x86_64')
@@ -20,10 +20,13 @@ depends=('sdl' 'libxxf86vm' 'libao' 'wxgtk' 'wiiuse' 'nvidia-cg-toolkit' \
 # IF YOU NEED SFML>=1.7 FOR SOMETHING ELSE, TRY REMOVING THE CONFLICT
 # BELOW AND ONLY TEMPORARY UNINSTALLING SFML TO BUILD/INSTALL DOLPHIN
 conflicts=('dolphin-emu-git' 'sfml>=1.7' 'sfml-git')
-
+install="${pkgname}.install"
 source=('dolphin-emu.desktop'
         'unistd.diff'
-        'Dolphin_Logo.png')
+        'Dolphin_Logo.png'
+	'dolphin-emu.xml'
+	'dolphin-emu_games.xml'
+	'dolphin-emu_scan.sh')
 
 _gitroot=https://code.google.com/p/dolphin-emu/
 _gitname=dolphin-emu-3.0
@@ -63,13 +66,22 @@ package() {
   cd "${srcdir}/dolphin-emu-3.0-build/build"
 
   make DESTDIR=${pkgdir} install
+  
+  mkdir -p "${pkgdir}"/usr/share/mythtv/themes/defaultmenu
+  mkdir -p "${pkgdir}"/usr/LH/bin
 
   install -Dm644 "${srcdir}/dolphin-emu.desktop" "${pkgdir}/usr/share/applications/dolphin-emu.desktop"
   install -Dm644 "${srcdir}/Dolphin_Logo.png" "${pkgdir}/usr/share/pixmaps/dolphin-emu.png"
+  cp "${srcdir}/dolphin-emu.xml" "${pkgdir}/usr/share/mythtv/themes/defaultmenu"
+  cp "${srcdir}/dolphin-emu_games.xml" "${pkgdir}/usr/share/mythtv/themes/defaultmenu"
+  install -m755 "${srcdir}/dolphin-emu_scan.sh" "${pkgdir}/usr/LH/bin"
 }
 
 # vim:set ts=2 sw=2 et:
 
 md5sums=('feed4580c2e6bfbc7f6c67dad861daae'
          'a463b96d02462b5f6b0894f6ced821ab'
-         'd15c51f547b4bd47e510faac40bcc9d6')
+         'd15c51f547b4bd47e510faac40bcc9d6'
+         'ab7a9b9cfe03db65c881134c0f02bda0'
+         '1d03499e0abab56285bc97176d311bf1'
+         '4d2304318e82fd9115810b7a13fa5ad0')
diff --git a/abs/extra/community/dolphin-emu/__changelog b/abs/extra/community/dolphin-emu/__changelog
new file mode 100644
index 0000000..cdd8871
--- /dev/null
+++ b/abs/extra/community/dolphin-emu/__changelog
@@ -0,0 +1,2 @@
+6/9/12 -chw-
+Added install file, and mythtv menu files.
diff --git a/abs/extra/community/dolphin-emu/dolphin-emu.install b/abs/extra/community/dolphin-emu/dolphin-emu.install
new file mode 100644
index 0000000..6acdd50
--- /dev/null
+++ b/abs/extra/community/dolphin-emu/dolphin-emu.install
@@ -0,0 +1,36 @@
+post_install() {
+  mv /usr/share/mythtv/themes/defaultmenu/game.xml /tmp
+  grep -v -e /mythmenu /tmp/game.xml > /tmp/game.xml.tmp
+  echo "<!--#Dolphin-Emu-->" >> /tmp/game.xml.tmp
+  echo "   <button>" >> /tmp/game.xml.tmp
+  echo "     <type>MENU_GAME</type>" >> /tmp/game.xml.tmp
+  echo "     <text>Dolphin Emulator</text>" >> /tmp/game.xml.tmp
+  echo "     <action>MENU dolphin-emu.xml</action>" >> /tmp/game.xml.tmp 
+  echo "   </button>" >> /tmp/game.xml.tmp
+  echo "<!--#Dolphin-Emu-->" >> /tmp/game.xml.tmp
+  echo "" >> /tmp/game.xml.tmp
+  echo "</mythmenu>" >> /tmp/game.xml.tmp
+  mv /tmp/game.xml.tmp /usr/share/mythtv/themes/defaultmenu/game.xml
+}
+
+post_upgrade() {
+  mv /usr/share/mythtv/themes/defaultmenu/game.xml /tmp/game.xml.tmp
+  sed -e '/\#Dolphin-Emu/,/\#Dolphin-Emu/d' < /tmp/game.xml.tmp > /usr/share/mythtv/themes/defaultmenu/game.xml
+  mv /usr/share/mythtv/themes/defaultmenu/game.xml /tmp
+  grep -v -e /mythmenu /tmp/game.xml > /tmp/game.xml.tmp
+  echo "<!--#Dolphin-Emu-->" >> /tmp/game.xml.tmp
+  echo "   <button>" >> /tmp/game.xml.tmp
+  echo "     <type>MENU_GAME</type>" >> /tmp/game.xml.tmp
+  echo "     <text>Dolphin Emulator</text>" >> /tmp/game.xml.tmp
+  echo "     <action>MENU dolphin-emu.xml</action>" >> /tmp/game.xml.tmp 
+  echo "   </button>" >> /tmp/game.xml.tmp
+  echo "<!--#Dolphin-Emu-->" >> /tmp/game.xml.tmp
+  echo "" >> /tmp/game.xml.tmp
+  echo "</mythmenu>" >> /tmp/game.xml.tmp
+  mv /tmp/game.xml.tmp /usr/share/mythtv/themes/defaultmenu/game.xml
+}
+
+post_remove() {
+  mv /usr/share/mythtv/themes/defaultmenu/game.xml /tmp/game.xml.tmp
+  sed -e '/\#Dolphin-Emu/,/\#Dolphin-Emu/d' < /tmp/game.xml.tmp > /usr/share/mythtv/themes/defaultmenu/game.xml
+}
diff --git a/abs/extra/community/dolphin-emu/dolphin-emu.xml b/abs/extra/community/dolphin-emu/dolphin-emu.xml
new file mode 100644
index 0000000..5aaf1a1
--- /dev/null
+++ b/abs/extra/community/dolphin-emu/dolphin-emu.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<mythmenu name="GAME">
+
+    <button>
+        <type>GAME</type>
+        <text>Scan for games</text>
+        <description></description>
+	<action>EXEC /usr/LH/bin/dolphin-emu_scan.sh</action>
+    </button>
+
+    <button>
+        <type>GAME</type>
+        <text>Play Dolphin Games</text>
+        <description>Play video games</description>
+        <action>MENU dolphin-emu_games.xml</action>
+    </button>
+
+</mythmenu>
diff --git a/abs/extra/community/dolphin-emu/dolphin-emu_games.xml b/abs/extra/community/dolphin-emu/dolphin-emu_games.xml
new file mode 100644
index 0000000..fdd19d9
--- /dev/null
+++ b/abs/extra/community/dolphin-emu/dolphin-emu_games.xml
@@ -0,0 +1,7 @@
+<mythmenu name="DOLPHIN">
+  <button>
+    <type>MENU_DOLPHIN</type>
+    <text>Please scan for games</text>
+    <action>UPMENU</action>
+  </button>
+</mythmenu>
diff --git a/abs/extra/community/dolphin-emu/dolphin-emu_scan.sh b/abs/extra/community/dolphin-emu/dolphin-emu_scan.sh
new file mode 100644
index 0000000..615cac8
--- /dev/null
+++ b/abs/extra/community/dolphin-emu/dolphin-emu_scan.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+#----------------------------------------------------------------------------
+. /etc/osd_cat.cfg || {
+        color=yellow
+        outline=2
+        outlinecolour=black
+        shadow=0
+        shadowcolour=black
+        font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
+}
+#----------------------------------------------------------------------------
+EXTNS=('[eE][lL][fF]' '[dD][oO][lL]' '[gG][cC][mM]' '[iI][sS][oO]' '[cC][iI][sS][oO]' '[gG][cC][zZ]' '[wW][aA][dD]')
+DIR=/myth/games/dolphin-emu/roms
+rm -fr /tmp/dolphin*
+echo -e "Scanning for games and creating menu." | osd_cat --pos=middle --align=center --delay=3 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font &
+for EXT in ${EXTNS[@]}
+do
+	if [ -d "$DIR" ]; then
+	cd $DIR
+	ls *.$EXT >> /tmp/dolphin-emu.games
+	fi
+done
+echo "<mythmenu name=\"DOLPHIN\">" > /tmp/dolphin-emu_games.xml
+
+while read line
+do
+	echo "  <button>" >> /tmp/dolphin-emu_games.xml
+	echo "    <type>MENU_DOLPHIN</type>" >> /tmp/dolphin-emu_games.xml
+	echo "    <text>$(echo "$line"  | sed 's/.\{4\}$//')</text>" >> /tmp/dolphin-emu_games.xml
+	echo "    <action>EXEC /usr/bin/dolphin-emu -b -e $DIR/"$line"</action>" >> /tmp/dolphin-emu_games.xml
+	echo "  </button>" >> /tmp/dolphin-emu_games.xml
+done < /tmp/dolphin-emu.games
+echo "</mythmenu>" >> /tmp/dolphin-emu_games.xml
+sudo mv /tmp/dolphin-emu_games.xml /usr/share/mythtv/themes/defaultmenu/
-- 
cgit v0.12