fna-workbench

fna-workbench Commit Details


Date:2016-01-13 15:27:50 (9 years 7 months ago)
Author:Ethan Lee
Branch:master
Commit:673fafc0f3dcc3f05cfdd175944992f6b9509a38
Parents: 55c73560a5e993a34dcf8973a7a4b42d0a4fab5c
Message:Shrink SDL2_GamePlatform instance variable list

Changes:

File differences

src/Game.cs
216216
217217
218218
219
220
219221
220222
221223
......
291293
292294
293295
296
297
298
294299
295300
296301
......
396401
397402
398403
399
404
400405
401406
402407
internal GamePlatform Platform;
internal bool RunApplication;
#endregion
#region Private Fields
_services.AddService(typeof(GamePlatform), Platform);
AudioDevice.Initialize();
// Ready to run the loop!
RunApplication = true;
}
#endregion
public void Exit()
{
Platform.Exit();
RunApplication = false;
_suppressDraw = true;
}
src/GamePlatform.cs
9191
9292
9393
94
95
96
97
98
9994
10095
10196
public abstract void BeforeInitialize();
/// <summary>
/// When implemented in a derived class, ends the active run loop.
/// </summary>
public abstract void Exit();
/// <summary>
/// When implemented in a derived class, starts the run loop and blocks
/// until it has ended.
/// </summary>
src/SDL2/SDL2_GamePlatform.cs
4646
4747
4848
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
6949
7050
7151
......
152132
153133
154134
155
156
157
158
159
160
161
162
163
164
165
166
167135
168136
169137
......
174142
175143
176144
145
146
147
148
149
150
151
152
153
154
177155
178156
179
157
180158
181159
182160
......
191169
192170
193171
194
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
195197
196198
197199
......
203205
204206
205207
206
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
207225
208226
209227
......
355373
356374
357375
358
376
359377
360378
361379
362380
363
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
364397
365398
366399
......
370403
371404
372405
373
374
375
376
377
378
379406
380407
381408
......
836863
837864
838865
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913866
914867
915868
#endregion
#region Private Game Loop Sentinel
private bool INTERNAL_runApplication;
#endregion
#region Private Active XNA Key List
private List<Keys> keys;
#endregion
#region Private Text Input Variables
private int[] INTERNAL_TextInputControlRepeat;
private bool[] INTERNAL_TextInputControlDown;
private bool INTERNAL_TextInputSuppress;
#endregion
#region Private DisplayMode Variables
private int displayIndex = 0;
{
INTERNAL_useFullscreenSpaces = false;
}
// Initialize Active Key List
keys = new List<Keys>();
/* Setup Text Input Control Character Arrays
* (Only 4 control keys supported at this time)
*/
INTERNAL_TextInputControlDown = new bool[4];
INTERNAL_TextInputControlRepeat = new int[4];
// Ready to run the loop!
INTERNAL_runApplication = true;
}
#endregion
{
SDL.SDL_ShowWindow(Game.Window.Handle);
// Active Key List
List<Keys> keys = new List<Keys>();
/* Setup Text Input Control Character Arrays
* (Only 4 control keys supported at this time)
*/
bool[] INTERNAL_TextInputControlDown = new bool[4];
int[] INTERNAL_TextInputControlRepeat = new int[4];
bool INTERNAL_TextInputSuppress = false;
SDL.SDL_Event evt;
while (INTERNAL_runApplication)
while (Game.RunApplication)
{
while (SDL.SDL_PollEvent(out evt) == 1)
{
if (!keys.Contains(key))
{
keys.Add(key);
INTERNAL_TextInputIn(key);
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = true;
INTERNAL_TextInputControlRepeat[0] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 8); // Backspace
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = true;
INTERNAL_TextInputControlRepeat[1] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 9); // Tab
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = true;
INTERNAL_TextInputControlRepeat[2] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 13); // Enter
}
else if (keys.Contains(Keys.LeftControl) && key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = true;
INTERNAL_TextInputControlRepeat[3] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 22); // Control-V (Paste)
INTERNAL_TextInputSuppress = true;
}
}
}
else if (evt.type == SDL.SDL_EventType.SDL_KEYUP)
#endif
if (keys.Remove(key))
{
INTERNAL_TextInputOut(key);
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = false;
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = false;
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = false;
}
else if ((!keys.Contains(Keys.LeftControl) && INTERNAL_TextInputControlDown[3]) || key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = false;
INTERNAL_TextInputSuppress = false;
}
}
}
// Quit
else if (evt.type == SDL.SDL_EventType.SDL_QUIT)
{
INTERNAL_runApplication = false;
Game.RunApplication = false;
break;
}
}
// Text Input Controls Key Handling
INTERNAL_TextInputUpdate();
if (INTERNAL_TextInputControlDown[0] && INTERNAL_TextInputControlRepeat[0] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 8);
}
if (INTERNAL_TextInputControlDown[1] && INTERNAL_TextInputControlRepeat[1] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 9);
}
if (INTERNAL_TextInputControlDown[2] && INTERNAL_TextInputControlRepeat[2] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 13);
}
if (INTERNAL_TextInputControlDown[3] && INTERNAL_TextInputControlRepeat[3] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 22);
}
Keyboard.SetKeys(keys);
Game.Tick();
Game.Exit();
}
public override void Exit()
{
// Stop the game loop
INTERNAL_runApplication = false;
}
public override void BeforeInitialize()
{
// We want to initialize the controllers ASAP!
#endregion
#region Private TextInput Methods
private void INTERNAL_TextInputIn(Keys key)
{
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = true;
INTERNAL_TextInputControlRepeat[0] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 8); // Backspace
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = true;
INTERNAL_TextInputControlRepeat[1] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 9); // Tab
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = true;
INTERNAL_TextInputControlRepeat[2] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 13); // Enter
}
else if (keys.Contains(Keys.LeftControl) && key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = true;
INTERNAL_TextInputControlRepeat[3] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 22); // Control-V (Paste)
INTERNAL_TextInputSuppress = true;
}
}
private void INTERNAL_TextInputOut(Keys key)
{
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = false;
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = false;
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = false;
}
else if ((!keys.Contains(Keys.LeftControl) && INTERNAL_TextInputControlDown[3]) || key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = false;
INTERNAL_TextInputSuppress = false;
}
}
private void INTERNAL_TextInputUpdate()
{
if (INTERNAL_TextInputControlDown[0] && INTERNAL_TextInputControlRepeat[0] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 8);
}
if (INTERNAL_TextInputControlDown[1] && INTERNAL_TextInputControlRepeat[1] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 9);
}
if (INTERNAL_TextInputControlDown[2] && INTERNAL_TextInputControlRepeat[2] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 13);
}
if (INTERNAL_TextInputControlDown[3] && INTERNAL_TextInputControlRepeat[3] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 22);
}
}
#endregion
#region Private Static SDL_Surface Interop
[StructLayout(LayoutKind.Sequential)]

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.58482s using 13 queries.