From 9126fad01bb7d11bb9a7be9794817e84f8e56bed Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 11 Nov 2009 15:16:02 +0000 Subject: [PATCH] Resource file fixes - and added resource file generation for ActiveX plugin --- makepanda/makepanda.py | 70 ++++++++++++++++++++++++++++++++++++++ makepanda/makepandacore.py | 42 +++++++++++++---------- 2 files changed, 94 insertions(+), 18 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index cb72dba73a..4ca4f3eb85 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1434,6 +1434,66 @@ static int check_panda_version = panda_version_$VERSION1_$VERSION2_$VERSION3; # endif """ +P3DACTIVEX_RC="""#include "resource.h" +#define APSTUDIO_READONLY_SYMBOLS +#include "afxres.h" +#undef APSTUDIO_READONLY_SYMBOLS +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif +#ifdef APSTUDIO_INVOKED +1 TEXTINCLUDE +BEGIN + "resource.h\\0" +END +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\\r\\n" + "\\0" +END +3 TEXTINCLUDE +BEGIN + "1 TYPELIB ""P3DActiveX.tlb""\\r\\n" + "\\0" +END +#endif +%s +IDB_P3DACTIVEX BITMAP "P3DActiveXCtrl.bmp" +IDD_PROPPAGE_P3DACTIVEX DIALOG 0, 0, 250, 62 +STYLE DS_SETFONT | WS_CHILD +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "TODO: Place controls to manipulate properties of P3DActiveX Control on this dialog.", + IDC_STATIC,7,25,229,16 +END +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_PROPPAGE_P3DACTIVEX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 243 + TOPMARGIN, 7 + BOTTOMMARGIN, 55 + END +END +#endif +STRINGTABLE +BEGIN + IDS_P3DACTIVEX "P3DActiveX Control" + IDS_P3DACTIVEX_PPG "P3DActiveX Property Page" +END +STRINGTABLE +BEGIN + IDS_P3DACTIVEX_PPG_CAPTION "General" +END +#endif +#ifndef APSTUDIO_INVOKED +1 TYPELIB "P3DActiveX.tlb" +#endif""" + def CreatePandaVersionFiles(): version1=int(VERSION.split(".")[0]) version2=int(VERSION.split(".")[1]) @@ -1477,6 +1537,16 @@ def CreatePandaVersionFiles(): ConditionalWriteFile(GetOutputDir()+'/include/checkPandaVersion.cxx', checkpandaversion_cxx) ConditionalWriteFile(GetOutputDir()+'/include/checkPandaVersion.h', checkpandaversion_h) ConditionalWriteFile(GetOutputDir()+"/tmp/null.cxx","") + + if RUNTIME: + p3dactivex_rc = {"name" : "Panda3D Game Engine Plug-in", + "version" : VERSION, + "description" : "Runs 3-D games and interactive applets", + "filename" : "p3dactivex.ocx", + "mimetype" : "application/x-panda3d", + "extension" : "p3d", + "filedesc" : "Panda3D applet"} + ConditionalWriteFile(GetOutputDir()+"/include/P3DActiveX.rc", P3DACTIVEX_RC % GenerateResourceFile(**p3dactivex_rc)) CreatePandaVersionFiles() diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 072189651e..18cb0ad04f 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1600,15 +1600,11 @@ def ParsePluginVersion(fn): # ########################################################################################## -RESOURCE_FILE_TEMPLATE = """#define APSTUDIO_READONLY_SYMBOLS -#include "winresrc.h" -#undef APSTUDIO_READONLY_SYMBOLS - -VS_VERSION_INFO VERSIONINFO +RESOURCE_FILE_TEMPLATE = """VS_VERSION_INFO VERSIONINFO FILEVERSION %(commaversion)s PRODUCTVERSION %(commaversion)s FILEFLAGSMASK 0x3fL - FILEFLAGS $(debugflag)s + FILEFLAGS %(debugflag)s FILEOS 0x40004L FILETYPE 0x2L FILESUBTYPE 0x0L @@ -1617,14 +1613,15 @@ BEGIN BEGIN BLOCK "040904e4" BEGIN - VALUE "FileDescription", "%(description)s\0" + VALUE "FileDescription", "%(description)s\\0" VALUE "FileVersion", "%(dotversion)s" - VALUE "LegalTrademarks", "\0" - VALUE "MIMEType", "%(mimetype)s\0" - VALUE "FileExtents", "%(extension)s\0" - VALUE "FileOpenName", "%(filedesc)s\0" - VALUE "OriginalFilename", "%(filename)s\0" - VALUE "ProductName", "%(name)s %(version)s\0" + VALUE "LegalTrademarks", "\\0" + VALUE "MIMEType", "%(mimetype)s\\0" + VALUE "FileExtents", "%(extension)s\\0" + VALUE "FileOpenName", "%(filedesc)s\\0" + VALUE "OLESelfRegister", "\\0" + VALUE "OriginalFilename", "%(filename)s\\0" + VALUE "ProductName", "%(name)s %(version)s\\0" VALUE "ProductVersion", "%(dotversion)s" END END @@ -1635,7 +1632,7 @@ BEGIN END """ -def GenerateResourceFile(basename, **kwargs): +def GenerateResourceFile(**kwargs): if "debugflag" not in kwargs: if GetOptimize() <= 2: kwargs["debugflag"] = "0x1L" @@ -1647,15 +1644,24 @@ def GenerateResourceFile(basename, **kwargs): if "commaversion" not in kwargs: kwargs["commaversion"] = kwargs["dotversion"].replace(".", ",") - rcdata = RESOURCE_FILE_TEMPLATE % kwargs + rcdata = "" + if not "noinclude" in kwargs: + rcdata += "#define APSTUDIO_READONLY_SYMBOLS\n" + rcdata += "#include \"winresrc.h\"\n" + rcdata += "#undef APSTUDIO_READONLY_SYMBOLS\n" + rcdata += RESOURCE_FILE_TEMPLATE % kwargs if "icon" in kwargs: rcdata += "\nICON_FILE ICON \"%s\"\n" % kwargs["icon"] + return rcdata + + +def WriteResourceFile(basename, **kwargs): if not basename.endswith(".rc"): basename += ".rc" basename = GetOutputDir() + "/include/" + basename - ConditionalWriteFile(basename, rcdata) + ConditionalWriteFile(basename, GenerateResourceFile(**kwargs)) return basename ######################################################################## @@ -1828,12 +1834,12 @@ def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0, winrc=0): if (SUFFIX_INC.count(suffix)): for d in CxxCalcDependencies(fullinput, ipath, []): t.deps[d] = 1 - if (dep != 0): + if (dep != 0): for x in dep: fulldep = FindLocation(x, ipath) t.deps[fulldep] = 1 if (winrc != 0 and sys.platform.startswith("win")): - t.deps[GenerateResourceFile(target.split("/")[-1].split(".")[0], **winrc)] = 1 + TargetAdd(target, input=WriteResourceFile(target.split("/")[-1].split(".")[0], **winrc)) if (target.endswith(".in")): t.deps[FindLocation("interrogate.exe",[])] = 1 t.deps[FindLocation("dtool_have_python.dat",[])] = 1