#Include "FiveWin.ch"
STATIC oImageList,oTree,oFile,cSave,lOpen,oGet,oTxt
//----------------------------------------------------------------------------//
FUNCTION Main(cFile)
LOCAL oDlg,oIco,oBtn1,oBtn2,oBtn3,oBtn4,oCur
LOCAL cOrigen:= ""
lOpen:= .F.
DEFINE CURSOR oCur RESOURCE "MANO"
DEFINE ICON oIco RESOURCE "00"
DEFINE DIALOG oDlg RESOURCE "EDITOR" TITLE "Editor de Recursos RC" ICON oIco
REDEFINE SAY oFile ID 201 OF oDlg
oImageList:= TImageList():New(24,24)
oImageList:Add(TBitmap():DEFINE("RCFILE1",,oDlg), TBitmap():DEFINE("RCFILE2",,oDlg))
oImageList:Add(TBitmap():DEFINE("BITMAP1",,oDlg), TBitmap():DEFINE("BITMAP2",,oDlg))
oImageList:Add(TBitmap():DEFINE("DIALOG1",,oDlg), TBitmap():DEFINE("DIALOG2",,oDlg))
oImageList:Add(TBitmap():DEFINE("ICON1",,oDlg), TBitmap():DEFINE("ICON2",,oDlg))
oImageList:Add(TBitmap():DEFINE("SPEAKER1",,oDlg), TBitmap():DEFINE("SPEAKER2",,oDlg))
oImageList:Add(TBitmap():DEFINE("VIDEO1",,oDlg), TBitmap():DEFINE("VIDEO2",,oDlg))
oImageList:Add(TBitmap():DEFINE("CURSOR1",,oDlg), TBitmap():DEFINE("CURSOR2",,oDlg))
oImageList:Add(TBitmap():DEFINE("CUSTOM1",,oDlg), TBitmap():DEFINE("CUSTOM2",,oDlg))
oImageList:Add(TBitmap():DEFINE("MENU1",,oDlg), TBitmap():DEFINE("MENU2",,oDlg))
oImageList:Add(TBitmap():DEFINE("MANIFEST1",,oDlg), TBitmap():DEFINE("MANIFEST2",,oDlg))
oImageList:Add(TBitmap():DEFINE("BMP1",,oDlg), TBitmap():DEFINE("BMP2",,oDlg))
oImageList:Add(TBitmap():DEFINE("DLG1",,oDlg), TBitmap():DEFINE("DLG2",,oDlg))
oImageList:Add(TBitmap():DEFINE("ICO1",,oDlg), TBitmap():DEFINE("ICO2",,oDlg))
oImageList:Add(TBitmap():DEFINE("WAV1",,oDlg), TBitmap():DEFINE("WAV2",,oDlg))
oImageList:Add(TBitmap():DEFINE("VID1",,oDlg), TBitmap():DEFINE("VID2",,oDlg))
oImageList:Add(TBitmap():DEFINE("CUR1",,oDlg), TBitmap():DEFINE("CUR2",,oDlg))
oImageList:Add(TBitmap():DEFINE("CUS1",,oDlg), TBitmap():DEFINE("CUS2",,oDlg))
oTree:= TTreeView():REDEFINE(100, oDlg, 0, , .F. ,"" )
REDEFINE GET oTxt ID 300 OF oDlg UPDATE
REDEFINE GET oGet VAR cOrigen ID 301 OF oDlg UPDATE
REDEFINE BUTTONBMP oBtn1 TEXTRIGHT RESOURCE "ABRIR" ID 400 OF oDlg ACTION AnalizaRC(AbrirRC(.F.,cFile))
REDEFINE BUTTONBMP oBtn2 TEXTRIGHT RESOURCE "EDITAR" ID 401 OF oDlg ACTION MSGInfo("Editar")
REDEFINE BUTTONBMP oBtn3 TEXTRIGHT RESOURCE "GUARDAR" ID 402 OF oDlg ACTION MSGInfo(cSave)//IF( cFileName != Nil .AND. FILE( cFileName ), MEMOWRIT( cFileName, oEditor:GetText() ),), oBtnSave:Disable()
REDEFINE BUTTONBMP oBtn4 TEXTRIGHT RESOURCE "SALIR" ID 403 OF oDlg ACTION oImageList:END(), oDlg:END()
oDlg:lHelpIcon:= .F.
oDlg:bInit:= {|| AnalizaRC(AbrirRC(.T.,cFile))}
oBtn1:oCursor:= oCur
oBtn2:oCursor:= oCur
oBtn3:oCursor:= oCur
oBtn4:oCursor:= oCur
ACTIVATE DIALOG oDlg CENTERED
RETURN Nil
//----------------------------------------------------------------------------//
STATIC FUNCTION AbrirRC(lAuto,cFile)
IF EMPTY(cFile) .AND. lAuto == .F.
cFile:= cGetFile("Archivo de Recursos en texto (*.rc)|*.rc|", "Agregar Archivo Recurso", 1,)
ENDIF
IF !EMPTY(cFile)
IF LEN(ALLTRIM(cFileNoPath(cFile))) > 3 .AND. cFileExt(cFile) == "rc"
IF lOpen == .T.
CierraRC()
ENDIF
cSave:= cFile
lOpen:= .T.
oFile:VarPut(cFile)
oFile:Refresh()
RETURN ALLTRIM(cFile)
ENDIF
ENDIF
RETURN Nil
//----------------------------------------------------------------------------//
STATIC FUNCTION AnalizaRC(cRCFile)
LOCAL oTxtFile
LOCAL oBmpItem, oDlgItem, oIcoItem, oWavItem, oVidItem, oCurItem, oCusItem
LOCAL aBmpItem, aIcoItem, aWavItem, aVidItem, aCurItem, aCusItem
IF !EMPTY(cRCFile)
oTree:SetImageList( oImageList )
oTree:Add( cFileNoExt(cRCFile) )
oTree:bChanged := {|| Nivel() }
oTxtFile = TTxtFile():New(cRCFile)
aBmpItem:= {}
aIcoItem:= {}
aWavItem:= {}
aVidItem:= {}
aCurItem:= {}
aCusItem:= {}
WHILE oTxtFile:SKIP()
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "BITMAP"
AADD(aBmpItem,ALLTRIM(StrToken(oTxtFile:cLine, 3)))
IF oBmpItem == Nil
oBmpItem = oTree:Add("MAPA DE BITS",1)
oBmpItem:Add( StrToken( oTxtFile:cLine, 1 ), 10, {|| oGet:VarPut(aBmpItem[Nivel()]), oGet:Refresh() })
ELSE
oBmpItem:Add( StrToken( oTxtFile:cLine, 1 ), 10, {|| oGet:VarPut(aBmpItem[Nivel()]), oGet:Refresh() })
ENDIF
ENDIF
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "DIALOG"
IF oDlgItem == Nil
oDlgItem = oTree:Add("DIALOGOS",2)
oDlgItem:Add( StrToken( oTxtFile:cLine, 1 ), 11, {|| oGet:VarPut("Construir Dialogo"), oGet:Refresh() })
ELSE
oDlgItem:Add( StrToken( oTxtFile:cLine, 1 ), 11, {|| oGet:VarPut("con Bwcc32.dll"), oGet:Refresh() })
ENDIF
ENDIF
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "ICON"
AADD(aIcoItem,ALLTRIM(StrToken(oTxtFile:cLine, 3)))
IF oIcoItem == Nil
oIcoItem = oTree:Add("ICONOS",3)
oIcoItem:Add( StrToken( oTxtFile:cLine, 1 ), 12, {|| oGet:VarPut(aIcoItem[Nivel()]), oGet:Refresh() })
ELSE
oIcoItem:Add( StrToken( oTxtFile:cLine, 1 ), 12, {|| oGet:VarPut(aIcoItem[Nivel()]), oGet:Refresh() })
ENDIF
ENDIF
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "WAVE"
AADD(aWavItem,ALLTRIM(StrToken(oTxtFile:cLine, 3)))
IF oWavItem == Nil
oWavItem = oTree:Add("SONIDOS",4)
oWavItem:Add( StrToken( oTxtFile:cLine, 1 ), 13, {|| oGet:VarPut(aWavItem[Nivel()]), oGet:Refresh() })
ELSE
oWavItem:Add( StrToken( oTxtFile:cLine, 1 ), 13, {|| oGet:VarPut(aWavItem[Nivel()]), oGet:Refresh() })
ENDIF
ENDIF
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "AVI"
AADD(aVidItem,ALLTRIM(StrToken(oTxtFile:cLine, 3)))
IF oVidItem == Nil
oVidItem = oTree:Add("VIDEOS",5)
oVidItem:Add( StrToken( oTxtFile:cLine, 1 ), 14, {|| oGet:VarPut(aVidItem[Nivel()]), oGet:Refresh() })
ELSE
oVidItem:Add( StrToken( oTxtFile:cLine, 1 ), 14, {|| oGet:VarPut(aVidItem[Nivel()]), oGet:Refresh() })
ENDIF
ENDIF
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "CURSOR"
AADD(aCurItem,ALLTRIM(StrToken(oTxtFile:cLine, 3)))
IF oCurItem == Nil
oCurItem = oTree:Add("CURSORES",6)
oCurItem:Add( StrToken( oTxtFile:cLine, 1 ), 15, {|| oGet:VarPut(aCurItem[Nivel()]), oGet:Refresh() })
ELSE
oCurItem:Add( StrToken( oTxtFile:cLine, 1 ), 15, {|| oGet:VarPut(aCurItem[Nivel()]), oGet:Refresh() })
ENDIF
ENDIF
IF UPPER( StrToken( oTxtFile:cLine, 2 ) ) == "CUSTOM"
AADD(aCusItem,ALLTRIM(StrToken(oTxtFile:cLine, 3)))
IF oCusItem == Nil
oCusItem = oTree:Add("PERSONALIZADO",7)
oCusItem:Add( StrToken( oTxtFile:cLine, 1 ), 16, {|| oGet:VarPut(aCusItem[Nivel()]), oGet:Refresh() })
ELSE
oCusItem:Add( StrToken( oTxtFile:cLine, 1 ), 16, {|| oGet:VarPut(aCusItem[Nivel()]), oGet:Refresh() })
ENDIF
ENDIF
END
oTree:nDlgCode:= DLGC_WANTALLKEYS
oTree:bChanged := {|oTree,oItem| oItem:= oTree:GetSelected(), IF( oItem # nil .and. ValType( oItem:cargo ) == "B", Eval( oItem:cargo ), nil ) }
oTxtFile:END()
ENDIF
RETURN Nil
//----------------------------------------------------------------------------//
STATIC FUNCTION CierraRC()
oTree:DeleteAll()
oTree:Cargo = Nil
oTree:Refresh()
RETURN Nil
//----------------------------------------------------------------------------//
STATIC FUNCTION Nivel()
LOCAL nSel
LOCAL oItem:= oTree:GetSelected()
/*MSGInfo( "Item Numero: " + STR( oItem:ItemLevel() ) + CRLF + ;
"Prompt: " + oItem:cPrompt + CRLF + ;
"Posicion: " + STR( SearchItemAt( oItem:cPrompt, .F., oItem ) ) + CRLF + ;
"Encontrado: " + IF( SearchItemAt( oItem:cPrompt, .T., oItem )," SI", " NO" ) )*/
nSel:= SearchItemAt( oItem:cPrompt, .F., oItem )
RETURN nSel
//----------------------------------------------------------------------------//
STATIC FUNCTION SearchItemAt( cItem, lItem, oTr )
LOCAL nPos := 0
LOCAL lSw := .F.
DEFAULT lItem := .F.
IF !EMPTY( oTr )
nPos := ASCAN( oTr:oParent:aItems, { | o | UPPER( cItem ) $ UPPER( o:cPrompt ) } )
IF nPos > 0
lSw:= .T.
ENDIF
ENDIF
RETURN IF( lItem, lSw, nPos )