Changes

Jump to navigation Jump to search
11,544 bytes added ,  14:49, 2 January 2010
no edit summary
Hey Hunter, I love your Card Manager app, much better than Windows 7 trying to open the pictures in there automagically!
If you want, I can help teach you some things, namely C/C++, if you're willing to learn. Drop me a message sometime. [[User:Paril|Paril]] 14:22, 1 January 2010 (UTC)
 
== Wii SD apps Manager source ==
 
Here is the source for my SD card manager.(i made it in autoit before i learned Python):
<source lang="">;===============================================================
; Wii SD apps Manager
;
; By Pbsds
;===============================================================
#NoTrayIcon
#Include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <ComboConstants.au3>
#include <GuiMenu.au3>
FileInstall("C:\Users\peder\Desktop\skrivebord\programmer\Ny mappe\mitt program\Wii SD apps Manager\splash.bmp",@TempDir & "\splash.bmp")
SplashImageOn ("Splash",@TempDir & "\splash.bmp",225,160,-1,-1,BitOR(1,2))
global $list, $listarray , $listarrayAviable
$SDcardRes = "Non"
 
Opt("GuiResizeMode", 930)
 
$MainGUI = GUICreate("Wii SD apps Manager",500,420,-1,-1,BitOr($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_MAXIMIZEBOX))
GUISetBkColor(0xCCE9FF)
 
;menu
$FileMenu = GUICtrlCreateMenu("File")
$FileMenuAdd = GUICtrlCreateMenuItem("Add an application",$FileMenu)
$FileMenuUpdate = GUICtrlCreateMenuItem("Update list",$FileMenu)
GUICtrlCreateMenuItem("",$FileMenu)
$FileMenuExit = GUICtrlCreateMenuItem("Exit",$FileMenu)
 
;ControlPanel:
$appinfo_button = GUICtrlCreateButton("App Info",1,1,50,30)
GUICtrlSetTip(-1, "Show the content of the selected app's meta.xml")
_GUICtrlButton_Enable($appinfo_button,False)
$appdelete_button = GUICtrlCreateButton("Delete",51,1,50,30)
GUICtrlSetTip(-1, "Remove the selected application from the drive")
_GUICtrlButton_Enable($appdelete_button,False)
 
GUICtrlCreateLabel("Drive:",203,8,30,16)
$DrivesAviable = GUICtrlCreateCombo("",235,4,70,21,$CBS_DROPDOWNLIST)
$GoToDrive = GUICtrlCreateButton("Go!",307,2,40,27)
 
$InfoPanel = GUICtrlCreateLabel("No app Selected...",350,0,@DesktopWidth - 350,32)
GUICtrlSetBkColor(-1,0xA3D8FF)
 
;The List
$list = GUICtrlCreateList("", 0, 32, 500, 368, BitOR($WS_VSCROLL,0x0100))
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
 
sleep(200)
SplashOff()
;show gui
GUISetState(@SW_SHOW)
 
;~ AddAppsFromSD($SDcardRes)
$oldselect = ""
SetDriveCombo("Non")
 
