forked from vpinball/vpinball
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
259 lines (209 loc) · 8.09 KB
/
main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#pragma once
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#ifdef ENABLE_SDL
#include <d3d11_1.h>
#include <dxgi1_2.h>
#pragma comment(lib,"d3d11.lib")
#pragma comment(lib,"dxgi.lib")
#endif
#include <windows.h>
#include <mmsystem.h>
#ifdef USE_DINPUT8
#define DIRECTINPUT_VERSION 0x0800
#else
#define DIRECTINPUT_VERSION 0x0700
#endif
#include <dinput.h>
#ifndef ENABLE_SDL
#ifdef _DEBUG
#define D3D_DEBUG_INFO
#endif
#include "minid3d9.h"
#endif
#include <dsound.h>
//#include <richedit.h>
//#include <atlcom.h>
#include <atlbase.h>
//#include <atlhost.h>
#include <atlctl.h>
//#include <cassert>
//#include <commctrl.h>
//#include <cstdio>
//#include "wchar.h"
#ifdef _MSC_VER
#define PATH_SEPARATOR_CHAR '\\'
#define PATH_SEPARATOR_WCHAR L'\\'
#define PATH_TABLES ("c:"s + PATH_SEPARATOR_CHAR + "Visual Pinball" + PATH_SEPARATOR_CHAR + "tables" + PATH_SEPARATOR_CHAR)
#define PATH_SCRIPTS ("c:"s + PATH_SEPARATOR_CHAR + "Visual Pinball" + PATH_SEPARATOR_CHAR + "scripts" + PATH_SEPARATOR_CHAR)
#define PATH_MUSIC ("c:"s + PATH_SEPARATOR_CHAR + "Visual Pinball" + PATH_SEPARATOR_CHAR + "music" + PATH_SEPARATOR_CHAR)
#define PATH_USER ("c:"s + PATH_SEPARATOR_CHAR + "Visual Pinball" + PATH_SEPARATOR_CHAR + "user" + PATH_SEPARATOR_CHAR)
#else
#define PATH_SEPARATOR_CHAR '/'
#define PATH_SEPARATOR_WCHAR L'/'
#define PATH_TABLES (string(getenv("HOME")) + PATH_SEPARATOR_CHAR + ".vpinball" + PATH_SEPARATOR_CHAR + "tables" + PATH_SEPARATOR_CHAR)
#define PATH_SCRIPTS (string(getenv("HOME")) + PATH_SEPARATOR_CHAR + ".vpinball" + PATH_SEPARATOR_CHAR + "scripts" + PATH_SEPARATOR_CHAR)
#define PATH_MUSIC (string(getenv("HOME")) + PATH_SEPARATOR_CHAR + ".vpinball" + PATH_SEPARATOR_CHAR + "music" + PATH_SEPARATOR_CHAR)
#define PATH_USER (string(getenv("HOME")) + PATH_SEPARATOR_CHAR + ".vpinball" + PATH_SEPARATOR_CHAR + "user" + PATH_SEPARATOR_CHAR)
#endif
#include <oleauto.h>
#include <wincrypt.h>
#include <intrin.h>
#if defined(_M_IX86) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
#define ENABLE_SSE_OPTIMIZATIONS
#include <xmmintrin.h>
#elif (defined(_M_ARM) || defined(_M_ARM64) || defined(__arm__) || defined(__arm64__) || defined(__aarch64__)) && (!defined(__ARM_ARCH) || __ARM_ARCH >= 7) && (!defined(_MSC_VER) || defined(__clang__)) //!! disable sse2neon if MSVC&non-clang
#define ENABLE_SSE_OPTIMIZATIONS
#include "sse2neon.h"
#endif
#include <vector>
#include <string>
#include <algorithm>
#include <commdlg.h>
using namespace std::string_literals;
using std::string;
using std::wstring;
using std::vector;
// try to load the file from the current directory
// if that fails, try the User, Scripts and Tables sub-directorys under where VP was loaded from
// if that also fails, try the standard installation path
static const string defaultFileNameSearch[] = { string(), string(), string(), string(), PATH_USER, PATH_SCRIPTS, PATH_TABLES };
static const string defaultPathSearch[] = { string(), "user"s +PATH_SEPARATOR_CHAR, "scripts"s +PATH_SEPARATOR_CHAR, "tables"s +PATH_SEPARATOR_CHAR, string(), string(), string() };
#include <dlgs.h>
#include <cderr.h>
#include <wxx_appcore.h> // Add CCriticalSection, CObject, CWinThread, CWinApp
//#include <wxx_archive.h> // Add CArchive
#include <wxx_commondlg.h> // Add CCommonDialog, CColorDialog, CFileDialog, CFindReplace, CFontDialog
#include <wxx_scrollview.h>
//#include <wxx_controls.h> // Add CAnimation, CComboBox, CComboBoxEx, CDateTime, CHeader, CHotKey, CIPAddress, CProgressBar, CSpinButton, CScrollBar, CSlider, CToolTip
//#include <wxx_cstring.h> // Add CString, CStringA, CStringW
//#include <wxx_ddx.h> // Add CDataExchange
//#include <wxx_dialog.h> // Add CDialog, CResizer
//#include <wxx_dockframe.h> // Add CDockFrame, CMDIDockFrame
//#include <wxx_docking.h> // Add CDocker, CDockContainer
//#include <wxx_exception.h> // Add CException, CFileException, CNotSupportedException, CResourceException, CUserException, CWinException
//#include <wxx_file.h> // Add CFile
//#include <wxx_frame.h> // Add CFrame
//#include <wxx_gdi.h> // Add CDC, CGDIObject, CBitmap, CBrush, CFont, CPalatte, CPen, CRgn
//#include <wxx_imagelist.h> // Add CImageList
#include <wxx_listview.h> // Add CListView
//#include <wxx_mdi.h> // Add CMDIChild, CMDIFrame, CDockMDIFrame
//#include <wxx_printdialogs.h> // Add CPageSetupDialog, CPrintSetupDialog
//#include <wxx_propertysheet.h> // Add CPropertyPage, CPropertySheet
//#include <wxx_rebar.h> // Add CRebar
//#include <wxx_regkey.h> // Add CRegKey
//#include <wxx_ribbon.h> // Add CRibbon, CRibbonFrame
#include <wxx_richedit.h> // Add CRichEdit
//#include <wxx_shared_ptr.h> // Add Shared_Ptr
//#include <wxx_socket.h> // Add CSocket
//#include <wxx_statusbar.h> // Add CStatusBar
//#include <wxx_stdcontrols.h> // Add CButton, CEdit, CListBox
//#include <wxx_tab.h> // Add CTab, CTabbedMDI
//#include <wxx_taskdialog.h> // Add CTaskDialog
//#include <wxx_time.h> // Add CTime
//#include <wxx_toolbar.h> // Add CToolBar
#include <wxx_treeview.h> // Add CTreeView
//#include <wxx_webbrowser.h> // Add CAXWindow, CWebBrowser
#include <wxx_wincore.h>
#define PLOG_OMIT_LOG_DEFINES
#define PLOG_NO_DBG_OUT_INSTANCE_ID 1
#include <plog/Log.h>
#include "helpers.h"
#include "def.h"
#include "math/math.h"
#include "math/vector.h"
#include "math/matrix.h"
#include "math/bbox.h"
#include "resource.h"
#include "memutil.h"
#include "disputil.h"
#include "dispid.h"
#include "variant.h"
#include "vector.h"
#include "vectorsort.h"
#include "vpinball.h"
#include "core/Settings.h"
#include "idebug.h"
#include "wintimer.h"
#include "eventproxy.h"
#include "worker.h"
#include "audio/audioplayer.h"
#include "media/fileio.h"
#include "pinundo.h"
#include "iselect.h"
#include "ieditable.h"
#include "codeview.h"
#include "media/lzwreader.h"
#include "media/lzwwriter.h"
#include "audio/wavread.h"
#include "audio/pinsound.h"
#include "pinbinary.h"
#include "extern.h"
#include "vpinball_h.h"
#include "parts/pintable.h"
#include "mesh.h"
#include "physics/collide.h"
#include "pin3d.h"
#include "sur.h"
#include "paintsur.h"
#include "hitsur.h"
#include "hitrectsur.h"
#include "parts/ball.h"
#include "physics/collideex.h"
#include "physics/hitball.h"
#include "physics/hittimer.h"
#include "physics/hitable.h"
#include "physics/hitflipper.h"
#include "physics/hitplunger.h"
#include "core/player.h"
#include "color.h"
#include "dragpoint.h"
#include "parts/timer.h"
#include "parts/flipper.h"
#include "parts/plunger.h"
#include "parts/textbox.h"
#include "parts/surface.h"
#include "parts/dispreel.h"
#include "parts/lightseq.h"
#include "parts/bumper.h"
#include "parts/trigger.h"
#include "parts/light.h"
#include "parts/kicker.h"
#include "parts/decal.h"
#include "parts/primitive.h"
#include "parts/hittarget.h"
#include "parts/gate.h"
#include "parts/spinner.h"
#include "parts/ramp.h"
#include "parts/flasher.h"
#include "parts/rubber.h"
#include "mixer.h"
#include "hid.h"
#include "plumb.h"
#include "physics/kdtree.h"
#include "slintf.h"
#include "trace.h"
inline void ShowError(const char * const sz)
{
if(g_pvp)
g_pvp->MessageBox(sz, "Visual Pinball Error", MB_OK | MB_ICONEXCLAMATION);
else
MessageBox(nullptr, sz, "Visual Pinball Error", MB_OK | MB_ICONEXCLAMATION);
}
inline void ShowError(const string& sz)
{
if(g_pvp)
g_pvp->MessageBox(sz.c_str(), "Visual Pinball Error", MB_OK | MB_ICONEXCLAMATION);
else
MessageBox(nullptr, sz.c_str(), "Visual Pinball Error", MB_OK | MB_ICONEXCLAMATION);
}
#include "editablereg.h"
__forceinline float getBGxmult()
{
return (float)g_pplayer->m_wnd_width * (float)(1.0 / EDITOR_BG_WIDTH) * g_pplayer->m_AAfactor;
}
__forceinline float getBGymult()
{
//return getBGxmult() / (((float)g_pplayer->m_screenwidth / (float)g_pplayer->m_screenheight) / (float)((double)EDITOR_BG_WIDTH / EDITOR_BG_HEIGHT));
return getBGxmult() / (((float)g_pplayer->m_wnd_width / (float)g_pplayer->m_wnd_height) / (float)((double)EDITOR_BG_WIDTH / EDITOR_BG_HEIGHT));
}