Change ImGui title

Make text file functions output to screen when test checkbox is checked.
This commit is contained in:
kelson8 2025-01-06 13:25:45 -05:00
parent 26e3acf9eb
commit 42956372a7
5 changed files with 117 additions and 7 deletions

View File

@ -212,6 +212,12 @@
<AdditionalDependencies>d3d9.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Directx9|Win32'">
<Link>
<AdditionalLibraryDirectories>.\lib\KCNet-TestDll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>KCNet-TestDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="lib\ImGui\backends\imgui_impl_opengl3.cpp" /> <ClCompile Include="lib\ImGui\backends\imgui_impl_opengl3.cpp" />
<ClCompile Include="Main.cpp" /> <ClCompile Include="Main.cpp" />
@ -223,8 +229,10 @@
<ClCompile Include="lib\ImGui\imgui_tables.cpp" /> <ClCompile Include="lib\ImGui\imgui_tables.cpp" />
<ClCompile Include="lib\ImGui\imgui_widgets.cpp" /> <ClCompile Include="lib\ImGui\imgui_widgets.cpp" />
<ClCompile Include="menus\main_menu.cpp" /> <ClCompile Include="menus\main_menu.cpp" />
<ClCompile Include="test\constructor_test.cpp" />
<ClCompile Include="test\directx9_test.cpp" /> <ClCompile Include="test\directx9_test.cpp" />
<ClCompile Include="test\opengl_test.cpp" /> <ClCompile Include="test\opengl_test.cpp" />
<ClCompile Include="menus\text_menu.cpp" />
<ClCompile Include="util\keystates.cpp" /> <ClCompile Include="util\keystates.cpp" />
<ClCompile Include="util\text_file_functions.cpp" /> <ClCompile Include="util\text_file_functions.cpp" />
<ClCompile Include="util\text_functions.cpp" /> <ClCompile Include="util\text_functions.cpp" />
@ -242,8 +250,10 @@
<ClInclude Include="lib\ImGui\imstb_truetype.h" /> <ClInclude Include="lib\ImGui\imstb_truetype.h" />
<ClInclude Include="menus\main_menu.h" /> <ClInclude Include="menus\main_menu.h" />
<ClInclude Include="menus\pch.h" /> <ClInclude Include="menus\pch.h" />
<ClInclude Include="test\constructor_test.h" />
<ClInclude Include="test\directx9_test.h" /> <ClInclude Include="test\directx9_test.h" />
<ClInclude Include="test\opengl_test.h" /> <ClInclude Include="test\opengl_test.h" />
<ClInclude Include="menus\text_menu.h" />
<ClInclude Include="util\keystates.h" /> <ClInclude Include="util\keystates.h" />
<ClInclude Include="util\text_file_functions.h" /> <ClInclude Include="util\text_file_functions.h" />
<ClInclude Include="util\text_functions.h" /> <ClInclude Include="util\text_functions.h" />

View File

@ -4,8 +4,8 @@ Size=400,400
Collapsed=1 Collapsed=1
[Window][Dear ImGui Demo] [Window][Dear ImGui Demo]
Pos=652,43 Pos=638,72
Size=550,680 Size=550,681
[Window][Hello, world!] [Window][Hello, world!]
Pos=116,183 Pos=116,183
@ -35,6 +35,10 @@ Size=499,136
IsChild=1 IsChild=1
Size=200,100 Size=200,100
[Window][KCNet ImGui]
Pos=113,150
Size=505,566
[Table][0x64418101,3] [Table][0x64418101,3]
RefScale=13 RefScale=13
Column 0 Width=63 Column 0 Width=63
@ -46,3 +50,65 @@ Column 0 Weight=1.0000
Column 1 Weight=1.0000 Column 1 Weight=1.0000
Column 2 Weight=1.0000 Column 2 Weight=1.0000
[Table][0xC9935533,3]
Column 0 Weight=1.0000
Column 1 Weight=1.0000
Column 2 Weight=1.0000
[Table][0x47600645,3]
RefScale=13
Column 0 Width=63
Column 1 Width=63
Column 2 Weight=1.0000
[Table][0xDE6957FF,6]
RefScale=13
Column 0 Width=63
Column 1 Width=63
Column 2 Width=-1
Column 3 Weight=1.0000
Column 4 Weight=1.0000
Column 5 Weight=-1.0000
[Table][0x861D378E,3]
Column 0 Weight=1.0000
Column 1 Weight=1.0000
Column 2 Weight=1.0000
[Table][0x1F146634,3]
RefScale=13
Column 0 Width=63
Column 1 Width=63
Column 2 Width=63
[Table][0x8DFA6E86,2]
Column 0 Weight=1.0000
Column 1 Weight=1.0000
[Table][0xFABAAEF7,2]
Column 0 Weight=1.0000
Column 1 Weight=1.0000
[Table][0xA43C3885,3]
RefScale=13
Column 0 Width=56
Column 1 Width=56
Column 2 Width=56
[Table][0x49F8DCEA,3]
RefScale=13
Column 0 Weight=1.0000
Column 1 Width=84
Column 2 Width=126
[Table][0x82CBB907,3]
Column 0 Weight=1.0000
Column 1 Weight=1.0000
Column 2 Weight=1.0000
[Table][0x49D11DC0,3]
RefScale=13
Column 0 Width=86
Column 1 Width=86
Column 2 Width=86

