1
1
forked from 0ad/0ad

# Fixes for MSVC

Use _WIN32/__WXMSW__ instead of OS_WIN.

This was SVN commit r4668.
This commit is contained in:
Ykkrosh 2006-12-01 20:34:28 +00:00
parent 42803552bf
commit 4d8133f785
15 changed files with 103 additions and 93 deletions

View File

@ -413,7 +413,7 @@ function setup_main_exe ()
"/ENTRY:entry",
-- delay loading of various Windows DLLs (not specific to any of the
-- external libraries; those and handled separately)
-- external libraries; those are handled separately)
"/DELAYLOAD:oleaut32.dll",
"/DELAYLOAD:advapi32.dll",
"/DELAYLOAD:user32.dll",
@ -584,8 +584,6 @@ local function setup_atlas_frontend_package (package_name)
package.trimprefix = source_root
package.includepaths = { source_root .. ".." }
package_add_extern_libs(used_extern_libs)
-- Platform Specifics
if OS == "windows" then
tinsert(package.defines, "_UNICODE")

0
build/workspaces/update-workspaces.bat Executable file → Normal file
View File

View File

@ -183,7 +183,7 @@ void CTerrainProperties::ReadPassability(bool passable, XMBElement node, CXeromy
#undef ATTR
STerrainPassability pass(passable);
bool hasType;
bool hasType = false;
bool hasSpeed;
XMBAttributeList attribs = node.getAttributes();
for (int i=0;i<attribs.Count;i++)

View File

@ -1,4 +1,4 @@
#if OS_WIN
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@ -15,11 +15,12 @@
#include "AtlasUI/Misc/DLLInterface.h"
#if OS_WIN
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
#ifdef _WIN32
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
#else
int main() {
int main()
#endif
{
Atlas_StartWindow(L"ActorEditor");
return 0;
}

View File

@ -1,4 +1,4 @@
#if OS_WIN
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@ -15,11 +15,12 @@
#include "AtlasUI/Misc/DLLInterface.h"
#if OS_WIN
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
#ifdef _WIN32
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
#else
int main() {
int main()
#endif
{
Atlas_StartWindow(L"ArchiveViewer");
return 0;
}

View File

@ -1,4 +1,4 @@
#if OS_WIN
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@ -15,11 +15,12 @@
#include "AtlasUI/Misc/DLLInterface.h"
#if OS_WIN
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
#ifdef _WIN32
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
#else
int main() {
int main()
#endif
{
Atlas_StartWindow(L"ColourTester");
return 0;
}

View File

@ -1,4 +1,4 @@
#if OS_WIN
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@ -15,11 +15,12 @@
#include "AtlasUI/Misc/DLLInterface.h"
#if OS_WIN
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
#ifdef _WIN32
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
#else
int main() {
int main()
#endif
{
Atlas_StartWindow(L"FileConverter");
return 0;
}

View File

@ -1,4 +1,4 @@
#if OS_WIN
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@ -15,11 +15,12 @@
#include "AtlasUI/Misc/DLLInterface.h"
#if OS_WIN
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
#ifdef _WIN32
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
#else
int main() {
int main()
#endif
{
Atlas_StartWindow(L"$$WINDOW_NAME$$");
return 0;
}

View File

@ -191,7 +191,7 @@ ActorViewer::ActorViewer(wxWindow* parent)
splitter->SplitVertically(sidePanel, canvas);
#if OS_WIN
#ifdef __WXMSW__
wglMakeCurrent(NULL, NULL);
#endif
POST_MESSAGE(SetContext, (canvas->GetContext()));

View File

@ -16,11 +16,11 @@ using namespace DatafileIO;
#include "wx/confbase.h"
#include "wx/wfstream.h"
#include "wx/tooltip.h"
#ifdef _WIN32
#include "wx/msw/registry.h"
#endif
#include "wx/progdlg.h"
#include "wx/regex.h"
#ifdef __WXMSW__
# include "wx/msw/registry.h"
#endif
// Possible TODO: Remove duplication of AtlasWindow code

View File

@ -2,15 +2,12 @@
#include "HighResTimer.h"
#ifndef _WIN32
#include <sys/time.h>
#endif
// TODO: Better accuracy and reliability, if necessary.
// TODO: Portability and general betterness. (But it's good enough for now.)
#ifdef __WXMSW__
HighResTimer::HighResTimer()
{
#ifdef _WIN32
LARGE_INTEGER freq;
BOOL ok = QueryPerformanceFrequency(&freq);
if (! ok)
@ -21,12 +18,10 @@ HighResTimer::HighResTimer()
{
m_TickLength = freq.QuadPart;
}
#endif
}
double HighResTimer::GetTime()
{
#ifdef _WIN32
LARGE_INTEGER count;
BOOL ok = QueryPerformanceCounter(&count);
if (! ok)
@ -35,9 +30,21 @@ double HighResTimer::GetTime()
return 0.0;
}
return (double)count.QuadPart / (double)m_TickLength.GetValue();
#else
}
#else // not __WXMSW__ :
#include <sys/time.h>
HighResTimer::HighResTimer()
{
}
double HighResTimer::GetTime()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec+(tv.tv_usec/1000000.0);
#endif
}
#endif

View File

@ -12,10 +12,6 @@
class SaveOnExitDialog : public wxDialog
{
#ifndef _WIN32
#define EndDialog EndModal
#endif
public:
SaveOnExitDialog(wxWindow* parent, bool allowCancel)
: wxDialog(parent, wxID_ANY, (wxString) _("Save changes?"))
@ -43,8 +39,8 @@ public:
sizer->SetSizeHints(this);
}
void OnSave(wxCommandEvent& WXUNUSED(event)) { EndDialog(wxID_SAVE); }
void OnNo(wxCommandEvent& WXUNUSED(event)) { EndDialog(wxID_NO); }
void OnSave(wxCommandEvent& WXUNUSED(event)) { EndModal(wxID_SAVE); }
void OnNo(wxCommandEvent& WXUNUSED(event)) { EndModal(wxID_NO); }
DECLARE_EVENT_TABLE();
};

View File

@ -42,7 +42,8 @@ namespace AtlasMessage
// Global variables, to remember state between DllMain and StartWindow and OnInit
wxString g_InitialWindowType;
bool g_IsLoaded = false;
#ifdef _WIN32
#ifdef __WXMSW__
HINSTANCE g_Module;
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved))
@ -64,7 +65,7 @@ BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpRese
return TRUE;
}
#endif
#endif // __WXMSW__
using namespace AtlasMessage;
@ -78,11 +79,12 @@ ATLASDLLIMPEXP void Atlas_SetMessagePasser(MessagePasser* passer)
ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
{
g_InitialWindowType = type;
#ifdef _WIN32
#ifdef __WXMSW__
wxEntry(g_Module);
#else
int argc=1;
char *argv[]={"atlas", NULL};
int argc = 1;
char *argv[] = {"atlas", NULL};
wxEntry(argc, argv);
#endif
}
@ -165,49 +167,6 @@ public:
return true;
}
bool OpenDirectory(const wxString& dir)
{
#ifdef _WIN32
// Code largely copied from wxLaunchDefaultBrowser:
// (TODO: portability)
typedef HINSTANCE (WINAPI *LPShellExecute)(HWND hwnd, const wxChar* lpOperation,
const wxChar* lpFile,
const wxChar* lpParameters,
const wxChar* lpDirectory,
INT nShowCmd);
HINSTANCE hShellDll = ::LoadLibrary(_T("shell32.dll"));
if (hShellDll == NULL)
return false;
LPShellExecute lpShellExecute =
(LPShellExecute) ::GetProcAddress(hShellDll,
wxString(_T("ShellExecute")
#ifdef _UNICODE
_T("W")
#else
_T("A")
#endif
).mb_str(wxConvLocal));
if (lpShellExecute == NULL)
return false;
/*HINSTANCE nResult =*/ (*lpShellExecute)(NULL, _T("explore"), dir.c_str(), NULL, NULL, SW_SHOWNORMAL);
// ignore return value, since we're not going to do anything if this fails
::FreeLibrary(hShellDll);
return true;
#else
// Figure out what goes for "default browser" on unix/linux/whatever
// open an xterm perhaps? :)
return false;
#endif
}
virtual void OnFatalException()
{
wxDebugReport report;
@ -240,6 +199,51 @@ public:
}
*/
private:
bool OpenDirectory(const wxString& dir)
{
// Open a directory on the filesystem - used so people can find the
// debug report files generated in OnFatalException easily
#ifdef __WXMSW__
// Code largely copied from wxLaunchDefaultBrowser:
typedef HINSTANCE (WINAPI *LPShellExecute)(HWND hwnd, const wxChar* lpOperation,
const wxChar* lpFile,
const wxChar* lpParameters,
const wxChar* lpDirectory,
INT nShowCmd);
HINSTANCE hShellDll = ::LoadLibrary(_T("shell32.dll"));
if (hShellDll == NULL)
return false;
LPShellExecute lpShellExecute =
(LPShellExecute) ::GetProcAddress(hShellDll,
wxString(_T("ShellExecute")
# ifdef _UNICODE
_T("W")
# else
_T("A")
# endif
).mb_str(wxConvLocal));
if (lpShellExecute == NULL)
return false;
/*HINSTANCE nResult =*/ (*lpShellExecute)(NULL, _T("explore"), dir.c_str(), NULL, NULL, SW_SHOWNORMAL);
// ignore return value, since we're not going to do anything if this fails
::FreeLibrary(hShellDll);
return true;
#else
// Figure out what goes for "default browser" on unix/linux/whatever
// open an xterm perhaps? :)
return false;
#endif
}
};
IMPLEMENT_APP_NO_MAIN(AtlasDLLApp)

View File

@ -383,7 +383,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
Canvas* canvas = new GameCanvas(m_SectionLayout.GetCanvasParent(), glAttribList);
m_SectionLayout.SetCanvas(canvas);
#ifdef _WIN32
#ifdef __WXMSW__
// The canvas' context gets made current on creation; but it can only be
// current for one thread at a time, and it needs to be current for the
// thread that is doing the draw calls, so disable it for this one.