summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ceef3cf)
raw | patch | inline | side by side (parent: ceef3cf)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 28 Sep 2017 14:00:42 +0000 (17:00 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 28 Sep 2017 14:01:31 +0000 (17:01 +0300) |
diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas
index 5cf17a788264ffc00dde1b8f1e524135680878a0..7783734b7df3fac31c364efff201f31bdcdd6a04 100644 (file)
--- a/src/engine/e_input.pas
+++ b/src/engine/e_input.pas
function e_InitInput(): Boolean;
procedure e_ReleaseInput();
procedure e_ClearInputBuffer();
-function e_PollInput(): Boolean;
+//function e_PollInput(): Boolean;
+procedure e_PollJoysticks(); // call this from message loop to update joysticks
function e_KeyPressed(Key: Word): Boolean;
function e_AnyKeyPressed(): Boolean;
function e_GetFirstKeyPressed(): Word;
}
end;
-function PollJoysticks(): Boolean;
+procedure e_PollJoysticks();
var
i, j: Word;
hat: Byte;
begin
- Result := False;
+ //Result := False;
if (Joysticks = nil) or (e_JoysticksAvailable = 0) then Exit;
SDL_JoystickUpdate();
for j := Low(Joysticks) to High(Joysticks) do
+ begin
with Joysticks[j] do
begin
- for i := 0 to Buttons do
- ButtBuf[i] := SDL_JoystickGetButton(Handle, i) <> 0;
- for i := 0 to Axes do
- AxisBuf[i] := SDL_JoystickGetAxis(Handle, i);
+ for i := 0 to Buttons do ButtBuf[i] := SDL_JoystickGetButton(Handle, i) <> 0;
+ for i := 0 to Axes do AxisBuf[i] := SDL_JoystickGetAxis(Handle, i);
for i := 0 to Hats do
begin
hat := SDL_JoystickGetHat(Handle, i);
HatBuf[i, HAT_RIGHT] := LongBool(hat and SDL_HAT_RIGHT);
end;
end;
+ end;
end;
procedure GenerateKeyNames();
end;
end;
+{
function e_PollInput(): Boolean;
var
kb, js: Boolean;
begin
kb := PollKeyboard();
- js := PollJoysticks();
+ js := e_PollJoysticks();
Result := kb or js;
end;
+}
function e_KeyPressed(Key: Word): Boolean;
var
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 53280381f8b390f9e16819f49786a3fd90e0cfc0..a505edc1cb44adbedd6af288142b102a4acd815f 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
Exit;
end;
-// ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî:
- e_PollInput();
+ // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
+ // no need to, as we'll do it in event handler
// Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
g_Console_Update();
begin
e_TextureFontGetSize(gStdFont, ww2, hh2);
- e_PollInput();
+ g_ProcessMessages();
+
if e_KeyPressed(IK_TAB) then
begin
if not gStatsPressed then
enet_packet_destroy(NetEvent.packet);
end
else
+ begin
if (NetEvent.kind = ENET_EVENT_TYPE_DISCONNECT) then
begin
State := 0;
OuterLoop := False;
Break;
end;
+ end;
end;
ProcessLoading(true);
- e_PollInput();
-
if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
begin
State := 0;
diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index 85263e51e7e709388809188f5c664c832f9f84e3..6d06e978e5251b8215289069a53f600a3be55cbb 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
ProcessLoading(true);
- e_PollInput();
-
if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
OuterLoop := False;
end;
ProcessLoading(true);
- e_PollInput();
-
if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
break;
end;
index 9e96a451f43f07326a693a2b78775945899ad2ea..14970abb766180a382834ccf10bf0b61c042305c 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
end;
procedure g_Serverlist_Control(var SL: TNetServerList);
+var
+ qm: Boolean;
begin
if gConsoleShow or gChatShow then
Exit;
- e_PollInput();
+ qm := g_ProcessMessages(); // this updates kbd
- if e_KeyPressed(IK_ESCAPE) then
+ if qm or e_KeyPressed(IK_ESCAPE) then
begin
SL := nil;
gState := STATE_MENU;
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index 37aac9da3d198269795ff608afd161a840d84d41..b24c6fa2db331f3c776c9002329bdf81c9b16c48 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
wadoptFast := gSFSFastMode;
e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', 'megawads/DOOM2D.WAD:\MAP01');
- gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitch', False);
+ gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True);
// Ãåéìïëåé â ñâîåé èãðå
gcMap := config.ReadStr('GameplayCustom', 'Map', '');
config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
- config.WriteBool('Game', 'BerserkAutoswitch', gBerserkAutoswitch);
+ config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
config.WriteStr ('GameplayCustom', 'Map', gcMap);
config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index bcad3ca07b1ce6a1cd202e0a9613928ce45ad840..b03214f79289ddf17b1d59b3302ee25bdf56844c 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
else
g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj.X, FObj.Y);
- if gFlash = 1 then
- if FPain < 50 then
- FPain := min(FPain + 25, 50);
- end else g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 3, FUID);
+ if (gFlash = 1) and (FPain < 50) then FPain := min(FPain + 25, 50);
+ end
+ else
+ begin
+ g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 3, FUID);
+ end;
DidFire := True;
FReloading[FCurrWeap] := WEAPON_RELOAD[FCurrWeap];
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 863072ce1188bf94fb59aed443671c630bae44a2..12a038f68950f620a4c804e6d7d7078b65b60946 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
procedure ProcessLoading (forceUpdate: Boolean=false);
+// returns `true` if quit event was received
+function g_ProcessMessages (): Boolean;
+
var
gwin_dump_extensions: Boolean = false;
while (SDL_PollEvent(@ev) > 0) do
begin
+ EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then break;
end;
+ e_PollJoysticks();
if (ev.type_ = SDL_QUITEV) or (gExit = EXIT_QUIT) then
begin
end;
-function ProcessMessage (): Boolean;
+function g_ProcessMessages (): Boolean;
var
- i, t: Integer;
ev: TSDL_Event;
begin
result := false;
FillChar(ev, SizeOf(ev), 0);
-
while (SDL_PollEvent(@ev) > 0) do
begin
result := EventHandler(ev);
if (ev.type_ = SDL_QUITEV) then exit;
end;
+ e_PollJoysticks();
+end;
+
+
+function ProcessMessage (): Boolean;
+var
+ i, t: Integer;
+begin
+ result := g_ProcessMessages();
Time := GetTimer();
Time_Delta := Time-Time_Old;