View File

@ -162,9 +162,9 @@ void DirectX9Test::directX9Test()
// Create application window // Create application window
//ImGui_ImplWin32_EnableDpiAwareness(); //ImGui_ImplWin32_EnableDpiAwareness();
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr }; WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"KCNet ImGui", nullptr };
::RegisterClassExW(&wc); ::RegisterClassExW(&wc);
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX9 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr); HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"KCNet ImGui", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr);
// Initialize Direct3D // Initialize Direct3D
if (!CreateDeviceD3D(hwnd)) if (!CreateDeviceD3D(hwnd))

View File

@ -3,6 +3,10 @@
#include <fstream> #include <fstream>
#include "text_file_functions.h" #include "text_file_functions.h"
// Add in ImGui for output text file to screen.
#include "imgui.h"
#include "imgui_impl_dx9.h"
// Checking if the file exists breaks without this // Checking if the file exists breaks without this
// https://stackoverflow.com/questions/19321804/this-function-or-variable-may-be-unsafe-visual-studio // https://stackoverflow.com/questions/19321804/this-function-or-variable-may-be-unsafe-visual-studio
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS #pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS
@ -56,12 +60,38 @@ void TextFileFunctions::readTextFile(std::string file)
#define _TEST #define _TEST
#endif #endif
// This works
// Some code from Google AI:///
void TextFileFunctions::outputTextFileContents(const char* filePath) {
std::ifstream myfile(filePath);
if (myfile.is_open())
{
std::string line;
std::string content;
// Output file contents
while (std::getline(myfile, line))
{
content += line + "\n";
}
// Close the file
myfile.close();
ImGui::Text("\"%s\" File contents: \n%s", filePath, &content);
//ImGui::InputTextMultiline();
}
else
{
ImGui::Text("Error opening file %s", filePath);
}
}
// Add test function for this, I need to figure out how to return an array like this. // Add test function for this, I need to figure out how to return an array like this.
#ifdef _TEST #ifdef _TEST
// This prints the text file output to the console but spams it, I probably won't use this much.
void TextFileFunctions::printTextOutput(std::string file) void TextFileFunctions::printTextOutput(std::string file)
{ {
//std::string line;
//std::string line[1000];
std::string line; std::string line;
std::ifstream myfile(file); std::ifstream myfile(file);
@ -72,7 +102,8 @@ void TextFileFunctions::printTextOutput(std::string file)
{ {
while (std::getline(myfile, line)) while (std::getline(myfile, line))
{ {
std::cout << line << '\n'; // Disabled for now
//std::cout << line << '\n';
//return line; //return line;
} }

View File

@ -5,4 +5,7 @@ public:
static void readTextFile(std::string file); static void readTextFile(std::string file);
//static std::string printTextOutput(std::string file); //static std::string printTextOutput(std::string file);
static void printTextOutput(std::string file); static void printTextOutput(std::string file);
static void outputTextFileContents(const char* filePath);
}; };