Remove the input playback. I do not like it.
This commit is contained in:
+1
-123
@@ -321,7 +321,7 @@ static void HandleEvent(SDL_Event *Event)
|
||||
} break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST: {
|
||||
if(SDL_SetWindowOpacity(Window, 0.3f) != 0) {
|
||||
if(SDL_SetWindowOpacity(Window, 0.1f) != 0) {
|
||||
/* TODO: This didn't work . . . SDL_GetError() */
|
||||
}
|
||||
} break;
|
||||
@@ -331,105 +331,6 @@ static void HandleEvent(SDL_Event *Event)
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLGetInputFileLocation(sdl_state *SDLState, char *path,
|
||||
size_t path_size, S32 SlotIndex)
|
||||
{
|
||||
const char *file_name = "loop.hmi";
|
||||
|
||||
ASSERT(SlotIndex == 1);
|
||||
|
||||
snprintf(path, path_size, "%s%s", SDLState->EXEDirPath, file_name);
|
||||
}
|
||||
|
||||
sdl_replay_buffer *SDLGetReplayBuffer(sdl_state *SDLState,
|
||||
S32 Index)
|
||||
{
|
||||
ASSERT(Index < (S32)ARRAY_SIZE(SDLState->ReplayBuffers));
|
||||
return &(SDLState->ReplayBuffers[Index]);
|
||||
}
|
||||
|
||||
static void SDLBeginRecordingInput(sdl_state *SDLState,
|
||||
S32 InputRecordingIndex)
|
||||
{
|
||||
sdl_replay_buffer *ReplayBuffer =
|
||||
SDLGetReplayBuffer(SDLState, InputRecordingIndex);
|
||||
if(ReplayBuffer->MemoryBlock) {
|
||||
char FileName[SDL_STATE_PATH_SIZE];
|
||||
|
||||
SDLGetInputFileLocation(SDLState, FileName, sizeof(FileName),
|
||||
InputRecordingIndex);
|
||||
|
||||
SDLState->InputRecordingIndex = InputRecordingIndex;
|
||||
|
||||
if(unlink(FileName) != 0) {
|
||||
/* TODO: Diagnostics . . . */
|
||||
}
|
||||
|
||||
SDLState->RecordingHandle =
|
||||
open(FileName, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR |
|
||||
S_IRGRP | S_IROTH);
|
||||
/* write(SDLState->RecordingHandle, SDLState->GameMmemoryBlock,
|
||||
(size_t)(SDLState->TotalSize)); */
|
||||
memcpy(ReplayBuffer->MemoryBlock, SDLState->GameMmemoryBlock,
|
||||
(size_t)(SDLState->TotalSize));
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLEndRecordingInput(sdl_state *SDLState)
|
||||
{
|
||||
close(SDLState->RecordingHandle);
|
||||
SDLState->InputRecordingIndex = 0;
|
||||
}
|
||||
|
||||
static void SDLBeginInputPlayback(sdl_state *SDLState,
|
||||
S32 InputPlayingIndex)
|
||||
{
|
||||
sdl_replay_buffer *ReplayBuffer =
|
||||
SDLGetReplayBuffer(SDLState, InputPlayingIndex);
|
||||
if(ReplayBuffer->MemoryBlock) {
|
||||
char FileName[SDL_STATE_PATH_SIZE];
|
||||
ssize_t size;
|
||||
|
||||
SDLGetInputFileLocation(SDLState, FileName, sizeof(FileName),
|
||||
InputPlayingIndex);
|
||||
|
||||
SDLState->InputPlayingIndex = InputPlayingIndex;
|
||||
SDLState->PlaybackHandle =
|
||||
open(FileName, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR |
|
||||
S_IRGRP | S_IROTH);
|
||||
/* size = read(SDLState->PlaybackHandle, SDLState->GameMmemoryBlock,
|
||||
(size_t)(SDLState->TotalSize)); */
|
||||
memcpy(SDLState->GameMmemoryBlock, ReplayBuffer->MemoryBlock,
|
||||
(size_t)(SDLState->TotalSize));
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLEndInputPlayback(sdl_state *SDLState)
|
||||
{
|
||||
close(SDLState->PlaybackHandle);
|
||||
SDLState->InputPlayingIndex = 0;
|
||||
}
|
||||
|
||||
static void SDLRecordInput(sdl_state *SDLState, game_input *NewInput)
|
||||
{
|
||||
write(SDLState->RecordingHandle, NewInput, sizeof(*NewInput));
|
||||
}
|
||||
|
||||
static void SDLPlaybackInput(sdl_state *SDLState, game_input *NewInput)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = read(SDLState->PlaybackHandle, NewInput, sizeof(*NewInput));
|
||||
if(size == 0 || size == -1) {
|
||||
S32 PlayingIndex;
|
||||
|
||||
PlayingIndex = SDLState->InputPlayingIndex;
|
||||
SDLEndInputPlayback(SDLState);
|
||||
SDLBeginInputPlayback(SDLState, PlayingIndex);
|
||||
size = read(SDLState->PlaybackHandle, NewInput, sizeof(*NewInput));
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLProcessMessages(sdl_state *SDLState,
|
||||
game_controller_input *KeyboardController)
|
||||
{
|
||||
@@ -505,22 +406,6 @@ static void SDLProcessMessages(sdl_state *SDLState,
|
||||
if(WasDown) {
|
||||
B32 AltKeyWasDown;
|
||||
|
||||
#if BUILD_INTERNAL
|
||||
|
||||
if(KeyCode == SDLK_l) {
|
||||
if(SDLState->InputPlayingIndex == 0) {
|
||||
if(SDLState->InputRecordingIndex == 0) {
|
||||
SDLBeginRecordingInput(SDLState, 1);
|
||||
} else {
|
||||
SDLEndRecordingInput(SDLState);
|
||||
SDLBeginInputPlayback(SDLState, 1);
|
||||
}
|
||||
} else {
|
||||
SDLEndInputPlayback(SDLState);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* NOTE: If your window manager already uses an Alt+F4
|
||||
* keybind to close programs, then we are likely
|
||||
* to see SDL_QUIT event occur before our
|
||||
@@ -1136,13 +1021,6 @@ S32 main(S32 argc, char *argv[])
|
||||
Buffer.BytesPerPixel = 4;
|
||||
Buffer.Pitch = GlobalBackbuffer.Pitch;
|
||||
|
||||
if(SDLState.InputRecordingIndex) {
|
||||
SDLRecordInput(&SDLState, NewInput);
|
||||
}
|
||||
if(SDLState.InputPlayingIndex) {
|
||||
SDLPlaybackInput(&SDLState, NewInput);
|
||||
}
|
||||
|
||||
if(Game.UpdateAndRender) {
|
||||
Game.UpdateAndRender(&Context, &GameMemory,
|
||||
NewInput, &Buffer,
|
||||
|
||||
Reference in New Issue
Block a user