26#include "wx/cmdline.h"
27#include "wx/filename.h"
29#include "wx/stdpaths.h"
52 window->SetWindowStyleFlag(wxDEFAULT_FRAME_STYLE | wxMAXIMIZE);
54 window->SetWindowStyleFlag(wxDEFAULT_FRAME_STYLE & ~wxMAXIMIZE);
62 std::string name = windowName;
65 window->GetClientSize(&width, &height);
67 Ogre::NameValuePairList params;
71 bool vsync = vm->GetHAL()->GetConfigBool(vm->GetHAL()->configfile,
"Skyscraper.Frontend.Vsync",
true);
73 params[
"vsync"] =
"true";
75 params[
"vsync"] =
"false";
76 params[
"vsyncInterval"] =
"1";
77 params[
"externalWindowHandle"] = getOgreHandle();
80 params[
"macAPI"] =
"cocoa";
81 params[
"macAPICocoaUseNSView"] =
"true";
84 return vm->GetHAL()->CreateRenderWindow(name, width, height, params);
93 wxString exefile = wxStandardPaths::Get().GetExecutablePath();
94 wxString app_path = wxPathOnly(exefile);
98 if (!wxDirExists(vm->data_path))
99 wxMkdir(vm->data_path);
101 if (!wxDirExists(vm->data_path + wxT(
"buildings")))
102 wxMkdir(vm->data_path + wxT(
"buildings"));
103 if (!wxDirExists(vm->data_path + wxT(
"data")))
104 wxMkdir(vm->data_path + wxT(
"data"));
105 if (!wxDirExists(vm->data_path + wxT(
"screenshots")))
106 wxMkdir(vm->data_path + wxT(
"screenshots"));
108 wxSetWorkingDirectory(app_path + wxT(
"/../Resources"));
110 if (!wxFileExists(vm->data_path + wxT(
"skyscraper.ini")))
111 wxCopyFile(
"skyscraper.ini", vm->data_path + wxT(
"skyscraper.ini"));
112 if (!wxFileExists(vm->data_path + wxT(
"keyboard.ini")))
113 wxCopyFile(
"keyboard.ini", vm->data_path + wxT(
"keyboard.ini"));
114 if (!wxFileExists(vm->data_path + wxT(
"joystick.ini")))
115 wxCopyFile(
"joystick.ini", vm->data_path + wxT(
"joystick.ini"));
117#elif defined (__WXGTK__)
118 wxSetWorkingDirectory(app_path + wxT(
"/../"));
120 wxSetWorkingDirectory(app_path);
124 static const wxCmdLineEntryDesc cmdLineDesc[] =
126 { wxCMD_LINE_SWITCH,
"h",
"help",
"show this help message",
127 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
129 { wxCMD_LINE_SWITCH,
"c",
"no-console",
"hide the console",
130 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
132 { wxCMD_LINE_SWITCH,
"f",
"fullscreen",
"start up in full-screen mode",
133 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
135 { wxCMD_LINE_SWITCH,
"k",
"check-script",
"quickly check building script, and exit after",
136 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
138 { wxCMD_LINE_SWITCH,
"m",
"no-menu",
"hide the main menu",
139 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
141 { wxCMD_LINE_SWITCH,
"M",
"no-music",
"disable the intro music",
142 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
144 { wxCMD_LINE_SWITCH,
"p",
"no-panel",
"hide the control panel",
145 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
147 { wxCMD_LINE_SWITCH,
"v",
"verbose",
"enable verbose mode",
148 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
150 { wxCMD_LINE_SWITCH,
"V",
"version",
"show version",
151 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
153 { wxCMD_LINE_PARAM, NULL, NULL,
"building filename",
154 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
160 parser =
new wxCmdLineParser(cmdLineDesc, argc, argv);
163 switch (parser->Parse())
174 wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED);
181#if defined(__WXMSW__)
183 return Ogre::StringConverter::toString((
size_t)((HWND)window->panel->GetHandle()));
184#elif defined(__WXGTK__)
192 GtkWidget* privHandle = window->m_wxwindow;
197 gtk_widget_realize(privHandle);
200 GdkWindow* gdkWin = gtk_widget_get_window((GtkWidget*)window->GetHandle());
201 Display* display = GDK_WINDOW_XDISPLAY(gdkWin);
202 Window wid = GDK_WINDOW_XID(gdkWin);
205 std::string screenStr = DisplayString(display);
206 screenStr = screenStr.substr(screenStr.find(
".") + 1, screenStr.size());
208 std::stringstream handleStream;
209 handleStream << (
unsigned long)display <<
':' << screenStr <<
':' << wid;
213 int attrlist[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16, GLX_STENCIL_SIZE, 8, None };
214 XVisualInfo* vi = glXChooseVisual(display, DefaultScreen(display), attrlist);
215 handleStream <<
':' << (
unsigned long)vi;
217 return std::string(handleStream.str());
219#elif defined(__WXMAC__)
220 return Ogre::StringConverter::toString((
size_t)window->MacGetTopLevelWindowRef());
222 #error Not supported on this platform!
Ogre::RenderWindow * CreateRenderWindow(const Ogre::NameValuePairList *miscParams=0, const std::string &windowName="")
const std::string getOgreHandle() const
void AllowResize(bool value)
std::string settingsPath()