Skip to content

Commit

Permalink
Added source code to DBP IDE. You will need a legacy version of the B…
Browse files Browse the repository at this point in the history
…CG API to complete the compile, as we are unable to release this as open source. Alternatively the BCG dependence could be removed or amended to support the latest version of BCG currently available.
  • Loading branch information
LeeBamberTGC committed Feb 14, 2016
1 parent 210254b commit acb03d0
Show file tree
Hide file tree
Showing 179 changed files with 27,905 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Synergy Editor TGC/Synergy Editor.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Synergy Editor", "Synergy Editor\Synergy Editor.vcxproj", "{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
ReleaseNETBOOK|Win32 = ReleaseNETBOOK|Win32
Remote|Win32 = Remote|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.Debug|Win32.ActiveCfg = Debug|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.Debug|Win32.Build.0 = Debug|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.Release|Win32.ActiveCfg = Release|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.Release|Win32.Build.0 = Release|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.ReleaseNETBOOK|Win32.ActiveCfg = ReleaseNETBOOK|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.ReleaseNETBOOK|Win32.Build.0 = ReleaseNETBOOK|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.Remote|Win32.ActiveCfg = Remote|Win32
{D2157F4F-E3E2-455D-9D10-71E9A8FB78D0}.Remote|Win32.Build.0 = Remote|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
CodeStyleEnforcer_RulesLocation =
CodeStyleEnforcer_Active = 0
EndGlobalSection
EndGlobal
128 changes: 128 additions & 0 deletions Synergy Editor TGC/Synergy Editor/AdBanner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// AdBanner.cpp : implementation file
//

#include "stdafx.h"
#include "AdBanner.h"
#include "HTTPComm.h"
#include "GameCreatorStore.h"
#include <atlimage.h>


// CAdBanner

IMPLEMENT_DYNAMIC(CAdBanner, CButton)

CAdBanner::CAdBanner()
{
m_bBitmapLoaded = false;
m_bLoading = false;
}

CAdBanner::~CAdBanner()
{
}


BEGIN_MESSAGE_MAP(CAdBanner, CButton)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()

unsigned CAdBanner::Run( )
{
m_bBitmapLoaded = false;
m_bLoading = true;

CString sPath = "TGCStore\\TEMP\\AdBanner.bmp";
HTTPComm server;

//HTTP call here
bool result = server.GetPreviewImage( "HTMLImages/AdBanner.bmp", sPath );
//if ( !result ) MessageBox( server.GetLastError( ), "TGC Store Error" );
if ( !result ) return 0;

//try and load the downloaded image
SetCurrentDirectory( theApp.m_szDirectory );
CImage image;
HRESULT hr = image.Load( sPath );
if ( FAILED(hr) ) return 0;

CWindowDC wndDC( this );
CDC dc;
dc.CreateCompatibleDC( &wndDC );

//copy the image to the local bitmap
m_bmpBanner.DeleteObject( );
m_bmpBanner.CreateBitmap( image.GetWidth(),image.GetHeight(), 1, 32, NULL );
CBitmap *oldBmp = dc.SelectObject( &m_bmpBanner );

::SetStretchBltMode( image.GetDC(), HALFTONE );
::SetBrushOrgEx( image.GetDC(), 0,0, NULL );
image.BitBlt( dc.GetSafeHdc( ), 0,0 );
dc.SelectObject( oldBmp );

image.ReleaseDC();
image.ReleaseDC();

//let the control draw the bitmap now
m_bLoading = false;
m_bBitmapLoaded = true;

Invalidate( );

return 0;
}



// CAdBanner message handlers

BOOL CAdBanner::OnEraseBkgnd( CDC *pDC )
{
return FALSE;
}

void CAdBanner::OnPaint()
{
CPaintDC dc( this );

CRect rectClient;
GetClientRect( &rectClient );

//CBrush brush; brush.CreateSolidBrush( GetSysColor( COLOR_3DFACE ) );
CPen pen; pen.CreatePen( PS_SOLID, 1, RGB(0,0,0) );
dc.SelectObject( &pen );
//dc.SelectObject( &brush );
dc.SelectStockObject( NULL_BRUSH );
dc.Rectangle( &rectClient );

if ( m_bBitmapLoaded )
{
//if the bitmap is loaded
CDC bmpDC;
bmpDC.CreateCompatibleDC( &dc );
bmpDC.SelectObject( &m_bmpBanner );

BITMAP details;
m_bmpBanner.GetBitmap( &details );

int iY = 0;
if ( rectClient.Height() > details.bmHeight ) iY = (rectClient.Height() - details.bmHeight) / 2;

dc.BitBlt( 0,iY, rectClient.Width(), rectClient.Height(), &bmpDC, 0,0, SRCCOPY );
}

if ( m_bLoading )
{
//optional loading screen
dc.SelectObject( GetFont( ) );
dc.SetBkMode( OPAQUE );
dc.SetBkColor( GetSysColor( COLOR_3DFACE ) );
dc.SetTextColor( RGB(0,0,0) );

//CString sText;
//GetWindowText( sText );
//dc.DrawText( GetLanguageData( _T("TGC Store"), _T("PleaseWait") ), -1, &rectClient, DT_CENTER | DT_SINGLELINE | DT_VCENTER );
//sText.ReleaseBuffer( );
}
}
29 changes: 29 additions & 0 deletions Synergy Editor TGC/Synergy Editor/AdBanner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "Thread.h"

// CAdBanner

class CAdBanner : public CButton, public Thread
{
DECLARE_DYNAMIC(CAdBanner)

public:
CAdBanner();
virtual ~CAdBanner();

void SetLoading( bool loading ) { m_bLoading = loading; Invalidate(); }

protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd( CDC *pDC );

unsigned Run( );

CBitmap m_bmpBanner;
bool m_bBitmapLoaded;
bool m_bLoading;
};


165 changes: 165 additions & 0 deletions Synergy Editor TGC/Synergy Editor/AdvertThread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Includes
#include "stdafx.h"
#include "AdvertThread.h"
#include "Synergy Editor.h"
#include "Utilities.h"
#include "Settings.h"
#include "direct.h"
#include "io.h"
#include "httpcomm.h"

// Defines
#define _CRT_SECURE_NO_WARNINGS

// Globals
bool g_bUsingAdvertising = false;
bool g_bUsingAdvertisingLoaded = false;
LONGLONG g_lUsingAdvertisingTimeStamp = 0;

// this code is called by the thread (independent of the main code)
unsigned CAdvertThread::Run( )
{
// are we free or full version user
g_bUsingAdvertising = IsFreeVersion();

// end thread
return 0;
}
CAdvertThread::CAdvertThread()
{
}
CAdvertThread::~CAdvertThread()
{
}
bool CAdvertThread::IsCertificateFree ( LPSTR pCertificate )
{
// connection details (default is free)
LPSTR pServer = "www.darkbasic.com";
LPSTR pPage = "tgco/isfree.php";

// init connection
HTTP_Connect ( pServer );

// prepare data to post
LPSTR pPostData = new char [ 256 ];
strcpy ( pPostData, "c=12345678901234567890123456789012" );
strcpy ( pPostData, "c=" );
strcat ( pPostData, pCertificate );
DWORD dwPostDataSize = strlen (pPostData);

// prepare header
LPSTR pHeader = new char[256];
sprintf ( pHeader, "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n", dwPostDataSize );
DWORD dwHeaderSize = -1L;

// issue request and get data back
LPSTR pData = HTTP_RequestData ( "POST", pPage, pHeader, dwHeaderSize, pPostData, dwPostDataSize );

// free usages
if ( pHeader )
{
delete pHeader;
pHeader=NULL;
}
if ( pPostData )
{
delete pPostData;
pPostData=NULL;
}

// free connection
HTTP_Disconnect();

// calculate result
bool bIsFree = true;
if ( pData )
{
if ( strcmp ( pData, "0" )==NULL ) bIsFree = false;
delete pData;
}

// return if free version
return bIsFree;
}
bool CAdvertThread::IsFreeVersion ( void )
{
// scan certificates folder for DBP certificate, then send it to server
// to see if we are using a free or paid-up version
bool bFree = true;

// find certificate folder and switch to it
char pOldDir [ _MAX_PATH ];
_getcwd ( pOldDir, _MAX_PATH );
CString pCertFolder = Settings::DBPLocation + L"Compiler\\certificates\\";
SetCurrentDirectory ( pCertFolder );

// find DBP certificate
_finddata_t filedata;
long hInternalFile = _findfirst("*.*", &filedata);
if(hInternalFile!=-1L)
{
int FileReturnValue = 0;
bool bContainsDBPString = false;
while ( FileReturnValue==0 && bFree==true )
{
if( !(filedata.attrib & _A_SUBDIR) )
{
char pFilename[256];
strcpy ( pFilename, filedata.name );
if ( pFilename )
{
if ( strlen(pFilename)==32 )
{
// found certificate file, read it to check if DBP certificate
HANDLE hFile = NULL;
DWORD dwBytesRead = 0;
hFile = CreateFileA ( pFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
if ( hFile != INVALID_HANDLE_VALUE )
{
DWORD dwFileSize = GetFileSize ( hFile, NULL );
LPSTR pFileData = new char[dwFileSize];
if ( pFileData )
{
ReadFile ( hFile, pFileData, dwFileSize, &dwBytesRead, NULL );
for ( DWORD n=0; n<dwFileSize; n++ )
{
if ( strnicmp ( pFileData + n, "Dark Basic Professional", 22 )==NULL )
{
// if it terminates
LPSTR pEndChar = pFileData + n + 23;
if ( *(pEndChar)==0 || *(pEndChar)==10 || *(pEndChar)==13 )
{
bContainsDBPString=true;
break;
}
}
}
delete pFileData;
if ( bContainsDBPString==true )
{
// found DBP certificate, is it a paid-up version?
if ( IsCertificateFree ( pFilename )==false )
{
// not free, so remove advertising
bFree = false;
}
}
}
CloseHandle ( hFile );
hFile = NULL;
}
}
}
}
FileReturnValue = _findnext(hInternalFile, &filedata);
}
_findclose(hInternalFile);
hInternalFile=NULL;
}

// restore folder
_chdir ( pOldDir );

// return result
return bFree;
}
17 changes: 17 additions & 0 deletions Synergy Editor TGC/Synergy Editor/AdvertThread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "stdafx.h"
#include "thread.h"

#pragma once

class CAdvertThread : public Thread
{
public:
CAdvertThread();
virtual ~CAdvertThread();

public:
unsigned Run( );
bool IsCertificateFree ( LPSTR pCertificate );
bool IsFreeVersion();

};
Loading

0 comments on commit acb03d0

Please sign in to comment.