;gui loop
While 1
$msg = GUIGetMsg()
Select
Case $msg = $appdelete_button
if MsgBox(0,"Wii SD apps Manager","Do you really want to delete this file?") == 4 Then
deleteApp($SDcardRes & ":\apps\" & $listarray[_GUICtrlListBox_GetCurSel($list) + 1])
EndIf
Case $msg = $appinfo_button
AppProp($SDcardRes & ":\apps\" & $listarray[_GUICtrlListBox_GetCurSel($list) + 1])
Case $msg = $FileMenuUpdate
_GUICtrlButton_Enable($appinfo_button,False)
_GUICtrlButton_Enable($appdelete_button,False)
GUICtrlSetData($InfoPanel,"No app Selected...")
AddAppsFromSD($SDcardRes)
Case $msg = $FileMenuAdd
If $SDcardRes <> "Non" Then
AddApp($SDcardRes)
_GUICtrlButton_Enable($appinfo_button,False)
_GUICtrlButton_Enable($appdelete_button,False)
AddAppsFromSD($SDcardRes)
Else
MsgBox(0,"ERROR!","You Need to select a drive first!")
EndIf
Case $msg = $GoToDrive
If (not (FileExists(GUICtrlRead($DrivesAviable) & ":\apps\"))) or GUICtrlRead($DrivesAviable) == "None" Then
_GUICtrlButton_Enable($appinfo_button,False)
_GUICtrlButton_Enable($appdelete_button,False)
$SDcardRes = StringTrimRight(GUICtrlRead($DrivesAviable),1)
SetDriveCombo(string($SDcardRes))
AddAppsFromSD($SDcardRes)
Else
EndIf
Case $msg = $GUI_EVENT_CLOSE or $msg = $FileMenuExit
FileDelete(@TempDir & "\splash.bmp")
Exit
EndSelect
#Region update buttons
If _GUICtrlListBox_GetText($list, _GUICtrlListBox_GetCurSel($list)) <> $oldselect Then
If FileExists($SDcardRes & ":\apps\" & $listarray[_GUICtrlListBox_GetCurSel($list) + 1]) == 1 Then
_GUICtrlButton_Enable($appinfo_button,True)
_GUICtrlButton_Enable($appdelete_button,True)
GUICtrlSetData($InfoPanel,"Path:" & @CRLF & $SDcardRes & ":\apps\" & $listarray[_GUICtrlListBox_GetCurSel($list) + 1])
Else
_GUICtrlButton_Enable($appinfo_button,False)
_GUICtrlButton_Enable($appdelete_button,False)
GUICtrlSetData($InfoPanel,"No app Selected...")
EndIf
$oldselect = _GUICtrlListBox_GetText($list, _GUICtrlListBox_GetCurSel($list))
EndIf
#EndRegion
WEnd
 
Func deleteApp($Dir)
DirRemove($Dir,1)
_GUICtrlButton_Enable($appinfo_button,False)
_GUICtrlButton_Enable($appdelete_button,False)
GUICtrlSetData($InfoPanel,"No app Selected...")
AddAppsFromSD($SDcardRes)
EndFunc
 
Func AddApp($dsres)
$AddAppGUI = GUICreate("Add an Application",300,400,-1,-1,BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
GUICtrlCreateGroup("Boot.dol",2,2,296,59)
GUICtrlCreateLabel("Boot.dol file path:",5,16,290,16)
$dolPath = GUICtrlCreateInput("",5,31,250,21)
$dolPathSet = GUICtrlCreateButton("...",256,31,40,21)
GUICtrlCreateGroup("Icon.png (Optional)",2,61,296,59)
GUICtrlCreateLabel("Icon.bin file path:",5,16+59,290,16)
$iconPath = GUICtrlCreateInput("",5,31+59,250,21)
$iconPathSet = GUICtrlCreateButton("...",256,31+59,40,21)
GUICtrlCreateGroup("Meta.xml (Optional)",2,60 + 59,296,245)
GUICtrlCreateLabel("Name:",5,15+59+59,290,16)
$XML_name = GUICtrlCreateInput("",5,30+59+59,290,21)
GUICtrlCreateLabel("Creator:",5,15+59+59 +37,290,16)
$XML_coder = GUICtrlCreateInput("",5,30+59+59 +37,290,21)
GUICtrlCreateLabel("Version:",5,15+59+59 +37+37,290,16)
$XML_version = GUICtrlCreateInput("",5,30+59+59 +37+37,290,21)
GUICtrlCreateLabel("Short description:",5,15+59+59 +37+37+37,290,16)
$XML_ShortDesc = GUICtrlCreateInput("",5,30+59+59 +37+37+37,290,21)
GUICtrlCreateLabel("Long description:",5,15+59+59 +37+37+37+37,290,16)
$XML_LongDesc = GUICtrlCreateEdit("",5,30+59+59 +37+37+37+37,290,66)
 
$OKButton = GUICtrlCreateButton("Create",118,367,90,31)
$CloseButton = GUICtrlCreateButton("Close",208,367,90,31)
GUISetState(@SW_SHOW)
while 1
$msg = GUIGetMsg()
Select
Case $msg = $dolPathSet
GUICtrlSetData($dolPath, FileOpenDialog("Select DOL", @WorkingDir, "Wii Executables (*.dol)", 1))
Case $msg = $iconPathSet
GUICtrlSetData($iconPath, FileOpenDialog("Select PNG image", @WorkingDir, "PNG image files (*.png)", 1))
;==================================================
Case $msg = $OKButton
If GUICtrlRead($dolPath) <> "" Then
do
$FolderName = InputBox("Folder name","Name of the folder:",GUICtrlRead($XML_name))
Until $FolderName <> ""
$XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' & @CRLF & '<app version="1">' & @CRLF & '<name>'
$XML &= GUICtrlRead($XML_name)
$XML &= '</name>' & @CRLF & ' <coder>'
$XML &= GUICtrlRead($XML_coder)
$XML &= '</coder>' & @CRLF & ' <version>'
$XML &= GUICtrlRead($XML_version)
$XML &= '</version>' & @CRLF & ' <release_date>00000000000000</release_date>' & @CRLF & ' <short_description>'
$XML &= GUICtrlRead($XML_ShortDesc)
$XML &= '</short_description>' & @CRLF & ' <long_description>'
$XML &= GUICtrlRead($XML_LongDesc)
$XML &= '</long_description> ' & @CRLF & '</app>'
DirCreate($dsres & ":\apps\" & $FolderName)
FileWrite($dsres & ":\apps\" & $FolderName & "\meta.xml",$XML)
FileCopy(GUICtrlRead($iconPath),$dsres & ":\apps\" & $FolderName & "\icon.png")
FileCopy(GUICtrlRead($dolPath),$dsres & ":\apps\" & $FolderName & "\boot.dol")
ExitLoop
Else
MsgBox(0,"ERROR!","You MUST select a boot.dol!")
EndIf
Case $msg = $GUI_EVENT_CLOSE or $msg = $CloseButton
ExitLoop
EndSelect
wend
GUIDelete($AddAppGUI)
EndFunc
 
Func AppProp($Dir)
SplashImageOn ("Splash",@TempDir & "\splash.bmp",225,160,-1,-1,BitOR(1,2))
_GDIPlus_Startup ()
$release_date = XMLread($Dir & "\meta.xml","release_date")
$PropGUI = GUICreate(_GUICtrlListBox_GetText($list, _GUICtrlListBox_GetCurSel($list)) & "'s Properties",300,400,-1,-1,BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
GUICtrlCreateGroup("Meta.xml",2,2,296,363)
GUICtrlCreateLabel( "Name: " & XMLread($Dir & "\meta.xml","name") & @CRLF & "Version: " & XMLread($Dir & "\meta.xml","version") & @CRLF & "Release date: " & stringright(StringLeft($release_date,8),2) & "/" & stringright(StringLeft($release_date,6),2) & "-" & StringLeft($release_date,4) & @CRLF & "Short description: " & XMLread($Dir & "\meta.xml","short_description") & @CRLF & "Long description:",5,21 + 68,290,70)
$Text = GUICtrlCreateEdit("",5,157,290,204, BitOR($GUI_SS_DEFAULT_LIST,0x0100,0x0800))
$img = _GDIPlus_BitmapCreateFromFile($Dir & "\icon.png")
$CloseButton = GUICtrlCreateButton("Close",208,367,90,31)
SplashOff()
GUISetState(@SW_SHOW)
GUICtrlSetData($Text,XMLread($Dir & "\meta.xml","long_description"))
$graphic = _GDIPlus_GraphicsCreateFromHWND($PropGUI)
_GDIPlus_GraphicsDrawImage($graphic, $img, 5, 21)
while 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE or $msg = $CloseButton
ExitLoop
EndSelect
wend
_GDIPlus_ImageDispose($img)
_WinAPI_DeleteObject($img)
_GDIPlus_ShutDown()
GUIDelete($PropGUI)
EndFunc
 
Func AddAppsFromSD($Drive)
SplashImageOn ("Splash",@TempDir & "\splash.bmp",225,160,-1,-1,BitOR(1,2))
GUICtrlSetData($list,"")
$listarray = ""
;~ _GUICtrlListBox_BeginUpdate($list)
$search = FileFindFirstFile($Drive & ":\apps\*")
While 1
If $Search = -1 Then
ExitLoop
EndIf
$File = FileFindNextFile($Search)
If @error Then ExitLoop
$FullFilePath = $Drive & ":\apps\" & $File
$FileAttributes = FileGetAttrib($FullFilePath)
If StringInStr($FileAttributes,"D") Then
If FileExists($FullFilePath & "\meta.xml") <> 0 And (FileExists($FullFilePath & "\boot.dol") == 1 or FileExists($FullFilePath & "\boot.elf") == 1) Then
_GUICtrlListBox_AddString($list,XMLread($FullFilePath & "\meta.xml","name"))
$listarray &= "\" & StringRight($FullFilePath, StringLen($FullFilePath)-StringInStr($FullFilePath, "\", 0, -1))
ElseIf FileExists($FullFilePath & "\boot.dol") == 1 or FileExists($FullFilePath & "\boot.elf") == 1 Then
_GUICtrlListBox_AddString($list,StringRight($FullFilePath, StringLen($FullFilePath)-StringInStr($FullFilePath, "\", 0, -1)))
$listarray &= "\" & StringRight($FullFilePath, StringLen($FullFilePath)-StringInStr($FullFilePath, "\", 0, -1))
EndIf
EndIf
WEnd
FileClose($search)
$listarray = StringSplit(StringTrimLeft($listarray,1),"\")
RemoveEmptyStringsFromList()
_GUICtrlListBox_UpdateHScroll($list)
;~ _GUICtrlListBox_EndUpdate($list)
SplashOff()
EndFunc
 
Func SetDriveCombo($set)
$array = DriveGetDrive("ALL")
$string = "None|"
For $i = 1 to $array[0]
$string &= $array[$i] & "|"
Next
GUICtrlSetData($DrivesAviable, "" , "")
If $set <> "Non" Then
$set &= ":"
Else
$set &= "e"
EndIf
GUICtrlSetData($DrivesAviable, stringtrimright($string,1) , $set)
EndFunc
 
Func RemoveEmptyStringsFromList()
For $i = 0 to _GUICtrlListBox_GetCount($list)
$temp = _GUICtrlListBox_GetText($list,$i)
If $temp == "" or $temp == " " Then
_GUICtrlListBox_DeleteString($list, $i)
EndIf
Next
EndFunc
 
Func XMLread($meta,$section)
$meta = FileRead($meta)
$temp = StringLeft($meta,StringInStr($meta,"</" & $section & ">",0,-1)-1)
return StringRight($temp,StringLen($temp)-StringInStr($temp,"<" & $section & ">",0,-1)-StringLen($section)-1)
EndFunc</source>
If it helps, here is a list of the funtions of you are going to translate it ;): [http://www.autoitscript.com/autoit3/docs/]
--[[User:Pbsds|pbsds]] 12:49, 2 January 2010 (UTC)
84

edits

Navigation menu