Skip to content

Commit

Permalink
-Implement tracking of global frame count
Browse files Browse the repository at this point in the history
-Add new (togglable) text feed info header element for global frame count
-Add new console commands:
  - fps: Prints current FPS to console
  - frame_count: Prints current global frame count to console
  - global_frame_count: alias for frame_count
  - text_feed_frame_count: prints whether global frame count element of text feed info header is enabled, and enables/disables the element if a boolean argument is provided
- Change title of external console output window from "Console Log" to "Console Output"
  • Loading branch information
SeanPesce committed Dec 12, 2017
1 parent 6a45015 commit 47ee2a8
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 32 deletions.
3 changes: 2 additions & 1 deletion include/SpD3D9OTextFeed.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum SP_D3D9O_TEXT_FEED_INFO_BAR_ENUM {
SP_D3D9O_INFO_BAR_TITLE = 1,
SP_D3D9O_INFO_BAR_DATE = 2,
SP_D3D9O_INFO_BAR_TIME = 4,
SP_D3D9O_INFO_BAR_FPS = 8
SP_D3D9O_INFO_BAR_FPS = 8,
SP_D3D9O_INFO_BAR_FRAME_COUNT = 16
};


Expand Down
4 changes: 4 additions & 0 deletions include/SpD3D9Overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class SpD3D9Overlay
SpD3D9Interface *d3d_interface = NULL;
SpD3D9Device *device = NULL;

// Global frame count
static unsigned long long frame_count;

// Overlay member data
SpD3D9OTextFeed *text_feed = NULL;
SpD3D9OConsole *console = NULL;
Expand All @@ -151,6 +154,7 @@ class SpD3D9Overlay
IDirect3DStateBlock9 *overlay_state_block = NULL; // State block applied before drawing overlay
unsigned int fps_count = 0;
unsigned int fps_timer_id = 0; // ID of timer used to update FPS count once per second


static bool run_plugin_funcs;
static std::list<SP_D3D9_PLUGIN> loaded_libraries;
Expand Down
1 change: 1 addition & 0 deletions include/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#define _SP_D3D9_OL_TXT_STYLE_KEY_ "OverlayTextStyle"
#define _SP_D3D9_OL_TXT_AUDIO_ENABLED_KEY_ "EnableAudioFeedback"
#define _SP_D3D9_OL_TXT_ENABLE_FPS_KEY_ "DisplayFPS"
#define _SP_D3D9_OL_TXT_ENABLE_FRAME_COUNT_KEY_ "DisplayFrameCount"
#define _SP_D3D9_OL_TXT_ENABLE_TIME_KEY_ "DisplayTime"
#define _SP_D3D9_OL_TXT_ENABLE_DATE_KEY_ "DisplayDate"
// Developer keybinds section key names
Expand Down
2 changes: 1 addition & 1 deletion src/SpD3D9Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ HRESULT SpD3D9Device::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HW


present_calls++; // Increment Present() call counter for the current second

SpD3D9Overlay::frame_count++; // Increment global frame count
// Call original routine
_SP_D3D9_CHECK_AND_RETURN_FAILED_(m_pIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion));
}
Expand Down
4 changes: 2 additions & 2 deletions src/SpD3D9OConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void SpD3D9OConsole::open_output_window()
// Command-line command to launch the external console output window
//char *start_command_parts[2] = { "cmd /V:ON /C \"@ECHO OFF&TITLE Console Log&CD /D\"", "\"&SET \"d3d9_output_line= \"&FOR /l %x IN (1, 0, 1) DO (SET /p d3d9_output_line=\"\" & ECHO:!d3d9_output_line! & SET \"d3d9_output_line= \")\"" };
//std::string start_command = std::string(start_command_parts[0]).append(game_exe_dir).append(start_command_parts[1]);
char *start_command_parts[2] = { "cmd /V:ON /C \"@ECHO OFF&TITLE Console Log", "&SET \"d3d9_output_line= \"&FOR /l %x IN (1, 0, 1) DO (SET /p d3d9_output_line=\"\" & ECHO:!d3d9_output_line! & SET \"d3d9_output_line= \")\"" };
char *start_command_parts[2] = { "cmd /V:ON /C \"@ECHO OFF&TITLE Console Output", "&SET \"d3d9_output_line= \"&FOR /l %x IN (1, 0, 1) DO (SET /p d3d9_output_line=\"\" & ECHO:!d3d9_output_line! & SET \"d3d9_output_line= \")\"" };
std::string start_command = std::string(start_command_parts[0]).append(start_command_parts[1]);

// Initialize the startup information for the child process
Expand Down Expand Up @@ -1932,7 +1932,7 @@ void SpD3D9OConsole::set_input_string_display_limits(unsigned int max_input_char
command_length = command.length();
}

if (command_length > max_input_chars)
if (command_length > (int)max_input_chars)
{
if (caret_position > input_display_end)
{
Expand Down
117 changes: 89 additions & 28 deletions src/SpD3D9OConsoleCommands.cpp

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/SpD3D9OTextFeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,15 @@ void SpD3D9OTextFeed::update_info_header()
info_string.append(" FPS] ");
}

if (show_info_bar & SP_D3D9O_INFO_BAR_FRAME_COUNT)
{
// Insert global frame count into text feed info string
info_string.append("[Frame count: ");
unsigned long long current_frame_count = overlay->frame_count; // Get FPS count
info_string.append(std::to_string(current_frame_count));
info_string.append("] ");
}


// Add live info bar elements from plugins
info_string.append(info_bar_plugin_elements);
Expand Down
3 changes: 3 additions & 0 deletions src/SpD3D9Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
bool SpD3D9Overlay::run_plugin_funcs = true;
std::list<SP_D3D9_PLUGIN> SpD3D9Overlay::loaded_libraries;

// Global frame count
unsigned long long SpD3D9Overlay::frame_count = 0;


SpD3D9Overlay::SpD3D9Overlay(SpD3D9Interface *new_interface, SpD3D9Device *new_device, HWND new_focus_window, D3DPRESENT_PARAMETERS *present_params)
{
Expand Down
1 change: 1 addition & 0 deletions src/SpD3D9SwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ HRESULT SpD3D9SwapChain::Present(const RECT *pSourceRect, const RECT *pDestRect,
}

(*present_calls)++;
SpD3D9Overlay::frame_count++; // Increment global frame count
HRESULT hres = m_pD3D9_swap_chain->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
return hres;
}

0 comments on commit 47ee2a8

Please sign in to comment.